index: fix copy/paste error
[mit.git] / logging.h
blob09423137032ff6138ec61e31e354d4b5180b67c3
1 #ifndef MODINITTOOLS_LOGGING_H
2 #define MODINITTOOLS_LOGGING_H
4 /* Do we use syslog for messages or stderr? */
5 extern int logging;
7 /* Number of times warn() has been called */
8 extern int warned;
10 void fatal(const char *fmt, ...);
11 void warn(const char *fmt, ...);
13 #define NOFAIL(ptr) do_nofail((ptr), __FILE__, __LINE__, #ptr)
15 #define nofail_asprintf(ptr, ...) \
16 { if (asprintf((ptr), __VA_ARGS__) < 0) do_nofail(NULL, __FILE__, __LINE__, #ptr); }
18 static inline void *do_nofail(void *ptr, const char *file, int line, const char *expr)
20 if (!ptr) {
21 fatal("Memory allocation failure %s line %d: %s.\n",
22 file, line, expr);
24 return ptr;
27 #endif /* MODINITTOOLS_LOGGING_H */