Skip to content

Commit d2bf82f

Browse files
committed
Update checks for new stat fields.
This uses the macros as defined by the man page, which, as noted in the comments, are defined correctly on as many libc's that I could check.
1 parent bf4fb03 commit d2bf82f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/disk_interface.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,14 @@ TimeStamp RealDiskInterface::Stat(const string& path, string* err) const {
194194
#if defined(__APPLE__) && !defined(_POSIX_C_SOURCE)
195195
return ((int64_t)st.st_mtimespec.tv_sec * 1000000000LL +
196196
st.st_mtimespec.tv_nsec);
197-
#elif defined(_LARGEFILE64_SOURCE)
197+
#elif (_POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700 || defined(_BSD_SOURCE) || defined(_SVID_SOURCE) || \
198+
defined(__BIONIC__))
199+
// For glibc, see "Timestamp files" in the Notes of http://www.kernel.org/doc/man-pages/online/pages/man2/stat.2.html
200+
// newlib, uClibc and musl follow the kernel (or Cygwin) headers and define the right macro values above.
201+
// For bsd, see https://github.com/freebsd/freebsd/blob/master/sys/sys/stat.h and similar
202+
// For bionic, C and POSIX API is always enabled.
198203
return (int64_t)st.st_mtim.tv_sec * 1000000000LL + st.st_mtim.tv_nsec;
199-
#elif defined(__CYGWIN__)
200-
return (int64_t)st.st_mtime * 1000000000LL;
201204
#else
202-
// see http://www.kernel.org/doc/man-pages/online/pages/man2/stat.2.html
203205
return (int64_t)st.st_mtime * 1000000000LL + st.st_mtimensec;
204206
#endif
205207
#endif

0 commit comments

Comments
 (0)