diff options
author | Deal(一线灵) <[email protected]> | 2023-06-02 07:31:37 +0800 |
---|---|---|
committer | GitHub <[email protected]> | 2023-06-01 23:31:37 +0000 |
commit | a91ac01004332d59370c5d6210e1605cb8f708c6 (patch) | |
tree | 7c811333538311e2c643142a85f64dc3bc1be1c8 | |
parent | edc20c87d3cd37608e8fa50556d718cd32755f3d (diff) |
Fix ios crash at sem_init fail with errno=78(function not implemented) (#855)
-rw-r--r-- | common/threads.cpp | 2 | ||||
-rw-r--r-- | common/threads.h | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/common/threads.cpp b/common/threads.cpp index 76a13d9d..c1d9e8b0 100644 --- a/common/threads.cpp +++ b/common/threads.cpp @@ -129,7 +129,7 @@ void althrd_setname(const char *name [[maybe_unused]]) } /* Do not try using libdispatch on systems where it is absent. */ -#if defined(__APPLE__) && ((MAC_OS_X_VERSION_MIN_REQUIRED > 1050) && !defined(__ppc__)) +#if defined(AL_APPLE_HAVE_DISPATCH) namespace al { diff --git a/common/threads.h b/common/threads.h index 2592e5b0..62d80828 100644 --- a/common/threads.h +++ b/common/threads.h @@ -16,8 +16,10 @@ #if defined(__APPLE__) #include <AvailabilityMacros.h> -#if (MAC_OS_X_VERSION_MIN_REQUIRED > 1050) && !defined(__ppc__) +#include <TargetConditionals.h> +#if (((MAC_OS_X_VERSION_MIN_REQUIRED > 1050) && !defined(__ppc__)) || TARGET_OS_IOS || TARGET_OS_TV) #include <dispatch/dispatch.h> +#define AL_APPLE_HAVE_DISPATCH 1 #else #include <semaphore.h> /* Fallback option for Apple without a working libdispatch */ #endif @@ -32,7 +34,7 @@ namespace al { class semaphore { #ifdef _WIN32 using native_type = void*; -#elif defined(__APPLE__) && ((MAC_OS_X_VERSION_MIN_REQUIRED > 1050) && !defined(__ppc__)) +#elif defined(AL_APPLE_HAVE_DISPATCH) using native_type = dispatch_semaphore_t; #else using native_type = sem_t; |