Debian Codegraph @

lib/time.in.h

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