VirtualBox

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

Last change on this file since 101603 was 98103, checked in by vboxsync, 2 years ago

Copyright year updates by scm.

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