On 12/23/2014 04:26 PM, Ola Liljedahl wrote:
On 23 December 2014 at 10:13, Maxim Uvarov <[email protected]> wrote:
Odp atomic operations based on compiler build-ins. Make
sure that compiler supports such operation at configure
stage.

Signed-off-by: Maxim Uvarov <[email protected]>
---
  v3: make atomic checks platfrom specific

  configure.ac                           |  4 +++-
  platform/linux-generic/m4/configure.m4 | 18 ++++++++++++++++++
  2 files changed, 21 insertions(+), 1 deletion(-)
  create mode 100644 platform/linux-generic/m4/configure.m4

diff --git a/configure.ac b/configure.ac
index 377e8be..f55beca 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..bfb1fb0
--- /dev/null
+++ b/platform/linux-generic/m4/configure.m4
@@ -0,0 +1,18 @@
+AC_MSG_CHECKING(for GCC atomic builtins)
+AC_LINK_IFELSE(
+    [AC_LANG_SOURCE(
+      [[#include <stdint.h>
+        int main() {
+        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"
Why >4.7.3? Minor releases do not introduce major new features.
__atomic support was introduced on GCC 4.7.0.
I have ubuntu 12.04 and there is 4.7.3. And it definatelly works there. So I just set tested value.
I'm ok to change it to 4.7.0.

Maxim.


+    exit -1)
--
1.8.5.1.163.gd7aced9


_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp


_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to