]>
git.saurik.com Git - apple/security.git/blob - SecurityServer/MacYarrow/YarrowServer/debug.h
2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
22 Contains: Debugging macros.
24 Written by: Doug Mitchell
26 Copyright: (c) 1999 by Apple Computer, Inc., all rights reserved.
28 Change History (most recent first):
37 extern void yarrowPanic(const char *errStr
);
39 #define ERROR_LOG_ENABLE 0
41 #define LOG_VIA_PRINTF 1
43 #if DEBUG || ERROR_LOG_ENABLE
51 #include <TextUtils.h>
53 #if defined(__cplusplus)
57 /* common log macros */
59 extern void dblog0(char *str
);
60 extern void dblog1(char *str
, void * arg1
);
61 extern void dblog2(char *str
, void * arg1
, void * arg2
);
62 extern void dblog3(char *str
, void * arg1
, void * arg2
, void * arg3
);
63 extern void dblog4(char *str
, void * arg1
, void * arg2
, void * arg3
, void * arg4
);
65 #if defined(__cplusplus)
69 #else /* LOG_VIA_PRINTF */
71 #define dblog0(str) printf(str)
72 #define dblog1(str, arg1) printf(str, arg1)
73 #define dblog2(str, arg1, arg2) printf(str, arg1, arg2)
74 #define dblog3(str, arg1, arg2, arg3) printf(str, arg1, arg2, arg3)
75 #define dblog4(str, arg1, arg2, arg3, arg4) printf(str, arg1, arg2, arg3, arg4)
77 #endif /* LOG_VIA_PRINTF */
79 #else /* log macros disabled */
82 #define dblog1(str, arg1)
83 #define dblog2(str, arg1, arg2)
84 #define dblog3(str, arg1, arg2, arg3)
85 #define dblog4(str, arg1, arg2, arg3, arg4)
87 #endif /* log macros */
91 #define dprintf0(str) dblog0(str)
92 #define dprintf1(str, arg1) dblog1(str, (void *)arg1)
93 #define dprintf2(str, arg1, arg2) dblog2(str, (void *)arg1, (void *)arg2)
94 #define dprintf3(str, arg1, arg2, arg3) dblog3(str, (void *)arg1, (void *)arg2, (void *)arg3)
95 #define dprintf4(str, arg1, arg2, arg3, arg4) dblog4(str, (void *)arg1, (void *)arg2, (void *)arg3, (void *) arg4)
97 #define CASSERT(expression) \
98 ((expression) ? (void)0 : \
99 (dprintf1 ("Assertion failed: " #expression \
100 ", file " __FILE__ ", line %d.\n", __LINE__), \
101 yarrowPanic("Assertion Failure")))
105 #define dprintf0(str)
106 #define dprintf1(str, arg1)
107 #define dprintf2(str, arg1, arg2)
108 #define dprintf3(str, arg1, arg2, arg3)
109 #define dprintf4(str, arg1, arg2, arg3, arg4)
111 #define CASSERT(expression)
116 * Error logging. This may well be platform dependent.
119 #define errorLog0(str) dblog0(str);
120 #define errorLog1(str, arg1) dblog1(str, (void *)arg1)
121 #define errorLog2(str, arg1, arg2) dblog2(str, (void *)arg1, (void *)arg2)
122 #define errorLog3(str, arg1, arg2, arg3) dblog3(str, (void *)arg1, (void *)arg2, (void *)arg3)
123 #define errorLog4(str, arg1, arg2, arg3, arg4) dblog4(str, (void *)arg1, (void *)arg2, (void *)arg3, (void *)arg4)
125 #else /* ERROR_LOG_ENABLE */
127 #define errorLog0(str)
128 #define errorLog1(str, arg1)
129 #define errorLog2(str, arg1, arg2)
130 #define errorLog3(str, arg1, arg2, arg3)
131 #define errorLog4(str, arg1, arg2, arg3, arg4)
133 #endif /* ERROR_LOG_ENABLE */
135 #endif /* _DEBUG_H_ */