Changeset 95975 in vbox for trunk/include/iprt/nocrt/stdlib.h
- Timestamp:
- Aug 2, 2022 12:55:08 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/nocrt/stdlib.h
r95818 r95975 30 30 #endif 31 31 32 #include <iprt/types.h> 32 #include <iprt/assert.h> 33 #include <iprt/env.h> 33 34 #include <iprt/mem.h> 35 #include <limits.h> 34 36 35 37 RT_C_DECLS_BEGIN 38 39 #define EXIT_SUCCESS RTEXITCODE_SUCCESS 40 #define EXIT_FAILURE RTEXITCODE_FAILURE 41 36 42 37 43 typedef void FNRTNOCRTATEXITCALLBACK(void) /*RT_NOEXCEPT*/; … … 74 80 } 75 81 82 DECLINLINE(const char *) RT_NOCRT(getenv)(const char *pszVar) 83 { 84 return RTEnvGet(pszVar); 85 } 86 87 void *RT_NOCRT(bsearch)(const void *pvKey, const void *pvBase, size_t cEntries, size_t cbEntry, 88 int (*pfnCompare)(const void *pv1, const void *pv2)); 89 void RT_NOCRT(qsort)(void *pvBase, size_t cEntries, size_t cbEntry, 90 int (*pfnCompare)(const void *pv1, const void *pv2)); 91 void RT_NOCRT(qsort_r)(void *pvBase, size_t cEntries, size_t cbEntry, 92 int (*pfnCompare)(const void *pv1, const void *pv2, void *pvUser), void *pvUser); 93 94 /* Map exit & abort onto fatal assert. */ 95 DECL_NO_RETURN(DECLINLINE(void)) RT_NOCRT(exit)(int iExitCode) { AssertMsgFailed(("exit: iExitCode=%d\n", iExitCode)); } 96 DECL_NO_RETURN(DECLINLINE(void)) RT_NOCRT(abort)(void) { AssertMsgFailed(("abort\n")); } 97 98 /* 99 * Underscored versions: 100 */ 101 DECLINLINE(void *) RT_NOCRT(_malloc)(size_t cb) 102 { 103 return RTMemAlloc(cb); 104 } 105 106 DECLINLINE(void *) RT_NOCRT(_calloc)(size_t cItems, size_t cbItem) 107 { 108 return RTMemAllocZ(cItems * cbItem); /* caller responsible for overflow issues. */ 109 } 110 111 DECLINLINE(void *) RT_NOCRT(_realloc)(void *pvOld, size_t cbNew) 112 { 113 return RTMemRealloc(pvOld, cbNew); 114 } 115 116 DECLINLINE(void) RT_NOCRT(_free)(void *pv) 117 { 118 RTMemFree(pv); 119 } 120 121 DECLINLINE(const char *) RT_NOCRT(_getenv)(const char *pszVar) 122 { 123 return RTEnvGet(pszVar); 124 } 125 126 void *RT_NOCRT(_bsearch)(const void *pvKey, const void *pvBase, size_t cEntries, size_t cbEntry, 127 int (*pfnCompare)(const void *pv1, const void *pv2)); 128 void RT_NOCRT(_qsort)(void *pvBase, size_t cEntries, size_t cbEntry, 129 int (*pfnCompare)(const void *pv1, const void *pv2)); 130 void RT_NOCRT(_qsort_r)(void *pvBase, size_t cEntries, size_t cbEntry, 131 int (*pfnCompare)(const void *pv1, const void *pv2, void *pvUser), void *pvUser); 132 133 /* Map exit & abort onto fatal assert. */ 134 DECL_NO_RETURN(DECLINLINE(void)) RT_NOCRT(_exit)(int iExitCode) { AssertMsgFailed(("_exit: iExitCode=%d\n", iExitCode)); } 135 DECL_NO_RETURN(DECLINLINE(void)) RT_NOCRT(_abort)(void) { AssertMsgFailed(("_abort\n")); } 136 137 /* Some windows CRT error control functions we totally ignore (only underscored): */ 138 # define _set_error_mode(a_Mode) (0) 139 # define _set_abort_behavior(a_fFlags, a_fMask) (0) 140 141 /* 142 * No-CRT aliases. 143 */ 76 144 # if !defined(RT_WITHOUT_NOCRT_WRAPPERS) && !defined(RT_WITHOUT_NOCRT_WRAPPER_ALIASES) 77 145 # define malloc RT_NOCRT(malloc) … … 79 147 # define realloc RT_NOCRT(realloc) 80 148 # define free RT_NOCRT(free) 149 # define getenv RT_NOCRT(getenv) 150 # define bsearch RT_NOCRT(bsearch) 151 # define exit RT_NOCRT(exit) 152 # define abort RT_NOCRT(abort) 153 154 # define _malloc RT_NOCRT(malloc) 155 # define _calloc RT_NOCRT(calloc) 156 # define _realloc RT_NOCRT(realloc) 157 # define _free RT_NOCRT(free) 158 # define _getenv RT_NOCRT(getenv) 159 # define _bsearch RT_NOCRT(bsearch) 160 # define _exit RT_NOCRT(exit) 161 # define _abort RT_NOCRT(abort) 81 162 # endif 82 163
Note:
See TracChangeset
for help on using the changeset viewer.