VirtualBox

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

Last change on this file since 78377 was 76585, checked in by vboxsync, 6 years ago

*: scm --fix-header-guard-endif

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