Check for struct stat.st_ctime_nsec before using

Using a configure check for stat.st_ctime_nsec fixes building on
Android which has that field but does not define STAT_HAVE_NSEC.

Before this change the Android build failed on the st_ctim.tv_nsec
fallback #else clause.
This commit is contained in:
Fredrik Fornwall 2016-10-11 00:40:33 +02:00 committed by Kurtis Rader
parent d8497f0f1e
commit 36f320598e
2 changed files with 2 additions and 1 deletions

View file

@ -284,6 +284,7 @@ AC_DEFINE_UNQUOTED([WCHAR_T_BITS], [$WCHAR_T_BITS], [The size of wchar_t in bits
#
# Detect nanoseconds fields in struct stat
#
AC_CHECK_MEMBERS([struct stat.st_ctime_nsec])
AC_CHECK_MEMBERS([struct stat.st_mtimespec.tv_nsec])
AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec])

View file

@ -548,7 +548,7 @@ file_id_t file_id_t::file_id_from_stat(const struct stat *buf) {
result.change_seconds = buf->st_ctime;
result.mod_seconds = buf->st_mtime;
#if STAT_HAVE_NSEC
#ifdef HAVE_STRUCT_STAT_ST_CTIME_NSEC
result.change_nanoseconds = buf->st_ctime_nsec;
result.mod_nanoseconds = buf->st_mtime_nsec;
#elif defined(__APPLE__)