AC_MSG_RESULT($enable_version_specific_runtime_libs)
AC_MSG_CHECKING([for --enable-linux-futex])
-LIBGOMP_ENABLE(linux-futex, yes,
+LIBGOMP_ENABLE(linux-futex, default, ,
[Use the Linux futex system call],
- permit yes|no)
+ permit yes|no|default)
AC_MSG_RESULT($enable_linux_futex)
# -------
AC_STDC_HEADERS
AC_HEADER_TIME
AC_CHECK_HEADERS(unistd.h semaphore.h sys/loadavg.h sys/time.h)
-AC_CHECK_HEADER([pthread.h],[],
- [AC_MSG_ERROR([Pthreads are required to build libgomp])])
+
+GCC_HEADER_STDINT(gstdint.h)
# Check to see if -pthread or -lpthread is needed. Prefer the former.
+# In case the pthread.h system header is not found, this test will fail.
XPCFLAGS=""
-CFLAGS="$CFLAGS -pthread"
+
+# Darwin doesn't need the -pthread option since threads are in libSystem
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[#include <pthread.h>
void *g(void *d) { return NULL; }],
[pthread_t t; pthread_create(&t,NULL,g,NULL);])],
- [XPCFLAGS=" -Wc,-pthread"],
+ [case $host in
+ *-darwin*)
+ ;;
+ default)
+ XPCFLAGS=" -Wc,-pthread"
+ ;;
+ esac],
[CFLAGS="$save_CFLAGS" LIBS="-lpthread $LIBS"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
# Check for functions needed.
AC_CHECK_FUNCS(getloadavg clock_gettime)
+# Check for broken semaphore implementation on darwin.
+# sem_init returns: sem_init error: Function not implemented.
+case "$host" in
+ *-darwin*)
+ AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
+ Define if the POSIX Semaphores do not work on your system.)
+ ;;
+ *-linux*)
+ case "$enable_linux_futex" in
+ default)
+ # If headers don't have gettid/futex syscalls definition, then
+ # default to no, otherwise there will be compile time failures.
+ # Otherwise, default to yes. If we don't detect we are
+ # compiled/linked against NPTL and not cross-compiling, check
+ # if programs are run by default against NPTL and if not, issue
+ # a warning.
+ enable_linux_futex=no
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM(
+ [#include <sys/syscall.h>
+ int lk;],
+ [syscall (SYS_gettid); syscall (SYS_futex, &lk, 0, 0, 0);])],
+ [AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM(
+ [#ifndef _GNU_SOURCE
+ #define _GNU_SOURCE 1
+ #endif
+ #include <pthread.h>
+ pthread_t th; void *status;],
+ [pthread_tryjoin_np (th, &status);])],[enable_linux_futex=yes],
+ [if test x$cross_compiling = xno; then
+ if getconf GNU_LIBPTHREAD_VERSION 2>/dev/null \
+ | LC_ALL=C grep -i NPTL > /dev/null 2>/dev/null; then
+ AC_MSG_WARN([The kernel might not support futex or gettid syscalls.
+If so, please configure with --disable-linux-futex])
+ fi
+ fi
+ enable_linux_futex=yes])])
+ ;;
+ yes)
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM(
+ [#include <sys/syscall.h>
+ int lk;],
+ [syscall (SYS_gettid); syscall (SYS_futex, &lk, 0, 0, 0);])],[],
+ [AC_MSG_ERROR([SYS_gettid and SYS_futex required for --enable-linux-futex])])
+ ;;
+ esac
+ ;;
+esac
+
# At least for glibc, clock_gettime is in librt. But don't pull that
# in if it still doesn't give us the function we want.
if test $ac_cv_func_clock_gettime = no; then
AC_CHECK_LIB(rt, clock_gettime,
[LIBS="-lrt $LIBS"
- AC_DEFINE(HAVE_CLOCK_GETTIME,
+ AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
[Define to 1 if you have the `clock_gettime' function.])])
fi
# See if we support thread-local storage.
-LIBGOMP_CHECK_TLS
+GCC_CHECK_TLS
# See what sort of export controls are availible.
LIBGOMP_CHECK_ATTRIBUTE_VISIBILITY
AM_CONDITIONAL([USE_FORTRAN], [test "$ac_cv_fc_compiler_gnu" = yes])
+# ??? 2006-01-24: Paulo committed to asking autoconf folk to document
+# and export AC_COMPUTE_INT. If that happens, then we'll need to remove
+# the underscore here and update the PREREQ. If it doesn't, then we'll
+# need to copy this macro to our acinclude.m4.
+save_CFLAGS="$CFLAGS"
+for i in $config_path; do
+ if test -f $srcdir/config/$i/omp-lock.h; then
+ CFLAGS="$CFLAGS -include $srcdir/config/$i/omp-lock.h"
+ break
+ fi
+done
+
+_AC_COMPUTE_INT([sizeof (omp_lock_t)], [OMP_LOCK_SIZE],,
+ [AC_MSG_ERROR([unsupported system, cannot find sizeof (omp_lock_t)])])
+_AC_COMPUTE_INT([__alignof (omp_lock_t)], [OMP_LOCK_ALIGN])
+_AC_COMPUTE_INT([sizeof (omp_nest_lock_t)], [OMP_NEST_LOCK_SIZE])
+_AC_COMPUTE_INT([__alignof (omp_nest_lock_t)], [OMP_NEST_LOCK_ALIGN])
+
+# If the lock fits in an integer, then arrange for Fortran to use that
+# integer. If it doesn't, then arrange for Fortran to use a pointer.
+# Except that we don't have a way at present to multi-lib the installed
+# Fortran modules, so we assume 8 bytes for pointers, regardless of the
+# actual target.
+OMP_LOCK_KIND=$OMP_LOCK_SIZE
+OMP_NEST_LOCK_KIND=$OMP_NEST_LOCK_SIZE
+if test $OMP_LOCK_SIZE -gt 8 || test $OMP_LOCK_ALIGN -gt $OMP_LOCK_SIZE; then
+ OMP_LOCK_KIND=8
+fi
+if test $OMP_NEST_LOCK_SIZE -gt 8 || test $OMP_NEST_LOCK_ALIGN -gt $OMP_NEST_LOCK_SIZE; then
+ OMP_NEST_LOCK_KIND=8
+fi
+
+AC_SUBST(OMP_LOCK_SIZE)
+AC_SUBST(OMP_LOCK_ALIGN)
+AC_SUBST(OMP_NEST_LOCK_SIZE)
+AC_SUBST(OMP_NEST_LOCK_ALIGN)
+AC_SUBST(OMP_LOCK_KIND)
+AC_SUBST(OMP_NEST_LOCK_KIND)
+CFLAGS="$save_CFLAGS"
+
+AC_CONFIG_FILES(omp.h omp_lib.h omp_lib.f90 libgomp_f.h)
AC_CONFIG_FILES(Makefile testsuite/Makefile libgomp.spec)
AC_OUTPUT