source: trunk/libs/newlib/src/config/futex.m4 @ 673

Last change on this file since 673 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 1.8 KB
Line 
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
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.
41If 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    ;;
60esac
61if test x$enable_linux_futex = xyes; then
62  $1
63fi
64])
Note: See TracBrowser for help on using the repository browser.