remove all legacy support for pre-2.6 kernels
[mit.git] / logging.h
blob4c25f5c55bb0f0099c1495fb2293021ef93d011c
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 silently drop all warnings? */
8 extern int quiet;
10 /* Number of times warn() has been called */
11 extern int warned;
13 /* Do we want informative messages as well as errors? */
14 extern int verbose;
16 extern void fatal(const char *fmt, ...);
17 extern void error(const char *fmt, ...);
18 extern void warn(const char *fmt, ...);
19 extern void info(const char *fmt, ...);
21 static inline void grammar(const char *cmd,
22 const char *filename, unsigned int line)
24 warn("%s line %u: ignoring bad line starting with '%s'\n",
25 filename, line, cmd);
28 #define NOFAIL(ptr) do_nofail((ptr), __FILE__, __LINE__, #ptr)
30 #define nofail_asprintf(ptr, ...) \
31 { if (asprintf((ptr), __VA_ARGS__) < 0) do_nofail(NULL, __FILE__, __LINE__, #ptr); }
33 static inline void *do_nofail(void *ptr, const char *file, int line, const char *expr)
35 if (!ptr) {
36 fatal("Memory allocation failure %s line %d: %s.\n",
37 file, line, expr);
39 return ptr;
42 #endif /* MODINITTOOLS_LOGGING_H */