immutable: Add tests.
[gnulib.git] / m4 / mkfifoat.m4
blob3d4ad2bd05205d786c6e09dac70bfd6beb888976
1 # serial 5
2 # See if we need to provide mkfifoat/mknodat replacement.
4 dnl Copyright (C) 2009-2021 Free Software Foundation, Inc.
5 dnl This file is free software; the Free Software Foundation
6 dnl gives unlimited permission to copy and/or distribute it,
7 dnl with or without modifications, as long as this notice is preserved.
9 # Written by Eric Blake.
11 AC_DEFUN([gl_FUNC_MKFIFOAT],
13   AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
14   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
16   dnl Persuade glibc <sys/stat.h> to declare mkfifoat() and mknodat().
17   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
19   AC_REQUIRE([gl_FUNC_OPENAT])
21   AC_CHECK_FUNCS_ONCE([mkfifoat mknodat])
22   if test $ac_cv_func_mkfifoat = yes; then
23     dnl Check for AIX 7.2 bug with trailing slash.
24     AC_CACHE_CHECK([whether mkfifoat rejects trailing slashes],
25       [gl_cv_func_mkfifoat_works],
26       [rm -f conftest.tmp
27        AC_RUN_IFELSE(
28          [AC_LANG_PROGRAM(
29             [[#include <fcntl.h>
30               #include <sys/stat.h>
31             ]],
32             [[int result = 0;
33               if (!mkfifoat (AT_FDCWD, "conftest.tmp/", 0600))
34                 result |= 1;
35               return result;
36             ]])
37          ],
38          [gl_cv_func_mkfifoat_works=yes],
39          [gl_cv_func_mkfifoat_works=no],
40          [case "$host_os" in
41                              # Guess yes on Linux systems.
42             linux-* | linux) gl_cv_func_mkfifoat_works="guessing yes" ;;
43                              # Guess yes on glibc systems.
44             *-gnu* | gnu*)   gl_cv_func_mkfifoat_works="guessing yes" ;;
45                              # Guess no on AIX systems.
46             aix*)            gl_cv_func_mkfifoat_works="guessing no" ;;
47                              # If we don't know, obey --enable-cross-guesses.
48             *)               gl_cv_func_mkfifoat_works="$gl_cross_guess_normal" ;;
49           esac
50          ])
51        rm -f conftest.tmp
52       ])
53     case "$gl_cv_func_mkfifoat_works" in
54       *yes) ;;
55       *)
56         REPLACE_MKFIFOAT=1
57         dnl mknodat() has the same bug as mkfifoat().
58         REPLACE_MKNODAT=1
59         ;;
60     esac
61   else
62     # No known system has mkfifoat but not mknodat
63     HAVE_MKFIFOAT=0
64     HAVE_MKNODAT=0
65   fi