2 * @brief General purpose macros.
15 #define model_print(fmt, ...) do { \
16 char mprintbuf[256]; \
17 int printbuflen=snprintf_(mprintbuf, 256, fmt, ## __VA_ARGS__); \
18 int lenleft = printbuflen < 256 ? printbuflen : 256; \
19 int totalwritten = 0; \
21 int byteswritten=write(model_out, &mprintbuf[totalwritten], lenleft); \
22 lenleft-=byteswritten; \
23 totalwritten+=byteswritten; \
28 #define DEBUG(fmt, ...) do { model_print("*** %15s:%-4d %25s() *** " fmt, __FILE__, __LINE__, __func__, ## __VA_ARGS__); } while (0)
29 #define DBG() DEBUG("\n")
30 #define DBG_ENABLED() (1)
32 #define DEBUG(fmt, ...)
34 #define DBG_ENABLED() (0)
37 void assert_hook(void);
40 #define ASSERT(expr) \
43 fprintf(stderr, "Error: assertion failed in %s at line %d\n", __FILE__, __LINE__); \
44 /* print_trace(); // Trace printing may cause dynamic memory allocation */ \
46 _Exit(EXIT_FAILURE); \
50 #define ASSERT(expr) \
52 #endif /* CONFIG_ASSERT */
54 #define error_msg(...) fprintf(stderr, "Error: " __VA_ARGS__)
56 void print_trace(void);
57 #endif /* __COMMON_H__ */