File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ # Some versions of gcc/libstdc++ require linking with -latomic if
2+ # using the C++ atomic library.
3+ #
4+ # Sourced from http://bugs.debian.org/797228
5+
6+ m4_define ( [ _CHECK_ATOMIC_testbody] , [ [
7+ #include <atomic>
8+ #include <cstdint>
9+
10+ int main() {
11+ std::atomic<int64_t> a{};
12+
13+ int64_t v = 5;
14+ int64_t r = a.fetch_add(v);
15+ return static_cast<int>(r);
16+ }
17+ ] ] )
18+
19+ AC_DEFUN ( [ CHECK_ATOMIC] , [
20+
21+ AC_LANG_PUSH ( C++ )
22+
23+ AC_MSG_CHECKING ( [ whether std::atomic can be used without link library] )
24+
25+ AC_LINK_IFELSE ( [ AC_LANG_SOURCE ( [ _CHECK_ATOMIC_testbody] ) ] ,[
26+ AC_MSG_RESULT ( [ yes] )
27+ ] ,[
28+ AC_MSG_RESULT ( [ no] )
29+ LIBS="$LIBS -latomic"
30+ AC_MSG_CHECKING ( [ whether std::atomic needs -latomic] )
31+ AC_LINK_IFELSE ( [ AC_LANG_SOURCE ( [ _CHECK_ATOMIC_testbody] ) ] ,[
32+ AC_MSG_RESULT ( [ yes] )
33+ ] ,[
34+ AC_MSG_RESULT ( [ no] )
35+ AC_MSG_FAILURE ( [ cannot figure our how to use std::atomic] )
36+ ] )
37+ ] )
38+
39+ AC_LANG_POP
40+ ] )
Original file line number Diff line number Diff line change 5959AC_PROG_OBJCXX
6060] )
6161
62+ dnl Check if -latomic is required for <std::atomic>
63+ CHECK_ATOMIC
64+
6265dnl Libtool init checks.
6366LT_INIT([ pic-only] )
6467
You can’t perform that action at this time.
0 commit comments