Restore fcatomic compatibility with Mac OS X 10.4.

Reverts the part of 6def66164a that
removed the fc_atomic_ptr_cmpexch compatibility code for systems earlier
than Mac OS X 10.5.

Reverts the part of 447b9ccc7d that moved
the definition of fc_atomic_ptr_get into the Mac OS X > 10.4 block. That
code is still needed on 10.4 and is implemented using functions that are
available on 10.4.

Compare against MAC_OS_X_VERSION_MIN_REQUIRED using a number not a
constant because the constant is not available on earlier SDKs.
This commit is contained in:
Ryan Schmidt 2021-07-08 16:17:44 -05:00 committed by Akira TAGOH
parent 8b3de9bd7f
commit 3a7ad1b49f
1 changed files with 7 additions and 4 deletions

View File

@ -72,8 +72,6 @@ typedef int fc_atomic_int_t;
#define FC_ATOMIC_INT_FORMAT "d" #define FC_ATOMIC_INT_FORMAT "d"
#define fc_atomic_int_add(AI, V) (OSAtomicAdd32Barrier ((V), &(AI)) - (V)) #define fc_atomic_int_add(AI, V) (OSAtomicAdd32Barrier ((V), &(AI)) - (V))
#if (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4 || __IPHONE_OS_VERSION_MIN_REQUIRED >= 20100)
#if SIZEOF_VOID_P == 8 #if SIZEOF_VOID_P == 8
#define fc_atomic_ptr_get(P) OSAtomicAdd64Barrier (0, (int64_t*)(P)) #define fc_atomic_ptr_get(P) OSAtomicAdd64Barrier (0, (int64_t*)(P))
#elif SIZEOF_VOID_P == 4 #elif SIZEOF_VOID_P == 4
@ -81,10 +79,15 @@ typedef int fc_atomic_int_t;
#else #else
#error "SIZEOF_VOID_P not 4 or 8 (assumes CHAR_BIT is 8)" #error "SIZEOF_VOID_P not 4 or 8 (assumes CHAR_BIT is 8)"
#endif #endif
#define fc_atomic_ptr_cmpexch(P,O,N) OSAtomicCompareAndSwapPtrBarrier ((void *) (O), (void *) (N), (void **) (P))
#if (MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 || __IPHONE_OS_VERSION_MIN_REQUIRED >= 20100)
#define fc_atomic_ptr_cmpexch(P,O,N) OSAtomicCompareAndSwapPtrBarrier ((void *) (O), (void *) (N), (void **) (P))
#else #else
#error "Your macOS / iOS targets are too old" #if __LP64__
#define fc_atomic_ptr_cmpexch(P,O,N) OSAtomicCompareAndSwap64Barrier ((int64_t) (O), (int64_t) (N), (int64_t *) (P))
#else
#define fc_atomic_ptr_cmpexch(P,O,N) OSAtomicCompareAndSwap32Barrier ((int32_t) (O), (int32_t) (N), (int32_t *) (P))
#endif
#endif #endif