Commit | Line | Data |
---|---|---|
8654f9d7 PE |
1 | # fstatat.m4 serial 3 |
2 | dnl Copyright (C) 2004-2013 Free Software Foundation, Inc. | |
3 | dnl This file is free software; the Free Software Foundation | |
4 | dnl gives unlimited permission to copy and/or distribute it, | |
5 | dnl with or without modifications, as long as this notice is preserved. | |
6 | ||
7 | # Written by Jim Meyering. | |
8 | ||
9 | # If we have the fstatat function, and it has the bug (in AIX 7.1) | |
10 | # that it does not fill in st_size correctly, use the replacement function. | |
11 | AC_DEFUN([gl_FUNC_FSTATAT], | |
12 | [ | |
13 | AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) | |
14 | AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) | |
15 | AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK]) | |
16 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | |
17 | AC_CHECK_FUNCS_ONCE([fstatat]) | |
18 | ||
19 | if test $ac_cv_func_fstatat = no; then | |
20 | HAVE_FSTATAT=0 | |
21 | else | |
22 | dnl Test for an AIX 7.1 bug; see | |
23 | dnl <http://lists.gnu.org/archive/html/bug-tar/2011-09/msg00015.html>. | |
24 | AC_CACHE_CHECK([whether fstatat (..., 0) works], | |
25 | [gl_cv_func_fstatat_zero_flag], | |
26 | [AC_RUN_IFELSE( | |
27 | [AC_LANG_SOURCE( | |
28 | [[ | |
29 | #include <fcntl.h> | |
30 | #include <sys/stat.h> | |
31 | int | |
32 | main (void) | |
33 | { | |
34 | struct stat a; | |
35 | return fstatat (AT_FDCWD, ".", &a, 0) != 0; | |
36 | } | |
37 | ]])], | |
38 | [gl_cv_func_fstatat_zero_flag=yes], | |
39 | [gl_cv_func_fstatat_zero_flag=no], | |
40 | [case "$host_os" in | |
41 | aix*) gl_cv_func_fstatat_zero_flag="guessing no";; | |
42 | *) gl_cv_func_fstatat_zero_flag="guessing yes";; | |
43 | esac | |
44 | ]) | |
45 | ]) | |
46 | ||
47 | case $gl_cv_func_fstatat_zero_flag+$gl_cv_func_lstat_dereferences_slashed_symlink in | |
48 | *yes+*yes) ;; | |
49 | *) REPLACE_FSTATAT=1 | |
50 | case $gl_cv_func_fstatat_zero_flag in | |
51 | *yes) | |
52 | AC_DEFINE([HAVE_WORKING_FSTATAT_ZERO_FLAG], [1], | |
53 | [Define to 1 if fstatat (..., 0) works. | |
54 | For example, it does not work in AIX 7.1.]) | |
55 | ;; | |
56 | esac | |
57 | ;; | |
58 | esac | |
59 | fi | |
60 | ]) |