VirtualBox

Ignore:
Timestamp:
Aug 2, 2022 12:55:08 AM (2 years ago)
Author:
vboxsync
Message:

include/iprt/nocrt: Prototyped a whole bunch of things to make mesa (almost) compile. bugref:10261

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/nocrt/stdlib.h

    r95818 r95975  
    3030#endif
    3131
    32 #include <iprt/types.h>
     32#include <iprt/assert.h>
     33#include <iprt/env.h>
    3334#include <iprt/mem.h>
     35#include <limits.h>
    3436
    3537RT_C_DECLS_BEGIN
     38
     39#define EXIT_SUCCESS    RTEXITCODE_SUCCESS
     40#define EXIT_FAILURE    RTEXITCODE_FAILURE
     41
    3642
    3743typedef void FNRTNOCRTATEXITCALLBACK(void) /*RT_NOEXCEPT*/;
     
    7480}
    7581
     82DECLINLINE(const char *) RT_NOCRT(getenv)(const char *pszVar)
     83{
     84    return RTEnvGet(pszVar);
     85}
     86
     87void       *RT_NOCRT(bsearch)(const void *pvKey, const void *pvBase, size_t cEntries, size_t cbEntry,
     88                              int (*pfnCompare)(const void *pv1, const void *pv2));
     89void        RT_NOCRT(qsort)(void *pvBase, size_t cEntries, size_t cbEntry,
     90                            int (*pfnCompare)(const void *pv1, const void *pv2));
     91void        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. */
     95DECL_NO_RETURN(DECLINLINE(void)) RT_NOCRT(exit)(int iExitCode) { AssertMsgFailed(("exit: iExitCode=%d\n", iExitCode)); }
     96DECL_NO_RETURN(DECLINLINE(void)) RT_NOCRT(abort)(void) { AssertMsgFailed(("abort\n")); }
     97
     98/*
     99 * Underscored versions:
     100 */
     101DECLINLINE(void *) RT_NOCRT(_malloc)(size_t cb)
     102{
     103    return RTMemAlloc(cb);
     104}
     105
     106DECLINLINE(void *) RT_NOCRT(_calloc)(size_t cItems, size_t cbItem)
     107{
     108    return RTMemAllocZ(cItems * cbItem); /* caller responsible for overflow issues. */
     109}
     110
     111DECLINLINE(void *) RT_NOCRT(_realloc)(void *pvOld, size_t cbNew)
     112{
     113    return RTMemRealloc(pvOld, cbNew);
     114}
     115
     116DECLINLINE(void) RT_NOCRT(_free)(void *pv)
     117{
     118    RTMemFree(pv);
     119}
     120
     121DECLINLINE(const char *) RT_NOCRT(_getenv)(const char *pszVar)
     122{
     123    return RTEnvGet(pszVar);
     124}
     125
     126void       *RT_NOCRT(_bsearch)(const void *pvKey, const void *pvBase, size_t cEntries, size_t cbEntry,
     127                               int (*pfnCompare)(const void *pv1, const void *pv2));
     128void        RT_NOCRT(_qsort)(void *pvBase, size_t cEntries, size_t cbEntry,
     129                             int (*pfnCompare)(const void *pv1, const void *pv2));
     130void        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. */
     134DECL_NO_RETURN(DECLINLINE(void)) RT_NOCRT(_exit)(int iExitCode) { AssertMsgFailed(("_exit: iExitCode=%d\n", iExitCode)); }
     135DECL_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 */
    76144# if !defined(RT_WITHOUT_NOCRT_WRAPPERS) && !defined(RT_WITHOUT_NOCRT_WRAPPER_ALIASES)
    77145#  define malloc    RT_NOCRT(malloc)
     
    79147#  define realloc   RT_NOCRT(realloc)
    80148#  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)
    81162# endif
    82163
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