From 8e62b6f6a29af65c31fc4f9f36a573f24862f421 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Fri, 5 Aug 2016 22:03:12 +0300 Subject: Use GCC atomic intrinsics for PowerPC 32/64 (GCC 4.8+ and clang 3.8+) * src/atomic_ops/sysdeps/gcc/powerpc.h: Include generic.h and do not include all_aligned_atomic_load_store.h, test_and_set_t_is_ao_t.h if GCC 4.8+ or clang 3.8+ unless AO_DISABLE_GCC_ATOMICS. * src/atomic_ops/sysdeps/gcc/powerpc.h (AO_nop_full, AO_lwsync, AO_nop_write, AO_nop_read, AO_load_acquire, AO_store_release, AO_test_and_set, AO_test_and_set_release, AO_test_and_set_full, AO_compare_and_swap, AO_compare_and_swap_acquire, AO_compare_and_swap_release, AO_compare_and_swap_full, AO_fetch_compare_and_swap, AO_fetch_compare_and_swap_acquire, AO_fetch_compare_and_swap_release, AO_fetch_compare_and_swap_full, AO_fetch_and_add, AO_fetch_and_add_acquire, AO_fetch_and_add_release, AO_fetch_and_add_full, AO_T_IS_INT): Do not define if generic.h is included. --- src/atomic_ops/sysdeps/gcc/powerpc.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/atomic_ops/sysdeps/gcc/powerpc.h b/src/atomic_ops/sysdeps/gcc/powerpc.h index 5bee475..7232117 100644 --- a/src/atomic_ops/sysdeps/gcc/powerpc.h +++ b/src/atomic_ops/sysdeps/gcc/powerpc.h @@ -20,6 +20,22 @@ /* http://www-106.ibm.com/developerworks/eserver/articles/powerpc.html. */ /* There appears to be no implicit ordering between any kind of */ /* independent memory references. */ + +/* TODO: Implement double-wide operations if available. */ + +#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) \ + || __clang_major__ > 3 \ + || (__clang_major__ == 3 && __clang_minor__ >= 8)) \ + && !defined(AO_DISABLE_GCC_ATOMICS) + /* Probably, it could be enabled even for earlier gcc/clang versions. */ + + /* TODO: As of clang-3.8.1, it emits lwsync in AO_load_acquire */ + /* (i.e., the code is less efficient than the one given below). */ + +# include "generic.h" + +#else /* AO_DISABLE_GCC_ATOMICS */ + /* Architecture enforces some ordering based on control dependence. */ /* I don't know if that could help. */ /* Data-dependent loads are always ordered. */ @@ -358,4 +374,4 @@ AO_fetch_and_add_full(volatile AO_t *addr, AO_t incr) { # define AO_T_IS_INT #endif -/* TODO: Implement double-wide operations if available. */ +#endif /* AO_DISABLE_GCC_ATOMICS */ -- cgit v1.2.1