[tz] [PATCH] Remove lint when debugging by compiling with -Dtime_tz='whatever'.

Paul Eggert eggert at cs.ucla.edu
Sat Aug 16 08:58:48 UTC 2014


* localtime.c (LOCALTIME_IMPLEMENTATION): New macro.
(time) [time_tz]: Move here from private.h, and make external.
* private.h (sys_time) [time_tz]: Define only if
LOCALTIME_IMPLEMENTATION, so that the code doesn't define an unused
static function sys_time that the compiler might complain about.
(time) [time_tz]: Move to localtime.c.
---
 localtime.c | 18 ++++++++++++++++++
 private.h   | 12 +++---------
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/localtime.c b/localtime.c
index 840fa21..551b5a2 100644
--- a/localtime.c
+++ b/localtime.c
@@ -10,7 +10,9 @@
 
 /*LINTLIBRARY*/
 
+#define LOCALTIME_IMPLEMENTATION
 #include "private.h"
+
 #include "tzfile.h"
 #include "fcntl.h"
 
@@ -2022,3 +2024,19 @@ posix2time(time_t t)
 }
 
 #endif /* defined STD_INSPIRED */
+
+#ifdef time_tz
+
+/* Convert from the underlying system's time_t to the ersatz time_tz,
+   which is called 'time_t' in this file.  */
+
+time_t
+time(time_t *p)
+{
+  time_t r = sys_time(0);
+  if (p)
+    *p = r;
+  return r;
+}
+
+#endif
diff --git a/private.h b/private.h
index c778035..6d3e6aa 100644
--- a/private.h
+++ b/private.h
@@ -248,7 +248,9 @@ typedef unsigned long uintmax_t;
 ** typical platforms.
 */
 #ifdef time_tz
+# ifdef LOCALTIME_IMPLEMENTATION
 static time_t sys_time(time_t *x) { return time(x); }
+# endif
 
 # undef  ctime
 # define ctime tz_ctime
@@ -289,15 +291,7 @@ struct tm *gmtime_r(time_t const *restrict, struct tm *restrict);
 struct tm *localtime(time_t const *);
 struct tm *localtime_r(time_t const *restrict, struct tm *restrict);
 time_t mktime(struct tm *);
-
-static time_t
-time(time_t *p)
-{
-	time_t r = sys_time(0);
-	if (p)
-		*p = r;
-	return r;
-}
+time_t time(time_t *);
 #endif
 
 /*
-- 
1.9.1



More information about the tz mailing list