VirtualBox

Changeset 76348 in vbox for trunk


Ignore:
Timestamp:
Dec 22, 2018 1:00:39 AM (6 years ago)
Author:
vboxsync
Message:

iprt/err*.h: Make VINF_SUCCESS available via errcore.h too.

Location:
trunk/include/iprt
Files:
2 edited

Legend:

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

    r76326 r76348  
    6262/* SED-START */
    6363
     64/** Success. */
     65#define VINF_SUCCESS                        0
     66
    6467/** @name Misc. Status Codes
    6568 * @{
    6669 */
    67 /** Success. */
    68 #define VINF_SUCCESS                        0
    69 
    7070/** General failure - DON'T USE THIS!!! */
    7171#define VERR_GENERAL_FAILURE                (-1)
  • trunk/include/iprt/errcore.h

    r76326 r76348  
    3636 * @{
    3737 */
     38
     39/** Success.
     40 * @ingroup grp_rt_err  */
     41#define VINF_SUCCESS                        0
     42
     43
     44/** @def RTERR_STRICT_RC
     45 * Indicates that RT_SUCCESS_NP, RT_SUCCESS, RT_FAILURE_NP and RT_FAILURE should
     46 * make type enforcing at compile time.
     47 *
     48 * @remarks     Only define this for C++ code.
     49 */
     50#if defined(__cplusplus) \
     51 && !defined(RTERR_STRICT_RC) \
     52 && !defined(RTERR_NO_STRICT_RC) \
     53 && (   defined(DOXYGEN_RUNNING) \
     54     || defined(DEBUG) \
     55     || defined(RT_STRICT) )
     56# define RTERR_STRICT_RC        1
     57#endif
     58
     59
     60/** @def RT_SUCCESS
     61 * Check for success. We expect success in normal cases, that is the code path depending on
     62 * this check is normally taken. To prevent any prediction use RT_SUCCESS_NP instead.
     63 *
     64 * @returns true if rc indicates success.
     65 * @returns false if rc indicates failure.
     66 *
     67 * @param   rc  The iprt status code to test.
     68 */
     69#define RT_SUCCESS(rc)      ( RT_LIKELY(RT_SUCCESS_NP(rc)) )
     70
     71/** @def RT_SUCCESS_NP
     72 * Check for success. Don't predict the result.
     73 *
     74 * @returns true if rc indicates success.
     75 * @returns false if rc indicates failure.
     76 *
     77 * @param   rc  The iprt status code to test.
     78 */
     79#ifdef RTERR_STRICT_RC
     80# define RT_SUCCESS_NP(rc)   ( RTErrStrictType(rc).success() )
     81#else
     82# define RT_SUCCESS_NP(rc)   ( (int)(rc) >= VINF_SUCCESS )
     83#endif
     84
     85/** @def RT_FAILURE
     86 * Check for failure, predicting unlikely.
     87 *
     88 * We don't expect in normal cases, that is the code path depending on this
     89 * check is normally NOT taken. To prevent any prediction use RT_FAILURE_NP
     90 * instead.
     91 *
     92 * @returns true if rc indicates failure.
     93 * @returns false if rc indicates success.
     94 *
     95 * @param   rc  The iprt status code to test.
     96 *
     97 * @remarks Please structure your code to use the RT_SUCCESS() macro instead of
     98 *          RT_FAILURE() where possible, as that gives us a better shot at good
     99 *          code with the windows compilers.
     100 */
     101#define RT_FAILURE(rc)      ( RT_UNLIKELY(!RT_SUCCESS_NP(rc)) )
     102
     103/** @def RT_FAILURE_NP
     104 * Check for failure, no prediction.
     105 *
     106 * @returns true if rc indicates failure.
     107 * @returns false if rc indicates success.
     108 *
     109 * @param   rc  The iprt status code to test.
     110 */
     111#define RT_FAILURE_NP(rc)   ( !RT_SUCCESS_NP(rc) )
     112
    38113
    39114#ifdef __cplusplus
     
    110185#endif /* __cplusplus */
    111186
    112 
    113 /** @def RTERR_STRICT_RC
    114  * Indicates that RT_SUCCESS_NP, RT_SUCCESS, RT_FAILURE_NP and RT_FAILURE should
    115  * make type enforcing at compile time.
    116  *
    117  * @remarks     Only define this for C++ code.
    118  */
    119 #if defined(__cplusplus) \
    120  && !defined(RTERR_STRICT_RC) \
    121  && !defined(RTERR_NO_STRICT_RC) \
    122  && (   defined(DOXYGEN_RUNNING) \
    123      || defined(DEBUG) \
    124      || defined(RT_STRICT) )
    125 # define RTERR_STRICT_RC        1
    126 #endif
    127 
    128 
    129 /** @def RT_SUCCESS
    130  * Check for success. We expect success in normal cases, that is the code path depending on
    131  * this check is normally taken. To prevent any prediction use RT_SUCCESS_NP instead.
    132  *
    133  * @returns true if rc indicates success.
    134  * @returns false if rc indicates failure.
    135  *
    136  * @param   rc  The iprt status code to test.
    137  */
    138 #define RT_SUCCESS(rc)      ( RT_LIKELY(RT_SUCCESS_NP(rc)) )
    139 
    140 /** @def RT_SUCCESS_NP
    141  * Check for success. Don't predict the result.
    142  *
    143  * @returns true if rc indicates success.
    144  * @returns false if rc indicates failure.
    145  *
    146  * @param   rc  The iprt status code to test.
    147  */
    148 #ifdef RTERR_STRICT_RC
    149 # define RT_SUCCESS_NP(rc)   ( RTErrStrictType(rc).success() )
    150 #else
    151 # define RT_SUCCESS_NP(rc)   ( (int)(rc) >= VINF_SUCCESS )
    152 #endif
    153 
    154 /** @def RT_FAILURE
    155  * Check for failure, predicting unlikely.
    156  *
    157  * We don't expect in normal cases, that is the code path depending on this
    158  * check is normally NOT taken. To prevent any prediction use RT_FAILURE_NP
    159  * instead.
    160  *
    161  * @returns true if rc indicates failure.
    162  * @returns false if rc indicates success.
    163  *
    164  * @param   rc  The iprt status code to test.
    165  *
    166  * @remarks Please structure your code to use the RT_SUCCESS() macro instead of
    167  *          RT_FAILURE() where possible, as that gives us a better shot at good
    168  *          code with the windows compilers.
    169  */
    170 #define RT_FAILURE(rc)      ( RT_UNLIKELY(!RT_SUCCESS_NP(rc)) )
    171 
    172 /** @def RT_FAILURE_NP
    173  * Check for failure, no prediction.
    174  *
    175  * @returns true if rc indicates failure.
    176  * @returns false if rc indicates success.
    177  *
    178  * @param   rc  The iprt status code to test.
    179  */
    180 #define RT_FAILURE_NP(rc)   ( !RT_SUCCESS_NP(rc) )
    181187
    182188RT_C_DECLS_BEGIN
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