VirtualBox

Changeset 55944 in vbox


Ignore:
Timestamp:
May 19, 2015 11:01:12 PM (9 years ago)
Author:
vboxsync
Message:

VirtualBoxBase.h: Replaced RT_UNLIKELY with RT_LIKELY to improve our karma wrt MSC.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/VirtualBoxBase.h

    r55582 r55944  
    157157 */
    158158#if defined(DEBUG)
    159 #define ComAssert(expr)    Assert(expr)
     159# define ComAssert(expr)    Assert(expr)
    160160#else
    161 #define ComAssert(expr)    \
    162     do { \
    163         if (RT_UNLIKELY(!(expr))) \
     161# define ComAssert(expr) \
     162    do { \
     163        if (RT_LIKELY(!!(expr))) \
     164        { /* likely */ } \
     165        else \
    164166            setError(E_FAIL, \
    165167                     "Assertion failed: [%s] at '%s' (%d) in %s.\nPlease contact the product vendor!", \
     
    180182 */
    181183#if defined(DEBUG)
    182 #define ComAssertFailed()    AssertFailed()
     184# define ComAssertFailed()  AssertFailed()
    183185#else
    184 #define ComAssertFailed()    \
     186# define ComAssertFailed() \
    185187    do { \
    186188        setError(E_FAIL, \
     
    200202 */
    201203#if defined(DEBUG)
    202 #define ComAssertMsg(expr, a) AssertMsg(expr, a)
     204# define ComAssertMsg(expr, a) AssertMsg(expr, a)
    203205#else
    204 #define ComAssertMsg(expr, a)  \
    205     do { \
    206         if (RT_UNLIKELY(!(expr))) \
     206# define ComAssertMsg(expr, a) \
     207    do { \
     208        if (RT_LIKELY(!!(expr))) \
     209        { /* likely */ } \
     210        else \
    207211            setError(E_FAIL, \
    208212                     "Assertion failed: [%s] at '%s' (%d) in %s.\n%s.\nPlease contact the product vendor!", \
     
    220224 */
    221225#if defined(DEBUG)
    222 #define ComAssertMsgFailed(a)   AssertMsgFailed(a)
     226# define ComAssertMsgFailed(a)  AssertMsgFailed(a)
    223227#else
    224 #define ComAssertMsgFailed(a) \
     228# define ComAssertMsgFailed(a) \
    225229    do { \
    226230        setError(E_FAIL, \
     
    239243 */
    240244#if defined(DEBUG)
    241 #define ComAssertRC(vrc)    AssertRC(vrc)
     245# define ComAssertRC(vrc)   AssertRC(vrc)
    242246#else
    243 #define ComAssertRC(vrc)    ComAssertMsgRC(vrc, ("%Rra", vrc))
     247# define ComAssertRC(vrc)   ComAssertMsgRC(vrc, ("%Rra", vrc))
    244248#endif
    245249
     
    254258 */
    255259#if defined(DEBUG)
    256 #define ComAssertMsgRC(vrc, msg)    AssertMsgRC(vrc, msg)
     260# define ComAssertMsgRC(vrc, msg)   AssertMsgRC(vrc, msg)
    257261#else
    258 #define ComAssertMsgRC(vrc, msg)    ComAssertMsg(RT_SUCCESS(vrc), msg)
     262# define ComAssertMsgRC(vrc, msg)   ComAssertMsg(RT_SUCCESS(vrc), msg)
    259263#endif
    260264
     
    268272 */
    269273#if defined(DEBUG)
    270 #define ComAssertComRC(rc) AssertComRC(rc)
     274# define ComAssertComRC(rc) AssertComRC(rc)
    271275#else
    272 #define ComAssertComRC(rc) ComAssertMsg(SUCCEEDED(rc), ("COM RC = %Rhrc (0x%08X)", (rc), (rc)))
     276# define ComAssertComRC(rc) ComAssertMsg(SUCCEEDED(rc), ("COM RC = %Rhrc (0x%08X)", (rc), (rc)))
    273277#endif
    274278
     
    365369#define CheckComArgNotNull(arg) \
    366370    do { \
    367         if (RT_UNLIKELY((arg) == NULL)) \
     371        if (RT_LIKELY((arg) == NULL)) \
     372        { /* likely */ }\
     373        else \
    368374            return setError(E_INVALIDARG, tr("Argument %s is NULL"), #arg); \
    369375    } while (0)
     
    376382#define CheckComArgMaybeNull(arg) \
    377383    do { \
    378         if (RT_UNLIKELY(!RT_VALID_PTR(arg) && (arg) != NULL)) \
     384        if (RT_LIKELY(RT_VALID_PTR(arg) || (arg) == NULL)) \
     385        { /* likely */ }\
     386        else \
    379387            return setError(E_INVALIDARG, tr("Argument %s is an invalid pointer"), #arg); \
    380388    } while (0)
     
    387395#define CheckComArgPointerValid(arg) \
    388396    do { \
    389         if (RT_UNLIKELY(!RT_VALID_PTR(arg))) \
     397        if (RT_LIKELY(RT_VALID_PTR(arg))) \
     398        { /* likely */ }\
     399        else \
    390400            return setError(E_POINTER, \
    391401                tr("Argument %s points to invalid memory location (%p)"), \
     
    400410#define CheckComArgSafeArrayNotNull(arg) \
    401411    do { \
    402         if (RT_UNLIKELY(ComSafeArrayInIsNull(arg))) \
     412        if (RT_LIKELY(!ComSafeArrayInIsNull(arg))) \
     413        { /* likely */ }\
     414        else \
    403415            return setError(E_INVALIDARG, tr("Argument %s is NULL"), #arg); \
    404416    } while (0)
     
    412424    do { \
    413425        IN_BSTR const bstrInCheck = (a_bstrIn); /* type check */ \
    414         if (RT_UNLIKELY(!RT_VALID_PTR(bstrInCheck))) \
     426        if (RT_LIKELY(RT_VALID_PTR(bstrInCheck))) \
     427        { /* likely */ }\
     428        else \
    415429            return setError(E_INVALIDARG, tr("Argument %s is an invalid pointer"), #a_bstrIn); \
    416430    } while (0)
     
    423437    do { \
    424438        IN_BSTR const bstrInCheck = (a_bstrIn); /* type check */ \
    425         if (RT_UNLIKELY(!RT_VALID_PTR(bstrInCheck) || *(bstrInCheck) == '\0')) \
     439        if (RT_LIKELY(RT_VALID_PTR(bstrInCheck) && *(bstrInCheck) != '\0')) \
     440        { /* likely */ }\
     441        else \
    426442            return setError(E_INVALIDARG, tr("Argument %s is empty or an invalid pointer"), #a_bstrIn); \
    427443    } while (0)
     
    438454        Guid tmpGuid(a_Arg); \
    439455        (a_GuidVar) = tmpGuid; \
    440         if (RT_UNLIKELY((a_GuidVar).isValid() == false)) \
     456        if (RT_LIKELY((a_GuidVar).isValid())) \
     457        { /* likely */ }\
     458        else \
    441459            return setError(E_INVALIDARG, \
    442460                tr("GUID argument %s is not valid (\"%ls\")"), #a_Arg, Bstr(a_Arg).raw()); \
     
    451469#define CheckComArgExpr(arg, expr) \
    452470    do { \
    453         if (RT_UNLIKELY(!(expr))) \
     471        if (RT_LIKELY(!!(expr))) \
     472        { /* likely */ }\
     473        else \
    454474            return setError(E_INVALIDARG, \
    455475                tr("Argument %s is invalid (must be %s)"), #arg, #expr); \
     
    467487#define CheckComArgExprMsg(arg, expr, msg) \
    468488    do { \
    469         if (RT_UNLIKELY(!(expr))) \
     489        if (RT_LIKELY(!!(expr))) \
     490        { /* likely */ }\
     491        else \
    470492            return setError(E_INVALIDARG, tr("Argument %s %s"), \
    471493                            #arg, Utf8StrFmt msg .c_str()); \
     
    479501#define CheckComArgOutPointerValid(arg) \
    480502    do { \
    481         if (RT_UNLIKELY(!VALID_PTR(arg))) \
     503        if (RT_LIKELY(RT_VALID_PTR(arg))) \
     504        { /* likely */ }\
     505        else \
    482506            return setError(E_POINTER, \
    483507                tr("Output argument %s points to invalid memory location (%p)"), \
     
    492516#define CheckComArgOutSafeArrayPointerValid(arg) \
    493517    do { \
    494         if (RT_UNLIKELY(ComSafeArrayOutIsNull(arg))) \
     518        if (RT_LIKELY(!ComSafeArrayOutIsNull(arg))) \
     519        { /* likely */ }\
     520        else \
    495521            return setError(E_POINTER, \
    496522                            tr("Output argument %s points to invalid memory location (%p)"), \
     
    535561 */
    536562#ifdef DEBUG
    537 #define DebugBreakThrow(a) \
     563# define DebugBreakThrow(a) \
    538564    do { \
    539565        RTAssertDebugBreak(); \
     
    541567} while (0)
    542568#else
    543 #define DebugBreakThrow(a) throw (a)
     569# define DebugBreakThrow(a) throw (a)
    544570#endif
    545571
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