@matheusbsbs / matheus-bagliano / commits / c567383b1e
Fork 0

Create USE_ST_TIMESPEC and turn it on for Darwin

Not all OSes use st_ctim and st_mtim in their struct stat. In particular, it appears that OS X uses st_*timespec instead. So add a Makefile variable and #define called USE_ST_TIMESPEC to switch the USE_NSEC defines to use st_*timespec. This also turns it on by default for OS X (Darwin) machines. Likely this is a sane default for other BSD kernels as well, but I don't have any to test that assumption on. Signed-off-by: Brian Gernhardt <benji@silverinsanity.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brian Gernhardt committed Mar 8, 2009 at 16:04 UTC c567383b1e3205c895b371d42a39fbdf131032ba
2 files changed +12
Makefile
+7
@@ -126,6 +126,9 @@ all::
126 # randomly break unless your underlying filesystem supports those sub-second
127 # times (my ext3 doesn't).
128 #
129 +# Define USE_ST_TIMESPEC if your "struct stat" uses "st_ctimespec" instead of
130 +# "st_ctim"
131 +#
132 # Define NO_NSEC if your "struct stat" does not have "st_ctim.tv_nsec"
133 # available. This automatically turns USE_NSEC off.
134 #
@@ -663,6 +666,7 @@ ifeq ($(uname_S),Darwin)
666 endif
667 NO_MEMMEM = YesPlease
668 THREADED_DELTA_SEARCH = YesPlease
669 + USE_ST_TIMESPEC = YesPlease
670 endif
671 ifeq ($(uname_S),SunOS)
672 NEEDS_SOCKET = YesPlease
@@ -928,6 +932,9 @@ endif
932 ifdef NO_ST_BLOCKS_IN_STRUCT_STAT
933 BASIC_CFLAGS += -DNO_ST_BLOCKS_IN_STRUCT_STAT
934 endif
935 +ifdef USE_ST_TIMESPEC
936 + BASIC_CFLAGS += -DUSE_ST_TIMESPEC
937 +endif
938 ifdef NO_NSEC
939 BASIC_CFLAGS += -DNO_NSEC
940 endif
git-compat-util.h
+5
@@ -389,8 +389,13 @@ void git_qsort(void *base, size_t nmemb, size_t size,
389 #define ST_CTIME_NSEC(st) 0
390 #define ST_MTIME_NSEC(st) 0
391 #else
392 +#ifdef USE_ST_TIMESPEC
393 +#define ST_CTIME_NSEC(st) ((unsigned int)((st).st_ctimespec.tv_nsec))
394 +#define ST_MTIME_NSEC(st) ((unsigned int)((st).st_mtimespec.tv_nsec))
395 +#else
396 #define ST_CTIME_NSEC(st) ((unsigned int)((st).st_ctim.tv_nsec))
397 #define ST_MTIME_NSEC(st) ((unsigned int)((st).st_mtim.tv_nsec))
398 #endif
399 +#endif
400
401 #endif