Skip to content

Commit

Permalink
Merge pull request #373 from barracuda156/ppc
Browse files Browse the repository at this point in the history
threads.h: fix for older macOS builds
  • Loading branch information
fador authored Oct 18, 2023
2 parents 8523c96 + fac849e commit 91f04b4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/threads.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@

#include <pthread.h>

#ifdef __APPLE__
#include <AvailabilityMacros.h>
#endif

#if defined(__GNUC__) && !defined(__MINGW32__)
#include <unistd.h> // IWYU pragma: export
#include <time.h> // IWYU pragma: export
Expand Down Expand Up @@ -84,9 +88,9 @@

#endif //__GNUC__

#ifdef __APPLE__
// POSIX semaphores are deprecated on Mac so we use Grand Central Dispatch
// semaphores instead.
#if defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED > 1050 && !defined(__ppc__)
// POSIX semaphores are deprecated on Mac so we use Grand Central Dispatch semaphores instead.
// However GCD is supported only on 10.6+, and is not supported on any ppc, including 10.6 Rosetta.
#include <dispatch/dispatch.h>
typedef dispatch_semaphore_t kvz_sem_t;

Expand All @@ -113,7 +117,7 @@ static INLINE void kvz_sem_destroy(kvz_sem_t *sem)
}

#else
// Use POSIX semaphores.
// Use POSIX semaphores. This is also a fallback for old Darwin.
#include <semaphore.h>

typedef sem_t kvz_sem_t;
Expand Down

0 comments on commit 91f04b4

Please sign in to comment.