* collect2.c (DO_COLLECT_EXPORT_LIST): New internal macro,
[official-gcc.git] / config / futex.m4
blobe95144dd16ae1056556478929ea8a3c9849568f2
1 dnl ----------------------------------------------------------------------
2 dnl This whole bit snagged from libgomp.
4 dnl
5 dnl GCC_LINUX_FUTEX
6 dnl    (SHELL-CODE_HANDLER)
7 dnl
8 AC_DEFUN([GCC_LINUX_FUTEX],[dnl
9 GCC_ENABLE(linux-futex,default, ,[use the Linux futex system call],
10            permit yes|no|default)
11 case "$target" in
12   *-linux*)
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>
25            int lk;],
26           [syscall (SYS_gettid); syscall (SYS_futex, &lk, 0, 0, 0);])],
27           [save_LIBS="$LIBS"
28            LIBS="-lpthread $LIBS"
29            AC_LINK_IFELSE(
30            [AC_LANG_PROGRAM(
31             [#ifndef _GNU_SOURCE
32              #define _GNU_SOURCE 1
33              #endif
34              #include <pthread.h>
35              pthread_t th; void *status;],
36             [pthread_tryjoin_np (th, &status);])],[enable_linux_futex=yes],
37             [if test x$cross_compiling = xno; then
38                if getconf GNU_LIBPTHREAD_VERSION 2>/dev/null \
39                   | LC_ALL=C grep -i NPTL > /dev/null 2>/dev/null; then :; else
40                  AC_MSG_WARN([The kernel might not support futex or gettid syscalls.
41 If so, please configure with --disable-linux-futex])
42                fi
43              fi
44              enable_linux_futex=yes])
45            LIBS="$save_LIBS"])
46         ;;
47       yes)
48         AC_LINK_IFELSE(
49          [AC_LANG_PROGRAM(
50           [#include <sys/syscall.h>
51            int lk;],
52           [syscall (SYS_gettid); syscall (SYS_futex, &lk, 0, 0, 0);])],[],
53           [AC_MSG_ERROR([SYS_gettid and SYS_futex required for --enable-linux-futex])])
54         ;;
55     esac
56     ;;
57   *)
58     enable_linux_futex=no
59     ;;
60 esac
61 if test x$enable_linux_futex = xyes; then
62   $1