diff mbox

[PATCHv2] configure.ac check for atomic operations support

Message ID 1418397092-26112-1-git-send-email-maxim.uvarov@linaro.org
State New
Headers show

Commit Message

Maxim Uvarov Dec. 12, 2014, 3:11 p.m. UTC
Odp atomic operations based on compiler build-ins. Make
sure that compiler supports such operation at configure
stage.

Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
---
 configure.ac | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
diff mbox

Patch

diff --git a/configure.ac b/configure.ac
index 8dbad4b..7bd2a47 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,6 +40,25 @@  AC_TYPE_INT32_T
 AC_TYPE_UINT32_T
 AC_TYPE_UINT64_T
 
+AC_MSG_CHECKING(for GCC atomic builtins)
+AC_LINK_IFELSE(
+    [AC_LANG_SOURCE(
+      [[#include <stdint.h>
+        int main() {
+        volatile uint32_t v = 1;
+        __atomic_fetch_add(&v, 1, __ATOMIC_RELAXED);
+        __atomic_fetch_sub(&v, 1, __ATOMIC_RELAXED);
+        __atomic_store_n(&v, 1, __ATOMIC_RELAXED);
+        __atomic_load_n(&v, __ATOMIC_RELAXED);
+        return 0;
+        }
+    ]])],
+    AC_MSG_RESULT(yes),
+    AC_MSG_RESULT(no)
+    echo "Atomic operation are not supported by your compiller."
+    echo "Use newer version. For gcc > 4.7.3"
+    exit -1)
+
 ##########################################################################
 # Determine which platform to build for
 ##########################################################################