immutable: Add tests.
[gnulib.git] / m4 / strerrorname_np.m4
blobf02d482c71213f4d59c959a92cde14919964a2b5
1 # strerrorname_np.m4 serial 1
2 dnl Copyright (C) 2020-2021 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.
7 AC_DEFUN([gl_FUNC_STRERRORNAME_NP],
9   dnl Persuade glibc <string.h> to declare strerrorname_np().
10   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
12   AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
13   AC_CHECK_FUNCS([strerrorname_np])
14   if test $ac_cv_func_strerrorname_np = yes; then
15     dnl In glibc 2.32, strerrorname_np returns English error descriptions, not
16     dnl error names.
17     dnl See <https://sourceware.org/bugzilla/show_bug.cgi?id=26555>.
18     AC_CACHE_CHECK([whether strerrorname_np works],
19       [gl_cv_func_strerrorname_np_works],
20       [AC_RUN_IFELSE(
21          [AC_LANG_PROGRAM(
22             [[#include <errno.h>
23               #include <string.h>
24             ]],
25             [[return strcmp (strerrorname_np (EINVAL), "EINVAL") != 0;
26             ]])],
27          [gl_cv_func_strerrorname_np_works=yes],
28          [gl_cv_func_strerrorname_np_works=no],
29          [case "$host_os" in
30             # Guess no on glibc systems.
31             *-gnu* | gnu*)
32               gl_cv_func_strerrorname_np_works="guessing no" ;;
33             # Otherwise obey --enable-cross-guesses.
34             *)
35               gl_cv_func_strerrorname_np_works="$gl_cross_guess_normal" ;;
36           esac
37          ])
38       ])
39     case "$gl_cv_func_strerrorname_np_works" in
40       *yes) ;;
41       *) REPLACE_STRERRORNAME_NP=1 ;;
42     esac
43   else
44     HAVE_STRERRORNAME_NP=0
45   fi