From 639607db00b96f33b0e18afa27188456c6ccad0a Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 4 May 2012 04:29:15 +0200 Subject: [PATCH] lstat: Avoid "guessing no" when cross-compiling to glibc systems. * m4/lstat.m4 (gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK): When cross- compiling, set gl_cv_func_lstat_dereferences_slashed_symlink to "guessing yes" or "guessing no". (gl_FUNC_LSTAT): Update. * m4/fstatat.m4 (gl_FUNC_FSTATAT): Update. * m4/openat.m4 (gl_FUNC_OPENAT): Update. * m4/unlinkat.m4 (gl_FUNC_UNLINKAT): Update. --- ChangeLog | 11 +++++++++++ m4/fstatat.m4 | 4 ++-- m4/lstat.m4 | 33 ++++++++++++++++++++------------- m4/openat.m4 | 4 ++-- m4/unlinkat.m4 | 23 +++++++++++++---------- 5 files changed, 48 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index c1c5ac29f..ca2f6c4de 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2012-05-03 Bruno Haible + lstat: Avoid "guessing no" when cross-compiling to glibc systems. + * m4/lstat.m4 (gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK): When cross- + compiling, set gl_cv_func_lstat_dereferences_slashed_symlink to + "guessing yes" or "guessing no". + (gl_FUNC_LSTAT): Update. + * m4/fstatat.m4 (gl_FUNC_FSTATAT): Update. + * m4/openat.m4 (gl_FUNC_OPENAT): Update. + * m4/unlinkat.m4 (gl_FUNC_UNLINKAT): Update. + +2012-05-03 Bruno Haible + *alloc-gnu, eealloc: Avoid "guessing no" when cross-compiling to glibc. * m4/malloc.m4 (_AC_FUNC_MALLOC_IF): Override in autoconf < 2.70. * m4/realloc.m4 (_AC_FUNC_REALLOC_IF): Override in autoconf < 2.70. diff --git a/m4/fstatat.m4 b/m4/fstatat.m4 index a68853154..f84e198fd 100644 --- a/m4/fstatat.m4 +++ b/m4/fstatat.m4 @@ -1,4 +1,4 @@ -# fstatat.m4 serial 2 +# fstatat.m4 serial 3 dnl Copyright (C) 2004-2012 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -45,7 +45,7 @@ AC_DEFUN([gl_FUNC_FSTATAT], ]) case $gl_cv_func_fstatat_zero_flag+$gl_cv_func_lstat_dereferences_slashed_symlink in - *yes+yes) ;; + *yes+*yes) ;; *) REPLACE_FSTATAT=1 case $gl_cv_func_fstatat_zero_flag in *yes) diff --git a/m4/lstat.m4 b/m4/lstat.m4 index b83858bdb..b7335bda1 100644 --- a/m4/lstat.m4 +++ b/m4/lstat.m4 @@ -1,4 +1,4 @@ -# serial 24 +# serial 25 # Copyright (C) 1997-2001, 2003-2012 Free Software Foundation, Inc. # @@ -16,9 +16,11 @@ AC_DEFUN([gl_FUNC_LSTAT], AC_CHECK_FUNCS_ONCE([lstat]) if test $ac_cv_func_lstat = yes; then AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK]) - if test $gl_cv_func_lstat_dereferences_slashed_symlink = no; then - REPLACE_LSTAT=1 - fi + case "$gl_cv_func_lstat_dereferences_slashed_symlink" in + *no) + REPLACE_LSTAT=1 + ;; + esac else HAVE_LSTAT=0 fi @@ -51,20 +53,25 @@ AC_DEFUN([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK], ]])], [gl_cv_func_lstat_dereferences_slashed_symlink=yes], [gl_cv_func_lstat_dereferences_slashed_symlink=no], - [# When cross-compiling, be pessimistic so we will end up using the - # replacement version of lstat that checks for trailing slashes and - # calls lstat a second time when necessary. - gl_cv_func_lstat_dereferences_slashed_symlink=no + [case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_lstat_dereferences_slashed_symlink="guessing yes" ;; + # If we don't know, assume the worst. + *) gl_cv_func_lstat_dereferences_slashed_symlink="guessing no" ;; + esac ]) else # If the 'ln -s' command failed, then we probably don't even # have an lstat function. - gl_cv_func_lstat_dereferences_slashed_symlink=no + gl_cv_func_lstat_dereferences_slashed_symlink="guessing no" fi rm -f conftest.sym conftest.file ]) - test $gl_cv_func_lstat_dereferences_slashed_symlink = yes && - AC_DEFINE_UNQUOTED([LSTAT_FOLLOWS_SLASHED_SYMLINK], [1], - [Define to 1 if 'lstat' dereferences a symlink specified - with a trailing slash.]) + case "$gl_cv_func_lstat_dereferences_slashed_symlink" in + *yes) + AC_DEFINE_UNQUOTED([LSTAT_FOLLOWS_SLASHED_SYMLINK], [1], + [Define to 1 if 'lstat' dereferences a symlink specified + with a trailing slash.]) + ;; + esac ]) diff --git a/m4/openat.m4 b/m4/openat.m4 index 33281d2c2..0040040b7 100644 --- a/m4/openat.m4 +++ b/m4/openat.m4 @@ -1,4 +1,4 @@ -# serial 43 +# serial 44 # See if we need to use our replacement for Solaris' openat et al functions. dnl Copyright (C) 2004-2012 Free Software Foundation, Inc. @@ -15,7 +15,7 @@ AC_DEFUN([gl_FUNC_OPENAT], AC_CHECK_FUNCS_ONCE([openat]) AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK]) case $ac_cv_func_openat+$gl_cv_func_lstat_dereferences_slashed_symlink in - yes+yes) + yes+*yes) ;; yes+*) # Solaris 9 has *at functions, but uniformly mishandles trailing diff --git a/m4/unlinkat.m4 b/m4/unlinkat.m4 index cf735baf2..fc10d590b 100644 --- a/m4/unlinkat.m4 +++ b/m4/unlinkat.m4 @@ -1,4 +1,4 @@ -# unlinkat.m4 serial 1 +# unlinkat.m4 serial 2 dnl Copyright (C) 2004-2012 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -16,15 +16,18 @@ AC_DEFUN([gl_FUNC_UNLINKAT], if test $ac_cv_func_unlinkat = no; then HAVE_UNLINKAT=0 else - if test $gl_cv_func_lstat_dereferences_slashed_symlink != yes; then - # Solaris 9 has *at functions, but uniformly mishandles trailing - # slash in all of them. - REPLACE_UNLINKAT=1 - else - # GNU/Hurd has unlinkat, but it has the same bug as unlink. - if test $REPLACE_UNLINK = 1; then + case "$gl_cv_func_lstat_dereferences_slashed_symlink" in + *no) + # Solaris 9 has *at functions, but uniformly mishandles trailing + # slash in all of them. REPLACE_UNLINKAT=1 - fi - fi + ;; + *) + # GNU/Hurd has unlinkat, but it has the same bug as unlink. + if test $REPLACE_UNLINK = 1; then + REPLACE_UNLINKAT=1 + fi + ;; + esac fi ]) -- 2.11.0