summaryrefslogtreecommitdiff
path: root/src/base/atomicops.h
diff options
context:
space:
mode:
authorRiku Voipio <riku.voipio@linaro.org>2014-01-29 10:54:29 +0200
committerRiku Voipio <riku.voipio@linaro.org>2014-02-05 16:35:49 +0200
commite8fe990fa06e337a07059c55adc6ed2a0888de95 (patch)
tree3efc0ee5c49277dcab4985c0d6cd5e11d520cbdd /src/base/atomicops.h
parentfa4b1c401da1ac381d4d72172825231b3d5518d9 (diff)
downloadgperftools-e8fe990fa06e337a07059c55adc6ed2a0888de95.tar.gz
implement atomics with gcc intrinsics
Gcc after 4.7 provides atomic builtins[1]. Use these instead of adding yet-another-assembly port for Aarch64 (64-bit ARM). This patch enables succesfully building and running atomicops unittest on Aarch64. This patch enables using gcc builtins only when no assembly implementation is provided. But as a quick check, atomicops_unittest and rest of testsuite passes with atomicops-internals-gcc also ARMv7 and X86_64 if the ifdef in atomicops is adjusted to prefer the generic implementation. [1] http://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html
Diffstat (limited to 'src/base/atomicops.h')
-rw-r--r--src/base/atomicops.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/base/atomicops.h b/src/base/atomicops.h
index f3cf1ad..30c819c 100644
--- a/src/base/atomicops.h
+++ b/src/base/atomicops.h
@@ -98,6 +98,9 @@
// ------------------------------------------------------------------------
#include "base/arm_instruction_set_select.h"
+#define GCC_VERSION (__GNUC__ * 10000 \
+ + __GNUC_MINOR__ * 100 \
+ + __GNUC_PATCHLEVEL__)
// TODO(csilvers): match piii, not just __i386. Also, match k8
#if defined(__MACH__) && defined(__APPLE__)
@@ -114,12 +117,13 @@
#include "base/atomicops-internals-linuxppc.h"
#elif defined(__GNUC__) && defined(__mips__)
#include "base/atomicops-internals-mips.h"
+#elif defined(__GNUC__) && GCC_VERSION >= 40700
+#include "base/atomicops-internals-gcc.h"
#else
// Assume x86 for now. If you need to support a new architecture and
// don't know how to implement atomic ops, you can probably get away
// with using pthreads, since atomicops is only used by spinlock.h/cc
-//#error You need to implement atomic operations for this architecture
-#include "base/atomicops-internals-x86.h"
+#error You need to implement atomic operations for this architecture
#endif
// Signed type that can hold a pointer and supports the atomic ops below, as