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