blob: ad53d403c78035a33cd39a71141cf7ad427c89f1 [file] [log] [blame]
#ifndef MODINITTOOLS_LOGGING_H
#define MODINITTOOLS_LOGGING_H
/* Do we use syslog for messages or stderr? */
extern int logging;
/* Number of times warn() has been called */
extern int warned;
extern void fatal(const char *fmt, ...);
extern void warn(const char *fmt, ...);
#define NOFAIL(ptr) do_nofail((ptr), __FILE__, __LINE__, #ptr)
#define nofail_asprintf(ptr, ...) \
{ if (asprintf((ptr), __VA_ARGS__) < 0) do_nofail(NULL, __FILE__, __LINE__, #ptr); }
static inline void *do_nofail(void *ptr, const char *file, int line, const char *expr)
{
if (!ptr) {
fatal("Memory allocation failure %s line %d: %s.\n",
file, line, expr);
}
return ptr;
}
#endif /* MODINITTOOLS_LOGGING_H */