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