| Juan Cespedes | cac15c3 | 2003-01-31 18:58:58 +0100 | [diff] [blame] | 1 | #include <features.h> |
| 2 | |
| Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame^] | 3 | void debug_(int level, const char *file, int line, const char *func, const char *fmt, ...); |
| 4 | |
| 5 | int xwrite(const char *, size_t); |
| 6 | int xwrites(const char *); |
| 7 | int xwritehexi(int); |
| 8 | int xwritehexl(long); |
| 9 | int xwritec(char); |
| 10 | int xwritecr(void); |
| 11 | int xwritedump(void *, long, int); |
| 12 | int xinfdump(long, void *, int); |
| 13 | |
| Juan Cespedes | cac15c3 | 2003-01-31 18:58:58 +0100 | [diff] [blame] | 14 | |
| 15 | # define debug(level, expr...) debug_(level, __FILE__, __LINE__, DEBUG_FUNCTION, expr) |
| 16 | |
| 17 | /* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__' |
| 18 | which contains the name of the function currently being defined. |
| 19 | This is broken in G++ before version 2.6. |
| 20 | C9x has a similar variable called __func__, but prefer the GCC one since |
| 21 | it demangles C++ function names. */ |
| 22 | # if __GNUC_PREREQ (2, 4) |
| 23 | # define DEBUG_FUNCTION __PRETTY_FUNCTION__ |
| 24 | # else |
| 25 | # if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L |
| 26 | # define DEBUG_FUNCTION __func__ |
| 27 | # else |
| 28 | # define DEBUG_FUNCTION ((__const char *) 0) |
| 29 | # endif |
| 30 | # endif |