From 38a619af97ccb98cfca702d8ae084926fd42fd39 Mon Sep 17 00:00:00 2001 From: "David M. Lee" Date: Wed, 5 Mar 2014 16:58:21 +0000 Subject: Corrected cross-platform stat nanosecond code When nanosecond time resolution was added for identifying config file changes, it didn't cover all of the myriad of ways that one might obtain nanosecond time resolution off of struct stat. Rather than complicate the #if even further figuring out one system from the next, this patch directly tests for the three struct members I know about today, and #ifdef's accordingly. Review: https://reviewboard.asterisk.org/r/3273/ ........ Merged revisions 409833 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 409834 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 409835 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@409836 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/config.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'main/config.c') diff --git a/main/config.c b/main/config.c index 8961fa9e3..a7228c36b 100644 --- a/main/config.c +++ b/main/config.c @@ -1246,10 +1246,14 @@ static void cfmstat_clear(struct cache_file_mtime *cfmtime) static void cfmstat_save(struct cache_file_mtime *cfmtime, struct stat *statbuf) { cfmtime->stat_size = statbuf->st_size; -#if defined(_BSD_SOURCE) || defined(_SVID_SOURCE) || (defined(_POSIX_C_SOURCE) && 200809L <= _POSIX_C_SOURCE) || (defined(_XOPEN_SOURCE) && 700 <= _XOPEN_SOURCE) +#if defined(HAVE_STRUCT_STAT_ST_MTIM) cfmtime->stat_mtime_nsec = statbuf->st_mtim.tv_nsec; -#else +#elif defined(HAVE_STRUCT_STAT_ST_MTIMENSEC) cfmtime->stat_mtime_nsec = statbuf->st_mtimensec; +#elif defined(HAVE_STRUCT_STAT_ST_MTIMESPEC) + cfmtime->stat_mtime_nsec = statbuf->st_mtimespec.tv_nsec; +#else + cfmtime->stat_mtime_nsec = 0; #endif cfmtime->stat_mtime = statbuf->st_mtime; } -- cgit v1.2.3