]>
Commit | Line | Data |
---|---|---|
056a1eb7 SF |
1 | /** @file |
2 | * IPRT - Assertions. | |
3 | */ | |
4 | ||
5 | /* | |
6 | * Copyright (C) 2006-2016 Oracle Corporation | |
7 | * | |
8 | * This file is part of VirtualBox Open Source Edition (OSE), as | |
9 | * available from http://www.virtualbox.org. This file is free software; | |
10 | * you can redistribute it and/or modify it under the terms of the GNU | |
11 | * General Public License (GPL) as published by the Free Software | |
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the | |
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the | |
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. | |
15 | * | |
16 | * The contents of this file may alternatively be used under the terms | |
17 | * of the Common Development and Distribution License Version 1.0 | |
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the | |
19 | * VirtualBox OSE distribution, in which case the provisions of the | |
20 | * CDDL are applicable instead of those of the GPL. | |
21 | * | |
22 | * You may elect to license modified versions of this file under the | |
23 | * terms and conditions of either the GPL or the CDDL or both. | |
24 | */ | |
25 | ||
26 | #ifndef ___iprt_assert_h | |
27 | #define ___iprt_assert_h | |
28 | ||
29 | #include <iprt/cdefs.h> | |
30 | #include <iprt/types.h> | |
31 | #include <iprt/stdarg.h> | |
32 | ||
33 | /** @defgroup grp_rt_assert Assert - Assertions | |
34 | * @ingroup grp_rt | |
35 | * | |
36 | * Assertions are generally used to check preconditions and other | |
37 | * assumptions. Sometimes it is also used to catch odd errors or errors | |
38 | * that one would like to inspect in the debugger. They should not be | |
39 | * used for errors that happen frequently. | |
40 | * | |
41 | * IPRT provides a host of assertion macros, so many that it can be a bit | |
42 | * overwhelming at first. Don't despair, there is a system (surprise). | |
43 | * | |
44 | * First there are four families of assertions: | |
45 | * - Assert - The normal strict build only assertions. | |
46 | * - AssertLogRel - Calls LogRel() in non-strict builds, otherwise like Assert. | |
47 | * - AssertRelease - Triggers in all builds. | |
48 | * - AssertFatal - Triggers in all builds and cannot be continued. | |
49 | * | |
50 | * Then there are variations wrt to argument list and behavior on failure: | |
51 | * - Msg - Custom RTStrPrintf-like message with the assertion message. | |
52 | * - Return - Return the specific rc on failure. | |
53 | * - ReturnVoid - Return (void) on failure. | |
54 | * - Break - Break (out of switch/loop) on failure. | |
55 | * - Stmt - Execute the specified statement(s) on failure. | |
56 | * - RC - Assert RT_SUCCESS. | |
57 | * - RCSuccess - Assert VINF_SUCCESS. | |
58 | * | |
59 | * In addition there is a very special family AssertCompile that can be | |
60 | * used for some limited compile-time checking, like structure sizes and member | |
61 | * alignment. This family doesn't have the same variations. | |
62 | * | |
63 | * | |
64 | * @remarks As you might have noticed, the macros don't follow the | |
65 | * coding guidelines wrt to macros supposedly being all uppercase | |
66 | * and underscored. For various reasons they don't, and nobody | |
67 | * has complained yet. Wonder why... :-) | |
68 | * | |
69 | * @remarks Each project has its own specific guidelines on how to use | |
70 | * assertions, so the above is just trying to give you the general idea | |
71 | * from the IPRT point of view. | |
72 | * | |
73 | * @{ | |
74 | */ | |
75 | ||
76 | RT_C_DECLS_BEGIN | |
77 | ||
78 | /** | |
79 | * The 1st part of an assert message. | |
80 | * | |
81 | * @param pszExpr Expression. Can be NULL. | |
82 | * @param uLine Location line number. | |
83 | * @param pszFile Location file name. | |
84 | * @param pszFunction Location function name. | |
85 | */ | |
86 | RTDECL(void) RTAssertMsg1(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction); | |
87 | /** | |
88 | * Weak version of RTAssertMsg1 that can be overridden locally in a module to | |
89 | * modify, redirect or otherwise mess with the assertion output. | |
90 | * | |
91 | * @copydoc RTAssertMsg1 | |
92 | */ | |
93 | RTDECL(void) RTAssertMsg1Weak(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction); | |
94 | ||
95 | /** | |
96 | * The 2nd (optional) part of an assert message. | |
97 | * | |
98 | * @param pszFormat Printf like format string. | |
99 | * @param ... Arguments to that string. | |
100 | */ | |
101 | RTDECL(void) RTAssertMsg2(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2); | |
102 | /** | |
103 | * Weak version of RTAssertMsg2 that forwards to RTAssertMsg2WeakV. | |
104 | * | |
105 | * There is not need to override this, check out RTAssertMsg2WeakV instead! | |
106 | * | |
107 | * @copydoc RTAssertMsg2 | |
108 | */ | |
109 | RTDECL(void) RTAssertMsg2Weak(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2); | |
110 | ||
111 | /** | |
112 | * The 2nd (optional) part of an assert message. | |
113 | * | |
114 | * @param pszFormat Printf like format string. | |
115 | * @param va Arguments to that string. | |
116 | */ | |
117 | RTDECL(void) RTAssertMsg2V(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0); | |
118 | /** | |
119 | * Weak version of RTAssertMsg2V that can be overridden locally in a module to | |
120 | * modify, redirect or otherwise mess with the assertion output. | |
121 | * | |
122 | * @copydoc RTAssertMsg2V | |
123 | */ | |
124 | RTDECL(void) RTAssertMsg2WeakV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0); | |
125 | ||
126 | /** | |
127 | * Additional information which should be appended to the 2nd part of an | |
128 | * assertion message. | |
129 | * | |
130 | * @param pszFormat Printf like format string. | |
131 | * @param ... Arguments to that string. | |
132 | */ | |
133 | RTDECL(void) RTAssertMsg2Add(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2); | |
134 | /** | |
135 | * Weak version of RTAssertMsg2Add that forwards to RTAssertMsg2AddWeakV. | |
136 | * | |
137 | * There is not need to override this, check out RTAssertMsg2AddWeakV instead! | |
138 | * | |
139 | * @copydoc RTAssertMsg2Add | |
140 | */ | |
141 | RTDECL(void) RTAssertMsg2AddWeak(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2); | |
142 | ||
143 | /** | |
144 | * Additional information which should be appended to the 2nd part of an | |
145 | * assertion message. | |
146 | * | |
147 | * @param pszFormat Printf like format string. | |
148 | * @param va Arguments to that string. | |
149 | */ | |
150 | RTDECL(void) RTAssertMsg2AddV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0); | |
151 | /** | |
152 | * Weak version of RTAssertMsg2AddV that can be overridden locally in a module | |
153 | * to modify, redirect or otherwise mess with the assertion output. | |
154 | * | |
155 | * @copydoc RTAssertMsg2AddV | |
156 | */ | |
157 | RTDECL(void) RTAssertMsg2AddWeakV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0); | |
158 | ||
159 | #ifdef IN_RING0 | |
160 | /** | |
161 | * Panics the system as the result of a fail assertion. | |
162 | */ | |
163 | RTR0DECL(void) RTR0AssertPanicSystem(void); | |
164 | #endif /* IN_RING0 */ | |
165 | ||
166 | /** | |
167 | * Overridable function that decides whether assertions executes the panic | |
168 | * (breakpoint) or not. | |
169 | * | |
170 | * The generic implementation will return true. | |
171 | * | |
172 | * @returns true if the breakpoint should be hit, false if it should be ignored. | |
173 | * | |
174 | * @remark The RTDECL() makes this a bit difficult to override on Windows. So, | |
175 | * you'll have to use RTASSERT_HAVE_SHOULD_PANIC or | |
176 | * RTASSERT_HAVE_SHOULD_PANIC_PRIVATE there to control the kind of | |
177 | * prototype. | |
178 | */ | |
179 | #if !defined(RTASSERT_HAVE_SHOULD_PANIC) && !defined(RTASSERT_HAVE_SHOULD_PANIC_PRIVATE) | |
180 | RTDECL(bool) RTAssertShouldPanic(void); | |
181 | #elif defined(RTASSERT_HAVE_SHOULD_PANIC_PRIVATE) | |
182 | bool RTAssertShouldPanic(void); | |
183 | #else | |
184 | DECLEXPORT(bool) RTCALL RTAssertShouldPanic(void); | |
185 | #endif | |
186 | ||
187 | /** | |
188 | * Controls whether the assertions should be quiet or noisy (default). | |
189 | * | |
190 | * @returns The old setting. | |
191 | * @param fQuiet The new setting. | |
192 | */ | |
193 | RTDECL(bool) RTAssertSetQuiet(bool fQuiet); | |
194 | ||
195 | /** | |
196 | * Are assertions quiet or noisy? | |
197 | * | |
198 | * @returns True if they are quiet, false if noisy. | |
199 | */ | |
200 | RTDECL(bool) RTAssertAreQuiet(void); | |
201 | ||
202 | /** | |
203 | * Makes the assertions panic (default) or not. | |
204 | * | |
205 | * @returns The old setting. | |
206 | * @param fPanic The new setting. | |
207 | */ | |
208 | RTDECL(bool) RTAssertSetMayPanic(bool fPanic); | |
209 | ||
210 | /** | |
211 | * Can assertion panic. | |
212 | * | |
213 | * @returns True if they can, false if not. | |
214 | */ | |
215 | RTDECL(bool) RTAssertMayPanic(void); | |
216 | ||
217 | ||
218 | /** @name Globals for crash analysis | |
219 | * @remarks This is the full potential set, it | |
220 | * @{ | |
221 | */ | |
222 | /** The last assert message, 1st part. */ | |
223 | extern RTDATADECL(char) g_szRTAssertMsg1[1024]; | |
224 | /** The last assert message, 2nd part. */ | |
225 | extern RTDATADECL(char) g_szRTAssertMsg2[4096]; | |
226 | /** The last assert message, expression. */ | |
227 | extern RTDATADECL(const char * volatile) g_pszRTAssertExpr; | |
228 | /** The last assert message, file name. */ | |
229 | extern RTDATADECL(const char * volatile) g_pszRTAssertFile; | |
230 | /** The last assert message, line number. */ | |
231 | extern RTDATADECL(uint32_t volatile) g_u32RTAssertLine; | |
232 | /** The last assert message, function name. */ | |
233 | extern RTDATADECL(const char * volatile) g_pszRTAssertFunction; | |
234 | /** @} */ | |
235 | ||
236 | RT_C_DECLS_END | |
237 | ||
238 | /** @def RTAssertDebugBreak() | |
239 | * Debugger breakpoint instruction. | |
240 | * | |
241 | * @remarks This macro does not depend on RT_STRICT. | |
242 | */ | |
243 | #define RTAssertDebugBreak() do { RT_BREAKPOINT(); } while (0) | |
244 | ||
245 | ||
246 | ||
247 | /** @name Compile time assertions. | |
248 | * | |
249 | * These assertions are used to check structure sizes, member/size alignments | |
250 | * and similar compile time expressions. | |
251 | * | |
252 | * @{ | |
253 | */ | |
254 | ||
255 | /** | |
256 | * RTASSERTTYPE is the type the AssertCompile() macro redefines. | |
257 | * It has no other function and shouldn't be used. | |
258 | * Visual C++ uses this. | |
259 | */ | |
260 | typedef int RTASSERTTYPE[1]; | |
261 | ||
262 | /** | |
263 | * RTASSERTVAR is the type the AssertCompile() macro redefines. | |
264 | * It has no other function and shouldn't be used. | |
265 | * GCC uses this. | |
266 | */ | |
267 | #ifdef __GNUC__ | |
268 | RT_C_DECLS_BEGIN | |
269 | #endif | |
270 | extern int RTASSERTVAR[1]; | |
271 | #ifdef __GNUC__ | |
272 | RT_C_DECLS_END | |
273 | #endif | |
274 | ||
275 | /** @def RTASSERT_HAVE_STATIC_ASSERT | |
276 | * Indicates that the compiler implements static_assert(expr, msg). | |
277 | */ | |
278 | #ifdef _MSC_VER | |
279 | # if _MSC_VER >= 1600 && defined(__cplusplus) | |
280 | # define RTASSERT_HAVE_STATIC_ASSERT | |
281 | # endif | |
282 | #endif | |
283 | #if defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__) | |
284 | # define RTASSERT_HAVE_STATIC_ASSERT | |
285 | #endif | |
286 | #if RT_CLANG_PREREQ(6, 0) | |
287 | # if __has_feature(cxx_static_assert) || __has_feature(c_static_assert) | |
288 | # define RTASSERT_HAVE_STATIC_ASSERT | |
289 | # endif | |
290 | #endif | |
291 | #ifdef DOXYGEN_RUNNING | |
292 | # define RTASSERT_HAVE_STATIC_ASSERT | |
293 | #endif | |
294 | ||
295 | /** @def AssertCompileNS | |
296 | * Asserts that a compile-time expression is true. If it's not break the build. | |
297 | * | |
298 | * This differs from AssertCompile in that it accepts some more expressions | |
299 | * than what C++0x allows - NS = Non-standard. | |
300 | * | |
301 | * @param expr Expression which should be true. | |
302 | */ | |
303 | #ifdef __GNUC__ | |
304 | # define AssertCompileNS(expr) extern int RTASSERTVAR[1] __attribute__((__unused__)), RTASSERTVAR[(expr) ? 1 : 0] __attribute__((__unused__)) | |
305 | #elif defined(__IBMC__) || defined(__IBMCPP__) | |
306 | # define AssertCompileNS(expr) extern int RTASSERTVAR[(expr) ? 1 : 0] | |
307 | #else | |
308 | # define AssertCompileNS(expr) typedef int RTASSERTTYPE[(expr) ? 1 : 0] | |
309 | #endif | |
310 | ||
311 | /** @def AssertCompile | |
312 | * Asserts that a C++0x compile-time expression is true. If it's not break the | |
313 | * build. | |
314 | * @param expr Expression which should be true. | |
315 | */ | |
316 | #ifdef RTASSERT_HAVE_STATIC_ASSERT | |
317 | # define AssertCompile(expr) static_assert(!!(expr), #expr) | |
318 | #else | |
319 | # define AssertCompile(expr) AssertCompileNS(expr) | |
320 | #endif | |
321 | ||
322 | /** @def RTASSERT_OFFSET_OF() | |
323 | * A offsetof() macro suitable for compile time assertions. | |
324 | * Both GCC v4 and VisualAge for C++ v3.08 has trouble using RT_OFFSETOF. | |
325 | */ | |
326 | #if defined(__GNUC__) | |
327 | # if __GNUC__ >= 4 | |
328 | # define RTASSERT_OFFSET_OF(a_Type, a_Member) __builtin_offsetof(a_Type, a_Member) | |
329 | # else | |
330 | # define RTASSERT_OFFSET_OF(a_Type, a_Member) RT_OFFSETOF(a_Type, a_Member) | |
331 | # endif | |
332 | #elif (defined(__IBMC__) || defined(__IBMCPP__)) && defined(RT_OS_OS2) | |
333 | # define RTASSERT_OFFSET_OF(a_Type, a_Member) __offsetof(a_Type, a_Member) | |
334 | #else | |
335 | # define RTASSERT_OFFSET_OF(a_Type, a_Member) RT_OFFSETOF(a_Type, a_Member) | |
336 | #endif | |
337 | ||
338 | ||
339 | /** @def AssertCompileSize | |
340 | * Asserts a size at compile. | |
341 | * @param type The type. | |
342 | * @param size The expected type size. | |
343 | */ | |
344 | #define AssertCompileSize(type, size) \ | |
345 | AssertCompile(sizeof(type) == (size)) | |
346 | ||
347 | /** @def AssertCompileSizeAlignment | |
348 | * Asserts a size alignment at compile. | |
349 | * @param type The type. | |
350 | * @param align The size alignment to assert. | |
351 | */ | |
352 | #define AssertCompileSizeAlignment(type, align) \ | |
353 | AssertCompile(!(sizeof(type) & ((align) - 1))) | |
354 | ||
355 | /** @def AssertCompileMemberSize | |
356 | * Asserts a member offset alignment at compile. | |
357 | * @param type The type. | |
358 | * @param member The member. | |
359 | * @param size The member size to assert. | |
360 | */ | |
361 | #define AssertCompileMemberSize(type, member, size) \ | |
362 | AssertCompile(RT_SIZEOFMEMB(type, member) == (size)) | |
363 | ||
364 | /** @def AssertCompileMemberSizeAlignment | |
365 | * Asserts a member size alignment at compile. | |
366 | * @param type The type. | |
367 | * @param member The member. | |
368 | * @param align The member size alignment to assert. | |
369 | */ | |
370 | #define AssertCompileMemberSizeAlignment(type, member, align) \ | |
371 | AssertCompile(!(RT_SIZEOFMEMB(type, member) & ((align) - 1))) | |
372 | ||
373 | /** @def AssertCompileMemberAlignment | |
374 | * Asserts a member offset alignment at compile. | |
375 | * @param type The type. | |
376 | * @param member The member. | |
377 | * @param align The member offset alignment to assert. | |
378 | */ | |
379 | #define AssertCompileMemberAlignment(type, member, align) \ | |
380 | AssertCompile(!(RTASSERT_OFFSET_OF(type, member) & ((align) - 1))) | |
381 | ||
382 | /** @def AssertCompileMemberOffset | |
383 | * Asserts an offset of a structure member at compile. | |
384 | * @param type The type. | |
385 | * @param member The member. | |
386 | * @param off The expected offset. | |
387 | */ | |
388 | #define AssertCompileMemberOffset(type, member, off) \ | |
389 | AssertCompile(RTASSERT_OFFSET_OF(type, member) == (off)) | |
390 | ||
391 | /** @def AssertCompile2MemberOffsets | |
392 | * Asserts that two (sub-structure) members in union have the same offset. | |
393 | * @param type The type. | |
394 | * @param member1 The first member. | |
395 | * @param member2 The second member. | |
396 | */ | |
397 | #define AssertCompile2MemberOffsets(type, member1, member2) \ | |
398 | AssertCompile(RTASSERT_OFFSET_OF(type, member1) == RTASSERT_OFFSET_OF(type, member2)) | |
399 | ||
400 | /** @def AssertCompileAdjacentMembers | |
401 | * Asserts that two structure members are adjacent. | |
402 | * @param type The type. | |
403 | * @param member1 The first member. | |
404 | * @param member2 The second member. | |
405 | */ | |
406 | #define AssertCompileAdjacentMembers(type, member1, member2) \ | |
407 | AssertCompile(RTASSERT_OFFSET_OF(type, member1) + RT_SIZEOFMEMB(type, member1) == RTASSERT_OFFSET_OF(type, member2)) | |
408 | ||
409 | /** @def AssertCompileMembersAtSameOffset | |
410 | * Asserts that members of two different structures are at the same offset. | |
411 | * @param type1 The first type. | |
412 | * @param member1 The first member. | |
413 | * @param type2 The second type. | |
414 | * @param member2 The second member. | |
415 | */ | |
416 | #define AssertCompileMembersAtSameOffset(type1, member1, type2, member2) \ | |
417 | AssertCompile(RTASSERT_OFFSET_OF(type1, member1) == RTASSERT_OFFSET_OF(type2, member2)) | |
418 | ||
419 | /** @def AssertCompileMembersSameSize | |
420 | * Asserts that members of two different structures have the same size. | |
421 | * @param type1 The first type. | |
422 | * @param member1 The first member. | |
423 | * @param type2 The second type. | |
424 | * @param member2 The second member. | |
425 | */ | |
426 | #define AssertCompileMembersSameSize(type1, member1, type2, member2) \ | |
427 | AssertCompile(RT_SIZEOFMEMB(type1, member1) == RT_SIZEOFMEMB(type2, member2)) | |
428 | ||
429 | /** @def AssertCompileMembersSameSizeAndOffset | |
430 | * Asserts that members of two different structures have the same size and are | |
431 | * at the same offset. | |
432 | * @param type1 The first type. | |
433 | * @param member1 The first member. | |
434 | * @param type2 The second type. | |
435 | * @param member2 The second member. | |
436 | */ | |
437 | #define AssertCompileMembersSameSizeAndOffset(type1, member1, type2, member2) \ | |
438 | AssertCompile( RTASSERT_OFFSET_OF(type1, member1) == RTASSERT_OFFSET_OF(type2, member2) \ | |
439 | && RT_SIZEOFMEMB(type1, member1) == RT_SIZEOFMEMB(type2, member2)) | |
440 | ||
441 | /** @} */ | |
442 | ||
443 | ||
444 | ||
445 | /** @name Assertions | |
446 | * | |
447 | * These assertions will only trigger when RT_STRICT is defined. When it is | |
448 | * undefined they will all be no-ops and generate no code. | |
449 | * | |
450 | * @{ | |
451 | */ | |
452 | ||
453 | ||
454 | /** @def RTASSERT_QUIET | |
455 | * This can be defined to shut up the messages for a file where this would be | |
456 | * problematic because the message printing code path passes thru it. | |
457 | * @internal */ | |
458 | #ifdef DOXYGEN_RUNNING | |
459 | # define RTASSERT_QUIET | |
460 | #endif | |
461 | #if defined(RTASSERT_QUIET) && !defined(DOXYGEN_RUNNING) | |
462 | # define RTAssertMsg1Weak(pszExpr, uLine, pszfile, pszFunction) \ | |
463 | do { } while (0) | |
464 | # define RTAssertMsg2Weak if (1) {} else RTAssertMsg2Weak | |
465 | #endif | |
466 | ||
467 | /** @def RTAssertDoPanic | |
468 | * Raises an assertion panic appropriate to the current context. | |
469 | * @remarks This macro does not depend on RT_STRICT. | |
470 | */ | |
471 | #if defined(IN_RING0) \ | |
472 | && (defined(RT_OS_DARWIN) || defined(RT_OS_HAIKU) || defined(RT_OS_SOLARIS)) | |
473 | # define RTAssertDoPanic() RTR0AssertPanicSystem() | |
474 | #else | |
475 | # define RTAssertDoPanic() RTAssertDebugBreak() | |
476 | #endif | |
477 | ||
478 | /** @def AssertBreakpoint() | |
479 | * Assertion Breakpoint. | |
480 | * @deprecated Use RTAssertPanic or RTAssertDebugBreak instead. | |
481 | */ | |
482 | #ifdef RT_STRICT | |
483 | # define AssertBreakpoint() RTAssertDebugBreak() | |
484 | #else | |
485 | # define AssertBreakpoint() do { } while (0) | |
486 | #endif | |
487 | ||
488 | /** @def RTAssertPanic() | |
489 | * If RT_STRICT is defined this macro will invoke RTAssertDoPanic if | |
490 | * RTAssertShouldPanic returns true. If RT_STRICT isn't defined it won't do any | |
491 | * thing. | |
492 | */ | |
493 | #if defined(RT_STRICT) && !defined(RTASSERT_DONT_PANIC) | |
494 | # define RTAssertPanic() do { if (RTAssertShouldPanic()) RTAssertDoPanic(); } while (0) | |
495 | #else | |
496 | # define RTAssertPanic() do { } while (0) | |
497 | #endif | |
498 | ||
499 | /** @def Assert | |
500 | * Assert that an expression is true. If false, hit breakpoint. | |
501 | * @param expr Expression which should be true. | |
502 | */ | |
503 | #ifdef RT_STRICT | |
504 | # define Assert(expr) \ | |
505 | do { \ | |
506 | if (RT_LIKELY(!!(expr))) \ | |
507 | { /* likely */ } \ | |
508 | else \ | |
509 | { \ | |
510 | RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \ | |
511 | RTAssertPanic(); \ | |
512 | } \ | |
513 | } while (0) | |
514 | #else | |
515 | # define Assert(expr) do { } while (0) | |
516 | #endif | |
517 | ||
518 | ||
519 | /** @def AssertStmt | |
520 | * Assert that an expression is true. If false, hit breakpoint and execute the | |
521 | * statement. | |
522 | * @param expr Expression which should be true. | |
523 | * @param stmt Statement to execute on failure. | |
524 | */ | |
525 | #ifdef RT_STRICT | |
526 | # define AssertStmt(expr, stmt) \ | |
527 | do { \ | |
528 | if (RT_LIKELY(!!(expr))) \ | |
529 | { /* likely */ } \ | |
530 | else \ | |
531 | { \ | |
532 | RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \ | |
533 | RTAssertPanic(); \ | |
534 | stmt; \ | |
535 | } \ | |
536 | } while (0) | |
537 | #else | |
538 | # define AssertStmt(expr, stmt) \ | |
539 | do { \ | |
540 | if (RT_LIKELY(!!(expr))) \ | |
541 | { /* likely */ } \ | |
542 | else \ | |
543 | { \ | |
544 | stmt; \ | |
545 | } \ | |
546 | } while (0) | |
547 | #endif | |
548 | ||
549 | ||
550 | /** @def AssertReturn | |
551 | * Assert that an expression is true and returns if it isn't. | |
552 | * In RT_STRICT mode it will hit a breakpoint before returning. | |
553 | * | |
554 | * @param expr Expression which should be true. | |
555 | * @param rc What is to be presented to return. | |
556 | */ | |
557 | #ifdef RT_STRICT | |
558 | # define AssertReturn(expr, rc) \ | |
559 | do { \ | |
560 | if (RT_LIKELY(!!(expr))) \ | |
561 | { /* likely */ } \ | |
562 | else \ | |
563 | { \ | |
564 | RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \ | |
565 | RTAssertPanic(); \ | |
566 | return (rc); \ | |
567 | } \ | |
568 | } while (0) | |
569 | #else | |
570 | # define AssertReturn(expr, rc) \ | |
571 | do { \ | |
572 | if (RT_LIKELY(!!(expr))) \ | |
573 | { /* likely */ } \ | |
574 | else \ | |
575 | return (rc); \ | |
576 | } while (0) | |
577 | #endif | |
578 | ||
579 | /** @def AssertReturnStmt | |
580 | * Assert that an expression is true, if it isn't execute the given statement | |
581 | * and return rc. | |
582 | * | |
583 | * In RT_STRICT mode it will hit a breakpoint before executing the statement and | |
584 | * returning. | |
585 | * | |
586 | * @param expr Expression which should be true. | |
587 | * @param stmt Statement to execute before returning on failure. | |
588 | * @param rc What is to be presented to return. | |
589 | */ | |
590 | #ifdef RT_STRICT | |
591 | # define AssertReturnStmt(expr, stmt, rc) \ | |
592 | do { \ | |
593 | if (RT_LIKELY(!!(expr))) \ | |
594 | { /* likely */ } \ | |
595 | else \ | |
596 | { \ | |
597 | RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
598 | RTAssertPanic(); \ | |
599 | stmt; \ | |
600 | return (rc); \ | |
601 | } \ | |
602 | } while (0) | |
603 | #else | |
604 | # define AssertReturnStmt(expr, stmt, rc) \ | |
605 | do { \ | |
606 | if (RT_LIKELY(!!(expr))) \ | |
607 | { /* likely */ } \ | |
608 | else \ | |
609 | { \ | |
610 | stmt; \ | |
611 | return (rc); \ | |
612 | } \ | |
613 | } while (0) | |
614 | #endif | |
615 | ||
616 | /** @def AssertReturnVoid | |
617 | * Assert that an expression is true and returns if it isn't. | |
618 | * In RT_STRICT mode it will hit a breakpoint before returning. | |
619 | * | |
620 | * @param expr Expression which should be true. | |
621 | */ | |
622 | #ifdef RT_STRICT | |
623 | # define AssertReturnVoid(expr) \ | |
624 | do { \ | |
625 | if (RT_LIKELY(!!(expr))) \ | |
626 | { /* likely */ } \ | |
627 | else \ | |
628 | { \ | |
629 | RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \ | |
630 | RTAssertPanic(); \ | |
631 | return; \ | |
632 | } \ | |
633 | } while (0) | |
634 | #else | |
635 | # define AssertReturnVoid(expr) \ | |
636 | do { \ | |
637 | if (RT_LIKELY(!!(expr))) \ | |
638 | { /* likely */ } \ | |
639 | else \ | |
640 | return; \ | |
641 | } while (0) | |
642 | #endif | |
643 | ||
644 | /** @def AssertReturnVoidStmt | |
645 | * Assert that an expression is true, if it isn't execute the given statement | |
646 | * and return. | |
647 | * | |
648 | * In RT_STRICT mode it will hit a breakpoint before returning. | |
649 | * | |
650 | * @param expr Expression which should be true. | |
651 | * @param stmt Statement to execute before returning on failure. | |
652 | */ | |
653 | #ifdef RT_STRICT | |
654 | # define AssertReturnVoidStmt(expr, stmt) \ | |
655 | do { \ | |
656 | if (RT_LIKELY(!!(expr))) \ | |
657 | { /* likely */ } \ | |
658 | else \ | |
659 | { \ | |
660 | RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
661 | RTAssertPanic(); \ | |
662 | stmt; \ | |
663 | return; \ | |
664 | } \ | |
665 | } while (0) | |
666 | #else | |
667 | # define AssertReturnVoidStmt(expr, stmt) \ | |
668 | do { \ | |
669 | if (RT_LIKELY(!!(expr))) \ | |
670 | { /* likely */ } \ | |
671 | else \ | |
672 | { \ | |
673 | stmt; \ | |
674 | return; \ | |
675 | } \ | |
676 | } while (0) | |
677 | #endif | |
678 | ||
679 | ||
680 | /** @def AssertBreak | |
681 | * Assert that an expression is true and breaks if it isn't. | |
682 | * In RT_STRICT mode it will hit a breakpoint before breaking. | |
683 | * | |
684 | * @param expr Expression which should be true. | |
685 | */ | |
686 | #ifdef RT_STRICT | |
687 | # define AssertBreak(expr) \ | |
688 | if (RT_LIKELY(!!(expr))) \ | |
689 | { /* likely */ } \ | |
690 | else if (1) \ | |
691 | { \ | |
692 | RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
693 | RTAssertPanic(); \ | |
694 | break; \ | |
695 | } else do {} while (0) | |
696 | #else | |
697 | # define AssertBreak(expr) \ | |
698 | if (RT_LIKELY(!!(expr))) \ | |
699 | { /* likely */ } \ | |
700 | else \ | |
701 | break | |
702 | #endif | |
703 | ||
704 | /** @def AssertContinue | |
705 | * Assert that an expression is true and continue if it isn't. | |
706 | * In RT_STRICT mode it will hit a breakpoint before continuing. | |
707 | * | |
708 | * @param expr Expression which should be true. | |
709 | */ | |
710 | #ifdef RT_STRICT | |
711 | # define AssertContinue(expr) \ | |
712 | if (RT_LIKELY(!!(expr))) \ | |
713 | { /* likely */ } \ | |
714 | else if (1) \ | |
715 | { \ | |
716 | RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
717 | RTAssertPanic(); \ | |
718 | continue; \ | |
719 | } else do {} while (0) | |
720 | #else | |
721 | # define AssertContinue(expr) \ | |
722 | if (RT_LIKELY(!!(expr))) \ | |
723 | { /* likely */ } \ | |
724 | else \ | |
725 | continue | |
726 | #endif | |
727 | ||
728 | /** @def AssertBreakStmt | |
729 | * Assert that an expression is true and breaks if it isn't. | |
730 | * In RT_STRICT mode it will hit a breakpoint before doing break. | |
731 | * | |
732 | * @param expr Expression which should be true. | |
733 | * @param stmt Statement to execute before break in case of a failed assertion. | |
734 | */ | |
735 | #ifdef RT_STRICT | |
736 | # define AssertBreakStmt(expr, stmt) \ | |
737 | if (RT_LIKELY(!!(expr))) \ | |
738 | { /* likely */ } \ | |
739 | else if (1) \ | |
740 | { \ | |
741 | RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
742 | RTAssertPanic(); \ | |
743 | stmt; \ | |
744 | break; \ | |
745 | } else do {} while (0) | |
746 | #else | |
747 | # define AssertBreakStmt(expr, stmt) \ | |
748 | if (RT_LIKELY(!!(expr))) \ | |
749 | { /* likely */ } \ | |
750 | else if (1) \ | |
751 | { \ | |
752 | stmt; \ | |
753 | break; \ | |
754 | } else do {} while (0) | |
755 | #endif | |
756 | ||
757 | ||
758 | /** @def AssertMsg | |
759 | * Assert that an expression is true. If it's not print message and hit breakpoint. | |
760 | * @param expr Expression which should be true. | |
761 | * @param a printf argument list (in parenthesis). | |
762 | */ | |
763 | #ifdef RT_STRICT | |
764 | # define AssertMsg(expr, a) \ | |
765 | do { \ | |
766 | if (RT_LIKELY(!!(expr))) \ | |
767 | { /* likely */ } \ | |
768 | else \ | |
769 | { \ | |
770 | RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \ | |
771 | RTAssertMsg2Weak a; \ | |
772 | RTAssertPanic(); \ | |
773 | } \ | |
774 | } while (0) | |
775 | #else | |
776 | # define AssertMsg(expr, a) do { } while (0) | |
777 | #endif | |
778 | ||
779 | /** @def AssertMsgStmt | |
780 | * Assert that an expression is true. If it's not print message and hit | |
781 | * breakpoint and execute the statement. | |
782 | * | |
783 | * @param expr Expression which should be true. | |
784 | * @param a printf argument list (in parenthesis). | |
785 | * @param stmt Statement to execute in case of a failed assertion. | |
786 | * | |
787 | * @remarks The expression and statement will be evaluated in all build types. | |
788 | */ | |
789 | #ifdef RT_STRICT | |
790 | # define AssertMsgStmt(expr, a, stmt) \ | |
791 | do { \ | |
792 | if (RT_LIKELY(!!(expr))) \ | |
793 | { /* likely */ } \ | |
794 | else \ | |
795 | { \ | |
796 | RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
797 | RTAssertMsg2Weak a; \ | |
798 | RTAssertPanic(); \ | |
799 | stmt; \ | |
800 | } \ | |
801 | } while (0) | |
802 | #else | |
803 | # define AssertMsgStmt(expr, a, stmt) \ | |
804 | do { \ | |
805 | if (RT_LIKELY(!!(expr))) \ | |
806 | { /* likely */ } \ | |
807 | else \ | |
808 | { \ | |
809 | stmt; \ | |
810 | } \ | |
811 | } while (0) | |
812 | #endif | |
813 | ||
814 | /** @def AssertMsgReturn | |
815 | * Assert that an expression is true and returns if it isn't. | |
816 | * In RT_STRICT mode it will hit a breakpoint before returning. | |
817 | * | |
818 | * @param expr Expression which should be true. | |
819 | * @param a printf argument list (in parenthesis). | |
820 | * @param rc What is to be presented to return. | |
821 | */ | |
822 | #ifdef RT_STRICT | |
823 | # define AssertMsgReturn(expr, a, rc) \ | |
824 | do { \ | |
825 | if (RT_LIKELY(!!(expr))) \ | |
826 | { /* likely */ } \ | |
827 | else \ | |
828 | { \ | |
829 | RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \ | |
830 | RTAssertMsg2Weak a; \ | |
831 | RTAssertPanic(); \ | |
832 | return (rc); \ | |
833 | } \ | |
834 | } while (0) | |
835 | #else | |
836 | # define AssertMsgReturn(expr, a, rc) \ | |
837 | do { \ | |
838 | if (RT_LIKELY(!!(expr))) \ | |
839 | { /* likely */ } \ | |
840 | else \ | |
841 | return (rc); \ | |
842 | } while (0) | |
843 | #endif | |
844 | ||
845 | /** @def AssertMsgReturnStmt | |
846 | * Assert that an expression is true, if it isn't execute the statement and | |
847 | * return. | |
848 | * | |
849 | * In RT_STRICT mode it will hit a breakpoint before returning. | |
850 | * | |
851 | * @param expr Expression which should be true. | |
852 | * @param a printf argument list (in parenthesis). | |
853 | * @param stmt Statement to execute before returning in case of a failed | |
854 | * assertion. | |
855 | * @param rc What is to be presented to return. | |
856 | */ | |
857 | #ifdef RT_STRICT | |
858 | # define AssertMsgReturnStmt(expr, a, stmt, rc) \ | |
859 | do { \ | |
860 | if (RT_LIKELY(!!(expr))) \ | |
861 | { /* likely */ } \ | |
862 | else \ | |
863 | { \ | |
864 | RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
865 | RTAssertMsg2Weak a; \ | |
866 | RTAssertPanic(); \ | |
867 | stmt; \ | |
868 | return (rc); \ | |
869 | } \ | |
870 | } while (0) | |
871 | #else | |
872 | # define AssertMsgReturnStmt(expr, a, stmt, rc) \ | |
873 | do { \ | |
874 | if (RT_LIKELY(!!(expr))) \ | |
875 | { /* likely */ } \ | |
876 | else \ | |
877 | { \ | |
878 | stmt; \ | |
879 | return (rc); \ | |
880 | } \ | |
881 | } while (0) | |
882 | #endif | |
883 | ||
884 | /** @def AssertMsgReturnVoid | |
885 | * Assert that an expression is true and returns if it isn't. | |
886 | * In RT_STRICT mode it will hit a breakpoint before returning. | |
887 | * | |
888 | * @param expr Expression which should be true. | |
889 | * @param a printf argument list (in parenthesis). | |
890 | */ | |
891 | #ifdef RT_STRICT | |
892 | # define AssertMsgReturnVoid(expr, a) \ | |
893 | do { \ | |
894 | if (RT_LIKELY(!!(expr))) \ | |
895 | { /* likely */ } \ | |
896 | else \ | |
897 | { \ | |
898 | RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \ | |
899 | RTAssertMsg2Weak a; \ | |
900 | RTAssertPanic(); \ | |
901 | return; \ | |
902 | } \ | |
903 | } while (0) | |
904 | #else | |
905 | # define AssertMsgReturnVoid(expr, a) \ | |
906 | do { \ | |
907 | if (RT_LIKELY(!!(expr))) \ | |
908 | { /* likely */ } \ | |
909 | else \ | |
910 | return; \ | |
911 | } while (0) | |
912 | #endif | |
913 | ||
914 | /** @def AssertMsgReturnVoidStmt | |
915 | * Assert that an expression is true, if it isn't execute the statement and | |
916 | * return. | |
917 | * | |
918 | * In RT_STRICT mode it will hit a breakpoint before returning. | |
919 | * | |
920 | * @param expr Expression which should be true. | |
921 | * @param a printf argument list (in parenthesis). | |
922 | * @param stmt Statement to execute before return in case of a failed assertion. | |
923 | */ | |
924 | #ifdef RT_STRICT | |
925 | # define AssertMsgReturnVoidStmt(expr, a, stmt) \ | |
926 | do { \ | |
927 | if (RT_LIKELY(!!(expr))) \ | |
928 | { /* likely */ } \ | |
929 | else \ | |
930 | { \ | |
931 | RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
932 | RTAssertMsg2Weak a; \ | |
933 | RTAssertPanic(); \ | |
934 | stmt; \ | |
935 | return; \ | |
936 | } \ | |
937 | } while (0) | |
938 | #else | |
939 | # define AssertMsgReturnVoidStmt(expr, a, stmt) \ | |
940 | do { \ | |
941 | if (RT_LIKELY(!!(expr))) \ | |
942 | { /* likely */ } \ | |
943 | else \ | |
944 | { \ | |
945 | stmt; \ | |
946 | return; \ | |
947 | } \ | |
948 | } while (0) | |
949 | #endif | |
950 | ||
951 | ||
952 | /** @def AssertMsgBreak | |
953 | * Assert that an expression is true and breaks if it isn't. | |
954 | * In RT_STRICT mode it will hit a breakpoint before returning. | |
955 | * | |
956 | * @param expr Expression which should be true. | |
957 | * @param a printf argument list (in parenthesis). | |
958 | */ | |
959 | #ifdef RT_STRICT | |
960 | # define AssertMsgBreak(expr, a) \ | |
961 | if (RT_LIKELY(!!(expr))) \ | |
962 | { /* likely */ } \ | |
963 | else if (1) \ | |
964 | { \ | |
965 | RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
966 | RTAssertMsg2Weak a; \ | |
967 | RTAssertPanic(); \ | |
968 | break; \ | |
969 | } else do {} while (0) | |
970 | #else | |
971 | # define AssertMsgBreak(expr, a) \ | |
972 | if (RT_LIKELY(!!(expr))) \ | |
973 | { /* likely */ } \ | |
974 | else \ | |
975 | break | |
976 | #endif | |
977 | ||
978 | /** @def AssertMsgBreakStmt | |
979 | * Assert that an expression is true and breaks if it isn't. | |
980 | * In RT_STRICT mode it will hit a breakpoint before doing break. | |
981 | * | |
982 | * @param expr Expression which should be true. | |
983 | * @param a printf argument list (in parenthesis). | |
984 | * @param stmt Statement to execute before break in case of a failed assertion. | |
985 | */ | |
986 | #ifdef RT_STRICT | |
987 | # define AssertMsgBreakStmt(expr, a, stmt) \ | |
988 | if (RT_LIKELY(!!(expr))) \ | |
989 | { /* likely */ } \ | |
990 | else if (1) \ | |
991 | { \ | |
992 | RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
993 | RTAssertMsg2Weak a; \ | |
994 | RTAssertPanic(); \ | |
995 | stmt; \ | |
996 | break; \ | |
997 | } else do {} while (0) | |
998 | #else | |
999 | # define AssertMsgBreakStmt(expr, a, stmt) \ | |
1000 | if (RT_LIKELY(!!(expr))) \ | |
1001 | { /* likely */ } \ | |
1002 | else if (1) \ | |
1003 | { \ | |
1004 | stmt; \ | |
1005 | break; \ | |
1006 | } else do {} while (0) | |
1007 | #endif | |
1008 | ||
1009 | /** @def AssertFailed | |
1010 | * An assertion failed, hit breakpoint. | |
1011 | */ | |
1012 | #ifdef RT_STRICT | |
1013 | # define AssertFailed() \ | |
1014 | do { \ | |
1015 | RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \ | |
1016 | RTAssertPanic(); \ | |
1017 | } while (0) | |
1018 | #else | |
1019 | # define AssertFailed() do { } while (0) | |
1020 | #endif | |
1021 | ||
1022 | /** @def AssertFailedStmt | |
1023 | * An assertion failed, hit breakpoint and execute statement. | |
1024 | */ | |
1025 | #ifdef RT_STRICT | |
1026 | # define AssertFailedStmt(stmt) \ | |
1027 | do { \ | |
1028 | RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \ | |
1029 | RTAssertPanic(); \ | |
1030 | stmt; \ | |
1031 | } while (0) | |
1032 | #else | |
1033 | # define AssertFailedStmt(stmt) do { stmt; } while (0) | |
1034 | #endif | |
1035 | ||
1036 | /** @def AssertFailedReturn | |
1037 | * An assertion failed, hit breakpoint (RT_STRICT mode only) and return. | |
1038 | * | |
1039 | * @param rc The rc to return. | |
1040 | */ | |
1041 | #ifdef RT_STRICT | |
1042 | # define AssertFailedReturn(rc) \ | |
1043 | do { \ | |
1044 | RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1045 | RTAssertPanic(); \ | |
1046 | return (rc); \ | |
1047 | } while (0) | |
1048 | #else | |
1049 | # define AssertFailedReturn(rc) \ | |
1050 | do { \ | |
1051 | return (rc); \ | |
1052 | } while (0) | |
1053 | #endif | |
1054 | ||
1055 | /** @def AssertFailedReturnStmt | |
1056 | * An assertion failed, hit breakpoint (RT_STRICT mode only), execute a | |
1057 | * statement and return a value. | |
1058 | * | |
1059 | * @param stmt The statement to execute before returning. | |
1060 | * @param rc The value to return. | |
1061 | */ | |
1062 | #ifdef RT_STRICT | |
1063 | # define AssertFailedReturnStmt(stmt, rc) \ | |
1064 | do { \ | |
1065 | RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1066 | RTAssertPanic(); \ | |
1067 | stmt; \ | |
1068 | return (rc); \ | |
1069 | } while (0) | |
1070 | #else | |
1071 | # define AssertFailedReturnStmt(stmt, rc) \ | |
1072 | do { \ | |
1073 | stmt; \ | |
1074 | return (rc); \ | |
1075 | } while (0) | |
1076 | #endif | |
1077 | ||
1078 | /** @def AssertFailedReturnVoid | |
1079 | * An assertion failed, hit breakpoint (RT_STRICT mode only) and return. | |
1080 | */ | |
1081 | #ifdef RT_STRICT | |
1082 | # define AssertFailedReturnVoid() \ | |
1083 | do { \ | |
1084 | RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1085 | RTAssertPanic(); \ | |
1086 | return; \ | |
1087 | } while (0) | |
1088 | #else | |
1089 | # define AssertFailedReturnVoid() \ | |
1090 | do { \ | |
1091 | return; \ | |
1092 | } while (0) | |
1093 | #endif | |
1094 | ||
1095 | /** @def AssertFailedReturnVoidStmt | |
1096 | * An assertion failed, hit breakpoint (RT_STRICT mode only), execute a | |
1097 | * statement and return. | |
1098 | * | |
1099 | * @param stmt The statement to execute before returning. | |
1100 | */ | |
1101 | #ifdef RT_STRICT | |
1102 | # define AssertFailedReturnVoidStmt(stmt) \ | |
1103 | do { \ | |
1104 | RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1105 | RTAssertPanic(); \ | |
1106 | stmt; \ | |
1107 | return; \ | |
1108 | } while (0) | |
1109 | #else | |
1110 | # define AssertFailedReturnVoidStmt(stmt) \ | |
1111 | do { \ | |
1112 | stmt; \ | |
1113 | return; \ | |
1114 | } while (0) | |
1115 | #endif | |
1116 | ||
1117 | ||
1118 | /** @def AssertFailedBreak | |
1119 | * An assertion failed, hit breakpoint (RT_STRICT mode only) and break. | |
1120 | */ | |
1121 | #ifdef RT_STRICT | |
1122 | # define AssertFailedBreak() \ | |
1123 | if (1) { \ | |
1124 | RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1125 | RTAssertPanic(); \ | |
1126 | break; \ | |
1127 | } else do {} while (0) | |
1128 | #else | |
1129 | # define AssertFailedBreak() \ | |
1130 | if (1) \ | |
1131 | break; \ | |
1132 | else do {} while (0) | |
1133 | #endif | |
1134 | ||
1135 | /** @def AssertFailedBreakStmt | |
1136 | * An assertion failed, hit breakpoint (RT_STRICT mode only), execute | |
1137 | * the given statement and break. | |
1138 | * | |
1139 | * @param stmt Statement to execute before break. | |
1140 | */ | |
1141 | #ifdef RT_STRICT | |
1142 | # define AssertFailedBreakStmt(stmt) \ | |
1143 | if (1) { \ | |
1144 | RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1145 | RTAssertPanic(); \ | |
1146 | stmt; \ | |
1147 | break; \ | |
1148 | } else do {} while (0) | |
1149 | #else | |
1150 | # define AssertFailedBreakStmt(stmt) \ | |
1151 | if (1) { \ | |
1152 | stmt; \ | |
1153 | break; \ | |
1154 | } else do {} while (0) | |
1155 | #endif | |
1156 | ||
1157 | ||
1158 | /** @def AssertMsgFailed | |
1159 | * An assertion failed print a message and a hit breakpoint. | |
1160 | * | |
1161 | * @param a printf argument list (in parenthesis). | |
1162 | */ | |
1163 | #ifdef RT_STRICT | |
1164 | # define AssertMsgFailed(a) \ | |
1165 | do { \ | |
1166 | RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \ | |
1167 | RTAssertMsg2Weak a; \ | |
1168 | RTAssertPanic(); \ | |
1169 | } while (0) | |
1170 | #else | |
1171 | # define AssertMsgFailed(a) do { } while (0) | |
1172 | #endif | |
1173 | ||
1174 | /** @def AssertMsgFailedReturn | |
1175 | * An assertion failed, hit breakpoint with message (RT_STRICT mode only) and return. | |
1176 | * | |
1177 | * @param a printf argument list (in parenthesis). | |
1178 | * @param rc What is to be presented to return. | |
1179 | */ | |
1180 | #ifdef RT_STRICT | |
1181 | # define AssertMsgFailedReturn(a, rc) \ | |
1182 | do { \ | |
1183 | RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1184 | RTAssertMsg2Weak a; \ | |
1185 | RTAssertPanic(); \ | |
1186 | return (rc); \ | |
1187 | } while (0) | |
1188 | #else | |
1189 | # define AssertMsgFailedReturn(a, rc) \ | |
1190 | do { \ | |
1191 | return (rc); \ | |
1192 | } while (0) | |
1193 | #endif | |
1194 | ||
1195 | /** @def AssertMsgFailedReturnVoid | |
1196 | * An assertion failed, hit breakpoint with message (RT_STRICT mode only) and return. | |
1197 | * | |
1198 | * @param a printf argument list (in parenthesis). | |
1199 | */ | |
1200 | #ifdef RT_STRICT | |
1201 | # define AssertMsgFailedReturnVoid(a) \ | |
1202 | do { \ | |
1203 | RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1204 | RTAssertMsg2Weak a; \ | |
1205 | RTAssertPanic(); \ | |
1206 | return; \ | |
1207 | } while (0) | |
1208 | #else | |
1209 | # define AssertMsgFailedReturnVoid(a) \ | |
1210 | do { \ | |
1211 | return; \ | |
1212 | } while (0) | |
1213 | #endif | |
1214 | ||
1215 | ||
1216 | /** @def AssertMsgFailedBreak | |
1217 | * An assertion failed, hit breakpoint with message (RT_STRICT mode only) and break. | |
1218 | * | |
1219 | * @param a printf argument list (in parenthesis). | |
1220 | */ | |
1221 | #ifdef RT_STRICT | |
1222 | # define AssertMsgFailedBreak(a) \ | |
1223 | if (1) { \ | |
1224 | RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1225 | RTAssertMsg2Weak a; \ | |
1226 | RTAssertPanic(); \ | |
1227 | break; \ | |
1228 | } else do {} while (0) | |
1229 | #else | |
1230 | # define AssertMsgFailedBreak(a) \ | |
1231 | if (1) \ | |
1232 | break; \ | |
1233 | else do {} while (0) | |
1234 | #endif | |
1235 | ||
1236 | /** @def AssertMsgFailedBreakStmt | |
1237 | * An assertion failed, hit breakpoint (RT_STRICT mode only), execute | |
1238 | * the given statement and break. | |
1239 | * | |
1240 | * @param a printf argument list (in parenthesis). | |
1241 | * @param stmt Statement to execute before break. | |
1242 | */ | |
1243 | #ifdef RT_STRICT | |
1244 | # define AssertMsgFailedBreakStmt(a, stmt) \ | |
1245 | if (1) { \ | |
1246 | RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1247 | RTAssertMsg2Weak a; \ | |
1248 | RTAssertPanic(); \ | |
1249 | stmt; \ | |
1250 | break; \ | |
1251 | } else do {} while (0) | |
1252 | #else | |
1253 | # define AssertMsgFailedBreakStmt(a, stmt) \ | |
1254 | if (1) { \ | |
1255 | stmt; \ | |
1256 | break; \ | |
1257 | } else do {} while (0) | |
1258 | #endif | |
1259 | ||
1260 | /** @} */ | |
1261 | ||
1262 | ||
1263 | ||
1264 | /** @name Release Log Assertions | |
1265 | * | |
1266 | * These assertions will work like normal strict assertion when RT_STRICT is | |
1267 | * defined and LogRel statements when RT_STRICT is undefined. Typically used for | |
1268 | * things which shouldn't go wrong, but when it does you'd like to know one way | |
1269 | * or the other. | |
1270 | * | |
1271 | * @{ | |
1272 | */ | |
1273 | ||
1274 | /** @def RTAssertLogRelMsg1 | |
1275 | * RTAssertMsg1Weak (strict builds) / LogRel wrapper (non-strict). | |
1276 | */ | |
1277 | #ifdef RT_STRICT | |
1278 | # define RTAssertLogRelMsg1(pszExpr, iLine, pszFile, pszFunction) \ | |
1279 | RTAssertMsg1Weak(pszExpr, iLine, pszFile, pszFunction) | |
1280 | #else | |
1281 | # define RTAssertLogRelMsg1(pszExpr, iLine, pszFile, pszFunction) \ | |
1282 | LogRel(("AssertLogRel %s(%d) %s: %s\n",\ | |
1283 | (pszFile), (iLine), (pszFunction), (pszExpr) )) | |
1284 | #endif | |
1285 | ||
1286 | /** @def RTAssertLogRelMsg2 | |
1287 | * RTAssertMsg2Weak (strict builds) / LogRel wrapper (non-strict). | |
1288 | */ | |
1289 | #ifdef RT_STRICT | |
1290 | # define RTAssertLogRelMsg2(a) RTAssertMsg2Weak a | |
1291 | #else | |
1292 | # define RTAssertLogRelMsg2(a) LogRel(a) | |
1293 | #endif | |
1294 | ||
1295 | /** @def AssertLogRel | |
1296 | * Assert that an expression is true. | |
1297 | * Strict builds will hit a breakpoint, non-strict will only do LogRel. | |
1298 | * | |
1299 | * @param expr Expression which should be true. | |
1300 | */ | |
1301 | #define AssertLogRel(expr) \ | |
1302 | do { \ | |
1303 | if (RT_LIKELY(!!(expr))) \ | |
1304 | { /* likely */ } \ | |
1305 | else \ | |
1306 | { \ | |
1307 | RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1308 | RTAssertPanic(); \ | |
1309 | } \ | |
1310 | } while (0) | |
1311 | ||
1312 | /** @def AssertLogRelReturn | |
1313 | * Assert that an expression is true, return \a rc if it isn't. | |
1314 | * Strict builds will hit a breakpoint, non-strict will only do LogRel. | |
1315 | * | |
1316 | * @param expr Expression which should be true. | |
1317 | * @param rc What is to be presented to return. | |
1318 | */ | |
1319 | #define AssertLogRelReturn(expr, rc) \ | |
1320 | do { \ | |
1321 | if (RT_LIKELY(!!(expr))) \ | |
1322 | { /* likely */ } \ | |
1323 | else \ | |
1324 | { \ | |
1325 | RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1326 | RTAssertPanic(); \ | |
1327 | return (rc); \ | |
1328 | } \ | |
1329 | } while (0) | |
1330 | ||
1331 | /** @def AssertLogRelReturnVoid | |
1332 | * Assert that an expression is true, return void if it isn't. | |
1333 | * Strict builds will hit a breakpoint, non-strict will only do LogRel. | |
1334 | * | |
1335 | * @param expr Expression which should be true. | |
1336 | */ | |
1337 | #define AssertLogRelReturnVoid(expr) \ | |
1338 | do { \ | |
1339 | if (RT_LIKELY(!!(expr))) \ | |
1340 | { /* likely */ } \ | |
1341 | else \ | |
1342 | { \ | |
1343 | RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1344 | RTAssertPanic(); \ | |
1345 | return; \ | |
1346 | } \ | |
1347 | } while (0) | |
1348 | ||
1349 | /** @def AssertLogRelBreak | |
1350 | * Assert that an expression is true, break if it isn't. | |
1351 | * Strict builds will hit a breakpoint, non-strict will only do LogRel. | |
1352 | * | |
1353 | * @param expr Expression which should be true. | |
1354 | */ | |
1355 | #define AssertLogRelBreak(expr) \ | |
1356 | if (RT_LIKELY(!!(expr))) \ | |
1357 | { /* likely */ } \ | |
1358 | else if (1) \ | |
1359 | { \ | |
1360 | RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1361 | RTAssertPanic(); \ | |
1362 | break; \ | |
1363 | } \ | |
1364 | else do {} while (0) | |
1365 | ||
1366 | /** @def AssertLogRelBreakStmt | |
1367 | * Assert that an expression is true, execute \a stmt and break if it isn't. | |
1368 | * Strict builds will hit a breakpoint, non-strict will only do LogRel. | |
1369 | * | |
1370 | * @param expr Expression which should be true. | |
1371 | * @param stmt Statement to execute before break in case of a failed assertion. | |
1372 | */ | |
1373 | #define AssertLogRelBreakStmt(expr, stmt) \ | |
1374 | if (RT_LIKELY(!!(expr))) \ | |
1375 | { /* likely */ } \ | |
1376 | else if (1) \ | |
1377 | { \ | |
1378 | RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1379 | RTAssertPanic(); \ | |
1380 | stmt; \ | |
1381 | break; \ | |
1382 | } else do {} while (0) | |
1383 | ||
1384 | /** @def AssertLogRelMsg | |
1385 | * Assert that an expression is true. | |
1386 | * Strict builds will hit a breakpoint, non-strict will only do LogRel. | |
1387 | * | |
1388 | * @param expr Expression which should be true. | |
1389 | * @param a printf argument list (in parenthesis). | |
1390 | */ | |
1391 | #define AssertLogRelMsg(expr, a) \ | |
1392 | do { \ | |
1393 | if (RT_LIKELY(!!(expr))) \ | |
1394 | { /* likely */ } \ | |
1395 | else\ | |
1396 | { \ | |
1397 | RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1398 | RTAssertLogRelMsg2(a); \ | |
1399 | RTAssertPanic(); \ | |
1400 | } \ | |
1401 | } while (0) | |
1402 | ||
1403 | /** @def AssertLogRelMsgStmt | |
1404 | * Assert that an expression is true, execute \a stmt and break if it isn't | |
1405 | * Strict builds will hit a breakpoint, non-strict will only do LogRel. | |
1406 | * | |
1407 | * @param expr Expression which should be true. | |
1408 | * @param a printf argument list (in parenthesis). | |
1409 | * @param stmt Statement to execute in case of a failed assertion. | |
1410 | */ | |
1411 | #define AssertLogRelMsgStmt(expr, a, stmt) \ | |
1412 | do { \ | |
1413 | if (RT_LIKELY(!!(expr))) \ | |
1414 | { /* likely */ } \ | |
1415 | else\ | |
1416 | { \ | |
1417 | RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1418 | RTAssertLogRelMsg2(a); \ | |
1419 | RTAssertPanic(); \ | |
1420 | stmt; \ | |
1421 | } \ | |
1422 | } while (0) | |
1423 | ||
1424 | /** @def AssertLogRelMsgReturn | |
1425 | * Assert that an expression is true, return \a rc if it isn't. | |
1426 | * Strict builds will hit a breakpoint, non-strict will only do LogRel. | |
1427 | * | |
1428 | * @param expr Expression which should be true. | |
1429 | * @param a printf argument list (in parenthesis). | |
1430 | * @param rc What is to be presented to return. | |
1431 | */ | |
1432 | #define AssertLogRelMsgReturn(expr, a, rc) \ | |
1433 | do { \ | |
1434 | if (RT_LIKELY(!!(expr))) \ | |
1435 | { /* likely */ } \ | |
1436 | else\ | |
1437 | { \ | |
1438 | RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1439 | RTAssertLogRelMsg2(a); \ | |
1440 | RTAssertPanic(); \ | |
1441 | return (rc); \ | |
1442 | } \ | |
1443 | } while (0) | |
1444 | ||
1445 | /** @def AssertLogRelMsgReturnStmt | |
1446 | * Assert that an expression is true, execute @a stmt and return @a rcRet if it | |
1447 | * isn't. | |
1448 | * Strict builds will hit a breakpoint, non-strict will only do LogRel. | |
1449 | * | |
1450 | * @param expr Expression which should be true. | |
1451 | * @param a printf argument list (in parenthesis). | |
1452 | * @param stmt Statement to execute before returning in case of a failed | |
1453 | * assertion. | |
1454 | * @param rcRet What is to be presented to return. | |
1455 | */ | |
1456 | #define AssertLogRelMsgReturnStmt(expr, a, stmt, rcRet) \ | |
1457 | do { \ | |
1458 | if (RT_LIKELY(!!(expr))) \ | |
1459 | { /* likely */ } \ | |
1460 | else\ | |
1461 | { \ | |
1462 | RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1463 | RTAssertLogRelMsg2(a); \ | |
1464 | RTAssertPanic(); \ | |
1465 | stmt; \ | |
1466 | return (rcRet); \ | |
1467 | } \ | |
1468 | } while (0) | |
1469 | ||
1470 | /** @def AssertLogRelMsgReturnVoid | |
1471 | * Assert that an expression is true, return (void) if it isn't. | |
1472 | * Strict builds will hit a breakpoint, non-strict will only do LogRel. | |
1473 | * | |
1474 | * @param expr Expression which should be true. | |
1475 | * @param a printf argument list (in parenthesis). | |
1476 | */ | |
1477 | #define AssertLogRelMsgReturnVoid(expr, a) \ | |
1478 | do { \ | |
1479 | if (RT_LIKELY(!!(expr))) \ | |
1480 | { /* likely */ } \ | |
1481 | else\ | |
1482 | { \ | |
1483 | RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1484 | RTAssertLogRelMsg2(a); \ | |
1485 | RTAssertPanic(); \ | |
1486 | return; \ | |
1487 | } \ | |
1488 | } while (0) | |
1489 | ||
1490 | /** @def AssertLogRelMsgBreak | |
1491 | * Assert that an expression is true, break if it isn't. | |
1492 | * Strict builds will hit a breakpoint, non-strict will only do LogRel. | |
1493 | * | |
1494 | * @param expr Expression which should be true. | |
1495 | * @param a printf argument list (in parenthesis). | |
1496 | */ | |
1497 | #define AssertLogRelMsgBreak(expr, a) \ | |
1498 | if (RT_LIKELY(!!(expr))) \ | |
1499 | { /* likely */ } \ | |
1500 | else if (1) \ | |
1501 | { \ | |
1502 | RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1503 | RTAssertLogRelMsg2(a); \ | |
1504 | RTAssertPanic(); \ | |
1505 | break; \ | |
1506 | } \ | |
1507 | else do {} while (0) | |
1508 | ||
1509 | /** @def AssertLogRelMsgBreakStmt | |
1510 | * Assert that an expression is true, execute \a stmt and break if it isn't. | |
1511 | * Strict builds will hit a breakpoint, non-strict will only do LogRel. | |
1512 | * | |
1513 | * @param expr Expression which should be true. | |
1514 | * @param a printf argument list (in parenthesis). | |
1515 | * @param stmt Statement to execute before break in case of a failed assertion. | |
1516 | */ | |
1517 | #define AssertLogRelMsgBreakStmt(expr, a, stmt) \ | |
1518 | if (RT_LIKELY(!!(expr))) \ | |
1519 | { /* likely */ } \ | |
1520 | else if (1) \ | |
1521 | { \ | |
1522 | RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1523 | RTAssertLogRelMsg2(a); \ | |
1524 | RTAssertPanic(); \ | |
1525 | stmt; \ | |
1526 | break; \ | |
1527 | } else do {} while (0) | |
1528 | ||
1529 | /** @def AssertLogRelFailed | |
1530 | * An assertion failed. | |
1531 | * Strict builds will hit a breakpoint, non-strict will only do LogRel. | |
1532 | */ | |
1533 | #define AssertLogRelFailed() \ | |
1534 | do { \ | |
1535 | RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1536 | RTAssertPanic(); \ | |
1537 | } while (0) | |
1538 | ||
1539 | /** @def AssertLogRelFailedReturn | |
1540 | * An assertion failed. | |
1541 | * Strict builds will hit a breakpoint, non-strict will only do LogRel. | |
1542 | * | |
1543 | * @param rc What is to be presented to return. | |
1544 | */ | |
1545 | #define AssertLogRelFailedReturn(rc) \ | |
1546 | do { \ | |
1547 | RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1548 | RTAssertPanic(); \ | |
1549 | return (rc); \ | |
1550 | } while (0) | |
1551 | ||
1552 | /** @def AssertLogRelFailedReturnVoid | |
1553 | * An assertion failed, hit a breakpoint and return. | |
1554 | * Strict builds will hit a breakpoint, non-strict will only do LogRel. | |
1555 | */ | |
1556 | #define AssertLogRelFailedReturnVoid() \ | |
1557 | do { \ | |
1558 | RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1559 | RTAssertPanic(); \ | |
1560 | return; \ | |
1561 | } while (0) | |
1562 | ||
1563 | /** @def AssertLogRelFailedBreak | |
1564 | * An assertion failed, break. | |
1565 | * Strict builds will hit a breakpoint, non-strict will only do LogRel. | |
1566 | */ | |
1567 | #define AssertLogRelFailedBreak() \ | |
1568 | if (1) \ | |
1569 | { \ | |
1570 | RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1571 | RTAssertPanic(); \ | |
1572 | break; \ | |
1573 | } else do {} while (0) | |
1574 | ||
1575 | /** @def AssertLogRelFailedBreakStmt | |
1576 | * An assertion failed, execute \a stmt and break. | |
1577 | * Strict builds will hit a breakpoint, non-strict will only do LogRel. | |
1578 | * | |
1579 | * @param stmt Statement to execute before break. | |
1580 | */ | |
1581 | #define AssertLogRelFailedBreakStmt(stmt) \ | |
1582 | if (1) \ | |
1583 | { \ | |
1584 | RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1585 | RTAssertPanic(); \ | |
1586 | stmt; \ | |
1587 | break; \ | |
1588 | } else do {} while (0) | |
1589 | ||
1590 | /** @def AssertLogRelMsgFailed | |
1591 | * An assertion failed. | |
1592 | * Strict builds will hit a breakpoint, non-strict will only do LogRel. | |
1593 | * | |
1594 | * @param a printf argument list (in parenthesis). | |
1595 | */ | |
1596 | #define AssertLogRelMsgFailed(a) \ | |
1597 | do { \ | |
1598 | RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1599 | RTAssertLogRelMsg2(a); \ | |
1600 | RTAssertPanic(); \ | |
1601 | } while (0) | |
1602 | ||
1603 | /** @def AssertLogRelMsgFailedStmt | |
1604 | * An assertion failed, execute @a stmt. | |
1605 | * | |
1606 | * Strict builds will hit a breakpoint, non-strict will only do LogRel. The | |
1607 | * statement will be executed in regardless of build type. | |
1608 | * | |
1609 | * @param a printf argument list (in parenthesis). | |
1610 | * @param stmt Statement to execute after raising/logging the assertion. | |
1611 | */ | |
1612 | #define AssertLogRelMsgFailedStmt(a, stmt) \ | |
1613 | do { \ | |
1614 | RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1615 | RTAssertLogRelMsg2(a); \ | |
1616 | RTAssertPanic(); \ | |
1617 | stmt; \ | |
1618 | } while (0) | |
1619 | ||
1620 | /** @def AssertLogRelMsgFailedReturn | |
1621 | * An assertion failed, return \a rc. | |
1622 | * Strict builds will hit a breakpoint, non-strict will only do LogRel. | |
1623 | * | |
1624 | * @param a printf argument list (in parenthesis). | |
1625 | * @param rc What is to be presented to return. | |
1626 | */ | |
1627 | #define AssertLogRelMsgFailedReturn(a, rc) \ | |
1628 | do { \ | |
1629 | RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1630 | RTAssertLogRelMsg2(a); \ | |
1631 | RTAssertPanic(); \ | |
1632 | return (rc); \ | |
1633 | } while (0) | |
1634 | ||
1635 | /** @def AssertLogRelMsgFailedReturnStmt | |
1636 | * An assertion failed, execute @a stmt and return @a rc. | |
1637 | * Strict builds will hit a breakpoint, non-strict will only do LogRel. | |
1638 | * | |
1639 | * @param a printf argument list (in parenthesis). | |
1640 | * @param stmt Statement to execute before returning in case of a failed | |
1641 | * assertion. | |
1642 | * @param rc What is to be presented to return. | |
1643 | */ | |
1644 | #define AssertLogRelMsgFailedReturnStmt(a, stmt, rc) \ | |
1645 | do { \ | |
1646 | RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1647 | RTAssertLogRelMsg2(a); \ | |
1648 | RTAssertPanic(); \ | |
1649 | stmt; \ | |
1650 | return (rc); \ | |
1651 | } while (0) | |
1652 | ||
1653 | /** @def AssertLogRelMsgFailedReturnVoid | |
1654 | * An assertion failed, return void. | |
1655 | * Strict builds will hit a breakpoint, non-strict will only do LogRel. | |
1656 | * | |
1657 | * @param a printf argument list (in parenthesis). | |
1658 | */ | |
1659 | #define AssertLogRelMsgFailedReturnVoid(a) \ | |
1660 | do { \ | |
1661 | RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1662 | RTAssertLogRelMsg2(a); \ | |
1663 | RTAssertPanic(); \ | |
1664 | return; \ | |
1665 | } while (0) | |
1666 | ||
1667 | /** @def AssertLogRelMsgFailedReturnVoidStmt | |
1668 | * An assertion failed, execute @a stmt and return void. | |
1669 | * Strict builds will hit a breakpoint, non-strict will only do LogRel. | |
1670 | * | |
1671 | * @param a printf argument list (in parenthesis). | |
1672 | * @param stmt Statement to execute before returning in case of a failed | |
1673 | * assertion. | |
1674 | */ | |
1675 | #define AssertLogRelMsgFailedReturnVoidStmt(a, stmt) \ | |
1676 | do { \ | |
1677 | RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1678 | RTAssertLogRelMsg2(a); \ | |
1679 | RTAssertPanic(); \ | |
1680 | stmt; \ | |
1681 | return; \ | |
1682 | } while (0) | |
1683 | ||
1684 | /** @def AssertLogRelMsgFailedBreak | |
1685 | * An assertion failed, break. | |
1686 | * Strict builds will hit a breakpoint, non-strict will only do LogRel. | |
1687 | * | |
1688 | * @param a printf argument list (in parenthesis). | |
1689 | */ | |
1690 | #define AssertLogRelMsgFailedBreak(a) \ | |
1691 | if (1)\ | |
1692 | { \ | |
1693 | RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1694 | RTAssertLogRelMsg2(a); \ | |
1695 | RTAssertPanic(); \ | |
1696 | break; \ | |
1697 | } else do {} while (0) | |
1698 | ||
1699 | /** @def AssertLogRelMsgFailedBreakStmt | |
1700 | * An assertion failed, execute \a stmt and break. | |
1701 | * Strict builds will hit a breakpoint, non-strict will only do LogRel. | |
1702 | * | |
1703 | * @param a printf argument list (in parenthesis). | |
1704 | * @param stmt Statement to execute before break. | |
1705 | */ | |
1706 | #define AssertLogRelMsgFailedBreakStmt(a, stmt) \ | |
1707 | if (1) \ | |
1708 | { \ | |
1709 | RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1710 | RTAssertLogRelMsg2(a); \ | |
1711 | RTAssertPanic(); \ | |
1712 | stmt; \ | |
1713 | break; \ | |
1714 | } else do {} while (0) | |
1715 | ||
1716 | /** @} */ | |
1717 | ||
1718 | ||
1719 | ||
1720 | /** @name Release Assertions | |
1721 | * | |
1722 | * These assertions are always enabled. | |
1723 | * @{ | |
1724 | */ | |
1725 | ||
1726 | /** @def RTAssertReleasePanic() | |
1727 | * Invokes RTAssertShouldPanic and RTAssertDoPanic. | |
1728 | * | |
1729 | * It might seem odd that RTAssertShouldPanic is necessary when its result isn't | |
1730 | * checked, but it's done since RTAssertShouldPanic is overrideable and might be | |
1731 | * used to bail out before taking down the system (the VMMR0 case). | |
1732 | */ | |
1733 | #define RTAssertReleasePanic() do { RTAssertShouldPanic(); RTAssertDoPanic(); } while (0) | |
1734 | ||
1735 | ||
1736 | /** @def AssertRelease | |
1737 | * Assert that an expression is true. If it's not hit a breakpoint. | |
1738 | * | |
1739 | * @param expr Expression which should be true. | |
1740 | */ | |
1741 | #define AssertRelease(expr) \ | |
1742 | do { \ | |
1743 | if (RT_LIKELY(!!(expr))) \ | |
1744 | { /* likely */ } \ | |
1745 | else \ | |
1746 | { \ | |
1747 | RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \ | |
1748 | RTAssertReleasePanic(); \ | |
1749 | } \ | |
1750 | } while (0) | |
1751 | ||
1752 | /** @def AssertReleaseReturn | |
1753 | * Assert that an expression is true, hit a breakpoint and return if it isn't. | |
1754 | * | |
1755 | * @param expr Expression which should be true. | |
1756 | * @param rc What is to be presented to return. | |
1757 | */ | |
1758 | #define AssertReleaseReturn(expr, rc) \ | |
1759 | do { \ | |
1760 | if (RT_LIKELY(!!(expr))) \ | |
1761 | { /* likely */ } \ | |
1762 | else \ | |
1763 | { \ | |
1764 | RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1765 | RTAssertReleasePanic(); \ | |
1766 | return (rc); \ | |
1767 | } \ | |
1768 | } while (0) | |
1769 | ||
1770 | /** @def AssertReleaseReturnVoid | |
1771 | * Assert that an expression is true, hit a breakpoint and return if it isn't. | |
1772 | * | |
1773 | * @param expr Expression which should be true. | |
1774 | */ | |
1775 | #define AssertReleaseReturnVoid(expr) \ | |
1776 | do { \ | |
1777 | if (RT_LIKELY(!!(expr))) \ | |
1778 | { /* likely */ } \ | |
1779 | else \ | |
1780 | { \ | |
1781 | RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1782 | RTAssertReleasePanic(); \ | |
1783 | return; \ | |
1784 | } \ | |
1785 | } while (0) | |
1786 | ||
1787 | ||
1788 | /** @def AssertReleaseBreak | |
1789 | * Assert that an expression is true, hit a breakpoint and break if it isn't. | |
1790 | * | |
1791 | * @param expr Expression which should be true. | |
1792 | */ | |
1793 | #define AssertReleaseBreak(expr) \ | |
1794 | if (RT_LIKELY(!!(expr))) \ | |
1795 | { /* likely */ } \ | |
1796 | else if (1) \ | |
1797 | { \ | |
1798 | RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1799 | RTAssertReleasePanic(); \ | |
1800 | break; \ | |
1801 | } else do {} while (0) | |
1802 | ||
1803 | /** @def AssertReleaseBreakStmt | |
1804 | * Assert that an expression is true, hit a breakpoint and break if it isn't. | |
1805 | * | |
1806 | * @param expr Expression which should be true. | |
1807 | * @param stmt Statement to execute before break in case of a failed assertion. | |
1808 | */ | |
1809 | #define AssertReleaseBreakStmt(expr, stmt) \ | |
1810 | if (RT_LIKELY(!!(expr))) \ | |
1811 | { /* likely */ } \ | |
1812 | else if (1) \ | |
1813 | { \ | |
1814 | RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1815 | RTAssertReleasePanic(); \ | |
1816 | stmt; \ | |
1817 | break; \ | |
1818 | } else do {} while (0) | |
1819 | ||
1820 | ||
1821 | /** @def AssertReleaseMsg | |
1822 | * Assert that an expression is true, print the message and hit a breakpoint if it isn't. | |
1823 | * | |
1824 | * @param expr Expression which should be true. | |
1825 | * @param a printf argument list (in parenthesis). | |
1826 | */ | |
1827 | #define AssertReleaseMsg(expr, a) \ | |
1828 | do { \ | |
1829 | if (RT_LIKELY(!!(expr))) \ | |
1830 | { /* likely */ } \ | |
1831 | else \ | |
1832 | { \ | |
1833 | RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1834 | RTAssertMsg2Weak a; \ | |
1835 | RTAssertReleasePanic(); \ | |
1836 | } \ | |
1837 | } while (0) | |
1838 | ||
1839 | /** @def AssertReleaseMsgReturn | |
1840 | * Assert that an expression is true, print the message and hit a breakpoint and return if it isn't. | |
1841 | * | |
1842 | * @param expr Expression which should be true. | |
1843 | * @param a printf argument list (in parenthesis). | |
1844 | * @param rc What is to be presented to return. | |
1845 | */ | |
1846 | #define AssertReleaseMsgReturn(expr, a, rc) \ | |
1847 | do { \ | |
1848 | if (RT_LIKELY(!!(expr))) \ | |
1849 | { /* likely */ } \ | |
1850 | else \ | |
1851 | { \ | |
1852 | RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1853 | RTAssertMsg2Weak a; \ | |
1854 | RTAssertReleasePanic(); \ | |
1855 | return (rc); \ | |
1856 | } \ | |
1857 | } while (0) | |
1858 | ||
1859 | /** @def AssertReleaseMsgReturnVoid | |
1860 | * Assert that an expression is true, print the message and hit a breakpoint and return if it isn't. | |
1861 | * | |
1862 | * @param expr Expression which should be true. | |
1863 | * @param a printf argument list (in parenthesis). | |
1864 | */ | |
1865 | #define AssertReleaseMsgReturnVoid(expr, a) \ | |
1866 | do { \ | |
1867 | if (RT_LIKELY(!!(expr))) \ | |
1868 | { /* likely */ } \ | |
1869 | else \ | |
1870 | { \ | |
1871 | RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1872 | RTAssertMsg2Weak a; \ | |
1873 | RTAssertReleasePanic(); \ | |
1874 | return; \ | |
1875 | } \ | |
1876 | } while (0) | |
1877 | ||
1878 | ||
1879 | /** @def AssertReleaseMsgBreak | |
1880 | * Assert that an expression is true, print the message and hit a breakpoint and break if it isn't. | |
1881 | * | |
1882 | * @param expr Expression which should be true. | |
1883 | * @param a printf argument list (in parenthesis). | |
1884 | */ | |
1885 | #define AssertReleaseMsgBreak(expr, a) \ | |
1886 | if (RT_LIKELY(!!(expr))) \ | |
1887 | { /* likely */ } \ | |
1888 | else if (1) \ | |
1889 | { \ | |
1890 | RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1891 | RTAssertMsg2Weak a; \ | |
1892 | RTAssertReleasePanic(); \ | |
1893 | break; \ | |
1894 | } else do {} while (0) | |
1895 | ||
1896 | /** @def AssertReleaseMsgBreakStmt | |
1897 | * Assert that an expression is true, print the message and hit a breakpoint and break if it isn't. | |
1898 | * | |
1899 | * @param expr Expression which should be true. | |
1900 | * @param a printf argument list (in parenthesis). | |
1901 | * @param stmt Statement to execute before break in case of a failed assertion. | |
1902 | */ | |
1903 | #define AssertReleaseMsgBreakStmt(expr, a, stmt) \ | |
1904 | if (RT_LIKELY(!!(expr))) \ | |
1905 | { /* likely */ } \ | |
1906 | else if (1) \ | |
1907 | { \ | |
1908 | RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1909 | RTAssertMsg2Weak a; \ | |
1910 | RTAssertReleasePanic(); \ | |
1911 | stmt; \ | |
1912 | break; \ | |
1913 | } else do {} while (0) | |
1914 | ||
1915 | ||
1916 | /** @def AssertReleaseFailed | |
1917 | * An assertion failed, hit a breakpoint. | |
1918 | */ | |
1919 | #define AssertReleaseFailed() \ | |
1920 | do { \ | |
1921 | RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1922 | RTAssertReleasePanic(); \ | |
1923 | } while (0) | |
1924 | ||
1925 | /** @def AssertReleaseFailedReturn | |
1926 | * An assertion failed, hit a breakpoint and return. | |
1927 | * | |
1928 | * @param rc What is to be presented to return. | |
1929 | */ | |
1930 | #define AssertReleaseFailedReturn(rc) \ | |
1931 | do { \ | |
1932 | RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1933 | RTAssertReleasePanic(); \ | |
1934 | return (rc); \ | |
1935 | } while (0) | |
1936 | ||
1937 | /** @def AssertReleaseFailedReturnVoid | |
1938 | * An assertion failed, hit a breakpoint and return. | |
1939 | */ | |
1940 | #define AssertReleaseFailedReturnVoid() \ | |
1941 | do { \ | |
1942 | RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1943 | RTAssertReleasePanic(); \ | |
1944 | return; \ | |
1945 | } while (0) | |
1946 | ||
1947 | ||
1948 | /** @def AssertReleaseFailedBreak | |
1949 | * An assertion failed, hit a breakpoint and break. | |
1950 | */ | |
1951 | #define AssertReleaseFailedBreak() \ | |
1952 | if (1) { \ | |
1953 | RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1954 | RTAssertReleasePanic(); \ | |
1955 | break; \ | |
1956 | } else do {} while (0) | |
1957 | ||
1958 | /** @def AssertReleaseFailedBreakStmt | |
1959 | * An assertion failed, hit a breakpoint and break. | |
1960 | * | |
1961 | * @param stmt Statement to execute before break. | |
1962 | */ | |
1963 | #define AssertReleaseFailedBreakStmt(stmt) \ | |
1964 | if (1) { \ | |
1965 | RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1966 | RTAssertReleasePanic(); \ | |
1967 | stmt; \ | |
1968 | break; \ | |
1969 | } else do {} while (0) | |
1970 | ||
1971 | ||
1972 | /** @def AssertReleaseMsgFailed | |
1973 | * An assertion failed, print a message and hit a breakpoint. | |
1974 | * | |
1975 | * @param a printf argument list (in parenthesis). | |
1976 | */ | |
1977 | #define AssertReleaseMsgFailed(a) \ | |
1978 | do { \ | |
1979 | RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \ | |
1980 | RTAssertMsg2Weak a; \ | |
1981 | RTAssertReleasePanic(); \ | |
1982 | } while (0) | |
1983 | ||
1984 | /** @def AssertReleaseMsgFailedReturn | |
1985 | * An assertion failed, print a message, hit a breakpoint and return. | |
1986 | * | |
1987 | * @param a printf argument list (in parenthesis). | |
1988 | * @param rc What is to be presented to return. | |
1989 | */ | |
1990 | #define AssertReleaseMsgFailedReturn(a, rc) \ | |
1991 | do { \ | |
1992 | RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
1993 | RTAssertMsg2Weak a; \ | |
1994 | RTAssertReleasePanic(); \ | |
1995 | return (rc); \ | |
1996 | } while (0) | |
1997 | ||
1998 | /** @def AssertReleaseMsgFailedReturnVoid | |
1999 | * An assertion failed, print a message, hit a breakpoint and return. | |
2000 | * | |
2001 | * @param a printf argument list (in parenthesis). | |
2002 | */ | |
2003 | #define AssertReleaseMsgFailedReturnVoid(a) \ | |
2004 | do { \ | |
2005 | RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
2006 | RTAssertMsg2Weak a; \ | |
2007 | RTAssertReleasePanic(); \ | |
2008 | return; \ | |
2009 | } while (0) | |
2010 | ||
2011 | ||
2012 | /** @def AssertReleaseMsgFailedBreak | |
2013 | * An assertion failed, print a message, hit a breakpoint and break. | |
2014 | * | |
2015 | * @param a printf argument list (in parenthesis). | |
2016 | */ | |
2017 | #define AssertReleaseMsgFailedBreak(a) \ | |
2018 | if (1) { \ | |
2019 | RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
2020 | RTAssertMsg2Weak a; \ | |
2021 | RTAssertReleasePanic(); \ | |
2022 | break; \ | |
2023 | } else do {} while (0) | |
2024 | ||
2025 | /** @def AssertReleaseMsgFailedBreakStmt | |
2026 | * An assertion failed, print a message, hit a breakpoint and break. | |
2027 | * | |
2028 | * @param a printf argument list (in parenthesis). | |
2029 | * @param stmt Statement to execute before break. | |
2030 | */ | |
2031 | #define AssertReleaseMsgFailedBreakStmt(a, stmt) \ | |
2032 | if (1) { \ | |
2033 | RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
2034 | RTAssertMsg2Weak a; \ | |
2035 | RTAssertReleasePanic(); \ | |
2036 | stmt; \ | |
2037 | break; \ | |
2038 | } else do {} while (0) | |
2039 | ||
2040 | /** @} */ | |
2041 | ||
2042 | ||
2043 | ||
2044 | /** @name Fatal Assertions | |
2045 | * These are similar to release assertions except that you cannot ignore them in | |
2046 | * any way, they will loop for ever if RTAssertDoPanic returns. | |
2047 | * | |
2048 | * @{ | |
2049 | */ | |
2050 | ||
2051 | /** @def AssertFatal | |
2052 | * Assert that an expression is true. If it's not hit a breakpoint (for ever). | |
2053 | * | |
2054 | * @param expr Expression which should be true. | |
2055 | */ | |
2056 | #define AssertFatal(expr) \ | |
2057 | do { \ | |
2058 | if (RT_LIKELY(!!(expr))) \ | |
2059 | { /* likely */ } \ | |
2060 | else \ | |
2061 | for (;;) \ | |
2062 | { \ | |
2063 | RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
2064 | RTAssertReleasePanic(); \ | |
2065 | } \ | |
2066 | } while (0) | |
2067 | ||
2068 | /** @def AssertFatalMsg | |
2069 | * Assert that an expression is true, print the message and hit a breakpoint (for ever) if it isn't. | |
2070 | * | |
2071 | * @param expr Expression which should be true. | |
2072 | * @param a printf argument list (in parenthesis). | |
2073 | */ | |
2074 | #define AssertFatalMsg(expr, a) \ | |
2075 | do { \ | |
2076 | if (RT_LIKELY(!!(expr))) \ | |
2077 | { /* likely */ } \ | |
2078 | else \ | |
2079 | for (;;) \ | |
2080 | { \ | |
2081 | RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ | |
2082 | RTAssertMsg2Weak a; \ | |
2083 | RTAssertReleasePanic(); \ | |
2084 | } \ | |
2085 | } while (0) | |
2086 | ||
2087 | /** @def AssertFatalFailed | |
2088 | * An assertion failed, hit a breakpoint (for ever). | |
2089 | */ | |
2090 | #define AssertFatalFailed() \ | |
2091 | do { \ | |
2092 | for (;;) \ | |
2093 | { \ | |
2094 | RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \ | |
2095 | RTAssertReleasePanic(); \ | |
2096 | } \ | |
2097 | } while (0) | |
2098 | ||
2099 | /** @def AssertFatalMsgFailed | |
2100 | * An assertion failed, print a message and hit a breakpoint (for ever). | |
2101 | * | |
2102 | * @param a printf argument list (in parenthesis). | |
2103 | */ | |
2104 | #define AssertFatalMsgFailed(a) \ | |
2105 | do { \ | |
2106 | for (;;) \ | |
2107 | { \ | |
2108 | RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \ | |
2109 | RTAssertMsg2Weak a; \ | |
2110 | RTAssertReleasePanic(); \ | |
2111 | } \ | |
2112 | } while (0) | |
2113 | ||
2114 | /** @} */ | |
2115 | ||
2116 | ||
2117 | ||
2118 | /** @name Convenience Assertions Macros | |
2119 | * @{ | |
2120 | */ | |
2121 | ||
2122 | /** @def AssertRC | |
2123 | * Asserts a iprt status code successful. | |
2124 | * | |
2125 | * On failure it will print info about the rc and hit a breakpoint. | |
2126 | * | |
2127 | * @param rc iprt status code. | |
2128 | * @remark rc is referenced multiple times. In release mode is NOREF()'ed. | |
2129 | */ | |
2130 | #define AssertRC(rc) AssertMsgRC(rc, ("%Rra\n", (rc))) | |
2131 | ||
2132 | /** @def AssertRCStmt | |
2133 | * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and execute | |
2134 | * @a stmt if it isn't. | |
2135 | * | |
2136 | * @param rc iprt status code. | |
2137 | * @param stmt Statement to execute before returning in case of a failed | |
2138 | * assertion. | |
2139 | * @remark rc is referenced multiple times. In release mode is NOREF()'ed. | |
2140 | */ | |
2141 | #define AssertRCStmt(rc, stmt) AssertMsgRCStmt(rc, ("%Rra\n", (rc)), stmt) | |
2142 | ||
2143 | /** @def AssertRCReturn | |
2144 | * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return if it isn't. | |
2145 | * | |
2146 | * @param rc iprt status code. | |
2147 | * @param rcRet What is to be presented to return. | |
2148 | * @remark rc is referenced multiple times. In release mode is NOREF()'ed. | |
2149 | */ | |
2150 | #define AssertRCReturn(rc, rcRet) AssertMsgRCReturn(rc, ("%Rra\n", (rc)), rcRet) | |
2151 | ||
2152 | /** @def AssertRCReturnStmt | |
2153 | * Asserts a iprt status code successful, bitch (RT_STRICT mode only), execute | |
2154 | * @a stmt and returns @a rcRet if it isn't. | |
2155 | * | |
2156 | * @param rc iprt status code. | |
2157 | * @param stmt Statement to execute before returning in case of a failed | |
2158 | * assertion. | |
2159 | * @param rcRet What is to be presented to return. | |
2160 | * @remark rc is referenced multiple times. In release mode is NOREF()'ed. | |
2161 | */ | |
2162 | #define AssertRCReturnStmt(rc, stmt, rcRet) AssertMsgRCReturnStmt(rc, ("%Rra\n", (rc)), stmt, rcRet) | |
2163 | ||
2164 | /** @def AssertRCReturnVoid | |
2165 | * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return if it isn't. | |
2166 | * | |
2167 | * @param rc iprt status code. | |
2168 | * @remark rc is referenced multiple times. In release mode is NOREF()'ed. | |
2169 | */ | |
2170 | #define AssertRCReturnVoid(rc) AssertMsgRCReturnVoid(rc, ("%Rra\n", (rc))) | |
2171 | ||
2172 | /** @def AssertRCReturnVoidStmt | |
2173 | * Asserts a iprt status code successful, bitch (RT_STRICT mode only), and | |
2174 | * execute the given statement/return if it isn't. | |
2175 | * | |
2176 | * @param rc iprt status code. | |
2177 | * @param stmt Statement to execute before returning on failure. | |
2178 | * @remark rc is referenced multiple times. In release mode is NOREF()'ed. | |
2179 | */ | |
2180 | #define AssertRCReturnVoidStmt(rc, stmt) AssertMsgRCReturnVoidStmt(rc, ("%Rra\n", (rc)), stmt) | |
2181 | ||
2182 | /** @def AssertRCBreak | |
2183 | * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break if it isn't. | |
2184 | * | |
2185 | * @param rc iprt status code. | |
2186 | * @remark rc is referenced multiple times. In release mode is NOREF()'ed. | |
2187 | */ | |
2188 | #define AssertRCBreak(rc) AssertMsgRCBreak(rc, ("%Rra\n", (rc))) | |
2189 | ||
2190 | /** @def AssertRCBreakStmt | |
2191 | * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break if it isn't. | |
2192 | * | |
2193 | * @param rc iprt status code. | |
2194 | * @param stmt Statement to execute before break in case of a failed assertion. | |
2195 | * @remark rc is referenced multiple times. In release mode is NOREF()'ed. | |
2196 | */ | |
2197 | #define AssertRCBreakStmt(rc, stmt) AssertMsgRCBreakStmt(rc, ("%Rra\n", (rc)), stmt) | |
2198 | ||
2199 | /** @def AssertMsgRC | |
2200 | * Asserts a iprt status code successful. | |
2201 | * | |
2202 | * It prints a custom message and hits a breakpoint on FAILURE. | |
2203 | * | |
2204 | * @param rc iprt status code. | |
2205 | * @param msg printf argument list (in parenthesis). | |
2206 | * @remark rc is referenced multiple times. In release mode is NOREF()'ed. | |
2207 | */ | |
2208 | #define AssertMsgRC(rc, msg) \ | |
2209 | do { AssertMsg(RT_SUCCESS_NP(rc), msg); NOREF(rc); } while (0) | |
2210 | ||
2211 | /** @def AssertMsgRCStmt | |
2212 | * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and | |
2213 | * execute @a stmt if it isn't. | |
2214 | * | |
2215 | * @param rc iprt status code. | |
2216 | * @param msg printf argument list (in parenthesis). | |
2217 | * @param stmt Statement to execute before returning in case of a failed | |
2218 | * assertion. | |
2219 | * @remark rc is referenced multiple times. In release mode is NOREF()'ed. | |
2220 | */ | |
2221 | #define AssertMsgRCStmt(rc, msg, stmt) \ | |
2222 | do { AssertMsgStmt(RT_SUCCESS_NP(rc), msg, stmt); NOREF(rc); } while (0) | |
2223 | ||
2224 | /** @def AssertMsgRCReturn | |
2225 | * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return | |
2226 | * @a rcRet if it isn't. | |
2227 | * | |
2228 | * @param rc iprt status code. | |
2229 | * @param msg printf argument list (in parenthesis). | |
2230 | * @param rcRet What is to be presented to return. | |
2231 | * @remark rc is referenced multiple times. In release mode is NOREF()'ed. | |
2232 | */ | |
2233 | #define AssertMsgRCReturn(rc, msg, rcRet) \ | |
2234 | do { AssertMsgReturn(RT_SUCCESS_NP(rc), msg, rcRet); NOREF(rc); } while (0) | |
2235 | ||
2236 | /** @def AssertMsgRCReturnStmt | |
2237 | * Asserts a iprt status code successful, bitch (RT_STRICT mode only), execute | |
2238 | * @a stmt and return @a rcRet if it isn't. | |
2239 | * | |
2240 | * @param rc iprt status code. | |
2241 | * @param msg printf argument list (in parenthesis). | |
2242 | * @param stmt Statement to execute before returning in case of a failed | |
2243 | * assertion. | |
2244 | * @param rcRet What is to be presented to return. | |
2245 | * @remark rc is referenced multiple times. In release mode is NOREF()'ed. | |
2246 | */ | |
2247 | #define AssertMsgRCReturnStmt(rc, msg, stmt, rcRet) \ | |
2248 | do { AssertMsgReturnStmt(RT_SUCCESS_NP(rc), msg, stmt, rcRet); NOREF(rc); } while (0) | |
2249 | ||
2250 | /** @def AssertMsgRCReturnVoid | |
2251 | * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return | |
2252 | * void if it isn't. | |
2253 | * | |
2254 | * @param rc iprt status code. | |
2255 | * @param msg printf argument list (in parenthesis). | |
2256 | * @remark rc is referenced multiple times. In release mode is NOREF()'ed. | |
2257 | */ | |
2258 | #define AssertMsgRCReturnVoid(rc, msg) \ | |
2259 | do { AssertMsgReturnVoid(RT_SUCCESS_NP(rc), msg); NOREF(rc); } while (0) | |
2260 | ||
2261 | /** @def AssertMsgRCReturnVoidStmt | |
2262 | * Asserts a iprt status code successful, bitch (RT_STRICT mode only), execute | |
2263 | * @a stmt and return void if it isn't. | |
2264 | * | |
2265 | * @param rc iprt status code. | |
2266 | * @param msg printf argument list (in parenthesis). | |
2267 | * @param stmt Statement to execute before break in case of a failed assertion. | |
2268 | * @remark rc is referenced multiple times. In release mode is NOREF()'ed. | |
2269 | */ | |
2270 | #define AssertMsgRCReturnVoidStmt(rc, msg, stmt) \ | |
2271 | do { AssertMsgReturnVoidStmt(RT_SUCCESS_NP(rc), msg, stmt); NOREF(rc); } while (0) | |
2272 | ||
2273 | /** @def AssertMsgRCBreak | |
2274 | * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break | |
2275 | * if it isn't. | |
2276 | * | |
2277 | * @param rc iprt status code. | |
2278 | * @param msg printf argument list (in parenthesis). | |
2279 | * @remark rc is referenced multiple times. In release mode is NOREF()'ed. | |
2280 | */ | |
2281 | #define AssertMsgRCBreak(rc, msg) \ | |
2282 | if (1) { AssertMsgBreak(RT_SUCCESS(rc), msg); NOREF(rc); } else do {} while (0) | |
2283 | ||
2284 | /** @def AssertMsgRCBreakStmt | |
2285 | * Asserts a iprt status code successful, bitch (RT_STRICT mode only), execute | |
2286 | * @a stmt and break if it isn't. | |
2287 | * | |
2288 | * @param rc iprt status code. | |
2289 | * @param msg printf argument list (in parenthesis). | |
2290 | * @param stmt Statement to execute before break in case of a failed assertion. | |
2291 | * @remark rc is referenced multiple times. In release mode is NOREF()'ed. | |
2292 | */ | |
2293 | #define AssertMsgRCBreakStmt(rc, msg, stmt) \ | |
2294 | if (1) { AssertMsgBreakStmt(RT_SUCCESS_NP(rc), msg, stmt); NOREF(rc); } else do {} while (0) | |
2295 | ||
2296 | /** @def AssertRCSuccess | |
2297 | * Asserts an iprt status code equals VINF_SUCCESS. | |
2298 | * | |
2299 | * On failure it will print info about the rc and hit a breakpoint. | |
2300 | * | |
2301 | * @param rc iprt status code. | |
2302 | * @remark rc is referenced multiple times. In release mode is NOREF()'ed. | |
2303 | */ | |
2304 | #define AssertRCSuccess(rc) do { AssertMsg((rc) == VINF_SUCCESS, ("%Rra\n", (rc))); NOREF(rc); } while (0) | |
2305 | ||
2306 | /** @def AssertRCSuccessReturn | |
2307 | * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and return if it isn't. | |
2308 | * | |
2309 | * @param rc iprt status code. | |
2310 | * @param rcRet What is to be presented to return. | |
2311 | * @remark rc is referenced multiple times. In release mode is NOREF()'ed. | |
2312 | */ | |
2313 | #define AssertRCSuccessReturn(rc, rcRet) AssertMsgReturn((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), rcRet) | |
2314 | ||
2315 | /** @def AssertRCSuccessReturnVoid | |
2316 | * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and return if it isn't. | |
2317 | * | |
2318 | * @param rc iprt status code. | |
2319 | * @remark rc is referenced multiple times. In release mode is NOREF()'ed. | |
2320 | */ | |
2321 | #define AssertRCSuccessReturnVoid(rc) AssertMsgReturnVoid((rc) == VINF_SUCCESS, ("%Rra\n", (rc))) | |
2322 | ||
2323 | /** @def AssertRCSuccessBreak | |
2324 | * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and break if it isn't. | |
2325 | * | |
2326 | * @param rc iprt status code. | |
2327 | * @remark rc is referenced multiple times. In release mode is NOREF()'ed. | |
2328 | */ | |
2329 | #define AssertRCSuccessBreak(rc) AssertMsgBreak((rc) == VINF_SUCCESS, ("%Rra\n", (rc))) | |
2330 | ||
2331 | /** @def AssertRCSuccessBreakStmt | |
2332 | * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and break if it isn't. | |
2333 | * | |
2334 | * @param rc iprt status code. | |
2335 | * @param stmt Statement to execute before break in case of a failed assertion. | |
2336 | * @remark rc is referenced multiple times. In release mode is NOREF()'ed. | |
2337 | */ | |
2338 | #define AssertRCSuccessBreakStmt(rc, stmt) AssertMsgBreakStmt((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), stmt) | |
2339 | ||
2340 | ||
2341 | /** @def AssertLogRelRC | |
2342 | * Asserts a iprt status code successful. | |
2343 | * | |
2344 | * @param rc iprt status code. | |
2345 | * @remark rc is referenced multiple times. | |
2346 | */ | |
2347 | #define AssertLogRelRC(rc) AssertLogRelMsgRC(rc, ("%Rra\n", (rc))) | |
2348 | ||
2349 | /** @def AssertLogRelRCReturn | |
2350 | * Asserts a iprt status code successful, returning \a rc if it isn't. | |
2351 | * | |
2352 | * @param rc iprt status code. | |
2353 | * @param rcRet What is to be presented to return. | |
2354 | * @remark rc is referenced multiple times. | |
2355 | */ | |
2356 | #define AssertLogRelRCReturn(rc, rcRet) AssertLogRelMsgRCReturn(rc, ("%Rra\n", (rc)), rcRet) | |
2357 | ||
2358 | /** @def AssertLogRelRCReturnStmt | |
2359 | * Asserts a iprt status code successful, executing \a stmt and returning \a rc | |
2360 | * if it isn't. | |
2361 | * | |
2362 | * @param rc iprt status code. | |
2363 | * @param stmt Statement to execute before returning in case of a failed | |
2364 | * assertion. | |
2365 | * @param rcRet What is to be presented to return. | |
2366 | * @remark rc is referenced multiple times. | |
2367 | */ | |
2368 | #define AssertLogRelRCReturnStmt(rc, stmt, rcRet) AssertLogRelMsgRCReturnStmt(rc, ("%Rra\n", (rc)), stmt, rcRet) | |
2369 | ||
2370 | /** @def AssertLogRelRCReturnVoid | |
2371 | * Asserts a iprt status code successful, returning (void) if it isn't. | |
2372 | * | |
2373 | * @param rc iprt status code. | |
2374 | * @remark rc is referenced multiple times. | |
2375 | */ | |
2376 | #define AssertLogRelRCReturnVoid(rc) AssertLogRelMsgRCReturnVoid(rc, ("%Rra\n", (rc))) | |
2377 | ||
2378 | /** @def AssertLogRelRCBreak | |
2379 | * Asserts a iprt status code successful, breaking if it isn't. | |
2380 | * | |
2381 | * @param rc iprt status code. | |
2382 | * @remark rc is referenced multiple times. | |
2383 | */ | |
2384 | #define AssertLogRelRCBreak(rc) AssertLogRelMsgRCBreak(rc, ("%Rra\n", (rc))) | |
2385 | ||
2386 | /** @def AssertLogRelRCBreakStmt | |
2387 | * Asserts a iprt status code successful, execute \a statement and break if it isn't. | |
2388 | * | |
2389 | * @param rc iprt status code. | |
2390 | * @param stmt Statement to execute before break in case of a failed assertion. | |
2391 | * @remark rc is referenced multiple times. | |
2392 | */ | |
2393 | #define AssertLogRelRCBreakStmt(rc, stmt) AssertLogRelMsgRCBreakStmt(rc, ("%Rra\n", (rc)), stmt) | |
2394 | ||
2395 | /** @def AssertLogRelMsgRC | |
2396 | * Asserts a iprt status code successful. | |
2397 | * | |
2398 | * @param rc iprt status code. | |
2399 | * @param msg printf argument list (in parenthesis). | |
2400 | * @remark rc is referenced multiple times. | |
2401 | */ | |
2402 | #define AssertLogRelMsgRC(rc, msg) AssertLogRelMsg(RT_SUCCESS_NP(rc), msg) | |
2403 | ||
2404 | /** @def AssertLogRelMsgRCReturn | |
2405 | * Asserts a iprt status code successful. | |
2406 | * | |
2407 | * @param rc iprt status code. | |
2408 | * @param msg printf argument list (in parenthesis). | |
2409 | * @param rcRet What is to be presented to return. | |
2410 | * @remark rc is referenced multiple times. | |
2411 | */ | |
2412 | #define AssertLogRelMsgRCReturn(rc, msg, rcRet) AssertLogRelMsgReturn(RT_SUCCESS_NP(rc), msg, rcRet) | |
2413 | ||
2414 | /** @def AssertLogRelMsgRCReturnStmt | |
2415 | * Asserts a iprt status code successful, execute \a stmt and return on | |
2416 | * failure. | |
2417 | * | |
2418 | * @param rc iprt status code. | |
2419 | * @param msg printf argument list (in parenthesis). | |
2420 | * @param stmt Statement to execute before returning in case of a failed | |
2421 | * assertion. | |
2422 | * @param rcRet What is to be presented to return. | |
2423 | * @remark rc is referenced multiple times. | |
2424 | */ | |
2425 | #define AssertLogRelMsgRCReturnStmt(rc, msg, stmt, rcRet) AssertLogRelMsgReturnStmt(RT_SUCCESS_NP(rc), msg, stmt, rcRet) | |
2426 | ||
2427 | /** @def AssertLogRelMsgRCReturnVoid | |
2428 | * Asserts a iprt status code successful. | |
2429 | * | |
2430 | * @param rc iprt status code. | |
2431 | * @param msg printf argument list (in parenthesis). | |
2432 | * @remark rc is referenced multiple times. | |
2433 | */ | |
2434 | #define AssertLogRelMsgRCReturnVoid(rc, msg) AssertLogRelMsgReturnVoid(RT_SUCCESS_NP(rc), msg) | |
2435 | ||
2436 | /** @def AssertLogRelMsgRCBreak | |
2437 | * Asserts a iprt status code successful. | |
2438 | * | |
2439 | * @param rc iprt status code. | |
2440 | * @param msg printf argument list (in parenthesis). | |
2441 | * @remark rc is referenced multiple times. | |
2442 | */ | |
2443 | #define AssertLogRelMsgRCBreak(rc, msg) AssertLogRelMsgBreak(RT_SUCCESS(rc), msg) | |
2444 | ||
2445 | /** @def AssertLogRelMsgRCBreakStmt | |
2446 | * Asserts a iprt status code successful, execute \a stmt and break if it isn't. | |
2447 | * | |
2448 | * @param rc iprt status code. | |
2449 | * @param msg printf argument list (in parenthesis). | |
2450 | * @param stmt Statement to execute before break in case of a failed assertion. | |
2451 | * @remark rc is referenced multiple times. | |
2452 | */ | |
2453 | #define AssertLogRelMsgRCBreakStmt(rc, msg, stmt) AssertLogRelMsgBreakStmt(RT_SUCCESS_NP(rc), msg, stmt) | |
2454 | ||
2455 | /** @def AssertLogRelRCSuccess | |
2456 | * Asserts that an iprt status code equals VINF_SUCCESS. | |
2457 | * | |
2458 | * @param rc iprt status code. | |
2459 | * @remark rc is referenced multiple times. | |
2460 | */ | |
2461 | #define AssertLogRelRCSuccess(rc) AssertLogRelMsg((rc) == VINF_SUCCESS, ("%Rra\n", (rc))) | |
2462 | ||
2463 | /** @def AssertLogRelRCSuccessReturn | |
2464 | * Asserts that an iprt status code equals VINF_SUCCESS. | |
2465 | * | |
2466 | * @param rc iprt status code. | |
2467 | * @param rcRet What is to be presented to return. | |
2468 | * @remark rc is referenced multiple times. | |
2469 | */ | |
2470 | #define AssertLogRelRCSuccessReturn(rc, rcRet) AssertLogRelMsgReturn((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), rcRet) | |
2471 | ||
2472 | /** @def AssertLogRelRCSuccessReturnVoid | |
2473 | * Asserts that an iprt status code equals VINF_SUCCESS. | |
2474 | * | |
2475 | * @param rc iprt status code. | |
2476 | * @remark rc is referenced multiple times. | |
2477 | */ | |
2478 | #define AssertLogRelRCSuccessReturnVoid(rc) AssertLogRelMsgReturnVoid((rc) == VINF_SUCCESS, ("%Rra\n", (rc))) | |
2479 | ||
2480 | /** @def AssertLogRelRCSuccessBreak | |
2481 | * Asserts that an iprt status code equals VINF_SUCCESS. | |
2482 | * | |
2483 | * @param rc iprt status code. | |
2484 | * @remark rc is referenced multiple times. | |
2485 | */ | |
2486 | #define AssertLogRelRCSuccessBreak(rc) AssertLogRelMsgBreak((rc) == VINF_SUCCESS, ("%Rra\n", (rc))) | |
2487 | ||
2488 | /** @def AssertLogRelRCSuccessBreakStmt | |
2489 | * Asserts that an iprt status code equals VINF_SUCCESS. | |
2490 | * | |
2491 | * @param rc iprt status code. | |
2492 | * @param stmt Statement to execute before break in case of a failed assertion. | |
2493 | * @remark rc is referenced multiple times. | |
2494 | */ | |
2495 | #define AssertLogRelRCSuccessBreakStmt(rc, stmt) AssertLogRelMsgBreakStmt((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), stmt) | |
2496 | ||
2497 | ||
2498 | /** @def AssertReleaseRC | |
2499 | * Asserts a iprt status code successful. | |
2500 | * | |
2501 | * On failure information about the error will be printed and a breakpoint hit. | |
2502 | * | |
2503 | * @param rc iprt status code. | |
2504 | * @remark rc is referenced multiple times. | |
2505 | */ | |
2506 | #define AssertReleaseRC(rc) AssertReleaseMsgRC(rc, ("%Rra\n", (rc))) | |
2507 | ||
2508 | /** @def AssertReleaseRCReturn | |
2509 | * Asserts a iprt status code successful, returning if it isn't. | |
2510 | * | |
2511 | * On failure information about the error will be printed, a breakpoint hit | |
2512 | * and finally returning from the function if the breakpoint is somehow ignored. | |
2513 | * | |
2514 | * @param rc iprt status code. | |
2515 | * @param rcRet What is to be presented to return. | |
2516 | * @remark rc is referenced multiple times. | |
2517 | */ | |
2518 | #define AssertReleaseRCReturn(rc, rcRet) AssertReleaseMsgRCReturn(rc, ("%Rra\n", (rc)), rcRet) | |
2519 | ||
2520 | /** @def AssertReleaseRCReturnVoid | |
2521 | * Asserts a iprt status code successful, returning if it isn't. | |
2522 | * | |
2523 | * On failure information about the error will be printed, a breakpoint hit | |
2524 | * and finally returning from the function if the breakpoint is somehow ignored. | |
2525 | * | |
2526 | * @param rc iprt status code. | |
2527 | * @remark rc is referenced multiple times. | |
2528 | */ | |
2529 | #define AssertReleaseRCReturnVoid(rc) AssertReleaseMsgRCReturnVoid(rc, ("%Rra\n", (rc))) | |
2530 | ||
2531 | /** @def AssertReleaseRCBreak | |
2532 | * Asserts a iprt status code successful, breaking if it isn't. | |
2533 | * | |
2534 | * On failure information about the error will be printed, a breakpoint hit | |
2535 | * and finally breaking the current statement if the breakpoint is somehow ignored. | |
2536 | * | |
2537 | * @param rc iprt status code. | |
2538 | * @remark rc is referenced multiple times. | |
2539 | */ | |
2540 | #define AssertReleaseRCBreak(rc) AssertReleaseMsgRCBreak(rc, ("%Rra\n", (rc))) | |
2541 | ||
2542 | /** @def AssertReleaseRCBreakStmt | |
2543 | * Asserts a iprt status code successful, break if it isn't. | |
2544 | * | |
2545 | * On failure information about the error will be printed, a breakpoint hit | |
2546 | * and finally the break statement will be issued if the breakpoint is somehow ignored. | |
2547 | * | |
2548 | * @param rc iprt status code. | |
2549 | * @param stmt Statement to execute before break in case of a failed assertion. | |
2550 | * @remark rc is referenced multiple times. | |
2551 | */ | |
2552 | #define AssertReleaseRCBreakStmt(rc, stmt) AssertReleaseMsgRCBreakStmt(rc, ("%Rra\n", (rc)), stmt) | |
2553 | ||
2554 | /** @def AssertReleaseMsgRC | |
2555 | * Asserts a iprt status code successful. | |
2556 | * | |
2557 | * On failure a custom message is printed and a breakpoint is hit. | |
2558 | * | |
2559 | * @param rc iprt status code. | |
2560 | * @param msg printf argument list (in parenthesis). | |
2561 | * @remark rc is referenced multiple times. | |
2562 | */ | |
2563 | #define AssertReleaseMsgRC(rc, msg) AssertReleaseMsg(RT_SUCCESS_NP(rc), msg) | |
2564 | ||
2565 | /** @def AssertReleaseMsgRCReturn | |
2566 | * Asserts a iprt status code successful. | |
2567 | * | |
2568 | * On failure a custom message is printed, a breakpoint is hit, and finally | |
2569 | * returning from the function if the breakpoint is somehow ignored. | |
2570 | * | |
2571 | * @param rc iprt status code. | |
2572 | * @param msg printf argument list (in parenthesis). | |
2573 | * @param rcRet What is to be presented to return. | |
2574 | * @remark rc is referenced multiple times. | |
2575 | */ | |
2576 | #define AssertReleaseMsgRCReturn(rc, msg, rcRet) AssertReleaseMsgReturn(RT_SUCCESS_NP(rc), msg, rcRet) | |
2577 | ||
2578 | /** @def AssertReleaseMsgRCReturnVoid | |
2579 | * Asserts a iprt status code successful. | |
2580 | * | |
2581 | * On failure a custom message is printed, a breakpoint is hit, and finally | |
2582 | * returning from the function if the breakpoint is somehow ignored. | |
2583 | * | |
2584 | * @param rc iprt status code. | |
2585 | * @param msg printf argument list (in parenthesis). | |
2586 | * @remark rc is referenced multiple times. | |
2587 | */ | |
2588 | #define AssertReleaseMsgRCReturnVoid(rc, msg) AssertReleaseMsgReturnVoid(RT_SUCCESS_NP(rc), msg) | |
2589 | ||
2590 | /** @def AssertReleaseMsgRCBreak | |
2591 | * Asserts a iprt status code successful. | |
2592 | * | |
2593 | * On failure a custom message is printed, a breakpoint is hit, and finally | |
2594 | * breaking the current status if the breakpoint is somehow ignored. | |
2595 | * | |
2596 | * @param rc iprt status code. | |
2597 | * @param msg printf argument list (in parenthesis). | |
2598 | * @remark rc is referenced multiple times. | |
2599 | */ | |
2600 | #define AssertReleaseMsgRCBreak(rc, msg) AssertReleaseMsgBreak(RT_SUCCESS(rc), msg) | |
2601 | ||
2602 | /** @def AssertReleaseMsgRCBreakStmt | |
2603 | * Asserts a iprt status code successful. | |
2604 | * | |
2605 | * On failure a custom message is printed, a breakpoint is hit, and finally | |
2606 | * the break statement is issued if the breakpoint is somehow ignored. | |
2607 | * | |
2608 | * @param rc iprt status code. | |
2609 | * @param msg printf argument list (in parenthesis). | |
2610 | * @param stmt Statement to execute before break in case of a failed assertion. | |
2611 | * @remark rc is referenced multiple times. | |
2612 | */ | |
2613 | #define AssertReleaseMsgRCBreakStmt(rc, msg, stmt) AssertReleaseMsgBreakStmt(RT_SUCCESS_NP(rc), msg, stmt) | |
2614 | ||
2615 | /** @def AssertReleaseRCSuccess | |
2616 | * Asserts that an iprt status code equals VINF_SUCCESS. | |
2617 | * | |
2618 | * On failure information about the error will be printed and a breakpoint hit. | |
2619 | * | |
2620 | * @param rc iprt status code. | |
2621 | * @remark rc is referenced multiple times. | |
2622 | */ | |
2623 | #define AssertReleaseRCSuccess(rc) AssertReleaseMsg((rc) == VINF_SUCCESS, ("%Rra\n", (rc))) | |
2624 | ||
2625 | /** @def AssertReleaseRCSuccessReturn | |
2626 | * Asserts that an iprt status code equals VINF_SUCCESS. | |
2627 | * | |
2628 | * On failure information about the error will be printed, a breakpoint hit | |
2629 | * and finally returning from the function if the breakpoint is somehow ignored. | |
2630 | * | |
2631 | * @param rc iprt status code. | |
2632 | * @param rcRet What is to be presented to return. | |
2633 | * @remark rc is referenced multiple times. | |
2634 | */ | |
2635 | #define AssertReleaseRCSuccessReturn(rc, rcRet) AssertReleaseMsgReturn((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), rcRet) | |
2636 | ||
2637 | /** @def AssertReleaseRCSuccessReturnVoid | |
2638 | * Asserts that an iprt status code equals VINF_SUCCESS. | |
2639 | * | |
2640 | * On failure information about the error will be printed, a breakpoint hit | |
2641 | * and finally returning from the function if the breakpoint is somehow ignored. | |
2642 | * | |
2643 | * @param rc iprt status code. | |
2644 | * @remark rc is referenced multiple times. | |
2645 | */ | |
2646 | #define AssertReleaseRCSuccessReturnVoid(rc) AssertReleaseMsgReturnVoid((rc) == VINF_SUCCESS, ("%Rra\n", (rc))) | |
2647 | ||
2648 | /** @def AssertReleaseRCSuccessBreak | |
2649 | * Asserts that an iprt status code equals VINF_SUCCESS. | |
2650 | * | |
2651 | * On failure information about the error will be printed, a breakpoint hit | |
2652 | * and finally breaking the current statement if the breakpoint is somehow ignored. | |
2653 | * | |
2654 | * @param rc iprt status code. | |
2655 | * @remark rc is referenced multiple times. | |
2656 | */ | |
2657 | #define AssertReleaseRCSuccessBreak(rc) AssertReleaseMsgBreak((rc) == VINF_SUCCESS, ("%Rra\n", (rc))) | |
2658 | ||
2659 | /** @def AssertReleaseRCSuccessBreakStmt | |
2660 | * Asserts that an iprt status code equals VINF_SUCCESS. | |
2661 | * | |
2662 | * On failure information about the error will be printed, a breakpoint hit | |
2663 | * and finally the break statement will be issued if the breakpoint is somehow ignored. | |
2664 | * | |
2665 | * @param rc iprt status code. | |
2666 | * @param stmt Statement to execute before break in case of a failed assertion. | |
2667 | * @remark rc is referenced multiple times. | |
2668 | */ | |
2669 | #define AssertReleaseRCSuccessBreakStmt(rc, stmt) AssertReleaseMsgBreakStmt((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), stmt) | |
2670 | ||
2671 | ||
2672 | /** @def AssertFatalRC | |
2673 | * Asserts a iprt status code successful. | |
2674 | * | |
2675 | * On failure information about the error will be printed and a breakpoint hit. | |
2676 | * | |
2677 | * @param rc iprt status code. | |
2678 | * @remark rc is referenced multiple times. | |
2679 | */ | |
2680 | #define AssertFatalRC(rc) AssertFatalMsgRC(rc, ("%Rra\n", (rc))) | |
2681 | ||
2682 | /** @def AssertReleaseMsgRC | |
2683 | * Asserts a iprt status code successful. | |
2684 | * | |
2685 | * On failure a custom message is printed and a breakpoint is hit. | |
2686 | * | |
2687 | * @param rc iprt status code. | |
2688 | * @param msg printf argument list (in parenthesis). | |
2689 | * @remark rc is referenced multiple times. | |
2690 | */ | |
2691 | #define AssertFatalMsgRC(rc, msg) AssertFatalMsg(RT_SUCCESS_NP(rc), msg) | |
2692 | ||
2693 | /** @def AssertFatalRCSuccess | |
2694 | * Asserts that an iprt status code equals VINF_SUCCESS. | |
2695 | * | |
2696 | * On failure information about the error will be printed and a breakpoint hit. | |
2697 | * | |
2698 | * @param rc iprt status code. | |
2699 | * @remark rc is referenced multiple times. | |
2700 | */ | |
2701 | #define AssertFatalRCSuccess(rc) AssertFatalMsg((rc) == VINF_SUCCESS, ("%Rra\n", (rc))) | |
2702 | ||
2703 | ||
2704 | /** @def AssertPtr | |
2705 | * Asserts that a pointer is valid. | |
2706 | * | |
2707 | * @param pv The pointer. | |
2708 | */ | |
2709 | #define AssertPtr(pv) AssertMsg(VALID_PTR(pv), ("%p\n", (pv))) | |
2710 | ||
2711 | /** @def AssertPtrReturn | |
2712 | * Asserts that a pointer is valid. | |
2713 | * | |
2714 | * @param pv The pointer. | |
2715 | * @param rcRet What is to be presented to return. | |
2716 | */ | |
2717 | #define AssertPtrReturn(pv, rcRet) AssertMsgReturn(VALID_PTR(pv), ("%p\n", (pv)), rcRet) | |
2718 | ||
2719 | /** @def AssertPtrReturnVoid | |
2720 | * Asserts that a pointer is valid. | |
2721 | * | |
2722 | * @param pv The pointer. | |
2723 | */ | |
2724 | #define AssertPtrReturnVoid(pv) AssertMsgReturnVoid(VALID_PTR(pv), ("%p\n", (pv))) | |
2725 | ||
2726 | /** @def AssertPtrBreak | |
2727 | * Asserts that a pointer is valid. | |
2728 | * | |
2729 | * @param pv The pointer. | |
2730 | */ | |
2731 | #define AssertPtrBreak(pv) AssertMsgBreak(VALID_PTR(pv), ("%p\n", (pv))) | |
2732 | ||
2733 | /** @def AssertPtrBreakStmt | |
2734 | * Asserts that a pointer is valid. | |
2735 | * | |
2736 | * @param pv The pointer. | |
2737 | * @param stmt Statement to execute before break in case of a failed assertion. | |
2738 | */ | |
2739 | #define AssertPtrBreakStmt(pv, stmt) AssertMsgBreakStmt(VALID_PTR(pv), ("%p\n", (pv)), stmt) | |
2740 | ||
2741 | /** @def AssertPtrNull | |
2742 | * Asserts that a pointer is valid or NULL. | |
2743 | * | |
2744 | * @param pv The pointer. | |
2745 | */ | |
2746 | #define AssertPtrNull(pv) AssertMsg(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv))) | |
2747 | ||
2748 | /** @def AssertPtrNullReturn | |
2749 | * Asserts that a pointer is valid or NULL. | |
2750 | * | |
2751 | * @param pv The pointer. | |
2752 | * @param rcRet What is to be presented to return. | |
2753 | */ | |
2754 | #define AssertPtrNullReturn(pv, rcRet) AssertMsgReturn(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)), rcRet) | |
2755 | ||
2756 | /** @def AssertPtrNullReturnVoid | |
2757 | * Asserts that a pointer is valid or NULL. | |
2758 | * | |
2759 | * @param pv The pointer. | |
2760 | */ | |
2761 | #define AssertPtrNullReturnVoid(pv) AssertMsgReturnVoid(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv))) | |
2762 | ||
2763 | /** @def AssertPtrNullBreak | |
2764 | * Asserts that a pointer is valid or NULL. | |
2765 | * | |
2766 | * @param pv The pointer. | |
2767 | */ | |
2768 | #define AssertPtrNullBreak(pv) AssertMsgBreak(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv))) | |
2769 | ||
2770 | /** @def AssertPtrNullBreakStmt | |
2771 | * Asserts that a pointer is valid or NULL. | |
2772 | * | |
2773 | * @param pv The pointer. | |
2774 | * @param stmt Statement to execute before break in case of a failed assertion. | |
2775 | */ | |
2776 | #define AssertPtrNullBreakStmt(pv, stmt) AssertMsgBreakStmt(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)), stmt) | |
2777 | ||
2778 | /** @def AssertGCPhys32 | |
2779 | * Asserts that the high dword of a physical address is zero | |
2780 | * | |
2781 | * @param GCPhys The address (RTGCPHYS). | |
2782 | */ | |
2783 | #define AssertGCPhys32(GCPhys) AssertMsg(VALID_PHYS32(GCPhys), ("%RGp\n", (RTGCPHYS)(GCPhys))) | |
2784 | ||
2785 | /** @def AssertGCPtr32 | |
2786 | * Asserts that the high dword of a physical address is zero | |
2787 | * | |
2788 | * @param GCPtr The address (RTGCPTR). | |
2789 | */ | |
2790 | #if GC_ARCH_BITS == 32 | |
2791 | # define AssertGCPtr32(GCPtr) do { } while (0) | |
2792 | #else | |
2793 | # define AssertGCPtr32(GCPtr) AssertMsg(!((GCPtr) & UINT64_C(0xffffffff00000000)), ("%RGv\n", GCPtr)) | |
2794 | #endif | |
2795 | ||
2796 | /** @def AssertForEach | |
2797 | * Equivalent to Assert for each value of the variable from the starting | |
2798 | * value to the finishing one. | |
2799 | * | |
2800 | * @param var Name of the counter variable. | |
2801 | * @param vartype Type of the counter variable. | |
2802 | * @param first Lowest inclusive value of the counter variable. | |
2803 | * This must be free from side effects. | |
2804 | * @param end Highest exclusive value of the counter variable. | |
2805 | * This must be free from side effects. | |
2806 | * @param expr Expression which should be true for each value of @a var. | |
2807 | */ | |
2808 | #define AssertForEach(var, vartype, first, end, expr) \ | |
2809 | do { \ | |
2810 | vartype var; \ | |
2811 | Assert((first) == (first) && (end) == (end)); /* partial check for side effects */ \ | |
2812 | for (var = (first); var < (end); var++) \ | |
2813 | AssertMsg(expr, ("%s = %#RX64 (%RI64)", #var, (uint64_t)var, (int64_t)var)); \ | |
2814 | } while (0) | |
2815 | ||
2816 | #ifdef RT_OS_WINDOWS | |
2817 | ||
2818 | /** @def AssertNtStatus | |
2819 | * Asserts that the NT_SUCCESS() returns true for the given NTSTATUS value. | |
2820 | * | |
2821 | * @param a_rcNt The NTSTATUS to check. Will be evaluated twice and | |
2822 | * subjected to NOREF(). | |
2823 | * @sa AssertRC() | |
2824 | */ | |
2825 | # define AssertNtStatus(a_rcNt) \ | |
2826 | do { AssertMsg(NT_SUCCESS(a_rcNt), ("%#x\n", (a_rcNt))); NOREF(a_rcNt); } while (0) | |
2827 | ||
2828 | /** @def AssertNtStatusSuccess | |
2829 | * Asserts that the given NTSTATUS value equals STATUS_SUCCESS. | |
2830 | * | |
2831 | * @param a_rcNt The NTSTATUS to check. Will be evaluated twice and | |
2832 | * subjected to NOREF(). | |
2833 | * @sa AssertRCSuccess() | |
2834 | */ | |
2835 | # define AssertNtStatusSuccess(a_rcNt) \ | |
2836 | do { AssertMsg((a_rcNt) == STATUS_SUCCESS, ("%#x\n", (a_rcNt))); NOREF(a_rcNt); } while (0) | |
2837 | ||
2838 | #endif /* RT_OS_WINDOWS */ | |
2839 | ||
2840 | /** @} */ | |
2841 | ||
2842 | /** @} */ | |
2843 | ||
2844 | #endif | |
2845 |