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.
7 dnl This file is offered as-is, without any warranty.
9 # See if we need to provide readlinkat replacement.
11 # Written by Eric Blake.
13 AC_DEFUN([gl_FUNC_READLINKAT],
15 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
16 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
17 gl_CHECK_FUNCS_ANDROID([readlinkat], [[#include <unistd.h>]])
18 AC_REQUIRE([gl_FUNC_READLINK])
19 if test $ac_cv_func_readlinkat = no; then
21 case "$gl_cv_onwards_func_readlinkat" in
22 future*) REPLACE_READLINKAT=1 ;;
25 AC_CACHE_CHECK([whether readlinkat signature is correct],
26 [gl_cv_decl_readlinkat_works],
30 /* Check whether original declaration has correct type. */
31 ssize_t readlinkat (int, char const *, char *, size_t);
34 [gl_cv_decl_readlinkat_works=yes],
35 [gl_cv_decl_readlinkat_works=no])
37 # Assume readlinkat has the same bugs as readlink,
38 # as is the case on macOS 14 with trailing slashes.
39 case $gl_cv_decl_readlinkat_works,$gl_cv_func_readlink_trailing_slash,$gl_cv_func_readlink_truncate in
47 dnl On Cygwin 3.3.6, readlinkat(AT_FDCWD,"/dev/null") returns
48 dnl "\\Device\\Null", which is unusable.