From f54e4e1cbdb11821bb3f66b2b50c793399e0af84 Mon Sep 17 00:00:00 2001 From: barracuda156 Date: Fri, 3 Nov 2023 13:40:25 +0800 Subject: [PATCH 5/5] semaphore: use libdispatch only where it actually exists --- src/util/semaphore.cc | 2 +- src/util/semaphore.h | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git src/util/semaphore.cc src/util/semaphore.cc index afed45e1..88107a36 100644 --- src/util/semaphore.cc +++ src/util/semaphore.cc @@ -13,7 +13,7 @@ #include #endif -#if defined(OS_MACOSX) +#if defined(OS_MACOSX) && (MAC_OS_X_VERSION_MIN_REQUIRED > 1050 && !defined(__ppc__)) Semaphore::Semaphore(int count) { native_handle_ = dispatch_semaphore_create(count); diff --git src/util/semaphore.h src/util/semaphore.h index 13a09927..e40aae0f 100644 --- src/util/semaphore.h +++ src/util/semaphore.h @@ -8,11 +8,15 @@ #ifndef UTIL_SEMAPHORE_H_ #define UTIL_SEMAPHORE_H_ +#ifdef __APPLE__ +#include +#endif + #include "util/build_config.h" #if defined(OS_WIN) #include -#elif defined(OS_MACOSX) +#elif defined(OS_MACOSX) && (MAC_OS_X_VERSION_MIN_REQUIRED > 1050 && !defined(__ppc__)) #include #elif defined(OS_ZOS) #include "zos-semaphore.h" @@ -34,7 +38,7 @@ class Semaphore { // becomes positive and then decrements the counter. void Wait(); -#if defined(OS_MACOSX) +#if defined(OS_MACOSX) && (MAC_OS_X_VERSION_MIN_REQUIRED > 1050 && !defined(__ppc__)) using NativeHandle = dispatch_semaphore_t; #elif defined(OS_POSIX) using NativeHandle = sem_t;