aboutsummaryrefslogtreecommitdiff
path: root/build-aux/m4/l_atomic.m4
diff options
context:
space:
mode:
authorAnthony Towns <aj@erisian.com.au>2016-08-23 16:55:15 +1000
committerLuke Dashjr <luke-jr+git@utopios.org>2016-09-21 02:43:47 +0000
commit147003c73edb5a949ca403ecf8883c1b8bfaa6c1 (patch)
treeaed40c392423dbc094f3edbf07d6e0d4ebc148a1 /build-aux/m4/l_atomic.m4
parent091cdebfb823734559f9694c4c45eba1598b05ff (diff)
downloadbitcoin-147003c73edb5a949ca403ecf8883c1b8bfaa6c1.tar.xz
Add configure check for -latomic
Github-Pull: #8563 Rebased-From: 878faacd7b3daac437cc689b13422f6432fb5cd0
Diffstat (limited to 'build-aux/m4/l_atomic.m4')
-rw-r--r--build-aux/m4/l_atomic.m440
1 files changed, 40 insertions, 0 deletions
diff --git a/build-aux/m4/l_atomic.m4 b/build-aux/m4/l_atomic.m4
new file mode 100644
index 0000000000..906724b640
--- /dev/null
+++ b/build-aux/m4/l_atomic.m4
@@ -0,0 +1,40 @@
+# Some versions of gcc/libstdc++ require linking with -latomic if
+# using the C++ atomic library.
+#
+# Sourced from http://bugs.debian.org/797228
+
+m4_define([_CHECK_ATOMIC_testbody], [[
+ #include <atomic>
+ #include <cstdint>
+
+ int main() {
+ std::atomic<int64_t> a{};
+
+ int64_t v = 5;
+ int64_t r = a.fetch_add(v);
+ return static_cast<int>(r);
+ }
+]])
+
+AC_DEFUN([CHECK_ATOMIC], [
+
+ AC_LANG_PUSH(C++)
+
+ AC_MSG_CHECKING([whether std::atomic can be used without link library])
+
+ AC_LINK_IFELSE([AC_LANG_SOURCE([_CHECK_ATOMIC_testbody])],[
+ AC_MSG_RESULT([yes])
+ ],[
+ AC_MSG_RESULT([no])
+ LIBS="$LIBS -latomic"
+ AC_MSG_CHECKING([whether std::atomic needs -latomic])
+ AC_LINK_IFELSE([AC_LANG_SOURCE([_CHECK_ATOMIC_testbody])],[
+ AC_MSG_RESULT([yes])
+ ],[
+ AC_MSG_RESULT([no])
+ AC_MSG_FAILURE([cannot figure our how to use std::atomic])
+ ])
+ ])
+
+ AC_LANG_POP
+])