VirtualBox

Ignore:
Timestamp:
Jul 20, 2022 7:37:11 PM (2 years ago)
Author:
vboxsync
Message:

IPRT/thread-win.cpp: IPRT_NO_CRT adjustments. bugref:10261

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/win/thread-win.cpp

    r93115 r95765  
    3232#include <iprt/nt/nt-and-windows.h>
    3333
    34 #include <errno.h>
    35 #include <process.h>
     34#ifndef IPRT_NO_CRT
     35# include <errno.h>
     36# include <process.h>
     37#endif
    3638
    3739#include <iprt/thread.h>
     
    8486*   Internal Functions                                                                                                           *
    8587*********************************************************************************************************************************/
    86 static unsigned __stdcall rtThreadNativeMain(void *pvArgs) RT_NOTHROW_PROTO;
    8788static void rtThreadWinTellDebuggerThreadName(uint32_t idThread, const char *pszName);
    8889DECLINLINE(void) rtThreadWinSetThreadName(PRTTHREADINT pThread, DWORD idThread);
     
    348349 * Wrapper which unpacks the param stuff and calls thread function.
    349350 */
     351#ifndef IPRT_NO_CRT
    350352static unsigned __stdcall rtThreadNativeMain(void *pvArgs) RT_NOTHROW_DEF
     353#else
     354static DWORD __stdcall rtThreadNativeMain(void *pvArgs) RT_NOTHROW_DEF
     355#endif
    351356{
    352357    DWORD           dwThreadId = GetCurrentThreadId();
     
    368373    TlsSetValue(g_dwSelfTLS, NULL);
    369374    rtThreadNativeUninitComAndOle();
     375#ifndef IPRT_NO_CRT
    370376    _endthreadex(rc);
    371     return rc;
     377    return rc; /* not reached */
     378#else
     379    for (;;)
     380        ExitThread(rc);
     381#endif
    372382}
    373383
     
    389399     */
    390400    pThread->hThread = (uintptr_t)INVALID_HANDLE_VALUE;
     401#ifndef IPRT_NO_CRT
    391402    unsigned    uThreadId = 0;
    392     uintptr_t   hThread   = _beginthreadex(NULL, cbStack, rtThreadNativeMain, pThread, 0, &uThreadId);
     403    uintptr_t   hThread   = _beginthreadex(NULL /*pSecAttrs*/, cbStack, rtThreadNativeMain, pThread, 0 /*fFlags*/, &uThreadId);
    393404    if (hThread != 0 && hThread != ~0U)
    394405    {
     
    398409    }
    399410    return RTErrConvertFromErrno(errno);
     411#else
     412    DWORD  idThread = 0;
     413    HANDLE hThread = CreateThread(NULL /*pSecAttrs*/, cbStack, rtThreadNativeMain, pThread, 0 /*fFlags*/, &idThread);
     414    if (hThread != NULL)
     415    {
     416        pThread->hThread = (uintptr_t)hThread;
     417        *pNativeThread = idThread;
     418        return VINF_SUCCESS;
     419    }
     420    return RTErrConvertFromWin32(GetLastError());
     421#endif
    400422}
    401423
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