1 | /* Copyright 1996 Michael Messollen. All rights reserved. */ |
---|
2 | //////////////////////////////////////////////////////////// |
---|
3 | // static char * rcsid = "$Id: debug.h,v 1.3 1997-09-12 07:19:55 Singular Exp $" ; |
---|
4 | //////////////////////////////////////////////////////////// |
---|
5 | // It is possible to include this file multiple times for different |
---|
6 | // settings of FACDEBUG and/or DEBUGOUTPUT |
---|
7 | |
---|
8 | #undef ASSERT |
---|
9 | #undef __ASSERT |
---|
10 | #undef STICKYASSERT |
---|
11 | #undef DEBOUT |
---|
12 | #undef DEBOUTLN |
---|
13 | #undef DEBINCLEVEL |
---|
14 | #undef DEBDECLEVEL |
---|
15 | #undef DEBOUTSL |
---|
16 | #undef DEBOUTMSG |
---|
17 | #undef DEBOUTNL |
---|
18 | |
---|
19 | #include <stdio.h> |
---|
20 | #include <stdlib.h> |
---|
21 | |
---|
22 | #ifdef NDEBUG |
---|
23 | #define ASSERT(ignore1,ignore2)((void)0) |
---|
24 | #else |
---|
25 | #define ASSERT(expression,message) \ |
---|
26 | ((void)((expression) ? 0 : __ASSERT(#expression, message, __FILE__, __LINE__))) |
---|
27 | #endif |
---|
28 | |
---|
29 | #define STICKYASSERT(expression,message) \ |
---|
30 | ((void)((expression) ? 0 : __ASSERT(#expression, message, __FILE__, __LINE__))) |
---|
31 | |
---|
32 | #define __ASSERT(expression, message, file, line) \ |
---|
33 | (fprintf( stderr, "error: %s\n%s:%u: failed assertion `%s'\n", \ |
---|
34 | message, file, line, expression ), abort(), 0 ) |
---|
35 | |
---|
36 | #ifdef DEBUGOUTPUT |
---|
37 | void deb_inc_level(); |
---|
38 | void deb_dec_level(); |
---|
39 | extern char * deb_level_msg; |
---|
40 | #define DEBINCLEVEL(stream,msg) \ |
---|
41 | (stream << "\n" << deb_level_msg << "entering << " << msg << " >>" << endl, deb_inc_level()) |
---|
42 | #define DEBDECLEVEL(stream,msg) \ |
---|
43 | (deb_dec_level(), stream << deb_level_msg << "leaving << " << msg << " >>" << endl) |
---|
44 | #define DEBOUTSL(stream) \ |
---|
45 | (stream << deb_level_msg, stream.flush()) |
---|
46 | #define DEBOUT(stream,msg,object) \ |
---|
47 | (stream << deb_level_msg << msg << object, stream.flush()) |
---|
48 | #define DEBOUTLN(stream,msg,object) \ |
---|
49 | (stream << deb_level_msg << msg << object << endl) |
---|
50 | #define DEBOUTMSG(stream,msg) \ |
---|
51 | (stream << deb_level_msg << msg << endl) |
---|
52 | #define DEBOUTNL(stream) \ |
---|
53 | (stream << endl) |
---|
54 | #else |
---|
55 | #define DEBINCLEVEL(stream,msg) |
---|
56 | #define DEBDECLEVEL(stream,msg) |
---|
57 | #define DEBOUTSL(stream) |
---|
58 | #define DEBOUT(stream,msg,object) |
---|
59 | #define DEBOUTLN(stream,msg,object) |
---|
60 | #define DEBOUTMSG(stream,msg) |
---|
61 | #define DEBOUTNL(stream) |
---|
62 | #endif |
---|
63 | |
---|
64 | /* |
---|
65 | $Log: not supported by cvs2svn $ |
---|
66 | Revision 1.2 1997/04/25 22:15:33 michael |
---|
67 | Version for libfac-0.2.1 |
---|
68 | |
---|
69 | Revision 1.1 1996/01/17 05:19:43 michael |
---|
70 | Initial revision |
---|
71 | |
---|
72 | */ |
---|