VirtualBox

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

Last change on this file since 76421 was 76371, checked in by vboxsync, 6 years ago

iprt/assert.h: Mark all PRETTY_FUNCTION use with RT_GCC_EXTENSION.

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

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