[1a80b4] | 1 | //////////////////////////////////////////////////////////// |
---|
[924d8f] | 2 | // $Id$ |
---|
[1a80b4] | 3 | //////////////////////////////////////////////////////////// |
---|
| 4 | // It is possible to include this file multiple times for different |
---|
| 5 | // settings of FACDEBUG and/or DEBUGOUTPUT |
---|
| 6 | |
---|
| 7 | #undef ASSERT |
---|
| 8 | #undef __ASSERT |
---|
| 9 | #undef STICKYASSERT |
---|
| 10 | #undef DEBOUT |
---|
| 11 | #undef DEBOUTLN |
---|
| 12 | #undef DEBINCLEVEL |
---|
| 13 | #undef DEBDECLEVEL |
---|
| 14 | #undef DEBOUTSL |
---|
| 15 | #undef DEBOUTMSG |
---|
| 16 | #undef DEBOUTNL |
---|
| 17 | |
---|
| 18 | #include <stdio.h> |
---|
| 19 | #include <stdlib.h> |
---|
| 20 | |
---|
| 21 | #ifdef NDEBUG |
---|
| 22 | #define ASSERT(ignore1,ignore2)((void)0) |
---|
| 23 | #else |
---|
| 24 | #define ASSERT(expression,message) \ |
---|
| 25 | ((void)((expression) ? 0 : __ASSERT(#expression, message, __FILE__, __LINE__))) |
---|
| 26 | #endif |
---|
| 27 | |
---|
| 28 | #define STICKYASSERT(expression,message) \ |
---|
| 29 | ((void)((expression) ? 0 : __ASSERT(#expression, message, __FILE__, __LINE__))) |
---|
| 30 | |
---|
| 31 | #define __ASSERT(expression, message, file, line) \ |
---|
| 32 | (fprintf( stderr, "error: %s\n%s:%u: failed assertion `%s'\n", \ |
---|
| 33 | message, file, line, expression ), abort(), 0 ) |
---|
| 34 | |
---|
| 35 | #ifdef DEBUGOUTPUT |
---|
[6742c8] | 36 | void deb_inc_level(); // use this helper routines from factory |
---|
| 37 | void deb_dec_level(); // use this helper routines from factory |
---|
| 38 | extern char * deb_level_msg; // from factory |
---|
[1a80b4] | 39 | #define DEBINCLEVEL(stream,msg) \ |
---|
[e2ca88] | 40 | (stream << "\n" << deb_level_msg << "entering << " << msg << " >>" << "\n", deb_inc_level()) |
---|
[1a80b4] | 41 | #define DEBDECLEVEL(stream,msg) \ |
---|
[e2ca88] | 42 | (deb_dec_level(), stream << deb_level_msg << "leaving << " << msg << " >>" << "\n") |
---|
[1a80b4] | 43 | #define DEBOUTSL(stream) \ |
---|
| 44 | (stream << deb_level_msg, stream.flush()) |
---|
| 45 | #define DEBOUT(stream,msg,object) \ |
---|
[4a81ec] | 46 | (stream << deb_level_msg << msg << object, stream.flush()) |
---|
[1a80b4] | 47 | #define DEBOUTLN(stream,msg,object) \ |
---|
[e2ca88] | 48 | (stream << deb_level_msg << msg << object << "\n") |
---|
[1a80b4] | 49 | #define DEBOUTMSG(stream,msg) \ |
---|
[e2ca88] | 50 | (stream << deb_level_msg << msg << "\n") |
---|
[1a80b4] | 51 | #define DEBOUTNL(stream) \ |
---|
[e2ca88] | 52 | (stream << "\n") |
---|
[1a80b4] | 53 | #else |
---|
| 54 | #define DEBINCLEVEL(stream,msg) |
---|
| 55 | #define DEBDECLEVEL(stream,msg) |
---|
| 56 | #define DEBOUTSL(stream) |
---|
| 57 | #define DEBOUT(stream,msg,object) |
---|
| 58 | #define DEBOUTLN(stream,msg,object) |
---|
| 59 | #define DEBOUTMSG(stream,msg) |
---|
| 60 | #define DEBOUTNL(stream) |
---|
| 61 | #endif |
---|
| 62 | |
---|