bug-gnulib
[Top][All Lists]
Advanced

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

Re: stat() replacement with _LARGE_FILES on AIX


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

Eric Blake wrote:
> According to Michael Haubenwallner on 10/30/2009 6:21 AM:
>> 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):
> 
> Thanks for the report.
> 
>> 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.
> 
> If stat is defined, we can't be positive it was defined to stat64 or some
> other spelling, like __stat64.  I'd feel safer blindly replacing all known
> spellings, as and when we encounter them.

Fine with me.

> So that I can fully understand the situation on AIX, what does the system
> header show for stat64()?  Is there a struct stat64?  I guess if the
> #define stat stat64 occurs before either declaration of stat() or struct
> stat, that would explain what you are seeing.

The declarations are in this order in <sys/stat.h> on AIX5.3:

---
#if !defined(_LARGE_FILES)
struct  stat { ... };
#endif

#if defined(_LARGE_FILES) || defined(_LARGE_FILE_API)
struct  stat64 { ... };
#endif /* _LARGE_FILES || LARGE_FILE_API */

#ifdef _LARGE_FILES
# define stat    stat64
# define fstat   fstat64
# if _XOPEN_SOURCE_EXTENDED==1
#  define lstat   lstat64
# endif
#endif  /* _LARGE_FILES */

    extern int  stat(const char *__restrict__, struct stat *__restrict__);
    extern int  fstat(int, struct stat *);
#ifdef _LARGE_FILE_API
    extern int  stat64(const char *__restrict__, struct stat64 *__restrict__);
    extern int  fstat64(int, struct stat64 *);
#endif /* _LARGE_FILE_API */

#if _XOPEN_SOURCE_EXTENDED==1
    extern int  lstat(const char *__restrict__, struct stat *__restrict__);
# ifdef _LARGE_FILE_API
    extern int  lstat64(const char *__restrict__, struct stat64 *__restrict__);
# endif /* _LARGE_FILE_API */
#endif /* _XOPEN_SOURCE_EXTENDED */
---

> I think I will probably apply your patch with minor modifications (the
> parenthesis in #if defined are unnecessary),

Do as you like, have attached another patch anyway.

> but seeing the system header
> will make it more comfortable to explain why we're doing this.

Do you still need (offlist?) the whole header file?

Thank you!
/haubi
diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h
index e7cb5ee..1e46da8 100644
--- a/lib/sys_stat.in.h
+++ b/lib/sys_stat.in.h
@@ -456,7 +456,15 @@ int mknodat (int fd, char const *file, mode_t mode, dev_t 
dev);
    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)
+#  ifdef _LARGE_FILES
+    /* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
+       so we have to replace stat64() instead of stat(). */
+#   define stat stat64
+#   undef stat64
+#   define stat64(name, st) rpl_stat (name, st)
+#  else /* !_LARGE_FILES */
+#   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]