Debian Codegraph @

lib/time.in.h

raw
1 /* A more-standard <time.h>.
2
3 Copyright (C) 2007-2025 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 # if __GLIBC__ >= 2
190 _GL_CXXALIASWARN (timespec_getres);
191 # endif
192 # elif defined GNULIB_POSIXCHECK
193 # undef timespec_getres
194 # if HAVE_RAW_DECL_TIMESPEC_GETRES
195 _GL_WARN_ON_USE (timespec_getres, "timespec_getres is unportable - "
196 "use gnulib module timespec_getres for portability");
197 # endif
198 # endif
199
200 /* Return the number of seconds that have elapsed since the Epoch. */
201 # if @GNULIB_TIME@
202 # if @REPLACE_TIME@
203 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
204 # define time rpl_time
205 # endif
206 _GL_FUNCDECL_RPL (time, time_t, (time_t *__tp), );
207 _GL_CXXALIAS_RPL (time, time_t, (time_t *__tp));
208 # else
209 _GL_CXXALIAS_SYS (time, time_t, (time_t *__tp));
210 # endif
211 # if __GLIBC__ >= 2
212 _GL_CXXALIASWARN (time);
213 # endif
214 # elif defined GNULIB_POSIXCHECK
215 # undef time
216 # if HAVE_RAW_DECL_TIME
217 _GL_WARN_ON_USE (time, "time has consistency problems - "
218 "use gnulib module time for portability");
219 # endif
220 # endif
221
222 /* Sleep for at least RQTP seconds unless interrupted, If interrupted,
223 return -1 and store the remaining time into RMTP. See
224 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/nanosleep.html>. */
225 # if @GNULIB_NANOSLEEP@
226 # if @REPLACE_NANOSLEEP@
227 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
228 # define nanosleep rpl_nanosleep
229 # endif
230 _GL_FUNCDECL_RPL (nanosleep, int,
231 (struct timespec const *__rqtp, struct timespec *__rmtp),
232 _GL_ARG_NONNULL ((1)));
233 _GL_CXXALIAS_RPL (nanosleep, int,
234 (struct timespec const *__rqtp, struct timespec *__rmtp));
235 # else
236 # if ! @HAVE_NANOSLEEP@
237 _GL_FUNCDECL_SYS (nanosleep, int,
238 (struct timespec const *__rqtp, struct timespec *__rmtp),
239 _GL_ARG_NONNULL ((1)));
240 # endif
241 _GL_CXXALIAS_SYS (nanosleep, int,
242 (struct timespec const *__rqtp, struct timespec *__rmtp));
243 # endif
244 _GL_CXXALIASWARN (nanosleep);
245 # elif defined GNULIB_POSIXCHECK
246 # undef nanosleep
247 # if HAVE_RAW_DECL_NANOSLEEP
248 _GL_WARN_ON_USE (nanosleep, "nanosleep is unportable - "
249 "use gnulib module nanosleep for portability");
250 # endif
251 # endif
252
253 /* Initialize time conversion information. */
254 # if @GNULIB_TZSET@
255 # if @REPLACE_TZSET@
256 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
257 # undef tzset
258 # define tzset rpl_tzset
259 # endif
260 _GL_FUNCDECL_RPL (tzset, void, (void), );
261 _GL_CXXALIAS_RPL (tzset, void, (void));
262 # elif defined _WIN32 && !defined __CYGWIN__
263 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
264 # undef tzset
265 # define tzset _tzset
266 # endif
267 _GL_CXXALIAS_MDA (tzset, void, (void));
268 # else
269 _GL_CXXALIAS_SYS (tzset, void, (void));
270 # endif
271 _GL_CXXALIASWARN (tzset);
272 # elif @GNULIB_MDA_TZSET@
273 /* On native Windows, map 'tzset' to '_tzset', so that -loldnames is not
274 required. In C++ with GNULIB_NAMESPACE, avoid differences between
275 platforms by defining GNULIB_NAMESPACE::tzset always. */
276 # if defined _WIN32 && !defined __CYGWIN__
277 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
278 # undef tzset
279 # define tzset _tzset
280 # endif
281 _GL_CXXALIAS_MDA (tzset, void, (void));
282 # else
283 _GL_CXXALIAS_SYS (tzset, void, (void));
284 # endif
285 _GL_CXXALIASWARN (tzset);
286 # elif defined GNULIB_POSIXCHECK
287 # undef tzset
288 # if HAVE_RAW_DECL_TZSET
289 _GL_WARN_ON_USE (tzset, "tzset has portability problems - "
290 "use gnulib module tzset for portability");
291 # endif
292 # endif
293
294 /* Return the 'time_t' representation of TP and normalize TP. */
295 # if @GNULIB_MKTIME@
296 # if @REPLACE_MKTIME@
297 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
298 # define mktime rpl_mktime
299 # endif
300 _GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp), _GL_ARG_NONNULL ((1)));
301 _GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
302 # else
303 _GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
304 # endif
305 # if __GLIBC__ >= 2
306 _GL_CXXALIASWARN (mktime);
307 # endif
308 # elif defined GNULIB_POSIXCHECK
309 # undef mktime
310 # if HAVE_RAW_DECL_MKTIME
311 _GL_WARN_ON_USE (mktime, "mktime has portability problems - "
312 "use gnulib module mktime for portability");
313 # endif
314 # endif
315
316 /* Convert TIMER to RESULT, assuming local time and UTC respectively. See
317 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/localtime_r.html> and
318 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/gmtime_r.html>. */
319 # if @GNULIB_TIME_R@
320 # if @REPLACE_LOCALTIME_R@
321 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
322 # undef localtime_r
323 # define localtime_r rpl_localtime_r
324 # endif
325 _GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
326 struct tm *restrict __result),
327 _GL_ARG_NONNULL ((1, 2)));
328 _GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
329 struct tm *restrict __result));
330 # else
331 # if ! @HAVE_DECL_LOCALTIME_R@
332 _GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
333 struct tm *restrict __result),
334 _GL_ARG_NONNULL ((1, 2)));
335 # endif
336 _GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
337 struct tm *restrict __result));
338 # endif
339 # if @HAVE_DECL_LOCALTIME_R@
340 _GL_CXXALIASWARN (localtime_r);
341 # endif
342 # if @REPLACE_LOCALTIME_R@
343 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
344 # undef gmtime_r
345 # define gmtime_r rpl_gmtime_r
346 # endif
347 _GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
348 struct tm *restrict __result),
349 _GL_ARG_NONNULL ((1, 2)));
350 _GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
351 struct tm *restrict __result));
352 # else
353 # if ! @HAVE_DECL_LOCALTIME_R@
354 _GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
355 struct tm *restrict __result),
356 _GL_ARG_NONNULL ((1, 2)));
357 # endif
358 _GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
359 struct tm *restrict __result));
360 # endif
361 # if @HAVE_DECL_LOCALTIME_R@
362 _GL_CXXALIASWARN (gmtime_r);
363 # endif
364 # elif defined GNULIB_POSIXCHECK
365 # undef localtime_r
366 # if HAVE_RAW_DECL_LOCALTIME_R
367 _GL_WARN_ON_USE (localtime_r, "localtime_r is unportable - "
368 "use gnulib module time_r for portability");
369 # endif
370 # undef gmtime_r
371 # if HAVE_RAW_DECL_GMTIME_R
372 _GL_WARN_ON_USE (gmtime_r, "gmtime_r is unportable - "
373 "use gnulib module time_r for portability");
374 # endif
375 # endif
376
377 /* Convert TIMER to RESULT, assuming local time and UTC respectively. See
378 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/localtime.html> and
379 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/gmtime.html>. */
380 # if @GNULIB_LOCALTIME@ || @REPLACE_LOCALTIME@
381 # if @REPLACE_LOCALTIME@
382 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
383 # undef localtime
384 # define localtime rpl_localtime
385 # endif
386 _GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer),
387 _GL_ARG_NONNULL ((1)));
388 _GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer));
389 # else
390 _GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer));
391 # endif
392 # if __GLIBC__ >= 2
393 _GL_CXXALIASWARN (localtime);
394 # endif
395 # elif defined GNULIB_POSIXCHECK
396 # undef localtime
397 # if HAVE_RAW_DECL_LOCALTIME
398 _GL_WARN_ON_USE (localtime, "localtime has portability problems - "
399 "use gnulib module localtime for portability");
400 # endif
401 # endif
402
403 # if 0 || @REPLACE_GMTIME@
404 # if @REPLACE_GMTIME@
405 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
406 # undef gmtime
407 # define gmtime rpl_gmtime
408 # endif
409 _GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer),
410 _GL_ARG_NONNULL ((1)));
411 _GL_CXXALIAS_RPL (gmtime, struct tm *, (time_t const *__timer));
412 # else
413 _GL_CXXALIAS_SYS (gmtime, struct tm *, (time_t const *__timer));
414 # endif
415 _GL_CXXALIASWARN (gmtime);
416 # endif
417
418 /* Parse BUF as a timestamp, assuming FORMAT specifies its layout, and store
419 the resulting broken-down time into TM. See
420 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/strptime.html>. */
421 # if @GNULIB_STRPTIME@
422 # if ! @HAVE_STRPTIME@
423 _GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
424 char const *restrict __format,
425 struct tm *restrict __tm),
426 _GL_ARG_NONNULL ((1, 2, 3)));
427 # endif
428 _GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
429 char const *restrict __format,
430 struct tm *restrict __tm));
431 _GL_CXXALIASWARN (strptime);
432 # elif defined GNULIB_POSIXCHECK
433 # undef strptime
434 # if HAVE_RAW_DECL_STRPTIME
435 _GL_WARN_ON_USE (strptime, "strptime is unportable - "
436 "use gnulib module strptime for portability");
437 # endif
438 # endif
439
440 /* Convert *TP to a date and time string. See
441 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/ctime.html>. */
442 # if @GNULIB_CTIME@
443 # if @REPLACE_CTIME@
444 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
445 # define ctime rpl_ctime
446 # endif
447 # ifndef __cplusplus
448 _GL_ATTRIBUTE_DEPRECATED
449 # endif
450 _GL_FUNCDECL_RPL (ctime, char *, (time_t const *__tp),
451 _GL_ARG_NONNULL ((1)));
452 _GL_CXXALIAS_RPL (ctime, char *, (time_t const *__tp));
453 # else
454 _GL_CXXALIAS_SYS (ctime, char *, (time_t const *__tp));
455 # endif
456 # if __GLIBC__ >= 2
457 _GL_CXXALIASWARN (ctime);
458 # endif
459 # elif defined GNULIB_POSIXCHECK
460 /* No need to warn about portability, as a more serious warning is below. */
461 # endif
462
463 /* Convert *TP to a date and time string. See
464 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html>. */
465 # if @GNULIB_STRFTIME@
466 # if @REPLACE_STRFTIME@
467 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
468 # define strftime rpl_strftime
469 # endif
470 _GL_FUNCDECL_RPL (strftime, size_t,
471 (char *restrict __buf, size_t __bufsize,
472 const char *restrict __fmt, const struct tm *restrict __tp),
473 _GL_ARG_NONNULL ((1, 3, 4)));
474 _GL_CXXALIAS_RPL (strftime, size_t,
475 (char *restrict __buf, size_t __bufsize,
476 const char *restrict __fmt, const struct tm *restrict __tp));
477 # else
478 _GL_CXXALIAS_SYS (strftime, size_t,
479 (char *restrict __buf, size_t __bufsize,
480 const char *restrict __fmt, const struct tm *restrict __tp));
481 # endif
482 # if __GLIBC__ >= 2
483 _GL_CXXALIASWARN (strftime);
484 # endif
485 # elif defined GNULIB_POSIXCHECK
486 # undef strftime
487 # if HAVE_RAW_DECL_STRFTIME
488 _GL_WARN_ON_USE (strftime, "strftime has portability problems - "
489 "use gnulib module strftime-fixes for portability");
490 # endif
491 # endif
492
493 # if @GNULIB_TIME_RZ@
494 /* Functions that use a first-class time zone data type, instead of
495 relying on an implicit global time zone.
496 Inspired by NetBSD. */
497
498 /* Represents a time zone.
499 (timezone_t) NULL stands for UTC. */
500 # if !@HAVE_TZALLOC@
501 # if !GNULIB_defined_timezone_t
502 # if !@HAVE_TIMEZONE_T@
503 typedef struct tm_zone *timezone_t;
504 # else
505 typedef struct tm_zone *rpl_timezone_t;
506 # define timezone_t rpl_timezone_t
507 # endif
508 # define GNULIB_defined_timezone_t 1
509 # endif
510 # endif
511
512 /* tzalloc (name)
513 Returns a time zone object for the given time zone NAME. This object
514 represents the time zone that other functions would use it the TZ
515 environment variable was set to NAME.
516 If NAME is NULL, the result represents the time zone that other functions
517 would use it the TZ environment variable was unset.
518 May return NULL if NAME is invalid (this is platform dependent) or
519 upon memory allocation failure. */
520 # if !@HAVE_TZALLOC@
521 _GL_FUNCDECL_SYS (tzalloc, timezone_t, (char const *__name), );
522 _GL_CXXALIAS_SYS (tzalloc, timezone_t, (char const *__name));
523 # endif
524
525 /* tzfree (tz)
526 Frees a time zone object.
527 The argument must have been returned by tzalloc(). */
528 # if !@HAVE_TZALLOC@
529 _GL_FUNCDECL_SYS (tzfree, void, (timezone_t __tz), );
530 _GL_CXXALIAS_SYS (tzfree, void, (timezone_t __tz));
531 # endif
532
533 /* localtime_rz (tz, &t, &result)
534 Converts an absolute time T to a broken-down time RESULT, assuming the
535 time zone TZ.
536 This function is like 'localtime_r', but relies on the argument TZ instead
537 of an implicit global time zone. */
538 # if @REPLACE_LOCALTIME_RZ@
539 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
540 # undef localtime_rz
541 # define localtime_rz rpl_localtime_rz
542 # endif
543 _GL_FUNCDECL_RPL (localtime_rz, struct tm *,
544 (timezone_t __tz, time_t const *restrict __timer,
545 struct tm *restrict __result),
546 _GL_ARG_NONNULL ((2, 3)));
547 _GL_CXXALIAS_RPL (localtime_rz, struct tm *,
548 (timezone_t __tz, time_t const *restrict __timer,
549 struct tm *restrict __result));
550 # else
551 # if !@HAVE_TZALLOC@
552 _GL_FUNCDECL_SYS (localtime_rz, struct tm *,
553 (timezone_t __tz, time_t const *restrict __timer,
554 struct tm *restrict __result),
555 _GL_ARG_NONNULL ((2, 3)));
556 # endif
557 _GL_CXXALIAS_SYS (localtime_rz, struct tm *,
558 (timezone_t __tz, time_t const *restrict __timer,
559 struct tm *restrict __result));
560 # endif
561
562 /* mktime_z (tz, &tm)
563 Normalizes the broken-down time TM and converts it to an absolute time,
564 assuming the time zone TZ. Returns the absolute time.
565 This function is like 'mktime', but relies on the argument TZ instead
566 of an implicit global time zone. */
567 # if @REPLACE_MKTIME_Z@
568 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
569 # undef mktime_z
570 # define mktime_z rpl_mktime_z
571 # endif
572 _GL_FUNCDECL_RPL (mktime_z, time_t,
573 (timezone_t __tz, struct tm *restrict __tm),
574 _GL_ARG_NONNULL ((2)));
575 _GL_CXXALIAS_RPL (mktime_z, time_t,
576 (timezone_t __tz, struct tm *restrict __tm));
577 # else
578 # if !@HAVE_TZALLOC@
579 _GL_FUNCDECL_SYS (mktime_z, time_t,
580 (timezone_t __tz, struct tm *restrict __tm),
581 _GL_ARG_NONNULL ((2)));
582 # endif
583 _GL_CXXALIAS_SYS (mktime_z, time_t,
584 (timezone_t __tz, struct tm *restrict __tm));
585 # endif
586
587 /* Time zone abbreviation strings (returned by 'localtime_rz' or 'mktime_z'
588 in the 'tm_zone' member of 'struct tm') are valid as long as
589 - the 'struct tm' argument is not destroyed or overwritten,
590 and
591 - the 'timezone_t' argument is not freed through tzfree(). */
592
593 # endif
594
595 /* Convert TM to a time_t value, assuming UTC. */
596 # if @GNULIB_TIMEGM@
597 # if @REPLACE_TIMEGM@
598 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
599 # undef timegm
600 # define timegm rpl_timegm
601 # endif
602 _GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm), _GL_ARG_NONNULL ((1)));
603 _GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
604 # else
605 # if ! @HAVE_TIMEGM@
606 _GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm), _GL_ARG_NONNULL ((1)));
607 # endif
608 _GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
609 # endif
610 # if __GLIBC__ >= 2
611 _GL_CXXALIASWARN (timegm);
612 # endif
613 # elif defined GNULIB_POSIXCHECK
614 # undef timegm
615 # if HAVE_RAW_DECL_TIMEGM
616 _GL_WARN_ON_USE (timegm, "timegm is unportable - "
617 "use gnulib module timegm for portability");
618 # endif
619 # endif
620
621 /* Encourage applications to avoid unsafe functions that can overrun
622 buffers when given outlandish struct tm values. Portable
623 applications should use strftime (or even sprintf) instead. */
624 # if defined GNULIB_POSIXCHECK
625 # undef asctime
626 # if HAVE_RAW_DECL_ASCTIME
627 _GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
628 "better use strftime (or even sprintf) instead");
629 # endif
630 # endif
631 # if defined GNULIB_POSIXCHECK
632 # undef asctime_r
633 # if HAVE_RAW_DECL_ASCTIME_R
634 _GL_WARN_ON_USE (asctime_r, "asctime_r can overrun buffers in some cases - "
635 "better use strftime (or even sprintf) instead");
636 # endif
637 # endif
638 # if defined GNULIB_POSIXCHECK
639 # undef ctime
640 # if HAVE_RAW_DECL_CTIME
641 _GL_WARN_ON_USE (ctime, "ctime can overrun buffers in some cases - "
642 "better use strftime (or even sprintf) instead");
643 # endif
644 # endif
645 # if defined GNULIB_POSIXCHECK
646 # undef ctime_r
647 # if HAVE_RAW_DECL_CTIME_R
648 _GL_WARN_ON_USE (ctime_r, "ctime_r can overrun buffers in some cases - "
649 "better use strftime (or even sprintf) instead");
650 # endif
651 # endif
652
653 #endif