2 dnl Copyright (C) 2009-2011 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 AC_DEFUN([gl_PTHREAD_CHECK],
9 AC_REQUIRE([gl_PTHREAD_DEFAULTS])
10 gl_CHECK_NEXT_HEADERS([pthread.h])
11 if test $ac_cv_header_pthread_h = yes; then
17 AC_CHECK_TYPES([pthread_t, pthread_spinlock_t], [], [],
22 if test $ac_cv_type_pthread_t != yes; then
25 if test $ac_cv_type_pthread_spinlock_t != yes; then
26 HAVE_PTHREAD_SPINLOCK_T=0
29 if test $ac_cv_header_pthread_h != yes ||
30 test $ac_cv_type_pthread_t != yes ||
31 test $ac_cv_type_pthread_spinlock_t != yes; then
37 AM_CONDITIONAL([GL_GENERATE_PTHREAD_H], [test -n "$PTHREAD_H"])
40 if test $ac_cv_header_pthread_h = yes; then
41 dnl We cannot use AC_SEARCH_LIBS here, because on OSF/1 5.1 pthread_join
42 dnl is defined as a macro which expands to __phread_join, and libpthread
43 dnl contains a definition for __phread_join but none for pthread_join.
44 AC_CACHE_CHECK([for library containing pthread_join],
45 [gl_cv_search_pthread_join],
46 [gl_saved_libs="$LIBS"
47 gl_cv_search_pthread_join=
50 [[#include <pthread.h>]],
51 [[pthread_join (pthread_self (), (void **) 0);]])],
52 [gl_cv_search_pthread_join="none required"])
53 if test -z "$gl_cv_search_pthread_join"; then
54 LIBS="-lpthread $gl_saved_libs"
57 [[#include <pthread.h>]],
58 [[pthread_join (pthread_self (), (void **) 0);]])],
59 [gl_cv_search_pthread_join="-lpthread"])
63 if test "$gl_cv_search_pthread_join" != "none required"; then
64 LIB_PTHREAD="$gl_cv_search_pthread_join"
67 AC_SUBST([LIB_PTHREAD])
69 AC_REQUIRE([AC_C_INLINE])
70 AC_REQUIRE([AC_C_RESTRICT])
73 AC_DEFUN([gl_PTHREAD_DEFAULTS],
75 dnl Assume proper GNU behavior unless another module says otherwise.
76 HAVE_PTHREAD_H=1; AC_SUBST([HAVE_PTHREAD_H])
77 HAVE_PTHREAD_T=1; AC_SUBST([HAVE_PTHREAD_T])
78 HAVE_PTHREAD_SPINLOCK_T=1; AC_SUBST([HAVE_PTHREAD_SPINLOCK_T])