diff options
| author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-12-28 12:13:40 +0100 |
|---|---|---|
| committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-12-28 12:13:40 +0100 |
| commit | b0afb8fe0ff1d87165af9df61501197a06240dda (patch) | |
| tree | 274ac6a96c53ef4c19ab4974ce24a06a233128c5 /gl/m4/pthread-spin.m4 | |
| parent | 68fc05381ee5fa0aee1413118fbb3d81ca888b09 (diff) | |
| download | monitoring-plugins-b0afb8fe0ff1d87165af9df61501197a06240dda.tar.gz | |
Sync with Gnulib stable-202507 code (a8ac9f9ce5)
Diffstat (limited to 'gl/m4/pthread-spin.m4')
| -rw-r--r-- | gl/m4/pthread-spin.m4 | 72 |
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 | ||
| 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_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 | ]) | ||
