VirtualBox

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

Last change on this file since 68154 was 65948, checked in by vboxsync, 8 years ago

gcc 7: added 'break' to the 'else' case of all Assert*Break() macros. The gcc 7 fall-thru detection seems to be executed before the dead code elimination pass.

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