Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

threads.h: fix for older macOS builds #373

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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