[asterisk-commits] dlee: branch 11 r409834 - in /branches/11: ./ include/asterisk/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Mar 5 10:56:03 CST 2014


Author: dlee
Date: Wed Mar  5 10:55:52 2014
New Revision: 409834

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=409834
Log:
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

Modified:
    branches/11/   (props changed)
    branches/11/configure
    branches/11/configure.ac
    branches/11/include/asterisk/autoconfig.h.in
    branches/11/main/config.c

Propchange: branches/11/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Modified: branches/11/configure.ac
URL: http://svnview.digium.com/svn/asterisk/branches/11/configure.ac?view=diff&rev=409834&r1=409833&r2=409834
==============================================================================
--- branches/11/configure.ac (original)
+++ branches/11/configure.ac Wed Mar  5 10:55:52 2014
@@ -562,6 +562,12 @@
 AC_STRUCT_TM
 AC_C_VOLATILE
 AC_CHECK_TYPES([ptrdiff_t])
+stat_nsec_found=no
+AC_CHECK_MEMBERS([struct stat.st_mtim, struct stat.st_mtimensec, struct stat.st_mtimespec], [stat_nsec_found=yes], [], [[#include <sys/stat.h>]])
+
+if test "${stat_nsec_found}" != yes; then
+	AC_MSG_WARN(Cannot determine nanosecond field of struct stat)
+fi
 
 # Checks for library functions.
 AC_FUNC_CHOWN

Modified: branches/11/include/asterisk/autoconfig.h.in
URL: http://svnview.digium.com/svn/asterisk/branches/11/include/asterisk/autoconfig.h.in?view=diff&rev=409834&r1=409833&r2=409834
==============================================================================
--- branches/11/include/asterisk/autoconfig.h.in (original)
+++ branches/11/include/asterisk/autoconfig.h.in Wed Mar  5 10:55:52 2014
@@ -865,6 +865,15 @@
 
 /* Define to 1 if `st_blksize' is a member of `struct stat'. */
 #undef HAVE_STRUCT_STAT_ST_BLKSIZE
+
+/* Define to 1 if `st_mtim' is a member of `struct stat'. */
+#undef HAVE_STRUCT_STAT_ST_MTIM
+
+/* Define to 1 if `st_mtimensec' is a member of `struct stat'. */
+#undef HAVE_STRUCT_STAT_ST_MTIMENSEC
+
+/* Define to 1 if `st_mtimespec' is a member of `struct stat'. */
+#undef HAVE_STRUCT_STAT_ST_MTIMESPEC
 
 /* Define to 1 if `cr_uid' is a member of `struct ucred'. */
 #undef HAVE_STRUCT_UCRED_CR_UID

Modified: branches/11/main/config.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/config.c?view=diff&rev=409834&r1=409833&r2=409834
==============================================================================
--- branches/11/main/config.c (original)
+++ branches/11/main/config.c Wed Mar  5 10:55:52 2014
@@ -1212,10 +1212,14 @@
 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;
+#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 = statbuf->st_mtimensec;
+	cfmtime->stat_mtime_nsec = 0;
 #endif
 	cfmtime->stat_mtime = statbuf->st_mtime;
 }




More information about the asterisk-commits mailing list