xref: /titanic_41/usr/src/lib/libast/sparc/include/ast/debug.h (revision 7d1e83948cb684521e72cab96020be241508f449)
1 
2 /* : : generated by proto : : */
3 /***********************************************************************
4 *                                                                      *
5 *               This software is part of the ast package               *
6 *          Copyright (c) 1985-2008 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_DECLARE(t,v)	t v
59 #define DEBUG_SET(n,v)		((n) = (v))
60 #define DEBUG_PRINT(fd,s,v)	do {char _b[1024];write(fd,_b,sfsprintf(_b,sizeof(_b),s,v));} while(0)
61 #define DEBUG_WRITE(fd,d,n)	write((fd),(d),(n))
62 #define DEBUG_TEMP(temp)	(temp) /* debugging stuff that should be removed */
63 #define DEBUG_RETURN(x)		(debug_fatal(__FILE__, __LINE__), (x))
64 #define DEBUG_BREAK		(debug_fatal(__FILE__, __LINE__))
65 #define DEBUG_GOTO(label)	do { debug_fatal(__FILE__, __LINE__); goto label; } while(0)
66 
67 #else
68 
69 #define debug(x)
70 #define message(x)
71 #define messagef(x)
72 
73 #define DEBUG_BEGTIME()
74 #define DEBUG_GETTIME()
75 #define DEBUG_ASSERT(p)
76 #define DEBUG_COUNT(n)
77 #define DEBUG_TALLY(c,n,v)
78 #define DEBUG_DECLARE(t,v)
79 #define DEBUG_SET(n,v)
80 #define DEBUG_PRINT(fd,s,v)
81 #define DEBUG_WRITE(fd,d,n)
82 #define DEBUG_KPV(x)
83 #define DEBUG_RETURN(x)		return(x)
84 #define DEBUG_BREAK		break
85 #define DEBUG_GOTO(label)	goto label
86 
87 #endif
88 
89 #if _BLD_ast && defined(__EXPORT__)
90 #undef __MANGLE__
91 #define __MANGLE__ __LINKAGE__		__EXPORT__
92 #endif
93 
94 extern __MANGLE__ double		debug_elapsed __PROTO__((int));
95 extern __MANGLE__ void		debug_fatal __PROTO__((const char*, int));
96 extern __MANGLE__ void		systrace __PROTO__((const char*));
97 
98 #undef __MANGLE__
99 #define __MANGLE__ __LINKAGE__
100 
101 #endif
102