VirtualBox

Changeset 33520 in vbox for trunk/include/iprt


Ignore:
Timestamp:
Oct 27, 2010 3:20:10 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
67114
Message:

iprt/assert.h: Added AssertLogRelMsgStmt, AssertLogRelMsgReturnStmt, AssertLogRelRCReturnStmt and AssertLogRelMsgRCReturnStmt. (The Assert*Stmt macros are currently added when needed.)

File:
1 edited

Legend:

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

    r32671 r33520  
    13231323    } while (0)
    13241324
     1325/** @def AssertLogRelMsgStmt
     1326 * Assert that an expression is true, execute \a stmt and break if it isn't
     1327 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
     1328 *
     1329 * @param   expr    Expression which should be true.
     1330 * @param   a       printf argument list (in parenthesis).
     1331 * @param   stmt    Statement to execute in case of a failed assertion.
     1332 */
     1333#define AssertLogRelMsgStmt(expr, a, stmt) \
     1334    do { \
     1335        if (RT_UNLIKELY(!(expr))) \
     1336        { \
     1337            RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
     1338            RTAssertLogRelMsg2(a); \
     1339            RTAssertPanic(); \
     1340            stmt; \
     1341        } \
     1342    } while (0)
     1343
    13251344/** @def AssertLogRelMsgReturn
    13261345 * Assert that an expression is true, return \a rc if it isn't.
     
    13381357            RTAssertLogRelMsg2(a); \
    13391358            RTAssertPanic(); \
     1359            return (rc); \
     1360        } \
     1361    } while (0)
     1362
     1363/** @def AssertLogRelMsgReturnStmt
     1364 * Assert that an expression is true, execute \a stmt and return \a rc if it
     1365 * isn't.
     1366 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
     1367 *
     1368 * @param   expr    Expression which should be true.
     1369 * @param   a       printf argument list (in parenthesis).
     1370 * @param   rc      What is to be presented to return.
     1371 * @param   stmt    Statement to execute before return in case of a failed
     1372 *                  assertion.
     1373 */
     1374#define AssertLogRelMsgReturnStmt(expr, a, rc, stmt) \
     1375    do { \
     1376        if (RT_UNLIKELY(!(expr))) \
     1377        { \
     1378            RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
     1379            RTAssertLogRelMsg2(a); \
     1380            RTAssertPanic(); \
     1381            stmt; \
    13401382            return (rc); \
    13411383        } \
     
    21042146#define AssertLogRelRCReturn(rc, rcRet)         AssertLogRelMsgRCReturn(rc, ("%Rra\n", (rc)), rcRet)
    21052147
     2148/** @def AssertLogRelRCReturnStmt
     2149 * Asserts a iprt status code successful, executing \a stmt and returning \a rc
     2150 * if it isn't.
     2151 *
     2152 * @param   rc      iprt status code.
     2153 * @param   rcRet   What is to be presented to return.
     2154 * @param   stmt    Statement to execute before returning in case of a failed
     2155 *                  assertion.
     2156 * @remark  rc is referenced multiple times.
     2157 */
     2158#define AssertLogRelRCReturnStmt(rc, rcRet, stmt) AssertLogRelMsgRCReturnStmt(rc, ("%Rra\n", (rc)), rcRet, stmt)
     2159
    21062160/** @def AssertLogRelRCReturnVoid
    21072161 * Asserts a iprt status code successful, returning (void) if it isn't.
     
    21472201 */
    21482202#define AssertLogRelMsgRCReturn(rc, msg, rcRet) AssertLogRelMsgReturn(RT_SUCCESS_NP(rc), msg, rcRet)
     2203
     2204/** @def AssertLogRelMsgRCReturnStmt
     2205 * Asserts a iprt status code successful, execute \a stmt and return on
     2206 * failure.
     2207 *
     2208 * @param   rc      iprt status code.
     2209 * @param   msg     printf argument list (in parenthesis).
     2210 * @param   rcRet   What is to be presented to return.
     2211 * @param   stmt    Statement to execute before break in case of a failed assertion.
     2212 * @remark  rc is referenced multiple times.
     2213 */
     2214#define AssertLogRelMsgRCReturnStmt(rc, msg, rcRet, stmt) AssertLogRelMsgReturnStmt(RT_SUCCESS_NP(rc), msg, rcRet, stmt)
    21492215
    21502216/** @def AssertLogRelMsgRCReturnVoid
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