Skip to content

Commit 019e252

Browse files
committed
threads: do not use libdispatch where it is not present
Fixes: #850
1 parent 118c729 commit 019e252

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

common/threads.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ void althrd_setname(const char *name [[maybe_unused]])
128128
#endif
129129
}
130130

131-
#ifdef __APPLE__
131+
/* Do not try using libdispatch on systems where it is absent. */
132+
#if defined(__APPLE__) && ((MAC_OS_X_VERSION_MIN_REQUIRED > 1050) && !defined(__ppc__))
132133

133134
namespace al {
134135

common/threads.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515
#endif
1616

1717
#if defined(__APPLE__)
18+
#include <AvailabilityMacros.h>
19+
#if (MAC_OS_X_VERSION_MIN_REQUIRED > 1050) && !defined(__ppc__)
1820
#include <dispatch/dispatch.h>
21+
#else
22+
#include <semaphore.h> /* Fallback option for Apple without a working libdispatch */
23+
#endif
1924
#elif !defined(_WIN32)
2025
#include <semaphore.h>
2126
#endif
@@ -27,7 +32,7 @@ namespace al {
2732
class semaphore {
2833
#ifdef _WIN32
2934
using native_type = void*;
30-
#elif defined(__APPLE__)
35+
#elif defined(__APPLE__) && ((MAC_OS_X_VERSION_MIN_REQUIRED > 1050) && !defined(__ppc__))
3136
using native_type = dispatch_semaphore_t;
3237
#else
3338
using native_type = sem_t;

0 commit comments

Comments
 (0)