X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=common.h;h=80bc9ad6e8c6977fb3622b8754c1982cf64c25f5;hb=70515e16c177a40e1053285262ff34e10c33e57e;hp=d4823dbfa5895b13a5f960d3f4ff3c9f5d7c3216;hpb=3801569c178bea693d4638de67cff18be78012ea;p=c11tester.git diff --git a/common.h b/common.h index d4823dbf..80bc9ad6 100644 --- a/common.h +++ b/common.h @@ -1,9 +1,12 @@ +/** @file common.h + * @brief General purpose macros. + */ + #ifndef __COMMON_H__ #define __COMMON_H__ #include - -//#define CONFIG_DEBUG +#include "config.h" #ifdef CONFIG_DEBUG #define DEBUG(fmt, ...) do { printf("*** %25s(): line %-4d *** " fmt, __func__, __LINE__, ##__VA_ARGS__); } while (0) @@ -15,10 +18,16 @@ #define DBG_ENABLED() (0) #endif -void * myMalloc(size_t size); -void myFree(void *ptr); +#define ASSERT(expr) \ +do { \ + if (!(expr)) { \ + fprintf(stderr, "Error: assertion failed in %s at line %d\n", __FILE__, __LINE__); \ + exit(EXIT_FAILURE); \ + } \ +} while (0); + +#define error_msg(...) fprintf(stderr, "Error: " __VA_ARGS__) -#define userMalloc(size) malloc(size) -#define userFree(ptr) free(ptr) +void print_trace(void); #endif /* __COMMON_H__ */