mirror of
https://gitlab.com/80486DX2-66/gists
synced 2025-01-10 08:27:48 +05:30
reverse-ramdisk.c: put all macros together and move them
This commit is contained in:
parent
015b81fb25
commit
4f396bb3ce
@ -19,6 +19,19 @@ To-Do: error handling on line 167, function fread()
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef DEBUG
|
||||
# define line_fail(x) do { \
|
||||
printf("failed on line %d\n", __LINE__ + x); \
|
||||
} while (0)
|
||||
#else
|
||||
# define line_fail(x) do {} while (0)
|
||||
#endif
|
||||
|
||||
#define retreat(s) do { \
|
||||
perror(s); \
|
||||
exit(EXIT_FAILURE); \
|
||||
} while (0)
|
||||
|
||||
typedef struct {
|
||||
int ID;
|
||||
char* file_path;
|
||||
@ -33,14 +46,6 @@ int tf_free(int ID);
|
||||
int tf_write(int ID, size_t offset, void* data, size_t data_size);
|
||||
int tf_read(int ID, size_t offset, void* dest, size_t data_size);
|
||||
|
||||
#ifdef DEBUG
|
||||
# define line_fail(x) do { \
|
||||
printf("failed on line %d\n", __LINE__ + x); \
|
||||
} while (0)
|
||||
#else
|
||||
# define line_fail(x) do {} while (0)
|
||||
#endif
|
||||
|
||||
int tf_alloc(size_t n, size_t type_size) {
|
||||
// Create an empty file
|
||||
size_t len_digit;
|
||||
@ -190,11 +195,6 @@ int tf_read(int ID, size_t offset, void* dest, size_t data_size) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define retreat(s) do { \
|
||||
perror(s); \
|
||||
exit(EXIT_FAILURE); \
|
||||
} while (0)
|
||||
|
||||
#ifdef TEST
|
||||
int main(void) {
|
||||
int ID = tf_alloc(4, sizeof(int));
|
||||
|
Loading…
x
Reference in New Issue
Block a user