Debian Codegraph @

lib/time.in.h

raw
1 /* A more-standard <time.h>.
2
3 Copyright (C) 2007-2024 Free Software Foundation, Inc.
4
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
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18 #if __GNUC__ >= 3
19 @PRAGMA_SYSTEM_HEADER@
20 #endif
21 @PRAGMA_COLUMNS@
22
23 /* This file uses #include_next of a system file that defines time_t.
24 For the 'year2038' module to work right, <config.h> needs to have been
25 included before. */
26 #if !_GL_CONFIG_H_INCLUDED
27 #error "Please include config.h first."
28 #endif
29
30 /* Don't get in the way of glibc when it includes time.h merely to
31 declare a few standard symbols, rather than to declare all the
32 symbols. (However, skip this for MinGW as it treats __need_time_t
33 incompatibly.) Also, Solaris 8 <time.h> eventually includes itself
34 recursively; if that is happening, just include the system <time.h>
35 without adding our own declarations. */
36 #if (((defined __need_time_t || defined __need_clock_t \
37 || defined __need_timespec) \
38 && !defined __MINGW32__) \
39 || defined _@GUARD_PREFIX@_TIME_H)
40
41 # @INCLUDE_NEXT@ @NEXT_TIME_H@
42
43 #else
44
45 # define _@GUARD_PREFIX@_TIME_H
46
47 /* mingw's <time.h> provides the functions asctime_r, ctime_r, gmtime_r,
48 localtime_r only if <unistd.h> or <pthread.h> has been included before. */
49 # if defined __MINGW32__
50 # include <unistd.h>
51 # endif
52
53 # @INCLUDE_NEXT@ @NEXT_TIME_H@
54
55 /* This file uses _GL_ATTRIBUTE_DEPRECATED, GNULIB_POSIXCHECK,
56 HAVE_RAW_DECL_*. */
57 # if !_GL_CONFIG_H_INCLUDED
58 # error "Please include config.h first."
59 # endif
60
61 /* NetBSD 5.0 mis-defines NULL. */
62 # include <stddef.h>
63
64 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
65
66 /* The definition of _GL_ARG_NONNULL is copied here. */
67
68 /* The definition of _GL_WARN_ON_USE is copied here. */
69
70 /* Some systems don't define struct timespec (e.g., AIX 4.1).
71 Or they define it with the wrong member names or define it in <sys/time.h>
72 (e.g., FreeBSD circa 1997). Stock Mingw prior to 3.0 does not define it,
73 but the pthreads-win32 library defines it in <pthread.h>. */
74 # if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@
75 # if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
76 # include <sys/time.h>
77 # elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
78 # include <pthread.h>
79 # elif @UNISTD_H_DEFINES_STRUCT_TIMESPEC@
80 # include <unistd.h>
81 # else
82
83 # ifdef __cplusplus
84 extern "C" {
85 # endif
86
87 # if !GNULIB_defined_struct_timespec
88 # undef timespec
89 # define timespec rpl_timespec
90 struct timespec
91 {
92 time_t tv_sec;
93 long int tv_nsec;
94 };
95 # define GNULIB_defined_struct_timespec 1
96 # endif
97
98 # ifdef __cplusplus
99 }
100 # endif
101
102 # endif
103 # endif
104
105 # if !GNULIB_defined_struct_time_t_must_be_integral
106 /* https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_types.h.html
107 requires time_t to be an integer type, even though C99 permits floating
108 point. We don't know of any implementation that uses floating
109 point, and it is much easier to write code that doesn't have to
110 worry about that corner case, so we force the issue. */
111 struct __time_t_must_be_integral {
112 unsigned int __floating_time_t_unsupported : (time_t) 1;
113 };
114 # define GNULIB_defined_struct_time_t_must_be_integral 1
115 # endif
116
117 /* Define TIME_UTC, a positive integer constant used for timespec_get(). */
118 # if ! @TIME_H_DEFINES_TIME_UTC@
119 # if !GNULIB_defined_TIME_UTC
120 # define TIME_UTC 1
121 # define GNULIB_defined_TIME_UTC 1
122 # endif
123 # endif
124
125 # if @GNULIB_TZNAME@
126 /* tzname[0..1]: Abbreviated time zone names, set by the tzset() function. */
127 # if NEED_DECL_TZNAME
128 extern
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
142 /* Set *TS to the current time, and return BASE.
143 Upon failure, return 0. */
144 # if @GNULIB_TIMESPEC_GET@
145 # if @REPLACE_TIMESPEC_GET@
146 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
147 # undef timespec_get
148 # define timespec_get rpl_timespec_get
149 # endif
150 _GL_FUNCDECL_RPL (timespec_get, int, (struct timespec *ts, int base),
151 _GL_ARG_NONNULL ((1)));
152 _GL_CXXALIAS_RPL (timespec_get, int, (struct timespec *ts, int base));
153 # else
154 # if !@HAVE_TIMESPEC_GET@
155 _GL_FUNCDECL_SYS (timespec_get, int, (struct timespec *ts, int base),
156 _GL_ARG_NONNULL ((1)));
157 # endif
158 _GL_CXXALIAS_SYS (timespec_get, int, (struct timespec *ts, int base));
159 # endif
160 # if __GLIBC__ >= 2
161 _GL_CXXALIASWARN (timespec_get);
162 # endif
163 # elif defined GNULIB_POSIXCHECK
164 # undef timespec_get
165 # if HAVE_RAW_DECL_TIMESPEC_GET
166 _GL_WARN_ON_USE (timespec_get, "timespec_get is unportable - "
167 "use gnulib module timespec_get for portability");
168 # endif
169 # endif
170
171 /* Set *TS to the current time resolution, and return BASE.
172 Upon failure, return 0. */
173 # if @GNULIB_TIMESPEC_GETRES@
174 # if @REPLACE_TIMESPEC_GETRES@
175 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
176 # undef timespec_getres
177 # define timespec_getres rpl_timespec_getres
178 # endif
179 _GL_FUNCDECL_RPL (timespec_getres, int, (struct timespec *ts, int base),
180 _GL_ARG_NONNULL ((1)));
181 _GL_CXXALIAS_RPL (timespec_getres, int, (struct timespec *ts, int base));
182 # else
183 # if !@HAVE_TIMESPEC_GETRES@
184 _GL_FUNCDECL_SYS (timespec_getres, int, (struct timespec *ts, int base),
185 _GL_ARG_NONNULL ((1)));
186 # endif
187 _GL_CXXALIAS_SYS (timespec_getres, int, (struct timespec *ts, int base));
188 # endif
189 _GL_CXXALIASWARN (timespec_getres);
190 # elif defined GNULIB_POSIXCHECK
191 # undef timespec_getres
192 # if HAVE_RAW_DECL_TIMESPEC_GETRES
193 _GL_WARN_ON_USE (timespec_getres, "timespec_getres is unportable - "
194 "use gnulib module timespec_getres for portability");
195 # endif
196 # endif
197
198 /* Return the number of seconds that have elapsed since the Epoch. */
199 # if @GNULIB_TIME@
200 # if @REPLACE_TIME@
201 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
202 # define time rpl_time
203 # endif
204 _GL_FUNCDECL_RPL (time, time_t, (time_t *__tp), );
205 _GL_CXXALIAS_RPL (time, time_t, (time_t *__tp));
206 # else
207 _GL_CXXALIAS_SYS (time, time_t, (time_t *__tp));
208 # endif
209 # if __GLIBC__ >= 2
210 _GL_CXXALIASWARN (time);
211 # endif
212 # elif defined GNULIB_POSIXCHECK
213 # undef time
214 # if HAVE_RAW_DECL_TIME
215 _GL_WARN_ON_USE (time, "time has consistency problems - "
216 "use gnulib module time for portability");
217 # endif
218 # endif
219
220 /* Sleep for at least RQTP seconds unless interrupted, If interrupted,
221 return -1 and store the remaining time into RMTP. See
222 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/nanosleep.html>. */
223 # if @GNULIB_NANOSLEEP@
224 # if @REPLACE_NANOSLEEP@
225 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
226 # define nanosleep rpl_nanosleep
227 # endif
228 _GL_FUNCDECL_RPL (nanosleep, int,
229 (struct timespec const *__rqtp, struct timespec *__rmtp),
230 _GL_ARG_NONNULL ((1)));
231 _GL_CXXALIAS_RPL (nanosleep, int,
232 (struct timespec const *__rqtp, struct timespec *__rmtp));
233 # else
234 # if ! @HAVE_NANOSLEEP@
235 _GL_FUNCDECL_SYS (nanosleep, int,
236 (struct timespec const *__rqtp, struct timespec *__rmtp),
237 _GL_ARG_NONNULL ((1)));
238 # endif
239 _GL_CXXALIAS_SYS (nanosleep, int,
240 (struct timespec const *__rqtp, struct timespec *__rmtp));
241 # endif
242 _GL_CXXALIASWARN (nanosleep);
243 # elif defined GNULIB_POSIXCHECK
244 # undef nanosleep
245 # if HAVE_RAW_DECL_NANOSLEEP
246 _GL_WARN_ON_USE (nanosleep, "nanosleep is unportable - "
247 "use gnulib module nanosleep for portability");
248 # endif
249 # endif
250
251 /* Initialize time conversion information. */
252 # if @GNULIB_TZSET@
253 # if @REPLACE_TZSET@
254 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
255 # undef tzset
256 # define tzset rpl_tzset
257 # endif
258 _GL_FUNCDECL_RPL (tzset, void, (void), );
259 _GL_CXXALIAS_RPL (tzset, void, (void));
260 # elif defined _WIN32 && !defined __CYGWIN__
261 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
262 # undef tzset
263 # define tzset _tzset
264 # endif
265 _GL_CXXALIAS_MDA (tzset, void, (void));
266 # else
267 _GL_CXXALIAS_SYS (tzset, void, (void));
268 # endif
269 _GL_CXXALIASWARN (tzset);
270 # elif @GNULIB_MDA_TZSET@
271 /* On native Windows, map 'tzset' to '_tzset', so that -loldnames is not
272 required. In C++ with GNULIB_NAMESPACE, avoid differences between
273 platforms by defining GNULIB_NAMESPACE::tzset always. */
274 # if defined _WIN32 && !defined __CYGWIN__
275 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
276 # undef tzset
277 # define tzset _tzset
278 # endif
279 _GL_CXXALIAS_MDA (tzset, void, (void));
280 # else
281 _GL_CXXALIAS_SYS (tzset, void, (void));
282 # endif
283 _GL_CXXALIASWARN (tzset);
284 # elif defined GNULIB_POSIXCHECK
285 # undef tzset
286 # if HAVE_RAW_DECL_TZSET
287 _GL_WARN_ON_USE (tzset, "tzset has portability problems - "
288 "use gnulib module tzset for portability");
289 # endif
290 # endif
291
292 /* Return the 'time_t' representation of TP and normalize TP. */
293 # if @GNULIB_MKTIME@
294 # if @REPLACE_MKTIME@
295 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
296 # define mktime rpl_mktime
297 # endif
298 _GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp), _GL_ARG_NONNULL ((1)));
299 _GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
300 # else
301 _GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
302 # endif
303 # if __GLIBC__ >= 2
304 _GL_CXXALIASWARN (mktime);
305 # endif
306 # elif defined GNULIB_POSIXCHECK
307 # undef mktime
308 # if HAVE_RAW_DECL_MKTIME
309 _GL_WARN_ON_USE (mktime, "mktime has portability problems - "
310 "use gnulib module mktime for portability");
311 # endif
312 # endif
313
314 /* Convert TIMER to RESULT, assuming local time and UTC respectively. See
315 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/localtime_r.html> and
316 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/gmtime_r.html>. */
317 # if @GNULIB_TIME_R@
318 # if @REPLACE_LOCALTIME_R@
319 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
320 # undef localtime_r
321 # define localtime_r rpl_localtime_r
322 # endif
323 _GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
324 struct tm *restrict __result),
325 _GL_ARG_NONNULL ((1, 2)));
326 _GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
327 struct tm *restrict __result));
328 # else
329 # if ! @HAVE_DECL_LOCALTIME_R@
330 _GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
331 struct tm *restrict __result),
332 _GL_ARG_NONNULL ((1, 2)));
333 # endif
334 _GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
335 struct tm *restrict __result));
336 # endif
337 # if @HAVE_DECL_LOCALTIME_R@
338 _GL_CXXALIASWARN (localtime_r);
339 # endif
340 # if @REPLACE_LOCALTIME_R@
341 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
342 # undef gmtime_r
343 # define gmtime_r rpl_gmtime_r
344 # endif
345 _GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
346 struct tm *restrict __result),
347 _GL_ARG_NONNULL ((1, 2)));
348 _GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
349 struct tm *restrict __result));
350 # else
351 # if ! @HAVE_DECL_LOCALTIME_R@
352 _GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
353 struct tm *restrict __result),
354 _GL_ARG_NONNULL ((1, 2)));
355 # endif
356 _GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
357 struct tm *restrict __result));
358 # endif
359 # if @HAVE_DECL_LOCALTIME_R@
360 _GL_CXXALIASWARN (gmtime_r);
361 # endif
362 # elif defined GNULIB_POSIXCHECK
363 # undef localtime_r
364 # if HAVE_RAW_DECL_LOCALTIME_R
365 _GL_WARN_ON_USE (localtime_r, "localtime_r is unportable - "
366 "use gnulib module time_r for portability");
367 # endif
368 # undef gmtime_r
369 # if HAVE_RAW_DECL_GMTIME_R
370 _GL_WARN_ON_USE (gmtime_r, "gmtime_r is unportable - "
371 "use gnulib module time_r for portability");
372 # endif
373 # endif
374
375 /* Convert TIMER to RESULT, assuming local time and UTC respectively. See
376 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/localtime.html> and
377 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/gmtime.html>. */
378 # if @GNULIB_LOCALTIME@ || @REPLACE_LOCALTIME@
379 # if @REPLACE_LOCALTIME@
380 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
381 # undef localtime
382 # define localtime rpl_localtime
383 # endif
384 _GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer),
385 _GL_ARG_NONNULL ((1)));
386 _GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer));
387 # else
388 _GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer));
389 # endif
390 # if __GLIBC__ >= 2
391 _GL_CXXALIASWARN (localtime);
392 # endif
393 # elif defined GNULIB_POSIXCHECK
394 # undef localtime
395 # if HAVE_RAW_DECL_LOCALTIME
396 _GL_WARN_ON_USE (localtime, "localtime has portability problems - "
397 "use gnulib module localtime for portability");
398 # endif
399 # endif
400
401 # if 0 || @REPLACE_GMTIME@
402 # if @REPLACE_GMTIME@
403 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
404 # undef gmtime
405 # define gmtime rpl_gmtime
406 # endif
407 _GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer),
408 _GL_ARG_NONNULL ((1)));
409 _GL_CXXALIAS_RPL (gmtime, struct tm *, (time_t const *__timer));
410 # else
411 _GL_CXXALIAS_SYS (gmtime, struct tm *, (time_t const *__timer));
412 # endif
413 _GL_CXXALIASWARN (gmtime);
414 # endif
415
416 /* Parse BUF as a timestamp, assuming FORMAT specifies its layout, and store
417 the resulting broken-down time into TM. See
418 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/strptime.html>. */
419 # if @GNULIB_STRPTIME@
420 # if ! @HAVE_STRPTIME@
421 _GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
422 char const *restrict __format,
423 struct tm *restrict __tm),
424 _GL_ARG_NONNULL ((1, 2, 3)));
425 # endif
426 _GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
427 char const *restrict __format,
428 struct tm *restrict __tm));
429 _GL_CXXALIASWARN (strptime);
430 # elif defined GNULIB_POSIXCHECK
431 # undef strptime
432 # if HAVE_RAW_DECL_STRPTIME
433 _GL_WARN_ON_USE (strptime, "strptime is unportable - "
434 "use gnulib module strptime for portability");
435 # endif
436 # endif
437
438 /* Convert *TP to a date and time string. See
439 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/ctime.html>. */
440 # if @GNULIB_CTIME@
441 # if @REPLACE_CTIME@
442 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
443 # define ctime rpl_ctime
444 # endif
445 # ifndef __cplusplus
446 _GL_ATTRIBUTE_DEPRECATED
447 # endif
448 _GL_FUNCDECL_RPL (ctime, char *, (time_t const *__tp),
449 _GL_ARG_NONNULL ((1)));
450 _GL_CXXALIAS_RPL (ctime, char *, (time_t const *__tp));
451 # else
452 _GL_CXXALIAS_SYS (ctime, char *, (time_t const *__tp));
453 # endif
454 # if __GLIBC__ >= 2
455 _GL_CXXALIASWARN (ctime);
456 # endif
457 # elif defined GNULIB_POSIXCHECK
458 /* No need to warn about portability, as a more serious warning is below. */
459 # endif
460
461 /* Convert *TP to a date and time string. See
462 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html>. */
463 # if @GNULIB_STRFTIME@
464 # if @REPLACE_STRFTIME@
465 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
466 # define strftime rpl_strftime
467 # endif
468 _GL_FUNCDECL_RPL (strftime, size_t,
469 (char *restrict __buf, size_t __bufsize,
470 const char *restrict __fmt, const struct tm *restrict __tp),
471 _GL_ARG_NONNULL ((1, 3, 4)));
472 _GL_CXXALIAS_RPL (strftime, size_t,
473 (char *restrict __buf, size_t __bufsize,
474 const char *restrict __fmt, const struct tm *restrict __tp));
475 # else
476 _GL_CXXALIAS_SYS (strftime, size_t,
477 (char *restrict __buf, size_t __bufsize,
478 const char *restrict __fmt, const struct tm *restrict __tp));
479 # endif
480 # if __GLIBC__ >= 2
481 _GL_CXXALIASWARN (strftime);
482 # endif
483 # elif defined GNULIB_POSIXCHECK
484 # undef strftime
485 # if HAVE_RAW_DECL_STRFTIME
486 _GL_WARN_ON_USE (strftime, "strftime has portability problems - "
487 "use gnulib module strftime-fixes for portability");
488 # endif
489 # endif
490
491 # if @GNULIB_TIME_RZ@
492 /* Functions that use a first-class time zone data type, instead of
493 relying on an implicit global time zone.
494 Inspired by NetBSD. */
495
496 /* Represents a time zone.
497 (timezone_t) NULL stands for UTC. */
498 # if !@HAVE_TZALLOC@
499 # if !GNULIB_defined_timezone_t
500 # if !@HAVE_TIMEZONE_T@
501 typedef struct tm_zone *timezone_t;
502 # else
503 typedef struct tm_zone *rpl_timezone_t;
504 # define timezone_t rpl_timezone_t
505 # endif
506 # define GNULIB_defined_timezone_t 1
507 # endif
508 # endif
509
510 /* tzalloc (name)
511 Returns a time zone object for the given time zone NAME. This object
512 represents the time zone that other functions would use it the TZ
513 environment variable was set to NAME.
514 If NAME is NULL, the result represents the time zone that other functions
515 would use it the TZ environment variable was unset.
516 May return NULL if NAME is invalid (this is platform dependent) or
517 upon memory allocation failure. */
518 # if !@HAVE_TZALLOC@
519 _GL_FUNCDECL_SYS (tzalloc, timezone_t, (char const *__name), );
520 _GL_CXXALIAS_SYS (tzalloc, timezone_t, (char const *__name));
521 # endif
522
523 /* tzfree (tz)
524 Frees a time zone object.
525 The argument must have been returned by tzalloc(). */
526 # if !@HAVE_TZALLOC@
527 _GL_FUNCDECL_SYS (tzfree, void, (timezone_t __tz), );
528 _GL_CXXALIAS_SYS (tzfree, void, (timezone_t __tz));
529 # endif
530
531 /* localtime_rz (tz, &t, &result)
532 Converts an absolute time T to a broken-down time RESULT, assuming the
533 time zone TZ.
534 This function is like 'localtime_r', but relies on the argument TZ instead
535 of an implicit global time zone. */
536 # if @REPLACE_LOCALTIME_RZ@
537 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
538 # undef localtime_rz
539 # define localtime_rz rpl_localtime_rz
540 # endif
541 _GL_FUNCDECL_RPL (localtime_rz, struct tm *,
542 (timezone_t __tz, time_t const *restrict __timer,
543 struct tm *restrict __result),
544 _GL_ARG_NONNULL ((2, 3)));
545 _GL_CXXALIAS_RPL (localtime_rz, struct tm *,
546 (timezone_t __tz, time_t const *restrict __timer,
547 struct tm *restrict __result));
548 # else
549 # if !@HAVE_TZALLOC@
550 _GL_FUNCDECL_SYS (localtime_rz, struct tm *,
551 (timezone_t __tz, time_t const *restrict __timer,
552 struct tm *restrict __result),
553 _GL_ARG_NONNULL ((2, 3)));
554 # endif
555 _GL_CXXALIAS_SYS (localtime_rz, struct tm *,
556 (timezone_t __tz, time_t const *restrict __timer,
557 struct tm *restrict __result));
558 # endif
559
560 /* mktime_z (tz, &tm)
561 Normalizes the broken-down time TM and converts it to an absolute time,
562 assuming the time zone TZ. Returns the absolute time.
563 This function is like 'mktime', but relies on the argument TZ instead
564 of an implicit global time zone. */
565 # if @REPLACE_MKTIME_Z@
566 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
567 # undef mktime_z
568 # define mktime_z rpl_mktime_z
569 # endif
570 _GL_FUNCDECL_RPL (mktime_z, time_t,
571 (timezone_t __tz, struct tm *restrict __tm),
572 _GL_ARG_NONNULL ((2)));
573 _GL_CXXALIAS_RPL (mktime_z, time_t,
574 (timezone_t __tz, struct tm *restrict __tm));
575 # else
576 # if !@HAVE_TZALLOC@
577 _GL_FUNCDECL_SYS (mktime_z, time_t,
578 (timezone_t __tz, struct tm *restrict __tm),
579 _GL_ARG_NONNULL ((2)));
580 # endif
581 _GL_CXXALIAS_SYS (mktime_z, time_t,
582 (timezone_t __tz, struct tm *restrict __tm));
583 # endif
584
585 /* Time zone abbreviation strings (returned by 'localtime_rz' or 'mktime_z'
586 in the 'tm_zone' member of 'struct tm') are valid as long as
587 - the 'struct tm' argument is not destroyed or overwritten,
588 and
589 - the 'timezone_t' argument is not freed through tzfree(). */
590
591 # endif
592
593 /* Convert TM to a time_t value, assuming UTC. */
594 # if @GNULIB_TIMEGM@
595 # if @REPLACE_TIMEGM@
596 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
597 # undef timegm
598 # define timegm rpl_timegm
599 # endif
600 _GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm), _GL_ARG_NONNULL ((1)));
601 _GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
602 # else
603 # if ! @HAVE_TIMEGM@
604 _GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm), _GL_ARG_NONNULL ((1)));
605 # endif
606 _GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
607 # endif
608 # if __GLIBC__ >= 2
609 _GL_CXXALIASWARN (timegm);
610 # endif
611 # elif defined GNULIB_POSIXCHECK
612 # undef timegm
613 # if HAVE_RAW_DECL_TIMEGM
614 _GL_WARN_ON_USE (timegm, "timegm is unportable - "
615 "use gnulib module timegm for portability");
616 # endif
617 # endif
618
619 /* Encourage applications to avoid unsafe functions that can overrun
620 buffers when given outlandish struct tm values. Portable
621 applications should use strftime (or even sprintf) instead. */
622 # if defined GNULIB_POSIXCHECK
623 # undef asctime
624 # if HAVE_RAW_DECL_ASCTIME
625 _GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
626 "better use strftime (or even sprintf) instead");
627 # endif
628 # endif
629 # if defined GNULIB_POSIXCHECK
630 # undef asctime_r
631 # if HAVE_RAW_DECL_ASCTIME_R
632 _GL_WARN_ON_USE (asctime_r, "asctime_r can overrun buffers in some cases - "
633 "better use strftime (or even sprintf) instead");
634 # endif
635 # endif
636 # if defined GNULIB_POSIXCHECK
637 # undef ctime
638 # if HAVE_RAW_DECL_CTIME
639 _GL_WARN_ON_USE (ctime, "ctime can overrun buffers in some cases - "
640 "better use strftime (or even sprintf) instead");
641 # endif
642 # endif
643 # if defined GNULIB_POSIXCHECK
644 # undef ctime_r
645 # if HAVE_RAW_DECL_CTIME_R
646 _GL_WARN_ON_USE (ctime_r, "ctime_r can overrun buffers in some cases - "
647 "better use strftime (or even sprintf) instead");
648 # endif
649 # endif
650
651 #endif