diff mbox

[PATCHv4,2/2] configure.ac check for atomic operations support

Message ID 1419865132-27981-3-git-send-email-maxim.uvarov@linaro.org
State New
Headers show

Commit Message

Maxim Uvarov Dec. 29, 2014, 2:58 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                           |  4 +++-
 platform/linux-generic/m4/configure.m4 | 17 +++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)
 create mode 100644 platform/linux-generic/m4/configure.m4
diff mbox

Patch

diff --git a/configure.ac b/configure.ac
index f0ce7e0..3436925 100644
--- a/configure.ac
+++ b/configure.ac
@@ -47,7 +47,9 @@  AC_ARG_WITH([platform],
     [AS_HELP_STRING([--with-platform=prefix],
         [Select platform to be used, default linux-generic])],
     [],
-    [with_platform=linux-generic])
+    [with_platform=linux-generic
+     m4_include([./platform/linux-generic/m4/configure.m4])
+    ])
 
 AC_SUBST([with_platform])
 
diff --git a/platform/linux-generic/m4/configure.m4 b/platform/linux-generic/m4/configure.m4
new file mode 100644
index 0000000..00f2f89
--- /dev/null
+++ b/platform/linux-generic/m4/configure.m4
@@ -0,0 +1,17 @@ 
+AC_MSG_CHECKING(for GCC atomic builtins)
+AC_LINK_IFELSE(
+    [AC_LANG_SOURCE(
+      [[int main() {
+        int 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 "GCC-style __atomic builtins not supported by the compiler."
+    echo "Use newer version. For gcc > 4.7.0"
+    exit -1)