Skip to content

Commit

Permalink
macOS: use libdispatch only where available (#1596)
Browse files Browse the repository at this point in the history
Signed-off-by: Sergey Fedorov <[email protected]>
  • Loading branch information
barracuda156 authored Dec 18, 2023
1 parent 975f6f3 commit a7befce
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
8 changes: 6 additions & 2 deletions IlmBase/IlmThread/IlmThreadSemaphore.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
#include "IlmThreadExport.h"
#include "IlmThreadNamespace.h"

#if defined(__APPLE__)
# include <AvailabilityMacros.h>
#endif

#if defined _WIN32 || defined _WIN64
# ifdef NOMINMAX
# undef NOMINMAX
Expand All @@ -56,7 +60,7 @@

#ifdef HAVE_POSIX_SEMAPHORES
# include <semaphore.h>
#elif defined(__APPLE__)
#elif defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED > 1050 && !defined(__ppc__)
# include <dispatch/dispatch.h>
#else
# ifdef ILMBASE_FORCE_CXX03
Expand Down Expand Up @@ -94,7 +98,7 @@ class ILMTHREAD_EXPORT Semaphore

mutable sem_t _semaphore;

#elif defined(__APPLE__)
#elif defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED > 1050 && !defined(__ppc__)
mutable dispatch_semaphore_t _semaphore;

#else
Expand Down
6 changes: 6 additions & 0 deletions IlmBase/IlmThread/IlmThreadSemaphoreOSX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@

#if defined(__APPLE__)

#include <AvailabilityMacros.h>

#if MAC_OS_X_VERSION_MIN_REQUIRED > 1050 && !defined(__ppc__)

#include "IlmThreadSemaphore.h"
#include "Iex.h"

Expand Down Expand Up @@ -96,3 +100,5 @@ Semaphore::value () const
ILMTHREAD_INTERNAL_NAMESPACE_SOURCE_EXIT

#endif

#endif
7 changes: 6 additions & 1 deletion IlmBase/IlmThread/IlmThreadSemaphorePosixCompat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@
#include "IlmBaseConfig.h"
#include "IlmThreadSemaphore.h"

#if !defined (HAVE_POSIX_SEMAPHORES) && !defined (__APPLE__)
#if defined(__APPLE__)
# include <AvailabilityMacros.h>
#endif

#if !defined (HAVE_POSIX_SEMAPHORES) && \
(!defined(__APPLE__) || (defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED < 1060 || defined(__ppc__))))
#if (!defined (_WIN32) && !defined (_WIN64)) || defined (__MINGW64_VERSION_MAJOR)

#include "Iex.h"
Expand Down

0 comments on commit a7befce

Please sign in to comment.