Enable high-resolution timestamps for Darwin (Mac OSX)
authorPaul Smith <psmith@gnu.org>
Sun, 13 Nov 2011 23:39:54 +0000 (23:39 +0000)
committerPaul Smith <psmith@gnu.org>
Sun, 13 Nov 2011 23:39:54 +0000 (23:39 +0000)
Patch provided by Troy Runkel <Troy.Runkel@mathworks.com>

ChangeLog
acinclude.m4
filedef.h

index adcab64..52724d1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-11-13  Paul Smith  <psmith@gnu.org>
+
+       * acinclude.m4 (AC_STRUCT_ST_MTIM_NSEC): Add support for Darwin.
+       Patch provided by Troy Runkel <Troy.Runkel@mathworks.com>
+       * filedef.h (FILE_TIMESTAMP_STAT_MODTIME): Ditto.
+
 2011-09-18  Paul Smith  <psmith@gnu.org>
 
        * main.c (main): If we're re-exec'ing and we're the master make,
index 0e56441..6d273e5 100644 (file)
@@ -100,22 +100,24 @@ changequote([,])dnl
 
 dnl ---------------------------------------------------------------------------
 dnl From Paul Eggert <eggert@twinsun.com>
+dnl Update for Darwin by Troy Runkel <Troy.Runkel@mathworks.com>
 
 AC_DEFUN([AC_STRUCT_ST_MTIM_NSEC],
- [AC_CACHE_CHECK([for nanoseconds field of struct stat.st_mtim],
+ [AC_CACHE_CHECK([for nanoseconds field of struct stat],
    ac_cv_struct_st_mtim_nsec,
    [ac_save_CPPFLAGS="$CPPFLAGS"
     ac_cv_struct_st_mtim_nsec=no
-    # tv_nsec -- the usual case
-    # _tv_nsec -- Solaris 2.6, if
+    # st_mtim.tv_nsec -- the usual case
+    # st_mtim._tv_nsec -- Solaris 2.6, if
     #  (defined _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED == 1
     #   && !defined __EXTENSIONS__)
-    # st__tim.tv_nsec -- UnixWare 2.1.2
-    for ac_val in tv_nsec _tv_nsec st__tim.tv_nsec; do
+    # st_mtim.st__tim.tv_nsec -- UnixWare 2.1.2
+    # st_mtimespec.tv_nsec -- Darwin (Mac OSX)
+    for ac_val in st_mtim.tv_nsec st_mtim._tv_nsec st_mtim.st__tim.tv_nsec st_mtimespec.tv_nsec; do
       CPPFLAGS="$ac_save_CPPFLAGS -DST_MTIM_NSEC=$ac_val"
       AC_TRY_COMPILE([#include <sys/types.h>
 #include <sys/stat.h>
-       ], [struct stat s; s.st_mtim.ST_MTIM_NSEC;],
+       ], [struct stat s; s.ST_MTIM_NSEC;],
         [ac_cv_struct_st_mtim_nsec=$ac_val; break])
     done
     CPPFLAGS="$ac_save_CPPFLAGS"
index 98e3f49..173e753 100644 (file)
--- a/filedef.h
+++ b/filedef.h
@@ -118,7 +118,7 @@ void print_file_data_base (void);
 
 #if FILE_TIMESTAMP_HI_RES
 # define FILE_TIMESTAMP_STAT_MODTIME(fname, st) \
-    file_timestamp_cons (fname, (st).st_mtime, (st).st_mtim.ST_MTIM_NSEC)
+    file_timestamp_cons (fname, (st).st_mtime, (st).ST_MTIM_NSEC)
 #else
 # define FILE_TIMESTAMP_STAT_MODTIME(fname, st) \
     file_timestamp_cons (fname, (st).st_mtime, 0)