VirtualBox

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

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

iprt/assert.h: AssertStmt.

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