VirtualBox

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

最後變更 在這個檔案從96407是 96407,由 vboxsync 提交於 3 年 前

scm copyright and license note update

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

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