xstrtol, xstrtoll tests: Fix test failures.
[gnulib.git] / m4 / readlinkat.m4
blob4c4e3588e0aa1ee0cc38cf89bf7b7f8f33cf20f9
1 # readlinkat.m4
2 # serial 10
3 dnl Copyright (C) 2009-2024 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.
8 # See if we need to provide readlinkat replacement.
10 # Written by Eric Blake.
12 AC_DEFUN([gl_FUNC_READLINKAT],
14   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
15   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
16   gl_CHECK_FUNCS_ANDROID([readlinkat], [[#include <unistd.h>]])
17   AC_REQUIRE([gl_FUNC_READLINK])
18   if test $ac_cv_func_readlinkat = no; then
19     HAVE_READLINKAT=0
20     case "$gl_cv_onwards_func_readlinkat" in
21       future*) REPLACE_READLINKAT=1 ;;
22     esac
23   else
24     AC_CACHE_CHECK([whether readlinkat signature is correct],
25       [gl_cv_decl_readlinkat_works],
26       [AC_COMPILE_IFELSE(
27          [AC_LANG_PROGRAM(
28            [[#include <unistd.h>
29              /* Check whether original declaration has correct type.  */
30              ssize_t readlinkat (int, char const *, char *, size_t);
31            ]])
32          ],
33          [gl_cv_decl_readlinkat_works=yes],
34          [gl_cv_decl_readlinkat_works=no])
35       ])
36     # Assume readlinkat has the same bugs as readlink,
37     # as is the case on macOS 14 with trailing slashes.
38     case $gl_cv_decl_readlinkat_works,$gl_cv_func_readlink_trailing_slash,$gl_cv_func_readlink_truncate in
39       *yes,*yes,*yes)
40         ;;
41       *)
42         REPLACE_READLINKAT=1
43         ;;
44     esac
46     dnl On Cygwin 3.3.6, readlinkat(AT_FDCWD,"/dev/null") returns
47     dnl "\\Device\\Null", which is unusable.
48     case "$host_os" in
49       cygwin*)
50         REPLACE_READLINKAT=1
51         ;;
52     esac
53   fi