]> git.ipfire.org Git - thirdparty/gcc.git/blame - config/futex.m4
c++/modules: Stream unmergeable temporaries by value again [PR114856]
[thirdparty/gcc.git] / config / futex.m4
CommitLineData
0f3e711e
JJ
1dnl ----------------------------------------------------------------------
2dnl This whole bit snagged from libgomp.
3
4dnl
5dnl GCC_LINUX_FUTEX
6dnl (SHELL-CODE_HANDLER)
7dnl
8AC_DEFUN([GCC_LINUX_FUTEX],[dnl
9GCC_ENABLE(linux-futex,default, ,[use the Linux futex system call],
10 permit yes|no|default)
11case "$target" in
b1e21e5a 12 *-linux* | *-uclinux*)
0f3e711e
JJ
13 case "$enable_linux_futex" in
14 default)
15 # If headers don't have gettid/futex syscalls definition, then
16 # default to no, otherwise there will be compile time failures.
17 # Otherwise, default to yes. If we don't detect we are
18 # compiled/linked against NPTL and not cross-compiling, check
19 # if programs are run by default against NPTL and if not, issue
20 # a warning.
21 enable_linux_futex=no
22 AC_LINK_IFELSE(
23 [AC_LANG_PROGRAM(
24 [#include <sys/syscall.h>
3c086f8d 25 #include <unistd.h>
0f3e711e
JJ
26 int lk;],
27 [syscall (SYS_gettid); syscall (SYS_futex, &lk, 0, 0, 0);])],
28 [save_LIBS="$LIBS"
29 LIBS="-lpthread $LIBS"
30 AC_LINK_IFELSE(
31 [AC_LANG_PROGRAM(
32 [#ifndef _GNU_SOURCE
33 #define _GNU_SOURCE 1
34 #endif
35 #include <pthread.h>
36 pthread_t th; void *status;],
37 [pthread_tryjoin_np (th, &status);])],[enable_linux_futex=yes],
38 [if test x$cross_compiling = xno; then
39 if getconf GNU_LIBPTHREAD_VERSION 2>/dev/null \
40 | LC_ALL=C grep -i NPTL > /dev/null 2>/dev/null; then :; else
41 AC_MSG_WARN([The kernel might not support futex or gettid syscalls.
42If so, please configure with --disable-linux-futex])
43 fi
44 fi
45 enable_linux_futex=yes])
46 LIBS="$save_LIBS"])
47 ;;
48 yes)
49 AC_LINK_IFELSE(
50 [AC_LANG_PROGRAM(
51 [#include <sys/syscall.h>
3c086f8d 52 #include <unistd.h>
0f3e711e
JJ
53 int lk;],
54 [syscall (SYS_gettid); syscall (SYS_futex, &lk, 0, 0, 0);])],[],
55 [AC_MSG_ERROR([SYS_gettid and SYS_futex required for --enable-linux-futex])])
56 ;;
57 esac
58 ;;
59 *)
60 enable_linux_futex=no
61 ;;
62esac
63if test x$enable_linux_futex = xyes; then
64 $1
65fi
66])