2 # ----------------------------------
3 # Check whether -lpthread is needed for pthread.
6 # - UseLibpthread: [YES|NO]
7 AC_DEFUN([FP_CHECK_PTHREAD_LIB],
9 dnl Some platforms (e.g. Android's Bionic) have pthreads support available
10 dnl without linking against libpthread. Check whether -lpthread is necessary
13 dnl Note that it is important that this happens before we AC_CHECK_LIB(thread)
14 AC_MSG_CHECKING(whether -lpthread is needed for pthreads)
15 AC_CHECK_FUNC(pthread_create,
21 AC_CHECK_LIB(pthread, pthread_create,
27 AC_MSG_RESULT([no pthreads support found.])
33 # FP_CHECK_PTHREAD_FUNCS
34 # ----------------------------------
35 # Check various aspects of the platform's pthreads support
37 # `AC_DEFINE`s various C `HAVE_*` macros.
38 AC_DEFUN([FP_CHECK_PTHREAD_FUNCS],
40 dnl Setting thread names
41 dnl ~~~~~~~~~~~~~~~~~~~~
42 dnl The portability situation here is complicated:
44 dnl * FreeBSD supports pthread_set_name_np in <pthread_np.h>
45 dnl and (if not _POSIX_SOURCE) pthread_setname_np() in <pthread.h>
46 dnl because of the conditional visibility, we prefer the former.
47 dnl * glibc supports pthread_setname_np
48 dnl * Darwin supports pthread_setname_np but does not take a
49 dnl pthread_t argument.
51 AC_CHECK_HEADERS([pthread_np.h])
53 dnl ** pthread_setname_np is a recent addition to glibc, and OS X has
54 dnl a different single-argument version.
55 AC_CHECK_LIB(pthread, pthread_setname_np)
57 AC_MSG_CHECKING([for pthread_setname_np (Darwin)])
63 [[pthread_setname_np("name");]]
67 AC_DEFINE([HAVE_PTHREAD_SETNAME_NP_DARWIN], [1],
68 [Define to 1 if you have the Darwin version of pthread_setname_np])
74 AC_MSG_CHECKING([for pthread_setname_np (glibc)])
81 [[pthread_setname_np(pthread_self(), "name");]]
85 AC_DEFINE([HAVE_PTHREAD_SETNAME_NP], [1],
86 [Define to 1 if you have the glibc version of pthread_setname_np])
92 AC_MSG_CHECKING([for pthread_setname_np (NetBSD)])
98 [[pthread_setname_np(pthread_self(), "%s", "name");]]
102 AC_DEFINE([HAVE_PTHREAD_SETNAME_NP_NETBSD], [1],
103 [Define to 1 if you have the NetBSD version of pthread_setname_np])
109 AC_MSG_CHECKING([for pthread_set_name_np])
113 #include <pthread_np.h>
115 [[pthread_set_name_np(pthread_self(), "name");]]
119 AC_DEFINE([HAVE_PTHREAD_SET_NAME_NP], [1],
120 [Define to 1 if you have pthread_set_name_np])
125 AC_CHECK_FUNCS_ONCE([pthread_condattr_setclock])