summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkira TAGOH <akira@tagoh.org>2013-05-16 13:41:32 +0900
committerAkira TAGOH <akira@tagoh.org>2013-05-16 14:58:35 +0900
commit0f9aa8759df563332db60055ae33dd9424ebf802 (patch)
treee50f0d13cabf6edc29326128a26da5afd9a0bced
parent93137252cfab1c38e1c9137d831c177665e0592a (diff)
Fix missing OSAtomicCompareAndSwapPtrBarrier() on Mac OS X 10.4
based on hb-atomic-private.hh in harfbuzz
-rw-r--r--src/fcatomic.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/fcatomic.h b/src/fcatomic.h
index a7643113..362e5216 100644
--- a/src/fcatomic.h
+++ b/src/fcatomic.h
@@ -70,13 +70,25 @@ typedef LONG fc_atomic_int_t;
#elif !defined(FC_NO_MT) && defined(__APPLE__)
#include <libkern/OSAtomic.h>
+#ifdef __MAC_OS_X_MIN_REQUIRED
+#include <AvailabilityMacros.h>
+#elif defined(__IPHONE_OS_MIN_REQUIRED)
+#include <Availability.h>
+#endif
typedef int fc_atomic_int_t;
#define fc_atomic_int_add(AI, V) (OSAtomicAdd32Barrier ((V), &(AI)) - (V))
#define fc_atomic_ptr_get(P) (OSMemoryBarrier (), (void *) *(P))
+#if (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4 || __IPHONE_VERSION_MIN_REQUIRED >= 20100)
#define fc_atomic_ptr_cmpexch(P,O,N) OSAtomicCompareAndSwapPtrBarrier ((void *) (O), (void *) (N), (void **) (P))
-
+#else
+#if __ppc64__ || __x86_64__
+#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
#elif !defined(FC_NO_MT) && defined(HAVE_INTEL_ATOMIC_PRIMITIVES)