Debian Codegraph @

m4/strerrorname_np.m4

raw
1 # strerrorname_np.m4
2 # serial 8
3 dnl Copyright (C) 2020-2026 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([gl_FUNC_STRERRORNAME_NP],
10 [
11 AC_REQUIRE([gl_STRING_H_DEFAULTS])
12
13 AC_REQUIRE([gl_CHECK_STRERRORNAME_NP])
14 if test $ac_cv_func_strerrorname_np = yes; then
15 case "$gl_cv_func_strerrorname_np_works" in
16 *yes) ;;
17 *) REPLACE_STRERRORNAME_NP=1 ;;
18 esac
19 else
20 HAVE_STRERRORNAME_NP=0
21 case "$gl_cv_onwards_func_strerrorname_np" in
22 future*) REPLACE_STRERRORNAME_NP=1 ;;
23 esac
24 fi
25 ])
26
27 # Check for a working strerrorname_np function.
28 # Sets ac_cv_func_strerrorname_np, gl_cv_onwards_func_strerrorname_np,
29 # gl_cv_func_strerrorname_np_works.
30 AC_DEFUN([gl_CHECK_STRERRORNAME_NP],
31 [
32 dnl Persuade glibc <string.h> to declare strerrorname_np().
33 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
34
35 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
36
37 gl_CHECK_FUNCS_ANDROID([strerrorname_np], [[#include <string.h>]])
38 if test $ac_cv_func_strerrorname_np = yes; then
39 dnl In glibc 2.32, strerrorname_np returns English error descriptions, not
40 dnl error names.
41 dnl See <https://sourceware.org/PR26555>.
42 dnl In glibc 2.36, strerrorname_np returns NULL for EDEADLOCK on powerpc and
43 dnl sparc platforms.
44 dnl See <https://sourceware.org/PR29545>.
45 dnl In glibc 2.37, strerrorname_np returns NULL for ENOSYM and
46 dnl EREMOTERELEASE on hppa platforms.
47 dnl See <https://sourceware.org/PR31080>.
48 dnl In Solaris 11 OmniOS, strerrorname_np returns NULL for ERESTART
49 dnl and ESTRPIPE.
50 dnl see <https://www.illumos.org/issues/17134>.
51 AC_CACHE_CHECK([whether strerrorname_np works],
52 [gl_cv_func_strerrorname_np_works],
53 [AC_RUN_IFELSE(
54 [AC_LANG_PROGRAM(
55 [[#include <errno.h>
56 #include <string.h>
57 ]],
58 [[return
59 strcmp (strerrorname_np (EINVAL), "EINVAL") != 0
60 #ifdef EDEADLOCK
61 || strerrorname_np (EDEADLOCK) == NULL
62 #endif
63 #ifdef ENOSYM
64 || strerrorname_np (ENOSYM) == NULL
65 #endif
66 #ifdef ERESTART
67 || strerrorname_np (ERESTART) == NULL
68 #endif
69 #ifdef ESTRPIPE
70 || strerrorname_np (ESTRPIPE) == NULL
71 #endif
72 ;
73 ]])],
74 [gl_cv_func_strerrorname_np_works=yes],
75 [gl_cv_func_strerrorname_np_works=no],
76 [case "$host_os" in
77 # Guess no on glibc systems.
78 *-gnu* | gnu*)
79 gl_cv_func_strerrorname_np_works="guessing no" ;;
80 # Otherwise obey --enable-cross-guesses.
81 *)
82 gl_cv_func_strerrorname_np_works="$gl_cross_guess_normal" ;;
83 esac
84 ])
85 ])
86 fi
87 ])
88
89 # Prerequisite for using strerrorname_np when available.
90 AC_DEFUN_ONCE([gl_OPTIONAL_STRERRORNAME_NP],
91 [
92 AC_REQUIRE([gl_CHECK_STRERRORNAME_NP])
93 if test $ac_cv_func_strerrorname_np = yes; then
94 case "$gl_cv_func_strerrorname_np_works" in
95 *yes)
96 AC_DEFINE([HAVE_WORKING_STRERRORNAME_NP], [1],
97 [Define to 1 if the function strerrorname_np exists and works.])
98 ;;
99 esac
100 fi
101 ])