Blame m4/fstatat.m4

Packit 709fb3
# fstatat.m4 serial 3
Packit 709fb3
dnl Copyright (C) 2004-2017 Free Software Foundation, Inc.
Packit 709fb3
dnl This file is free software; the Free Software Foundation
Packit 709fb3
dnl gives unlimited permission to copy and/or distribute it,
Packit 709fb3
dnl with or without modifications, as long as this notice is preserved.
Packit 709fb3
Packit 709fb3
# Written by Jim Meyering.
Packit 709fb3
Packit 709fb3
# If we have the fstatat function, and it has the bug (in AIX 7.1)
Packit 709fb3
# that it does not fill in st_size correctly, use the replacement function.
Packit 709fb3
AC_DEFUN([gl_FUNC_FSTATAT],
Packit 709fb3
[
Packit 709fb3
  AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
Packit 709fb3
  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
Packit 709fb3
  AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
Packit 709fb3
  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
Packit 709fb3
  AC_CHECK_FUNCS_ONCE([fstatat])
Packit 709fb3
Packit 709fb3
  if test $ac_cv_func_fstatat = no; then
Packit 709fb3
    HAVE_FSTATAT=0
Packit 709fb3
  else
Packit 709fb3
    dnl Test for an AIX 7.1 bug; see
Packit 709fb3
    dnl <http://lists.gnu.org/archive/html/bug-tar/2011-09/msg00015.html>.
Packit 709fb3
    AC_CACHE_CHECK([whether fstatat (..., 0) works],
Packit 709fb3
      [gl_cv_func_fstatat_zero_flag],
Packit 709fb3
      [AC_RUN_IFELSE(
Packit 709fb3
         [AC_LANG_SOURCE(
Packit 709fb3
            [[
Packit 709fb3
              #include <fcntl.h>
Packit 709fb3
              #include <sys/stat.h>
Packit 709fb3
              int
Packit 709fb3
              main (void)
Packit 709fb3
              {
Packit 709fb3
                struct stat a;
Packit 709fb3
                return fstatat (AT_FDCWD, ".", &a, 0) != 0;
Packit 709fb3
              }
Packit 709fb3
            ]])],
Packit 709fb3
         [gl_cv_func_fstatat_zero_flag=yes],
Packit 709fb3
         [gl_cv_func_fstatat_zero_flag=no],
Packit 709fb3
         [case "$host_os" in
Packit 709fb3
            aix*) gl_cv_func_fstatat_zero_flag="guessing no";;
Packit 709fb3
            *)    gl_cv_func_fstatat_zero_flag="guessing yes";;
Packit 709fb3
          esac
Packit 709fb3
         ])
Packit 709fb3
      ])
Packit 709fb3
Packit 709fb3
    case $gl_cv_func_fstatat_zero_flag+$gl_cv_func_lstat_dereferences_slashed_symlink in
Packit 709fb3
    *yes+*yes) ;;
Packit 709fb3
    *) REPLACE_FSTATAT=1
Packit 709fb3
       case $gl_cv_func_fstatat_zero_flag in
Packit 709fb3
       *yes)
Packit 709fb3
         AC_DEFINE([HAVE_WORKING_FSTATAT_ZERO_FLAG], [1],
Packit 709fb3
           [Define to 1 if fstatat (..., 0) works.
Packit 709fb3
            For example, it does not work in AIX 7.1.])
Packit 709fb3
         ;;
Packit 709fb3
       esac
Packit 709fb3
       ;;
Packit 709fb3
    esac
Packit 709fb3
  fi
Packit 709fb3
])