mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
Add configure check for -latomic
This commit is contained in:
parent
41d8e78f94
commit
878faacd7b
40
build-aux/m4/l_atomic.m4
Normal file
40
build-aux/m4/l_atomic.m4
Normal file
@ -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
|
||||||
|
])
|
@ -57,6 +57,9 @@ case $host in
|
|||||||
esac
|
esac
|
||||||
dnl Require C++11 compiler (no GNU extensions)
|
dnl Require C++11 compiler (no GNU extensions)
|
||||||
AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory])
|
AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory])
|
||||||
|
dnl Check if -latomic is required for <std::atomic>
|
||||||
|
CHECK_ATOMIC
|
||||||
|
|
||||||
dnl Libtool init checks.
|
dnl Libtool init checks.
|
||||||
LT_INIT([pic-only])
|
LT_INIT([pic-only])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user