17 /*----- debugging arrangements, rather contingent -----*/
23 typedef struct { /* both inclusive */
30 #define DEBUG_FLAG_LIST \
38 #define DF(f) dbg__shift_##f,
43 #define DF(f) dbg_##f = 1 << dbg__shift_##f,
50 #define DEBUGP(f) (!!(debug_flags & dbg_##f))
52 void debug_flush(void);
55 const char *get_vardir(void);
57 #define FMT(f,a) __attribute__((format(printf,f,a)))
58 #define NORET __attribute__((noreturn))
60 #define DEFINE_VWRAPPERF(decls, funcf, otherattribs) \
61 decls void funcf(const char *fmt, ...) FMT(1,2) otherattribs; \
62 decls void funcf(const char *fmt, ...) { \
63 va_list al; va_start(al,fmt); v##funcf(fmt,al); va_end(al); \
66 #define DEBUG_DEFINE_SOME_DEBUGF(fl,funcf) \
67 static void v##funcf(const char *fmt, va_list al) { \
69 vfprintf(debug,fmt,al); \
71 DEFINE_VWRAPPERF(static, funcf, )
73 #define DEBUG_DEFINE_DEBUGF(fl) DEBUG_DEFINE_SOME_DEBUGF(fl,debugf)
76 /*---------- error handling ----------*/
78 void vfatal(const char *fmt, va_list) FMT(1,0) NORET;
79 void fatal(const char *fmt, ...) FMT(1,2) NORET;
81 #define sysassert(what) \
82 ((what) ? (void)0 : sysassert_fail(__FILE__, __LINE__, #what))
84 void sysassert_fail(const char *file, int line, const char *what)
85 __attribute__((noreturn));
88 void *mmalloc(size_t sz);
89 void *mrealloc(void *p, size_t sz);