Michael Haubenwallner <michael.haubenwallner <at> salomon.at> writes:
> > 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: Thanks - that confirms what I wanted to know. > > --- > #if !defined(_LARGE_FILES) > struct stat { ... }; > #endif struct stat only exists if _LARGE_FILES is undefined... > > #if defined(_LARGE_FILES) || defined(_LARGE_FILE_API) > struct stat64 { ... }; > #endif /* _LARGE_FILES || LARGE_FILE_API */ struct stat64 exists for _LARGE_FILES and also if you can see both stat() and stat64()... > > #ifdef _LARGE_FILES > # define stat stat64 > # define fstat fstat64 This is overriding only stat(), since struct stat was undefined to begin with on this preprocessor path, but picking up on the fact that only struct stat64 was declared... > # if _XOPEN_SOURCE_EXTENDED==1 > # define lstat lstat64 > # endif > #endif /* _LARGE_FILES */ > > extern int stat(const char *__restrict__, struct stat *__restrict__); This line declares: stat(struct stat) if _LARGE_FILES was undefined, otherwise it declares two synonyms: stat(struct stat64) aka stat64(struct stat64) > extern int fstat(int, struct stat *); > #ifdef _LARGE_FILE_API > extern int stat64(const char *__restrict__, struct stat64 *__restrict__); If _LARGE_FILES, this is a repeat delaration, and we have exactly: stat(struct stat64) stat64(struct stat64) visible to the app. If _LARGE_FILE_API but not _LARGE_FILES, then we have: stat(struct stat) stat64(struct stat64) visible to the app. And with neither, then we see only stat(struct stat). > Do as you like, have attached another patch anyway. Your second patch looks like it solves the problem nicely. We end up with this with _LARGE_FILES: stat(struct stat) => rpl_stat(struct stat64) which is exactly what we want. And there is no change if _LARGE_FILES is undefined. > > Do you still need (offlist?) the whole header file? Nope, you've done enough. Thanks! Now all I have to do is test that your patch doesn't break Linux or Solaris (that is, either autoconf doesn't set _LARGE_FILES for those platforms, or the use of _LARGE_FILES on those platforms doesn't break anything). -- Eric Blake