| 1 |
# pthread-thread.m4 |
| 2 |
# serial 3 |
| 3 |
dnl Copyright (C) 2019-2025 Free Software Foundation, Inc. |
| 4 |
dnl This file is free software; the Free Software Foundation |
| 5 |
dnl gives unlimited permission to copy and/or distribute it, |
| 6 |
dnl with or without modifications, as long as this notice is preserved. |
| 7 |
dnl This file is offered as-is, without any warranty. |
| 8 |
|
| 9 |
AC_DEFUN([gl_PTHREAD_THREAD], |
| 10 |
[ |
| 11 |
AC_REQUIRE([gl_PTHREAD_H]) |
| 12 |
AC_REQUIRE([AC_CANONICAL_HOST]) |
| 13 |
|
| 14 |
if { case "$host_os" in mingw* | windows*) true;; *) false;; esac; } \ |
| 15 |
&& test $gl_threads_api = windows; then |
| 16 |
dnl Choose function names that don't conflict with the mingw-w64 winpthreads |
| 17 |
dnl library. |
| 18 |
REPLACE_PTHREAD_CREATE=1 |
| 19 |
REPLACE_PTHREAD_ATTR_INIT=1 |
| 20 |
REPLACE_PTHREAD_ATTR_GETDETACHSTATE=1 |
| 21 |
REPLACE_PTHREAD_ATTR_SETDETACHSTATE=1 |
| 22 |
REPLACE_PTHREAD_ATTR_DESTROY=1 |
| 23 |
REPLACE_PTHREAD_SELF=1 |
| 24 |
REPLACE_PTHREAD_EQUAL=1 |
| 25 |
REPLACE_PTHREAD_DETACH=1 |
| 26 |
REPLACE_PTHREAD_JOIN=1 |
| 27 |
REPLACE_PTHREAD_EXIT=1 |
| 28 |
else |
| 29 |
if test $HAVE_PTHREAD_H = 0; then |
| 30 |
HAVE_PTHREAD_CREATE=0 |
| 31 |
HAVE_PTHREAD_ATTR_INIT=0 |
| 32 |
HAVE_PTHREAD_ATTR_GETDETACHSTATE=0 |
| 33 |
HAVE_PTHREAD_ATTR_SETDETACHSTATE=0 |
| 34 |
HAVE_PTHREAD_ATTR_DESTROY=0 |
| 35 |
HAVE_PTHREAD_SELF=0 |
| 36 |
HAVE_PTHREAD_EQUAL=0 |
| 37 |
HAVE_PTHREAD_DETACH=0 |
| 38 |
HAVE_PTHREAD_JOIN=0 |
| 39 |
HAVE_PTHREAD_EXIT=0 |
| 40 |
else |
| 41 |
dnl On HP-UX 11.11, pthread_create() and pthread_attr_init() are only |
| 42 |
dnl defined as inline functions. |
| 43 |
AC_CACHE_CHECK([whether pthread_create exists as a global function], |
| 44 |
[gl_cv_func_pthread_create], |
| 45 |
[saved_LIBS="$LIBS" |
| 46 |
LIBS="$LIBS $LIBPMULTITHREAD" |
| 47 |
AC_LINK_IFELSE( |
| 48 |
[AC_LANG_SOURCE( |
| 49 |
[[extern |
| 50 |
#ifdef __cplusplus |
| 51 |
"C" |
| 52 |
#endif |
| 53 |
int pthread_create (void); |
| 54 |
int main () |
| 55 |
{ |
| 56 |
return pthread_create (); |
| 57 |
} |
| 58 |
]])], |
| 59 |
[gl_cv_func_pthread_create=yes], |
| 60 |
[gl_cv_func_pthread_create=no]) |
| 61 |
LIBS="$saved_LIBS" |
| 62 |
]) |
| 63 |
if test $gl_cv_func_pthread_create = no; then |
| 64 |
REPLACE_PTHREAD_CREATE=1 |
| 65 |
REPLACE_PTHREAD_ATTR_INIT=1 |
| 66 |
AC_DEFINE([PTHREAD_CREATE_IS_INLINE], [1], |
| 67 |
[Define if pthread_create is an inline function.]) |
| 68 |
fi |
| 69 |
fi |
| 70 |
fi |
| 71 |
]) |