Add configure tests for Intel atomic intrinsics
This commit is contained in:
parent
68c75b4697
commit
04bc1eebe7
17
configure.ac
17
configure.ac
@ -177,6 +177,23 @@ if $have_uniscribe; then
|
||||
fi
|
||||
AM_CONDITIONAL(HAVE_UNISCRIBE, $have_uniscribe)
|
||||
|
||||
dnl ===========================================================================
|
||||
|
||||
AC_CACHE_CHECK([for Intel atomic primitives], hb_cv_have_intel_atomic_primitives, [
|
||||
hb_cv_have_intel_atomic_primitives=false
|
||||
AC_TRY_LINK([], [
|
||||
void memory_barrier (void) { __sync_synchronize (); }
|
||||
int atomic_add (int i) { return __sync_fetch_and_add (&i, 1); }
|
||||
int atomic_cmpxchg (int *i, int *j, int *k) { return __sync_bool_compare_and_swap (&i, j, k); }
|
||||
], hb_cv_have_intel_atomic_primitives=true
|
||||
)
|
||||
])
|
||||
if $hb_cv_have_intel_atomic_primitives; then
|
||||
AC_DEFINE(HAVE_INTEL_ATOMIC_PRIMITIVES, 1, [Have Intel __sync_* atomic primitives])
|
||||
fi
|
||||
|
||||
dnl ===========================================================================
|
||||
|
||||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
harfbuzz.pc
|
||||
|
@ -51,7 +51,7 @@ typedef long hb_atomic_int_t;
|
||||
#define hb_atomic_int_add(AI, V) _InterlockedExchangeAdd (&(AI), (V))
|
||||
|
||||
#define hb_atomic_ptr_get(P) (MemoryBarrier (), (void *) *(P))
|
||||
#define hb_atomic_ptr_cmpexch(P,O,N) (_InterlockedCompareExchangePointer ((void * volatile *) (P), (N), (O)) == (O))
|
||||
#define hb_atomic_ptr_cmpexch(P,O,N) (_InterlockedCompareExchangePointer ((void **) (P), (void *) (N), (void *) (O)) == (void *) (O))
|
||||
|
||||
|
||||
#elif !defined(HB_NO_MT) && defined(__APPLE__)
|
||||
@ -62,10 +62,10 @@ typedef int32_t hb_atomic_int_t;
|
||||
#define hb_atomic_int_add(AI, V) (OSAtomicAdd32Barrier ((V), &(AI)) - (V))
|
||||
|
||||
#define hb_atomic_ptr_get(P) (OSMemoryBarrier (), (void *) *(P))
|
||||
#define hb_atomic_ptr_cmpexch(P,O,N) OSAtomicCompareAndSwapPtrBarrier ((O), (N), (void * volatile *) (P))
|
||||
#define hb_atomic_ptr_cmpexch(P,O,N) OSAtomicCompareAndSwapPtrBarrier ((void *) (O), (void *) (N), (void **) (P))
|
||||
|
||||
|
||||
#elif !defined(HB_NO_MT) && defined(__GNUC__)
|
||||
#elif !defined(HB_NO_MT) && defined(HAVE_INTEL_ATOMIC_PRIMITIVES)
|
||||
|
||||
typedef int hb_atomic_int_t;
|
||||
#define hb_atomic_int_add(AI, V) __sync_fetch_and_add (&(AI), (V))
|
||||
@ -84,7 +84,7 @@ typedef int hb_atomic_int_t;
|
||||
#endif
|
||||
|
||||
#define hb_atomic_ptr_get(P) g_atomic_pointer_get (P)
|
||||
#define hb_atomic_ptr_cmpexch(P,O,N) g_atomic_pointer_compare_and_exchange ((void * volatile *) (P), (O), (N))
|
||||
#define hb_atomic_ptr_cmpexch(P,O,N) g_atomic_pointer_compare_and_exchange ((void **) (P), (void *) (O), (void *) (N))
|
||||
|
||||
|
||||
#elif !defined(HB_NO_MT)
|
||||
@ -94,7 +94,7 @@ typedef volatile int hb_atomic_int_t;
|
||||
#define hb_atomic_int_add(AI, V) (((AI) += (V)) - (V))
|
||||
|
||||
#define hb_atomic_ptr_get(P) ((void *) *(P))
|
||||
#define hb_atomic_ptr_cmpexch(P,O,N) (*(P) == (O) ? (*(P) = (N), TRUE) : FALSE)
|
||||
#define hb_atomic_ptr_cmpexch(P,O,N) (* (void * volatile *) (P) == (void *) (O) ? (* (void * volatile *) (P) = (void *) (N), TRUE) : FALSE)
|
||||
|
||||
|
||||
#else /* HB_NO_MT */
|
||||
@ -103,7 +103,7 @@ typedef int hb_atomic_int_t;
|
||||
#define hb_atomic_int_add(AI, V) (((AI) += (V)) - (V))
|
||||
|
||||
#define hb_atomic_ptr_get(P) ((void *) *(P))
|
||||
#define hb_atomic_ptr_cmpexch(P,O,N) *(P)
|
||||
#define hb_atomic_ptr_cmpexch(P,O,N) (* (void **) (P) == (void *) (O) ? (* (void **) (P) = (void *) (N), TRUE) : FALSE)
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -75,7 +75,7 @@ typedef GStaticMutex hb_mutex_impl_t;
|
||||
#define hb_mutex_impl_finish(M) g_static_mutex_free (M)
|
||||
|
||||
|
||||
#elif !defined(HB_NO_MT) && defined(__GNUC__)
|
||||
#elif !defined(HB_NO_MT) && defined(HAVE_INTEL_ATOMIC_PRIMITIVES)
|
||||
|
||||
#if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_YIELD)
|
||||
# include <sched.h>
|
||||
|
Loading…
Reference in New Issue
Block a user