added stacktrace
[nao-ulib.git] / src / die.h
blob2d9edb63b3a3550f3355ac818ae50647b91a6b6c
1 /*
2 * nao-ulib
3 * Copyright 2011 Daniel Borkmann <dborkma@tik.ee.ethz.ch>
4 * Subject to the GPL.
5 * Nao-Team HTWK,
6 * Faculty of Computer Science, Mathematics and Natural Sciences,
7 * Leipzig University of Applied Sciences (HTWK Leipzig)
8 */
10 #ifndef DIE_H
11 #define DIE_H
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <stdarg.h>
16 #include <string.h>
17 #include <errno.h>
19 static inline void die(void)
21 exit(EXIT_FAILURE);
24 static inline void _die(void)
26 _exit(EXIT_FAILURE);
29 static inline void sync_e(void)
31 fflush(stderr);
34 static inline void sync_o(void)
36 fflush(stdout);
39 static inline void info(char *msg, ...)
41 va_list vl;
42 va_start(vl, msg);
43 vfprintf(stdout, msg, vl);
44 va_end(vl);
47 static inline void whine(char *msg, ...)
49 va_list vl;
50 va_start(vl, msg);
51 vfprintf(stderr, msg, vl);
52 va_end(vl);
54 sync_e();
57 static inline void vomit(char *msg, ...)
59 va_list vl;
60 va_start(vl, msg);
61 vfprintf(stderr, msg, vl);
62 va_end(vl);
63 fprintf(stderr, ": %s\n", strerror(errno));
65 sync_e();
66 die();
69 static inline void panic(char *msg, ...)
71 va_list vl;
72 va_start(vl, msg);
73 vfprintf(stderr, msg, vl);
74 va_end(vl);
76 sync_e();
77 die();
80 #ifdef DEBUG
81 static inline void debug(char *msg, ...)
83 va_list vl;
84 va_start(vl, msg);
85 vfprintf(stderr, msg, vl);
86 va_end(vl);
88 sync_e();
90 #else
91 static inline void debug(char *msg, ...)
94 #endif /* DEBUG */
96 #endif /* DIE_H */