bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

stat() replacement with _LARGE_FILES on AIX


From: Michael Haubenwallner
Subject: stat() replacement with _LARGE_FILES on AIX
Date: Fri, 30 Oct 2009 13:21:33 +0100
User-agent: Thunderbird 2.0.0.23 (X11/20091015)

Hi,

using stat() replacement on AIX results in these build errors (seen in
gzip-1.3.13 on AIX5.3), because AIX defines 'stat' to 'stat64' when
_LARGE_FILES is defined (by AC_SYS_LARGEFILE):

  CC     lstat.o
lstat.c:62: warning: "struct stat" declared inside parameter list
lstat.c:63: error: conflicting types for 'rpl_lstat'
./sys/stat.h:326: error: previous declaration of 'rpl_lstat' was here
lstat.c:63: error: conflicting types for 'rpl_lstat'
./sys/stat.h:326: error: previous declaration of 'rpl_lstat' was here
lstat.c: In function `rpl_lstat':
lstat.c:65: warning: passing arg 2 of `orig_lstat' from incompatible pointer 
type
lstat.c:76: error: dereferencing pointer to incomplete type
lstat.c:84: error: dereferencing pointer to incomplete type
lstat.c:89: warning: passing arg 2 of `rpl_stat' from incompatible pointer type
make[3]: *** [lstat.o] Error 1

IMHO, when _LARGE_FILES is defined, it is stat64() that should be
replaced instead of stat().

As far as I know, only AIX does use _LARGE_FILES, so the attached patch,
which works with both gcc and xlc for gzip-1.3.13, should be safe.

Thank you!
/haubi/
diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h
index e7cb5ee..de4502d 100644
--- a/lib/sys_stat.in.h
+++ b/lib/sys_stat.in.h
@@ -455,8 +455,15 @@ int mknodat (int fd, char const *file, mode_t mode, dev_t 
dev);
 /* We can't use the object-like #define stat rpl_stat, because of
    struct stat.  This means that rpl_stat will not be used if the user
    does (stat)(a,b).  Oh well.  */
-#  undef stat
-#  define stat(name, st) rpl_stat (name, st)
+#  if defined(_LARGE_FILES) && defined(stat)
+    /* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
+       so we have to replace stat64() instead of stat(). */
+#   undef stat64
+#   define stat64(name, st) rpl_stat (name, st)
+#  else /* !_LARGE_FILES */
+#   undef stat
+#   define stat(name, st) rpl_stat (name, st)
+#  endif /* !_LARGE_FILES */
 extern int stat (const char *name, struct stat *buf);
 # endif
 #elif defined GNULIB_POSIXCHECK

reply via email to

[Prev in Thread] Current Thread [Next in Thread]