[tz] [PROPOSED PATCH 2/3] Port to NetBSD when using GCC_DEBUG_FLAGS or defining time_tz.
Paul Eggert
eggert at cs.ucla.edu
Sat Aug 16 08:22:08 UTC 2014
Alan Barrett wrote:
> That should be tz_posix2time, not tz_time2posix.
Thanks, fixed in the obvious way with the attached revised patch to the
tz code.
> More generally, it would be nice to know what went wrong on NetBSD.
The same thing that goes wrong on any platform if one wants to
portability-test the tz code by compiling it with -Dtime_tz='uintmax_t'
(say): the prototypes in <time.h> which use time_t='long' (say) conflict
with with the altered prototypes localtime.c wants to use internally
which use time_t='uintmax_t'. Unlike most other platforms, recent
versions of NetBSD declare a posix2time prototype in <time.h>, so NetBSD
needs a workaround for the posix2time clash even though most platforms
don't.
The motivation for all this is to add support for NetBSD-style
localtime_rz, mktime_z, tzalloc, and tzfree, along the lines suggested
by Christos Zoulas in
<http://mm.icann.org/pipermail/tz/2010-September/016435.html>. These
functions have been added to NetBSD. I've found some problems with the
NetBSD API and plan to propose a simpler API here soon, which is binary
compatible with a subset of NetBSD's. If it works out maybe we can get
it into POSIX.
I'll CC: this to Christos to give him a heads-up.
-------------- next part --------------
From d933df7b626158438c396af3d62317862efc419f Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert at cs.ucla.edu>
Date: Thu, 14 Aug 2014 21:32:56 -0700
Subject: [PATCH 1/3] Port to NetBSD when using GCC_DEBUG_FLAGS or defining
time_tz.
* private.h (offtime, posix2time, time2posix, timeoff) [time_tz]:
Define tz_* replacements for these functions too.
(asctime_r): Move to after time_tz definitions, to keep like
declarations together.
(tzsetwall) [STD_INSPIRED]: Declare if not defined.
(offtime, timeoff, time2posix, posix2time) [STD_INSPIRED]:
Declare if not defined, or if time_tz is defined.
* NEWS: Document this.
---
NEWS | 3 +++
private.h | 51 +++++++++++++++++++++++++++++++++++++++++----------
2 files changed, 44 insertions(+), 10 deletions(-)
diff --git a/NEWS b/NEWS
index a8218f1..6affa5b 100644
--- a/NEWS
+++ b/NEWS
@@ -39,6 +39,9 @@ Unreleased, experimental changes
tzselect -c now uses a hybrid distance measure that works better
in Africa. (Thanks to Alan Barrett for noting the problem.)
+ The C source code now ports to NetBSD when GCC_DEBUG_FLAGS is used,
+ or when time_tz is defined.
+
When HAVE_UTMPX_H is set the 'date' command now builds on systems
whose <utmpx.h> file does not define WTMPX_FILE, and when setting
the date it updates the wtmpx file if _PATH_WTMPX is defined.
diff --git a/private.h b/private.h
index ad22b9a..bee0a90 100644
--- a/private.h
+++ b/private.h
@@ -237,16 +237,6 @@ typedef unsigned long uintmax_t;
*/
/*
-** Some time.h implementations don't declare asctime_r.
-** Others might define it as a macro.
-** Fix the former without affecting the latter.
-*/
-
-#ifndef asctime_r
-extern char * asctime_r(struct tm const *, char *);
-#endif
-
-/*
** Compile with -Dtime_tz=T to build the tz package with a private
** time_t type equivalent to T rather than the system-supplied time_t.
** This debugging feature can test unusual design decisions
@@ -272,10 +262,18 @@ static time_t sys_time(time_t *x) { return time(x); }
# define localtime_r tz_localtime_r
# undef mktime
# define mktime tz_mktime
+# undef offtime
+# define offtime tz_offtime
+# undef posix2time
+# define posix2time tz_posix2time
# undef time
# define time tz_time
+# undef time2posix
+# define time2posix tz_time2posix
# undef time_t
# define time_t tz_time_t
+# undef timeoff
+# define timeoff tz_timeoff
typedef time_tz time_t;
@@ -299,6 +297,39 @@ time(time_t *p)
#endif
/*
+** Some time.h implementations don't declare asctime_r.
+** Others might define it as a macro.
+** Fix the former without affecting the latter.
+*/
+
+#ifndef asctime_r
+extern char * asctime_r(struct tm const *, char *);
+#endif
+
+/*
+** The STD_INSPIRED functions are similar, but most also need
+** declarations if time_tz is defined.
+*/
+
+#ifdef STD_INSPIRED
+# if !defined tzsetwall
+void tzsetwall(void);
+# endif
+# if !defined offtime || defined time_tz
+struct tm *offtime(time_t const *, long);
+# endif
+# if !defined timeoff || defined time_tz
+time_t timeoff(struct tm *, long);
+# endif
+# if !defined time2posix || defined time_tz
+time_t time2posix(time_t);
+# endif
+# if !defined posix2time || defined time_tz
+time_t posix2time(time_t);
+# endif
+#endif
+
+/*
** Private function declarations.
*/
--
1.9.1
More information about the tz
mailing list