1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* A more-standard <time.h>.
4 
5    Copyright (C) 2007-2019 Free Software Foundation, Inc.
6 
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 3, or (at your option)
10    any later version.
11 
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16 
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, see <https://www.gnu.org/licenses/>.  */
19 
20 #if __GNUC__ >= 3
21 @PRAGMA_SYSTEM_HEADER@
22 #endif
23 @PRAGMA_COLUMNS@
24 
25 /* Don't get in the way of glibc when it includes time.h merely to
26    declare a few standard symbols, rather than to declare all the
27    symbols.  (However, skip this for MinGW as it treats __need_time_t
28    incompatibly.)  Also, Solaris 8 <time.h> eventually includes itself
29    recursively; if that is happening, just include the system <time.h>
30    without adding our own declarations.  */
31 #if (((defined __need_time_t || defined __need_clock_t \
32        || defined __need_timespec)                     \
33       && !defined __MINGW32__)                         \
34      || defined _@GUARD_PREFIX@_TIME_H)
35 
36 # @INCLUDE_NEXT@ @NEXT_TIME_H@
37 
38 #else
39 
40 # define _@GUARD_PREFIX@_TIME_H
41 
42 # @INCLUDE_NEXT@ @NEXT_TIME_H@
43 
44 /* NetBSD 5.0 mis-defines NULL.  */
45 # include <stddef.h>
46 
47 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
48 
49 /* The definition of _GL_ARG_NONNULL is copied here.  */
50 
51 /* The definition of _GL_WARN_ON_USE is copied here.  */
52 
53 /* Some systems don't define struct timespec (e.g., AIX 4.1).
54    Or they define it with the wrong member names or define it in <sys/time.h>
55    (e.g., FreeBSD circa 1997).  Stock Mingw prior to 3.0 does not define it,
56    but the pthreads-win32 library defines it in <pthread.h>.  */
57 # if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@
58 #  if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
59 #   include <sys/time.h>
60 #  elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
61 #   include <pthread.h>
62 #  elif @UNISTD_H_DEFINES_STRUCT_TIMESPEC@
63 #   include <unistd.h>
64 #  else
65 
66 #   ifdef __cplusplus
67 extern "C" {
68 #   endif
69 
70 #   if !GNULIB_defined_struct_timespec
71 #    undef timespec
72 #    define timespec rpl_timespec
73 struct timespec
74 {
75   time_t tv_sec;
76   long int tv_nsec;
77 };
78 #    define GNULIB_defined_struct_timespec 1
79 #   endif
80 
81 #   ifdef __cplusplus
82 }
83 #   endif
84 
85 #  endif
86 # endif
87 
88 # if !GNULIB_defined_struct_time_t_must_be_integral
89 /* Per http://austingroupbugs.net/view.php?id=327, POSIX requires
90    time_t to be an integer type, even though C99 permits floating
91    point.  We don't know of any implementation that uses floating
92    point, and it is much easier to write code that doesn't have to
93    worry about that corner case, so we force the issue.  */
94 struct __time_t_must_be_integral {
95   unsigned int __floating_time_t_unsupported : (time_t) 1;
96 };
97 #  define GNULIB_defined_struct_time_t_must_be_integral 1
98 # endif
99 
100 /* Sleep for at least RQTP seconds unless interrupted,  If interrupted,
101    return -1 and store the remaining time into RMTP.  See
102    <http://www.opengroup.org/susv3xsh/nanosleep.html>.  */
103 # if @GNULIB_NANOSLEEP@
104 #  if @REPLACE_NANOSLEEP@
105 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
106 #    define nanosleep rpl_nanosleep
107 #   endif
108 _GL_FUNCDECL_RPL (nanosleep, int,
109                   (struct timespec const *__rqtp, struct timespec *__rmtp)
110                   _GL_ARG_NONNULL ((1)));
111 _GL_CXXALIAS_RPL (nanosleep, int,
112                   (struct timespec const *__rqtp, struct timespec *__rmtp));
113 #  else
114 #   if ! @HAVE_NANOSLEEP@
115 _GL_FUNCDECL_SYS (nanosleep, int,
116                   (struct timespec const *__rqtp, struct timespec *__rmtp)
117                   _GL_ARG_NONNULL ((1)));
118 #   endif
119 _GL_CXXALIAS_SYS (nanosleep, int,
120                   (struct timespec const *__rqtp, struct timespec *__rmtp));
121 #  endif
122 _GL_CXXALIASWARN (nanosleep);
123 # endif
124 
125 /* Initialize time conversion information.  */
126 # if @GNULIB_TZSET@
127 #  if @REPLACE_TZSET@
128 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
129 #    undef tzset
130 #    define tzset rpl_tzset
131 #   endif
132 _GL_FUNCDECL_RPL (tzset, void, (void));
133 _GL_CXXALIAS_RPL (tzset, void, (void));
134 #  else
135 #   if ! @HAVE_TZSET@
136 _GL_FUNCDECL_SYS (tzset, void, (void));
137 #   endif
138 _GL_CXXALIAS_SYS (tzset, void, (void));
139 #  endif
140 _GL_CXXALIASWARN (tzset);
141 # endif
142 
143 /* Return the 'time_t' representation of TP and normalize TP.  */
144 # if @GNULIB_MKTIME@
145 #  if @REPLACE_MKTIME@
146 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
147 #    define mktime rpl_mktime
148 #   endif
149 _GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1)));
150 _GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
151 #  else
152 _GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
153 #  endif
154 _GL_CXXALIASWARN (mktime);
155 # endif
156 
157 /* Convert TIMER to RESULT, assuming local time and UTC respectively.  See
158    <http://www.opengroup.org/susv3xsh/localtime_r.html> and
159    <http://www.opengroup.org/susv3xsh/gmtime_r.html>.  */
160 # if @GNULIB_TIME_R@
161 #  if @REPLACE_LOCALTIME_R@
162 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
163 #    undef localtime_r
164 #    define localtime_r rpl_localtime_r
165 #   endif
166 _GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
167                                              struct tm *restrict __result)
168                                             _GL_ARG_NONNULL ((1, 2)));
169 _GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
170                                              struct tm *restrict __result));
171 #  else
172 #   if ! @HAVE_DECL_LOCALTIME_R@
173 _GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
174                                              struct tm *restrict __result)
175                                             _GL_ARG_NONNULL ((1, 2)));
176 #   endif
177 _GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
178                                              struct tm *restrict __result));
179 #  endif
180 #  if @HAVE_DECL_LOCALTIME_R@
181 _GL_CXXALIASWARN (localtime_r);
182 #  endif
183 #  if @REPLACE_LOCALTIME_R@
184 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
185 #    undef gmtime_r
186 #    define gmtime_r rpl_gmtime_r
187 #   endif
188 _GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
189                                           struct tm *restrict __result)
190                                          _GL_ARG_NONNULL ((1, 2)));
191 _GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
192                                           struct tm *restrict __result));
193 #  else
194 #   if ! @HAVE_DECL_LOCALTIME_R@
195 _GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
196                                           struct tm *restrict __result)
197                                          _GL_ARG_NONNULL ((1, 2)));
198 #   endif
199 _GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
200                                           struct tm *restrict __result));
201 #  endif
202 #  if @HAVE_DECL_LOCALTIME_R@
203 _GL_CXXALIASWARN (gmtime_r);
204 #  endif
205 # endif
206 
207 /* Convert TIMER to RESULT, assuming local time and UTC respectively.  See
208    <http://www.opengroup.org/susv3xsh/localtime.html> and
209    <http://www.opengroup.org/susv3xsh/gmtime.html>.  */
210 # if @GNULIB_LOCALTIME@ || @REPLACE_LOCALTIME@
211 #  if @REPLACE_LOCALTIME@
212 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
213 #    undef localtime
214 #    define localtime rpl_localtime
215 #   endif
216 _GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer)
217                                           _GL_ARG_NONNULL ((1)));
218 _GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer));
219 #  else
220 _GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer));
221 #  endif
222 _GL_CXXALIASWARN (localtime);
223 # endif
224 
225 # if 0 || @REPLACE_GMTIME@
226 #  if @REPLACE_GMTIME@
227 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
228 #    undef gmtime
229 #    define gmtime rpl_gmtime
230 #   endif
231 _GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer)
232                                        _GL_ARG_NONNULL ((1)));
233 _GL_CXXALIAS_RPL (gmtime, struct tm *, (time_t const *__timer));
234 #  else
235 _GL_CXXALIAS_SYS (gmtime, struct tm *, (time_t const *__timer));
236 #  endif
237 _GL_CXXALIASWARN (gmtime);
238 # endif
239 
240 /* Parse BUF as a timestamp, assuming FORMAT specifies its layout, and store
241    the resulting broken-down time into TM.  See
242    <http://www.opengroup.org/susv3xsh/strptime.html>.  */
243 # if @GNULIB_STRPTIME@
244 #  if ! @HAVE_STRPTIME@
245 _GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
246                                      char const *restrict __format,
247                                      struct tm *restrict __tm)
248                                     _GL_ARG_NONNULL ((1, 2, 3)));
249 #  endif
250 _GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
251                                      char const *restrict __format,
252                                      struct tm *restrict __tm));
253 _GL_CXXALIASWARN (strptime);
254 # endif
255 
256 /* Convert *TP to a date and time string.  See
257    <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ctime.html>.  */
258 # if @GNULIB_CTIME@
259 #  if @REPLACE_CTIME@
260 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
261 #    define ctime rpl_ctime
262 #   endif
263 _GL_FUNCDECL_RPL (ctime, char *, (time_t const *__tp)
264                                  _GL_ARG_NONNULL ((1)));
265 _GL_CXXALIAS_RPL (ctime, char *, (time_t const *__tp));
266 #  else
267 _GL_CXXALIAS_SYS (ctime, char *, (time_t const *__tp));
268 #  endif
269 _GL_CXXALIASWARN (ctime);
270 # endif
271 
272 /* Convert *TP to a date and time string.  See
273    <http://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html>.  */
274 # if @GNULIB_STRFTIME@
275 #  if @REPLACE_STRFTIME@
276 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
277 #    define strftime rpl_strftime
278 #   endif
279 _GL_FUNCDECL_RPL (strftime, size_t, (char *__buf, size_t __bufsize,
280                                      const char *__fmt, const struct tm *__tp)
281                                     _GL_ARG_NONNULL ((1, 3, 4)));
282 _GL_CXXALIAS_RPL (strftime, size_t, (char *__buf, size_t __bufsize,
283                                      const char *__fmt, const struct tm *__tp));
284 #  else
285 _GL_CXXALIAS_SYS (strftime, size_t, (char *__buf, size_t __bufsize,
286                                      const char *__fmt, const struct tm *__tp));
287 #  endif
288 _GL_CXXALIASWARN (strftime);
289 # endif
290 
291 # if defined _GNU_SOURCE && @GNULIB_TIME_RZ@ && ! @HAVE_TIMEZONE_T@
292 typedef struct tm_zone *timezone_t;
293 _GL_FUNCDECL_SYS (tzalloc, timezone_t, (char const *__name));
294 _GL_CXXALIAS_SYS (tzalloc, timezone_t, (char const *__name));
295 _GL_FUNCDECL_SYS (tzfree, void, (timezone_t __tz));
296 _GL_CXXALIAS_SYS (tzfree, void, (timezone_t __tz));
297 _GL_FUNCDECL_SYS (localtime_rz, struct tm *,
298                   (timezone_t __tz, time_t const *restrict __timer,
299                    struct tm *restrict __result) _GL_ARG_NONNULL ((2, 3)));
300 _GL_CXXALIAS_SYS (localtime_rz, struct tm *,
301                   (timezone_t __tz, time_t const *restrict __timer,
302                    struct tm *restrict __result));
303 _GL_FUNCDECL_SYS (mktime_z, time_t,
304                   (timezone_t __tz, struct tm *restrict __result)
305                   _GL_ARG_NONNULL ((2)));
306 _GL_CXXALIAS_SYS (mktime_z, time_t,
307                   (timezone_t __tz, struct tm *restrict __result));
308 # endif
309 
310 /* Convert TM to a time_t value, assuming UTC.  */
311 # if @GNULIB_TIMEGM@
312 #  if @REPLACE_TIMEGM@
313 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
314 #    undef timegm
315 #    define timegm rpl_timegm
316 #   endif
317 _GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
318 _GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
319 #  else
320 #   if ! @HAVE_TIMEGM@
321 _GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
322 #   endif
323 _GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
324 #  endif
325 _GL_CXXALIASWARN (timegm);
326 # endif
327 
328 /* Encourage applications to avoid unsafe functions that can overrun
329    buffers when given outlandish struct tm values.  Portable
330    applications should use strftime (or even sprintf) instead.  */
331 # if defined GNULIB_POSIXCHECK
332 #  undef asctime
333 _GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
334                  "better use strftime (or even sprintf) instead");
335 # endif
336 # if defined GNULIB_POSIXCHECK
337 #  undef asctime_r
338 _GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - "
339                  "better use strftime (or even sprintf) instead");
340 # endif
341 # if defined GNULIB_POSIXCHECK
342 #  undef ctime
343 _GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - "
344                  "better use strftime (or even sprintf) instead");
345 # endif
346 # if defined GNULIB_POSIXCHECK
347 #  undef ctime_r
348 _GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - "
349                  "better use strftime (or even sprintf) instead");
350 # endif
351 
352 #endif
353