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