VirtualBox

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

Last change on this file since 103446 was 103446, checked in by vboxsync, 3 months ago

iprt/assert.h: Added AssertContinueStmt. [build fix]

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 90.9 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 AssertBreakStmt
534 * Assert that an expression is true and breaks if it isn't.
535 * In RT_STRICT mode it will hit a breakpoint before doing break.
536 *
537 * @param expr Expression which should be true.
538 * @param stmt Statement to execute before break in case of a failed assertion.
539 */
540#ifdef RT_STRICT
541# define AssertBreakStmt(expr, stmt) \
542 if (RT_LIKELY(!!(expr))) \
543 { /* likely */ } \
544 else if (1) \
545 { \
546 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
547 RTAssertPanic(); \
548 stmt; \
549 break; \
550 } else do {} while (0)
551#else
552# define AssertBreakStmt(expr, stmt) \
553 if (RT_LIKELY(!!(expr))) \
554 { /* likely */ } \
555 else if (1) \
556 { \
557 stmt; \
558 break; \
559 } else do {} while (0)
560#endif
561
562/** @def AssertContinue
563 * Assert that an expression is true and continue if it isn't.
564 * In RT_STRICT mode it will hit a breakpoint before continuing.
565 *
566 * @param expr Expression which should be true.
567 */
568#ifdef RT_STRICT
569# define AssertContinue(expr) \
570 if (RT_LIKELY(!!(expr))) \
571 { /* likely */ } \
572 else if (1) \
573 { \
574 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
575 RTAssertPanic(); \
576 continue; \
577 } else do {} while (0)
578#else
579# define AssertContinue(expr) \
580 if (RT_LIKELY(!!(expr))) \
581 { /* likely */ } \
582 else \
583 continue
584#endif
585
586/** @def AssertContinueStmt
587 * Assert that an expression is true and continue if it isn't.
588 * In RT_STRICT mode it will hit a breakpoint before continuing.
589 *
590 * @param expr Expression which should be true.
591 * @param stmt Statement to execute before contine in case of a failed assertion.
592 */
593#ifdef RT_STRICT
594# define AssertContinueStmt(expr, stmt) \
595 if (RT_LIKELY(!!(expr))) \
596 { /* likely */ } \
597 else if (1) \
598 { \
599 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
600 RTAssertPanic(); \
601 stmt; \
602 continue; \
603 } else do {} while (0)
604#else
605# define AssertContinueStmt(expr, stmt) \
606 if (RT_LIKELY(!!(expr))) \
607 { /* likely */ } \
608 else if (1) \
609 { \
610 stmt; \
611 continue; \
612 } else do {} while (0)
613#endif
614
615
616/** @def AssertMsg
617 * Assert that an expression is true. If it's not print message and hit breakpoint.
618 * @param expr Expression which should be true.
619 * @param a printf argument list (in parenthesis).
620 */
621#ifdef RT_STRICT
622# define AssertMsg(expr, a) \
623 do { \
624 if (RT_LIKELY(!!(expr))) \
625 { /* likely */ } \
626 else \
627 { \
628 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
629 RTAssertMsg2Weak a; \
630 RTAssertPanic(); \
631 } \
632 } while (0)
633#else
634# define AssertMsg(expr, a) do { } while (0)
635#endif
636
637/** @def AssertMsgStmt
638 * Assert that an expression is true. If it's not print message and hit
639 * breakpoint and execute the statement.
640 *
641 * @param expr Expression which should be true.
642 * @param a printf argument list (in parenthesis).
643 * @param stmt Statement to execute in case of a failed assertion.
644 *
645 * @remarks The expression and statement will be evaluated in all build types.
646 */
647#ifdef RT_STRICT
648# define AssertMsgStmt(expr, a, stmt) \
649 do { \
650 if (RT_LIKELY(!!(expr))) \
651 { /* likely */ } \
652 else \
653 { \
654 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
655 RTAssertMsg2Weak a; \
656 RTAssertPanic(); \
657 stmt; \
658 } \
659 } while (0)
660#else
661# define AssertMsgStmt(expr, a, stmt) \
662 do { \
663 if (RT_LIKELY(!!(expr))) \
664 { /* likely */ } \
665 else \
666 { \
667 stmt; \
668 } \
669 } while (0)
670#endif
671
672/** @def AssertMsgReturn
673 * Assert that an expression is true and returns if it isn't.
674 * In RT_STRICT mode it will hit a breakpoint before returning.
675 *
676 * @param expr Expression which should be true.
677 * @param a printf argument list (in parenthesis).
678 * @param rc What is to be presented to return.
679 */
680#ifdef RT_STRICT
681# define AssertMsgReturn(expr, a, rc) \
682 do { \
683 if (RT_LIKELY(!!(expr))) \
684 { /* likely */ } \
685 else \
686 { \
687 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
688 RTAssertMsg2Weak a; \
689 RTAssertPanic(); \
690 return (rc); \
691 } \
692 } while (0)
693#else
694# define AssertMsgReturn(expr, a, rc) \
695 do { \
696 if (RT_LIKELY(!!(expr))) \
697 { /* likely */ } \
698 else \
699 return (rc); \
700 } while (0)
701#endif
702
703/** @def AssertMsgReturnStmt
704 * Assert that an expression is true, if it isn't execute the statement and
705 * return.
706 *
707 * In RT_STRICT mode it will hit a breakpoint before returning.
708 *
709 * @param expr Expression which should be true.
710 * @param a printf argument list (in parenthesis).
711 * @param stmt Statement to execute before returning in case of a failed
712 * assertion.
713 * @param rc What is to be presented to return.
714 */
715#ifdef RT_STRICT
716# define AssertMsgReturnStmt(expr, a, stmt, rc) \
717 do { \
718 if (RT_LIKELY(!!(expr))) \
719 { /* likely */ } \
720 else \
721 { \
722 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
723 RTAssertMsg2Weak a; \
724 RTAssertPanic(); \
725 stmt; \
726 return (rc); \
727 } \
728 } while (0)
729#else
730# define AssertMsgReturnStmt(expr, a, stmt, rc) \
731 do { \
732 if (RT_LIKELY(!!(expr))) \
733 { /* likely */ } \
734 else \
735 { \
736 stmt; \
737 return (rc); \
738 } \
739 } while (0)
740#endif
741
742/** @def AssertMsgReturnVoid
743 * Assert that an expression is true and returns if it isn't.
744 * In RT_STRICT mode it will hit a breakpoint before returning.
745 *
746 * @param expr Expression which should be true.
747 * @param a printf argument list (in parenthesis).
748 */
749#ifdef RT_STRICT
750# define AssertMsgReturnVoid(expr, a) \
751 do { \
752 if (RT_LIKELY(!!(expr))) \
753 { /* likely */ } \
754 else \
755 { \
756 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
757 RTAssertMsg2Weak a; \
758 RTAssertPanic(); \
759 return; \
760 } \
761 } while (0)
762#else
763# define AssertMsgReturnVoid(expr, a) \
764 do { \
765 if (RT_LIKELY(!!(expr))) \
766 { /* likely */ } \
767 else \
768 return; \
769 } while (0)
770#endif
771
772/** @def AssertMsgReturnVoidStmt
773 * Assert that an expression is true, if it isn't execute the statement and
774 * return.
775 *
776 * In RT_STRICT mode it will hit a breakpoint before returning.
777 *
778 * @param expr Expression which should be true.
779 * @param a printf argument list (in parenthesis).
780 * @param stmt Statement to execute before return in case of a failed assertion.
781 */
782#ifdef RT_STRICT
783# define AssertMsgReturnVoidStmt(expr, a, stmt) \
784 do { \
785 if (RT_LIKELY(!!(expr))) \
786 { /* likely */ } \
787 else \
788 { \
789 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
790 RTAssertMsg2Weak a; \
791 RTAssertPanic(); \
792 stmt; \
793 return; \
794 } \
795 } while (0)
796#else
797# define AssertMsgReturnVoidStmt(expr, a, stmt) \
798 do { \
799 if (RT_LIKELY(!!(expr))) \
800 { /* likely */ } \
801 else \
802 { \
803 stmt; \
804 return; \
805 } \
806 } while (0)
807#endif
808
809
810/** @def AssertMsgBreak
811 * Assert that an expression is true and breaks if it isn't.
812 * In RT_STRICT mode it will hit a breakpoint before returning.
813 *
814 * @param expr Expression which should be true.
815 * @param a printf argument list (in parenthesis).
816 */
817#ifdef RT_STRICT
818# define AssertMsgBreak(expr, a) \
819 if (RT_LIKELY(!!(expr))) \
820 { /* likely */ } \
821 else if (1) \
822 { \
823 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
824 RTAssertMsg2Weak a; \
825 RTAssertPanic(); \
826 break; \
827 } else \
828 break
829#else
830# define AssertMsgBreak(expr, a) \
831 if (RT_LIKELY(!!(expr))) \
832 { /* likely */ } \
833 else \
834 break
835#endif
836
837/** @def AssertMsgBreakStmt
838 * Assert that an expression is true and breaks if it isn't.
839 * In RT_STRICT mode it will hit a breakpoint before doing break.
840 *
841 * @param expr Expression which should be true.
842 * @param a printf argument list (in parenthesis).
843 * @param stmt Statement to execute before break in case of a failed assertion.
844 */
845#ifdef RT_STRICT
846# define AssertMsgBreakStmt(expr, a, stmt) \
847 if (RT_LIKELY(!!(expr))) \
848 { /* likely */ } \
849 else if (1) \
850 { \
851 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
852 RTAssertMsg2Weak a; \
853 RTAssertPanic(); \
854 stmt; \
855 break; \
856 } else \
857 break
858#else
859# define AssertMsgBreakStmt(expr, a, stmt) \
860 if (RT_LIKELY(!!(expr))) \
861 { /* likely */ } \
862 else if (1) \
863 { \
864 stmt; \
865 break; \
866 } else \
867 break
868#endif
869
870/** @def AssertFailed
871 * An assertion failed, hit breakpoint.
872 */
873#ifdef RT_STRICT
874# define AssertFailed() \
875 do { \
876 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
877 RTAssertPanic(); \
878 } while (0)
879#else
880# define AssertFailed() do { } while (0)
881#endif
882
883/** @def AssertFailedStmt
884 * An assertion failed, hit breakpoint and execute statement.
885 */
886#ifdef RT_STRICT
887# define AssertFailedStmt(stmt) \
888 do { \
889 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
890 RTAssertPanic(); \
891 stmt; \
892 } while (0)
893#else
894# define AssertFailedStmt(stmt) do { stmt; } while (0)
895#endif
896
897/** @def AssertFailedReturn
898 * An assertion failed, hit breakpoint (RT_STRICT mode only) and return.
899 *
900 * @param rc The rc to return.
901 */
902#ifdef RT_STRICT
903# define AssertFailedReturn(rc) \
904 do { \
905 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
906 RTAssertPanic(); \
907 return (rc); \
908 } while (0)
909#else
910# define AssertFailedReturn(rc) \
911 do { \
912 return (rc); \
913 } while (0)
914#endif
915
916/** @def AssertFailedReturnStmt
917 * An assertion failed, hit breakpoint (RT_STRICT mode only), execute a
918 * statement and return a value.
919 *
920 * @param stmt The statement to execute before returning.
921 * @param rc The value to return.
922 */
923#ifdef RT_STRICT
924# define AssertFailedReturnStmt(stmt, rc) \
925 do { \
926 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
927 RTAssertPanic(); \
928 stmt; \
929 return (rc); \
930 } while (0)
931#else
932# define AssertFailedReturnStmt(stmt, rc) \
933 do { \
934 stmt; \
935 return (rc); \
936 } while (0)
937#endif
938
939/** @def AssertFailedReturnVoid
940 * An assertion failed, hit breakpoint (RT_STRICT mode only) and return.
941 */
942#ifdef RT_STRICT
943# define AssertFailedReturnVoid() \
944 do { \
945 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
946 RTAssertPanic(); \
947 return; \
948 } while (0)
949#else
950# define AssertFailedReturnVoid() \
951 do { \
952 return; \
953 } while (0)
954#endif
955
956/** @def AssertFailedReturnVoidStmt
957 * An assertion failed, hit breakpoint (RT_STRICT mode only), execute a
958 * statement and return.
959 *
960 * @param stmt The statement to execute before returning.
961 */
962#ifdef RT_STRICT
963# define AssertFailedReturnVoidStmt(stmt) \
964 do { \
965 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
966 RTAssertPanic(); \
967 stmt; \
968 return; \
969 } while (0)
970#else
971# define AssertFailedReturnVoidStmt(stmt) \
972 do { \
973 stmt; \
974 return; \
975 } while (0)
976#endif
977
978
979/** @def AssertFailedBreak
980 * An assertion failed, hit breakpoint (RT_STRICT mode only) and break.
981 */
982#ifdef RT_STRICT
983# define AssertFailedBreak() \
984 if (1) { \
985 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
986 RTAssertPanic(); \
987 break; \
988 } else \
989 break
990#else
991# define AssertFailedBreak() \
992 if (1) \
993 break; \
994 else \
995 break
996#endif
997
998/** @def AssertFailedBreakStmt
999 * An assertion failed, hit breakpoint (RT_STRICT mode only), execute
1000 * the given statement and break.
1001 *
1002 * @param stmt Statement to execute before break.
1003 */
1004#ifdef RT_STRICT
1005# define AssertFailedBreakStmt(stmt) \
1006 if (1) { \
1007 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1008 RTAssertPanic(); \
1009 stmt; \
1010 break; \
1011 } else \
1012 break
1013#else
1014# define AssertFailedBreakStmt(stmt) \
1015 if (1) { \
1016 stmt; \
1017 break; \
1018 } else \
1019 break
1020#endif
1021
1022
1023/** @def AssertMsgFailed
1024 * An assertion failed print a message and a hit breakpoint.
1025 *
1026 * @param a printf argument list (in parenthesis).
1027 */
1028#ifdef RT_STRICT
1029# define AssertMsgFailed(a) \
1030 do { \
1031 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1032 RTAssertMsg2Weak a; \
1033 RTAssertPanic(); \
1034 } while (0)
1035#else
1036# define AssertMsgFailed(a) do { } while (0)
1037#endif
1038
1039/** @def AssertMsgFailedReturn
1040 * An assertion failed, hit breakpoint with message (RT_STRICT mode only) and return.
1041 *
1042 * @param a printf argument list (in parenthesis).
1043 * @param rc What is to be presented to return.
1044 */
1045#ifdef RT_STRICT
1046# define AssertMsgFailedReturn(a, rc) \
1047 do { \
1048 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1049 RTAssertMsg2Weak a; \
1050 RTAssertPanic(); \
1051 return (rc); \
1052 } while (0)
1053#else
1054# define AssertMsgFailedReturn(a, rc) \
1055 do { \
1056 return (rc); \
1057 } while (0)
1058#endif
1059
1060/** @def AssertMsgFailedReturnVoid
1061 * An assertion failed, hit breakpoint with message (RT_STRICT mode only) and return.
1062 *
1063 * @param a printf argument list (in parenthesis).
1064 */
1065#ifdef RT_STRICT
1066# define AssertMsgFailedReturnVoid(a) \
1067 do { \
1068 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1069 RTAssertMsg2Weak a; \
1070 RTAssertPanic(); \
1071 return; \
1072 } while (0)
1073#else
1074# define AssertMsgFailedReturnVoid(a) \
1075 do { \
1076 return; \
1077 } while (0)
1078#endif
1079
1080
1081/** @def AssertMsgFailedBreak
1082 * An assertion failed, hit breakpoint with message (RT_STRICT mode only) and break.
1083 *
1084 * @param a printf argument list (in parenthesis).
1085 */
1086#ifdef RT_STRICT
1087# define AssertMsgFailedBreak(a) \
1088 if (1) { \
1089 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1090 RTAssertMsg2Weak a; \
1091 RTAssertPanic(); \
1092 break; \
1093 } else \
1094 break
1095#else
1096# define AssertMsgFailedBreak(a) \
1097 if (1) \
1098 break; \
1099 else \
1100 break
1101#endif
1102
1103/** @def AssertMsgFailedBreakStmt
1104 * An assertion failed, hit breakpoint (RT_STRICT mode only), execute
1105 * the given statement and break.
1106 *
1107 * @param a printf argument list (in parenthesis).
1108 * @param stmt Statement to execute before break.
1109 */
1110#ifdef RT_STRICT
1111# define AssertMsgFailedBreakStmt(a, stmt) \
1112 if (1) { \
1113 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1114 RTAssertMsg2Weak a; \
1115 RTAssertPanic(); \
1116 stmt; \
1117 break; \
1118 } else \
1119 break
1120#else
1121# define AssertMsgFailedBreakStmt(a, stmt) \
1122 if (1) { \
1123 stmt; \
1124 break; \
1125 } else \
1126 break
1127#endif
1128
1129/** @} */
1130
1131
1132
1133/** @name Release Log Assertions
1134 *
1135 * These assertions will work like normal strict assertion when RT_STRICT is
1136 * defined and LogRel statements when RT_STRICT is undefined. Typically used for
1137 * things which shouldn't go wrong, but when it does you'd like to know one way
1138 * or the other.
1139 *
1140 * @{
1141 */
1142
1143/** @def RTAssertLogRelMsg1
1144 * RTAssertMsg1Weak (strict builds) / LogRel wrapper (non-strict).
1145 */
1146#ifdef RT_STRICT
1147# define RTAssertLogRelMsg1(pszExpr, iLine, pszFile, pszFunction) \
1148 RTAssertMsg1Weak(pszExpr, iLine, pszFile, pszFunction)
1149#else
1150# define RTAssertLogRelMsg1(pszExpr, iLine, pszFile, pszFunction) \
1151 LogRel(("AssertLogRel %s(%d) %s: %s\n",\
1152 (pszFile), (iLine), (pszFunction), (pszExpr) ))
1153#endif
1154
1155/** @def RTAssertLogRelMsg2
1156 * RTAssertMsg2Weak (strict builds) / LogRel wrapper (non-strict).
1157 */
1158#ifdef RT_STRICT
1159# define RTAssertLogRelMsg2(a) RTAssertMsg2Weak a
1160#else
1161# define RTAssertLogRelMsg2(a) LogRel(a)
1162#endif
1163
1164/** @def AssertLogRel
1165 * Assert that an expression is true.
1166 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1167 *
1168 * @param expr Expression which should be true.
1169 */
1170#define AssertLogRel(expr) \
1171 do { \
1172 if (RT_LIKELY(!!(expr))) \
1173 { /* likely */ } \
1174 else \
1175 { \
1176 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1177 RTAssertPanic(); \
1178 } \
1179 } while (0)
1180
1181/** @def AssertLogRelReturn
1182 * Assert that an expression is true, return \a rc if it isn't.
1183 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1184 *
1185 * @param expr Expression which should be true.
1186 * @param rc What is to be presented to return.
1187 */
1188#define AssertLogRelReturn(expr, rc) \
1189 do { \
1190 if (RT_LIKELY(!!(expr))) \
1191 { /* likely */ } \
1192 else \
1193 { \
1194 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1195 RTAssertPanic(); \
1196 return (rc); \
1197 } \
1198 } while (0)
1199
1200/** @def AssertLogRelReturnVoid
1201 * Assert that an expression is true, return void if it isn't.
1202 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1203 *
1204 * @param expr Expression which should be true.
1205 */
1206#define AssertLogRelReturnVoid(expr) \
1207 do { \
1208 if (RT_LIKELY(!!(expr))) \
1209 { /* likely */ } \
1210 else \
1211 { \
1212 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1213 RTAssertPanic(); \
1214 return; \
1215 } \
1216 } while (0)
1217
1218/** @def AssertLogRelBreak
1219 * Assert that an expression is true, break if it isn't.
1220 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1221 *
1222 * @param expr Expression which should be true.
1223 */
1224#define AssertLogRelBreak(expr) \
1225 if (RT_LIKELY(!!(expr))) \
1226 { /* likely */ } \
1227 else if (1) \
1228 { \
1229 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1230 RTAssertPanic(); \
1231 break; \
1232 } \
1233 else \
1234 break
1235
1236/** @def AssertLogRelBreakStmt
1237 * Assert that an expression is true, execute \a stmt and break if it isn't.
1238 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1239 *
1240 * @param expr Expression which should be true.
1241 * @param stmt Statement to execute before break in case of a failed assertion.
1242 */
1243#define AssertLogRelBreakStmt(expr, stmt) \
1244 if (RT_LIKELY(!!(expr))) \
1245 { /* likely */ } \
1246 else if (1) \
1247 { \
1248 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1249 RTAssertPanic(); \
1250 stmt; \
1251 break; \
1252 } else \
1253 break
1254
1255/** @def AssertLogRelStmt
1256 * Assert that an expression is true, return \a rc if it isn't.
1257 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1258 *
1259 * @param expr Expression which should be true.
1260 * @param stmt Statement to execute in case of a failed assertion.
1261 */
1262#define AssertLogRelStmt(expr, stmt) \
1263 do { \
1264 if (RT_LIKELY(!!(expr))) \
1265 { /* likely */ } \
1266 else \
1267 { \
1268 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1269 RTAssertPanic(); \
1270 stmt; \
1271 } \
1272 } while (0)
1273
1274/** @def AssertLogRelMsg
1275 * Assert that an expression is true.
1276 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1277 *
1278 * @param expr Expression which should be true.
1279 * @param a printf argument list (in parenthesis).
1280 */
1281#define AssertLogRelMsg(expr, a) \
1282 do { \
1283 if (RT_LIKELY(!!(expr))) \
1284 { /* likely */ } \
1285 else\
1286 { \
1287 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1288 RTAssertLogRelMsg2(a); \
1289 RTAssertPanic(); \
1290 } \
1291 } while (0)
1292
1293/** @def AssertLogRelMsgStmt
1294 * Assert that an expression is true, execute \a stmt and break if it isn't
1295 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1296 *
1297 * @param expr Expression which should be true.
1298 * @param a printf argument list (in parenthesis).
1299 * @param stmt Statement to execute in case of a failed assertion.
1300 */
1301#define AssertLogRelMsgStmt(expr, a, stmt) \
1302 do { \
1303 if (RT_LIKELY(!!(expr))) \
1304 { /* likely */ } \
1305 else\
1306 { \
1307 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1308 RTAssertLogRelMsg2(a); \
1309 RTAssertPanic(); \
1310 stmt; \
1311 } \
1312 } while (0)
1313
1314/** @def AssertLogRelMsgReturn
1315 * Assert that an expression is true, return \a rc if it isn't.
1316 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1317 *
1318 * @param expr Expression which should be true.
1319 * @param a printf argument list (in parenthesis).
1320 * @param rc What is to be presented to return.
1321 */
1322#define AssertLogRelMsgReturn(expr, a, rc) \
1323 do { \
1324 if (RT_LIKELY(!!(expr))) \
1325 { /* likely */ } \
1326 else\
1327 { \
1328 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1329 RTAssertLogRelMsg2(a); \
1330 RTAssertPanic(); \
1331 return (rc); \
1332 } \
1333 } while (0)
1334
1335/** @def AssertLogRelMsgReturnStmt
1336 * Assert that an expression is true, execute @a stmt and return @a rcRet if it
1337 * isn't.
1338 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1339 *
1340 * @param expr Expression which should be true.
1341 * @param a printf argument list (in parenthesis).
1342 * @param stmt Statement to execute before returning in case of a failed
1343 * assertion.
1344 * @param rcRet What is to be presented to return.
1345 */
1346#define AssertLogRelMsgReturnStmt(expr, a, stmt, rcRet) \
1347 do { \
1348 if (RT_LIKELY(!!(expr))) \
1349 { /* likely */ } \
1350 else\
1351 { \
1352 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1353 RTAssertLogRelMsg2(a); \
1354 RTAssertPanic(); \
1355 stmt; \
1356 return (rcRet); \
1357 } \
1358 } while (0)
1359
1360/** @def AssertLogRelMsgReturnVoid
1361 * Assert that an expression is true, return (void) if it isn't.
1362 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1363 *
1364 * @param expr Expression which should be true.
1365 * @param a printf argument list (in parenthesis).
1366 */
1367#define AssertLogRelMsgReturnVoid(expr, a) \
1368 do { \
1369 if (RT_LIKELY(!!(expr))) \
1370 { /* likely */ } \
1371 else\
1372 { \
1373 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1374 RTAssertLogRelMsg2(a); \
1375 RTAssertPanic(); \
1376 return; \
1377 } \
1378 } while (0)
1379
1380/** @def AssertLogRelMsgBreak
1381 * Assert that an expression is true, break if it isn't.
1382 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1383 *
1384 * @param expr Expression which should be true.
1385 * @param a printf argument list (in parenthesis).
1386 */
1387#define AssertLogRelMsgBreak(expr, a) \
1388 if (RT_LIKELY(!!(expr))) \
1389 { /* likely */ } \
1390 else if (1) \
1391 { \
1392 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1393 RTAssertLogRelMsg2(a); \
1394 RTAssertPanic(); \
1395 break; \
1396 } \
1397 else \
1398 break
1399
1400/** @def AssertLogRelMsgBreakStmt
1401 * Assert that an expression is true, execute \a stmt and break if it isn't.
1402 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1403 *
1404 * @param expr Expression which should be true.
1405 * @param a printf argument list (in parenthesis).
1406 * @param stmt Statement to execute before break in case of a failed assertion.
1407 */
1408#define AssertLogRelMsgBreakStmt(expr, a, stmt) \
1409 if (RT_LIKELY(!!(expr))) \
1410 { /* likely */ } \
1411 else if (1) \
1412 { \
1413 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1414 RTAssertLogRelMsg2(a); \
1415 RTAssertPanic(); \
1416 stmt; \
1417 break; \
1418 } else \
1419 break
1420
1421/** @def AssertLogRelFailed
1422 * An assertion failed.
1423 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1424 */
1425#define AssertLogRelFailed() \
1426 do { \
1427 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1428 RTAssertPanic(); \
1429 } while (0)
1430
1431/** @def AssertLogRelFailedReturn
1432 * An assertion failed.
1433 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1434 *
1435 * @param rc What is to be presented to return.
1436 */
1437#define AssertLogRelFailedReturn(rc) \
1438 do { \
1439 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1440 RTAssertPanic(); \
1441 return (rc); \
1442 } while (0)
1443
1444/** @def AssertLogRelFailedReturnVoid
1445 * An assertion failed, hit a breakpoint and return.
1446 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1447 */
1448#define AssertLogRelFailedReturnVoid() \
1449 do { \
1450 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1451 RTAssertPanic(); \
1452 return; \
1453 } while (0)
1454
1455/** @def AssertLogRelFailedBreak
1456 * An assertion failed, break.
1457 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1458 */
1459#define AssertLogRelFailedBreak() \
1460 if (1) \
1461 { \
1462 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1463 RTAssertPanic(); \
1464 break; \
1465 } else \
1466 break
1467
1468/** @def AssertLogRelFailedBreakStmt
1469 * An assertion failed, execute \a stmt and break.
1470 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1471 *
1472 * @param stmt Statement to execute before break.
1473 */
1474#define AssertLogRelFailedBreakStmt(stmt) \
1475 if (1) \
1476 { \
1477 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1478 RTAssertPanic(); \
1479 stmt; \
1480 break; \
1481 } else \
1482 break
1483
1484/** @def AssertLogRelMsgFailed
1485 * An assertion failed.
1486 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1487 *
1488 * @param a printf argument list (in parenthesis).
1489 */
1490#define AssertLogRelMsgFailed(a) \
1491 do { \
1492 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1493 RTAssertLogRelMsg2(a); \
1494 RTAssertPanic(); \
1495 } while (0)
1496
1497/** @def AssertLogRelMsgFailedStmt
1498 * An assertion failed, execute @a stmt.
1499 *
1500 * Strict builds will hit a breakpoint, non-strict will only do LogRel. The
1501 * statement will be executed in regardless of build type.
1502 *
1503 * @param a printf argument list (in parenthesis).
1504 * @param stmt Statement to execute after raising/logging the assertion.
1505 */
1506#define AssertLogRelMsgFailedStmt(a, stmt) \
1507 do { \
1508 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1509 RTAssertLogRelMsg2(a); \
1510 RTAssertPanic(); \
1511 stmt; \
1512 } while (0)
1513
1514/** @def AssertLogRelMsgFailedReturn
1515 * An assertion failed, return \a rc.
1516 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1517 *
1518 * @param a printf argument list (in parenthesis).
1519 * @param rc What is to be presented to return.
1520 */
1521#define AssertLogRelMsgFailedReturn(a, rc) \
1522 do { \
1523 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1524 RTAssertLogRelMsg2(a); \
1525 RTAssertPanic(); \
1526 return (rc); \
1527 } while (0)
1528
1529/** @def AssertLogRelMsgFailedReturnStmt
1530 * An assertion failed, execute @a stmt and return @a rc.
1531 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1532 *
1533 * @param a printf argument list (in parenthesis).
1534 * @param stmt Statement to execute before returning in case of a failed
1535 * assertion.
1536 * @param rc What is to be presented to return.
1537 */
1538#define AssertLogRelMsgFailedReturnStmt(a, stmt, rc) \
1539 do { \
1540 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1541 RTAssertLogRelMsg2(a); \
1542 RTAssertPanic(); \
1543 stmt; \
1544 return (rc); \
1545 } while (0)
1546
1547/** @def AssertLogRelMsgFailedReturnVoid
1548 * An assertion failed, return void.
1549 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1550 *
1551 * @param a printf argument list (in parenthesis).
1552 */
1553#define AssertLogRelMsgFailedReturnVoid(a) \
1554 do { \
1555 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1556 RTAssertLogRelMsg2(a); \
1557 RTAssertPanic(); \
1558 return; \
1559 } while (0)
1560
1561/** @def AssertLogRelMsgFailedReturnVoidStmt
1562 * An assertion failed, execute @a stmt and return void.
1563 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1564 *
1565 * @param a printf argument list (in parenthesis).
1566 * @param stmt Statement to execute before returning in case of a failed
1567 * assertion.
1568 */
1569#define AssertLogRelMsgFailedReturnVoidStmt(a, stmt) \
1570 do { \
1571 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1572 RTAssertLogRelMsg2(a); \
1573 RTAssertPanic(); \
1574 stmt; \
1575 return; \
1576 } while (0)
1577
1578/** @def AssertLogRelMsgFailedBreak
1579 * An assertion failed, break.
1580 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1581 *
1582 * @param a printf argument list (in parenthesis).
1583 */
1584#define AssertLogRelMsgFailedBreak(a) \
1585 if (1)\
1586 { \
1587 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1588 RTAssertLogRelMsg2(a); \
1589 RTAssertPanic(); \
1590 break; \
1591 } else \
1592 break
1593
1594/** @def AssertLogRelMsgFailedBreakStmt
1595 * An assertion failed, execute \a stmt and break.
1596 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1597 *
1598 * @param a printf argument list (in parenthesis).
1599 * @param stmt Statement to execute before break.
1600 */
1601#define AssertLogRelMsgFailedBreakStmt(a, stmt) \
1602 if (1) \
1603 { \
1604 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1605 RTAssertLogRelMsg2(a); \
1606 RTAssertPanic(); \
1607 stmt; \
1608 break; \
1609 } else \
1610 break
1611
1612/** @} */
1613
1614
1615
1616/** @name Release Assertions
1617 *
1618 * These assertions are always enabled.
1619 * @{
1620 */
1621
1622/** @def RTAssertReleasePanic()
1623 * Invokes RTAssertShouldPanic and RTAssertDoPanic.
1624 *
1625 * It might seem odd that RTAssertShouldPanic is necessary when its result isn't
1626 * checked, but it's done since RTAssertShouldPanic is overrideable and might be
1627 * used to bail out before taking down the system (the VMMR0 case).
1628 */
1629#if defined(RT_STRICT) || !defined(RTASSERT_NO_RELEASE_ASSERTIONS)
1630# define RTAssertReleasePanic() do { RTAssertShouldPanic(); RTAssertDoPanic(); } while (0)
1631#else
1632# define RTAssertReleasePanic() do { } while (0)
1633#endif
1634
1635
1636/** @def AssertRelease
1637 * Assert that an expression is true. If it's not hit a breakpoint.
1638 *
1639 * @param expr Expression which should be true.
1640 */
1641#if defined(RT_STRICT) || !defined(RTASSERT_NO_RELEASE_ASSERTIONS)
1642# define AssertRelease(expr) \
1643 do { \
1644 if (RT_LIKELY(!!(expr))) \
1645 { /* likely */ } \
1646 else \
1647 { \
1648 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1649 RTAssertReleasePanic(); \
1650 } \
1651 } while (0)
1652#else
1653# define AssertRelease(expr) do { } while (0)
1654#endif
1655
1656
1657/** @def AssertReleaseReturn
1658 * Assert that an expression is true, hit a breakpoint and return if it isn't.
1659 *
1660 * @param expr Expression which should be true.
1661 * @param rc What is to be presented to return.
1662 */
1663#if defined(RT_STRICT) || !defined(RTASSERT_NO_RELEASE_ASSERTIONS)
1664# define AssertReleaseReturn(expr, rc) \
1665 do { \
1666 if (RT_LIKELY(!!(expr))) \
1667 { /* likely */ } \
1668 else \
1669 { \
1670 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1671 RTAssertReleasePanic(); \
1672 return (rc); \
1673 } \
1674 } while (0)
1675#else
1676# define AssertReleaseReturn(expr, rc) \
1677 do { \
1678 if (RT_LIKELY(!!(expr))) \
1679 { /* likely */ } \
1680 else \
1681 return (rc); \
1682 } while (0)
1683#endif
1684
1685/** @def AssertReleaseReturnVoid
1686 * Assert that an expression is true, hit a breakpoint and return if it isn't.
1687 *
1688 * @param expr Expression which should be true.
1689 */
1690#if defined(RT_STRICT) || !defined(RTASSERT_NO_RELEASE_ASSERTIONS)
1691# define AssertReleaseReturnVoid(expr) \
1692 do { \
1693 if (RT_LIKELY(!!(expr))) \
1694 { /* likely */ } \
1695 else \
1696 { \
1697 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1698 RTAssertReleasePanic(); \
1699 return; \
1700 } \
1701 } while (0)
1702#else
1703# define AssertReleaseReturnVoid(expr) \
1704 do { \
1705 if (RT_LIKELY(!!(expr))) \
1706 { /* likely */ } \
1707 else \
1708 return; \
1709 } while (0)
1710#endif
1711
1712
1713/** @def AssertReleaseBreak
1714 * Assert that an expression is true, hit a breakpoint and break if it isn't.
1715 *
1716 * @param expr Expression which should be true.
1717 */
1718#if defined(RT_STRICT) || !defined(RTASSERT_NO_RELEASE_ASSERTIONS)
1719# define AssertReleaseBreak(expr) \
1720 if (RT_LIKELY(!!(expr))) \
1721 { /* likely */ } \
1722 else if (1) \
1723 { \
1724 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1725 RTAssertReleasePanic(); \
1726 break; \
1727 } else \
1728 break
1729#else
1730# define AssertReleaseBreak(expr) \
1731 if (RT_LIKELY(!!(expr))) \
1732 { /* likely */ } \
1733 else \
1734 break
1735#endif
1736
1737/** @def AssertReleaseBreakStmt
1738 * Assert that an expression is true, hit a breakpoint and break if it isn't.
1739 *
1740 * @param expr Expression which should be true.
1741 * @param stmt Statement to execute before break in case of a failed assertion.
1742 */
1743#if defined(RT_STRICT) || !defined(RTASSERT_NO_RELEASE_ASSERTIONS)
1744# define AssertReleaseBreakStmt(expr, stmt) \
1745 if (RT_LIKELY(!!(expr))) \
1746 { /* likely */ } \
1747 else if (1) \
1748 { \
1749 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1750 RTAssertReleasePanic(); \
1751 stmt; \
1752 break; \
1753 } else \
1754 break
1755#else
1756# define AssertReleaseBreakStmt(expr, stmt) \
1757 if (RT_LIKELY(!!(expr))) \
1758 { /* likely */ } \
1759 else if (1) \
1760 { \
1761 stmt; \
1762 break; \
1763 } else \
1764 break
1765#endif
1766
1767
1768/** @def AssertReleaseMsg
1769 * Assert that an expression is true, print the message and hit a breakpoint if it isn't.
1770 *
1771 * @param expr Expression which should be true.
1772 * @param a printf argument list (in parenthesis).
1773 */
1774#if defined(RT_STRICT) || !defined(RTASSERT_NO_RELEASE_ASSERTIONS)
1775# define AssertReleaseMsg(expr, a) \
1776 do { \
1777 if (RT_LIKELY(!!(expr))) \
1778 { /* likely */ } \
1779 else \
1780 { \
1781 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1782 RTAssertMsg2Weak a; \
1783 RTAssertReleasePanic(); \
1784 } \
1785 } while (0)
1786#else
1787# define AssertReleaseMsg(expr, a) do { } while (0)
1788#endif
1789
1790/** @def AssertReleaseMsgReturn
1791 * Assert that an expression is true, print the message and hit a breakpoint and return if it isn't.
1792 *
1793 * @param expr Expression which should be true.
1794 * @param a printf argument list (in parenthesis).
1795 * @param rc What is to be presented to return.
1796 */
1797#if defined(RT_STRICT) || !defined(RTASSERT_NO_RELEASE_ASSERTIONS)
1798# define AssertReleaseMsgReturn(expr, a, rc) \
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 (rc); \
1808 } \
1809 } while (0)
1810#else
1811# define AssertReleaseMsgReturn(expr, a, rc) \
1812 do { \
1813 if (RT_LIKELY(!!(expr))) \
1814 { /* likely */ } \
1815 else \
1816 return (rc); \
1817 } while (0)
1818#endif
1819
1820/** @def AssertReleaseMsgReturnVoid
1821 * Assert that an expression is true, print the message and hit a breakpoint and return if it isn't.
1822 *
1823 * @param expr Expression which should be true.
1824 * @param a printf argument list (in parenthesis).
1825 */
1826#if defined(RT_STRICT) || !defined(RTASSERT_NO_RELEASE_ASSERTIONS)
1827# define AssertReleaseMsgReturnVoid(expr, a) \
1828 do { \
1829 if (RT_LIKELY(!!(expr))) \
1830 { /* likely */ } \
1831 else \
1832 { \
1833 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1834 RTAssertMsg2Weak a; \
1835 RTAssertReleasePanic(); \
1836 return; \
1837 } \
1838 } while (0)
1839#else
1840# define AssertReleaseMsgReturnVoid(expr, a) \
1841 do { \
1842 if (RT_LIKELY(!!(expr))) \
1843 { /* likely */ } \
1844 else \
1845 return; \
1846 } while (0)
1847#endif
1848
1849
1850/** @def AssertReleaseMsgBreak
1851 * Assert that an expression is true, print the message and hit a breakpoint and break if it isn't.
1852 *
1853 * @param expr Expression which should be true.
1854 * @param a printf argument list (in parenthesis).
1855 */
1856#if defined(RT_STRICT) || !defined(RTASSERT_NO_RELEASE_ASSERTIONS)
1857# define AssertReleaseMsgBreak(expr, a) \
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 break; \
1866 } else \
1867 break
1868#else
1869# define AssertReleaseMsgBreak(expr, a) \
1870 if (RT_LIKELY(!!(expr))) \
1871 { /* likely */ } \
1872 else if (1) \
1873 break; \
1874 else \
1875 break
1876#endif
1877
1878/** @def AssertReleaseMsgBreakStmt
1879 * Assert that an expression is true, print the message and hit a breakpoint and break if it isn't.
1880 *
1881 * @param expr Expression which should be true.
1882 * @param a printf argument list (in parenthesis).
1883 * @param stmt Statement to execute before break in case of a failed assertion.
1884 */
1885#if defined(RT_STRICT) || !defined(RTASSERT_NO_RELEASE_ASSERTIONS)
1886# define AssertReleaseMsgBreakStmt(expr, a, stmt) \
1887 if (RT_LIKELY(!!(expr))) \
1888 { /* likely */ } \
1889 else if (1) \
1890 { \
1891 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1892 RTAssertMsg2Weak a; \
1893 RTAssertReleasePanic(); \
1894 stmt; \
1895 break; \
1896 } else \
1897 break
1898#else
1899# define AssertReleaseMsgBreakStmt(expr, a, stmt) \
1900 if (RT_LIKELY(!!(expr))) \
1901 { /* likely */ } \
1902 else if (1) \
1903 { \
1904 stmt; \
1905 break; \
1906 } else \
1907 break
1908#endif
1909
1910
1911/** @def AssertReleaseFailed
1912 * An assertion failed, hit a breakpoint.
1913 */
1914#if defined(RT_STRICT) || !defined(RTASSERT_NO_RELEASE_ASSERTIONS)
1915# define AssertReleaseFailed() \
1916 do { \
1917 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1918 RTAssertReleasePanic(); \
1919 } while (0)
1920#else
1921# define AssertReleaseFailed() do { } while (0)
1922#endif
1923
1924/** @def AssertReleaseFailedReturn
1925 * An assertion failed, hit a breakpoint and return.
1926 *
1927 * @param rc What is to be presented to return.
1928 */
1929#if defined(RT_STRICT) || !defined(RTASSERT_NO_RELEASE_ASSERTIONS)
1930# define AssertReleaseFailedReturn(rc) \
1931 do { \
1932 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1933 RTAssertReleasePanic(); \
1934 return (rc); \
1935 } while (0)
1936#else
1937# define AssertReleaseFailedReturn(rc) \
1938 do { return (rc); } while (0)
1939#endif
1940
1941/** @def AssertReleaseFailedReturnVoid
1942 * An assertion failed, hit a breakpoint and return.
1943 */
1944#if defined(RT_STRICT) || !defined(RTASSERT_NO_RELEASE_ASSERTIONS)
1945# define AssertReleaseFailedReturnVoid() \
1946 do { \
1947 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1948 RTAssertReleasePanic(); \
1949 return; \
1950 } while (0)
1951#else
1952# define AssertReleaseFailedReturnVoid() \
1953 do { return; } while (0)
1954#endif
1955
1956/** @def AssertReleaseFailedBreak
1957 * An assertion failed, hit a breakpoint and break.
1958 */
1959#if defined(RT_STRICT) || !defined(RTASSERT_NO_RELEASE_ASSERTIONS)
1960# define AssertReleaseFailedBreak() \
1961 if (1) { \
1962 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1963 RTAssertReleasePanic(); \
1964 break; \
1965 } else \
1966 break
1967#else
1968# define AssertReleaseFailedBreak() \
1969 if (1) \
1970 break; \
1971 else \
1972 break
1973#endif
1974
1975/** @def AssertReleaseFailedBreakStmt
1976 * An assertion failed, hit a breakpoint and break.
1977 *
1978 * @param stmt Statement to execute before break.
1979 */
1980#if defined(RT_STRICT) || !defined(RTASSERT_NO_RELEASE_ASSERTIONS)
1981# define AssertReleaseFailedBreakStmt(stmt) \
1982 if (1) { \
1983 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1984 RTAssertReleasePanic(); \
1985 stmt; \
1986 break; \
1987 } else \
1988 break
1989#else
1990# define AssertReleaseFailedBreakStmt(stmt) \
1991 if (1) { \
1992 stmt; \
1993 break; \
1994 } else \
1995 break
1996#endif
1997
1998/** @def AssertReleaseMsgFailed
1999 * An assertion failed, print a message and hit a breakpoint.
2000 *
2001 * @param a printf argument list (in parenthesis).
2002 */
2003#if defined(RT_STRICT) || !defined(RTASSERT_NO_RELEASE_ASSERTIONS)
2004# define AssertReleaseMsgFailed(a) \
2005 do { \
2006 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
2007 RTAssertMsg2Weak a; \
2008 RTAssertReleasePanic(); \
2009 } while (0)
2010#else
2011# define AssertReleaseMsgFailed(a) do { } while (0)
2012#endif
2013
2014/** @def AssertReleaseMsgFailedReturn
2015 * An assertion failed, print a message, hit a breakpoint and return.
2016 *
2017 * @param a printf argument list (in parenthesis).
2018 * @param rc What is to be presented to return.
2019 */
2020#if defined(RT_STRICT) || !defined(RTASSERT_NO_RELEASE_ASSERTIONS)
2021# define AssertReleaseMsgFailedReturn(a, rc) \
2022 do { \
2023 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
2024 RTAssertMsg2Weak a; \
2025 RTAssertReleasePanic(); \
2026 return (rc); \
2027 } while (0)
2028#else
2029# define AssertReleaseMsgFailedReturn(a, rc) \
2030 do { return (rc); } while (0)
2031#endif
2032
2033/** @def AssertReleaseMsgFailedReturnVoid
2034 * An assertion failed, print a message, hit a breakpoint and return.
2035 *
2036 * @param a printf argument list (in parenthesis).
2037 */
2038#if defined(RT_STRICT) || !defined(RTASSERT_NO_RELEASE_ASSERTIONS)
2039# define AssertReleaseMsgFailedReturnVoid(a) \
2040 do { \
2041 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
2042 RTAssertMsg2Weak a; \
2043 RTAssertReleasePanic(); \
2044 return; \
2045 } while (0)
2046#else
2047# define AssertReleaseMsgFailedReturnVoid(a) \
2048 do { return; } while (0)
2049#endif
2050
2051
2052/** @def AssertReleaseMsgFailedBreak
2053 * An assertion failed, print a message, hit a breakpoint and break.
2054 *
2055 * @param a printf argument list (in parenthesis).
2056 */
2057#if defined(RT_STRICT) || !defined(RTASSERT_NO_RELEASE_ASSERTIONS)
2058# define AssertReleaseMsgFailedBreak(a) \
2059 if (1) { \
2060 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
2061 RTAssertMsg2Weak a; \
2062 RTAssertReleasePanic(); \
2063 break; \
2064 } else \
2065 break
2066#else
2067# define AssertReleaseMsgFailedBreak(a) \
2068 if (1) \
2069 break; \
2070 else \
2071 break
2072#endif
2073
2074/** @def AssertReleaseMsgFailedBreakStmt
2075 * An assertion failed, print a message, hit a breakpoint and break.
2076 *
2077 * @param a printf argument list (in parenthesis).
2078 * @param stmt Statement to execute before break.
2079 */
2080#if defined(RT_STRICT) || !defined(RTASSERT_NO_RELEASE_ASSERTIONS)
2081# define AssertReleaseMsgFailedBreakStmt(a, stmt) \
2082 if (1) { \
2083 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
2084 RTAssertMsg2Weak a; \
2085 RTAssertReleasePanic(); \
2086 stmt; \
2087 break; \
2088 } else \
2089 break
2090#else
2091# define AssertReleaseMsgFailedBreakStmt(a, stmt) \
2092 if (1) { \
2093 stmt; \
2094 break; \
2095 } else \
2096 break
2097#endif
2098/** @} */
2099
2100
2101
2102/** @name Fatal Assertions
2103 * These are similar to release assertions except that you cannot ignore them in
2104 * any way, they will loop for ever if RTAssertDoPanic returns.
2105 *
2106 * @{
2107 */
2108
2109/** @def AssertFatal
2110 * Assert that an expression is true. If it's not hit a breakpoint (for ever).
2111 *
2112 * @param expr Expression which should be true.
2113 */
2114#define AssertFatal(expr) \
2115 do { \
2116 if (RT_LIKELY(!!(expr))) \
2117 { /* likely */ } \
2118 else \
2119 for (;;) \
2120 { \
2121 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
2122 RTAssertReleasePanic(); \
2123 } \
2124 } while (0)
2125
2126/** @def AssertFatalMsg
2127 * Assert that an expression is true, print the message and hit a breakpoint (for ever) if it isn't.
2128 *
2129 * @param expr Expression which should be true.
2130 * @param a printf argument list (in parenthesis).
2131 */
2132#define AssertFatalMsg(expr, a) \
2133 do { \
2134 if (RT_LIKELY(!!(expr))) \
2135 { /* likely */ } \
2136 else \
2137 for (;;) \
2138 { \
2139 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
2140 RTAssertMsg2Weak a; \
2141 RTAssertReleasePanic(); \
2142 } \
2143 } while (0)
2144
2145/** @def AssertFatalFailed
2146 * An assertion failed, hit a breakpoint (for ever).
2147 */
2148#define AssertFatalFailed() \
2149 do { \
2150 for (;;) \
2151 { \
2152 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
2153 RTAssertReleasePanic(); \
2154 } \
2155 } while (0)
2156
2157/** @def AssertFatalMsgFailed
2158 * An assertion failed, print a message and hit a breakpoint (for ever).
2159 *
2160 * @param a printf argument list (in parenthesis).
2161 */
2162#define AssertFatalMsgFailed(a) \
2163 do { \
2164 for (;;) \
2165 { \
2166 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
2167 RTAssertMsg2Weak a; \
2168 RTAssertReleasePanic(); \
2169 } \
2170 } while (0)
2171
2172/** @} */
2173
2174
2175
2176/** @name Convenience Assertions Macros
2177 * @{
2178 */
2179
2180/** @def AssertRC
2181 * Asserts a iprt status code successful.
2182 *
2183 * On failure it will print info about the rc and hit a breakpoint.
2184 *
2185 * @param rc iprt status code.
2186 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2187 */
2188#define AssertRC(rc) AssertMsgRC(rc, ("%Rra\n", (rc)))
2189
2190/** @def AssertRCStmt
2191 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and execute
2192 * @a stmt if it isn't.
2193 *
2194 * @param rc iprt status code.
2195 * @param stmt Statement to execute before returning in case of a failed
2196 * assertion.
2197 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2198 */
2199#define AssertRCStmt(rc, stmt) AssertMsgRCStmt(rc, ("%Rra\n", (rc)), stmt)
2200
2201/** @def AssertRCReturn
2202 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return if it isn't.
2203 *
2204 * @param rc iprt status code.
2205 * @param rcRet What is to be presented to return.
2206 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2207 */
2208#define AssertRCReturn(rc, rcRet) AssertMsgRCReturn(rc, ("%Rra\n", (rc)), rcRet)
2209
2210/** @def AssertRCReturnStmt
2211 * Asserts a iprt status code successful, bitch (RT_STRICT mode only), execute
2212 * @a stmt and returns @a rcRet if it isn't.
2213 *
2214 * @param rc iprt status code.
2215 * @param stmt Statement to execute before returning in case of a failed
2216 * assertion.
2217 * @param rcRet What is to be presented to return.
2218 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2219 */
2220#define AssertRCReturnStmt(rc, stmt, rcRet) AssertMsgRCReturnStmt(rc, ("%Rra\n", (rc)), stmt, rcRet)
2221
2222/** @def AssertRCReturnVoid
2223 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return if it isn't.
2224 *
2225 * @param rc iprt status code.
2226 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2227 */
2228#define AssertRCReturnVoid(rc) AssertMsgRCReturnVoid(rc, ("%Rra\n", (rc)))
2229
2230/** @def AssertRCReturnVoidStmt
2231 * Asserts a iprt status code successful, bitch (RT_STRICT mode only), and
2232 * execute the given statement/return if it isn't.
2233 *
2234 * @param rc iprt status code.
2235 * @param stmt Statement to execute before returning on failure.
2236 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2237 */
2238#define AssertRCReturnVoidStmt(rc, stmt) AssertMsgRCReturnVoidStmt(rc, ("%Rra\n", (rc)), stmt)
2239
2240/** @def AssertRCBreak
2241 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break if it isn't.
2242 *
2243 * @param rc iprt status code.
2244 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2245 */
2246#define AssertRCBreak(rc) AssertMsgRCBreak(rc, ("%Rra\n", (rc)))
2247
2248/** @def AssertRCBreakStmt
2249 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break if it isn't.
2250 *
2251 * @param rc iprt status code.
2252 * @param stmt Statement to execute before break in case of a failed assertion.
2253 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2254 */
2255#define AssertRCBreakStmt(rc, stmt) AssertMsgRCBreakStmt(rc, ("%Rra\n", (rc)), stmt)
2256
2257/** @def AssertMsgRC
2258 * Asserts a iprt status code successful.
2259 *
2260 * It prints a custom message and hits a breakpoint on FAILURE.
2261 *
2262 * @param rc iprt status code.
2263 * @param msg printf argument list (in parenthesis).
2264 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2265 */
2266#define AssertMsgRC(rc, msg) \
2267 do { AssertMsg(RT_SUCCESS_NP(rc), msg); NOREF(rc); } while (0)
2268
2269/** @def AssertMsgRCStmt
2270 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and
2271 * execute @a stmt if it isn't.
2272 *
2273 * @param rc iprt status code.
2274 * @param msg printf argument list (in parenthesis).
2275 * @param stmt Statement to execute before returning in case of a failed
2276 * assertion.
2277 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2278 */
2279#define AssertMsgRCStmt(rc, msg, stmt) \
2280 do { AssertMsgStmt(RT_SUCCESS_NP(rc), msg, stmt); NOREF(rc); } while (0)
2281
2282/** @def AssertMsgRCReturn
2283 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return
2284 * @a rcRet if it isn't.
2285 *
2286 * @param rc iprt status code.
2287 * @param msg printf argument list (in parenthesis).
2288 * @param rcRet What is to be presented to return.
2289 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2290 */
2291#define AssertMsgRCReturn(rc, msg, rcRet) \
2292 do { AssertMsgReturn(RT_SUCCESS_NP(rc), msg, rcRet); NOREF(rc); } while (0)
2293
2294/** @def AssertMsgRCReturnStmt
2295 * Asserts a iprt status code successful, bitch (RT_STRICT mode only), execute
2296 * @a stmt and return @a rcRet if it isn't.
2297 *
2298 * @param rc iprt status code.
2299 * @param msg printf argument list (in parenthesis).
2300 * @param stmt Statement to execute before returning in case of a failed
2301 * assertion.
2302 * @param rcRet What is to be presented to return.
2303 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2304 */
2305#define AssertMsgRCReturnStmt(rc, msg, stmt, rcRet) \
2306 do { AssertMsgReturnStmt(RT_SUCCESS_NP(rc), msg, stmt, rcRet); NOREF(rc); } while (0)
2307
2308/** @def AssertMsgRCReturnVoid
2309 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return
2310 * void if it isn't.
2311 *
2312 * @param rc iprt status code.
2313 * @param msg printf argument list (in parenthesis).
2314 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2315 */
2316#define AssertMsgRCReturnVoid(rc, msg) \
2317 do { AssertMsgReturnVoid(RT_SUCCESS_NP(rc), msg); NOREF(rc); } while (0)
2318
2319/** @def AssertMsgRCReturnVoidStmt
2320 * Asserts a iprt status code successful, bitch (RT_STRICT mode only), execute
2321 * @a stmt and return void if it isn't.
2322 *
2323 * @param rc iprt status code.
2324 * @param msg printf argument list (in parenthesis).
2325 * @param stmt Statement to execute before break in case of a failed assertion.
2326 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2327 */
2328#define AssertMsgRCReturnVoidStmt(rc, msg, stmt) \
2329 do { AssertMsgReturnVoidStmt(RT_SUCCESS_NP(rc), msg, stmt); NOREF(rc); } while (0)
2330
2331/** @def AssertMsgRCBreak
2332 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break
2333 * if it isn't.
2334 *
2335 * @param rc iprt status code.
2336 * @param msg printf argument list (in parenthesis).
2337 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2338 */
2339#define AssertMsgRCBreak(rc, msg) \
2340 if (1) { AssertMsgBreak(RT_SUCCESS(rc), msg); NOREF(rc); } else do {} while (0)
2341
2342/** @def AssertMsgRCBreakStmt
2343 * Asserts a iprt status code successful, bitch (RT_STRICT mode only), execute
2344 * @a stmt and break if it isn't.
2345 *
2346 * @param rc iprt status code.
2347 * @param msg printf argument list (in parenthesis).
2348 * @param stmt Statement to execute before break in case of a failed assertion.
2349 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2350 */
2351#define AssertMsgRCBreakStmt(rc, msg, stmt) \
2352 if (1) { AssertMsgBreakStmt(RT_SUCCESS_NP(rc), msg, stmt); NOREF(rc); } else do {} while (0)
2353
2354/** @def AssertRCSuccess
2355 * Asserts an iprt status code equals VINF_SUCCESS.
2356 *
2357 * On failure it will print info about the rc and hit a breakpoint.
2358 *
2359 * @param rc iprt status code.
2360 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2361 */
2362#define AssertRCSuccess(rc) do { AssertMsg((rc) == VINF_SUCCESS, ("%Rra\n", (rc))); NOREF(rc); } while (0)
2363
2364/** @def AssertRCSuccessReturn
2365 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and return if it isn't.
2366 *
2367 * @param rc iprt status code.
2368 * @param rcRet What is to be presented to return.
2369 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2370 */
2371#define AssertRCSuccessReturn(rc, rcRet) AssertMsgReturn((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), rcRet)
2372
2373/** @def AssertRCSuccessReturnVoid
2374 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and return if it isn't.
2375 *
2376 * @param rc iprt status code.
2377 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2378 */
2379#define AssertRCSuccessReturnVoid(rc) AssertMsgReturnVoid((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2380
2381/** @def AssertRCSuccessBreak
2382 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and break if it isn't.
2383 *
2384 * @param rc iprt status code.
2385 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2386 */
2387#define AssertRCSuccessBreak(rc) AssertMsgBreak((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2388
2389/** @def AssertRCSuccessBreakStmt
2390 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and break if it isn't.
2391 *
2392 * @param rc iprt status code.
2393 * @param stmt Statement to execute before break in case of a failed assertion.
2394 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2395 */
2396#define AssertRCSuccessBreakStmt(rc, stmt) AssertMsgBreakStmt((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), stmt)
2397
2398
2399/** @def AssertLogRelRC
2400 * Asserts a iprt status code successful.
2401 *
2402 * @param rc iprt status code.
2403 * @remark rc is referenced multiple times.
2404 */
2405#define AssertLogRelRC(rc) AssertLogRelMsgRC(rc, ("%Rra\n", (rc)))
2406
2407/** @def AssertLogRelRCReturn
2408 * Asserts a iprt status code successful, returning \a rc if it isn't.
2409 *
2410 * @param rc iprt status code.
2411 * @param rcRet What is to be presented to return.
2412 * @remark rc is referenced multiple times.
2413 */
2414#define AssertLogRelRCReturn(rc, rcRet) AssertLogRelMsgRCReturn(rc, ("%Rra\n", (rc)), rcRet)
2415
2416/** @def AssertLogRelRCReturnStmt
2417 * Asserts a iprt status code successful, executing \a stmt and returning \a rc
2418 * if it isn't.
2419 *
2420 * @param rc iprt status code.
2421 * @param stmt Statement to execute before returning in case of a failed
2422 * assertion.
2423 * @param rcRet What is to be presented to return.
2424 * @remark rc is referenced multiple times.
2425 */
2426#define AssertLogRelRCReturnStmt(rc, stmt, rcRet) AssertLogRelMsgRCReturnStmt(rc, ("%Rra\n", (rc)), stmt, rcRet)
2427
2428/** @def AssertLogRelRCReturnVoid
2429 * Asserts a iprt status code successful, returning (void) if it isn't.
2430 *
2431 * @param rc iprt status code.
2432 * @remark rc is referenced multiple times.
2433 */
2434#define AssertLogRelRCReturnVoid(rc) AssertLogRelMsgRCReturnVoid(rc, ("%Rra\n", (rc)))
2435
2436/** @def AssertLogRelRCBreak
2437 * Asserts a iprt status code successful, breaking if it isn't.
2438 *
2439 * @param rc iprt status code.
2440 * @remark rc is referenced multiple times.
2441 */
2442#define AssertLogRelRCBreak(rc) AssertLogRelMsgRCBreak(rc, ("%Rra\n", (rc)))
2443
2444/** @def AssertLogRelRCBreakStmt
2445 * Asserts a iprt status code successful, execute \a statement and break if it isn't.
2446 *
2447 * @param rc iprt status code.
2448 * @param stmt Statement to execute before break in case of a failed assertion.
2449 * @remark rc is referenced multiple times.
2450 */
2451#define AssertLogRelRCBreakStmt(rc, stmt) AssertLogRelMsgRCBreakStmt(rc, ("%Rra\n", (rc)), stmt)
2452
2453/** @def AssertLogRelMsgRC
2454 * Asserts a iprt status code successful.
2455 *
2456 * @param rc iprt status code.
2457 * @param msg printf argument list (in parenthesis).
2458 * @remark rc is referenced multiple times.
2459 */
2460#define AssertLogRelMsgRC(rc, msg) AssertLogRelMsg(RT_SUCCESS_NP(rc), msg)
2461
2462/** @def AssertLogRelMsgRCReturn
2463 * Asserts a iprt status code successful.
2464 *
2465 * @param rc iprt status code.
2466 * @param msg printf argument list (in parenthesis).
2467 * @param rcRet What is to be presented to return.
2468 * @remark rc is referenced multiple times.
2469 */
2470#define AssertLogRelMsgRCReturn(rc, msg, rcRet) AssertLogRelMsgReturn(RT_SUCCESS_NP(rc), msg, rcRet)
2471
2472/** @def AssertLogRelMsgRCReturnStmt
2473 * Asserts a iprt status code successful, execute \a stmt and return on
2474 * failure.
2475 *
2476 * @param rc iprt status code.
2477 * @param msg printf argument list (in parenthesis).
2478 * @param stmt Statement to execute before returning in case of a failed
2479 * assertion.
2480 * @param rcRet What is to be presented to return.
2481 * @remark rc is referenced multiple times.
2482 */
2483#define AssertLogRelMsgRCReturnStmt(rc, msg, stmt, rcRet) AssertLogRelMsgReturnStmt(RT_SUCCESS_NP(rc), msg, stmt, rcRet)
2484
2485/** @def AssertLogRelMsgRCReturnVoid
2486 * Asserts a iprt status code successful.
2487 *
2488 * @param rc iprt status code.
2489 * @param msg printf argument list (in parenthesis).
2490 * @remark rc is referenced multiple times.
2491 */
2492#define AssertLogRelMsgRCReturnVoid(rc, msg) AssertLogRelMsgReturnVoid(RT_SUCCESS_NP(rc), msg)
2493
2494/** @def AssertLogRelMsgRCBreak
2495 * Asserts a iprt status code successful.
2496 *
2497 * @param rc iprt status code.
2498 * @param msg printf argument list (in parenthesis).
2499 * @remark rc is referenced multiple times.
2500 */
2501#define AssertLogRelMsgRCBreak(rc, msg) AssertLogRelMsgBreak(RT_SUCCESS(rc), msg)
2502
2503/** @def AssertLogRelMsgRCBreakStmt
2504 * Asserts a iprt status code successful, execute \a stmt and break if it isn't.
2505 *
2506 * @param rc iprt status code.
2507 * @param msg printf argument list (in parenthesis).
2508 * @param stmt Statement to execute before break in case of a failed assertion.
2509 * @remark rc is referenced multiple times.
2510 */
2511#define AssertLogRelMsgRCBreakStmt(rc, msg, stmt) AssertLogRelMsgBreakStmt(RT_SUCCESS_NP(rc), msg, stmt)
2512
2513/** @def AssertLogRelRCSuccess
2514 * Asserts that an iprt status code equals VINF_SUCCESS.
2515 *
2516 * @param rc iprt status code.
2517 * @remark rc is referenced multiple times.
2518 */
2519#define AssertLogRelRCSuccess(rc) AssertLogRelMsg((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2520
2521/** @def AssertLogRelRCSuccessReturn
2522 * Asserts that an iprt status code equals VINF_SUCCESS.
2523 *
2524 * @param rc iprt status code.
2525 * @param rcRet What is to be presented to return.
2526 * @remark rc is referenced multiple times.
2527 */
2528#define AssertLogRelRCSuccessReturn(rc, rcRet) AssertLogRelMsgReturn((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), rcRet)
2529
2530/** @def AssertLogRelRCSuccessReturnVoid
2531 * Asserts that an iprt status code equals VINF_SUCCESS.
2532 *
2533 * @param rc iprt status code.
2534 * @remark rc is referenced multiple times.
2535 */
2536#define AssertLogRelRCSuccessReturnVoid(rc) AssertLogRelMsgReturnVoid((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2537
2538/** @def AssertLogRelRCSuccessBreak
2539 * Asserts that an iprt status code equals VINF_SUCCESS.
2540 *
2541 * @param rc iprt status code.
2542 * @remark rc is referenced multiple times.
2543 */
2544#define AssertLogRelRCSuccessBreak(rc) AssertLogRelMsgBreak((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2545
2546/** @def AssertLogRelRCSuccessBreakStmt
2547 * Asserts that an iprt status code equals VINF_SUCCESS.
2548 *
2549 * @param rc iprt status code.
2550 * @param stmt Statement to execute before break in case of a failed assertion.
2551 * @remark rc is referenced multiple times.
2552 */
2553#define AssertLogRelRCSuccessBreakStmt(rc, stmt) AssertLogRelMsgBreakStmt((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), stmt)
2554
2555
2556/** @def AssertReleaseRC
2557 * Asserts a iprt status code successful.
2558 *
2559 * On failure information about the error will be printed and a breakpoint hit.
2560 *
2561 * @param rc iprt status code.
2562 * @remark rc is referenced multiple times.
2563 */
2564#define AssertReleaseRC(rc) AssertReleaseMsgRC(rc, ("%Rra\n", (rc)))
2565
2566/** @def AssertReleaseRCReturn
2567 * Asserts a iprt status code successful, returning if it isn't.
2568 *
2569 * On failure information about the error will be printed, a breakpoint hit
2570 * and finally returning from the function if the breakpoint is somehow ignored.
2571 *
2572 * @param rc iprt status code.
2573 * @param rcRet What is to be presented to return.
2574 * @remark rc is referenced multiple times.
2575 */
2576#define AssertReleaseRCReturn(rc, rcRet) AssertReleaseMsgRCReturn(rc, ("%Rra\n", (rc)), rcRet)
2577
2578/** @def AssertReleaseRCReturnVoid
2579 * Asserts a iprt status code successful, returning if it isn't.
2580 *
2581 * On failure information about the error will be printed, a breakpoint hit
2582 * and finally returning from the function if the breakpoint is somehow ignored.
2583 *
2584 * @param rc iprt status code.
2585 * @remark rc is referenced multiple times.
2586 */
2587#define AssertReleaseRCReturnVoid(rc) AssertReleaseMsgRCReturnVoid(rc, ("%Rra\n", (rc)))
2588
2589/** @def AssertReleaseRCBreak
2590 * Asserts a iprt status code successful, breaking if it isn't.
2591 *
2592 * On failure information about the error will be printed, a breakpoint hit
2593 * and finally breaking the current statement if the breakpoint is somehow ignored.
2594 *
2595 * @param rc iprt status code.
2596 * @remark rc is referenced multiple times.
2597 */
2598#define AssertReleaseRCBreak(rc) AssertReleaseMsgRCBreak(rc, ("%Rra\n", (rc)))
2599
2600/** @def AssertReleaseRCBreakStmt
2601 * Asserts a iprt status code successful, break if it isn't.
2602 *
2603 * On failure information about the error will be printed, a breakpoint hit
2604 * and finally the break statement will be issued if the breakpoint is somehow ignored.
2605 *
2606 * @param rc iprt status code.
2607 * @param stmt Statement to execute before break in case of a failed assertion.
2608 * @remark rc is referenced multiple times.
2609 */
2610#define AssertReleaseRCBreakStmt(rc, stmt) AssertReleaseMsgRCBreakStmt(rc, ("%Rra\n", (rc)), stmt)
2611
2612/** @def AssertReleaseMsgRC
2613 * Asserts a iprt status code successful.
2614 *
2615 * On failure a custom message is printed and a breakpoint is hit.
2616 *
2617 * @param rc iprt status code.
2618 * @param msg printf argument list (in parenthesis).
2619 * @remark rc is referenced multiple times.
2620 */
2621#define AssertReleaseMsgRC(rc, msg) AssertReleaseMsg(RT_SUCCESS_NP(rc), msg)
2622
2623/** @def AssertReleaseMsgRCReturn
2624 * Asserts a iprt status code successful.
2625 *
2626 * On failure a custom message is printed, a breakpoint is hit, and finally
2627 * returning from the function if the breakpoint is somehow ignored.
2628 *
2629 * @param rc iprt status code.
2630 * @param msg printf argument list (in parenthesis).
2631 * @param rcRet What is to be presented to return.
2632 * @remark rc is referenced multiple times.
2633 */
2634#define AssertReleaseMsgRCReturn(rc, msg, rcRet) AssertReleaseMsgReturn(RT_SUCCESS_NP(rc), msg, rcRet)
2635
2636/** @def AssertReleaseMsgRCReturnVoid
2637 * Asserts a iprt status code successful.
2638 *
2639 * On failure a custom message is printed, a breakpoint is hit, and finally
2640 * returning from the function if the breakpoint is somehow ignored.
2641 *
2642 * @param rc iprt status code.
2643 * @param msg printf argument list (in parenthesis).
2644 * @remark rc is referenced multiple times.
2645 */
2646#define AssertReleaseMsgRCReturnVoid(rc, msg) AssertReleaseMsgReturnVoid(RT_SUCCESS_NP(rc), msg)
2647
2648/** @def AssertReleaseMsgRCBreak
2649 * Asserts a iprt status code successful.
2650 *
2651 * On failure a custom message is printed, a breakpoint is hit, and finally
2652 * breaking the current status if the breakpoint is somehow ignored.
2653 *
2654 * @param rc iprt status code.
2655 * @param msg printf argument list (in parenthesis).
2656 * @remark rc is referenced multiple times.
2657 */
2658#define AssertReleaseMsgRCBreak(rc, msg) AssertReleaseMsgBreak(RT_SUCCESS(rc), msg)
2659
2660/** @def AssertReleaseMsgRCBreakStmt
2661 * Asserts a iprt status code successful.
2662 *
2663 * On failure a custom message is printed, a breakpoint is hit, and finally
2664 * the break statement is issued if the breakpoint is somehow ignored.
2665 *
2666 * @param rc iprt status code.
2667 * @param msg printf argument list (in parenthesis).
2668 * @param stmt Statement to execute before break in case of a failed assertion.
2669 * @remark rc is referenced multiple times.
2670 */
2671#define AssertReleaseMsgRCBreakStmt(rc, msg, stmt) AssertReleaseMsgBreakStmt(RT_SUCCESS_NP(rc), msg, stmt)
2672
2673/** @def AssertReleaseRCSuccess
2674 * Asserts that an iprt status code equals VINF_SUCCESS.
2675 *
2676 * On failure information about the error will be printed and a breakpoint hit.
2677 *
2678 * @param rc iprt status code.
2679 * @remark rc is referenced multiple times.
2680 */
2681#define AssertReleaseRCSuccess(rc) AssertReleaseMsg((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2682
2683/** @def AssertReleaseRCSuccessReturn
2684 * Asserts that an iprt status code equals VINF_SUCCESS.
2685 *
2686 * On failure information about the error will be printed, a breakpoint hit
2687 * and finally returning from the function if the breakpoint is somehow ignored.
2688 *
2689 * @param rc iprt status code.
2690 * @param rcRet What is to be presented to return.
2691 * @remark rc is referenced multiple times.
2692 */
2693#define AssertReleaseRCSuccessReturn(rc, rcRet) AssertReleaseMsgReturn((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), rcRet)
2694
2695/** @def AssertReleaseRCSuccessReturnVoid
2696 * Asserts that an iprt status code equals VINF_SUCCESS.
2697 *
2698 * On failure information about the error will be printed, a breakpoint hit
2699 * and finally returning from the function if the breakpoint is somehow ignored.
2700 *
2701 * @param rc iprt status code.
2702 * @remark rc is referenced multiple times.
2703 */
2704#define AssertReleaseRCSuccessReturnVoid(rc) AssertReleaseMsgReturnVoid((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2705
2706/** @def AssertReleaseRCSuccessBreak
2707 * Asserts that an iprt status code equals VINF_SUCCESS.
2708 *
2709 * On failure information about the error will be printed, a breakpoint hit
2710 * and finally breaking the current statement if the breakpoint is somehow ignored.
2711 *
2712 * @param rc iprt status code.
2713 * @remark rc is referenced multiple times.
2714 */
2715#define AssertReleaseRCSuccessBreak(rc) AssertReleaseMsgBreak((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2716
2717/** @def AssertReleaseRCSuccessBreakStmt
2718 * Asserts that an iprt status code equals VINF_SUCCESS.
2719 *
2720 * On failure information about the error will be printed, a breakpoint hit
2721 * and finally the break statement will be issued if the breakpoint is somehow ignored.
2722 *
2723 * @param rc iprt status code.
2724 * @param stmt Statement to execute before break in case of a failed assertion.
2725 * @remark rc is referenced multiple times.
2726 */
2727#define AssertReleaseRCSuccessBreakStmt(rc, stmt) AssertReleaseMsgBreakStmt((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), stmt)
2728
2729
2730/** @def AssertFatalRC
2731 * Asserts a iprt status code successful.
2732 *
2733 * On failure information about the error will be printed and a breakpoint hit.
2734 *
2735 * @param rc iprt status code.
2736 * @remark rc is referenced multiple times.
2737 */
2738#define AssertFatalRC(rc) AssertFatalMsgRC(rc, ("%Rra\n", (rc)))
2739
2740/** @def AssertReleaseMsgRC
2741 * Asserts a iprt status code successful.
2742 *
2743 * On failure a custom message is printed and a breakpoint is hit.
2744 *
2745 * @param rc iprt status code.
2746 * @param msg printf argument list (in parenthesis).
2747 * @remark rc is referenced multiple times.
2748 */
2749#define AssertFatalMsgRC(rc, msg) AssertFatalMsg(RT_SUCCESS_NP(rc), msg)
2750
2751/** @def AssertFatalRCSuccess
2752 * Asserts that an iprt status code equals VINF_SUCCESS.
2753 *
2754 * On failure information about the error will be printed and a breakpoint hit.
2755 *
2756 * @param rc iprt status code.
2757 * @remark rc is referenced multiple times.
2758 */
2759#define AssertFatalRCSuccess(rc) AssertFatalMsg((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2760
2761
2762/** @def AssertPtr
2763 * Asserts that a pointer is valid.
2764 *
2765 * @param pv The pointer.
2766 */
2767#define AssertPtr(pv) AssertMsg(RT_VALID_PTR(pv), ("%p\n", (pv)))
2768
2769/** @def AssertPtrReturn
2770 * Asserts that a pointer is valid.
2771 *
2772 * @param pv The pointer.
2773 * @param rcRet What is to be presented to return.
2774 */
2775#define AssertPtrReturn(pv, rcRet) AssertMsgReturn(RT_VALID_PTR(pv), ("%p\n", (pv)), rcRet)
2776
2777/** @def AssertPtrReturnVoid
2778 * Asserts that a pointer is valid.
2779 *
2780 * @param pv The pointer.
2781 */
2782#define AssertPtrReturnVoid(pv) AssertMsgReturnVoid(RT_VALID_PTR(pv), ("%p\n", (pv)))
2783
2784/** @def AssertPtrReturnStmt
2785 * Asserts that a pointer is valid.
2786 *
2787 * @param pv The pointer.
2788 * @param stmt Statement to execute before returninig in case of a failed
2789 * assertion.
2790 * @param rcRet What is to be presented to return.
2791 */
2792#define AssertPtrReturnStmt(pv, stmt, rcRet) AssertMsgReturnStmt(RT_VALID_PTR(pv), ("%p\n", (pv)), stmt, rcRet)
2793
2794/** @def AssertPtrReturnVoidStmt
2795 * Asserts that a pointer is valid.
2796 *
2797 * @param pv The pointer.
2798 * @param stmt Statement to execute before returninig in case of a failed
2799 * assertion.
2800 */
2801#define AssertPtrReturnVoidStmt(pv, stmt) AssertMsgReturnVoid(RT_VALID_PTR(pv), ("%p\n", (pv)), stmt)
2802
2803/** @def AssertPtrBreak
2804 * Asserts that a pointer is valid.
2805 *
2806 * @param pv The pointer.
2807 */
2808#define AssertPtrBreak(pv) AssertMsgBreak(RT_VALID_PTR(pv), ("%p\n", (pv)))
2809
2810/** @def AssertPtrBreakStmt
2811 * Asserts that a pointer is valid.
2812 *
2813 * @param pv The pointer.
2814 * @param stmt Statement to execute before break in case of a failed assertion.
2815 */
2816#define AssertPtrBreakStmt(pv, stmt) AssertMsgBreakStmt(RT_VALID_PTR(pv), ("%p\n", (pv)), stmt)
2817
2818/** @def AssertPtrNull
2819 * Asserts that a pointer is valid or NULL.
2820 *
2821 * @param pv The pointer.
2822 */
2823#define AssertPtrNull(pv) AssertMsg(RT_VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)))
2824
2825/** @def AssertPtrNullReturn
2826 * Asserts that a pointer is valid or NULL.
2827 *
2828 * @param pv The pointer.
2829 * @param rcRet What is to be presented to return.
2830 */
2831#define AssertPtrNullReturn(pv, rcRet) AssertMsgReturn(RT_VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)), rcRet)
2832
2833/** @def AssertPtrNullReturnVoid
2834 * Asserts that a pointer is valid or NULL.
2835 *
2836 * @param pv The pointer.
2837 */
2838#define AssertPtrNullReturnVoid(pv) AssertMsgReturnVoid(RT_VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)))
2839
2840/** @def AssertPtrNullBreak
2841 * Asserts that a pointer is valid or NULL.
2842 *
2843 * @param pv The pointer.
2844 */
2845#define AssertPtrNullBreak(pv) AssertMsgBreak(RT_VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)))
2846
2847/** @def AssertPtrNullBreakStmt
2848 * Asserts that a pointer is valid or NULL.
2849 *
2850 * @param pv The pointer.
2851 * @param stmt Statement to execute before break in case of a failed assertion.
2852 */
2853#define AssertPtrNullBreakStmt(pv, stmt) AssertMsgBreakStmt(RT_VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)), stmt)
2854
2855/** @def AssertGCPhys32
2856 * Asserts that the high dword of a physical address is zero
2857 *
2858 * @param GCPhys The address (RTGCPHYS).
2859 */
2860#define AssertGCPhys32(GCPhys) AssertMsg(VALID_PHYS32(GCPhys), ("%RGp\n", (RTGCPHYS)(GCPhys)))
2861
2862/** @def AssertGCPtr32
2863 * Asserts that the high dword of a physical address is zero
2864 *
2865 * @param GCPtr The address (RTGCPTR).
2866 */
2867#if GC_ARCH_BITS == 32
2868# define AssertGCPtr32(GCPtr) do { } while (0)
2869#else
2870# define AssertGCPtr32(GCPtr) AssertMsg(!((GCPtr) & UINT64_C(0xffffffff00000000)), ("%RGv\n", GCPtr))
2871#endif
2872
2873/** @def AssertForEach
2874 * Equivalent to Assert for each value of the variable from the starting
2875 * value to the finishing one.
2876 *
2877 * @param var Name of the counter variable.
2878 * @param vartype Type of the counter variable.
2879 * @param first Lowest inclusive value of the counter variable.
2880 * This must be free from side effects.
2881 * @param end Highest exclusive value of the counter variable.
2882 * This must be free from side effects.
2883 * @param expr Expression which should be true for each value of @a var.
2884 */
2885#define AssertForEach(var, vartype, first, end, expr) \
2886 do { \
2887 vartype var; \
2888 Assert((first) == (first) && (end) == (end)); /* partial check for side effects */ \
2889 for (var = (first); var < (end); var++) \
2890 AssertMsg(expr, ("%s = %#RX64 (%RI64)", #var, (uint64_t)var, (int64_t)var)); \
2891 } while (0)
2892
2893#ifdef RT_OS_WINDOWS
2894
2895/** @def AssertNtStatus
2896 * Asserts that the NT_SUCCESS() returns true for the given NTSTATUS value.
2897 *
2898 * @param a_rcNt The NTSTATUS to check. Will be evaluated twice and
2899 * subjected to NOREF().
2900 * @sa AssertRC()
2901 */
2902# define AssertNtStatus(a_rcNt) \
2903 do { AssertMsg(NT_SUCCESS(a_rcNt), ("%#x\n", (a_rcNt))); NOREF(a_rcNt); } while (0)
2904
2905/** @def AssertNtStatusSuccess
2906 * Asserts that the given NTSTATUS value equals STATUS_SUCCESS.
2907 *
2908 * @param a_rcNt The NTSTATUS to check. Will be evaluated twice and
2909 * subjected to NOREF().
2910 * @sa AssertRCSuccess()
2911 */
2912# define AssertNtStatusSuccess(a_rcNt) \
2913 do { AssertMsg((a_rcNt) == STATUS_SUCCESS, ("%#x\n", (a_rcNt))); NOREF(a_rcNt); } while (0)
2914
2915#endif /* RT_OS_WINDOWS */
2916
2917/** @} */
2918
2919/** @} */
2920
2921#endif /* !IPRT_INCLUDED_assert_h */
2922
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use