VirtualBox

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

Last change on this file since 11556 was 11190, checked in by vboxsync, 16 years ago

AssertLogRelMsg1: Fixed the LogRel() version, it was printing the file twice and omittnig the function and expression.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 63.1 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
36/** @defgroup grp_rt_assert Assert - Assertions
37 * @ingroup grp_rt
38 *
39 * Assertions are generally used to check precoditions and other
40 * assumptions. Sometimes it is also used to catch odd errors or errors
41 * that one would like to inspect in the debugger. They should not be
42 * used for errors that happen frequently.
43 *
44 * IPRT provides a host of assertion macros, so many that it can be a bit
45 * overwhelming at first. Don't despair, there is a system (surprise).
46 *
47 * First there are four families of assertions:
48 * - Assert - The normal strict build only assertions.
49 * - AssertLogRel - Calls LogRel() in non-strict builds, otherwise like Assert.
50 * - AssertRelease - Triggers in all builds.
51 * - AssertFatal - Triggers in all builds and cannot be continued.
52 *
53 * Then there are variations wrt to argument list and behavior on failure:
54 * - Msg - Custom RTStrPrintf-like message with the assertion message.
55 * - Return - Return the specific rc on failure.
56 * - ReturnVoid - Return (void) on failure.
57 * - Break - Break (out of switch/loop) on failure.
58 * - Stmt - Execute the specified statment(s) on failure.
59 * - RC - Assert RT_SUCCESS.
60 * - RCSuccess - Assert VINF_SUCCESS.
61 *
62 * In additions there is a very special familiy AssertCompile that can be
63 * used for some limited compile checking. Like structure sizes and member
64 * alignment. This family doesn't have the same variations.
65 *
66 *
67 * @remarks As you might've noticed, the macros doesn't follow the
68 * coding guidelines wrt to macros supposedly being all uppercase
69 * and underscored. For various reasons they don't, and it nobody
70 * has complained yet. Wonder why... :-)
71 *
72 * @remarks Each project has its own specific guidelines on how to use
73 * assertions, so the above is just trying to give you the general idea
74 * from the IPRT point of view.
75 *
76 * @{
77 */
78
79__BEGIN_DECLS
80
81/**
82 * The 1st part of an assert message.
83 *
84 * @param pszExpr Expression. Can be NULL.
85 * @param uLine Location line number.
86 * @param pszFile Location file name.
87 * @param pszFunction Location function name.
88 * @remark This API exists in HC Ring-3 and GC.
89 */
90RTDECL(void) AssertMsg1(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction);
91
92/**
93 * The 2nd (optional) part of an assert message.
94 * @param pszFormat Printf like format string.
95 * @param ... Arguments to that string.
96 * @remark This API exists in HC Ring-3 and GC.
97 */
98RTDECL(void) AssertMsg2(const char *pszFormat, ...);
99
100/**
101 * Overridable function that decides whether assertions executes the breakpoint or not.
102 *
103 * The generic implementation will return true.
104 *
105 * @returns true if the breakpoint should be hit, false if it should be ignored.
106 * @remark The RTDECL() makes this a bit difficult to override on windows. Sorry.
107 */
108RTDECL(bool) RTAssertDoBreakpoint(void);
109
110/** The last assert message, 1st part. */
111extern RTDATADECL(char) g_szRTAssertMsg1[1024];
112/** The last assert message, 2nd part. */
113extern RTDATADECL(char) g_szRTAssertMsg2[2048];
114
115__END_DECLS
116
117
118/** @def AssertBreakpoint()
119 * Assertion Breakpoint.
120 *
121 * @remark In the gnu world we add a nop instruction after the int3 to
122 * force gdb to remain at the int3 source line.
123 * @remark The L4 kernel will try make sense of the breakpoint, thus the jmp.
124 */
125#ifdef RT_STRICT
126# ifdef __GNUC__
127# ifndef __L4ENV__
128# define AssertBreakpoint() do { if (RTAssertDoBreakpoint()) { __asm__ __volatile__ ("int3\n\tnop"); } } while (0)
129# else
130# define AssertBreakpoint() do { if (RTAssertDoBreakpoint()) { __asm__ __volatile__ ("int3; jmp 1f; 1:"); } } while (0)
131# endif
132# elif defined(_MSC_VER) || defined(DOXYGEN_RUNNING)
133# define AssertBreakpoint() do { if (RTAssertDoBreakpoint()) { __debugbreak(); } } while (0)
134# else
135# error "Unknown compiler"
136# endif
137#else
138# define AssertBreakpoint() do { } while (0)
139#endif
140
141/**
142 * RTASSERTTYPE is the type the AssertCompile() macro redefines.
143 * It has no other function and shouldn't be used.
144 * Visual C++ uses this.
145 */
146typedef int RTASSERTTYPE[1];
147
148/**
149 * RTASSERTVAR is the type the AssertCompile() macro redefines.
150 * It has no other function and shouldn't be used.
151 * GCC uses this.
152 */
153#ifdef __GNUC__
154__BEGIN_DECLS
155#endif
156extern int RTASSERTVAR[1];
157#ifdef __GNUC__
158__END_DECLS
159#endif
160
161/** @def AssertCompile
162 * Asserts that a compile-time expression is true. If it's not break the build.
163 * @param expr Expression which should be true.
164 */
165#ifdef __GNUC__
166# define AssertCompile(expr) extern int RTASSERTVAR[1] __attribute__((unused)), RTASSERTVAR[(expr) ? 1 : 0] __attribute__((unused))
167#else
168# define AssertCompile(expr) typedef int RTASSERTTYPE[(expr) ? 1 : 0]
169#endif
170
171/** @def AssertCompileSize
172 * Asserts a size at compile.
173 * @param type The type.
174 * @param size The expected type size.
175 */
176#define AssertCompileSize(type, size) \
177 AssertCompile(sizeof(type) == (size))
178
179/** @def AssertCompileSizeAlignment
180 * Asserts a size alignment at compile.
181 * @param type The type.
182 * @param align The size alignment to assert.
183 */
184#define AssertCompileSizeAlignment(type, align) \
185 AssertCompile(!(sizeof(type) & ((align) - 1)))
186
187/** @def AssertCompileMemberSize
188 * Asserts a member offset alignment at compile.
189 * @param type The type.
190 * @param member The member.
191 * @param size The member size to assert.
192 */
193#define AssertCompileMemberSize(type, member, size) \
194 AssertCompile(RT_SIZEOFMEMB(type, member) == (size))
195
196/** @def AssertCompileMemberSizeAlignment
197 * Asserts a member size alignment at compile.
198 * @param type The type.
199 * @param member The member.
200 * @param align The member size alignment to assert.
201 */
202#define AssertCompileMemberSizeAlignment(type, member, align) \
203 AssertCompile(!(RT_SIZEOFMEMB(type, member) & ((align) - 1)))
204
205/** @def AssertCompileMemberAlignment
206 * Asserts a member offset alignment at compile.
207 * @param type The type.
208 * @param member The member.
209 * @param align The member offset alignment to assert.
210 */
211#if defined(__GNUC__) && defined(__cplusplus)
212# if __GNUC__ >= 4
213# define AssertCompileMemberAlignment(type, member, align) \
214 AssertCompile(!(__builtin_offsetof(type, member) & ((align) - 1)))
215# else
216# define AssertCompileMemberAlignment(type, member, align) \
217 AssertCompile(!(RT_OFFSETOF(type, member) & ((align) - 1)))
218# endif
219#else
220# define AssertCompileMemberAlignment(type, member, align) \
221 AssertCompile(!(RT_OFFSETOF(type, member) & ((align) - 1)))
222#endif
223
224/** @def AssertCompileMemberOffset
225 * Asserts a offset of a structure member at compile.
226 * @param type The type.
227 * @param member The member.
228 * @param off The expected offset.
229 */
230#if defined(__GNUC__) && defined(__cplusplus)
231# if __GNUC__ >= 4
232# define AssertCompileMemberOffset(type, member, off) \
233 AssertCompile(__builtin_offsetof(type, member) == (off))
234# else
235# define AssertCompileMemberOffset(type, member, off) \
236 AssertCompile(RT_OFFSETOF(type, member) == (off))
237# endif
238#else
239# define AssertCompileMemberOffset(type, member, off) \
240 AssertCompile(RT_OFFSETOF(type, member) == (off))
241#endif
242
243
244/** @def Assert
245 * Assert that an expression is true. If it's not hit breakpoint.
246 * @param expr Expression which should be true.
247 */
248#ifdef RT_STRICT
249# define Assert(expr) \
250 do { \
251 if (RT_UNLIKELY(!(expr))) \
252 { \
253 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
254 AssertBreakpoint(); \
255 } \
256 } while (0)
257#else
258# define Assert(expr) do { } while (0)
259#endif
260
261
262/** @def AssertReturn
263 * Assert that an expression is true and returns if it isn't.
264 * In RT_STRICT mode it will hit a breakpoint before returning.
265 *
266 * @param expr Expression which should be true.
267 * @param rc What is to be presented to return.
268 */
269#ifdef RT_STRICT
270# define AssertReturn(expr, rc) \
271 do { \
272 if (RT_UNLIKELY(!(expr))) \
273 { \
274 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
275 AssertBreakpoint(); \
276 return (rc); \
277 } \
278 } while (0)
279#else
280# define AssertReturn(expr, rc) \
281 do { \
282 if (RT_UNLIKELY(!(expr))) \
283 return (rc); \
284 } while (0)
285#endif
286
287/** @def AssertReturnVoid
288 * Assert that an expression is true and returns if it isn't.
289 * In RT_STRICT mode it will hit a breakpoint before returning.
290 *
291 * @param expr Expression which should be true.
292 */
293#ifdef RT_STRICT
294# define AssertReturnVoid(expr) \
295 do { \
296 if (RT_UNLIKELY(!(expr))) \
297 { \
298 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
299 AssertBreakpoint(); \
300 return; \
301 } \
302 } while (0)
303#else
304# define AssertReturnVoid(expr) \
305 do { \
306 if (RT_UNLIKELY(!(expr))) \
307 return; \
308 } while (0)
309#endif
310
311
312/** @def AssertBreak
313 * Assert that an expression is true and breaks if it isn't.
314 * In RT_STRICT mode it will hit a breakpoint before returning.
315 *
316 * @param expr Expression which should be true.
317 */
318#ifdef RT_STRICT
319# define AssertBreak(expr) \
320 if (RT_UNLIKELY(!(expr))) \
321 { \
322 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
323 AssertBreakpoint(); \
324 break; \
325 } else do {} while (0)
326#else
327# define AssertBreak(expr) \
328 if (RT_UNLIKELY(!(expr))) \
329 break; \
330 else do {} while (0)
331#endif
332
333/** @def AssertBreakStmt
334 * Assert that an expression is true and breaks if it isn't.
335 * In RT_STRICT mode it will hit a breakpoint before doing break.
336 *
337 * @param expr Expression which should be true.
338 * @param stmt Statement to execute before break in case of a failed assertion.
339 */
340#ifdef RT_STRICT
341# define AssertBreakStmt(expr, stmt) \
342 if (RT_UNLIKELY(!(expr))) { \
343 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
344 AssertBreakpoint(); \
345 stmt; \
346 break; \
347 } else do {} while (0)
348#else
349# define AssertBreakStmt(expr, stmt) \
350 if (RT_UNLIKELY(!(expr))) { \
351 stmt; \
352 break; \
353 } else do {} while (0)
354#endif
355
356
357/** @def AssertMsg
358 * Assert that an expression is true. If it's not print message and hit breakpoint.
359 * @param expr Expression which should be true.
360 * @param a printf argument list (in parenthesis).
361 */
362#ifdef RT_STRICT
363# define AssertMsg(expr, a) \
364 do { \
365 if (RT_UNLIKELY(!(expr))) \
366 { \
367 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
368 AssertMsg2 a; \
369 AssertBreakpoint(); \
370 } \
371 } while (0)
372#else
373# define AssertMsg(expr, a) do { } while (0)
374#endif
375
376/** @def AssertMsgReturn
377 * Assert that an expression is true and returns if it isn't.
378 * In RT_STRICT mode it will hit a breakpoint before returning.
379 *
380 * @param expr Expression which should be true.
381 * @param a printf argument list (in parenthesis).
382 * @param rc What is to be presented to return.
383 */
384#ifdef RT_STRICT
385# define AssertMsgReturn(expr, a, rc) \
386 do { \
387 if (RT_UNLIKELY(!(expr))) \
388 { \
389 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
390 AssertMsg2 a; \
391 AssertBreakpoint(); \
392 return (rc); \
393 } \
394 } while (0)
395#else
396# define AssertMsgReturn(expr, a, rc) \
397 do { \
398 if (RT_UNLIKELY(!(expr))) \
399 return (rc); \
400 } while (0)
401#endif
402
403/** @def AssertMsgReturnVoid
404 * Assert that an expression is true and returns if it isn't.
405 * In RT_STRICT mode it will hit a breakpoint before returning.
406 *
407 * @param expr Expression which should be true.
408 * @param a printf argument list (in parenthesis).
409 */
410#ifdef RT_STRICT
411# define AssertMsgReturnVoid(expr, a) \
412 do { \
413 if (RT_UNLIKELY(!(expr))) \
414 { \
415 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
416 AssertMsg2 a; \
417 AssertBreakpoint(); \
418 return; \
419 } \
420 } while (0)
421#else
422# define AssertMsgReturnVoid(expr, a) \
423 do { \
424 if (RT_UNLIKELY(!(expr))) \
425 return; \
426 } while (0)
427#endif
428
429
430/** @def AssertMsgBreak
431 * Assert that an expression is true and breaks if it isn't.
432 * In RT_STRICT mode it will hit a breakpoint before returning.
433 *
434 * @param expr Expression which should be true.
435 * @param a printf argument list (in parenthesis).
436 */
437#ifdef RT_STRICT
438# define AssertMsgBreak(expr, a) \
439 if (RT_UNLIKELY(!(expr))) \
440 { \
441 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
442 AssertMsg2 a; \
443 AssertBreakpoint(); \
444 break; \
445 } else do {} while (0)
446#else
447# define AssertMsgBreak(expr, a) \
448 if (RT_UNLIKELY(!(expr))) \
449 break; \
450 else do {} while (0)
451#endif
452
453/** @def AssertMsgBreakStmt
454 * Assert that an expression is true and breaks if it isn't.
455 * In RT_STRICT mode it will hit a breakpoint before doing break.
456 *
457 * @param expr Expression which should be true.
458 * @param a printf argument list (in parenthesis).
459 * @param stmt Statement to execute before break in case of a failed assertion.
460 */
461#ifdef RT_STRICT
462# define AssertMsgBreakStmt(expr, a, stmt) \
463 if (RT_UNLIKELY(!(expr))) { \
464 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
465 AssertMsg2 a; \
466 AssertBreakpoint(); \
467 stmt; \
468 break; \
469 } else do {} while (0)
470#else
471# define AssertMsgBreakStmt(expr, a, stmt) \
472 if (RT_UNLIKELY(!(expr))) { \
473 stmt; \
474 break; \
475 } else do {} while (0)
476#endif
477
478/** @def AssertFailed
479 * An assertion failed hit breakpoint.
480 */
481#ifdef RT_STRICT
482# define AssertFailed() \
483 do { \
484 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
485 AssertBreakpoint(); \
486 } while (0)
487#else
488# define AssertFailed() do { } while (0)
489#endif
490
491/** @def AssertFailedReturn
492 * An assertion failed, hit breakpoint (RT_STRICT mode only) and return.
493 *
494 * @param rc The rc to return.
495 */
496#ifdef RT_STRICT
497# define AssertFailedReturn(rc) \
498 do { \
499 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
500 AssertBreakpoint(); \
501 return (rc); \
502 } while (0)
503#else
504# define AssertFailedReturn(rc) \
505 do { \
506 return (rc); \
507 } while (0)
508#endif
509
510/** @def AssertFailedReturnVoid
511 * An assertion failed, hit breakpoint (RT_STRICT mode only) and return.
512 */
513#ifdef RT_STRICT
514# define AssertFailedReturnVoid() \
515 do { \
516 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
517 AssertBreakpoint(); \
518 return; \
519 } while (0)
520#else
521# define AssertFailedReturnVoid() \
522 do { \
523 return; \
524 } while (0)
525#endif
526
527
528/** @def AssertFailedBreak
529 * An assertion failed, hit breakpoint (RT_STRICT mode only) and break.
530 */
531#ifdef RT_STRICT
532# define AssertFailedBreak() \
533 if (1) { \
534 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
535 AssertBreakpoint(); \
536 break; \
537 } else do {} while (0)
538#else
539# define AssertFailedBreak() \
540 if (1) \
541 break; \
542 else do {} while (0)
543#endif
544
545/** @def AssertFailedBreakStmt
546 * An assertion failed, hit breakpoint (RT_STRICT mode only), execute
547 * the given statement and break.
548 *
549 * @param stmt Statement to execute before break.
550 */
551#ifdef RT_STRICT
552# define AssertFailedBreakStmt(stmt) \
553 if (1) { \
554 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
555 AssertBreakpoint(); \
556 stmt; \
557 break; \
558 } else do {} while (0)
559#else
560# define AssertFailedBreakStmt(stmt) \
561 if (1) { \
562 stmt; \
563 break; \
564 } else do {} while (0)
565#endif
566
567
568/** @def AssertMsgFailed
569 * An assertion failed print a message and a hit breakpoint.
570 *
571 * @param a printf argument list (in parenthesis).
572 */
573#ifdef RT_STRICT
574# define AssertMsgFailed(a) \
575 do { \
576 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
577 AssertMsg2 a; \
578 AssertBreakpoint(); \
579 } while (0)
580#else
581# define AssertMsgFailed(a) do { } while (0)
582#endif
583
584/** @def AssertMsgFailedReturn
585 * An assertion failed, hit breakpoint with message (RT_STRICT mode only) and return.
586 *
587 * @param a printf argument list (in parenthesis).
588 * @param rc What is to be presented to return.
589 */
590#ifdef RT_STRICT
591# define AssertMsgFailedReturn(a, rc) \
592 do { \
593 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
594 AssertMsg2 a; \
595 AssertBreakpoint(); \
596 return (rc); \
597 } while (0)
598#else
599# define AssertMsgFailedReturn(a, rc) \
600 do { \
601 return (rc); \
602 } while (0)
603#endif
604
605/** @def AssertMsgFailedReturnVoid
606 * An assertion failed, hit breakpoint with message (RT_STRICT mode only) and return.
607 *
608 * @param a printf argument list (in parenthesis).
609 */
610#ifdef RT_STRICT
611# define AssertMsgFailedReturnVoid(a) \
612 do { \
613 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
614 AssertMsg2 a; \
615 AssertBreakpoint(); \
616 return; \
617 } while (0)
618#else
619# define AssertMsgFailedReturnVoid(a) \
620 do { \
621 return; \
622 } while (0)
623#endif
624
625
626/** @def AssertMsgFailedBreak
627 * An assertion failed, hit breakpoint with message (RT_STRICT mode only) and break.
628 *
629 * @param a printf argument list (in parenthesis).
630 */
631#ifdef RT_STRICT
632# define AssertMsgFailedBreak(a) \
633 if (1) { \
634 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
635 AssertMsg2 a; \
636 AssertBreakpoint(); \
637 break; \
638 } else do {} while (0)
639#else
640# define AssertMsgFailedBreak(a) \
641 if (1) \
642 break; \
643 else do {} while (0)
644#endif
645
646/** @def AssertMsgFailedBreakStmt
647 * An assertion failed, hit breakpoint (RT_STRICT mode only), execute
648 * the given statement and break.
649 *
650 * @param a printf argument list (in parenthesis).
651 * @param stmt Statement to execute before break.
652 */
653#ifdef RT_STRICT
654# define AssertMsgFailedBreakStmt(a, stmt) \
655 if (1) { \
656 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
657 AssertMsg2 a; \
658 AssertBreakpoint(); \
659 stmt; \
660 break; \
661 } else do {} while (0)
662#else
663# define AssertMsgFailedBreakStmt(a, stmt) \
664 if (1) { \
665 stmt; \
666 break; \
667 } else do {} while (0)
668#endif
669
670
671
672/** @def AssertLogRelBreakpoint()
673 * Assertion LogRel Breakpoint.
674 *
675 * NOP in non-strict (release) builds, hardware breakpoint in strict builds,
676 *
677 * @remark In the gnu world we add a nop instruction after the int3 to
678 * force gdb to remain at the int3 source line.
679 * @remark The L4 kernel will try make sense of the breakpoint, thus the jmp.
680 */
681#ifdef RT_STRICT
682# ifdef __GNUC__
683# ifndef __L4ENV__
684# define AssertLogRelBreakpoint() do { RTAssertDoBreakpoint(); __asm__ __volatile__ ("int3\n\tnop"); } while (0)
685# else
686# define AssertLogRelBreakpoint() do { RTAssertDoBreakpoint(); __asm__ __volatile__ ("int3; jmp 1f; 1:"); } while (0)
687# endif
688# elif defined(_MSC_VER) || defined(DOXYGEN_RUNNING)
689# define AssertLogRelBreakpoint() do { RTAssertDoBreakpoint(); __debugbreak(); } while (0)
690# else
691# error "Unknown compiler"
692# endif
693#else /* !RT_STRICT */
694# define AssertLogRelBreakpoint() do { } while (0)
695#endif /* !RT_STRICT */
696
697
698/** @def AssertLogRelMsg1
699 * AssertMsg1 (strict builds) / LogRel wrapper (non-strict).
700 */
701#ifdef RT_STRICT
702# define AssertLogRelMsg1(pszExpr, iLine, pszFile, pszFunction) \
703 AssertMsg1(pszExpr, iLine, pszFile, pszFunction)
704#else
705# define AssertLogRelMsg1(pszExpr, iLine, pszFile, pszFunction) \
706 LogRel(("AssertLogRel %s(%d) %s: %s\n",\
707 (pszFile), (iLine), (pszFunction), (pszExpr) ))
708#endif
709
710/** @def AssertLogRelMsg2
711 * AssertMsg2 (strict builds) / LogRel wrapper (non-strict).
712 */
713#ifdef RT_STRICT
714# define AssertLogRelMsg2(a) AssertMsg2 a
715#else
716# define AssertLogRelMsg2(a) LogRel(a)
717#endif
718
719/** @def AssertLogRel
720 * Assert that an expression is true.
721 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
722 *
723 * @param expr Expression which should be true.
724 */
725#define AssertLogRel(expr) \
726 do { \
727 if (RT_UNLIKELY(!(expr))) \
728 { \
729 AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
730 AssertLogRelBreakpoint(); \
731 } \
732 } while (0)
733
734/** @def AssertLogRelReturn
735 * Assert that an expression is true, return \a rc if it isn't.
736 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
737 *
738 * @param expr Expression which should be true.
739 * @param rc What is to be presented to return.
740 */
741#define AssertLogRelReturn(expr, rc) \
742 do { \
743 if (RT_UNLIKELY(!(expr))) \
744 { \
745 AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
746 AssertLogRelBreakpoint(); \
747 return (rc); \
748 } \
749 } while (0)
750
751/** @def AssertLogRelReturnVoid
752 * Assert that an expression is true, return void if it isn't.
753 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
754 *
755 * @param expr Expression which should be true.
756 */
757#define AssertLogRelReturnVoid(expr) \
758 do { \
759 if (RT_UNLIKELY(!(expr))) \
760 { \
761 AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
762 AssertLogRelBreakpoint(); \
763 return; \
764 } \
765 } while (0)
766
767/** @def AssertLogRelBreak
768 * Assert that an expression is true, break if it isn't.
769 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
770 *
771 * @param expr Expression which should be true.
772 */
773#define AssertLogRelBreak(expr) \
774 if (RT_UNLIKELY(!(expr))) \
775 { \
776 AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
777 AssertLogRelBreakpoint(); \
778 break; \
779 } \
780 else do {} while (0)
781
782/** @def AssertLogRelBreakStmt
783 * Assert that an expression is true, execute \a stmt and break if it isn't.
784 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
785 *
786 * @param expr Expression which should be true.
787 * @param stmt Statement to execute before break in case of a failed assertion.
788 */
789#define AssertLogRelBreakStmt(expr, stmt) \
790 if (RT_UNLIKELY(!(expr))) \
791 { \
792 AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
793 AssertLogRelBreakpoint(); \
794 stmt; \
795 break; \
796 } else do {} while (0)
797
798/** @def AssertLogRelMsg
799 * Assert that an expression is true.
800 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
801 *
802 * @param expr Expression which should be true.
803 * @param a printf argument list (in parenthesis).
804 */
805#define AssertLogRelMsg(expr, a) \
806 do { \
807 if (RT_UNLIKELY(!(expr))) \
808 { \
809 AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
810 AssertLogRelMsg2(a); \
811 AssertLogRelBreakpoint(); \
812 } \
813 } while (0)
814
815/** @def AssertLogRelMsgReturn
816 * Assert that an expression is true, return \a rc if it isn't.
817 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
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#define AssertLogRelMsgReturn(expr, a, rc) \
824 do { \
825 if (RT_UNLIKELY(!(expr))) \
826 { \
827 AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
828 AssertLogRelMsg2(a); \
829 AssertLogRelBreakpoint(); \
830 return (rc); \
831 } \
832 } while (0)
833
834/** @def AssertLogRelMsgReturnVoid
835 * Assert that an expression is true, return (void) if it isn't.
836 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
837 *
838 * @param expr Expression which should be true.
839 * @param a printf argument list (in parenthesis).
840 */
841#define AssertLogRelMsgReturnVoid(expr, a) \
842 do { \
843 if (RT_UNLIKELY(!(expr))) \
844 { \
845 AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
846 AssertLogRelMsg2(a); \
847 AssertLogRelBreakpoint(); \
848 return; \
849 } \
850 } while (0)
851
852/** @def AssertLogRelMsgBreak
853 * Assert that an expression is true, break if it isn't.
854 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
855 *
856 * @param expr Expression which should be true.
857 * @param a printf argument list (in parenthesis).
858 */
859#define AssertLogRelMsgBreak(expr, a) \
860 if (RT_UNLIKELY(!(expr))) \
861 { \
862 AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
863 AssertLogRelMsg2(a); \
864 AssertLogRelBreakpoint(); \
865 break; \
866 } \
867 else do {} while (0)
868
869/** @def AssertLogRelMsgBreakStmt
870 * Assert that an expression is true, execute \a stmt and break if it isn't.
871 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
872 *
873 * @param expr Expression which should be true.
874 * @param a printf argument list (in parenthesis).
875 * @param stmt Statement to execute before break in case of a failed assertion.
876 */
877#define AssertLogRelMsgBreakStmt(expr, a, stmt) \
878 if (RT_UNLIKELY(!(expr))) \
879 { \
880 AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
881 AssertLogRelMsg2(a); \
882 AssertLogRelBreakpoint(); \
883 stmt; \
884 break; \
885 } else do {} while (0)
886
887/** @def AssertLogRelFailed
888 * An assertion failed.
889 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
890 */
891#define AssertLogRelFailed() \
892 do { \
893 AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
894 AssertLogRelBreakpoint(); \
895 } while (0)
896
897/** @def AssertLogRelFailedReturn
898 * An assertion failed.
899 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
900 *
901 * @param rc What is to be presented to return.
902 */
903#define AssertLogRelFailedReturn(rc) \
904 do { \
905 AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
906 AssertLogRelBreakpoint(); \
907 return (rc); \
908 } while (0)
909
910/** @def AssertLogRelFailedReturnVoid
911 * An assertion failed, hit a breakpoint and return.
912 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
913 */
914#define AssertLogRelFailedReturnVoid() \
915 do { \
916 AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
917 AssertLogRelBreakpoint(); \
918 return; \
919 } while (0)
920
921/** @def AssertLogRelFailedBreak
922 * An assertion failed, break.
923 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
924 */
925#define AssertLogRelFailedBreak() \
926 if (1) \
927 { \
928 AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
929 AssertLogRelBreakpoint(); \
930 break; \
931 } else do {} while (0)
932
933/** @def AssertLogRelFailedBreakStmt
934 * An assertion failed, execute \a stmt and break.
935 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
936 *
937 * @param stmt Statement to execute before break.
938 */
939#define AssertLogRelFailedBreakStmt(stmt) \
940 if (1) \
941 { \
942 AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
943 AssertLogRelBreakpoint(); \
944 stmt; \
945 break; \
946 } else do {} while (0)
947
948/** @def AssertLogRelMsgFailed
949 * An assertion failed.
950 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
951 *
952 * @param a printf argument list (in parenthesis).
953 */
954#define AssertLogRelMsgFailed(a) \
955 do { \
956 AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
957 AssertLogRelMsg2(a); \
958 AssertLogRelBreakpoint(); \
959 } while (0)
960
961/** @def AssertLogRelMsgFailedReturn
962 * An assertion failed, return \a rc.
963 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
964 *
965 * @param a printf argument list (in parenthesis).
966 * @param rc What is to be presented to return.
967 */
968#define AssertLogRelMsgFailedReturn(a, rc) \
969 do { \
970 AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
971 AssertLogRelMsg2(a); \
972 AssertLogRelBreakpoint(); \
973 return (rc); \
974 } while (0)
975
976/** @def AssertLogRelMsgFailedReturnVoid
977 * An assertion failed, return void.
978 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
979 *
980 * @param a printf argument list (in parenthesis).
981 */
982#define AssertLogRelMsgFailedReturnVoid(a) \
983 do { \
984 AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
985 AssertLogRelMsg2(a); \
986 AssertLogRelBreakpoint(); \
987 return; \
988 } while (0)
989
990/** @def AssertLogRelMsgFailedBreak
991 * An assertion failed, break.
992 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
993 *
994 * @param a printf argument list (in parenthesis).
995 */
996#define AssertLogRelMsgFailedBreak(a) \
997 if (1)\
998 { \
999 AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1000 AssertLogRelMsg2(a); \
1001 AssertLogRelBreakpoint(); \
1002 break; \
1003 } else do {} while (0)
1004
1005/** @def AssertLogRelMsgFailedBreakStmt
1006 * An assertion failed, execute \a stmt and break.
1007 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1008 *
1009 * @param a printf argument list (in parenthesis).
1010 * @param stmt Statement to execute before break.
1011 */
1012#define AssertLogRelMsgFailedBreakStmt(a, stmt) \
1013 if (1) \
1014 { \
1015 AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1016 AssertLogRelMsg2(a); \
1017 AssertLogRelBreakpoint(); \
1018 stmt; \
1019 break; \
1020 } else do {} while (0)
1021
1022
1023
1024/** @def AssertReleaseBreakpoint()
1025 * Assertion Breakpoint.
1026 *
1027 * @remark In the gnu world we add a nop instruction after the int3 to
1028 * force gdb to remain at the int3 source line.
1029 * @remark The L4 kernel will try make sense of the breakpoint, thus the jmp.
1030 */
1031#ifdef __GNUC__
1032# ifndef __L4ENV__
1033# define AssertReleaseBreakpoint() do { RTAssertDoBreakpoint(); __asm__ __volatile__ ("int3\n\tnop"); } while (0)
1034# else
1035# define AssertReleaseBreakpoint() do { RTAssertDoBreakpoint(); __asm__ __volatile__ ("int3; jmp 1f; 1:"); } while (0)
1036# endif
1037#elif defined(_MSC_VER) || defined(DOXYGEN_RUNNING)
1038# define AssertReleaseBreakpoint() do { RTAssertDoBreakpoint(); __debugbreak(); } while (0)
1039#else
1040# error "Unknown compiler"
1041#endif
1042
1043
1044/** @def AssertRelease
1045 * Assert that an expression is true. If it's not hit a breakpoint.
1046 *
1047 * @param expr Expression which should be true.
1048 */
1049#define AssertRelease(expr) \
1050 do { \
1051 if (RT_UNLIKELY(!(expr))) \
1052 { \
1053 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1054 AssertReleaseBreakpoint(); \
1055 } \
1056 } while (0)
1057
1058/** @def AssertReleaseReturn
1059 * Assert that an expression is true, hit a breakpoing and return if it isn't.
1060 *
1061 * @param expr Expression which should be true.
1062 * @param rc What is to be presented to return.
1063 */
1064#define AssertReleaseReturn(expr, rc) \
1065 do { \
1066 if (RT_UNLIKELY(!(expr))) \
1067 { \
1068 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1069 AssertReleaseBreakpoint(); \
1070 return (rc); \
1071 } \
1072 } while (0)
1073
1074/** @def AssertReleaseReturnVoid
1075 * Assert that an expression is true, hit a breakpoing and return if it isn't.
1076 *
1077 * @param expr Expression which should be true.
1078 */
1079#define AssertReleaseReturnVoid(expr) \
1080 do { \
1081 if (RT_UNLIKELY(!(expr))) \
1082 { \
1083 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1084 AssertReleaseBreakpoint(); \
1085 return; \
1086 } \
1087 } while (0)
1088
1089
1090/** @def AssertReleaseBreak
1091 * Assert that an expression is true, hit a breakpoing and break if it isn't.
1092 *
1093 * @param expr Expression which should be true.
1094 */
1095#define AssertReleaseBreak(expr) \
1096 if { \
1097 if (RT_UNLIKELY(!(expr))) \
1098 { \
1099 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1100 AssertReleaseBreakpoint(); \
1101 break; \
1102 } \
1103 } else do {} while (0)
1104
1105/** @def AssertReleaseBreakStmt
1106 * Assert that an expression is true, hit a breakpoing and break if it isn't.
1107 *
1108 * @param expr Expression which should be true.
1109 * @param stmt Statement to execute before break in case of a failed assertion.
1110 */
1111#define AssertReleaseBreakStmt(expr, stmt) \
1112 if (RT_UNLIKELY(!(expr))) \
1113 { \
1114 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1115 AssertReleaseBreakpoint(); \
1116 stmt; \
1117 break; \
1118 } else do {} while (0)
1119
1120
1121/** @def AssertReleaseMsg
1122 * Assert that an expression is true, print the message and hit a breakpoint if it isn't.
1123 *
1124 * @param expr Expression which should be true.
1125 * @param a printf argument list (in parenthesis).
1126 */
1127#define AssertReleaseMsg(expr, a) \
1128 do { \
1129 if (RT_UNLIKELY(!(expr))) \
1130 { \
1131 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1132 AssertMsg2 a; \
1133 AssertReleaseBreakpoint(); \
1134 } \
1135 } while (0)
1136
1137/** @def AssertReleaseMsgReturn
1138 * Assert that an expression is true, print the message and hit a breakpoint and return if it isn't.
1139 *
1140 * @param expr Expression which should be true.
1141 * @param a printf argument list (in parenthesis).
1142 * @param rc What is to be presented to return.
1143 */
1144#define AssertReleaseMsgReturn(expr, a, rc) \
1145 do { \
1146 if (RT_UNLIKELY(!(expr))) \
1147 { \
1148 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1149 AssertMsg2 a; \
1150 AssertReleaseBreakpoint(); \
1151 return (rc); \
1152 } \
1153 } while (0)
1154
1155/** @def AssertReleaseMsgReturnVoid
1156 * Assert that an expression is true, print the message and hit a breakpoint and return if it isn't.
1157 *
1158 * @param expr Expression which should be true.
1159 * @param a printf argument list (in parenthesis).
1160 */
1161#define AssertReleaseMsgReturnVoid(expr, a) \
1162 do { \
1163 if (RT_UNLIKELY(!(expr))) \
1164 { \
1165 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1166 AssertMsg2 a; \
1167 AssertReleaseBreakpoint(); \
1168 return; \
1169 } \
1170 } while (0)
1171
1172
1173/** @def AssertReleaseMsgBreak
1174 * Assert that an expression is true, print the message and hit a breakpoint and break if it isn't.
1175 *
1176 * @param expr Expression which should be true.
1177 * @param a printf argument list (in parenthesis).
1178 */
1179#define AssertReleaseMsgBreak(expr, a) \
1180 if (RT_UNLIKELY(!(expr))) \
1181 { \
1182 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1183 AssertMsg2 a; \
1184 AssertReleaseBreakpoint(); \
1185 break; \
1186 } else do {} while (0)
1187
1188/** @def AssertReleaseMsgBreakStmt
1189 * Assert that an expression is true, print the message and hit a breakpoing and break if it isn't.
1190 *
1191 * @param expr Expression which should be true.
1192 * @param a printf argument list (in parenthesis).
1193 * @param stmt Statement to execute before break in case of a failed assertion.
1194 */
1195#define AssertReleaseMsgBreakStmt(expr, a, stmt) \
1196 if (RT_UNLIKELY(!(expr))) { \
1197 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1198 AssertMsg2 a; \
1199 AssertReleaseBreakpoint(); \
1200 stmt; \
1201 break; \
1202 } else do {} while (0)
1203
1204
1205/** @def AssertReleaseFailed
1206 * An assertion failed, hit a breakpoint.
1207 */
1208#define AssertReleaseFailed() \
1209 do { \
1210 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1211 AssertReleaseBreakpoint(); \
1212 } while (0)
1213
1214/** @def AssertReleaseFailedReturn
1215 * An assertion failed, hit a breakpoint and return.
1216 *
1217 * @param rc What is to be presented to return.
1218 */
1219#define AssertReleaseFailedReturn(rc) \
1220 do { \
1221 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1222 AssertReleaseBreakpoint(); \
1223 return (rc); \
1224 } while (0)
1225
1226/** @def AssertReleaseFailedReturnVoid
1227 * An assertion failed, hit a breakpoint and return.
1228 */
1229#define AssertReleaseFailedReturnVoid() \
1230 do { \
1231 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1232 AssertReleaseBreakpoint(); \
1233 return; \
1234 } while (0)
1235
1236
1237/** @def AssertReleaseFailedBreak
1238 * An assertion failed, hit a breakpoint and break.
1239 */
1240#define AssertReleaseFailedBreak() \
1241 if (1) { \
1242 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1243 AssertReleaseBreakpoint(); \
1244 break; \
1245 } else do {} while (0)
1246
1247/** @def AssertReleaseFailedBreakStmt
1248 * An assertion failed, hit a breakpoint and break.
1249 *
1250 * @param stmt Statement to execute before break.
1251 */
1252#define AssertReleaseFailedBreakStmt(stmt) \
1253 if (1) { \
1254 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1255 AssertReleaseBreakpoint(); \
1256 stmt; \
1257 break; \
1258 } else do {} while (0)
1259
1260
1261/** @def AssertReleaseMsgFailed
1262 * An assertion failed, print a message and hit a breakpoint.
1263 *
1264 * @param a printf argument list (in parenthesis).
1265 */
1266#define AssertReleaseMsgFailed(a) \
1267 do { \
1268 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1269 AssertMsg2 a; \
1270 AssertReleaseBreakpoint(); \
1271 } while (0)
1272
1273/** @def AssertReleaseMsgFailedReturn
1274 * An assertion failed, print a message, hit a breakpoint and return.
1275 *
1276 * @param a printf argument list (in parenthesis).
1277 * @param rc What is to be presented to return.
1278 */
1279#define AssertReleaseMsgFailedReturn(a, rc) \
1280 do { \
1281 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1282 AssertMsg2 a; \
1283 AssertReleaseBreakpoint(); \
1284 return (rc); \
1285 } while (0)
1286
1287/** @def AssertReleaseMsgFailedReturnVoid
1288 * An assertion failed, print a message, hit a breakpoint and return.
1289 *
1290 * @param a printf argument list (in parenthesis).
1291 */
1292#define AssertReleaseMsgFailedReturnVoid(a) \
1293 do { \
1294 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1295 AssertMsg2 a; \
1296 AssertReleaseBreakpoint(); \
1297 return; \
1298 } while (0)
1299
1300
1301/** @def AssertReleaseMsgFailedBreak
1302 * An assertion failed, print a message, hit a breakpoint and break.
1303 *
1304 * @param a printf argument list (in parenthesis).
1305 */
1306#define AssertReleaseMsgFailedBreak(a) \
1307 if (1) { \
1308 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1309 AssertMsg2 a; \
1310 AssertReleaseBreakpoint(); \
1311 break; \
1312 } else do {} while (0)
1313
1314/** @def AssertReleaseMsgFailedBreakStmt
1315 * An assertion failed, print a message, hit a breakpoint and break.
1316 *
1317 * @param a printf argument list (in parenthesis).
1318 * @param stmt Statement to execute before break.
1319 */
1320#define AssertReleaseMsgFailedBreakStmt(a, stmt) \
1321 if (1) { \
1322 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1323 AssertMsg2 a; \
1324 AssertReleaseBreakpoint(); \
1325 stmt; \
1326 break; \
1327 } else do {} while (0)
1328
1329
1330/** @def AssertFatal
1331 * Assert that an expression is true. If it's not hit a breakpoint (for ever).
1332 *
1333 * @param expr Expression which should be true.
1334 */
1335#define AssertFatal(expr) \
1336 do { \
1337 if (RT_UNLIKELY(!(expr))) \
1338 for (;;) \
1339 { \
1340 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1341 AssertReleaseBreakpoint(); \
1342 } \
1343 } while (0)
1344
1345/** @def AssertFatalMsg
1346 * Assert that an expression is true, print the message and hit a breakpoint (for ever) if it isn't.
1347 *
1348 * @param expr Expression which should be true.
1349 * @param a printf argument list (in parenthesis).
1350 */
1351#define AssertFatalMsg(expr, a) \
1352 do { \
1353 if (RT_UNLIKELY(!(expr))) \
1354 for (;;) \
1355 { \
1356 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1357 AssertMsg2 a; \
1358 AssertReleaseBreakpoint(); \
1359 } \
1360 } while (0)
1361
1362/** @def AssertFatalFailed
1363 * An assertion failed, hit a breakpoint (for ever).
1364 */
1365#define AssertFatalFailed() \
1366 do { \
1367 for (;;) \
1368 { \
1369 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1370 AssertReleaseBreakpoint(); \
1371 } \
1372 } while (0)
1373
1374/** @def AssertFatalMsgFailed
1375 * An assertion failed, print a message and hit a breakpoint (for ever).
1376 *
1377 * @param a printf argument list (in parenthesis).
1378 */
1379#define AssertFatalMsgFailed(a) \
1380 do { \
1381 for (;;) \
1382 { \
1383 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1384 AssertMsg2 a; \
1385 AssertReleaseBreakpoint(); \
1386 } \
1387 } while (0)
1388
1389
1390/** @def AssertRC
1391 * Asserts a iprt status code successful.
1392 *
1393 * On failure it will print info about the rc and hit a breakpoint.
1394 *
1395 * @param rc iprt status code.
1396 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1397 */
1398#define AssertRC(rc) AssertMsgRC(rc, ("%Rra\n", (rc)))
1399
1400/** @def AssertRCReturn
1401 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return if it isn't.
1402 *
1403 * @param rc iprt status code.
1404 * @param rcRet What is to be presented to return.
1405 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1406 */
1407#define AssertRCReturn(rc, rcRet) AssertMsgRCReturn(rc, ("%Rra\n", (rc)), rcRet)
1408
1409/** @def AssertRCReturnVoid
1410 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return if it isn't.
1411 *
1412 * @param rc iprt status code.
1413 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1414 */
1415#define AssertRCReturnVoid(rc) AssertMsgRCReturnVoid(rc, ("%Rra\n", (rc)))
1416
1417/** @def AssertRCBreak
1418 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break if it isn't.
1419 *
1420 * @param rc iprt status code.
1421 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1422 */
1423#define AssertRCBreak(rc) AssertMsgRCBreak(rc, ("%Rra\n", (rc)))
1424
1425/** @def AssertRCBreakStmt
1426 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break if it isn't.
1427 *
1428 * @param rc iprt status code.
1429 * @param stmt Statement to execute before break in case of a failed assertion.
1430 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1431 */
1432#define AssertRCBreakStmt(rc, stmt) AssertMsgRCBreakStmt(rc, ("%Rra\n", (rc)), stmt)
1433
1434/** @def AssertMsgRC
1435 * Asserts a iprt status code successful.
1436 *
1437 * It prints a custom message and hits a breakpoint on FAILURE.
1438 *
1439 * @param rc iprt status code.
1440 * @param msg printf argument list (in parenthesis).
1441 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1442 */
1443#define AssertMsgRC(rc, msg) \
1444 do { AssertMsg(RT_SUCCESS_NP(rc), msg); NOREF(rc); } while (0)
1445
1446/** @def AssertMsgRCReturn
1447 * Asserts a iprt status code successful and if it's not return the specified status code.
1448 *
1449 * If RT_STRICT is defined the message will be printed and a breakpoint hit before it returns
1450 *
1451 * @param rc iprt status code.
1452 * @param msg printf argument list (in parenthesis).
1453 * @param rcRet What is to be presented to return.
1454 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1455 */
1456#define AssertMsgRCReturn(rc, msg, rcRet) \
1457 do { AssertMsgReturn(RT_SUCCESS_NP(rc), msg, rcRet); NOREF(rc); } while (0)
1458
1459/** @def AssertMsgRCReturnVoid
1460 * Asserts a iprt status code successful and if it's not return.
1461 *
1462 * If RT_STRICT is defined the message will be printed and a breakpoint hit before it returns
1463 *
1464 * @param rc iprt status code.
1465 * @param msg printf argument list (in parenthesis).
1466 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1467 */
1468#define AssertMsgRCReturnVoid(rc, msg) \
1469 do { AssertMsgReturnVoid(RT_SUCCESS_NP(rc), msg); NOREF(rc); } while (0)
1470
1471/** @def AssertMsgRCBreak
1472 * Asserts a iprt status code successful and if it's not break.
1473 *
1474 * If RT_STRICT is defined the message will be printed and a breakpoint hit before it breaks
1475 *
1476 * @param rc iprt status code.
1477 * @param msg printf argument list (in parenthesis).
1478 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1479 */
1480#define AssertMsgRCBreak(rc, msg) \
1481 if (1) { AssertMsgBreak(RT_SUCCESS(rc), msg); NOREF(rc); } else do {} while (0)
1482
1483/** @def AssertMsgRCBreakStmt
1484 * Asserts a iprt status code successful and break if it's not.
1485 *
1486 * If RT_STRICT is defined the message will be printed and a breakpoint hit before it returns
1487 *
1488 * @param rc iprt status code.
1489 * @param msg printf argument list (in parenthesis).
1490 * @param stmt Statement to execute before break in case of a failed assertion.
1491 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1492 */
1493#define AssertMsgRCBreakStmt(rc, msg, stmt) \
1494 if (1) { AssertMsgBreakStmt(RT_SUCCESS_NP(rc), msg, stmt); NOREF(rc); } else do {} while (0)
1495
1496/** @def AssertRCSuccess
1497 * Asserts an iprt status code equals VINF_SUCCESS.
1498 *
1499 * On failure it will print info about the rc and hit a breakpoint.
1500 *
1501 * @param rc iprt status code.
1502 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1503 */
1504#define AssertRCSuccess(rc) AssertMsg((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
1505
1506/** @def AssertRCSuccessReturn
1507 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and return if it isn't.
1508 *
1509 * @param rc iprt status code.
1510 * @param rcRet What is to be presented to return.
1511 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1512 */
1513#define AssertRCSuccessReturn(rc, rcRet) AssertMsgReturn((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), rcRet)
1514
1515/** @def AssertRCSuccessReturnVoid
1516 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and return if it isn't.
1517 *
1518 * @param rc iprt status code.
1519 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1520 */
1521#define AssertRCSuccessReturnVoid(rc) AssertMsgReturnVoid((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
1522
1523/** @def AssertRCSuccessBreak
1524 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and break if it isn't.
1525 *
1526 * @param rc iprt status code.
1527 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1528 */
1529#define AssertRCSuccessBreak(rc) AssertMsgBreak((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
1530
1531/** @def AssertRCSuccessBreakStmt
1532 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and break if it isn't.
1533 *
1534 * @param rc iprt status code.
1535 * @param stmt Statement to execute before break in case of a failed assertion.
1536 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1537 */
1538#define AssertRCSuccessBreakStmt(rc, stmt) AssertMsgBreakStmt((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), stmt)
1539
1540
1541/** @def AssertLogRelRC
1542 * Asserts a iprt status code successful.
1543 *
1544 * @param rc iprt status code.
1545 * @remark rc is references multiple times.
1546 */
1547#define AssertLogRelRC(rc) AssertLogRelMsgRC(rc, ("%Rra\n", (rc)))
1548
1549/** @def AssertLogRelRCReturn
1550 * Asserts a iprt status code successful, returning \a rc if it isn't.
1551 *
1552 * @param rc iprt status code.
1553 * @param rcRet What is to be presented to return.
1554 * @remark rc is references multiple times.
1555 */
1556#define AssertLogRelRCReturn(rc, rcRet) AssertLogRelMsgRCReturn(rc, ("%Rra\n", (rc)), rcRet)
1557
1558/** @def AssertLogRelRCReturnVoid
1559 * Asserts a iprt status code successful, returning (void) if it isn't.
1560 *
1561 * @param rc iprt status code.
1562 * @remark rc is references multiple times.
1563 */
1564#define AssertLogRelRCReturnVoid(rc) AssertLogRelMsgRCReturnVoid(rc, ("%Rra\n", (rc)))
1565
1566/** @def AssertLogRelRCBreak
1567 * Asserts a iprt status code successful, breaking if it isn't.
1568 *
1569 * @param rc iprt status code.
1570 * @remark rc is references multiple times.
1571 */
1572#define AssertLogRelRCBreak(rc) AssertLogRelMsgRCBreak(rc, ("%Rra\n", (rc)))
1573
1574/** @def AssertLogRelRCBreakStmt
1575 * Asserts a iprt status code successful, execute \a statement and break if it isn't.
1576 *
1577 * @param rc iprt status code.
1578 * @param stmt Statement to execute before break in case of a failed assertion.
1579 * @remark rc is references multiple times.
1580 */
1581#define AssertLogRelRCBreakStmt(rc, stmt) AssertLogRelMsgRCBreakStmt(rc, ("%Rra\n", (rc)), stmt)
1582
1583/** @def AssertLogRelMsgRC
1584 * Asserts a iprt status code successful.
1585 *
1586 * @param rc iprt status code.
1587 * @param msg printf argument list (in parenthesis).
1588 * @remark rc is references multiple times.
1589 */
1590#define AssertLogRelMsgRC(rc, msg) AssertLogRelMsg(RT_SUCCESS_NP(rc), msg)
1591
1592/** @def AssertLogRelMsgRCReturn
1593 * Asserts a iprt status code successful.
1594 *
1595 * @param rc iprt status code.
1596 * @param msg printf argument list (in parenthesis).
1597 * @param rcRet What is to be presented to return.
1598 * @remark rc is references multiple times.
1599 */
1600#define AssertLogRelMsgRCReturn(rc, msg, rcRet) AssertLogRelMsgReturn(RT_SUCCESS_NP(rc), msg, rcRet)
1601
1602/** @def AssertLogRelMsgRCReturnVoid
1603 * Asserts a iprt status code successful.
1604 *
1605 * @param rc iprt status code.
1606 * @param msg printf argument list (in parenthesis).
1607 * @remark rc is references multiple times.
1608 */
1609#define AssertLogRelMsgRCReturnVoid(rc, msg) AssertLogRelMsgReturnVoid(RT_SUCCESS_NP(rc), msg)
1610
1611/** @def AssertLogRelMsgRCBreak
1612 * Asserts a iprt status code successful.
1613 *
1614 * @param rc iprt status code.
1615 * @param msg printf argument list (in parenthesis).
1616 * @remark rc is references multiple times.
1617 */
1618#define AssertLogRelMsgRCBreak(rc, msg) AssertLogRelMsgBreak(RT_SUCCESS(rc), msg)
1619
1620/** @def AssertLogRelMsgRCBreakStmt
1621 * Asserts a iprt status code successful, execute \a stmt and break if it isn't.
1622 *
1623 * @param rc iprt status code.
1624 * @param msg printf argument list (in parenthesis).
1625 * @param stmt Statement to execute before break in case of a failed assertion.
1626 * @remark rc is references multiple times.
1627 */
1628#define AssertLogRelMsgRCBreakStmt(rc, msg, stmt) AssertLogRelMsgBreakStmt(RT_SUCCESS_NP(rc), msg, stmt)
1629
1630/** @def AssertLogRelRCSuccess
1631 * Asserts that an iprt status code equals VINF_SUCCESS.
1632 *
1633 * @param rc iprt status code.
1634 * @remark rc is references multiple times.
1635 */
1636#define AssertLogRelRCSuccess(rc) AssertLogRelMsg((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
1637
1638/** @def AssertLogRelRCSuccessReturn
1639 * Asserts that an iprt status code equals VINF_SUCCESS.
1640 *
1641 * @param rc iprt status code.
1642 * @param rcRet What is to be presented to return.
1643 * @remark rc is references multiple times.
1644 */
1645#define AssertLogRelRCSuccessReturn(rc, rcRet) AssertLogRelMsgReturn((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), rcRet)
1646
1647/** @def AssertLogRelRCSuccessReturnVoid
1648 * Asserts that an iprt status code equals VINF_SUCCESS.
1649 *
1650 * @param rc iprt status code.
1651 * @remark rc is references multiple times.
1652 */
1653#define AssertLogRelRCSuccessReturnVoid(rc) AssertLogRelMsgReturnVoid((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
1654
1655/** @def AssertLogRelRCSuccessBreak
1656 * Asserts that an iprt status code equals VINF_SUCCESS.
1657 *
1658 * @param rc iprt status code.
1659 * @remark rc is references multiple times.
1660 */
1661#define AssertLogRelRCSuccessBreak(rc) AssertLogRelMsgBreak((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
1662
1663/** @def AssertLogRelRCSuccessBreakStmt
1664 * Asserts that an iprt status code equals VINF_SUCCESS.
1665 *
1666 * @param rc iprt status code.
1667 * @param stmt Statement to execute before break in case of a failed assertion.
1668 * @remark rc is references multiple times.
1669 */
1670#define AssertLogRelRCSuccessBreakStmt(rc, stmt) AssertLogRelMsgBreakStmt((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), stmt)
1671
1672
1673/** @def AssertReleaseRC
1674 * Asserts a iprt status code successful.
1675 *
1676 * On failure information about the error will be printed and a breakpoint hit.
1677 *
1678 * @param rc iprt status code.
1679 * @remark rc is references multiple times.
1680 */
1681#define AssertReleaseRC(rc) AssertReleaseMsgRC(rc, ("%Rra\n", (rc)))
1682
1683/** @def AssertReleaseRCReturn
1684 * Asserts a iprt status code successful, returning if it isn't.
1685 *
1686 * On failure information about the error will be printed, a breakpoint hit
1687 * and finally returning from the function if the breakpoint is somehow ignored.
1688 *
1689 * @param rc iprt status code.
1690 * @param rcRet What is to be presented to return.
1691 * @remark rc is references multiple times.
1692 */
1693#define AssertReleaseRCReturn(rc, rcRet) AssertReleaseMsgRCReturn(rc, ("%Rra\n", (rc)), rcRet)
1694
1695/** @def AssertReleaseRCReturnVoid
1696 * Asserts a iprt status code successful, returning if it isn't.
1697 *
1698 * On failure information about the error will be printed, a breakpoint hit
1699 * and finally returning from the function if the breakpoint is somehow ignored.
1700 *
1701 * @param rc iprt status code.
1702 * @remark rc is references multiple times.
1703 */
1704#define AssertReleaseRCReturnVoid(rc) AssertReleaseMsgRCReturnVoid(rc, ("%Rra\n", (rc)))
1705
1706/** @def AssertReleaseRCBreak
1707 * Asserts a iprt status code successful, breaking if it isn't.
1708 *
1709 * On failure information about the error will be printed, a breakpoint hit
1710 * and finally breaking the current statement if the breakpoint is somehow ignored.
1711 *
1712 * @param rc iprt status code.
1713 * @remark rc is references multiple times.
1714 */
1715#define AssertReleaseRCBreak(rc) AssertReleaseMsgRCBreak(rc, ("%Rra\n", (rc)))
1716
1717/** @def AssertReleaseRCBreakStmt
1718 * Asserts a iprt status code successful, break if it isn't.
1719 *
1720 * On failure information about the error will be printed, a breakpoint hit
1721 * and finally the break statement will be issued if the breakpoint is somehow ignored.
1722 *
1723 * @param rc iprt status code.
1724 * @param stmt Statement to execute before break in case of a failed assertion.
1725 * @remark rc is references multiple times.
1726 */
1727#define AssertReleaseRCBreakStmt(rc, stmt) AssertReleaseMsgRCBreakStmt(rc, ("%Rra\n", (rc)), stmt)
1728
1729/** @def AssertReleaseMsgRC
1730 * Asserts a iprt status code successful.
1731 *
1732 * On failure a custom message is printed and a breakpoint is hit.
1733 *
1734 * @param rc iprt status code.
1735 * @param msg printf argument list (in parenthesis).
1736 * @remark rc is references multiple times.
1737 */
1738#define AssertReleaseMsgRC(rc, msg) AssertReleaseMsg(RT_SUCCESS_NP(rc), msg)
1739
1740/** @def AssertReleaseMsgRCReturn
1741 * Asserts a iprt status code successful.
1742 *
1743 * On failure a custom message is printed, a breakpoint is hit, and finally
1744 * returning from the function if the breakpoint is showhow ignored.
1745 *
1746 * @param rc iprt status code.
1747 * @param msg printf argument list (in parenthesis).
1748 * @param rcRet What is to be presented to return.
1749 * @remark rc is references multiple times.
1750 */
1751#define AssertReleaseMsgRCReturn(rc, msg, rcRet) AssertReleaseMsgReturn(RT_SUCCESS_NP(rc), msg, rcRet)
1752
1753/** @def AssertReleaseMsgRCReturnVoid
1754 * Asserts a iprt status code successful.
1755 *
1756 * On failure a custom message is printed, a breakpoint is hit, and finally
1757 * returning from the function if the breakpoint is showhow ignored.
1758 *
1759 * @param rc iprt status code.
1760 * @param msg printf argument list (in parenthesis).
1761 * @remark rc is references multiple times.
1762 */
1763#define AssertReleaseMsgRCReturnVoid(rc, msg) AssertReleaseMsgReturnVoid(RT_SUCCESS_NP(rc), msg)
1764
1765/** @def AssertReleaseMsgRCBreak
1766 * Asserts a iprt status code successful.
1767 *
1768 * On failure a custom message is printed, a breakpoint is hit, and finally
1769 * breaking the current status if the breakpoint is showhow ignored.
1770 *
1771 * @param rc iprt status code.
1772 * @param msg printf argument list (in parenthesis).
1773 * @remark rc is references multiple times.
1774 */
1775#define AssertReleaseMsgRCBreak(rc, msg) AssertReleaseMsgBreak(RT_SUCCESS(rc), msg)
1776
1777/** @def AssertReleaseMsgRCBreakStmt
1778 * Asserts a iprt status code successful.
1779 *
1780 * On failure a custom message is printed, a breakpoint is hit, and finally
1781 * the brean statement is issued if the breakpoint is showhow ignored.
1782 *
1783 * @param rc iprt status code.
1784 * @param msg printf argument list (in parenthesis).
1785 * @param stmt Statement to execute before break in case of a failed assertion.
1786 * @remark rc is references multiple times.
1787 */
1788#define AssertReleaseMsgRCBreakStmt(rc, msg, stmt) AssertReleaseMsgBreakStmt(RT_SUCCESS_NP(rc), msg, stmt)
1789
1790/** @def AssertReleaseRCSuccess
1791 * Asserts that an iprt status code equals VINF_SUCCESS.
1792 *
1793 * On failure information about the error will be printed and a breakpoint hit.
1794 *
1795 * @param rc iprt status code.
1796 * @remark rc is references multiple times.
1797 */
1798#define AssertReleaseRCSuccess(rc) AssertReleaseMsg((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
1799
1800/** @def AssertReleaseRCSuccessReturn
1801 * Asserts that an iprt status code equals VINF_SUCCESS.
1802 *
1803 * On failure information about the error will be printed, a breakpoint hit
1804 * and finally returning from the function if the breakpoint is somehow ignored.
1805 *
1806 * @param rc iprt status code.
1807 * @param rcRet What is to be presented to return.
1808 * @remark rc is references multiple times.
1809 */
1810#define AssertReleaseRCSuccessReturn(rc, rcRet) AssertReleaseMsgReturn((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), rcRet)
1811
1812/** @def AssertReleaseRCSuccessReturnVoid
1813 * Asserts that an iprt status code equals VINF_SUCCESS.
1814 *
1815 * On failure information about the error will be printed, a breakpoint hit
1816 * and finally returning from the function if the breakpoint is somehow ignored.
1817 *
1818 * @param rc iprt status code.
1819 * @remark rc is references multiple times.
1820 */
1821#define AssertReleaseRCSuccessReturnVoid(rc) AssertReleaseMsgReturnVoid((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
1822
1823/** @def AssertReleaseRCSuccessBreak
1824 * Asserts that an iprt status code equals VINF_SUCCESS.
1825 *
1826 * On failure information about the error will be printed, a breakpoint hit
1827 * and finally breaking the current statement if the breakpoint is somehow ignored.
1828 *
1829 * @param rc iprt status code.
1830 * @remark rc is references multiple times.
1831 */
1832#define AssertReleaseRCSuccessBreak(rc) AssertReleaseMsgBreak((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
1833
1834/** @def AssertReleaseRCSuccessBreakStmt
1835 * Asserts that an iprt status code equals VINF_SUCCESS.
1836 *
1837 * On failure information about the error will be printed, a breakpoint hit
1838 * and finally the break statement will be issued if the breakpoint is somehow ignored.
1839 *
1840 * @param rc iprt status code.
1841 * @param stmt Statement to execute before break in case of a failed assertion.
1842 * @remark rc is references multiple times.
1843 */
1844#define AssertReleaseRCSuccessBreakStmt(rc, stmt) AssertReleaseMsgBreakStmt((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), stmt)
1845
1846
1847/** @def AssertFatalRC
1848 * Asserts a iprt status code successful.
1849 *
1850 * On failure information about the error will be printed and a breakpoint hit.
1851 *
1852 * @param rc iprt status code.
1853 * @remark rc is references multiple times.
1854 */
1855#define AssertFatalRC(rc) AssertFatalMsgRC(rc, ("%Rra\n", (rc)))
1856
1857/** @def AssertReleaseMsgRC
1858 * Asserts a iprt status code successful.
1859 *
1860 * On failure a custom message is printed and a breakpoint is hit.
1861 *
1862 * @param rc iprt status code.
1863 * @param msg printf argument list (in parenthesis).
1864 * @remark rc is references multiple times.
1865 */
1866#define AssertFatalMsgRC(rc, msg) AssertFatalMsg(RT_SUCCESS_NP(rc), msg)
1867
1868/** @def AssertFatalRCSuccess
1869 * Asserts that an iprt status code equals VINF_SUCCESS.
1870 *
1871 * On failure information about the error will be printed and a breakpoint hit.
1872 *
1873 * @param rc iprt status code.
1874 * @remark rc is references multiple times.
1875 */
1876#define AssertFatalRCSuccess(rc) AssertFatalMsg((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
1877
1878
1879/** @def AssertPtr
1880 * Asserts that a pointer is valid.
1881 *
1882 * @param pv The pointer.
1883 */
1884#define AssertPtr(pv) AssertMsg(VALID_PTR(pv), ("%p\n", (pv)))
1885
1886/** @def AssertPtrReturn
1887 * Asserts that a pointer is valid.
1888 *
1889 * @param pv The pointer.
1890 * @param rcRet What is to be presented to return.
1891 */
1892#define AssertPtrReturn(pv, rcRet) AssertMsgReturn(VALID_PTR(pv), ("%p\n", (pv)), rcRet)
1893
1894/** @def AssertPtrReturnVoid
1895 * Asserts that a pointer is valid.
1896 *
1897 * @param pv The pointer.
1898 */
1899#define AssertPtrReturnVoid(pv) AssertMsgReturnVoid(VALID_PTR(pv), ("%p\n", (pv)))
1900
1901/** @def AssertPtrBreak
1902 * Asserts that a pointer is valid.
1903 *
1904 * @param pv The pointer.
1905 */
1906#define AssertPtrBreak(pv) AssertMsgBreak(VALID_PTR(pv), ("%p\n", (pv)))
1907
1908/** @def AssertPtrBreakStmt
1909 * Asserts that a pointer is valid.
1910 *
1911 * @param pv The pointer.
1912 * @param stmt Statement to execute before break in case of a failed assertion.
1913 */
1914#define AssertPtrBreakStmt(pv, stmt) AssertMsgBreakStmt(VALID_PTR(pv), ("%p\n", (pv)), stmt)
1915
1916/** @def AssertPtrNull
1917 * Asserts that a pointer is valid or NULL.
1918 *
1919 * @param pv The pointer.
1920 */
1921#define AssertPtrNull(pv) AssertMsg(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)))
1922
1923/** @def AssertPtrNullReturn
1924 * Asserts that a pointer is valid or NULL.
1925 *
1926 * @param pv The pointer.
1927 * @param rcRet What is to be presented to return.
1928 */
1929#define AssertPtrNullReturn(pv, rcRet) AssertMsgReturn(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)), rcRet)
1930
1931/** @def AssertPtrNullReturnVoid
1932 * Asserts that a pointer is valid or NULL.
1933 *
1934 * @param pv The pointer.
1935 */
1936#define AssertPtrNullReturnVoid(pv) AssertMsgReturnVoid(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)))
1937
1938/** @def AssertPtrNullBreak
1939 * Asserts that a pointer is valid or NULL.
1940 *
1941 * @param pv The pointer.
1942 */
1943#define AssertPtrNullBreak(pv) AssertMsgBreak(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)))
1944
1945/** @def AssertPtrNullBreakStmt
1946 * Asserts that a pointer is valid or NULL.
1947 *
1948 * @param pv The pointer.
1949 * @param stmt Statement to execute before break in case of a failed assertion.
1950 */
1951#define AssertPtrNullBreakStmt(pv, stmt) AssertMsgBreakStmt(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)), stmt)
1952
1953/** @def AssertGCPhys32
1954 * Asserts that the high dword of a physical address is zero
1955 *
1956 * @param GCPhys The address (RTGCPHYS).
1957 */
1958#define AssertGCPhys32(GCPhys) AssertMsg(VALID_PHYS32(GCPhys), ("%RGp\n", (RTGCPHYS)(GCPhys)))
1959
1960
1961/** @} */
1962
1963#endif
1964
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