Enable high-resolution timestamps for Darwin (Mac OSX)

Patch provided by Troy Runkel <Troy.Runkel@mathworks.com>
This commit is contained in:
Paul Smith 2011-11-13 23:39:54 +00:00
parent c7d07fd0b5
commit bfc3e1ca7c
3 changed files with 15 additions and 7 deletions

View file

@ -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,

View 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"

View file

@ -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)