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