From cd14d18d0c33b320f1d73867a69c4b601ecd1cb9 Mon Sep 17 00:00:00 2001 From: David Reid Date: Sun, 27 Apr 2025 19:50:35 +1000 Subject: [PATCH] Fix an error when pthread_attr_setstacksize() is unavailable. --- miniaudio.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/miniaudio.h b/miniaudio.h index 9a62ea15..669b9f19 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -11549,6 +11549,7 @@ IMPLEMENTATION #if !defined(MA_WIN32) #include #include /* select() (used for ma_sleep()). */ +#include #include #endif @@ -16222,9 +16223,18 @@ static ma_result ma_thread_create__posix(ma_thread* pThread, ma_thread_priority } #endif - if (stackSize > 0) { - pthread_attr_setstacksize(&attr, stackSize); + #if defined(_POSIX_THREAD_ATTR_STACKSIZE) && _POSIX_THREAD_ATTR_STACKSIZE >= 0 + { + if (stackSize > 0) { + pthread_attr_setstacksize(&attr, stackSize); + } } + #else + { + (void)stackSize; /* Suppress unused parameter warning. */ + } + #endif + if (scheduler != -1) { int priorityMin = sched_get_priority_min(scheduler); @@ -18070,7 +18080,6 @@ DEVICE I/O #ifdef MA_POSIX #include - #include /* No need for dlfcn.h if we're not using runtime linking. */ #ifndef MA_NO_RUNTIME_LINKING