source: filezilla/trunk/fuentes/m4/check_atomic.m4 @ 3185

Last change on this file since 3185 was 3185, checked in by jrpelegrina, 3 years ago

Update new version: 3.15.02

File size: 897 bytes
RevLine 
[130]1# Some versions of gcc/libstdc++ require linking with -latomic if
2# using the C++ atomic library.
3
4m4_define([_CHECK_ATOMIC_testbody], [[
5  #include <atomic>
6  #include <cstdint>
7
8  int main() {
9    std::atomic<int64_t> a{};
10
11    int64_t v = 5;
12    int64_t r = a.fetch_add(v);
13    return static_cast<int>(r);
14  }
15]])
16
17AC_DEFUN([CHECK_ATOMIC], [
18
19  AC_LANG_PUSH(C++)
20
21  AC_MSG_CHECKING([whether std::atomic can be used without link library])
22
23  AC_LINK_IFELSE([AC_LANG_SOURCE([_CHECK_ATOMIC_testbody])],[
24      AC_MSG_RESULT([yes])
25    ],[
26      AC_MSG_RESULT([no])
27      LIBS="$LIBS -latomic"
28      AC_MSG_CHECKING([whether std::atomic needs -latomic])
29      AC_LINK_IFELSE([AC_LANG_SOURCE([_CHECK_ATOMIC_testbody])],[
30          AC_MSG_RESULT([yes])
31        ],[
32          AC_MSG_RESULT([no])
[3185]33          AC_MSG_FAILURE([cannot figure out how to use std::atomic])
[130]34        ])
35    ])
36
37  AC_LANG_POP
38])
Note: See TracBrowser for help on using the repository browser.