Debian Codegraph @

src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26 #ifndef WTF_Assertions_h
27 #define WTF_Assertions_hcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:27:9`!
28
29 /*
30 no namespaces because this file has to be includable from C and Objective-C
31
32 Note, this file uses many GCC extensions, but it should be compatible with
33 C, Objective C, C++, and Objective C++.
34
35 For non-debug builds, everything is disabled by default.
36 Defining any of the symbols explicitly prevents this from having any effect.
37
38 MSVC7 note: variadic macro support was added in MSVC8, so for now we disable
39 those macros in MSVC7. For more info, see the MSDN document on variadic
40 macros here:
41
42 http://msdn2.microsoft.com/en-us/library/ms177415(VS.80).aspx
43 */
44
45 #include "Platform.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h`/
46
47 #if COMPILERcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:39:9`!(MSVC)
48 #include <stddef.h>
49 #else
50 #include <inttypes.h>
51 #endif
52
53 #if OScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:49:9`!(SYMBIAN)
54 #include <e32def.h>
55 #include <e32debug.h>
56 #endif
57
58 #ifdef NDEBUGcxx . . $ `<built-in>:472:9`!
59 #define ASSERTIONS_DISABLED_DEFAULTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:59:9`! 1
60 #else
61 #define ASSERTIONS_DISABLED_DEFAULT 0
62 #endif
63
64 #if COMPILERcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:39:9`!(MSVC7) || COMPILERcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:39:9`!(WINSCW)
65 #define HAVE_VARIADIC_MACRO 0
66 #else
67 #define HAVE_VARIADIC_MACROcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:67:9`! 1
68 #endif
69
70 #ifndef ASSERT_DISABLED
71 #define ASSERT_DISABLEDcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:71:9`! ASSERTIONS_DISABLED_DEFAULTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:59:9`!
72 #endif
73
74 #ifndef ASSERT_MSG_DISABLED
75 #if HAVEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:46:9`!(VARIADIC_MACRO)
76 #define ASSERT_MSG_DISABLEDcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:76:9`! ASSERTIONS_DISABLED_DEFAULTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:59:9`!
77 #else
78 #define ASSERT_MSG_DISABLED 1
79 #endif
80 #endif
81
82 #ifndef ASSERT_ARG_DISABLED
83 #define ASSERT_ARG_DISABLEDcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:83:9`! ASSERTIONS_DISABLED_DEFAULTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:59:9`!
84 #endif
85
86 #ifndef FATAL_DISABLED
87 #if HAVEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:46:9`!(VARIADIC_MACRO)
88 #define FATAL_DISABLEDcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:88:9`! ASSERTIONS_DISABLED_DEFAULTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:59:9`!
89 #else
90 #define FATAL_DISABLED 1
91 #endif
92 #endif
93
94 #ifndef ERROR_DISABLED
95 #if HAVEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:46:9`!(VARIADIC_MACRO)
96 #define ERROR_DISABLEDcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:96:9`! ASSERTIONS_DISABLED_DEFAULTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:59:9`!
97 #else
98 #define ERROR_DISABLED 1
99 #endif
100 #endif
101
102 #ifndef LOG_DISABLEDcxx . . $ `<built-in>:473:9`!
103 #if HAVE(VARIADIC_MACRO)
104 #define LOG_DISABLED ASSERTIONS_DISABLED_DEFAULT
105 #else
106 #define LOG_DISABLED 1
107 #endif
108 #endif
109
110 #if COMPILERcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:39:9`!(GCC)
111 #define WTF_PRETTY_FUNCTIONcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:111:9`! __PRETTY_FUNCTION__
112 #else
113 #define WTF_PRETTY_FUNCTION __FUNCTION__
114 #endif
115
116 /* WTF logging functions can process %@ in the format string to log a NSObject* but the printf format attribute
117 emits a warning when %@ is used in the format string. Until <rdar://problem/5195437> is resolved we can't include
118 the attribute when being used from Objective-C code in case it decides to use %@. */
119 #if COMPILERcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:39:9`!(GCC) && !defined(__OBJC__)
120 #define WTF_ATTRIBUTE_PRINTFcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:120:9`!(formatStringArgument, extraArguments) __attribute__((__format__(printf, formatStringArgument, extraArguments)))
121 #else
122 #define WTF_ATTRIBUTE_PRINTF(formatStringArgument, extraArguments)
123 #endif
124
125 /* These helper functions are always declared, but not necessarily always defined if the corresponding function is disabled. */
126
127 #ifdef __cpluspluscxx . . $ `<built-in>:448:9`!
128 extern "C" {
129 #endif
130
131 typedef enum { WTFLogChannelOff, WTFLogChannelOn } WTFLogChannelState;
132
133 typedef struct {
134 unsigned mask;
135 const char *defaultName;
136 WTFLogChannelState state;
137 } WTFLogChannel;
138
139 void WTFReportAssertionFailure(const char* file, int line, const char* function, const char* assertion);
140 void WTFReportAssertionFailureWithMessage(const char* file, int line, const char* function, const char* assertion, const char* format, ...) WTF_ATTRIBUTE_PRINTFcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:120:9`!(5, 6);
141 void WTFReportArgumentAssertionFailure(const char* file, int line, const char* function, const char* argName, const char* assertion);
142 void WTFReportFatalError(const char* file, int line, const char* function, const char* format, ...) WTF_ATTRIBUTE_PRINTFcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:120:9`!(4, 5);
143 void WTFReportError(const char* file, int line, const char* function, const char* format, ...) WTF_ATTRIBUTE_PRINTFcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:120:9`!(4, 5);
144 void WTFLog(WTFLogChannel* channel, const char* format, ...) WTF_ATTRIBUTE_PRINTFcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:120:9`!(2, 3);
145 void WTFLogVerbose(const char* file, int line, const char* function, WTFLogChannel* channel, const char* format, ...) WTF_ATTRIBUTE_PRINTFcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:120:9`!(5, 6);
146
147 #ifdef __cpluspluscxx . . $ `<built-in>:448:9`!
148 }
149 #endif
150
151 /* CRASH -- gets us into the debugger or the crash reporter -- signals are ignored by the crash reporter so we must do better */
152
153 #ifndef CRASH
154 #if OScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:49:9`!(SYMBIAN)
155 #define CRASH() do { \
156 __DEBUGGER(); \
157 User::Panic(_L("Webkit CRASH"),0); \
158 } while(false)
159 #else
160 #define CRASHcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:160:9`!() do { \
161 *(int *)(uintptr_t)0xbbadbeef = 0; \
162 ((void(*)())0)(); /* More reliable, but doesn't say BBADBEEF */ \
163 } while(false)
164 #endif
165 #endif
166
167 /* ASSERT, ASSERT_NOT_REACHED, ASSERT_UNUSED */
168
169 #if OScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:49:9`!(WINCE) && !PLATFORMcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:33:9`!(TORCHMOBILE)
170 /* FIXME: We include this here only to avoid a conflict with the ASSERT macro. */
171 #include <windows.h>
172 #undef min
173 #undef max
174 #undef ERROR
175 #endif
176
177 #if OScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:49:9`!(WINDOWS) || OScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:49:9`!(SYMBIAN)
178 /* FIXME: Change to use something other than ASSERT to avoid this conflict with the underlying platform */
179 #undef ASSERT
180 #endif
181
182 #if ASSERT_DISABLEDcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:71:9`!
183
184 #define ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(assertion) ((void)0)
185 #define ASSERT_NOT_REACHEDcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:185:9`!() ((void)0)
186 #define ASSERT_UNUSEDcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:186:9`!(variable, assertion) ((void)variable)
187
188 #else
189
190 #define ASSERT(assertion) do \
191 if (!(assertion)) { \
192 WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, #assertion); \
193 CRASH(); \
194 } \
195 while (0)
196
197 #define ASSERT_NOT_REACHED() do { \
198 WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, 0); \
199 CRASH(); \
200 } while (0)
201
202 #define ASSERT_UNUSED(variable, assertion) ASSERT(assertion)
203
204 #endif
205
206 /* ASSERT_WITH_MESSAGE */
207
208 #if COMPILERcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:39:9`!(MSVC7)
209 #define ASSERT_WITH_MESSAGE(assertion) ((void)0)
210 #elif COMPILERcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:39:9`!(WINSCW)
211 #define ASSERT_WITH_MESSAGE(assertion, arg...) ((void)0)
212 #elif ASSERT_MSG_DISABLEDcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:76:9`!
213 #define ASSERT_WITH_MESSAGEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:213:9`!(assertion, ...) ((void)0)
214 #else
215 #define ASSERT_WITH_MESSAGE(assertion, ...) do \
216 if (!(assertion)) { \
217 WTFReportAssertionFailureWithMessage(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, #assertion, __VA_ARGS__); \
218 CRASH(); \
219 } \
220 while (0)
221 #endif
222
223
224 /* ASSERT_ARG */
225
226 #if ASSERT_ARG_DISABLEDcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:83:9`!
227
228 #define ASSERT_ARGcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:228:9`!(argName, assertion) ((void)0)
229
230 #else
231
232 #define ASSERT_ARG(argName, assertion) do \
233 if (!(assertion)) { \
234 WTFReportArgumentAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, #argName, #assertion); \
235 CRASH(); \
236 } \
237 while (0)
238
239 #endif
240
241 /* COMPILE_ASSERT */
242 #ifndef COMPILE_ASSERT
243 #if COMPILER_SUPPORTScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:41:9`!(C_STATIC_ASSERT)
244 /* Unlike static_assert below, this also works in plain C code. */
245 #define COMPILE_ASSERT(exp, name) _Static_assert((exp), #name)
246 #elif COMPILER_SUPPORTScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:41:9`!(CXX_STATIC_ASSERT)
247 #define COMPILE_ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:247:9`!(exp, name) static_assert((exp), #name)
248 #else
249 #define COMPILE_ASSERT(exp, name) typedef int dummy##name [(exp) ? 1 : -1]
250 #endif
251 #endif
252
253 /* FATAL */
254
255 #if COMPILERcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:39:9`!(MSVC7)
256 #define FATAL() ((void)0)
257 #elif COMPILERcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:39:9`!(WINSCW)
258 #define FATAL(arg...) ((void)0)
259 #elif FATAL_DISABLEDcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:88:9`!
260 #define FATALcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:260:9`!(...) ((void)0)
261 #else
262 #define FATAL(...) do { \
263 WTFReportFatalError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, __VA_ARGS__); \
264 CRASH(); \
265 } while (0)
266 #endif
267
268 /* LOG_ERROR */
269
270 #if COMPILERcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:39:9`!(MSVC7)
271 #define LOG_ERROR() ((void)0)
272 #elif COMPILERcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:39:9`!(WINSCW)
273 #define LOG_ERROR(arg...) ((void)0)
274 #elif ERROR_DISABLEDcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:96:9`!
275 #define LOG_ERRORcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:275:9`!(...) ((void)0)
276 #else
277 #define LOG_ERROR(...) WTFReportError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, __VA_ARGS__)
278 #endif
279
280 /* LOG */
281
282 #if COMPILERcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:39:9`!(MSVC7)
283 #define LOG() ((void)0)
284 #elif COMPILERcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:39:9`!(WINSCW)
285 #define LOG(arg...) ((void)0)
286 #elif LOG_DISABLEDcxx . . $ `<built-in>:473:9`!
287 #define LOGcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:287:9`!(channel, ...) ((void)0)
288 #else
289 #define LOG(channel, ...) WTFLog(&JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_PREFIX, channel), __VA_ARGS__)
290 #define JOIN_LOG_CHANNEL_WITH_PREFIX(prefix, channel) JOIN_LOG_CHANNEL_WITH_PREFIX_LEVEL_2(prefix, channel)
291 #define JOIN_LOG_CHANNEL_WITH_PREFIX_LEVEL_2(prefix, channel) prefix ## channel
292 #endif
293
294 /* LOG_VERBOSE */
295
296 #if COMPILERcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:39:9`!(MSVC7)
297 #define LOG_VERBOSE(channel) ((void)0)
298 #elif COMPILERcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:39:9`!(WINSCW)
299 #define LOG_VERBOSE(channel, arg...) ((void)0)
300 #elif LOG_DISABLEDcxx . . $ `<built-in>:473:9`!
301 #define LOG_VERBOSEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:301:9`!(channel, ...) ((void)0)
302 #else
303 #define LOG_VERBOSE(channel, ...) WTFLogVerbose(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, &JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_PREFIX, channel), __VA_ARGS__)
304 #endif
305
306 #endif /* WTF_Assertions_h */