VirtualBox

Changeset 15668 in vbox for trunk/include/iprt


Ignore:
Timestamp:
Dec 18, 2008 5:41:50 PM (16 years ago)
Author:
vboxsync
Message:

iprt/assert.h: AssertMsgReturnVoidStmt AssertMsgReturnStmt.

File:
1 edited

Legend:

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

    r15640 r15668  
    565565#endif
    566566
     567/** @def AssertMsgReturnStmt
     568 * Assert that an expression is true, if it isn't execute the statement and
     569 * return.
     570 *
     571 * In RT_STRICT mode it will hit a breakpoint before returning.
     572 *
     573 * @param   expr    Expression which should be true.
     574 * @param   a       printf argument list (in parenthesis).
     575 * @param   stmt    Statement to execute before break in case of a failed assertion.
     576 * @param   rc      What is to be presented to return.
     577 */
     578#ifdef RT_STRICT
     579# define AssertMsgReturnStmt(expr, a, stmt, rc)  \
     580    do { \
     581        if (RT_UNLIKELY(!(expr))) \
     582        { \
     583            AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
     584            AssertMsg2 a; \
     585            RTAssertPanic(); \
     586            stmt; \
     587            return (rc); \
     588        } \
     589    } while (0)
     590#else
     591# define AssertMsgReturnStmt(expr, a, stmt, rc) \
     592    do { \
     593        if (RT_UNLIKELY(!(expr))) \
     594        { \
     595            stmt; \
     596            return (rc); \
     597        } \
     598    } while (0)
     599#endif
     600
    567601/** @def AssertMsgReturnVoid
    568602 * Assert that an expression is true and returns if it isn't.
     
    588622        if (RT_UNLIKELY(!(expr))) \
    589623            return; \
     624    } while (0)
     625#endif
     626
     627/** @def AssertMsgReturnVoidStmt
     628 * Assert that an expression is true, if it isn't execute the statement and
     629 * return.
     630 *
     631 * In RT_STRICT mode it will hit a breakpoint before returning.
     632 *
     633 * @param   expr    Expression which should be true.
     634 * @param   a       printf argument list (in parenthesis).
     635 * @param   stmt    Statement to execute before break in case of a failed assertion.
     636 */
     637#ifdef RT_STRICT
     638# define AssertMsgReturnVoidStmt(expr, a, stmt)  \
     639    do { \
     640        if (RT_UNLIKELY(!(expr))) \
     641        { \
     642            AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
     643            AssertMsg2 a; \
     644            RTAssertPanic(); \
     645            stmt; \
     646            return; \
     647        } \
     648    } while (0)
     649#else
     650# define AssertMsgReturnVoidStmt(expr, a, stmt) \
     651    do { \
     652        if (RT_UNLIKELY(!(expr))) \
     653        { \
     654            stmt; \
     655            return; \
     656        } \
    590657    } while (0)
    591658#endif
Note: See TracChangeset for help on using the changeset viewer.

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