From 809a36a6d5beb09ca916ee4313bc19a92099a672 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Fri, 7 Jan 2022 12:36:52 +0300 Subject: Use CreateThread instead of _beginthreadex Change-Id: I4a106a670daaca85cefed08c7baeaa980841a233 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128117 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- sal/osl/w32/thread.cxx | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) (limited to 'sal/osl') diff --git a/sal/osl/w32/thread.cxx b/sal/osl/w32/thread.cxx index 71d11901cebf..fe5ac30b01df 100644 --- a/sal/osl/w32/thread.cxx +++ b/sal/osl/w32/thread.cxx @@ -20,6 +20,7 @@ #include "system.h" #include "thread.hxx" +#include #include #include #include @@ -27,6 +28,7 @@ #include #include #include +#include #include #include @@ -39,7 +41,7 @@ namespace { typedef struct { HANDLE m_hThread; /* OS-handle used for all thread-functions */ - unsigned m_ThreadId; /* identifier for this thread */ + DWORD m_ThreadId; /* identifier for this thread */ sal_Int32 m_nTerminationRequested; oslWorkerFunction m_WorkerFunction; void* m_pData; @@ -50,7 +52,7 @@ typedef struct static oslThread oslCreateThread(oslWorkerFunction pWorker, void* pThreadData, sal_uInt32 nFlags); -static unsigned __stdcall oslWorkerWrapperFunction(void* pData) +static DWORD WINAPI oslWorkerWrapperFunction(_In_ LPVOID pData) { osl_TThreadImpl* pThreadImpl= static_cast(pData); @@ -85,34 +87,17 @@ static oslThread oslCreateThread(oslWorkerFunction pWorker, pThreadImpl->m_pData= pThreadData; pThreadImpl->m_nTerminationRequested= 0; - pThreadImpl->m_hThread= - reinterpret_cast(_beginthreadex(nullptr, /* no security */ + pThreadImpl->m_hThread= CreateThread( + nullptr, /* no security */ 0, /* default stack-size */ oslWorkerWrapperFunction, /* worker-function */ pThreadImpl, /* provide worker-function with data */ nFlags, /* start thread immediately or suspended */ - &pThreadImpl->m_ThreadId)); + &pThreadImpl->m_ThreadId); if(pThreadImpl->m_hThread == nullptr) { - switch (errno) - { - case EAGAIN: - fprintf(stderr, "_beginthreadex errno EAGAIN\n"); - break; - case EINVAL: - fprintf(stderr, "_beginthreadex errno EINVAL\n"); - break; - case EACCES: - fprintf(stderr, "_beginthreadex errno EACCES\n"); - break; - case ENOMEM: - fprintf(stderr, "_beginthreadex undocumented errno ENOMEM - this means not enough VM for stack\n"); - break; - default: - fprintf(stderr, "_beginthreadex unexpected errno %d\n", errno); - break; - } + SAL_WARN("sal.osl", "CreateThread failed:" << WindowsErrorString(GetLastError())); /* create failed */ free(pThreadImpl); -- cgit