Import upstream version 1.28
[debian/tar] / gnu / time.in.h
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-2014 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 <http://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.  Also, Solaris 8 <time.h> eventually includes itself
28    recursively; if that is happening, just include the system <time.h>
29    without adding our own declarations.  */
30 #if (defined __need_time_t || defined __need_clock_t \
31      || defined __need_timespec \
32      || defined _@GUARD_PREFIX@_TIME_H)
33
34 # @INCLUDE_NEXT@ @NEXT_TIME_H@
35
36 #else
37
38 # define _@GUARD_PREFIX@_TIME_H
39
40 # @INCLUDE_NEXT@ @NEXT_TIME_H@
41
42 /* NetBSD 5.0 mis-defines NULL.  */
43 # include <stddef.h>
44
45 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
46
47 /* The definition of _GL_ARG_NONNULL is copied here.  */
48
49 /* The definition of _GL_WARN_ON_USE is copied here.  */
50
51 /* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3).
52    Or they define it with the wrong member names or define it in <sys/time.h>
53    (e.g., FreeBSD circa 1997).  Stock Mingw prior to 3.0 does not define it,
54    but the pthreads-win32 library defines it in <pthread.h>.  */
55 # if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@
56 #  if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
57 #   include <sys/time.h>
58 #  elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
59 #   include <pthread.h>
60 #  else
61
62 #   ifdef __cplusplus
63 extern "C" {
64 #   endif
65
66 #   if !GNULIB_defined_struct_timespec
67 #    undef timespec
68 #    define timespec rpl_timespec
69 struct timespec
70 {
71   time_t tv_sec;
72   long int tv_nsec;
73 };
74 #    define GNULIB_defined_struct_timespec 1
75 #   endif
76
77 #   ifdef __cplusplus
78 }
79 #   endif
80
81 #  endif
82 # endif
83
84 # if !GNULIB_defined_struct_time_t_must_be_integral
85 /* Per http://austingroupbugs.net/view.php?id=327, POSIX requires
86    time_t to be an integer type, even though C99 permits floating
87    point.  We don't know of any implementation that uses floating
88    point, and it is much easier to write code that doesn't have to
89    worry about that corner case, so we force the issue.  */
90 struct __time_t_must_be_integral {
91   unsigned int __floating_time_t_unsupported : (time_t) 1;
92 };
93 #  define GNULIB_defined_struct_time_t_must_be_integral 1
94 # endif
95
96 /* Sleep for at least RQTP seconds unless interrupted,  If interrupted,
97    return -1 and store the remaining time into RMTP.  See
98    <http://www.opengroup.org/susv3xsh/nanosleep.html>.  */
99 # if @GNULIB_NANOSLEEP@
100 #  if @REPLACE_NANOSLEEP@
101 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
102 #    define nanosleep rpl_nanosleep
103 #   endif
104 _GL_FUNCDECL_RPL (nanosleep, int,
105                   (struct timespec const *__rqtp, struct timespec *__rmtp)
106                   _GL_ARG_NONNULL ((1)));
107 _GL_CXXALIAS_RPL (nanosleep, int,
108                   (struct timespec const *__rqtp, struct timespec *__rmtp));
109 #  else
110 #   if ! @HAVE_NANOSLEEP@
111 _GL_FUNCDECL_SYS (nanosleep, int,
112                   (struct timespec const *__rqtp, struct timespec *__rmtp)
113                   _GL_ARG_NONNULL ((1)));
114 #   endif
115 _GL_CXXALIAS_SYS (nanosleep, int,
116                   (struct timespec const *__rqtp, struct timespec *__rmtp));
117 #  endif
118 _GL_CXXALIASWARN (nanosleep);
119 # endif
120
121 /* Return the 'time_t' representation of TP and normalize TP.  */
122 # if @GNULIB_MKTIME@
123 #  if @REPLACE_MKTIME@
124 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
125 #    define mktime rpl_mktime
126 #   endif
127 _GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1)));
128 _GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
129 #  else
130 _GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
131 #  endif
132 _GL_CXXALIASWARN (mktime);
133 # endif
134
135 /* Convert TIMER to RESULT, assuming local time and UTC respectively.  See
136    <http://www.opengroup.org/susv3xsh/localtime_r.html> and
137    <http://www.opengroup.org/susv3xsh/gmtime_r.html>.  */
138 # if @GNULIB_TIME_R@
139 #  if @REPLACE_LOCALTIME_R@
140 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
141 #    undef localtime_r
142 #    define localtime_r rpl_localtime_r
143 #   endif
144 _GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
145                                              struct tm *restrict __result)
146                                             _GL_ARG_NONNULL ((1, 2)));
147 _GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
148                                              struct tm *restrict __result));
149 #  else
150 #   if ! @HAVE_DECL_LOCALTIME_R@
151 _GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
152                                              struct tm *restrict __result)
153                                             _GL_ARG_NONNULL ((1, 2)));
154 #   endif
155 _GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
156                                              struct tm *restrict __result));
157 #  endif
158 #  if @HAVE_DECL_LOCALTIME_R@
159 _GL_CXXALIASWARN (localtime_r);
160 #  endif
161 #  if @REPLACE_LOCALTIME_R@
162 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
163 #    undef gmtime_r
164 #    define gmtime_r rpl_gmtime_r
165 #   endif
166 _GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
167                                           struct tm *restrict __result)
168                                          _GL_ARG_NONNULL ((1, 2)));
169 _GL_CXXALIAS_RPL (gmtime_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 (gmtime_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 (gmtime_r, struct tm *, (time_t const *restrict __timer,
178                                           struct tm *restrict __result));
179 #  endif
180 #  if @HAVE_DECL_LOCALTIME_R@
181 _GL_CXXALIASWARN (gmtime_r);
182 #  endif
183 # endif
184
185 /* Convert TIMER to RESULT, assuming local time and UTC respectively.  See
186    <http://www.opengroup.org/susv3xsh/localtime.html> and
187    <http://www.opengroup.org/susv3xsh/gmtime.html>.  */
188 # if @GNULIB_GETTIMEOFDAY@
189 #  if @REPLACE_LOCALTIME@
190 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
191 #    undef localtime
192 #    define localtime rpl_localtime
193 #   endif
194 _GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer)
195                                           _GL_ARG_NONNULL ((1)));
196 _GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer));
197 #  else
198 _GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer));
199 #  endif
200 _GL_CXXALIASWARN (localtime);
201 # endif
202
203 # if @GNULIB_GETTIMEOFDAY@
204 #  if @REPLACE_GMTIME@
205 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
206 #    undef gmtime
207 #    define gmtime rpl_gmtime
208 #   endif
209 _GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer)
210                                        _GL_ARG_NONNULL ((1)));
211 _GL_CXXALIAS_RPL (gmtime, struct tm *, (time_t const *__timer));
212 #  else
213 _GL_CXXALIAS_SYS (gmtime, struct tm *, (time_t const *__timer));
214 #  endif
215 _GL_CXXALIASWARN (gmtime);
216 # endif
217
218 /* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
219    the resulting broken-down time into TM.  See
220    <http://www.opengroup.org/susv3xsh/strptime.html>.  */
221 # if @GNULIB_STRPTIME@
222 #  if ! @HAVE_STRPTIME@
223 _GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
224                                      char const *restrict __format,
225                                      struct tm *restrict __tm)
226                                     _GL_ARG_NONNULL ((1, 2, 3)));
227 #  endif
228 _GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
229                                      char const *restrict __format,
230                                      struct tm *restrict __tm));
231 _GL_CXXALIASWARN (strptime);
232 # endif
233
234 /* Convert TM to a time_t value, assuming UTC.  */
235 # if @GNULIB_TIMEGM@
236 #  if @REPLACE_TIMEGM@
237 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
238 #    undef timegm
239 #    define timegm rpl_timegm
240 #   endif
241 _GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
242 _GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
243 #  else
244 #   if ! @HAVE_TIMEGM@
245 _GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
246 #   endif
247 _GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
248 #  endif
249 _GL_CXXALIASWARN (timegm);
250 # endif
251
252 /* Encourage applications to avoid unsafe functions that can overrun
253    buffers when given outlandish struct tm values.  Portable
254    applications should use strftime (or even sprintf) instead.  */
255 # if defined GNULIB_POSIXCHECK
256 #  undef asctime
257 _GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
258                  "better use strftime (or even sprintf) instead");
259 # endif
260 # if defined GNULIB_POSIXCHECK
261 #  undef asctime_r
262 _GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - "
263                  "better use strftime (or even sprintf) instead");
264 # endif
265 # if defined GNULIB_POSIXCHECK
266 #  undef ctime
267 _GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - "
268                  "better use strftime (or even sprintf) instead");
269 # endif
270 # if defined GNULIB_POSIXCHECK
271 #  undef ctime_r
272 _GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - "
273                  "better use strftime (or even sprintf) instead");
274 # endif
275
276 #endif