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