VirtualBox

source: vbox/trunk/include/iprt/assert.h@ 77807

Last change on this file since 77807 was 76585, checked in by vboxsync, 6 years ago

*: scm --fix-header-guard-endif

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette