Debian Codegraph @

m4/setlocale_null.m4

raw
1 # setlocale_null.m4 serial 8
2 dnl Copyright (C) 2019-2023 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 AC_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.
17 *-musl* | midipix* | darwin* | freebsd* | midnightbsd* | netbsd* | openbsd* | aix* | haiku*)
18 gl_cv_func_setlocale_null_all_mtsafe=no ;;
19 # Guess no on Cygwin < 3.4.6.
20 cygwin*)
21 AC_EGREP_CPP([Lucky user],
22 [
23 #if defined __CYGWIN__
24 #include <cygwin/version.h>
25 #if CYGWIN_VERSION_DLL_COMBINED >= CYGWIN_VERSION_DLL_MAKE_COMBINED (3004, 6)
26 Lucky user
27 #endif
28 #endif
29 ],
30 [gl_cv_func_setlocale_null_all_mtsafe=yes],
31 [gl_cv_func_setlocale_null_all_mtsafe=no])
32 ;;
33 # Guess yes on glibc, HP-UX, IRIX, Solaris, native Windows.
34 *-gnu* | gnu* | hpux* | irix* | solaris* | mingw*)
35 gl_cv_func_setlocale_null_all_mtsafe=yes ;;
36 # If we don't know, obey --enable-cross-guesses.
37 *)
38 gl_cv_func_setlocale_null_all_mtsafe="$gl_cross_guess_normal" ;;
39 esac
40 ])
41 dnl On platforms without multithreading, there is no issue.
42 case "$host_os" in
43 mingw*) ;;
44 *)
45 if test $gl_pthread_api = no && test $ac_cv_header_threads_h = no; then
46 gl_cv_func_setlocale_null_all_mtsafe="trivially yes"
47 fi
48 ;;
49 esac
50 case "$gl_cv_func_setlocale_null_all_mtsafe" in
51 *yes) SETLOCALE_NULL_ALL_MTSAFE=1 ;;
52 *) SETLOCALE_NULL_ALL_MTSAFE=0 ;;
53 esac
54 AC_DEFINE_UNQUOTED([SETLOCALE_NULL_ALL_MTSAFE], [$SETLOCALE_NULL_ALL_MTSAFE],
55 [Define to 1 if setlocale (LC_ALL, NULL) is multithread-safe.])
56
57 dnl This is about a single category (not LC_ALL).
58 AC_CACHE_CHECK([whether setlocale (category, NULL) is multithread-safe],
59 [gl_cv_func_setlocale_null_one_mtsafe],
60 [case "$host_os" in
61 # Guess no on OpenBSD, AIX.
62 openbsd* | aix*)
63 gl_cv_func_setlocale_null_one_mtsafe=no ;;
64 # Guess yes on glibc, musl libc, macOS, FreeBSD, NetBSD, HP-UX, IRIX, Solaris, Haiku, Cygwin, native Windows.
65 *-gnu* | gnu* | *-musl* | midipix* | darwin* | freebsd* | midnightbsd* | netbsd* | hpux* | irix* | solaris* | haiku* | cygwin* | mingw*)
66 gl_cv_func_setlocale_null_one_mtsafe=yes ;;
67 # If we don't know, obey --enable-cross-guesses.
68 *)
69 gl_cv_func_setlocale_null_one_mtsafe="$gl_cross_guess_normal" ;;
70 esac
71 ])
72 dnl On platforms without multithreading, there is no issue.
73 case "$host_os" in
74 mingw*) ;;
75 *)
76 if test $gl_pthread_api = no && test $ac_cv_header_threads_h = no; then
77 gl_cv_func_setlocale_null_one_mtsafe="trivially yes"
78 fi
79 ;;
80 esac
81 case "$gl_cv_func_setlocale_null_one_mtsafe" in
82 *yes) SETLOCALE_NULL_ONE_MTSAFE=1 ;;
83 *) SETLOCALE_NULL_ONE_MTSAFE=0 ;;
84 esac
85 AC_DEFINE_UNQUOTED([SETLOCALE_NULL_ONE_MTSAFE], [$SETLOCALE_NULL_ONE_MTSAFE],
86 [Define to 1 if setlocale (category, NULL) is multithread-safe.])
87
88 dnl Determine link dependencies of lib/setlocale_null.c and lib/setlocale-lock.c.
89 if test $SETLOCALE_NULL_ALL_MTSAFE = 0 || test $SETLOCALE_NULL_ONE_MTSAFE = 0; then
90 case "$host_os" in
91 mingw*) SETLOCALE_NULL_LIB= ;;
92 *)
93 gl_WEAK_SYMBOLS
94 case "$gl_cv_have_weak" in
95 *yes) SETLOCALE_NULL_LIB= ;;
96 *) SETLOCALE_NULL_LIB="$LIBPTHREAD" ;;
97 esac
98 ;;
99 esac
100 else
101 SETLOCALE_NULL_LIB=
102 fi
103 dnl SETLOCALE_NULL_LIB is expected to be '-pthread' or '-lpthread' on AIX
104 dnl with gcc or xlc, and empty otherwise.
105 AC_SUBST([SETLOCALE_NULL_LIB])
106 dnl For backward compatibility.
107 LIB_SETLOCALE_NULL="$SETLOCALE_NULL_LIB"
108 AC_SUBST([LIB_SETLOCALE_NULL])
109 ])
110
111 # Prerequisites of lib/setlocale-lock.c.
112 AC_DEFUN([gl_PREREQ_SETLOCALE_LOCK],
113 [
114 gl_VISIBILITY
115 ])