From af6d18829e2b8a63294f6433065e1ce1bcfac1d7 Mon Sep 17 00:00:00 2001 From: elasota Date: Sun, 21 May 2023 21:53:18 -0400 Subject: [PATCH] Fix compile failure on systems where pthread_t isn't a pointer, and possibly also systems where it isn't pointer-sized either --- AerofoilX/GpSystemServices_X.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/AerofoilX/GpSystemServices_X.cpp b/AerofoilX/GpSystemServices_X.cpp index 32e0f8f..fbcb8d9 100644 --- a/AerofoilX/GpSystemServices_X.cpp +++ b/AerofoilX/GpSystemServices_X.cpp @@ -13,6 +13,8 @@ #include #include #include +#include +#include struct GpSystemServices_X_ThreadStartParams { @@ -52,13 +54,19 @@ void *GpSystemServices_X::CreateThread(ThreadFunc_t threadFunc, void *context) if (!evt) return nullptr; + pthread_t *threadPtr = static_cast(malloc(sizeof(pthread_t))); + if (!threadPtr) + { + evt->Destroy(); + return nullptr; + } + GpSystemServices_X_ThreadStartParams startParams; startParams.m_threadContext = context; startParams.m_threadFunc = threadFunc; startParams.m_threadStartEvent = evt; - pthread_t thread = nullptr; - if (pthread_create(&thread, nullptr, StaticStartThread, &startParams) != 0) + if (pthread_create(threadPtr, nullptr, StaticStartThread, &startParams) != 0) { evt->Destroy(); return nullptr; @@ -67,7 +75,7 @@ void *GpSystemServices_X::CreateThread(ThreadFunc_t threadFunc, void *context) evt->Wait(); evt->Destroy(); - return thread; + return static_cast(threadPtr); } bool GpSystemServices_X::Beep() const