| Juan Cespedes | cac15c3 | 2003-01-31 18:58:58 +0100 | [diff] [blame] | 1 | #include <features.h> |
| 2 | |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 3 | void debug_(int level, const char *file, int line, const char *func, |
| Juan Cespedes | a413e5b | 2007-09-04 17:34:53 +0200 | [diff] [blame] | 4 | const char *fmt, ...) __attribute__((format(printf,5,6))); |
| Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 5 | |
| Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 6 | int xinfdump(long, void *, int); |
| 7 | |
| Juan Cespedes | cac15c3 | 2003-01-31 18:58:58 +0100 | [diff] [blame] | 8 | # define debug(level, expr...) debug_(level, __FILE__, __LINE__, DEBUG_FUNCTION, expr) |
| 9 | |
| 10 | /* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__' |
| 11 | which contains the name of the function currently being defined. |
| 12 | This is broken in G++ before version 2.6. |
| 13 | C9x has a similar variable called __func__, but prefer the GCC one since |
| 14 | it demangles C++ function names. */ |
| 15 | # if __GNUC_PREREQ (2, 4) |
| 16 | # define DEBUG_FUNCTION __PRETTY_FUNCTION__ |
| 17 | # else |
| 18 | # if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L |
| 19 | # define DEBUG_FUNCTION __func__ |
| 20 | # else |
| Juan Cespedes | 43739a6 | 2009-04-07 13:10:08 +0200 | [diff] [blame] | 21 | # define DEBUG_FUNCTION "???" |
| Juan Cespedes | cac15c3 | 2003-01-31 18:58:58 +0100 | [diff] [blame] | 22 | # endif |
| 23 | # endif |