git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* USE_NSEC bug?
@ 2013-03-20  6:36 Andrew Rodland
  2013-03-20  7:53 ` Jeff King
  0 siblings, 1 reply; 9+ messages in thread
From: Andrew Rodland @ 2013-03-20  6:36 UTC (permalink / raw)
  To: git

While investigating this StackOverflow question:
http://stackoverflow.com/questions/15516168/how-to-cross-compile-git-for-arm
I found that fetch-pack.c uses ST_MTIME_NSEC outside of the protection
of #ifdef USE_NSEC. This results in a broken build if
!defined(USE_NSEC) && !defined(NO_NSEC) and the target system doesn't
happen to be recent glibc.

I'm not sure where to pin the bug exactly — on fetch-pack.c, on
git-compat-util.h, on configure for not seeing if one of those fields
actually exists and setting NO_NSEC otherwise, or elsewhere, but I
would be tempted to fix it in one of the two below ways, which should
always be foolproof when !defined(USE_NSEC). That seems right to me,
since USE_NSEC is an experimental-ish feature.

Please Cc any replies as I'm not subscribed.

Way one (smaller diff for an uglier result):

--

diff --git a/git-compat-util.h b/git-compat-util.h
index 90e0372..222caaa 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -638,10 +638,13 @@ void git_qsort(void *base, size_t nmemb, size_t size,
 # define FORCE_DIR_SET_GID 0
 #endif

 #ifdef NO_NSEC
 #undef USE_NSEC
+#endif
+
+#ifndef USE_NSEC
 #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))

--

Way two (bigger diff for a prettier result):

diff --git a/git-compat-util.h b/git-compat-util.h
index 90e0372..0a15b1a 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -638,20 +638,23 @@ void git_qsort(void *base, size_t nmemb, size_t size,
 # define FORCE_DIR_SET_GID 0
 #endif

 #ifdef NO_NSEC
 #undef USE_NSEC
-#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
+
+#ifdef USE_NSEC
+# 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
+#else /* !USE_NSEC */
+# define ST_CTIME_NSEC(st) 0
+# define ST_MTIME_NSEC(st) 0
 #endif

 #ifdef UNRELIABLE_FSTAT
 #define fstat_is_reliable() 0
 #else

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-03-20 19:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-20  6:36 USE_NSEC bug? Andrew Rodland
2013-03-20  7:53 ` Jeff King
2013-03-20 17:04   ` Junio C Hamano
2013-03-20 17:09     ` Jeff King
2013-03-20 17:31       ` Junio C Hamano
2013-03-20 18:22         ` Andrew Rodland
2013-03-20 18:30           ` Jeff King
2013-03-20 18:52             ` Junio C Hamano
2013-03-20 19:00               ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).