| | 34 | |
|---|
| | 35 | /** @defgroup grp_rt_err_hlp Status Code Helpers |
|---|
| | 36 | * @ingroup grp_rt_err |
|---|
| | 37 | * @{ |
|---|
| | 38 | */ |
|---|
| | 39 | |
|---|
| | 40 | /** @def RT_SUCCESS |
|---|
| | 41 | * Check for success. We expect success in normal cases, that is the code path depending on |
|---|
| | 42 | * this check is normally taken. To prevent any prediction use RT_SUCCESS_NP instead. |
|---|
| | 43 | * |
|---|
| | 44 | * @returns true if rc indicates success. |
|---|
| | 45 | * @returns false if rc indicates failure. |
|---|
| | 46 | * |
|---|
| | 47 | * @param rc The iprt status code to test. |
|---|
| | 48 | */ |
|---|
| | 49 | #define RT_SUCCESS(rc) ( RT_LIKELY((int)(rc) >= VINF_SUCCESS) ) |
|---|
| | 50 | |
|---|
| | 51 | /** @def RT_SUCCESS_NP |
|---|
| | 52 | * Check for success. Don't predict the result. |
|---|
| | 53 | * |
|---|
| | 54 | * @returns true if rc indicates success. |
|---|
| | 55 | * @returns false if rc indicates failure. |
|---|
| | 56 | * |
|---|
| | 57 | * @param rc The iprt status code to test. |
|---|
| | 58 | */ |
|---|
| | 59 | #define RT_SUCCESS_NP(rc) ( (int)(rc) >= VINF_SUCCESS ) |
|---|
| | 60 | |
|---|
| | 61 | /** @def RT_FAILURE |
|---|
| | 62 | * Check for failure. We don't expect in normal cases, that is the code path depending on |
|---|
| | 63 | * this check is normally NOT taken. To prevent any prediction use RT_FAILURE_NP instead. |
|---|
| | 64 | * |
|---|
| | 65 | * @returns true if rc indicates failure. |
|---|
| | 66 | * @returns false if rc indicates success. |
|---|
| | 67 | * |
|---|
| | 68 | * @param rc The iprt status code to test. |
|---|
| | 69 | */ |
|---|
| | 70 | #define RT_FAILURE(rc) ( RT_UNLIKELY(!RT_SUCCESS_NP(rc)) ) |
|---|
| | 71 | |
|---|
| | 72 | /** @def RT_FAILURE_NP |
|---|
| | 73 | * Check for failure. Don't predict the result. |
|---|
| | 74 | * |
|---|
| | 75 | * @returns true if rc indicates failure. |
|---|
| | 76 | * @returns false if rc indicates success. |
|---|
| | 77 | * |
|---|
| | 78 | * @param rc The iprt status code to test. |
|---|
| | 79 | */ |
|---|
| | 80 | #define RT_FAILURE_NP(rc) ( !RT_SUCCESS_NP(rc) ) |
|---|
| | 81 | |
|---|
| | 82 | /** |
|---|
| | 83 | * Converts a Darwin HRESULT error to an iprt status code. |
|---|
| | 84 | * |
|---|
| | 85 | * @returns iprt status code. |
|---|
| | 86 | * @param iNativeCode errno code. |
|---|
| | 87 | * @remark Darwin only. |
|---|
| | 88 | */ |
|---|
| | 89 | RTDECL(int) RTErrConvertFromDarwinCOM(int32_t iNativeCode); |
|---|
| | 90 | |
|---|
| | 91 | /** |
|---|
| | 92 | * Converts a Darwin IOReturn error to an iprt status code. |
|---|
| | 93 | * |
|---|
| | 94 | * @returns iprt status code. |
|---|
| | 95 | * @param iNativeCode errno code. |
|---|
| | 96 | * @remark Darwin only. |
|---|
| | 97 | */ |
|---|
| | 98 | RTDECL(int) RTErrConvertFromDarwinIO(int iNativeCode); |
|---|
| | 99 | |
|---|
| | 100 | /** |
|---|
| | 101 | * Converts a Darwin kern_return_t error to an iprt status code. |
|---|
| | 102 | * |
|---|
| | 103 | * @returns iprt status code. |
|---|
| | 104 | * @param iNativeCode errno code. |
|---|
| | 105 | * @remark Darwin only. |
|---|
| | 106 | */ |
|---|
| | 107 | RTDECL(int) RTErrConvertFromDarwinKern(int iNativeCode); |
|---|
| | 108 | |
|---|
| | 109 | /** |
|---|
| | 110 | * Converts errno to iprt status code. |
|---|
| | 111 | * |
|---|
| | 112 | * @returns iprt status code. |
|---|
| | 113 | * @param uNativeCode errno code. |
|---|
| | 114 | */ |
|---|
| | 115 | RTDECL(int) RTErrConvertFromErrno(unsigned uNativeCode); |
|---|
| | 116 | |
|---|
| | 117 | /** |
|---|
| | 118 | * Converts a L4 errno to a iprt status code. |
|---|
| | 119 | * |
|---|
| | 120 | * @returns iprt status code. |
|---|
| | 121 | * @param uNativeCode l4 errno. |
|---|
| | 122 | * @remark L4 only. |
|---|
| | 123 | */ |
|---|
| | 124 | RTDECL(int) RTErrConvertFromL4Errno(unsigned uNativeCode); |
|---|
| | 125 | |
|---|
| | 126 | /** |
|---|
| | 127 | * Converts NT status code to iprt status code. |
|---|
| | 128 | * |
|---|
| | 129 | * Needless to say, this is only available on NT and winXX targets. |
|---|
| | 130 | * |
|---|
| | 131 | * @returns iprt status code. |
|---|
| | 132 | * @param lNativeCode NT status code. |
|---|
| | 133 | * @remark Windows only. |
|---|
| | 134 | */ |
|---|
| | 135 | RTDECL(int) RTErrConvertFromNtStatus(long lNativeCode); |
|---|
| | 136 | |
|---|
| | 137 | /** |
|---|
| | 138 | * Converts OS/2 error code to iprt status code. |
|---|
| | 139 | * |
|---|
| | 140 | * @returns iprt status code. |
|---|
| | 141 | * @param uNativeCode OS/2 error code. |
|---|
| | 142 | * @remark OS/2 only. |
|---|
| | 143 | */ |
|---|
| | 144 | RTDECL(int) RTErrConvertFromOS2(unsigned uNativeCode); |
|---|
| | 145 | |
|---|
| | 146 | /** |
|---|
| | 147 | * Converts Win32 error code to iprt status code. |
|---|
| | 148 | * |
|---|
| | 149 | * @returns iprt status code. |
|---|
| | 150 | * @param uNativeCode Win32 error code. |
|---|
| | 151 | * @remark Windows only. |
|---|
| | 152 | */ |
|---|
| | 153 | RTDECL(int) RTErrConvertFromWin32(unsigned uNativeCode); |
|---|
| | 154 | |
|---|
| | 155 | |
|---|
| | 156 | #ifdef IN_RING3 |
|---|
| | 157 | |
|---|
| | 158 | /** |
|---|
| | 159 | * iprt status code message. |
|---|
| | 160 | */ |
|---|
| | 161 | typedef struct RTSTATUSMSG |
|---|
| | 162 | { |
|---|
| | 163 | /** Pointer to the short message string. */ |
|---|
| | 164 | const char *pszMsgShort; |
|---|
| | 165 | /** Pointer to the full message string. */ |
|---|
| | 166 | const char *pszMsgFull; |
|---|
| | 167 | /** Pointer to the define string. */ |
|---|
| | 168 | const char *pszDefine; |
|---|
| | 169 | /** Status code number. */ |
|---|
| | 170 | int iCode; |
|---|
| | 171 | } RTSTATUSMSG; |
|---|
| | 172 | /** Pointer to iprt status code message. */ |
|---|
| | 173 | typedef RTSTATUSMSG *PRTSTATUSMSG; |
|---|
| | 174 | /** Pointer to const iprt status code message. */ |
|---|
| | 175 | typedef const RTSTATUSMSG *PCRTSTATUSMSG; |
|---|
| | 176 | |
|---|
| | 177 | /** |
|---|
| | 178 | * Get the message structure corresponding to a given iprt status code. |
|---|
| | 179 | * |
|---|
| | 180 | * @returns Pointer to read-only message description. |
|---|
| | 181 | * @param rc The status code. |
|---|
| | 182 | */ |
|---|
| | 183 | RTDECL(PCRTSTATUSMSG) RTErrGet(int rc); |
|---|
| | 184 | |
|---|
| | 185 | /** |
|---|
| | 186 | * Get the define corresponding to a given iprt status code. |
|---|
| | 187 | * |
|---|
| | 188 | * @returns Pointer to read-only string with the \#define identifier. |
|---|
| | 189 | * @param rc The status code. |
|---|
| | 190 | */ |
|---|
| | 191 | #define RTErrGetDefine(rc) (RTErrGet(rc)->pszDefine) |
|---|
| | 192 | |
|---|
| | 193 | /** |
|---|
| | 194 | * Get the short description corresponding to a given iprt status code. |
|---|
| | 195 | * |
|---|
| | 196 | * @returns Pointer to read-only string with the description. |
|---|
| | 197 | * @param rc The status code. |
|---|
| | 198 | */ |
|---|
| | 199 | #define RTErrGetShort(rc) (RTErrGet(rc)->pszMsgShort) |
|---|
| | 200 | |
|---|
| | 201 | /** |
|---|
| | 202 | * Get the full description corresponding to a given iprt status code. |
|---|
| | 203 | * |
|---|
| | 204 | * @returns Pointer to read-only string with the description. |
|---|
| | 205 | * @param rc The status code. |
|---|
| | 206 | */ |
|---|
| | 207 | #define RTErrGetFull(rc) (RTErrGet(rc)->pszMsgFull) |
|---|
| | 208 | |
|---|
| | 209 | #ifdef __WIN__ |
|---|
| | 210 | /** |
|---|
| | 211 | * Windows error code message. |
|---|
| | 212 | */ |
|---|
| | 213 | typedef struct RTWINERRMSG |
|---|
| | 214 | { |
|---|
| | 215 | /** Pointer to the full message string. */ |
|---|
| | 216 | const char *pszMsgFull; |
|---|
| | 217 | /** Pointer to the define string. */ |
|---|
| | 218 | const char *pszDefine; |
|---|
| | 219 | /** Error code number. */ |
|---|
| | 220 | long iCode; |
|---|
| | 221 | } RTWINERRMSG; |
|---|
| | 222 | /** Pointer to Windows error code message. */ |
|---|
| | 223 | typedef RTWINERRMSG *PRTWINERRMSG; |
|---|
| | 224 | /** Pointer to const Windows error code message. */ |
|---|
| | 225 | typedef const RTWINERRMSG *PCRTWINERRMSG; |
|---|
| | 226 | |
|---|
| | 227 | /** |
|---|
| | 228 | * Get the message structure corresponding to a given Windows error code. |
|---|
| | 229 | * |
|---|
| | 230 | * @returns Pointer to read-only message description. |
|---|
| | 231 | * @param rc The status code. |
|---|
| | 232 | */ |
|---|
| | 233 | RTDECL(PCRTWINERRMSG) RTErrWinGet(long rc); |
|---|
| | 234 | #endif /* __WIN__ */ |
|---|
| | 235 | |
|---|
| | 236 | #endif /* IN_RING3 */ |
|---|
| | 237 | |
|---|
| | 238 | /** @} */ |
|---|
| | 239 | |
|---|
| | 240 | |
|---|
| 619 | | |
|---|
| 620 | | /** @defgroup grp_rt_err_hlp Status Code Helpers |
|---|
| 621 | | * @ingroup grp_rt_err |
|---|
| 622 | | * @{ |
|---|
| 623 | | */ |
|---|
| 624 | | |
|---|
| 625 | | /** @def RT_SUCCESS |
|---|
| 626 | | * Check for success. We expect success in normal cases, that is the code path depending on |
|---|
| 627 | | * this check is normally taken. To prevent any prediction use RT_SUCCESS_NP instead. |
|---|
| 628 | | * |
|---|
| 629 | | * @returns true if rc indicates success. |
|---|
| 630 | | * @returns false if rc indicates failure. |
|---|
| 631 | | * |
|---|
| 632 | | * @param rc The iprt status code to test. |
|---|
| 633 | | */ |
|---|
| 634 | | #define RT_SUCCESS(rc) ( RT_LIKELY((int)(rc) >= VINF_SUCCESS) ) |
|---|
| 635 | | |
|---|
| 636 | | /** @def RT_SUCCESS_NP |
|---|
| 637 | | * Check for success. Don't predict the result. |
|---|
| 638 | | * |
|---|
| 639 | | * @returns true if rc indicates success. |
|---|
| 640 | | * @returns false if rc indicates failure. |
|---|
| 641 | | * |
|---|
| 642 | | * @param rc The iprt status code to test. |
|---|
| 643 | | */ |
|---|
| 644 | | #define RT_SUCCESS_NP(rc) ( (int)(rc) >= VINF_SUCCESS ) |
|---|
| 645 | | |
|---|
| 646 | | /** @def RT_FAILURE |
|---|
| 647 | | * Check for failure. We don't expect in normal cases, that is the code path depending on |
|---|
| 648 | | * this check is normally NOT taken. To prevent any prediction use RT_FAILURE_NP instead. |
|---|
| 649 | | * |
|---|
| 650 | | * @returns true if rc indicates failure. |
|---|
| 651 | | * @returns false if rc indicates success. |
|---|
| 652 | | * |
|---|
| 653 | | * @param rc The iprt status code to test. |
|---|
| 654 | | */ |
|---|
| 655 | | #define RT_FAILURE(rc) ( RT_UNLIKELY(!RT_SUCCESS_NP(rc)) ) |
|---|
| 656 | | |
|---|
| 657 | | /** @def RT_FAILURE_NP |
|---|
| 658 | | * Check for failure. Don't predict the result. |
|---|
| 659 | | * |
|---|
| 660 | | * @returns true if rc indicates failure. |
|---|
| 661 | | * @returns false if rc indicates success. |
|---|
| 662 | | * |
|---|
| 663 | | * @param rc The iprt status code to test. |
|---|
| 664 | | */ |
|---|
| 665 | | #define RT_FAILURE_NP(rc) ( !RT_SUCCESS_NP(rc) ) |
|---|
| 666 | | |
|---|
| 667 | | /** |
|---|
| 668 | | * Converts a Darwin HRESULT error to an iprt status code. |
|---|
| 669 | | * |
|---|
| 670 | | * @returns iprt status code. |
|---|
| 671 | | * @param iNativeCode errno code. |
|---|
| 672 | | * @remark Darwin only. |
|---|
| 673 | | */ |
|---|
| 674 | | RTDECL(int) RTErrConvertFromDarwinCOM(int32_t iNativeCode); |
|---|
| 675 | | |
|---|
| 676 | | /** |
|---|
| 677 | | * Converts a Darwin IOReturn error to an iprt status code. |
|---|
| 678 | | * |
|---|
| 679 | | * @returns iprt status code. |
|---|
| 680 | | * @param iNativeCode errno code. |
|---|
| 681 | | * @remark Darwin only. |
|---|
| 682 | | */ |
|---|
| 683 | | RTDECL(int) RTErrConvertFromDarwinIO(int iNativeCode); |
|---|
| 684 | | |
|---|
| 685 | | /** |
|---|
| 686 | | * Converts a Darwin kern_return_t error to an iprt status code. |
|---|
| 687 | | * |
|---|
| 688 | | * @returns iprt status code. |
|---|
| 689 | | * @param iNativeCode errno code. |
|---|
| 690 | | * @remark Darwin only. |
|---|
| 691 | | */ |
|---|
| 692 | | RTDECL(int) RTErrConvertFromDarwinKern(int iNativeCode); |
|---|
| 693 | | |
|---|
| 694 | | /** |
|---|
| 695 | | * Converts errno to iprt status code. |
|---|
| 696 | | * |
|---|
| 697 | | * @returns iprt status code. |
|---|
| 698 | | * @param uNativeCode errno code. |
|---|
| 699 | | */ |
|---|
| 700 | | RTDECL(int) RTErrConvertFromErrno(unsigned uNativeCode); |
|---|
| 701 | | |
|---|
| 702 | | /** |
|---|
| 703 | | * Converts a L4 errno to a iprt status code. |
|---|
| 704 | | * |
|---|
| 705 | | * @returns iprt status code. |
|---|
| 706 | | * @param uNativeCode l4 errno. |
|---|
| 707 | | * @remark L4 only. |
|---|
| 708 | | */ |
|---|
| 709 | | RTDECL(int) RTErrConvertFromL4Errno(unsigned uNativeCode); |
|---|
| 710 | | |
|---|
| 711 | | /** |
|---|
| 712 | | * Converts NT status code to iprt status code. |
|---|
| 713 | | * |
|---|
| 714 | | * Needless to say, this is only available on NT and winXX targets. |
|---|
| 715 | | * |
|---|
| 716 | | * @returns iprt status code. |
|---|
| 717 | | * @param lNativeCode NT status code. |
|---|
| 718 | | * @remark Windows only. |
|---|
| 719 | | */ |
|---|
| 720 | | RTDECL(int) RTErrConvertFromNtStatus(long lNativeCode); |
|---|
| 721 | | |
|---|
| 722 | | /** |
|---|
| 723 | | * Converts OS/2 error code to iprt status code. |
|---|
| 724 | | * |
|---|
| 725 | | * @returns iprt status code. |
|---|
| 726 | | * @param uNativeCode OS/2 error code. |
|---|
| 727 | | * @remark OS/2 only. |
|---|
| 728 | | */ |
|---|
| 729 | | RTDECL(int) RTErrConvertFromOS2(unsigned uNativeCode); |
|---|
| 730 | | |
|---|
| 731 | | /** |
|---|
| 732 | | * Converts Win32 error code to iprt status code. |
|---|
| 733 | | * |
|---|
| 734 | | * @returns iprt status code. |
|---|
| 735 | | * @param uNativeCode Win32 error code. |
|---|
| 736 | | * @remark Windows only. |
|---|
| 737 | | */ |
|---|
| 738 | | RTDECL(int) RTErrConvertFromWin32(unsigned uNativeCode); |
|---|
| 739 | | |
|---|
| 740 | | |
|---|
| 741 | | #ifdef IN_RING3 |
|---|
| 742 | | |
|---|
| 743 | | /** |
|---|
| 744 | | * iprt status code message. |
|---|
| 745 | | */ |
|---|
| 746 | | typedef struct RTSTATUSMSG |
|---|
| 747 | | { |
|---|
| 748 | | /** Pointer to the short message string. */ |
|---|
| 749 | | const char *pszMsgShort; |
|---|
| 750 | | /** Pointer to the full message string. */ |
|---|
| 751 | | const char *pszMsgFull; |
|---|
| 752 | | /** Pointer to the define string. */ |
|---|
| 753 | | const char *pszDefine; |
|---|
| 754 | | /** Status code number. */ |
|---|
| 755 | | int iCode; |
|---|
| 756 | | } RTSTATUSMSG; |
|---|
| 757 | | /** Pointer to iprt status code message. */ |
|---|
| 758 | | typedef RTSTATUSMSG *PRTSTATUSMSG; |
|---|
| 759 | | /** Pointer to const iprt status code message. */ |
|---|
| 760 | | typedef const RTSTATUSMSG *PCRTSTATUSMSG; |
|---|
| 761 | | |
|---|
| 762 | | /** |
|---|
| 763 | | * Get the message structure corresponding to a given iprt status code. |
|---|
| 764 | | * |
|---|
| 765 | | * @returns Pointer to read-only message description. |
|---|
| 766 | | * @param rc The status code. |
|---|
| 767 | | */ |
|---|
| 768 | | RTDECL(PCRTSTATUSMSG) RTErrGet(int rc); |
|---|
| 769 | | |
|---|
| 770 | | /** |
|---|
| 771 | | * Get the define corresponding to a given iprt status code. |
|---|
| 772 | | * |
|---|
| 773 | | * @returns Pointer to read-only string with the \#define identifier. |
|---|
| 774 | | * @param rc The status code. |
|---|
| 775 | | */ |
|---|
| 776 | | #define RTErrGetDefine(rc) (RTErrGet(rc)->pszDefine) |
|---|
| 777 | | |
|---|
| 778 | | /** |
|---|
| 779 | | * Get the short description corresponding to a given iprt status code. |
|---|
| 780 | | * |
|---|
| 781 | | * @returns Pointer to read-only string with the description. |
|---|
| 782 | | * @param rc The status code. |
|---|
| 783 | | */ |
|---|
| 784 | | #define RTErrGetShort(rc) (RTErrGet(rc)->pszMsgShort) |
|---|
| 785 | | |
|---|
| 786 | | /** |
|---|
| 787 | | * Get the full description corresponding to a given iprt status code. |
|---|
| 788 | | * |
|---|
| 789 | | * @returns Pointer to read-only string with the description. |
|---|
| 790 | | * @param rc The status code. |
|---|
| 791 | | */ |
|---|
| 792 | | #define RTErrGetFull(rc) (RTErrGet(rc)->pszMsgFull) |
|---|
| 793 | | |
|---|
| 794 | | #ifdef __WIN__ |
|---|
| 795 | | /** |
|---|
| 796 | | * Windows error code message. |
|---|
| 797 | | */ |
|---|
| 798 | | typedef struct RTWINERRMSG |
|---|
| 799 | | { |
|---|
| 800 | | /** Pointer to the full message string. */ |
|---|
| 801 | | const char *pszMsgFull; |
|---|
| 802 | | /** Pointer to the define string. */ |
|---|
| 803 | | const char *pszDefine; |
|---|
| 804 | | /** Error code number. */ |
|---|
| 805 | | long iCode; |
|---|
| 806 | | } RTWINERRMSG; |
|---|
| 807 | | /** Pointer to Windows error code message. */ |
|---|
| 808 | | typedef RTWINERRMSG *PRTWINERRMSG; |
|---|
| 809 | | /** Pointer to const Windows error code message. */ |
|---|
| 810 | | typedef const RTWINERRMSG *PCRTWINERRMSG; |
|---|
| 811 | | |
|---|
| 812 | | /** |
|---|
| 813 | | * Get the message structure corresponding to a given Windows error code. |
|---|
| 814 | | * |
|---|
| 815 | | * @returns Pointer to read-only message description. |
|---|
| 816 | | * @param rc The status code. |
|---|
| 817 | | */ |
|---|
| 818 | | RTDECL(PCRTWINERRMSG) RTErrWinGet(long rc); |
|---|
| 819 | | #endif /* __WIN__ */ |
|---|
| 820 | | |
|---|
| 821 | | #endif /* IN_RING3 */ |
|---|
| 822 | | |
|---|
| 823 | | /** @} */ |
|---|
| 824 | | |
|---|