build: Build tests in a separate directory
[mit.git] / logging.h
blob2c4a2f3eb968a320bea66938cdc909230c2df7ab
1 #ifndef MODINITTOOLS_LOGGING_H
2 #define MODINITTOOLS_LOGGING_H
4 /* Do we use syslog for messages or stderr? */
5 extern int logging;
7 /* Do we want to silent drop all warnings? */
8 extern int quiet;
10 /* Number of times warn() has been called */
11 extern int warned;
13 extern void fatal(const char *fmt, ...);
14 extern void warn(const char *fmt, ...);
16 #define NOFAIL(ptr) do_nofail((ptr), __FILE__, __LINE__, #ptr)
18 #define nofail_asprintf(ptr, ...) \
19 { if (asprintf((ptr), __VA_ARGS__) < 0) do_nofail(NULL, __FILE__, __LINE__, #ptr); }
21 static inline void *do_nofail(void *ptr, const char *file, int line, const char *expr)
23 if (!ptr) {
24 fatal("Memory allocation failure %s line %d: %s.\n",
25 file, line, expr);
27 return ptr;
30 #endif /* MODINITTOOLS_LOGGING_H */