2016-09-29 07:57:47 +02:00
|
|
|
dnl Copyright (c) 2015 Tim Kosse <tim.kosse@filezilla-project.org>
|
|
|
|
dnl Copying and distribution of this file, with or without modification, are
|
|
|
|
dnl permitted in any medium without royalty provided the copyright notice
|
|
|
|
dnl and this notice are preserved. This file is offered as-is, without any
|
|
|
|
dnl warranty.
|
|
|
|
|
2016-09-09 08:57:08 +02:00
|
|
|
# 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>
|
2021-05-11 20:10:21 +02:00
|
|
|
#include <chrono>
|
|
|
|
|
|
|
|
using namespace std::chrono_literals;
|
2016-09-09 08:57:08 +02:00
|
|
|
|
|
|
|
int main() {
|
2021-01-15 03:54:07 +01:00
|
|
|
std::atomic<bool> lock{true};
|
|
|
|
std::atomic_exchange(&lock, false);
|
|
|
|
|
2021-05-11 20:10:21 +02:00
|
|
|
std::atomic<std::chrono::seconds> t{0s};
|
|
|
|
t.store(2s);
|
|
|
|
|
2016-09-09 08:57:08 +02:00
|
|
|
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])
|
2016-09-29 07:57:47 +02:00
|
|
|
AC_MSG_FAILURE([cannot figure out how to use std::atomic])
|
2016-09-09 08:57:08 +02:00
|
|
|
])
|
|
|
|
])
|
|
|
|
|
|
|
|
AC_LANG_POP
|
|
|
|
])
|