]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - ubuntu/vbox/include/iprt/assert.h
6 * Copyright (C) 2006-2016 Oracle Corporation
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.
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.
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.
26 #ifndef ___iprt_assert_h
27 #define ___iprt_assert_h
29 #include <iprt/cdefs.h>
30 #include <iprt/types.h>
31 #include <iprt/stdarg.h>
33 /** @defgroup grp_rt_assert Assert - Assertions
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.
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).
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.
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.
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.
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... :-)
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.
79 * The 1st part of an assert message.
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.
86 RTDECL(void) RTAssertMsg1(const char *pszExpr
, unsigned uLine
, const char *pszFile
, const char *pszFunction
);
88 * Weak version of RTAssertMsg1 that can be overridden locally in a module to
89 * modify, redirect or otherwise mess with the assertion output.
91 * @copydoc RTAssertMsg1
93 RTDECL(void) RTAssertMsg1Weak(const char *pszExpr
, unsigned uLine
, const char *pszFile
, const char *pszFunction
);
96 * The 2nd (optional) part of an assert message.
98 * @param pszFormat Printf like format string.
99 * @param ... Arguments to that string.
101 RTDECL(void) RTAssertMsg2(const char *pszFormat
, ...) RT_IPRT_FORMAT_ATTR(1, 2);
103 * Weak version of RTAssertMsg2 that forwards to RTAssertMsg2WeakV.
105 * There is not need to override this, check out RTAssertMsg2WeakV instead!
107 * @copydoc RTAssertMsg2
109 RTDECL(void) RTAssertMsg2Weak(const char *pszFormat
, ...) RT_IPRT_FORMAT_ATTR(1, 2);
112 * The 2nd (optional) part of an assert message.
114 * @param pszFormat Printf like format string.
115 * @param va Arguments to that string.
117 RTDECL(void) RTAssertMsg2V(const char *pszFormat
, va_list va
) RT_IPRT_FORMAT_ATTR(1, 0);
119 * Weak version of RTAssertMsg2V that can be overridden locally in a module to
120 * modify, redirect or otherwise mess with the assertion output.
122 * @copydoc RTAssertMsg2V
124 RTDECL(void) RTAssertMsg2WeakV(const char *pszFormat
, va_list va
) RT_IPRT_FORMAT_ATTR(1, 0);
127 * Additional information which should be appended to the 2nd part of an
130 * @param pszFormat Printf like format string.
131 * @param ... Arguments to that string.
133 RTDECL(void) RTAssertMsg2Add(const char *pszFormat
, ...) RT_IPRT_FORMAT_ATTR(1, 2);
135 * Weak version of RTAssertMsg2Add that forwards to RTAssertMsg2AddWeakV.
137 * There is not need to override this, check out RTAssertMsg2AddWeakV instead!
139 * @copydoc RTAssertMsg2Add
141 RTDECL(void) RTAssertMsg2AddWeak(const char *pszFormat
, ...) RT_IPRT_FORMAT_ATTR(1, 2);
144 * Additional information which should be appended to the 2nd part of an
147 * @param pszFormat Printf like format string.
148 * @param va Arguments to that string.
150 RTDECL(void) RTAssertMsg2AddV(const char *pszFormat
, va_list va
) RT_IPRT_FORMAT_ATTR(1, 0);
152 * Weak version of RTAssertMsg2AddV that can be overridden locally in a module
153 * to modify, redirect or otherwise mess with the assertion output.
155 * @copydoc RTAssertMsg2AddV
157 RTDECL(void) RTAssertMsg2AddWeakV(const char *pszFormat
, va_list va
) RT_IPRT_FORMAT_ATTR(1, 0);
161 * Panics the system as the result of a fail assertion.
163 RTR0DECL(void) RTR0AssertPanicSystem(void);
164 #endif /* IN_RING0 */
167 * Overridable function that decides whether assertions executes the panic
168 * (breakpoint) or not.
170 * The generic implementation will return true.
172 * @returns true if the breakpoint should be hit, false if it should be ignored.
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
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);
184 DECLEXPORT(bool) RTCALL
RTAssertShouldPanic(void);
188 * Controls whether the assertions should be quiet or noisy (default).
190 * @returns The old setting.
191 * @param fQuiet The new setting.
193 RTDECL(bool) RTAssertSetQuiet(bool fQuiet
);
196 * Are assertions quiet or noisy?
198 * @returns True if they are quiet, false if noisy.
200 RTDECL(bool) RTAssertAreQuiet(void);
203 * Makes the assertions panic (default) or not.
205 * @returns The old setting.
206 * @param fPanic The new setting.
208 RTDECL(bool) RTAssertSetMayPanic(bool fPanic
);
211 * Can assertion panic.
213 * @returns True if they can, false if not.
215 RTDECL(bool) RTAssertMayPanic(void);
218 /** @name Globals for crash analysis
219 * @remarks This is the full potential set, it
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
;
238 /** @def RTAssertDebugBreak()
239 * Debugger breakpoint instruction.
241 * @remarks This macro does not depend on RT_STRICT.
243 #define RTAssertDebugBreak() do { RT_BREAKPOINT(); } while (0)
247 /** @name Compile time assertions.
249 * These assertions are used to check structure sizes, member/size alignments
250 * and similar compile time expressions.
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.
260 typedef int RTASSERTTYPE
[1];
263 * RTASSERTVAR is the type the AssertCompile() macro redefines.
264 * It has no other function and shouldn't be used.
270 extern int RTASSERTVAR
[1];
275 /** @def RTASSERT_HAVE_STATIC_ASSERT
276 * Indicates that the compiler implements static_assert(expr, msg).
279 # if _MSC_VER >= 1600 && defined(__cplusplus)
280 # define RTASSERT_HAVE_STATIC_ASSERT
283 #if defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__)
284 # define RTASSERT_HAVE_STATIC_ASSERT
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
291 #ifdef DOXYGEN_RUNNING
292 # define RTASSERT_HAVE_STATIC_ASSERT
295 /** @def AssertCompileNS
296 * Asserts that a compile-time expression is true. If it's not break the build.
298 * This differs from AssertCompile in that it accepts some more expressions
299 * than what C++0x allows - NS = Non-standard.
301 * @param expr Expression which should be true.
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]
308 # define AssertCompileNS(expr) typedef int RTASSERTTYPE[(expr) ? 1 : 0]
311 /** @def AssertCompile
312 * Asserts that a C++0x compile-time expression is true. If it's not break the
314 * @param expr Expression which should be true.
316 #ifdef RTASSERT_HAVE_STATIC_ASSERT
317 # define AssertCompile(expr) static_assert(!!(expr), #expr)
319 # define AssertCompile(expr) AssertCompileNS(expr)
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.
326 #if defined(__GNUC__)
328 # define RTASSERT_OFFSET_OF(a_Type, a_Member) __builtin_offsetof(a_Type, a_Member)
330 # define RTASSERT_OFFSET_OF(a_Type, a_Member) RT_OFFSETOF(a_Type, a_Member)
332 #elif (defined(__IBMC__) || defined(__IBMCPP__)) && defined(RT_OS_OS2)
333 # define RTASSERT_OFFSET_OF(a_Type, a_Member) __offsetof(a_Type, a_Member)
335 # define RTASSERT_OFFSET_OF(a_Type, a_Member) RT_OFFSETOF(a_Type, a_Member)
339 /** @def AssertCompileSize
340 * Asserts a size at compile.
341 * @param type The type.
342 * @param size The expected type size.
344 #define AssertCompileSize(type, size) \
345 AssertCompile(sizeof(type) == (size))
347 /** @def AssertCompileSizeAlignment
348 * Asserts a size alignment at compile.
349 * @param type The type.
350 * @param align The size alignment to assert.
352 #define AssertCompileSizeAlignment(type, align) \
353 AssertCompile(!(sizeof(type) & ((align) - 1)))
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.
361 #define AssertCompileMemberSize(type, member, size) \
362 AssertCompile(RT_SIZEOFMEMB(type, member) == (size))
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.
370 #define AssertCompileMemberSizeAlignment(type, member, align) \
371 AssertCompile(!(RT_SIZEOFMEMB(type, member) & ((align) - 1)))
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.
379 #define AssertCompileMemberAlignment(type, member, align) \
380 AssertCompile(!(RTASSERT_OFFSET_OF(type, member) & ((align) - 1)))
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.
388 #define AssertCompileMemberOffset(type, member, off) \
389 AssertCompile(RTASSERT_OFFSET_OF(type, member) == (off))
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.
397 #define AssertCompile2MemberOffsets(type, member1, member2) \
398 AssertCompile(RTASSERT_OFFSET_OF(type, member1) == RTASSERT_OFFSET_OF(type, member2))
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.
406 #define AssertCompileAdjacentMembers(type, member1, member2) \
407 AssertCompile(RTASSERT_OFFSET_OF(type, member1) + RT_SIZEOFMEMB(type, member1) == RTASSERT_OFFSET_OF(type, member2))
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.
416 #define AssertCompileMembersAtSameOffset(type1, member1, type2, member2) \
417 AssertCompile(RTASSERT_OFFSET_OF(type1, member1) == RTASSERT_OFFSET_OF(type2, member2))
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.
426 #define AssertCompileMembersSameSize(type1, member1, type2, member2) \
427 AssertCompile(RT_SIZEOFMEMB(type1, member1) == RT_SIZEOFMEMB(type2, member2))
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.
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))
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.
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.
458 #ifdef DOXYGEN_RUNNING
459 # define RTASSERT_QUIET
461 #if defined(RTASSERT_QUIET) && !defined(DOXYGEN_RUNNING)
462 # define RTAssertMsg1Weak(pszExpr, uLine, pszfile, pszFunction) \
464 # define RTAssertMsg2Weak if (1) {} else RTAssertMsg2Weak
467 /** @def RTAssertDoPanic
468 * Raises an assertion panic appropriate to the current context.
469 * @remarks This macro does not depend on RT_STRICT.
471 #if defined(IN_RING0) \
472 && (defined(RT_OS_DARWIN) || defined(RT_OS_HAIKU) || defined(RT_OS_SOLARIS))
473 # define RTAssertDoPanic() RTR0AssertPanicSystem()
475 # define RTAssertDoPanic() RTAssertDebugBreak()
478 /** @def AssertBreakpoint()
479 * Assertion Breakpoint.
480 * @deprecated Use RTAssertPanic or RTAssertDebugBreak instead.
483 # define AssertBreakpoint() RTAssertDebugBreak()
485 # define AssertBreakpoint() do { } while (0)
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
493 #if defined(RT_STRICT) && !defined(RTASSERT_DONT_PANIC)
494 # define RTAssertPanic() do { if (RTAssertShouldPanic()) RTAssertDoPanic(); } while (0)
496 # define RTAssertPanic() do { } while (0)
500 * Assert that an expression is true. If false, hit breakpoint.
501 * @param expr Expression which should be true.
504 # define Assert(expr) \
506 if (RT_LIKELY(!!(expr))) \
510 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
515 # define Assert(expr) do { } while (0)
520 * Assert that an expression is true. If false, hit breakpoint and execute the
522 * @param expr Expression which should be true.
523 * @param stmt Statement to execute on failure.
526 # define AssertStmt(expr, stmt) \
528 if (RT_LIKELY(!!(expr))) \
532 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
538 # define AssertStmt(expr, stmt) \
540 if (RT_LIKELY(!!(expr))) \
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.
554 * @param expr Expression which should be true.
555 * @param rc What is to be presented to return.
558 # define AssertReturn(expr, rc) \
560 if (RT_LIKELY(!!(expr))) \
564 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
570 # define AssertReturn(expr, rc) \
572 if (RT_LIKELY(!!(expr))) \
579 /** @def AssertReturnStmt
580 * Assert that an expression is true, if it isn't execute the given statement
583 * In RT_STRICT mode it will hit a breakpoint before executing the statement and
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.
591 # define AssertReturnStmt(expr, stmt, rc) \
593 if (RT_LIKELY(!!(expr))) \
597 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
604 # define AssertReturnStmt(expr, stmt, rc) \
606 if (RT_LIKELY(!!(expr))) \
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.
620 * @param expr Expression which should be true.
623 # define AssertReturnVoid(expr) \
625 if (RT_LIKELY(!!(expr))) \
629 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
635 # define AssertReturnVoid(expr) \
637 if (RT_LIKELY(!!(expr))) \
644 /** @def AssertReturnVoidStmt
645 * Assert that an expression is true, if it isn't execute the given statement
648 * In RT_STRICT mode it will hit a breakpoint before returning.
650 * @param expr Expression which should be true.
651 * @param stmt Statement to execute before returning on failure.
654 # define AssertReturnVoidStmt(expr, stmt) \
656 if (RT_LIKELY(!!(expr))) \
660 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
667 # define AssertReturnVoidStmt(expr, stmt) \
669 if (RT_LIKELY(!!(expr))) \
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.
684 * @param expr Expression which should be true.
687 # define AssertBreak(expr) \
688 if (RT_LIKELY(!!(expr))) \
692 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
695 } else do {} while (0)
697 # define AssertBreak(expr) \
698 if (RT_LIKELY(!!(expr))) \
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.
708 * @param expr Expression which should be true.
711 # define AssertContinue(expr) \
712 if (RT_LIKELY(!!(expr))) \
716 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
719 } else do {} while (0)
721 # define AssertContinue(expr) \
722 if (RT_LIKELY(!!(expr))) \
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.
732 * @param expr Expression which should be true.
733 * @param stmt Statement to execute before break in case of a failed assertion.
736 # define AssertBreakStmt(expr, stmt) \
737 if (RT_LIKELY(!!(expr))) \
741 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
745 } else do {} while (0)
747 # define AssertBreakStmt(expr, stmt) \
748 if (RT_LIKELY(!!(expr))) \
754 } else do {} while (0)
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).
764 # define AssertMsg(expr, a) \
766 if (RT_LIKELY(!!(expr))) \
770 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
771 RTAssertMsg2Weak a; \
776 # define AssertMsg(expr, a) do { } while (0)
779 /** @def AssertMsgStmt
780 * Assert that an expression is true. If it's not print message and hit
781 * breakpoint and execute the statement.
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.
787 * @remarks The expression and statement will be evaluated in all build types.
790 # define AssertMsgStmt(expr, a, stmt) \
792 if (RT_LIKELY(!!(expr))) \
796 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
797 RTAssertMsg2Weak a; \
803 # define AssertMsgStmt(expr, a, stmt) \
805 if (RT_LIKELY(!!(expr))) \
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.
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.
823 # define AssertMsgReturn(expr, a, rc) \
825 if (RT_LIKELY(!!(expr))) \
829 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
830 RTAssertMsg2Weak a; \
836 # define AssertMsgReturn(expr, a, rc) \
838 if (RT_LIKELY(!!(expr))) \
845 /** @def AssertMsgReturnStmt
846 * Assert that an expression is true, if it isn't execute the statement and
849 * In RT_STRICT mode it will hit a breakpoint before returning.
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
855 * @param rc What is to be presented to return.
858 # define AssertMsgReturnStmt(expr, a, stmt, rc) \
860 if (RT_LIKELY(!!(expr))) \
864 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
865 RTAssertMsg2Weak a; \
872 # define AssertMsgReturnStmt(expr, a, stmt, rc) \
874 if (RT_LIKELY(!!(expr))) \
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.
888 * @param expr Expression which should be true.
889 * @param a printf argument list (in parenthesis).
892 # define AssertMsgReturnVoid(expr, a) \
894 if (RT_LIKELY(!!(expr))) \
898 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
899 RTAssertMsg2Weak a; \
905 # define AssertMsgReturnVoid(expr, a) \
907 if (RT_LIKELY(!!(expr))) \
914 /** @def AssertMsgReturnVoidStmt
915 * Assert that an expression is true, if it isn't execute the statement and
918 * In RT_STRICT mode it will hit a breakpoint before returning.
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.
925 # define AssertMsgReturnVoidStmt(expr, a, stmt) \
927 if (RT_LIKELY(!!(expr))) \
931 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
932 RTAssertMsg2Weak a; \
939 # define AssertMsgReturnVoidStmt(expr, a, stmt) \
941 if (RT_LIKELY(!!(expr))) \
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.
956 * @param expr Expression which should be true.
957 * @param a printf argument list (in parenthesis).
960 # define AssertMsgBreak(expr, a) \
961 if (RT_LIKELY(!!(expr))) \
965 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
966 RTAssertMsg2Weak a; \
969 } else do {} while (0)
971 # define AssertMsgBreak(expr, a) \
972 if (RT_LIKELY(!!(expr))) \
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.
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.
987 # define AssertMsgBreakStmt(expr, a, stmt) \
988 if (RT_LIKELY(!!(expr))) \
992 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
993 RTAssertMsg2Weak a; \
997 } else do {} while (0)
999 # define AssertMsgBreakStmt(expr, a, stmt) \
1000 if (RT_LIKELY(!!(expr))) \
1006 } else do {} while (0)
1009 /** @def AssertFailed
1010 * An assertion failed, hit breakpoint.
1013 # define AssertFailed() \
1015 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1019 # define AssertFailed() do { } while (0)
1022 /** @def AssertFailedStmt
1023 * An assertion failed, hit breakpoint and execute statement.
1026 # define AssertFailedStmt(stmt) \
1028 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1033 # define AssertFailedStmt(stmt) do { stmt; } while (0)
1036 /** @def AssertFailedReturn
1037 * An assertion failed, hit breakpoint (RT_STRICT mode only) and return.
1039 * @param rc The rc to return.
1042 # define AssertFailedReturn(rc) \
1044 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1049 # define AssertFailedReturn(rc) \
1055 /** @def AssertFailedReturnStmt
1056 * An assertion failed, hit breakpoint (RT_STRICT mode only), execute a
1057 * statement and return a value.
1059 * @param stmt The statement to execute before returning.
1060 * @param rc The value to return.
1063 # define AssertFailedReturnStmt(stmt, rc) \
1065 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1071 # define AssertFailedReturnStmt(stmt, rc) \
1078 /** @def AssertFailedReturnVoid
1079 * An assertion failed, hit breakpoint (RT_STRICT mode only) and return.
1082 # define AssertFailedReturnVoid() \
1084 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1089 # define AssertFailedReturnVoid() \
1095 /** @def AssertFailedReturnVoidStmt
1096 * An assertion failed, hit breakpoint (RT_STRICT mode only), execute a
1097 * statement and return.
1099 * @param stmt The statement to execute before returning.
1102 # define AssertFailedReturnVoidStmt(stmt) \
1104 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1110 # define AssertFailedReturnVoidStmt(stmt) \
1118 /** @def AssertFailedBreak
1119 * An assertion failed, hit breakpoint (RT_STRICT mode only) and break.
1122 # define AssertFailedBreak() \
1124 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1127 } else do {} while (0)
1129 # define AssertFailedBreak() \
1132 else do {} while (0)
1135 /** @def AssertFailedBreakStmt
1136 * An assertion failed, hit breakpoint (RT_STRICT mode only), execute
1137 * the given statement and break.
1139 * @param stmt Statement to execute before break.
1142 # define AssertFailedBreakStmt(stmt) \
1144 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1148 } else do {} while (0)
1150 # define AssertFailedBreakStmt(stmt) \
1154 } else do {} while (0)
1158 /** @def AssertMsgFailed
1159 * An assertion failed print a message and a hit breakpoint.
1161 * @param a printf argument list (in parenthesis).
1164 # define AssertMsgFailed(a) \
1166 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1167 RTAssertMsg2Weak a; \
1171 # define AssertMsgFailed(a) do { } while (0)
1174 /** @def AssertMsgFailedReturn
1175 * An assertion failed, hit breakpoint with message (RT_STRICT mode only) and return.
1177 * @param a printf argument list (in parenthesis).
1178 * @param rc What is to be presented to return.
1181 # define AssertMsgFailedReturn(a, rc) \
1183 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1184 RTAssertMsg2Weak a; \
1189 # define AssertMsgFailedReturn(a, rc) \
1195 /** @def AssertMsgFailedReturnVoid
1196 * An assertion failed, hit breakpoint with message (RT_STRICT mode only) and return.
1198 * @param a printf argument list (in parenthesis).
1201 # define AssertMsgFailedReturnVoid(a) \
1203 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1204 RTAssertMsg2Weak a; \
1209 # define AssertMsgFailedReturnVoid(a) \
1216 /** @def AssertMsgFailedBreak
1217 * An assertion failed, hit breakpoint with message (RT_STRICT mode only) and break.
1219 * @param a printf argument list (in parenthesis).
1222 # define AssertMsgFailedBreak(a) \
1224 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1225 RTAssertMsg2Weak a; \
1228 } else do {} while (0)
1230 # define AssertMsgFailedBreak(a) \
1233 else do {} while (0)
1236 /** @def AssertMsgFailedBreakStmt
1237 * An assertion failed, hit breakpoint (RT_STRICT mode only), execute
1238 * the given statement and break.
1240 * @param a printf argument list (in parenthesis).
1241 * @param stmt Statement to execute before break.
1244 # define AssertMsgFailedBreakStmt(a, stmt) \
1246 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1247 RTAssertMsg2Weak a; \
1251 } else do {} while (0)
1253 # define AssertMsgFailedBreakStmt(a, stmt) \
1257 } else do {} while (0)
1264 /** @name Release Log Assertions
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
1274 /** @def RTAssertLogRelMsg1
1275 * RTAssertMsg1Weak (strict builds) / LogRel wrapper (non-strict).
1278 # define RTAssertLogRelMsg1(pszExpr, iLine, pszFile, pszFunction) \
1279 RTAssertMsg1Weak(pszExpr, iLine, pszFile, pszFunction)
1281 # define RTAssertLogRelMsg1(pszExpr, iLine, pszFile, pszFunction) \
1282 LogRel(("AssertLogRel %s(%d) %s: %s\n",\
1283 (pszFile), (iLine), (pszFunction), (pszExpr) ))
1286 /** @def RTAssertLogRelMsg2
1287 * RTAssertMsg2Weak (strict builds) / LogRel wrapper (non-strict).
1290 # define RTAssertLogRelMsg2(a) RTAssertMsg2Weak a
1292 # define RTAssertLogRelMsg2(a) LogRel(a)
1295 /** @def AssertLogRel
1296 * Assert that an expression is true.
1297 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1299 * @param expr Expression which should be true.
1301 #define AssertLogRel(expr) \
1303 if (RT_LIKELY(!!(expr))) \
1307 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
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.
1316 * @param expr Expression which should be true.
1317 * @param rc What is to be presented to return.
1319 #define AssertLogRelReturn(expr, rc) \
1321 if (RT_LIKELY(!!(expr))) \
1325 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
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.
1335 * @param expr Expression which should be true.
1337 #define AssertLogRelReturnVoid(expr) \
1339 if (RT_LIKELY(!!(expr))) \
1343 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
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.
1353 * @param expr Expression which should be true.
1355 #define AssertLogRelBreak(expr) \
1356 if (RT_LIKELY(!!(expr))) \
1360 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1364 else do {} while (0)
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.
1370 * @param expr Expression which should be true.
1371 * @param stmt Statement to execute before break in case of a failed assertion.
1373 #define AssertLogRelBreakStmt(expr, stmt) \
1374 if (RT_LIKELY(!!(expr))) \
1378 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1382 } else do {} while (0)
1384 /** @def AssertLogRelMsg
1385 * Assert that an expression is true.
1386 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1388 * @param expr Expression which should be true.
1389 * @param a printf argument list (in parenthesis).
1391 #define AssertLogRelMsg(expr, a) \
1393 if (RT_LIKELY(!!(expr))) \
1397 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1398 RTAssertLogRelMsg2(a); \
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.
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.
1411 #define AssertLogRelMsgStmt(expr, a, stmt) \
1413 if (RT_LIKELY(!!(expr))) \
1417 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1418 RTAssertLogRelMsg2(a); \
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.
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.
1432 #define AssertLogRelMsgReturn(expr, a, rc) \
1434 if (RT_LIKELY(!!(expr))) \
1438 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1439 RTAssertLogRelMsg2(a); \
1445 /** @def AssertLogRelMsgReturnStmt
1446 * Assert that an expression is true, execute @a stmt and return @a rcRet if it
1448 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
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
1454 * @param rcRet What is to be presented to return.
1456 #define AssertLogRelMsgReturnStmt(expr, a, stmt, rcRet) \
1458 if (RT_LIKELY(!!(expr))) \
1462 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1463 RTAssertLogRelMsg2(a); \
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.
1474 * @param expr Expression which should be true.
1475 * @param a printf argument list (in parenthesis).
1477 #define AssertLogRelMsgReturnVoid(expr, a) \
1479 if (RT_LIKELY(!!(expr))) \
1483 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1484 RTAssertLogRelMsg2(a); \
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.
1494 * @param expr Expression which should be true.
1495 * @param a printf argument list (in parenthesis).
1497 #define AssertLogRelMsgBreak(expr, a) \
1498 if (RT_LIKELY(!!(expr))) \
1502 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1503 RTAssertLogRelMsg2(a); \
1507 else do {} while (0)
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.
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.
1517 #define AssertLogRelMsgBreakStmt(expr, a, stmt) \
1518 if (RT_LIKELY(!!(expr))) \
1522 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1523 RTAssertLogRelMsg2(a); \
1527 } else do {} while (0)
1529 /** @def AssertLogRelFailed
1530 * An assertion failed.
1531 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1533 #define AssertLogRelFailed() \
1535 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1539 /** @def AssertLogRelFailedReturn
1540 * An assertion failed.
1541 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1543 * @param rc What is to be presented to return.
1545 #define AssertLogRelFailedReturn(rc) \
1547 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
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.
1556 #define AssertLogRelFailedReturnVoid() \
1558 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1563 /** @def AssertLogRelFailedBreak
1564 * An assertion failed, break.
1565 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1567 #define AssertLogRelFailedBreak() \
1570 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1573 } else do {} while (0)
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.
1579 * @param stmt Statement to execute before break.
1581 #define AssertLogRelFailedBreakStmt(stmt) \
1584 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1588 } else do {} while (0)
1590 /** @def AssertLogRelMsgFailed
1591 * An assertion failed.
1592 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1594 * @param a printf argument list (in parenthesis).
1596 #define AssertLogRelMsgFailed(a) \
1598 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1599 RTAssertLogRelMsg2(a); \
1603 /** @def AssertLogRelMsgFailedStmt
1604 * An assertion failed, execute @a stmt.
1606 * Strict builds will hit a breakpoint, non-strict will only do LogRel. The
1607 * statement will be executed in regardless of build type.
1609 * @param a printf argument list (in parenthesis).
1610 * @param stmt Statement to execute after raising/logging the assertion.
1612 #define AssertLogRelMsgFailedStmt(a, stmt) \
1614 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1615 RTAssertLogRelMsg2(a); \
1620 /** @def AssertLogRelMsgFailedReturn
1621 * An assertion failed, return \a rc.
1622 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1624 * @param a printf argument list (in parenthesis).
1625 * @param rc What is to be presented to return.
1627 #define AssertLogRelMsgFailedReturn(a, rc) \
1629 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1630 RTAssertLogRelMsg2(a); \
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.
1639 * @param a printf argument list (in parenthesis).
1640 * @param stmt Statement to execute before returning in case of a failed
1642 * @param rc What is to be presented to return.
1644 #define AssertLogRelMsgFailedReturnStmt(a, stmt, rc) \
1646 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1647 RTAssertLogRelMsg2(a); \
1653 /** @def AssertLogRelMsgFailedReturnVoid
1654 * An assertion failed, return void.
1655 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1657 * @param a printf argument list (in parenthesis).
1659 #define AssertLogRelMsgFailedReturnVoid(a) \
1661 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1662 RTAssertLogRelMsg2(a); \
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.
1671 * @param a printf argument list (in parenthesis).
1672 * @param stmt Statement to execute before returning in case of a failed
1675 #define AssertLogRelMsgFailedReturnVoidStmt(a, stmt) \
1677 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1678 RTAssertLogRelMsg2(a); \
1684 /** @def AssertLogRelMsgFailedBreak
1685 * An assertion failed, break.
1686 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1688 * @param a printf argument list (in parenthesis).
1690 #define AssertLogRelMsgFailedBreak(a) \
1693 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1694 RTAssertLogRelMsg2(a); \
1697 } else do {} while (0)
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.
1703 * @param a printf argument list (in parenthesis).
1704 * @param stmt Statement to execute before break.
1706 #define AssertLogRelMsgFailedBreakStmt(a, stmt) \
1709 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1710 RTAssertLogRelMsg2(a); \
1714 } else do {} while (0)
1720 /** @name Release Assertions
1722 * These assertions are always enabled.
1726 /** @def RTAssertReleasePanic()
1727 * Invokes RTAssertShouldPanic and RTAssertDoPanic.
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).
1733 #define RTAssertReleasePanic() do { RTAssertShouldPanic(); RTAssertDoPanic(); } while (0)
1736 /** @def AssertRelease
1737 * Assert that an expression is true. If it's not hit a breakpoint.
1739 * @param expr Expression which should be true.
1741 #define AssertRelease(expr) \
1743 if (RT_LIKELY(!!(expr))) \
1747 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1748 RTAssertReleasePanic(); \
1752 /** @def AssertReleaseReturn
1753 * Assert that an expression is true, hit a breakpoint and return if it isn't.
1755 * @param expr Expression which should be true.
1756 * @param rc What is to be presented to return.
1758 #define AssertReleaseReturn(expr, rc) \
1760 if (RT_LIKELY(!!(expr))) \
1764 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1765 RTAssertReleasePanic(); \
1770 /** @def AssertReleaseReturnVoid
1771 * Assert that an expression is true, hit a breakpoint and return if it isn't.
1773 * @param expr Expression which should be true.
1775 #define AssertReleaseReturnVoid(expr) \
1777 if (RT_LIKELY(!!(expr))) \
1781 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1782 RTAssertReleasePanic(); \
1788 /** @def AssertReleaseBreak
1789 * Assert that an expression is true, hit a breakpoint and break if it isn't.
1791 * @param expr Expression which should be true.
1793 #define AssertReleaseBreak(expr) \
1794 if (RT_LIKELY(!!(expr))) \
1798 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1799 RTAssertReleasePanic(); \
1801 } else do {} while (0)
1803 /** @def AssertReleaseBreakStmt
1804 * Assert that an expression is true, hit a breakpoint and break if it isn't.
1806 * @param expr Expression which should be true.
1807 * @param stmt Statement to execute before break in case of a failed assertion.
1809 #define AssertReleaseBreakStmt(expr, stmt) \
1810 if (RT_LIKELY(!!(expr))) \
1814 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1815 RTAssertReleasePanic(); \
1818 } else do {} while (0)
1821 /** @def AssertReleaseMsg
1822 * Assert that an expression is true, print the message and hit a breakpoint if it isn't.
1824 * @param expr Expression which should be true.
1825 * @param a printf argument list (in parenthesis).
1827 #define AssertReleaseMsg(expr, a) \
1829 if (RT_LIKELY(!!(expr))) \
1833 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1834 RTAssertMsg2Weak a; \
1835 RTAssertReleasePanic(); \
1839 /** @def AssertReleaseMsgReturn
1840 * Assert that an expression is true, print the message and hit a breakpoint and return if it isn't.
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.
1846 #define AssertReleaseMsgReturn(expr, a, rc) \
1848 if (RT_LIKELY(!!(expr))) \
1852 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1853 RTAssertMsg2Weak a; \
1854 RTAssertReleasePanic(); \
1859 /** @def AssertReleaseMsgReturnVoid
1860 * Assert that an expression is true, print the message and hit a breakpoint and return if it isn't.
1862 * @param expr Expression which should be true.
1863 * @param a printf argument list (in parenthesis).
1865 #define AssertReleaseMsgReturnVoid(expr, a) \
1867 if (RT_LIKELY(!!(expr))) \
1871 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1872 RTAssertMsg2Weak a; \
1873 RTAssertReleasePanic(); \
1879 /** @def AssertReleaseMsgBreak
1880 * Assert that an expression is true, print the message and hit a breakpoint and break if it isn't.
1882 * @param expr Expression which should be true.
1883 * @param a printf argument list (in parenthesis).
1885 #define AssertReleaseMsgBreak(expr, a) \
1886 if (RT_LIKELY(!!(expr))) \
1890 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1891 RTAssertMsg2Weak a; \
1892 RTAssertReleasePanic(); \
1894 } else do {} while (0)
1896 /** @def AssertReleaseMsgBreakStmt
1897 * Assert that an expression is true, print the message and hit a breakpoint and break if it isn't.
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.
1903 #define AssertReleaseMsgBreakStmt(expr, a, stmt) \
1904 if (RT_LIKELY(!!(expr))) \
1908 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1909 RTAssertMsg2Weak a; \
1910 RTAssertReleasePanic(); \
1913 } else do {} while (0)
1916 /** @def AssertReleaseFailed
1917 * An assertion failed, hit a breakpoint.
1919 #define AssertReleaseFailed() \
1921 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1922 RTAssertReleasePanic(); \
1925 /** @def AssertReleaseFailedReturn
1926 * An assertion failed, hit a breakpoint and return.
1928 * @param rc What is to be presented to return.
1930 #define AssertReleaseFailedReturn(rc) \
1932 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1933 RTAssertReleasePanic(); \
1937 /** @def AssertReleaseFailedReturnVoid
1938 * An assertion failed, hit a breakpoint and return.
1940 #define AssertReleaseFailedReturnVoid() \
1942 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1943 RTAssertReleasePanic(); \
1948 /** @def AssertReleaseFailedBreak
1949 * An assertion failed, hit a breakpoint and break.
1951 #define AssertReleaseFailedBreak() \
1953 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1954 RTAssertReleasePanic(); \
1956 } else do {} while (0)
1958 /** @def AssertReleaseFailedBreakStmt
1959 * An assertion failed, hit a breakpoint and break.
1961 * @param stmt Statement to execute before break.
1963 #define AssertReleaseFailedBreakStmt(stmt) \
1965 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1966 RTAssertReleasePanic(); \
1969 } else do {} while (0)
1972 /** @def AssertReleaseMsgFailed
1973 * An assertion failed, print a message and hit a breakpoint.
1975 * @param a printf argument list (in parenthesis).
1977 #define AssertReleaseMsgFailed(a) \
1979 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1980 RTAssertMsg2Weak a; \
1981 RTAssertReleasePanic(); \
1984 /** @def AssertReleaseMsgFailedReturn
1985 * An assertion failed, print a message, hit a breakpoint and return.
1987 * @param a printf argument list (in parenthesis).
1988 * @param rc What is to be presented to return.
1990 #define AssertReleaseMsgFailedReturn(a, rc) \
1992 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1993 RTAssertMsg2Weak a; \
1994 RTAssertReleasePanic(); \
1998 /** @def AssertReleaseMsgFailedReturnVoid
1999 * An assertion failed, print a message, hit a breakpoint and return.
2001 * @param a printf argument list (in parenthesis).
2003 #define AssertReleaseMsgFailedReturnVoid(a) \
2005 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
2006 RTAssertMsg2Weak a; \
2007 RTAssertReleasePanic(); \
2012 /** @def AssertReleaseMsgFailedBreak
2013 * An assertion failed, print a message, hit a breakpoint and break.
2015 * @param a printf argument list (in parenthesis).
2017 #define AssertReleaseMsgFailedBreak(a) \
2019 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
2020 RTAssertMsg2Weak a; \
2021 RTAssertReleasePanic(); \
2023 } else do {} while (0)
2025 /** @def AssertReleaseMsgFailedBreakStmt
2026 * An assertion failed, print a message, hit a breakpoint and break.
2028 * @param a printf argument list (in parenthesis).
2029 * @param stmt Statement to execute before break.
2031 #define AssertReleaseMsgFailedBreakStmt(a, stmt) \
2033 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
2034 RTAssertMsg2Weak a; \
2035 RTAssertReleasePanic(); \
2038 } else do {} while (0)
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.
2051 /** @def AssertFatal
2052 * Assert that an expression is true. If it's not hit a breakpoint (for ever).
2054 * @param expr Expression which should be true.
2056 #define AssertFatal(expr) \
2058 if (RT_LIKELY(!!(expr))) \
2063 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
2064 RTAssertReleasePanic(); \
2068 /** @def AssertFatalMsg
2069 * Assert that an expression is true, print the message and hit a breakpoint (for ever) if it isn't.
2071 * @param expr Expression which should be true.
2072 * @param a printf argument list (in parenthesis).
2074 #define AssertFatalMsg(expr, a) \
2076 if (RT_LIKELY(!!(expr))) \
2081 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
2082 RTAssertMsg2Weak a; \
2083 RTAssertReleasePanic(); \
2087 /** @def AssertFatalFailed
2088 * An assertion failed, hit a breakpoint (for ever).
2090 #define AssertFatalFailed() \
2094 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
2095 RTAssertReleasePanic(); \
2099 /** @def AssertFatalMsgFailed
2100 * An assertion failed, print a message and hit a breakpoint (for ever).
2102 * @param a printf argument list (in parenthesis).
2104 #define AssertFatalMsgFailed(a) \
2108 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
2109 RTAssertMsg2Weak a; \
2110 RTAssertReleasePanic(); \
2118 /** @name Convenience Assertions Macros
2123 * Asserts a iprt status code successful.
2125 * On failure it will print info about the rc and hit a breakpoint.
2127 * @param rc iprt status code.
2128 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2130 #define AssertRC(rc) AssertMsgRC(rc, ("%Rra\n", (rc)))
2132 /** @def AssertRCStmt
2133 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and execute
2134 * @a stmt if it isn't.
2136 * @param rc iprt status code.
2137 * @param stmt Statement to execute before returning in case of a failed
2139 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2141 #define AssertRCStmt(rc, stmt) AssertMsgRCStmt(rc, ("%Rra\n", (rc)), stmt)
2143 /** @def AssertRCReturn
2144 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return if it isn't.
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.
2150 #define AssertRCReturn(rc, rcRet) AssertMsgRCReturn(rc, ("%Rra\n", (rc)), rcRet)
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.
2156 * @param rc iprt status code.
2157 * @param stmt Statement to execute before returning in case of a failed
2159 * @param rcRet What is to be presented to return.
2160 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2162 #define AssertRCReturnStmt(rc, stmt, rcRet) AssertMsgRCReturnStmt(rc, ("%Rra\n", (rc)), stmt, rcRet)
2164 /** @def AssertRCReturnVoid
2165 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return if it isn't.
2167 * @param rc iprt status code.
2168 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2170 #define AssertRCReturnVoid(rc) AssertMsgRCReturnVoid(rc, ("%Rra\n", (rc)))
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.
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.
2180 #define AssertRCReturnVoidStmt(rc, stmt) AssertMsgRCReturnVoidStmt(rc, ("%Rra\n", (rc)), stmt)
2182 /** @def AssertRCBreak
2183 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break if it isn't.
2185 * @param rc iprt status code.
2186 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2188 #define AssertRCBreak(rc) AssertMsgRCBreak(rc, ("%Rra\n", (rc)))
2190 /** @def AssertRCBreakStmt
2191 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break if it isn't.
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.
2197 #define AssertRCBreakStmt(rc, stmt) AssertMsgRCBreakStmt(rc, ("%Rra\n", (rc)), stmt)
2199 /** @def AssertMsgRC
2200 * Asserts a iprt status code successful.
2202 * It prints a custom message and hits a breakpoint on FAILURE.
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.
2208 #define AssertMsgRC(rc, msg) \
2209 do { AssertMsg(RT_SUCCESS_NP(rc), msg); NOREF(rc); } while (0)
2211 /** @def AssertMsgRCStmt
2212 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and
2213 * execute @a stmt if it isn't.
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
2219 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2221 #define AssertMsgRCStmt(rc, msg, stmt) \
2222 do { AssertMsgStmt(RT_SUCCESS_NP(rc), msg, stmt); NOREF(rc); } while (0)
2224 /** @def AssertMsgRCReturn
2225 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return
2226 * @a rcRet if it isn't.
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.
2233 #define AssertMsgRCReturn(rc, msg, rcRet) \
2234 do { AssertMsgReturn(RT_SUCCESS_NP(rc), msg, rcRet); NOREF(rc); } while (0)
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.
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
2244 * @param rcRet What is to be presented to return.
2245 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2247 #define AssertMsgRCReturnStmt(rc, msg, stmt, rcRet) \
2248 do { AssertMsgReturnStmt(RT_SUCCESS_NP(rc), msg, stmt, rcRet); NOREF(rc); } while (0)
2250 /** @def AssertMsgRCReturnVoid
2251 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return
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.
2258 #define AssertMsgRCReturnVoid(rc, msg) \
2259 do { AssertMsgReturnVoid(RT_SUCCESS_NP(rc), msg); NOREF(rc); } while (0)
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.
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.
2270 #define AssertMsgRCReturnVoidStmt(rc, msg, stmt) \
2271 do { AssertMsgReturnVoidStmt(RT_SUCCESS_NP(rc), msg, stmt); NOREF(rc); } while (0)
2273 /** @def AssertMsgRCBreak
2274 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break
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.
2281 #define AssertMsgRCBreak(rc, msg) \
2282 if (1) { AssertMsgBreak(RT_SUCCESS(rc), msg); NOREF(rc); } else do {} while (0)
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.
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.
2293 #define AssertMsgRCBreakStmt(rc, msg, stmt) \
2294 if (1) { AssertMsgBreakStmt(RT_SUCCESS_NP(rc), msg, stmt); NOREF(rc); } else do {} while (0)
2296 /** @def AssertRCSuccess
2297 * Asserts an iprt status code equals VINF_SUCCESS.
2299 * On failure it will print info about the rc and hit a breakpoint.
2301 * @param rc iprt status code.
2302 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2304 #define AssertRCSuccess(rc) do { AssertMsg((rc) == VINF_SUCCESS, ("%Rra\n", (rc))); NOREF(rc); } while (0)
2306 /** @def AssertRCSuccessReturn
2307 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and return if it isn't.
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.
2313 #define AssertRCSuccessReturn(rc, rcRet) AssertMsgReturn((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), rcRet)
2315 /** @def AssertRCSuccessReturnVoid
2316 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and return if it isn't.
2318 * @param rc iprt status code.
2319 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2321 #define AssertRCSuccessReturnVoid(rc) AssertMsgReturnVoid((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2323 /** @def AssertRCSuccessBreak
2324 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and break if it isn't.
2326 * @param rc iprt status code.
2327 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2329 #define AssertRCSuccessBreak(rc) AssertMsgBreak((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2331 /** @def AssertRCSuccessBreakStmt
2332 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and break if it isn't.
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.
2338 #define AssertRCSuccessBreakStmt(rc, stmt) AssertMsgBreakStmt((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), stmt)
2341 /** @def AssertLogRelRC
2342 * Asserts a iprt status code successful.
2344 * @param rc iprt status code.
2345 * @remark rc is referenced multiple times.
2347 #define AssertLogRelRC(rc) AssertLogRelMsgRC(rc, ("%Rra\n", (rc)))
2349 /** @def AssertLogRelRCReturn
2350 * Asserts a iprt status code successful, returning \a rc if it isn't.
2352 * @param rc iprt status code.
2353 * @param rcRet What is to be presented to return.
2354 * @remark rc is referenced multiple times.
2356 #define AssertLogRelRCReturn(rc, rcRet) AssertLogRelMsgRCReturn(rc, ("%Rra\n", (rc)), rcRet)
2358 /** @def AssertLogRelRCReturnStmt
2359 * Asserts a iprt status code successful, executing \a stmt and returning \a rc
2362 * @param rc iprt status code.
2363 * @param stmt Statement to execute before returning in case of a failed
2365 * @param rcRet What is to be presented to return.
2366 * @remark rc is referenced multiple times.
2368 #define AssertLogRelRCReturnStmt(rc, stmt, rcRet) AssertLogRelMsgRCReturnStmt(rc, ("%Rra\n", (rc)), stmt, rcRet)
2370 /** @def AssertLogRelRCReturnVoid
2371 * Asserts a iprt status code successful, returning (void) if it isn't.
2373 * @param rc iprt status code.
2374 * @remark rc is referenced multiple times.
2376 #define AssertLogRelRCReturnVoid(rc) AssertLogRelMsgRCReturnVoid(rc, ("%Rra\n", (rc)))
2378 /** @def AssertLogRelRCBreak
2379 * Asserts a iprt status code successful, breaking if it isn't.
2381 * @param rc iprt status code.
2382 * @remark rc is referenced multiple times.
2384 #define AssertLogRelRCBreak(rc) AssertLogRelMsgRCBreak(rc, ("%Rra\n", (rc)))
2386 /** @def AssertLogRelRCBreakStmt
2387 * Asserts a iprt status code successful, execute \a statement and break if it isn't.
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.
2393 #define AssertLogRelRCBreakStmt(rc, stmt) AssertLogRelMsgRCBreakStmt(rc, ("%Rra\n", (rc)), stmt)
2395 /** @def AssertLogRelMsgRC
2396 * Asserts a iprt status code successful.
2398 * @param rc iprt status code.
2399 * @param msg printf argument list (in parenthesis).
2400 * @remark rc is referenced multiple times.
2402 #define AssertLogRelMsgRC(rc, msg) AssertLogRelMsg(RT_SUCCESS_NP(rc), msg)
2404 /** @def AssertLogRelMsgRCReturn
2405 * Asserts a iprt status code successful.
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.
2412 #define AssertLogRelMsgRCReturn(rc, msg, rcRet) AssertLogRelMsgReturn(RT_SUCCESS_NP(rc), msg, rcRet)
2414 /** @def AssertLogRelMsgRCReturnStmt
2415 * Asserts a iprt status code successful, execute \a stmt and return on
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
2422 * @param rcRet What is to be presented to return.
2423 * @remark rc is referenced multiple times.
2425 #define AssertLogRelMsgRCReturnStmt(rc, msg, stmt, rcRet) AssertLogRelMsgReturnStmt(RT_SUCCESS_NP(rc), msg, stmt, rcRet)
2427 /** @def AssertLogRelMsgRCReturnVoid
2428 * Asserts a iprt status code successful.
2430 * @param rc iprt status code.
2431 * @param msg printf argument list (in parenthesis).
2432 * @remark rc is referenced multiple times.
2434 #define AssertLogRelMsgRCReturnVoid(rc, msg) AssertLogRelMsgReturnVoid(RT_SUCCESS_NP(rc), msg)
2436 /** @def AssertLogRelMsgRCBreak
2437 * Asserts a iprt status code successful.
2439 * @param rc iprt status code.
2440 * @param msg printf argument list (in parenthesis).
2441 * @remark rc is referenced multiple times.
2443 #define AssertLogRelMsgRCBreak(rc, msg) AssertLogRelMsgBreak(RT_SUCCESS(rc), msg)
2445 /** @def AssertLogRelMsgRCBreakStmt
2446 * Asserts a iprt status code successful, execute \a stmt and break if it isn't.
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.
2453 #define AssertLogRelMsgRCBreakStmt(rc, msg, stmt) AssertLogRelMsgBreakStmt(RT_SUCCESS_NP(rc), msg, stmt)
2455 /** @def AssertLogRelRCSuccess
2456 * Asserts that an iprt status code equals VINF_SUCCESS.
2458 * @param rc iprt status code.
2459 * @remark rc is referenced multiple times.
2461 #define AssertLogRelRCSuccess(rc) AssertLogRelMsg((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2463 /** @def AssertLogRelRCSuccessReturn
2464 * Asserts that an iprt status code equals VINF_SUCCESS.
2466 * @param rc iprt status code.
2467 * @param rcRet What is to be presented to return.
2468 * @remark rc is referenced multiple times.
2470 #define AssertLogRelRCSuccessReturn(rc, rcRet) AssertLogRelMsgReturn((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), rcRet)
2472 /** @def AssertLogRelRCSuccessReturnVoid
2473 * Asserts that an iprt status code equals VINF_SUCCESS.
2475 * @param rc iprt status code.
2476 * @remark rc is referenced multiple times.
2478 #define AssertLogRelRCSuccessReturnVoid(rc) AssertLogRelMsgReturnVoid((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2480 /** @def AssertLogRelRCSuccessBreak
2481 * Asserts that an iprt status code equals VINF_SUCCESS.
2483 * @param rc iprt status code.
2484 * @remark rc is referenced multiple times.
2486 #define AssertLogRelRCSuccessBreak(rc) AssertLogRelMsgBreak((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2488 /** @def AssertLogRelRCSuccessBreakStmt
2489 * Asserts that an iprt status code equals VINF_SUCCESS.
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.
2495 #define AssertLogRelRCSuccessBreakStmt(rc, stmt) AssertLogRelMsgBreakStmt((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), stmt)
2498 /** @def AssertReleaseRC
2499 * Asserts a iprt status code successful.
2501 * On failure information about the error will be printed and a breakpoint hit.
2503 * @param rc iprt status code.
2504 * @remark rc is referenced multiple times.
2506 #define AssertReleaseRC(rc) AssertReleaseMsgRC(rc, ("%Rra\n", (rc)))
2508 /** @def AssertReleaseRCReturn
2509 * Asserts a iprt status code successful, returning if it isn't.
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.
2514 * @param rc iprt status code.
2515 * @param rcRet What is to be presented to return.
2516 * @remark rc is referenced multiple times.
2518 #define AssertReleaseRCReturn(rc, rcRet) AssertReleaseMsgRCReturn(rc, ("%Rra\n", (rc)), rcRet)
2520 /** @def AssertReleaseRCReturnVoid
2521 * Asserts a iprt status code successful, returning if it isn't.
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.
2526 * @param rc iprt status code.
2527 * @remark rc is referenced multiple times.
2529 #define AssertReleaseRCReturnVoid(rc) AssertReleaseMsgRCReturnVoid(rc, ("%Rra\n", (rc)))
2531 /** @def AssertReleaseRCBreak
2532 * Asserts a iprt status code successful, breaking if it isn't.
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.
2537 * @param rc iprt status code.
2538 * @remark rc is referenced multiple times.
2540 #define AssertReleaseRCBreak(rc) AssertReleaseMsgRCBreak(rc, ("%Rra\n", (rc)))
2542 /** @def AssertReleaseRCBreakStmt
2543 * Asserts a iprt status code successful, break if it isn't.
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.
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.
2552 #define AssertReleaseRCBreakStmt(rc, stmt) AssertReleaseMsgRCBreakStmt(rc, ("%Rra\n", (rc)), stmt)
2554 /** @def AssertReleaseMsgRC
2555 * Asserts a iprt status code successful.
2557 * On failure a custom message is printed and a breakpoint is hit.
2559 * @param rc iprt status code.
2560 * @param msg printf argument list (in parenthesis).
2561 * @remark rc is referenced multiple times.
2563 #define AssertReleaseMsgRC(rc, msg) AssertReleaseMsg(RT_SUCCESS_NP(rc), msg)
2565 /** @def AssertReleaseMsgRCReturn
2566 * Asserts a iprt status code successful.
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.
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.
2576 #define AssertReleaseMsgRCReturn(rc, msg, rcRet) AssertReleaseMsgReturn(RT_SUCCESS_NP(rc), msg, rcRet)
2578 /** @def AssertReleaseMsgRCReturnVoid
2579 * Asserts a iprt status code successful.
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.
2584 * @param rc iprt status code.
2585 * @param msg printf argument list (in parenthesis).
2586 * @remark rc is referenced multiple times.
2588 #define AssertReleaseMsgRCReturnVoid(rc, msg) AssertReleaseMsgReturnVoid(RT_SUCCESS_NP(rc), msg)
2590 /** @def AssertReleaseMsgRCBreak
2591 * Asserts a iprt status code successful.
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.
2596 * @param rc iprt status code.
2597 * @param msg printf argument list (in parenthesis).
2598 * @remark rc is referenced multiple times.
2600 #define AssertReleaseMsgRCBreak(rc, msg) AssertReleaseMsgBreak(RT_SUCCESS(rc), msg)
2602 /** @def AssertReleaseMsgRCBreakStmt
2603 * Asserts a iprt status code successful.
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.
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.
2613 #define AssertReleaseMsgRCBreakStmt(rc, msg, stmt) AssertReleaseMsgBreakStmt(RT_SUCCESS_NP(rc), msg, stmt)
2615 /** @def AssertReleaseRCSuccess
2616 * Asserts that an iprt status code equals VINF_SUCCESS.
2618 * On failure information about the error will be printed and a breakpoint hit.
2620 * @param rc iprt status code.
2621 * @remark rc is referenced multiple times.
2623 #define AssertReleaseRCSuccess(rc) AssertReleaseMsg((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2625 /** @def AssertReleaseRCSuccessReturn
2626 * Asserts that an iprt status code equals VINF_SUCCESS.
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.
2631 * @param rc iprt status code.
2632 * @param rcRet What is to be presented to return.
2633 * @remark rc is referenced multiple times.
2635 #define AssertReleaseRCSuccessReturn(rc, rcRet) AssertReleaseMsgReturn((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), rcRet)
2637 /** @def AssertReleaseRCSuccessReturnVoid
2638 * Asserts that an iprt status code equals VINF_SUCCESS.
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.
2643 * @param rc iprt status code.
2644 * @remark rc is referenced multiple times.
2646 #define AssertReleaseRCSuccessReturnVoid(rc) AssertReleaseMsgReturnVoid((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2648 /** @def AssertReleaseRCSuccessBreak
2649 * Asserts that an iprt status code equals VINF_SUCCESS.
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.
2654 * @param rc iprt status code.
2655 * @remark rc is referenced multiple times.
2657 #define AssertReleaseRCSuccessBreak(rc) AssertReleaseMsgBreak((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2659 /** @def AssertReleaseRCSuccessBreakStmt
2660 * Asserts that an iprt status code equals VINF_SUCCESS.
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.
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.
2669 #define AssertReleaseRCSuccessBreakStmt(rc, stmt) AssertReleaseMsgBreakStmt((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), stmt)
2672 /** @def AssertFatalRC
2673 * Asserts a iprt status code successful.
2675 * On failure information about the error will be printed and a breakpoint hit.
2677 * @param rc iprt status code.
2678 * @remark rc is referenced multiple times.
2680 #define AssertFatalRC(rc) AssertFatalMsgRC(rc, ("%Rra\n", (rc)))
2682 /** @def AssertReleaseMsgRC
2683 * Asserts a iprt status code successful.
2685 * On failure a custom message is printed and a breakpoint is hit.
2687 * @param rc iprt status code.
2688 * @param msg printf argument list (in parenthesis).
2689 * @remark rc is referenced multiple times.
2691 #define AssertFatalMsgRC(rc, msg) AssertFatalMsg(RT_SUCCESS_NP(rc), msg)
2693 /** @def AssertFatalRCSuccess
2694 * Asserts that an iprt status code equals VINF_SUCCESS.
2696 * On failure information about the error will be printed and a breakpoint hit.
2698 * @param rc iprt status code.
2699 * @remark rc is referenced multiple times.
2701 #define AssertFatalRCSuccess(rc) AssertFatalMsg((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2705 * Asserts that a pointer is valid.
2707 * @param pv The pointer.
2709 #define AssertPtr(pv) AssertMsg(VALID_PTR(pv), ("%p\n", (pv)))
2711 /** @def AssertPtrReturn
2712 * Asserts that a pointer is valid.
2714 * @param pv The pointer.
2715 * @param rcRet What is to be presented to return.
2717 #define AssertPtrReturn(pv, rcRet) AssertMsgReturn(VALID_PTR(pv), ("%p\n", (pv)), rcRet)
2719 /** @def AssertPtrReturnVoid
2720 * Asserts that a pointer is valid.
2722 * @param pv The pointer.
2724 #define AssertPtrReturnVoid(pv) AssertMsgReturnVoid(VALID_PTR(pv), ("%p\n", (pv)))
2726 /** @def AssertPtrBreak
2727 * Asserts that a pointer is valid.
2729 * @param pv The pointer.
2731 #define AssertPtrBreak(pv) AssertMsgBreak(VALID_PTR(pv), ("%p\n", (pv)))
2733 /** @def AssertPtrBreakStmt
2734 * Asserts that a pointer is valid.
2736 * @param pv The pointer.
2737 * @param stmt Statement to execute before break in case of a failed assertion.
2739 #define AssertPtrBreakStmt(pv, stmt) AssertMsgBreakStmt(VALID_PTR(pv), ("%p\n", (pv)), stmt)
2741 /** @def AssertPtrNull
2742 * Asserts that a pointer is valid or NULL.
2744 * @param pv The pointer.
2746 #define AssertPtrNull(pv) AssertMsg(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)))
2748 /** @def AssertPtrNullReturn
2749 * Asserts that a pointer is valid or NULL.
2751 * @param pv The pointer.
2752 * @param rcRet What is to be presented to return.
2754 #define AssertPtrNullReturn(pv, rcRet) AssertMsgReturn(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)), rcRet)
2756 /** @def AssertPtrNullReturnVoid
2757 * Asserts that a pointer is valid or NULL.
2759 * @param pv The pointer.
2761 #define AssertPtrNullReturnVoid(pv) AssertMsgReturnVoid(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)))
2763 /** @def AssertPtrNullBreak
2764 * Asserts that a pointer is valid or NULL.
2766 * @param pv The pointer.
2768 #define AssertPtrNullBreak(pv) AssertMsgBreak(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)))
2770 /** @def AssertPtrNullBreakStmt
2771 * Asserts that a pointer is valid or NULL.
2773 * @param pv The pointer.
2774 * @param stmt Statement to execute before break in case of a failed assertion.
2776 #define AssertPtrNullBreakStmt(pv, stmt) AssertMsgBreakStmt(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)), stmt)
2778 /** @def AssertGCPhys32
2779 * Asserts that the high dword of a physical address is zero
2781 * @param GCPhys The address (RTGCPHYS).
2783 #define AssertGCPhys32(GCPhys) AssertMsg(VALID_PHYS32(GCPhys), ("%RGp\n", (RTGCPHYS)(GCPhys)))
2785 /** @def AssertGCPtr32
2786 * Asserts that the high dword of a physical address is zero
2788 * @param GCPtr The address (RTGCPTR).
2790 #if GC_ARCH_BITS == 32
2791 # define AssertGCPtr32(GCPtr) do { } while (0)
2793 # define AssertGCPtr32(GCPtr) AssertMsg(!((GCPtr) & UINT64_C(0xffffffff00000000)), ("%RGv\n", GCPtr))
2796 /** @def AssertForEach
2797 * Equivalent to Assert for each value of the variable from the starting
2798 * value to the finishing one.
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.
2808 #define AssertForEach(var, vartype, first, end, expr) \
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)); \
2816 #ifdef RT_OS_WINDOWS
2818 /** @def AssertNtStatus
2819 * Asserts that the NT_SUCCESS() returns true for the given NTSTATUS value.
2821 * @param a_rcNt The NTSTATUS to check. Will be evaluated twice and
2822 * subjected to NOREF().
2825 # define AssertNtStatus(a_rcNt) \
2826 do { AssertMsg(NT_SUCCESS(a_rcNt), ("%#x\n", (a_rcNt))); NOREF(a_rcNt); } while (0)
2828 /** @def AssertNtStatusSuccess
2829 * Asserts that the given NTSTATUS value equals STATUS_SUCCESS.
2831 * @param a_rcNt The NTSTATUS to check. Will be evaluated twice and
2832 * subjected to NOREF().
2833 * @sa AssertRCSuccess()
2835 # define AssertNtStatusSuccess(a_rcNt) \
2836 do { AssertMsg((a_rcNt) == STATUS_SUCCESS, ("%#x\n", (a_rcNt))); NOREF(a_rcNt); } while (0)
2838 #endif /* RT_OS_WINDOWS */