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