summaryrefslogtreecommitdiffstats
path: root/gl/time.in.h
diff options
context:
space:
mode:
Diffstat (limited to 'gl/time.in.h')
-rw-r--r--gl/time.in.h141
1 files changed, 98 insertions, 43 deletions
diff --git a/gl/time.in.h b/gl/time.in.h
index df99c8ab..5bbccf76 100644
--- a/gl/time.in.h
+++ b/gl/time.in.h
@@ -1,6 +1,6 @@
1/* A more-standard <time.h>. 1/* A more-standard <time.h>.
2 2
3 Copyright (C) 2007-2024 Free Software Foundation, Inc. 3 Copyright (C) 2007-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -122,6 +122,23 @@ struct __time_t_must_be_integral {
122# endif 122# endif
123# endif 123# endif
124 124
125# if @GNULIB_TZNAME@
126/* tzname[0..1]: Abbreviated time zone names, set by the tzset() function. */
127# if NEED_DECL_TZNAME
128extern
129# ifdef __cplusplus
130 "C"
131# endif
132 char *tzname[];
133# endif
134# if defined _WIN32 && !defined __CYGWIN__
135/* On native Windows, map 'tzname' to '_tzname' etc., so that -loldnames is not
136 required. */
137# undef tzname
138# define tzname _tzname
139# endif
140# endif
141
125/* Set *TS to the current time, and return BASE. 142/* Set *TS to the current time, and return BASE.
126 Upon failure, return 0. */ 143 Upon failure, return 0. */
127# if @GNULIB_TIMESPEC_GET@ 144# if @GNULIB_TIMESPEC_GET@
@@ -130,12 +147,12 @@ struct __time_t_must_be_integral {
130# undef timespec_get 147# undef timespec_get
131# define timespec_get rpl_timespec_get 148# define timespec_get rpl_timespec_get
132# endif 149# endif
133_GL_FUNCDECL_RPL (timespec_get, int, (struct timespec *ts, int base) 150_GL_FUNCDECL_RPL (timespec_get, int, (struct timespec *ts, int base),
134 _GL_ARG_NONNULL ((1))); 151 _GL_ARG_NONNULL ((1)));
135_GL_CXXALIAS_RPL (timespec_get, int, (struct timespec *ts, int base)); 152_GL_CXXALIAS_RPL (timespec_get, int, (struct timespec *ts, int base));
136# else 153# else
137# if !@HAVE_TIMESPEC_GET@ 154# if !@HAVE_TIMESPEC_GET@
138_GL_FUNCDECL_SYS (timespec_get, int, (struct timespec *ts, int base) 155_GL_FUNCDECL_SYS (timespec_get, int, (struct timespec *ts, int base),
139 _GL_ARG_NONNULL ((1))); 156 _GL_ARG_NONNULL ((1)));
140# endif 157# endif
141_GL_CXXALIAS_SYS (timespec_get, int, (struct timespec *ts, int base)); 158_GL_CXXALIAS_SYS (timespec_get, int, (struct timespec *ts, int base));
@@ -144,7 +161,6 @@ _GL_CXXALIAS_SYS (timespec_get, int, (struct timespec *ts, int base));
144_GL_CXXALIASWARN (timespec_get); 161_GL_CXXALIASWARN (timespec_get);
145# endif 162# endif
146# elif defined GNULIB_POSIXCHECK 163# elif defined GNULIB_POSIXCHECK
147# undef timespec_get
148# if HAVE_RAW_DECL_TIMESPEC_GET 164# if HAVE_RAW_DECL_TIMESPEC_GET
149_GL_WARN_ON_USE (timespec_get, "timespec_get is unportable - " 165_GL_WARN_ON_USE (timespec_get, "timespec_get is unportable - "
150 "use gnulib module timespec_get for portability"); 166 "use gnulib module timespec_get for portability");
@@ -159,19 +175,20 @@ _GL_WARN_ON_USE (timespec_get, "timespec_get is unportable - "
159# undef timespec_getres 175# undef timespec_getres
160# define timespec_getres rpl_timespec_getres 176# define timespec_getres rpl_timespec_getres
161# endif 177# endif
162_GL_FUNCDECL_RPL (timespec_getres, int, (struct timespec *ts, int base) 178_GL_FUNCDECL_RPL (timespec_getres, int, (struct timespec *ts, int base),
163 _GL_ARG_NONNULL ((1))); 179 _GL_ARG_NONNULL ((1)));
164_GL_CXXALIAS_RPL (timespec_getres, int, (struct timespec *ts, int base)); 180_GL_CXXALIAS_RPL (timespec_getres, int, (struct timespec *ts, int base));
165# else 181# else
166# if !@HAVE_TIMESPEC_GETRES@ 182# if !@HAVE_TIMESPEC_GETRES@
167_GL_FUNCDECL_SYS (timespec_getres, int, (struct timespec *ts, int base) 183_GL_FUNCDECL_SYS (timespec_getres, int, (struct timespec *ts, int base),
168 _GL_ARG_NONNULL ((1))); 184 _GL_ARG_NONNULL ((1)));
169# endif 185# endif
170_GL_CXXALIAS_SYS (timespec_getres, int, (struct timespec *ts, int base)); 186_GL_CXXALIAS_SYS (timespec_getres, int, (struct timespec *ts, int base));
171# endif 187# endif
188# if __GLIBC__ >= 2
172_GL_CXXALIASWARN (timespec_getres); 189_GL_CXXALIASWARN (timespec_getres);
190# endif
173# elif defined GNULIB_POSIXCHECK 191# elif defined GNULIB_POSIXCHECK
174# undef timespec_getres
175# if HAVE_RAW_DECL_TIMESPEC_GETRES 192# if HAVE_RAW_DECL_TIMESPEC_GETRES
176_GL_WARN_ON_USE (timespec_getres, "timespec_getres is unportable - " 193_GL_WARN_ON_USE (timespec_getres, "timespec_getres is unportable - "
177 "use gnulib module timespec_getres for portability"); 194 "use gnulib module timespec_getres for portability");
@@ -184,7 +201,7 @@ _GL_WARN_ON_USE (timespec_getres, "timespec_getres is unportable - "
184# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 201# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
185# define time rpl_time 202# define time rpl_time
186# endif 203# endif
187_GL_FUNCDECL_RPL (time, time_t, (time_t *__tp)); 204_GL_FUNCDECL_RPL (time, time_t, (time_t *__tp), );
188_GL_CXXALIAS_RPL (time, time_t, (time_t *__tp)); 205_GL_CXXALIAS_RPL (time, time_t, (time_t *__tp));
189# else 206# else
190_GL_CXXALIAS_SYS (time, time_t, (time_t *__tp)); 207_GL_CXXALIAS_SYS (time, time_t, (time_t *__tp));
@@ -193,7 +210,6 @@ _GL_CXXALIAS_SYS (time, time_t, (time_t *__tp));
193_GL_CXXALIASWARN (time); 210_GL_CXXALIASWARN (time);
194# endif 211# endif
195# elif defined GNULIB_POSIXCHECK 212# elif defined GNULIB_POSIXCHECK
196# undef time
197# if HAVE_RAW_DECL_TIME 213# if HAVE_RAW_DECL_TIME
198_GL_WARN_ON_USE (time, "time has consistency problems - " 214_GL_WARN_ON_USE (time, "time has consistency problems - "
199 "use gnulib module time for portability"); 215 "use gnulib module time for portability");
@@ -209,14 +225,14 @@ _GL_WARN_ON_USE (time, "time has consistency problems - "
209# define nanosleep rpl_nanosleep 225# define nanosleep rpl_nanosleep
210# endif 226# endif
211_GL_FUNCDECL_RPL (nanosleep, int, 227_GL_FUNCDECL_RPL (nanosleep, int,
212 (struct timespec const *__rqtp, struct timespec *__rmtp) 228 (struct timespec const *__rqtp, struct timespec *__rmtp),
213 _GL_ARG_NONNULL ((1))); 229 _GL_ARG_NONNULL ((1)));
214_GL_CXXALIAS_RPL (nanosleep, int, 230_GL_CXXALIAS_RPL (nanosleep, int,
215 (struct timespec const *__rqtp, struct timespec *__rmtp)); 231 (struct timespec const *__rqtp, struct timespec *__rmtp));
216# else 232# else
217# if ! @HAVE_NANOSLEEP@ 233# if ! @HAVE_NANOSLEEP@
218_GL_FUNCDECL_SYS (nanosleep, int, 234_GL_FUNCDECL_SYS (nanosleep, int,
219 (struct timespec const *__rqtp, struct timespec *__rmtp) 235 (struct timespec const *__rqtp, struct timespec *__rmtp),
220 _GL_ARG_NONNULL ((1))); 236 _GL_ARG_NONNULL ((1)));
221# endif 237# endif
222_GL_CXXALIAS_SYS (nanosleep, int, 238_GL_CXXALIAS_SYS (nanosleep, int,
@@ -224,7 +240,6 @@ _GL_CXXALIAS_SYS (nanosleep, int,
224# endif 240# endif
225_GL_CXXALIASWARN (nanosleep); 241_GL_CXXALIASWARN (nanosleep);
226# elif defined GNULIB_POSIXCHECK 242# elif defined GNULIB_POSIXCHECK
227# undef nanosleep
228# if HAVE_RAW_DECL_NANOSLEEP 243# if HAVE_RAW_DECL_NANOSLEEP
229_GL_WARN_ON_USE (nanosleep, "nanosleep is unportable - " 244_GL_WARN_ON_USE (nanosleep, "nanosleep is unportable - "
230 "use gnulib module nanosleep for portability"); 245 "use gnulib module nanosleep for portability");
@@ -238,7 +253,7 @@ _GL_WARN_ON_USE (nanosleep, "nanosleep is unportable - "
238# undef tzset 253# undef tzset
239# define tzset rpl_tzset 254# define tzset rpl_tzset
240# endif 255# endif
241_GL_FUNCDECL_RPL (tzset, void, (void)); 256_GL_FUNCDECL_RPL (tzset, void, (void), );
242_GL_CXXALIAS_RPL (tzset, void, (void)); 257_GL_CXXALIAS_RPL (tzset, void, (void));
243# elif defined _WIN32 && !defined __CYGWIN__ 258# elif defined _WIN32 && !defined __CYGWIN__
244# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 259# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -265,7 +280,6 @@ _GL_CXXALIAS_SYS (tzset, void, (void));
265# endif 280# endif
266_GL_CXXALIASWARN (tzset); 281_GL_CXXALIASWARN (tzset);
267# elif defined GNULIB_POSIXCHECK 282# elif defined GNULIB_POSIXCHECK
268# undef tzset
269# if HAVE_RAW_DECL_TZSET 283# if HAVE_RAW_DECL_TZSET
270_GL_WARN_ON_USE (tzset, "tzset has portability problems - " 284_GL_WARN_ON_USE (tzset, "tzset has portability problems - "
271 "use gnulib module tzset for portability"); 285 "use gnulib module tzset for portability");
@@ -278,7 +292,7 @@ _GL_WARN_ON_USE (tzset, "tzset has portability problems - "
278# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 292# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
279# define mktime rpl_mktime 293# define mktime rpl_mktime
280# endif 294# endif
281_GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1))); 295_GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp), _GL_ARG_NONNULL ((1)));
282_GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp)); 296_GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
283# else 297# else
284_GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp)); 298_GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
@@ -287,7 +301,6 @@ _GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
287_GL_CXXALIASWARN (mktime); 301_GL_CXXALIASWARN (mktime);
288# endif 302# endif
289# elif defined GNULIB_POSIXCHECK 303# elif defined GNULIB_POSIXCHECK
290# undef mktime
291# if HAVE_RAW_DECL_MKTIME 304# if HAVE_RAW_DECL_MKTIME
292_GL_WARN_ON_USE (mktime, "mktime has portability problems - " 305_GL_WARN_ON_USE (mktime, "mktime has portability problems - "
293 "use gnulib module mktime for portability"); 306 "use gnulib module mktime for portability");
@@ -304,14 +317,14 @@ _GL_WARN_ON_USE (mktime, "mktime has portability problems - "
304# define localtime_r rpl_localtime_r 317# define localtime_r rpl_localtime_r
305# endif 318# endif
306_GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer, 319_GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
307 struct tm *restrict __result) 320 struct tm *restrict __result),
308 _GL_ARG_NONNULL ((1, 2))); 321 _GL_ARG_NONNULL ((1, 2)));
309_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer, 322_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
310 struct tm *restrict __result)); 323 struct tm *restrict __result));
311# else 324# else
312# if ! @HAVE_DECL_LOCALTIME_R@ 325# if ! @HAVE_DECL_LOCALTIME_R@
313_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer, 326_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
314 struct tm *restrict __result) 327 struct tm *restrict __result),
315 _GL_ARG_NONNULL ((1, 2))); 328 _GL_ARG_NONNULL ((1, 2)));
316# endif 329# endif
317_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer, 330_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
@@ -326,14 +339,14 @@ _GL_CXXALIASWARN (localtime_r);
326# define gmtime_r rpl_gmtime_r 339# define gmtime_r rpl_gmtime_r
327# endif 340# endif
328_GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer, 341_GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
329 struct tm *restrict __result) 342 struct tm *restrict __result),
330 _GL_ARG_NONNULL ((1, 2))); 343 _GL_ARG_NONNULL ((1, 2)));
331_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer, 344_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
332 struct tm *restrict __result)); 345 struct tm *restrict __result));
333# else 346# else
334# if ! @HAVE_DECL_LOCALTIME_R@ 347# if ! @HAVE_DECL_LOCALTIME_R@
335_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, 348_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
336 struct tm *restrict __result) 349 struct tm *restrict __result),
337 _GL_ARG_NONNULL ((1, 2))); 350 _GL_ARG_NONNULL ((1, 2)));
338# endif 351# endif
339_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, 352_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
@@ -343,12 +356,10 @@ _GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
343_GL_CXXALIASWARN (gmtime_r); 356_GL_CXXALIASWARN (gmtime_r);
344# endif 357# endif
345# elif defined GNULIB_POSIXCHECK 358# elif defined GNULIB_POSIXCHECK
346# undef localtime_r
347# if HAVE_RAW_DECL_LOCALTIME_R 359# if HAVE_RAW_DECL_LOCALTIME_R
348_GL_WARN_ON_USE (localtime_r, "localtime_r is unportable - " 360_GL_WARN_ON_USE (localtime_r, "localtime_r is unportable - "
349 "use gnulib module time_r for portability"); 361 "use gnulib module time_r for portability");
350# endif 362# endif
351# undef gmtime_r
352# if HAVE_RAW_DECL_GMTIME_R 363# if HAVE_RAW_DECL_GMTIME_R
353_GL_WARN_ON_USE (gmtime_r, "gmtime_r is unportable - " 364_GL_WARN_ON_USE (gmtime_r, "gmtime_r is unportable - "
354 "use gnulib module time_r for portability"); 365 "use gnulib module time_r for portability");
@@ -364,7 +375,7 @@ _GL_WARN_ON_USE (gmtime_r, "gmtime_r is unportable - "
364# undef localtime 375# undef localtime
365# define localtime rpl_localtime 376# define localtime rpl_localtime
366# endif 377# endif
367_GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer) 378_GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer),
368 _GL_ARG_NONNULL ((1))); 379 _GL_ARG_NONNULL ((1)));
369_GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer)); 380_GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer));
370# else 381# else
@@ -374,7 +385,6 @@ _GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer));
374_GL_CXXALIASWARN (localtime); 385_GL_CXXALIASWARN (localtime);
375# endif 386# endif
376# elif defined GNULIB_POSIXCHECK 387# elif defined GNULIB_POSIXCHECK
377# undef localtime
378# if HAVE_RAW_DECL_LOCALTIME 388# if HAVE_RAW_DECL_LOCALTIME
379_GL_WARN_ON_USE (localtime, "localtime has portability problems - " 389_GL_WARN_ON_USE (localtime, "localtime has portability problems - "
380 "use gnulib module localtime for portability"); 390 "use gnulib module localtime for portability");
@@ -387,7 +397,7 @@ _GL_WARN_ON_USE (localtime, "localtime has portability problems - "
387# undef gmtime 397# undef gmtime
388# define gmtime rpl_gmtime 398# define gmtime rpl_gmtime
389# endif 399# endif
390_GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer) 400_GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer),
391 _GL_ARG_NONNULL ((1))); 401 _GL_ARG_NONNULL ((1)));
392_GL_CXXALIAS_RPL (gmtime, struct tm *, (time_t const *__timer)); 402_GL_CXXALIAS_RPL (gmtime, struct tm *, (time_t const *__timer));
393# else 403# else
@@ -403,7 +413,7 @@ _GL_CXXALIASWARN (gmtime);
403# if ! @HAVE_STRPTIME@ 413# if ! @HAVE_STRPTIME@
404_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf, 414_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
405 char const *restrict __format, 415 char const *restrict __format,
406 struct tm *restrict __tm) 416 struct tm *restrict __tm),
407 _GL_ARG_NONNULL ((1, 2, 3))); 417 _GL_ARG_NONNULL ((1, 2, 3)));
408# endif 418# endif
409_GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf, 419_GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
@@ -411,7 +421,6 @@ _GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
411 struct tm *restrict __tm)); 421 struct tm *restrict __tm));
412_GL_CXXALIASWARN (strptime); 422_GL_CXXALIASWARN (strptime);
413# elif defined GNULIB_POSIXCHECK 423# elif defined GNULIB_POSIXCHECK
414# undef strptime
415# if HAVE_RAW_DECL_STRPTIME 424# if HAVE_RAW_DECL_STRPTIME
416_GL_WARN_ON_USE (strptime, "strptime is unportable - " 425_GL_WARN_ON_USE (strptime, "strptime is unportable - "
417 "use gnulib module strptime for portability"); 426 "use gnulib module strptime for portability");
@@ -428,7 +437,7 @@ _GL_WARN_ON_USE (strptime, "strptime is unportable - "
428# ifndef __cplusplus 437# ifndef __cplusplus
429_GL_ATTRIBUTE_DEPRECATED 438_GL_ATTRIBUTE_DEPRECATED
430# endif 439# endif
431_GL_FUNCDECL_RPL (ctime, char *, (time_t const *__tp) 440_GL_FUNCDECL_RPL (ctime, char *, (time_t const *__tp),
432 _GL_ARG_NONNULL ((1))); 441 _GL_ARG_NONNULL ((1)));
433_GL_CXXALIAS_RPL (ctime, char *, (time_t const *__tp)); 442_GL_CXXALIAS_RPL (ctime, char *, (time_t const *__tp));
434# else 443# else
@@ -450,7 +459,7 @@ _GL_CXXALIASWARN (ctime);
450# endif 459# endif
451_GL_FUNCDECL_RPL (strftime, size_t, 460_GL_FUNCDECL_RPL (strftime, size_t,
452 (char *restrict __buf, size_t __bufsize, 461 (char *restrict __buf, size_t __bufsize,
453 const char *restrict __fmt, const struct tm *restrict __tp) 462 const char *restrict __fmt, const struct tm *restrict __tp),
454 _GL_ARG_NONNULL ((1, 3, 4))); 463 _GL_ARG_NONNULL ((1, 3, 4)));
455_GL_CXXALIAS_RPL (strftime, size_t, 464_GL_CXXALIAS_RPL (strftime, size_t,
456 (char *restrict __buf, size_t __bufsize, 465 (char *restrict __buf, size_t __bufsize,
@@ -464,21 +473,30 @@ _GL_CXXALIAS_SYS (strftime, size_t,
464_GL_CXXALIASWARN (strftime); 473_GL_CXXALIASWARN (strftime);
465# endif 474# endif
466# elif defined GNULIB_POSIXCHECK 475# elif defined GNULIB_POSIXCHECK
467# undef strftime
468# if HAVE_RAW_DECL_STRFTIME 476# if HAVE_RAW_DECL_STRFTIME
469_GL_WARN_ON_USE (strftime, "strftime has portability problems - " 477_GL_WARN_ON_USE (strftime, "strftime has portability problems - "
470 "use gnulib module strftime-fixes for portability"); 478 "use gnulib module strftime-fixes for portability");
471# endif 479# endif
472# endif 480# endif
473 481
474# if defined _GNU_SOURCE && @GNULIB_TIME_RZ@ && ! @HAVE_TIMEZONE_T@ 482# if @GNULIB_TIME_RZ@
475/* Functions that use a first-class time zone data type, instead of 483/* Functions that use a first-class time zone data type, instead of
476 relying on an implicit global time zone. 484 relying on an implicit global time zone.
477 Inspired by NetBSD. */ 485 Inspired by NetBSD. */
478 486
479/* Represents a time zone. 487/* Represents a time zone.
480 (timezone_t) NULL stands for UTC. */ 488 (timezone_t) NULL stands for UTC. */
489# if !@HAVE_TZALLOC@
490# if !GNULIB_defined_timezone_t
491# if !@HAVE_TIMEZONE_T@
481typedef struct tm_zone *timezone_t; 492typedef struct tm_zone *timezone_t;
493# else
494typedef struct tm_zone *rpl_timezone_t;
495# define timezone_t rpl_timezone_t
496# endif
497# define GNULIB_defined_timezone_t 1
498# endif
499# endif
482 500
483/* tzalloc (name) 501/* tzalloc (name)
484 Returns a time zone object for the given time zone NAME. This object 502 Returns a time zone object for the given time zone NAME. This object
@@ -488,37 +506,79 @@ typedef struct tm_zone *timezone_t;
488 would use it the TZ environment variable was unset. 506 would use it the TZ environment variable was unset.
489 May return NULL if NAME is invalid (this is platform dependent) or 507 May return NULL if NAME is invalid (this is platform dependent) or
490 upon memory allocation failure. */ 508 upon memory allocation failure. */
491_GL_FUNCDECL_SYS (tzalloc, timezone_t, (char const *__name)); 509# if !@HAVE_TZALLOC@
510_GL_FUNCDECL_SYS (tzalloc, timezone_t, (char const *__name), );
492_GL_CXXALIAS_SYS (tzalloc, timezone_t, (char const *__name)); 511_GL_CXXALIAS_SYS (tzalloc, timezone_t, (char const *__name));
512# endif
493 513
494/* tzfree (tz) 514/* tzfree (tz)
495 Frees a time zone object. 515 Free a time zone object, preserving errno.
496 The argument must have been returned by tzalloc(). */ 516 The argument must have been returned by tzalloc(). */
497_GL_FUNCDECL_SYS (tzfree, void, (timezone_t __tz)); 517# if !@HAVE_TZALLOC@
518_GL_FUNCDECL_SYS (tzfree, void, (timezone_t __tz), );
498_GL_CXXALIAS_SYS (tzfree, void, (timezone_t __tz)); 519_GL_CXXALIAS_SYS (tzfree, void, (timezone_t __tz));
520# else
521# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
522# undef tzfree
523# define tzfree rpl_tzfree
524# endif
525_GL_FUNCDECL_RPL (tzfree, void, (timezone_t __tz), );
526_GL_CXXALIAS_RPL (tzfree, void, (timezone_t __tz));
527# endif
499 528
500/* localtime_rz (tz, &t, &result) 529/* localtime_rz (tz, &t, &result)
501 Converts an absolute time T to a broken-down time RESULT, assuming the 530 Converts an absolute time T to a broken-down time RESULT, assuming the
502 time zone TZ. 531 time zone TZ.
503 This function is like 'localtime_r', but relies on the argument TZ instead 532 This function is like 'localtime_r', but relies on the argument TZ instead
504 of an implicit global time zone. */ 533 of an implicit global time zone. */
534# if @REPLACE_LOCALTIME_RZ@
535# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
536# undef localtime_rz
537# define localtime_rz rpl_localtime_rz
538# endif
539_GL_FUNCDECL_RPL (localtime_rz, struct tm *,
540 (timezone_t __tz, time_t const *restrict __timer,
541 struct tm *restrict __result),
542 _GL_ARG_NONNULL ((2, 3)));
543_GL_CXXALIAS_RPL (localtime_rz, struct tm *,
544 (timezone_t __tz, time_t const *restrict __timer,
545 struct tm *restrict __result));
546# else
547# if !@HAVE_TZALLOC@
505_GL_FUNCDECL_SYS (localtime_rz, struct tm *, 548_GL_FUNCDECL_SYS (localtime_rz, struct tm *,
506 (timezone_t __tz, time_t const *restrict __timer, 549 (timezone_t __tz, time_t const *restrict __timer,
507 struct tm *restrict __result) _GL_ARG_NONNULL ((2, 3))); 550 struct tm *restrict __result),
551 _GL_ARG_NONNULL ((2, 3)));
552# endif
508_GL_CXXALIAS_SYS (localtime_rz, struct tm *, 553_GL_CXXALIAS_SYS (localtime_rz, struct tm *,
509 (timezone_t __tz, time_t const *restrict __timer, 554 (timezone_t __tz, time_t const *restrict __timer,
510 struct tm *restrict __result)); 555 struct tm *restrict __result));
556# endif
511 557
512/* mktime_z (tz, &tm) 558/* mktime_z (tz, &tm)
513 Normalizes the broken-down time TM and converts it to an absolute time, 559 Normalizes the broken-down time TM and converts it to an absolute time,
514 assuming the time zone TZ. Returns the absolute time. 560 assuming the time zone TZ. Returns the absolute time.
515 This function is like 'mktime', but relies on the argument TZ instead 561 This function is like 'mktime', but relies on the argument TZ instead
516 of an implicit global time zone. */ 562 of an implicit global time zone. */
563# if @REPLACE_MKTIME_Z@
564# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
565# undef mktime_z
566# define mktime_z rpl_mktime_z
567# endif
568_GL_FUNCDECL_RPL (mktime_z, time_t,
569 (timezone_t __tz, struct tm *restrict __tm),
570 _GL_ARG_NONNULL ((2)));
571_GL_CXXALIAS_RPL (mktime_z, time_t,
572 (timezone_t __tz, struct tm *restrict __tm));
573# else
574# if !@HAVE_TZALLOC@
517_GL_FUNCDECL_SYS (mktime_z, time_t, 575_GL_FUNCDECL_SYS (mktime_z, time_t,
518 (timezone_t __tz, struct tm *restrict __tm) 576 (timezone_t __tz, struct tm *restrict __tm),
519 _GL_ARG_NONNULL ((2))); 577 _GL_ARG_NONNULL ((2)));
578# endif
520_GL_CXXALIAS_SYS (mktime_z, time_t, 579_GL_CXXALIAS_SYS (mktime_z, time_t,
521 (timezone_t __tz, struct tm *restrict __tm)); 580 (timezone_t __tz, struct tm *restrict __tm));
581# endif
522 582
523/* Time zone abbreviation strings (returned by 'localtime_rz' or 'mktime_z' 583/* Time zone abbreviation strings (returned by 'localtime_rz' or 'mktime_z'
524 in the 'tm_zone' member of 'struct tm') are valid as long as 584 in the 'tm_zone' member of 'struct tm') are valid as long as
@@ -535,11 +595,11 @@ _GL_CXXALIAS_SYS (mktime_z, time_t,
535# undef timegm 595# undef timegm
536# define timegm rpl_timegm 596# define timegm rpl_timegm
537# endif 597# endif
538_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1))); 598_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm), _GL_ARG_NONNULL ((1)));
539_GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm)); 599_GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
540# else 600# else
541# if ! @HAVE_TIMEGM@ 601# if ! @HAVE_TIMEGM@
542_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1))); 602_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm), _GL_ARG_NONNULL ((1)));
543# endif 603# endif
544_GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm)); 604_GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
545# endif 605# endif
@@ -547,7 +607,6 @@ _GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
547_GL_CXXALIASWARN (timegm); 607_GL_CXXALIASWARN (timegm);
548# endif 608# endif
549# elif defined GNULIB_POSIXCHECK 609# elif defined GNULIB_POSIXCHECK
550# undef timegm
551# if HAVE_RAW_DECL_TIMEGM 610# if HAVE_RAW_DECL_TIMEGM
552_GL_WARN_ON_USE (timegm, "timegm is unportable - " 611_GL_WARN_ON_USE (timegm, "timegm is unportable - "
553 "use gnulib module timegm for portability"); 612 "use gnulib module timegm for portability");
@@ -558,28 +617,24 @@ _GL_WARN_ON_USE (timegm, "timegm is unportable - "
558 buffers when given outlandish struct tm values. Portable 617 buffers when given outlandish struct tm values. Portable
559 applications should use strftime (or even sprintf) instead. */ 618 applications should use strftime (or even sprintf) instead. */
560# if defined GNULIB_POSIXCHECK 619# if defined GNULIB_POSIXCHECK
561# undef asctime
562# if HAVE_RAW_DECL_ASCTIME 620# if HAVE_RAW_DECL_ASCTIME
563_GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - " 621_GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
564 "better use strftime (or even sprintf) instead"); 622 "better use strftime (or even sprintf) instead");
565# endif 623# endif
566# endif 624# endif
567# if defined GNULIB_POSIXCHECK 625# if defined GNULIB_POSIXCHECK
568# undef asctime_r
569# if HAVE_RAW_DECL_ASCTIME_R 626# if HAVE_RAW_DECL_ASCTIME_R
570_GL_WARN_ON_USE (asctime_r, "asctime_r can overrun buffers in some cases - " 627_GL_WARN_ON_USE (asctime_r, "asctime_r can overrun buffers in some cases - "
571 "better use strftime (or even sprintf) instead"); 628 "better use strftime (or even sprintf) instead");
572# endif 629# endif
573# endif 630# endif
574# if defined GNULIB_POSIXCHECK 631# if defined GNULIB_POSIXCHECK
575# undef ctime
576# if HAVE_RAW_DECL_CTIME 632# if HAVE_RAW_DECL_CTIME
577_GL_WARN_ON_USE (ctime, "ctime can overrun buffers in some cases - " 633_GL_WARN_ON_USE (ctime, "ctime can overrun buffers in some cases - "
578 "better use strftime (or even sprintf) instead"); 634 "better use strftime (or even sprintf) instead");
579# endif 635# endif
580# endif 636# endif
581# if defined GNULIB_POSIXCHECK 637# if defined GNULIB_POSIXCHECK
582# undef ctime_r
583# if HAVE_RAW_DECL_CTIME_R 638# if HAVE_RAW_DECL_CTIME_R
584_GL_WARN_ON_USE (ctime_r, "ctime_r can overrun buffers in some cases - " 639_GL_WARN_ON_USE (ctime_r, "ctime_r can overrun buffers in some cases - "
585 "better use strftime (or even sprintf) instead"); 640 "better use strftime (or even sprintf) instead");