xref: /titanic_44/usr/src/lib/libast/i386/include/ast/debug.h (revision f6e214c7418f43af38bd8c3a557e3d0a1d311cfa)
1 
2 /* : : generated by proto : : */
3 /***********************************************************************
4 *                                                                      *
5 *               This software is part of the ast package               *
6 *          Copyright (c) 1985-2010 AT&T Intellectual Property          *
7 *                      and is licensed under the                       *
8 *                  Common Public License, Version 1.0                  *
9 *                    by AT&T Intellectual Property                     *
10 *                                                                      *
11 *                A copy of the License is available at                 *
12 *            http://www.opensource.org/licenses/cpl1.0.txt             *
13 *         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
14 *                                                                      *
15 *              Information and Software Systems Research               *
16 *                            AT&T Research                             *
17 *                           Florham Park NJ                            *
18 *                                                                      *
19 *                 Glenn Fowler <gsf@research.att.com>                  *
20 *                  David Korn <dgk@research.att.com>                   *
21 *                   Phong Vo <kpv@research.att.com>                    *
22 *                                                                      *
23 ***********************************************************************/
24 
25 /*
26  * common ast debug definitions
27  * include after the ast headers
28  */
29 
30 #ifndef _DEBUG_H
31 #if !defined(__PROTO__)
32 #include <prototyped.h>
33 #endif
34 #if !defined(__LINKAGE__)
35 #define __LINKAGE__		/* 2004-08-11 transition */
36 #endif
37 
38 #define _DEBUG_H
39 
40 #include <ast.h>
41 #include <error.h>
42 
43 #if !defined(DEBUG) && _BLD_DEBUG
44 #define DEBUG		_BLD_DEBUG
45 #endif
46 
47 #if DEBUG || _BLD_DEBUG
48 
49 #define debug(x)	x
50 #define message(x)	do if (error_info.trace < 0) { error x; } while (0)
51 #define messagef(x)	do if (error_info.trace < 0) { errorf x; } while (0)
52 
53 #define DEBUG_BEGTIME()		debug_elapsed(1)
54 #define DEBUG_GETTIME()		debug_elapsed(0)
55 #define DEBUG_ASSERT(p)		((p) ? 0 : (debug_fatal(__FILE__, __LINE__),0))
56 #define DEBUG_COUNT(n)		((n) += 1)
57 #define DEBUG_TALLY(c,n,v)	((c) ? ((n) += (v)) : (n))
58 #define DEBUG_INCREASE(n)	((n) += 1)
59 #define DEBUG_DECREASE(n)	((n) -= 1)
60 #define DEBUG_DECLARE(t,v)	t v
61 #define DEBUG_SET(n,v)		((n) = (v))
62 #define DEBUG_PRINT(fd,s,v)	do {char _b[1024];write(fd,_b,sfsprintf(_b,sizeof(_b),s,v));} while(0)
63 #define DEBUG_WRITE(fd,d,n)	write((fd),(d),(n))
64 #define DEBUG_TEMP(temp)	(temp) /* debugging stuff that should be removed */
65 #define DEBUG_BREAK		break
66 #define DEBUG_CONTINUE		continue
67 #define DEBUG_GOTO(label)	do { debug_fatal(__FILE__, __LINE__); goto label; } while(0)
68 #define DEBUG_RETURN(x)		do { debug_fatal(__FILE__, __LINE__); return(x); } while(0)
69 
70 #else
71 
72 #define debug(x)
73 #define message(x)
74 #define messagef(x)
75 
76 #define DEBUG_BEGTIME()
77 #define DEBUG_GETTIME()
78 #define DEBUG_ASSERT(p)
79 #define DEBUG_COUNT(n)
80 #define DEBUG_TALLY(c,n,v)
81 #define DEBUG_INCREASE(n)
82 #define DEBUG_DECREASE(n)
83 #define DEBUG_DECLARE(t,v)
84 #define DEBUG_SET(n,v)
85 #define DEBUG_PRINT(fd,s,v)
86 #define DEBUG_WRITE(fd,d,n)
87 #define DEBUG_TEMP(x)
88 #define DEBUG_BREAK		break
89 #define DEBUG_CONTINUE		continue
90 #define DEBUG_GOTO(label)	goto label
91 #define DEBUG_RETURN(x)		return(x)
92 
93 #endif
94 
95 #ifndef BREAK
96 #define BREAK			DEBUG_BREAK
97 #endif
98 #ifndef CONTINUE
99 #define CONTINUE		DEBUG_CONTINUE
100 #endif
101 #ifndef GOTO
102 #define GOTO(label)		DEBUG_GOTO(label)
103 #endif
104 #ifndef RETURN
105 #define RETURN(x)		DEBUG_RETURN(x)
106 #endif
107 
108 #if _BLD_ast && defined(__EXPORT__)
109 #undef __MANGLE__
110 #define __MANGLE__ __LINKAGE__		__EXPORT__
111 #endif
112 
113 extern __MANGLE__ double		debug_elapsed __PROTO__((int));
114 extern __MANGLE__ void		debug_fatal __PROTO__((const char*, int));
115 extern __MANGLE__ void		systrace __PROTO__((const char*));
116 
117 #undef __MANGLE__
118 #define __MANGLE__ __LINKAGE__
119 
120 #endif
121