[tz] [PROPOSED PATCH 2/2] Allow -Dtime_tz=... libs alongside standard libs
Paul Eggert
eggert at cs.ucla.edu
Wed Mar 11 03:55:53 UTC 2015
Allow libraries built with -Dtime_tz=... to be used in executables
that also use standard-library time_t and libraries.
(Problem reported by Bradley White.)
* NEWS: Document this.
* private.h (localtime_rz, mktime_rz, posix2time_z, time2posix_z)
(tzalloc, tzfree, tzset, tzsetwall) [time_tz]: Define to
tz_localtime_rz etc., so that these functions can be used in the
same executable as standard functions with standard time_t.
(tzset, tzsetwall) [time_tz]: Declare, so that the tz_-prefixed
version ins declared.
---
NEWS | 4 +++-
private.h | 19 ++++++++++++++++++-
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/NEWS b/NEWS
index 89b5349..47f707b 100644
--- a/NEWS
+++ b/NEWS
@@ -34,7 +34,9 @@ Unreleased, experimental changes
Fix integer overflow bug in reference 'mktime' implementation.
(Problem reported by Jörg Richter.)
- Allow -Dtime_tz=time_t compilations. (Problem reported by Bradley White.)
+ Allow -Dtime_tz=time_t compilations, and allow -Dtime_tz=... libraries
+ to be used in the same executable as standard-library time_t functions.
+ (Problems reported by Bradley White.)
Changes affecting commentary
diff --git a/private.h b/private.h
index b9429ae..de9c13e 100644
--- a/private.h
+++ b/private.h
@@ -324,16 +324,24 @@ typedef time_tz tz_time_t;
# define localtime tz_localtime
# undef localtime_r
# define localtime_r tz_localtime_r
+# undef localtime_rz
+# define localtime_rz tz_localtime_rz
# undef mktime
# define mktime tz_mktime
+# undef mktime_z
+# define mktime_z tz_mktime_z
# undef offtime
# define offtime tz_offtime
# undef posix2time
# define posix2time tz_posix2time
+# undef posix2time_z
+# define posix2time_z tz_posix2time_z
# undef time
# define time tz_time
# undef time2posix
# define time2posix tz_time2posix
+# undef time2posix_z
+# define time2posix_z tz_time2posix_z
# undef time_t
# define time_t tz_time_t
# undef timegm
@@ -342,6 +350,14 @@ typedef time_tz tz_time_t;
# define timelocal tz_timelocal
# undef timeoff
# define timeoff tz_timeoff
+# undef tzalloc
+# define tzalloc tz_tzalloc
+# undef tzfree
+# define tzfree tz_tzfree
+# undef tzset
+# define tzset tz_tzset
+# undef tzsetwall
+# define tzsetwall tz_tzsetwall
char *ctime(time_t const *);
char *ctime_r(time_t const *, char *);
@@ -352,6 +368,7 @@ struct tm *localtime(time_t const *);
struct tm *localtime_r(time_t const *restrict, struct tm *restrict);
time_t mktime(struct tm *);
time_t time(time_t *);
+void tzset(void);
#endif
/*
@@ -370,7 +387,7 @@ extern char * asctime_r(struct tm const *restrict, char *restrict);
*/
#ifdef STD_INSPIRED
-# if !defined tzsetwall
+# if !defined tzsetwall || defined time_tz
void tzsetwall(void);
# endif
# if !defined offtime || defined time_tz
--
2.1.0
More information about the tz
mailing list