VirtualBox

Changeset 96052 in vbox


Ignore:
Timestamp:
Aug 5, 2022 10:48:48 AM (2 years ago)
Author:
vboxsync
Message:

IPRT/nocrt: Added no-CRT per-thread data like errno and strtok state. Implemented strtol and errno accessor. bugref:10261

Location:
trunk
Files:
5 added
5 edited

Legend:

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

    r95975 r96052  
    4646
    4747RT_C_DECLS_BEGIN
     48
    4849RTDECL(int *) rtNoCrtGetErrnoPtr(void);
    4950# define errno (*rtNoCrtGetErrnoPtr())
  • trunk/src/VBox/Runtime/Makefile.kmk

    r96045 r96052  
    18021802        common/string/nocrt-strdup.cpp \
    18031803        common/string/nocrt-stricmp.cpp \
    1804         common/string/strtok_r.cpp
     1804        common/string/nocrt-strtol.cpp \
     1805        common/string/strtok_r.cpp \
     1806        r3/nocrt-per-thread-1.cpp \
     1807        r3/nocrt-per-thread-2.cpp \
     1808        r3/nocrt-errno.cpp
    18051809  RuntimeR3_SOURCES.x86 = $(RuntimeBaseR3_SOURCES.x86) \
    18061810        common/misc/setjmp.asm \
  • trunk/src/VBox/Runtime/common/misc/thread.cpp

    r95200 r96052  
    394394#ifdef RT_WITH_ICONV_CACHE
    395395        rtStrIconvCacheInit(pThread);
     396#endif
     397#if defined(IPRT_NO_CRT) && defined(IN_RING3)
     398        pThread->NoCrt.enmAllocType = RTNOCRTTHREADDATA::kAllocType_Embedded;
     399        RTListInit(&pThread->NoCrt.ListEntry);
    396400#endif
    397401        rc = RTSemEventMultiCreate(&pThread->EventUser);
     
    465469                    ASMAtomicIncU32(&g_cThreadInTree);
    466470                    ASMAtomicIncU32(&g_acRTThreadTypeStats[pThread->enmType]);
     471
     472#if defined(IPRT_NO_CRT) && defined(IN_RING3)
     473                    RTTLS const iTlsPerThread = g_iTlsRtNoCrtPerThread;
     474                    if (   iTlsPerThread != NIL_RTTLS
     475                        && RTTlsGet(iTlsPerThread) == NULL)
     476                        RTTlsSet(iTlsPerThread, &pThread->NoCrt);
     477#endif
    467478                }
    468479
     
    687698     */
    688699    rtThreadRemove(pThread);
     700
     701#if defined(IPRT_NO_CRT) && defined(IN_RING3)
     702    RTTLS const iTlsPerThread = g_iTlsRtNoCrtPerThread;
     703    if (   iTlsPerThread != NIL_RTTLS
     704        && RTTlsGet(iTlsPerThread) == &pThread->NoCrt)
     705        RTTlsSet(iTlsPerThread, &g_RtNoCrtPerThreadDummy);
     706#endif
     707
    689708    rtThreadRelease(pThread);
    690709}
  • trunk/src/VBox/Runtime/common/string/nocrt-strtok.cpp

    r96045 r96052  
    2929*   Header Files                                                                                                                 *
    3030*********************************************************************************************************************************/
    31 #include "internal/iprt.h"
     31#include "internal/nocrt.h"
    3232#include <iprt/string.h>
    3333
     
    3636char *RT_NOCRT(strtok)(char *psz, const char *pszDelimiters)
    3737{
    38     static char *s_pszState = NULL; /** @todo make this a TLS variable. */
    39     return RT_NOCRT(strtok_r)(psz, pszDelimiters, &s_pszState);
     38    PRTNOCRTTHREADDATA pNoCrtData = rtNoCrtThreadDataGet();
     39    if (pNoCrtData)
     40        return RT_NOCRT(strtok_r)(psz, pszDelimiters, &pNoCrtData->pszStrToken);
     41
     42    static char *s_pszFallback = NULL;
     43    return RT_NOCRT(strtok_r)(psz, pszDelimiters, &s_pszFallback);
    4044}
    4145RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(strtok);
  • trunk/src/VBox/Runtime/include/internal/thread.h

    r94718 r96052  
    4242#ifdef RT_WITH_ICONV_CACHE
    4343# include "internal/string.h"
     44#endif
     45#if defined(IPRT_NO_CRT) && defined(IN_RING3)
     46# include "internal/nocrt.h"
    4447#endif
    4548
     
    106109    /** Handle cache for iconv.
    107110     * @remarks ASSUMES sizeof(void *) >= sizeof(iconv_t). */
    108     void *ahIconvs[RTSTRICONV_END];
     111    void                   *ahIconvs[RTSTRICONV_END];
    109112#endif
    110113#ifdef IPRT_WITH_GENERIC_TLS
     
    114117    /** Thread name. */
    115118    char                    szName[RTTHREAD_NAME_LEN];
     119#if defined(IPRT_NO_CRT) && defined(IN_RING3)
     120    /** No-CRT per thread data. */
     121    RTNOCRTTHREADDATA       NoCrt;
     122#endif
    116123} RTTHREADINT;
    117124/** Pointer to the internal representation of a thread. */
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