VirtualBox

Changeset 104808 in vbox


Ignore:
Timestamp:
May 28, 2024 10:46:02 PM (12 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
163383
Message:

iprt/assert.h: Added AssertLogRelReturnStmt & AssertLogRelReturnVoidStmt. bugref:10687

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/assert.h

    r103638 r104808  
    11981198    } while (0)
    11991199
     1200/** @def AssertLogRelReturnStmt
     1201 * Assert that an expression is true, execute \a stmt & return \a rc if it
     1202 * isn't. Strict builds will hit a breakpoint, non-strict will only do LogRel.
     1203 *
     1204 * @param   expr    Expression which should be true.
     1205 * @param   stmt    Statement to execute before break in case of a failed
     1206 *                  assertion.
     1207 * @param   rc      What is to be presented to return.
     1208 */
     1209#define AssertLogRelReturnStmt(expr, stmt, rc) \
     1210    do { \
     1211        if (RT_LIKELY(!!(expr))) \
     1212        { /* likely */ } \
     1213        else \
     1214        { \
     1215            RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
     1216            RTAssertPanic(); \
     1217            stmt; \
     1218            return (rc); \
     1219        } \
     1220    } while (0)
     1221
    12001222/** @def AssertLogRelReturnVoid
    12011223 * Assert that an expression is true, return void if it isn't.
     
    12121234            RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
    12131235            RTAssertPanic(); \
     1236            return; \
     1237        } \
     1238    } while (0)
     1239
     1240/** @def AssertLogRelReturnVoidStmt
     1241 * Assert that an expression is true, execute \a stmt & return void if it isn't.
     1242 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
     1243 *
     1244 * @param   expr    Expression which should be true.
     1245 * @param   stmt    Statement to execute before break in case of a failed
     1246 *                  assertion.
     1247 */
     1248#define AssertLogRelReturnVoidStmt(expr, stmt) \
     1249    do { \
     1250        if (RT_LIKELY(!!(expr))) \
     1251        { /* likely */ } \
     1252        else \
     1253        { \
     1254            RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
     1255            RTAssertPanic(); \
     1256            stmt; \
    12141257            return; \
    12151258        } \
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette