summaryrefslogtreecommitdiff
path: root/sal/osl
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2022-01-07 12:36:52 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2022-01-07 18:21:09 +0100
commit809a36a6d5beb09ca916ee4313bc19a92099a672 (patch)
treee502b2b6659de27ddae9164e643ed92d56622541 /sal/osl
parentdcb7bd026cc1813eaee8b7dadba0583348b4458e (diff)
Use CreateThread instead of _beginthreadex
Change-Id: I4a106a670daaca85cefed08c7baeaa980841a233 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128117 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sal/osl')
-rw-r--r--sal/osl/w32/thread.cxx31
1 files changed, 8 insertions, 23 deletions
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 <comphelper/windowserrorstring.hxx>
#include <osl/diagnose.h>
#include <osl/mutex.hxx>
#include <osl/thread.h>
@@ -27,6 +28,7 @@
#include <osl/time.h>
#include <osl/interlck.h>
#include <rtl/tencinfo.h>
+#include <sal/log.hxx>
#include <systools/win32/comtools.hxx>
#include <errno.h>
@@ -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<osl_TThreadImpl*>(pData);
@@ -85,34 +87,17 @@ static oslThread oslCreateThread(oslWorkerFunction pWorker,
pThreadImpl->m_pData= pThreadData;
pThreadImpl->m_nTerminationRequested= 0;
- pThreadImpl->m_hThread=
- reinterpret_cast<HANDLE>(_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);