From a91ac01004332d59370c5d6210e1605cb8f708c6 Mon Sep 17 00:00:00 2001 From: "Deal(一线灵)" Date: Fri, 2 Jun 2023 07:31:37 +0800 Subject: Fix ios crash at sem_init fail with errno=78(function not implemented) (#855) --- common/threads.cpp | 2 +- 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 -#if (MAC_OS_X_VERSION_MIN_REQUIRED > 1050) && !defined(__ppc__) +#include +#if (((MAC_OS_X_VERSION_MIN_REQUIRED > 1050) && !defined(__ppc__)) || TARGET_OS_IOS || TARGET_OS_TV) #include +#define AL_APPLE_HAVE_DISPATCH 1 #else #include /* 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; -- cgit v1.2.3