[tz] [PROPOSED] Rename asctime symbols if required in private.h

Roland Young ryoung.itrs at gmail.com
Tue Oct 15 11:24:04 UTC 2019


When libtz.a is built using -DRESERVE_STD_EXT_IDS (but not in other cases where
TZ_TIME_T is defined) the asctime and asctime_r symbols need renaming.

Note: if my assumption about "other cases" is wrong, the preprocessor guards in
this patch should be omitted.
---
 private.h | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/private.h b/private.h
index 1ead147..112a58c 100644
--- a/private.h
+++ b/private.h
@@ -409,6 +409,12 @@ static time_t sys_time(time_t *x) { return time(x); }

 typedef time_tz tz_time_t;

+#if RESERVE_STD_EXT_IDS
+# undef  asctime
+# define asctime tz_asctime
+# undef  asctime_r
+# define asctime_r tz_asctime_r
+#endif
 # undef  ctime
 # define ctime tz_ctime
 # undef  ctime_r
@@ -478,6 +484,10 @@ typedef time_tz tz_time_t;
 #  define altzone tz_altzone
 # endif

+#if RESERVE_STD_EXT_IDS
+char *asctime(struct tm const *timeptr);
+char *asctime_r(struct tm const *restrict, char *restrict);
+#endif
 char *ctime(time_t const *);
 char *ctime_r(time_t const *, char *);
 double difftime(time_t, time_t) ATTRIBUTE_CONST;
@@ -494,7 +504,7 @@ 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
+#endif  /* defined TZ_TIME_T */

 #if !HAVE_DECL_ASCTIME_R && !defined asctime_r
 extern char *asctime_r(struct tm const *restrict, char *restrict);
-- 
2.7.4


More information about the tz mailing list