This commit is contained in:
anon 2024-07-17 00:04:36 +02:00
parent 7222328ace
commit 8136db2cc6
2 changed files with 15 additions and 11 deletions

View File

@ -8,6 +8,7 @@
#include "eaxhla.h"
#include "assembler.h"
#include "unix.h"
#include "safety.h"
#include "debug.h"
unsigned int * token_array = NULL;
@ -50,17 +51,6 @@ void dump_variables_to_assembler(void) {
tommy_hashtable_foreach(&symbol_table, dump_variable_to_assembler);
}
// XXX Move these to somewhere more sane
#define check(code) do { \
if (code) { return 1; } \
} while (0)
#define checked_fwrite(src, size, n, file) do { \
if(fwrite (src, size, n, file) != n) { \
return 1; \
} \
} while (0)
static
int write_output(FILE * file) {
// XXX Where can i move these?

14
source/safety.h Normal file
View File

@ -0,0 +1,14 @@
#ifndef SAFETY_H
#define SAFETY_H
#define check(code) do { \
if (code) { return 1; } \
} while (0)
#define checked_fwrite(src, size, n, file) do { \
if(fwrite (src, size, n, file) != n) { \
return 1; \
} \
} while (0)
#endif