Home | History | Annotate | Line # | Download | only in config
      1 dnl ----------------------------------------------------------------------
      2 dnl This whole bit snagged from libgomp.
      3 
      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* | *-uclinux*)
     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 	   #include <unistd.h>
     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.
     42 If 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>
     52 	   #include <unistd.h>
     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     ;;
     62 esac
     63 if test x$enable_linux_futex = xyes; then
     64   $1
     65 fi
     66 ])
     67