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 mkfifoat/mknodat replacement.
11 # Written by Eric Blake.
13 AC_DEFUN([gl_FUNC_MKFIFOAT],
15 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
16 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
18 dnl Persuade glibc <sys/stat.h> to declare mkfifoat() and mknodat().
19 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
21 AC_REQUIRE([gl_FUNC_OPENAT])
23 gl_CHECK_FUNCS_ANDROID_MACOS([mknodat], [[#include <sys/stat.h>]])
24 gl_CHECK_FUNCS_ANDROID_MACOS([mkfifoat], [[#include <sys/stat.h>]])
25 if test $ac_cv_func_mkfifoat = yes; then
26 dnl Check for AIX 7.2 bug and macOS 14 bugs with trailing slash.
27 AC_CACHE_CHECK([whether mkfifoat rejects trailing slashes],
28 [gl_cv_func_mkfifoat_works],
37 /* This test fails on AIX 7.2. */
38 if (!mkfifoat (AT_FDCWD, "conftest.tmp/", 0600))
40 /* This test fails on macOS 14. */
41 if (!symlink ("conftest.fifo", "conftest.tmp")
42 && !mkfifoat (AT_FDCWD, "conftest.tmp/", 0600))
47 [gl_cv_func_mkfifoat_works=yes],
48 [gl_cv_func_mkfifoat_works=no],
50 # Guess yes on Linux systems.
51 linux-* | linux) gl_cv_func_mkfifoat_works="guessing yes" ;;
52 # Guess yes on glibc systems.
53 *-gnu* | gnu*) gl_cv_func_mkfifoat_works="guessing yes" ;;
54 # Guess no on macOS systems.
55 darwin*) gl_cv_func_mkfifoat_works="guessing no" ;;
56 # Guess no on AIX systems.
57 aix*) gl_cv_func_mkfifoat_works="guessing no" ;;
58 # If we don't know, obey --enable-cross-guesses.
59 *) gl_cv_func_mkfifoat_works="$gl_cross_guess_normal" ;;
64 case "$gl_cv_func_mkfifoat_works" in
68 dnl mknodat() has the same bug as mkfifoat().
73 # No known system has mkfifoat but not mknodat
75 case "$gl_cv_onwards_func_mkfifoat" in
76 future*) REPLACE_MKFIFOAT=1 ;;
79 case "$gl_cv_onwards_func_mknodat" in
80 future*) REPLACE_MKNODAT=1 ;;