md5, sha1, sha256, sha512: add gl_SET_CRYPTO_CHECK_DEFAULT
[gnulib.git] / lib / fstatat.c
index f1bed73..845c171 100644 (file)
@@ -1,6 +1,6 @@
 /* Work around an fstatat bug on Solaris 9.
 
-   Copyright (C) 2006, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2009-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 #undef __need_system_sys_stat_h
 
 #if HAVE_FSTATAT
-static inline int
+static int
 orig_fstatat (int fd, char const *filename, struct stat *buf, int flags)
 {
   return fstatat (fd, filename, buf, flags);
 }
 #endif
 
-#include <sys/stat.h>
+/* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc
+   eliminates this include because of the preliminary #include <sys/stat.h>
+   above.  */
+#include "sys/stat.h"
 
 #include <errno.h>
 #include <fcntl.h>
 #include <string.h>
 
-#if HAVE_FSTATAT
-
-# undef fstatat
-
-# ifndef FSTATAT_AT_FDCWD_0_BROKEN
-#  define FSTATAT_AT_FDCWD_0_BROKEN 0
-# endif
+#if HAVE_FSTATAT && HAVE_WORKING_FSTATAT_ZERO_FLAG
 
 # ifndef LSTAT_FOLLOWS_SLASHED_SYMLINK
 #  define LSTAT_FOLLOWS_SLASHED_SYMLINK 0
@@ -66,10 +63,7 @@ orig_fstatat (int fd, char const *filename, struct stat *buf, int flags)
 int
 rpl_fstatat (int fd, char const *file, struct stat *st, int flag)
 {
-  int result =
-    (FSTATAT_AT_FDCWD_0_BROKEN && fd == AT_FDCWD && flag == 0
-     ? stat (file, st)
-     : orig_fstatat (fd, file, st, flag));
+  int result = orig_fstatat (fd, file, st, flag);
   size_t len;
 
   if (LSTAT_FOLLOWS_SLASHED_SYMLINK || result != 0)
@@ -85,7 +79,7 @@ rpl_fstatat (int fd, char const *file, struct stat *st, int flag)
           errno = ENOTDIR;
           return -1;
         }
-      result = fstatat (fd, file, st, flag & ~AT_SYMLINK_NOFOLLOW);
+      result = orig_fstatat (fd, file, st, flag & ~AT_SYMLINK_NOFOLLOW);
     }
   /* Fix stat behavior.  */
   if (result == 0 && !S_ISDIR (st->st_mode) && file[len - 1] == '/')
@@ -96,20 +90,20 @@ rpl_fstatat (int fd, char const *file, struct stat *st, int flag)
   return result;
 }
 
-#else /* !HAVE_FSTATAT */
+#else /* ! (HAVE_FSTATAT && HAVE_WORKING_FSTATAT_ZERO_FLAG) */
 
-/* On mingw, the gnulib <sys/stat.h> defines `stat' as a function-like
+/* On mingw, the gnulib <sys/stat.h> defines 'stat' as a function-like
    macro; but using it in AT_FUNC_F2 causes compilation failure
    because the preprocessor sees a use of a macro that requires two
    arguments but is only given one.  Hence, we need an inline
    forwarder to get past the preprocessor.  */
-static inline int
+static int
 stat_func (char const *name, struct stat *st)
 {
   return stat (name, st);
 }
 
-/* Likewise, if there is no native `lstat', then the gnulib
+/* Likewise, if there is no native 'lstat', then the gnulib
    <sys/stat.h> defined it as stat, which also needs adjustment.  */
 # if !HAVE_LSTAT
 #  undef lstat