VirtualBox

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

Last change on this file since 79851 was 79851, checked in by vboxsync, 5 years ago

iprt/assert.h: Improved RTASSERT_QUIET handling of RTAssertMsg2Weak for compilers with variadic macro support.

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

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