VirtualBox

Changeset 15640 in vbox for trunk/include/iprt


Ignore:
Timestamp:
Dec 18, 2008 11:07:54 AM (16 years ago)
Author:
vboxsync
Message:

iprt/assert.h: AssertReturnStmt, AssertReturnVoidStmt. cleanup of AssertFailedReturn*Stmt.

File:
1 edited

Legend:

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

    r15398 r15640  
    385385#endif
    386386
     387/** @def AssertReturnStmt
     388 * Assert that an expression is true, if it isn't execute the given statement
     389 * and return rc.
     390 *
     391 * In RT_STRICT mode it will hit a breakpoint before executing the statment and
     392 * returning.
     393 *
     394 * @param   expr    Expression which should be true.
     395 * @param   stmt    Statement to execute before returning on failure.
     396 * @param   rc      What is to be presented to return.
     397 */
     398#ifdef RT_STRICT
     399# define AssertReturnStmt(expr, stmt, rc) \
     400    do { \
     401        if (RT_UNLIKELY(!(expr))) \
     402        { \
     403            AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
     404            RTAssertPanic(); \
     405            stmt; \
     406            return (rc); \
     407        } \
     408    } while (0)
     409#else
     410# define AssertReturnStmt(expr, stmt, rc) \
     411    do { \
     412        if (RT_UNLIKELY(!(expr))) \
     413        { \
     414            stmt; \
     415            return (rc); \
     416        } \
     417    } while (0)
     418#endif
     419
    387420/** @def AssertReturnVoid
    388421 * Assert that an expression is true and returns if it isn't.
     
    406439        if (RT_UNLIKELY(!(expr))) \
    407440            return; \
     441    } while (0)
     442#endif
     443
     444/** @def AssertReturnVoidStmt
     445 * Assert that an expression is true, if it isn't execute the given statement
     446 * and return.
     447 *
     448 * In RT_STRICT mode it will hit a breakpoint before returning.
     449 *
     450 * @param   expr    Expression which should be true.
     451 * @param   stmt    Statement to execute before returning on failure.
     452 */
     453#ifdef RT_STRICT
     454# define AssertReturnVoidStmt(expr, stmt) \
     455    do { \
     456        if (RT_UNLIKELY(!(expr))) \
     457        { \
     458            AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
     459            RTAssertPanic(); \
     460            stmt; \
     461            return; \
     462        } \
     463    } while (0)
     464#else
     465# define AssertReturnVoidStmt(expr, stmt) \
     466    do { \
     467        if (RT_UNLIKELY(!(expr))) \
     468        { \
     469            stmt; \
     470            return; \
     471        } \
    408472    } while (0)
    409473#endif
     
    608672#endif
    609673
     674/** @def AssertFailedReturnStmt
     675 * An assertion failed, hit breakpoint (RT_STRICT mode only), execute a
     676 * statement and return a value.
     677 *
     678 * @param stmt The statement to execute before returning.
     679 * @param rc   The value to return.
     680 */
     681#ifdef RT_STRICT
     682# define AssertFailedReturnStmt(stmt, rc)  \
     683    do { \
     684        AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
     685        RTAssertPanic(); \
     686        stmt; \
     687        return (rc); \
     688    } while (0)
     689#else
     690# define AssertFailedReturnStmt(stmt, rc)  \
     691    do { \
     692        stmt; \
     693        return (rc); \
     694    } while (0)
     695#endif
     696
    610697/** @def AssertFailedReturnVoid
    611698 * An assertion failed, hit breakpoint (RT_STRICT mode only) and return.
     
    625712#endif
    626713
    627 
    628 /**
    629  * @def AssertFailedReturnStmt
    630  * An assertion failed, hit breakpoint (RT_STRICT mode only), execute a
    631  * statement and return a value.
    632  *
    633  * @param stmt The statement to execute.
    634  * @param rc   The value to return.
    635  */
    636 #ifdef RT_STRICT
    637 # define AssertFailedReturnStmt(stmt, rc)  \
    638     do { \
    639         AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
    640         stmt; \
    641         RTAssertPanic(); \
    642         return (rc); \
    643     } while (0)
    644 #else
    645 # define AssertFailedReturnStmt(stmt, rc)  \
    646     do { \
    647         stmt; \
    648         return (rc); \
    649     } while (0)
    650 #endif
    651 
    652 /**
    653  * @def AssertFailedReturnVoidStmt
     714/** @def AssertFailedReturnVoidStmt
    654715 * An assertion failed, hit breakpoint (RT_STRICT mode only), execute a
    655716 * statement and return.
    656717 *
    657  * @param stmt The statement to execute.
     718 * @param stmt The statement to execute before returning.
    658719 */
    659720#ifdef RT_STRICT
     
    661722    do { \
    662723        AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
    663         stmt; \
    664         RTAssertPanic(); \
    665         return; \
    666     } while (0)
    667 #else
    668 # define AssertFailedReturnVoidStmt(stmt)  \
    669     do { \
     724        RTAssertPanic(); \
    670725        stmt; \
    671726        return; \
    672727    } while (0)
    673 #endif
    674 
     728#else
     729# define AssertFailedReturnVoidStmt(stmt)  \
     730    do { \
     731        stmt; \
     732        return; \
     733    } while (0)
     734#endif
    675735
    676736
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