VirtualBox

Changeset 55951 in vbox


Ignore:
Timestamp:
May 19, 2015 11:48:06 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
100450
Message:

iprt/cdefs.h,iprt/err.h: More or less deprecated RT_UNLIKELY and RT_FAILURE in favor of code organized around RT_LIKELY and RT_SUCCESS.

Location:
trunk/include/iprt
Files:
2 edited

Legend:

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

    r55468 r55951  
    13211321 * A few notes about the usage:
    13221322 *
     1323 *      - Generally, order your code use RT_LIKELY() instead of RT_UNLIKELY().
     1324 *
    13231325 *      - Generally, use RT_UNLIKELY() with error condition checks (unless you
    13241326 *        have some _strong_ reason to do otherwise, in which case document it),
     
    13281330 *      - Other than that, if you don't know the likelihood of a test succeeding
    13291331 *        from empirical or other 'hard' evidence, don't make predictions unless
    1330  *        you happen to be a Dirk Gently.
     1332 *        you happen to be a Dirk Gently character.
    13311333 *
    13321334 *      - These macros are meant to be used in places that get executed a lot. It
     
    13361338 *
    13371339 *      - Note that RT_SUCCESS() and RT_FAILURE() already makes use of RT_LIKELY()
    1338  *        and RT_UNLIKELY(). Should you wish for prediction free status checks,
     1340 *        and RT_UNLIKELY().  Should you wish for prediction free status checks,
    13391341 *        use the RT_SUCCESS_NP() and RT_FAILURE_NP() macros instead.
    13401342 *
     
    13421344 * @returns the boolean result of the expression.
    13431345 * @param   expr        The expression that's very likely to be true.
    1344  * @see RT_UNLIKELY
     1346 * @see     RT_UNLIKELY
    13451347 */
    13461348/** @def RT_UNLIKELY
     
    13511353 * @returns the boolean result of the expression.
    13521354 * @param   expr        The expression that's very unlikely to be true.
    1353  * @see RT_LIKELY
     1355 * @see     RT_LIKELY
     1356 *
     1357 * @remarks Please use RT_LIKELY() instead wherever possible!  That gives us a
     1358 *          better chance of the windows compilers to generate favorable code
     1359 *          too.  The belief is that the compiler will by default assume the
     1360 *          if-case is more likely than the else-case.
    13541361 */
    13551362#if defined(__GNUC__)
  • trunk/include/iprt/err.h

    r55659 r55951  
    162162
    163163/** @def RT_FAILURE
    164  * Check for failure. We don't expect in normal cases, that is the code path depending on
    165  * this check is normally NOT taken. To prevent any prediction use RT_FAILURE_NP instead.
     164 * Check for failure, predicting unlikely.
     165 *
     166 * We don't expect in normal cases, that is the code path depending on this
     167 * check is normally NOT taken. To prevent any prediction use RT_FAILURE_NP
     168 * instead.
    166169 *
    167170 * @returns true if rc indicates failure.
     
    169172 *
    170173 * @param   rc  The iprt status code to test.
     174 *
     175 * @remarks Please structure your code to use the RT_SUCCESS() macro instead of
     176 *          RT_FAILURE() where possible, as that gives us a better shot at good
     177 *          code with the windows compilers.
    171178 */
    172179#define RT_FAILURE(rc)      ( RT_UNLIKELY(!RT_SUCCESS_NP(rc)) )
    173180
    174181/** @def RT_FAILURE_NP
    175  * Check for failure. Don't predict the result.
     182 * Check for failure, no prediction.
    176183 *
    177184 * @returns true if rc indicates failure.
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