| 1 |
# pthread-spin.m4 |
| 2 |
# serial 8 |
| 3 |
dnl Copyright (C) 2019-2024 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_ONCE([gl_PTHREAD_SPIN], |
| 10 |
[ |
| 11 |
AC_REQUIRE([gl_PTHREAD_H_PART1]) |
| 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_SPIN_INIT=1 |
| 19 |
REPLACE_PTHREAD_SPIN_LOCK=1 |
| 20 |
REPLACE_PTHREAD_SPIN_TRYLOCK=1 |
| 21 |
REPLACE_PTHREAD_SPIN_UNLOCK=1 |
| 22 |
REPLACE_PTHREAD_SPIN_DESTROY=1 |
| 23 |
else |
| 24 |
if test $HAVE_PTHREAD_H = 0 || test $HAVE_PTHREAD_SPINLOCK_T = 0; then |
| 25 |
HAVE_PTHREAD_SPIN_INIT=0 |
| 26 |
HAVE_PTHREAD_SPIN_LOCK=0 |
| 27 |
HAVE_PTHREAD_SPIN_TRYLOCK=0 |
| 28 |
HAVE_PTHREAD_SPIN_UNLOCK=0 |
| 29 |
HAVE_PTHREAD_SPIN_DESTROY=0 |
| 30 |
else |
| 31 |
dnl Test whether the gnulib module 'threadlib' is in use. |
| 32 |
dnl Some packages like Emacs use --avoid=threadlib. |
| 33 |
dnl Write the symbol in such a way that it does not cause 'aclocal' to pick |
| 34 |
dnl the threadlib.m4 file that is installed in $PREFIX/share/aclocal/. |
| 35 |
m4_ifdef([gl_][THREADLIB], [ |
| 36 |
AC_REQUIRE([gl_][THREADLIB]) |
| 37 |
dnl Test whether the functions actually exist. |
| 38 |
dnl FreeBSD 5.2.1 declares them but does not define them. |
| 39 |
AC_CACHE_CHECK([for pthread_spin_init], |
| 40 |
[gl_cv_func_pthread_spin_init_in_LIBMULTITHREAD], |
| 41 |
[gl_saved_LIBS="$LIBS" |
| 42 |
LIBS="$LIBS $LIBMULTITHREAD" |
| 43 |
AC_LINK_IFELSE( |
| 44 |
[AC_LANG_PROGRAM( |
| 45 |
[[#include <pthread.h> |
| 46 |
]], |
| 47 |
[[pthread_spinlock_t lock; |
| 48 |
return pthread_spin_init (&lock, 0); |
| 49 |
]]) |
| 50 |
], |
| 51 |
[gl_cv_func_pthread_spin_init_in_LIBMULTITHREAD=yes], |
| 52 |
[gl_cv_func_pthread_spin_init_in_LIBMULTITHREAD=no]) |
| 53 |
LIBS="$gl_saved_LIBS" |
| 54 |
]) |
| 55 |
if test $gl_cv_func_pthread_spin_init_in_LIBMULTITHREAD != yes; then |
| 56 |
HAVE_PTHREAD_SPIN_INIT=0 |
| 57 |
REPLACE_PTHREAD_SPIN_INIT=1 |
| 58 |
HAVE_PTHREAD_SPIN_LOCK=0 |
| 59 |
REPLACE_PTHREAD_SPIN_LOCK=1 |
| 60 |
HAVE_PTHREAD_SPIN_TRYLOCK=0 |
| 61 |
REPLACE_PTHREAD_SPIN_TRYLOCK=1 |
| 62 |
HAVE_PTHREAD_SPIN_UNLOCK=0 |
| 63 |
REPLACE_PTHREAD_SPIN_UNLOCK=1 |
| 64 |
HAVE_PTHREAD_SPIN_DESTROY=0 |
| 65 |
REPLACE_PTHREAD_SPIN_DESTROY=1 |
| 66 |
fi |
| 67 |
], [ |
| 68 |
: |
| 69 |
]) |
| 70 |
fi |
| 71 |
fi |
| 72 |
]) |