summaryrefslogtreecommitdiffstats
path: root/gl/m4/setlocale_null.m4
diff options
context:
space:
mode:
authorKristian Schuster <116557017+KriSchu@users.noreply.github.com>2023-02-19 22:49:18 (GMT)
committerKristian Schuster <116557017+KriSchu@users.noreply.github.com>2023-02-19 22:49:18 (GMT)
commita0d42777217296c0a7bdb1e1be8d8f6de1b24dd7 (patch)
tree8effe94c57b2f9796ba36090b07551baa8f1e1cb /gl/m4/setlocale_null.m4
parentca3d59cd6918c9e2739e783b721d4c1122640fd3 (diff)
parentc07206f2ccc2356aa74bc6813a94c2190017d44e (diff)
downloadmonitoring-plugins-a0d42777217296c0a7bdb1e1be8d8f6de1b24dd7.tar.gz
Merge remote-tracking branch 'origin/master' into feature_check_disk_add_ignore_missing_option
Diffstat (limited to 'gl/m4/setlocale_null.m4')
-rw-r--r--gl/m4/setlocale_null.m498
1 files changed, 98 insertions, 0 deletions
diff --git a/gl/m4/setlocale_null.m4 b/gl/m4/setlocale_null.m4
new file mode 100644
index 0000000..032119d
--- /dev/null
+++ b/gl/m4/setlocale_null.m4
@@ -0,0 +1,98 @@
1# setlocale_null.m4 serial 5
2dnl Copyright (C) 2019-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_SETLOCALE_NULL],
8[
9 AC_REQUIRE([AC_CANONICAL_HOST])
10 AC_REQUIRE([gl_PTHREADLIB])
11 AC_CHECK_HEADERS_ONCE([threads.h])
12
13 AC_CACHE_CHECK([whether setlocale (LC_ALL, NULL) is multithread-safe],
14 [gl_cv_func_setlocale_null_all_mtsafe],
15 [case "$host_os" in
16 # Guess no on musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku, Cygwin.
17 *-musl* | darwin* | freebsd* | midnightbsd* | netbsd* | openbsd* | aix* | haiku* | cygwin*)
18 gl_cv_func_setlocale_null_all_mtsafe=no ;;
19 # Guess yes on glibc, HP-UX, IRIX, Solaris, native Windows.
20 *-gnu* | gnu* | hpux* | irix* | solaris* | mingw*)
21 gl_cv_func_setlocale_null_all_mtsafe=yes ;;
22 # If we don't know, obey --enable-cross-guesses.
23 *)
24 gl_cv_func_setlocale_null_all_mtsafe="$gl_cross_guess_normal" ;;
25 esac
26 ])
27 dnl On platforms without multithreading, there is no issue.
28 case "$host_os" in
29 mingw*) ;;
30 *)
31 if test $gl_pthread_api = no && test $ac_cv_header_threads_h = no; then
32 gl_cv_func_setlocale_null_all_mtsafe="trivially yes"
33 fi
34 ;;
35 esac
36 case "$gl_cv_func_setlocale_null_all_mtsafe" in
37 *yes) SETLOCALE_NULL_ALL_MTSAFE=1 ;;
38 *) SETLOCALE_NULL_ALL_MTSAFE=0 ;;
39 esac
40 AC_DEFINE_UNQUOTED([SETLOCALE_NULL_ALL_MTSAFE], [$SETLOCALE_NULL_ALL_MTSAFE],
41 [Define to 1 if setlocale (LC_ALL, NULL) is multithread-safe.])
42
43 dnl This is about a single category (not LC_ALL).
44 AC_CACHE_CHECK([whether setlocale (category, NULL) is multithread-safe],
45 [gl_cv_func_setlocale_null_one_mtsafe],
46 [case "$host_os" in
47 # Guess no on OpenBSD, AIX.
48 openbsd* | aix*)
49 gl_cv_func_setlocale_null_one_mtsafe=no ;;
50 # Guess yes on glibc, musl libc, macOS, FreeBSD, NetBSD, HP-UX, IRIX, Solaris, Haiku, Cygwin, native Windows.
51 *-gnu* | gnu* | *-musl* | darwin* | freebsd* | midnightbsd* | netbsd* | hpux* | irix* | solaris* | haiku* | cygwin* | mingw*)
52 gl_cv_func_setlocale_null_one_mtsafe=yes ;;
53 # If we don't know, obey --enable-cross-guesses.
54 *)
55 gl_cv_func_setlocale_null_one_mtsafe="$gl_cross_guess_normal" ;;
56 esac
57 ])
58 dnl On platforms without multithreading, there is no issue.
59 case "$host_os" in
60 mingw*) ;;
61 *)
62 if test $gl_pthread_api = no && test $ac_cv_header_threads_h = no; then
63 gl_cv_func_setlocale_null_one_mtsafe="trivially yes"
64 fi
65 ;;
66 esac
67 case "$gl_cv_func_setlocale_null_one_mtsafe" in
68 *yes) SETLOCALE_NULL_ONE_MTSAFE=1 ;;
69 *) SETLOCALE_NULL_ONE_MTSAFE=0 ;;
70 esac
71 AC_DEFINE_UNQUOTED([SETLOCALE_NULL_ONE_MTSAFE], [$SETLOCALE_NULL_ONE_MTSAFE],
72 [Define to 1 if setlocale (category, NULL) is multithread-safe.])
73
74 dnl Determine link dependencies of lib/setlocale_null.c and lib/setlocale-lock.c.
75 if test $SETLOCALE_NULL_ALL_MTSAFE = 0 || test $SETLOCALE_NULL_ONE_MTSAFE = 0; then
76 case "$host_os" in
77 mingw*) LIB_SETLOCALE_NULL= ;;
78 *)
79 gl_WEAK_SYMBOLS
80 case "$gl_cv_have_weak" in
81 *yes) LIB_SETLOCALE_NULL= ;;
82 *) LIB_SETLOCALE_NULL="$LIBPTHREAD" ;;
83 esac
84 ;;
85 esac
86 else
87 LIB_SETLOCALE_NULL=
88 fi
89 dnl LIB_SETLOCALE_NULL is expected to be '-pthread' or '-lpthread' on AIX
90 dnl with gcc or xlc, and empty otherwise.
91 AC_SUBST([LIB_SETLOCALE_NULL])
92])
93
94# Prerequisites of lib/setlocale-lock.c.
95AC_DEFUN([gl_PREREQ_SETLOCALE_LOCK],
96[
97 gl_VISIBILITY
98])