File: cxx_have_std_thread.m4

package info (click to toggle)
xerces-c 3.2.4%2Bdebian-1.3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 19,948 kB
  • sloc: cpp: 167,201; xml: 23,619; sh: 4,789; ansic: 3,988; makefile: 1,438; perl: 355; javascript: 18
file content (50 lines) | stat: -rw-r--r-- 1,186 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
dnl @synopsis AC_CXX_HAVE_STD_THREAD
dnl
dnl If the compiler supports ISO C++11 <thread> and <mutex>, define
dnl HAVE_STD_THREAD.
dnl
dnl @category Cxx
dnl @author Roger Leigh
dnl @author Roger Leigh <rleigh@codelibre.net>
dnl @version 2017-06-09
dnl @license AllPermissive

AC_DEFUN([AC_CXX_HAVE_STD_THREAD],
[AC_CACHE_CHECK(whether the compiler supports ISO C++11 <thread> and <mutex>,
ac_cv_cxx_have_std_thread,
[AC_REQUIRE([AC_CXX_HAVE_NAMESPACES])
 AC_REQUIRE([ACX_PTHREAD])
 AC_LANG_SAVE
 AC_LANG_CPLUSPLUS
 save_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
 AC_TRY_COMPILE([#include <thread>
#include <mutex>
#include <iostream>

namespace
{

  std::mutex m1;
  std::recursive_mutex m2;

  void
  threadmain()
  {
    std::lock_guard<std::mutex> lock1(m1);
    std::lock_guard<std::recursive_mutex> lock2(m2);
    std::cout << "In thread" << std::endl;
  }

}
],[std::thread foo(threadmain);
  foo.join();
return 0;],
 ac_cv_cxx_have_std_thread=yes, ac_cv_cxx_have_std_thread=no)
 CFLAGS="$save_CFLAGS"
 AC_LANG_RESTORE
])
if test "$ac_cv_cxx_have_std_thread" = yes; then
  AC_DEFINE(HAVE_STD_THREAD,,[define if the compiler supports ISO C++11 <thread> and <mutex>])
fi
])