aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorSergey Fedorov <[email protected]>2023-05-28 14:28:00 +0800
committerGitHub <[email protected]>2023-05-28 06:28:00 +0000
commitcd781b1511d437816aac65f89646bd80dbf7c040 (patch)
tree068ef176fa47787d239d948c89a278b5d6426177 /common
parent118c729680d6664f793f8d88ff0b7548137847d3 (diff)
threads: do not use libdispatch where it is not present (#851)
Fixes: https://github.com/kcat/openal-soft/issues/850
Diffstat (limited to 'common')
-rw-r--r--common/threads.cpp3
-rw-r--r--common/threads.h7
2 files changed, 8 insertions, 2 deletions
diff --git a/common/threads.cpp b/common/threads.cpp
index 136c4813..76a13d9d 100644
--- a/common/threads.cpp
+++ b/common/threads.cpp
@@ -128,7 +128,8 @@ void althrd_setname(const char *name [[maybe_unused]])
#endif
}
-#ifdef __APPLE__
+/* Do not try using libdispatch on systems where it is absent. */
+#if defined(__APPLE__) && ((MAC_OS_X_VERSION_MIN_REQUIRED > 1050) && !defined(__ppc__))
namespace al {
diff --git a/common/threads.h b/common/threads.h
index 59fccd12..2592e5b0 100644
--- a/common/threads.h
+++ b/common/threads.h
@@ -15,7 +15,12 @@
#endif
#if defined(__APPLE__)
+#include <AvailabilityMacros.h>
+#if (MAC_OS_X_VERSION_MIN_REQUIRED > 1050) && !defined(__ppc__)
#include <dispatch/dispatch.h>
+#else
+#include <semaphore.h> /* Fallback option for Apple without a working libdispatch */
+#endif
#elif !defined(_WIN32)
#include <semaphore.h>
#endif
@@ -27,7 +32,7 @@ namespace al {
class semaphore {
#ifdef _WIN32
using native_type = void*;
-#elif defined(__APPLE__)
+#elif defined(__APPLE__) && ((MAC_OS_X_VERSION_MIN_REQUIRED > 1050) && !defined(__ppc__))
using native_type = dispatch_semaphore_t;
#else
using native_type = sem_t;