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