]>
git.saurik.com Git - apple/security.git/blob - Security/libsecurity_apple_csp/lib/cspdebugging.h
2 * Copyright (c) 2000-2001,2011,2013-2014 Apple 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.
25 Copyright (c) 1998,2011,2013-2014 Apple Inc. All Rights Reserved.
27 Change History (most recent first):
29 06/02/98 dpm Added DEBUG_THREAD_YIELD.
34 #ifndef _CSPDEBUGGING_H_
35 #define _CSPDEBUGGING_H_
38 #define DEBUG_ENABLE 0
39 #define ERROR_LOG_ENABLE 0
41 #define DEBUG_ENABLE 1
42 #define ERROR_LOG_ENABLE 1
46 #define LOG_VIA_PRINTF 1
48 #if DEBUG_ENABLE || ERROR_LOG_ENABLE
55 #error Hey, figure out a debug mechanism
58 #include <TextUtils.h>
60 /* common log macros */
62 /* remaining ones can take constant strings */
68 extern void dblog0(char *str
);
69 extern void dblog1(char *str
, void * arg1
);
70 extern void dblog2(char *str
, void * arg1
, void * arg2
);
71 extern void dblog3(char *str
, void * arg1
, void * arg2
, void * arg3
);
72 extern void dblog4(char *str
, void * arg1
, void * arg2
, void * arg3
, void * arg4
);
79 #else /* LOG_VIA_PRINTF */
81 #define dblog0(str) printf(str)
82 #define dblog1(str, arg1) printf(str, arg1)
83 #define dblog2(str, arg1, arg2) printf(str, arg1, arg2)
84 #define dblog3(str, arg1, arg2, arg3) printf(str, arg1, arg2, arg3)
85 #define dblog4(str, arg1, arg2, arg3, arg4) printf(str, arg1, arg2, arg3, arg4)
87 #endif /* LOG_VIA_PRINTF */
89 #else /* log macros disabled */
92 #define dblog1(str, arg1)
93 #define dblog2(str, arg1, arg2)
94 #define dblog3(str, arg1, arg2, arg3)
95 #define dblog4(str, arg1, arg2, arg3, arg4)
97 #endif /* DEBUG_ENABLE || ERROR_LOG_ENABLE */
101 #define dprintf0(str) dblog0(str)
102 #define dprintf1(str, arg1) dblog1(str, arg1)
103 #define dprintf2(str, arg1, arg2) dblog2(str, arg1, arg2)
104 #define dprintf3(str, arg1, arg2, arg3) dblog3(str, arg1, arg2, arg3)
105 #define dprintf4(str, arg1, arg2, arg3, arg4) dblog4(str, arg1, arg2, arg3, arg4)
111 static inline void _panic(const char *str
)
121 #define CASSERT(expression) \
122 ((expression) ? (void)0 : \
123 (dprintf1 ("Assertion failed: " #expression \
124 ", file " __FILE__ ", line %d.\n", __LINE__), \
125 _panic("Assertion Failure")))
127 #else /* DEBUG_ENABLE */
129 #define dprintf0(str)
130 #define dprintf1(str, arg1)
131 #define dprintf2(str, arg1, arg2)
132 #define dprintf3(str, arg1, arg2, arg3)
133 #define dprintf4(str, arg1, arg2, arg3, arg4)
135 #define CASSERT(expression)
137 #endif /* DEBUG_ENABLE */
140 * Error logging. This may well be platform dependent.
143 #define errorLog0(str) dblog0(str);
144 #define errorLog1(str, arg1) dblog1(str, arg1)
145 #define errorLog2(str, arg1, arg2) dblog2(str, arg1, arg2)
146 #define errorLog3(str, arg1, arg2, arg3) dblog3(str, arg1, arg2, arg3)
147 #define errorLog4(str, arg1, arg2, arg3, arg4) dblog4(str, arg1, arg2, arg3, arg4)
149 #else /* ERROR_LOG_ENABLE */
151 #define errorLog0(str)
152 #define errorLog1(str, arg1)
153 #define errorLog2(str, arg1, arg2)
154 #define errorLog3(str, arg1, arg2, arg3)
155 #define errorLog4(str, arg1, arg2, arg3, arg4)
157 #endif /* ERROR_LOG_ENABLE */
159 #endif /* _CSPDEBUGGING_H_ */