summaryrefslogtreecommitdiffstats
path: root/gl/m4/pthread-spin.m4
diff options
context:
space:
mode:
authorLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-12-28 12:50:39 +0100
committerGitHub <noreply@github.com>2025-12-28 12:50:39 +0100
commite7dd07c8025b169b7b43b955066a7200d9cdf244 (patch)
tree6e8c927cfc67f3708b91ac79df07707af26e4929 /gl/m4/pthread-spin.m4
parent828a9720b10814c5836d03aa35af05d196c4104b (diff)
parentb0afb8fe0ff1d87165af9df61501197a06240dda (diff)
downloadmonitoring-plugins-e7dd07c8025b169b7b43b955066a7200d9cdf244.tar.gz
Merge pull request #2213 from RincewindsHat/update/gnulib
Sync with Gnulib stable-202507 code (a8ac9f9ce5)
Diffstat (limited to 'gl/m4/pthread-spin.m4')
-rw-r--r--gl/m4/pthread-spin.m472
1 files changed, 72 insertions, 0 deletions
diff --git a/gl/m4/pthread-spin.m4 b/gl/m4/pthread-spin.m4
new file mode 100644
index 00000000..aae2fb3b
--- /dev/null
+++ b/gl/m4/pthread-spin.m4
@@ -0,0 +1,72 @@
1# pthread-spin.m4
2# serial 8
3dnl Copyright (C) 2019-2025 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9AC_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])