Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

l_atomic.m4 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. dnl Copyright (c) 2015 Tim Kosse <tim.kosse@filezilla-project.org>
  2. dnl Copying and distribution of this file, with or without modification, are
  3. dnl permitted in any medium without royalty provided the copyright notice
  4. dnl and this notice are preserved. This file is offered as-is, without any
  5. dnl warranty.
  6. # Some versions of gcc/libstdc++ require linking with -latomic if
  7. # using the C++ atomic library.
  8. #
  9. # Sourced from http://bugs.debian.org/797228
  10. m4_define([_CHECK_ATOMIC_testbody], [[
  11. #include <atomic>
  12. #include <cstdint>
  13. int main() {
  14. std::atomic<int64_t> a{};
  15. int64_t v = 5;
  16. int64_t r = a.fetch_add(v);
  17. return static_cast<int>(r);
  18. }
  19. ]])
  20. AC_DEFUN([CHECK_ATOMIC], [
  21. AC_LANG_PUSH(C++)
  22. AC_MSG_CHECKING([whether std::atomic can be used without link library])
  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])
  33. AC_MSG_FAILURE([cannot figure out how to use std::atomic])
  34. ])
  35. ])
  36. AC_LANG_POP
  37. ])