git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Create USE_ST_TIMESPEC and turn it on for Darwin

From
Brian Gernhardt <benji@silverinsanity.com>
Date
Mar 8, 2009, 20:04 UTC
Message-ID
<1236542668-83333-1-git-send-email-benji@silverinsanity.com>

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>
---
 This is on top of "next".
 Now time to go debug a Bus Error in git-grep that made this hard to find.
 Makefile          |    7 +++++++
 git-compat-util.h |    5 +++++
 2 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/Makefile b/Makefile
index 9a23aa5..4bdaad7 100644
--- a/Makefile
+++ b/Makefile
@@ -126,6 +126,9 @@ all::
 # randomly break unless your underlying filesystem supports those sub-second
 # times (my ext3 doesn't).
 #
+# Define USE_ST_TIMESPEC if your "struct stat" uses "st_ctimespec" instead of
+# "st_ctim"
+#
 # Define NO_NSEC if your "struct stat" does not have "st_ctim.tv_nsec"
 # available.  This automatically turns USE_NSEC off.
 #
@@ -660,6 +663,7 @@ ifeq ($(uname_S),Darwin)
 	endif
 	NO_MEMMEM = YesPlease
 	THREADED_DELTA_SEARCH = YesPlease
+	USE_ST_TIMESPEC = YesPlease
 endif
 ifeq ($(uname_S),SunOS)
 	NEEDS_SOCKET = YesPlease
@@ -925,6 +929,9 @@ endif
 ifdef NO_ST_BLOCKS_IN_STRUCT_STAT
 	BASIC_CFLAGS += -DNO_ST_BLOCKS_IN_STRUCT_STAT
 endif
+ifdef USE_ST_TIMESPEC
+	BASIC_CFLAGS += -DUSE_ST_TIMESPEC
+endif
 ifdef NO_NSEC
 	BASIC_CFLAGS += -DNO_NSEC
 endif
diff --git a/git-compat-util.h b/git-compat-util.h
index 83d8389..1906253 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -393,8 +393,13 @@ void git_qsort(void *base, size_t nmemb, size_t size,
 #define ST_CTIME_NSEC(st) 0
 #define ST_MTIME_NSEC(st) 0
 #else
+#ifdef USE_ST_TIMESPEC
+#define ST_CTIME_NSEC(st) ((unsigned int)((st).st_ctimespec.tv_nsec))
+#define ST_MTIME_NSEC(st) ((unsigned int)((st).st_mtimespec.tv_nsec))
+#else
 #define ST_CTIME_NSEC(st) ((unsigned int)((st).st_ctim.tv_nsec))
 #define ST_MTIME_NSEC(st) ((unsigned int)((st).st_mtim.tv_nsec))
 #endif
+#endif
 
 #endif
-- 
1.6.2.221.g2411c.dirty
Next: Junio C Hamano
Message 1 of 4 in “Create USE_ST_TIMESPEC and turn it on for Darwin”
  1. Create USE_ST_TIMESPEC and turn it on for DarwinBrian Gernhardt, Mar 8, 2009
  2. Junio C HamanoMar 8, 2009
  3. Brian GernhardtMar 8, 2009
  4. Makefile: Set compiler switch for USE_NSECBrian Gernhardt, Mar 8, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.