summaryrefslogtreecommitdiff
path: root/tests/time.in.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/time.in.h')
-rw-r--r--tests/time.in.h143
1 files changed, 138 insertions, 5 deletions
diff --git a/tests/time.in.h b/tests/time.in.h
index 6aa67498..df99c8ab 100644
--- a/tests/time.in.h
+++ b/tests/time.in.h
@@ -1,6 +1,6 @@
/* A more-standard <time.h>.
- Copyright (C) 2007-2022 Free Software Foundation, Inc.
+ Copyright (C) 2007-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -20,6 +20,13 @@
#endif
@PRAGMA_COLUMNS@
+/* This file uses #include_next of a system file that defines time_t.
+ For the 'year2038' module to work right, <config.h> needs to have been
+ included before. */
+#if !_GL_CONFIG_H_INCLUDED
+ #error "Please include config.h first."
+#endif
+
/* Don't get in the way of glibc when it includes time.h merely to
declare a few standard symbols, rather than to declare all the
symbols. (However, skip this for MinGW as it treats __need_time_t
@@ -45,6 +52,12 @@
# @INCLUDE_NEXT@ @NEXT_TIME_H@
+/* This file uses _GL_ATTRIBUTE_DEPRECATED, GNULIB_POSIXCHECK,
+ HAVE_RAW_DECL_*. */
+# if !_GL_CONFIG_H_INCLUDED
+# error "Please include config.h first."
+# endif
+
/* NetBSD 5.0 mis-defines NULL. */
# include <stddef.h>
@@ -112,23 +125,79 @@ struct __time_t_must_be_integral {
/* Set *TS to the current time, and return BASE.
Upon failure, return 0. */
# if @GNULIB_TIMESPEC_GET@
-# if ! @HAVE_TIMESPEC_GET@
+# if @REPLACE_TIMESPEC_GET@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef timespec_get
+# define timespec_get rpl_timespec_get
+# endif
+_GL_FUNCDECL_RPL (timespec_get, int, (struct timespec *ts, int base)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (timespec_get, int, (struct timespec *ts, int base));
+# else
+# if !@HAVE_TIMESPEC_GET@
_GL_FUNCDECL_SYS (timespec_get, int, (struct timespec *ts, int base)
_GL_ARG_NONNULL ((1)));
-# endif
+# endif
_GL_CXXALIAS_SYS (timespec_get, int, (struct timespec *ts, int base));
+# endif
+# if __GLIBC__ >= 2
_GL_CXXALIASWARN (timespec_get);
+# endif
+# elif defined GNULIB_POSIXCHECK
+# undef timespec_get
+# if HAVE_RAW_DECL_TIMESPEC_GET
+_GL_WARN_ON_USE (timespec_get, "timespec_get is unportable - "
+ "use gnulib module timespec_get for portability");
+# endif
# endif
/* Set *TS to the current time resolution, and return BASE.
Upon failure, return 0. */
# if @GNULIB_TIMESPEC_GETRES@
-# if ! @HAVE_TIMESPEC_GETRES@
+# if @REPLACE_TIMESPEC_GETRES@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef timespec_getres
+# define timespec_getres rpl_timespec_getres
+# endif
+_GL_FUNCDECL_RPL (timespec_getres, int, (struct timespec *ts, int base)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (timespec_getres, int, (struct timespec *ts, int base));
+# else
+# if !@HAVE_TIMESPEC_GETRES@
_GL_FUNCDECL_SYS (timespec_getres, int, (struct timespec *ts, int base)
_GL_ARG_NONNULL ((1)));
-# endif
+# endif
_GL_CXXALIAS_SYS (timespec_getres, int, (struct timespec *ts, int base));
+# endif
_GL_CXXALIASWARN (timespec_getres);
+# elif defined GNULIB_POSIXCHECK
+# undef timespec_getres
+# if HAVE_RAW_DECL_TIMESPEC_GETRES
+_GL_WARN_ON_USE (timespec_getres, "timespec_getres is unportable - "
+ "use gnulib module timespec_getres for portability");
+# endif
+# endif
+
+/* Return the number of seconds that have elapsed since the Epoch. */
+# if @GNULIB_TIME@
+# if @REPLACE_TIME@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define time rpl_time
+# endif
+_GL_FUNCDECL_RPL (time, time_t, (time_t *__tp));
+_GL_CXXALIAS_RPL (time, time_t, (time_t *__tp));
+# else
+_GL_CXXALIAS_SYS (time, time_t, (time_t *__tp));
+# endif
+# if __GLIBC__ >= 2
+_GL_CXXALIASWARN (time);
+# endif
+# elif defined GNULIB_POSIXCHECK
+# undef time
+# if HAVE_RAW_DECL_TIME
+_GL_WARN_ON_USE (time, "time has consistency problems - "
+ "use gnulib module time for portability");
+# endif
# endif
/* Sleep for at least RQTP seconds unless interrupted, If interrupted,
@@ -154,6 +223,12 @@ _GL_CXXALIAS_SYS (nanosleep, int,
(struct timespec const *__rqtp, struct timespec *__rmtp));
# endif
_GL_CXXALIASWARN (nanosleep);
+# elif defined GNULIB_POSIXCHECK
+# undef nanosleep
+# if HAVE_RAW_DECL_NANOSLEEP
+_GL_WARN_ON_USE (nanosleep, "nanosleep is unportable - "
+ "use gnulib module nanosleep for portability");
+# endif
# endif
/* Initialize time conversion information. */
@@ -189,6 +264,12 @@ _GL_CXXALIAS_MDA (tzset, void, (void));
_GL_CXXALIAS_SYS (tzset, void, (void));
# endif
_GL_CXXALIASWARN (tzset);
+# elif defined GNULIB_POSIXCHECK
+# undef tzset
+# if HAVE_RAW_DECL_TZSET
+_GL_WARN_ON_USE (tzset, "tzset has portability problems - "
+ "use gnulib module tzset for portability");
+# endif
# endif
/* Return the 'time_t' representation of TP and normalize TP. */
@@ -205,6 +286,12 @@ _GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
# if __GLIBC__ >= 2
_GL_CXXALIASWARN (mktime);
# endif
+# elif defined GNULIB_POSIXCHECK
+# undef mktime
+# if HAVE_RAW_DECL_MKTIME
+_GL_WARN_ON_USE (mktime, "mktime has portability problems - "
+ "use gnulib module mktime for portability");
+# endif
# endif
/* Convert TIMER to RESULT, assuming local time and UTC respectively. See
@@ -255,6 +342,17 @@ _GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
# if @HAVE_DECL_LOCALTIME_R@
_GL_CXXALIASWARN (gmtime_r);
# endif
+# elif defined GNULIB_POSIXCHECK
+# undef localtime_r
+# if HAVE_RAW_DECL_LOCALTIME_R
+_GL_WARN_ON_USE (localtime_r, "localtime_r is unportable - "
+ "use gnulib module time_r for portability");
+# endif
+# undef gmtime_r
+# if HAVE_RAW_DECL_GMTIME_R
+_GL_WARN_ON_USE (gmtime_r, "gmtime_r is unportable - "
+ "use gnulib module time_r for portability");
+# endif
# endif
/* Convert TIMER to RESULT, assuming local time and UTC respectively. See
@@ -275,6 +373,12 @@ _GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer));
# if __GLIBC__ >= 2
_GL_CXXALIASWARN (localtime);
# endif
+# elif defined GNULIB_POSIXCHECK
+# undef localtime
+# if HAVE_RAW_DECL_LOCALTIME
+_GL_WARN_ON_USE (localtime, "localtime has portability problems - "
+ "use gnulib module localtime for portability");
+# endif
# endif
# if 0 || @REPLACE_GMTIME@
@@ -306,6 +410,12 @@ _GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
char const *restrict __format,
struct tm *restrict __tm));
_GL_CXXALIASWARN (strptime);
+# elif defined GNULIB_POSIXCHECK
+# undef strptime
+# if HAVE_RAW_DECL_STRPTIME
+_GL_WARN_ON_USE (strptime, "strptime is unportable - "
+ "use gnulib module strptime for portability");
+# endif
# endif
/* Convert *TP to a date and time string. See
@@ -315,6 +425,9 @@ _GL_CXXALIASWARN (strptime);
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define ctime rpl_ctime
# endif
+# ifndef __cplusplus
+_GL_ATTRIBUTE_DEPRECATED
+# endif
_GL_FUNCDECL_RPL (ctime, char *, (time_t const *__tp)
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (ctime, char *, (time_t const *__tp));
@@ -324,6 +437,8 @@ _GL_CXXALIAS_SYS (ctime, char *, (time_t const *__tp));
# if __GLIBC__ >= 2
_GL_CXXALIASWARN (ctime);
# endif
+# elif defined GNULIB_POSIXCHECK
+/* No need to warn about portability, as a more serious warning is below. */
# endif
/* Convert *TP to a date and time string. See
@@ -348,6 +463,12 @@ _GL_CXXALIAS_SYS (strftime, size_t,
# if __GLIBC__ >= 2
_GL_CXXALIASWARN (strftime);
# endif
+# elif defined GNULIB_POSIXCHECK
+# undef strftime
+# if HAVE_RAW_DECL_STRFTIME
+_GL_WARN_ON_USE (strftime, "strftime has portability problems - "
+ "use gnulib module strftime-fixes for portability");
+# endif
# endif
# if defined _GNU_SOURCE && @GNULIB_TIME_RZ@ && ! @HAVE_TIMEZONE_T@
@@ -422,7 +543,15 @@ _GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
# endif
_GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
# endif
+# if __GLIBC__ >= 2
_GL_CXXALIASWARN (timegm);
+# endif
+# elif defined GNULIB_POSIXCHECK
+# undef timegm
+# if HAVE_RAW_DECL_TIMEGM
+_GL_WARN_ON_USE (timegm, "timegm is unportable - "
+ "use gnulib module timegm for portability");
+# endif
# endif
/* Encourage applications to avoid unsafe functions that can overrun
@@ -430,8 +559,10 @@ _GL_CXXALIASWARN (timegm);
applications should use strftime (or even sprintf) instead. */
# if defined GNULIB_POSIXCHECK
# undef asctime
+# if HAVE_RAW_DECL_ASCTIME
_GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
"better use strftime (or even sprintf) instead");
+# endif
# endif
# if defined GNULIB_POSIXCHECK
# undef asctime_r
@@ -442,8 +573,10 @@ _GL_WARN_ON_USE (asctime_r, "asctime_r can overrun buffers in some cases - "
# endif
# if defined GNULIB_POSIXCHECK
# undef ctime
+# if HAVE_RAW_DECL_CTIME
_GL_WARN_ON_USE (ctime, "ctime can overrun buffers in some cases - "
"better use strftime (or even sprintf) instead");
+# endif
# endif
# if defined GNULIB_POSIXCHECK
# undef ctime_r