VirtualBox

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

Last change on this file since 74981 was 74500, checked in by vboxsync, 6 years ago

iprt/assert.h: Added AssertLogRelStmt.

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