VirtualBox

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

Last change on this file since 25548 was 25548, checked in by vboxsync, 15 years ago

iprt/assert.h: RTASSERT_QUIET for shutting up assertions in code that is involved in the message output.

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