Avoid libtool 'nm' errors
[openafs.git] / src / cf / pthread.m4
1 AC_DEFUN([OPENAFS_PTHREAD_CHECKS],[
2 PTHREAD_LIBS=error
3 if test "x$MKAFS_OSTYPE" = OBSD; then
4         PTHREAD_LIBS="-pthread"
5 fi
6 if test "x$MKAFS_OSTYPE" = xDFBSD; then
7         PTHREAD_LIBS="-pthread"
8 fi
9 if test "x$PTHREAD_LIBS" = xerror; then
10         AC_CHECK_LIB(pthread, pthread_attr_init,
11                 PTHREAD_LIBS="-lpthread")
12 fi
13 if test "x$PTHREAD_LIBS" = xerror; then
14         AC_CHECK_LIB(pthreads, pthread_attr_init,
15                 PTHREAD_LIBS="-lpthreads")
16 fi
17 if test "x$PTHREAD_LIBS" = xerror; then
18         AC_CHECK_LIB(c_r, pthread_attr_init,
19                 PTHREAD_LIBS="-lc_r")
20 fi
21 if test "x$PTHREAD_LIBS" = xerror; then
22         AC_CHECK_FUNC(pthread_attr_init, PTHREAD_LIBS="")
23 fi
24 if test "x$PTHREAD_LIBS" = xerror; then
25         # pthread_attr_init is a macro under HPUX 11.0 and 11.11
26         AC_CHECK_LIB(pthread, pthread_attr_destroy,
27                 PTHREAD_LIBS="-lpthread")
28 fi
29 if test "x$PTHREAD_LIBS" = xerror; then
30         AC_MSG_WARN(*** Unable to locate working posix thread library ***)
31 fi
32 AC_SUBST(PTHREAD_LIBS)
33 ])
34
35 AC_DEFUN([OPENAFS_MORE_PTHREAD_CHECKS],[
36 dnl Look for "non-portable" pthreads functions.
37 save_LIBS="$LIBS"
38 LIBS="$LIBS $PTHREAD_LIBS"
39 AC_CHECK_FUNCS([ \
40         pthread_set_name_np \
41         pthread_setname_np \
42 ])
43
44 dnl Sadly, there are three different versions of pthread_setname_np.
45 dnl Try to cater for all of them.
46 if test "$ac_cv_func_pthread_setname_np" = "yes" ; then
47     AC_MSG_CHECKING([for signature of pthread_setname_np])
48     AC_TRY_COMPILE([
49 #include <pthread.h>
50 #ifdef HAVE_PTHREAD_NP_H
51 #include <pthread_np.h>
52 #endif
53 ], [pthread_setname_np(pthread_self(), "test", (void *)0)], [
54         AC_MSG_RESULT([three arguments])
55         pthread_setname_np_args=3], [
56         AC_TRY_COMPILE([
57 #include <pthread.h>
58 #ifdef HAVE_PTHREAD_NP_H
59 #include <pthread_np.h>
60 #endif
61 ], [pthread_setname_np(pthread_self(), "test")], [
62             AC_MSG_RESULT([two arguments])
63             pthread_setname_np_args=2], [
64             AC_TRY_COMPILE([
65 #include <pthread.h>
66 #ifdef HAVE_PTHREAD_NP_H
67 #include <pthread_np.h>
68 #endif
69 ], [pthread_setname_np("test")], [
70                 AC_MSG_RESULT([one argument])
71                 pthread_setname_np_args=1], [pthread_setname_np_args=0])
72 ])
73 ])
74 AC_DEFINE_UNQUOTED([PTHREAD_SETNAME_NP_ARGS], $pthread_setname_np_args, [Number of arguments required by pthread_setname_np() function])
75 fi
76 ])