7dcac1d3ced8ccdfa4f81d26508c48ab7b66bed4
[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-2013 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 does not define it, but the
54    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 /* The pthreads-win32 <pthread.h> also defines a couple of broken macros.  */
61 #   undef asctime_r
62 #   undef ctime_r
63 #   undef gmtime_r
64 #   undef localtime_r
65 #   undef rand_r
66 #   undef strtok_r
67 #  else
68
69 #   ifdef __cplusplus
70 extern "C" {
71 #   endif
72
73 #   if !GNULIB_defined_struct_timespec
74 #    undef timespec
75 #    define timespec rpl_timespec
76 struct timespec
77 {
78   time_t tv_sec;
79   long int tv_nsec;
80 };
81 #    define GNULIB_defined_struct_timespec 1
82 #   endif
83
84 #   ifdef __cplusplus
85 }
86 #   endif
87
88 #  endif
89 # endif
90
91 # if !GNULIB_defined_struct_time_t_must_be_integral
92 /* Per http://austingroupbugs.net/view.php?id=327, POSIX requires
93    time_t to be an integer type, even though C99 permits floating
94    point.  We don't know of any implementation that uses floating
95    point, and it is much easier to write code that doesn't have to
96    worry about that corner case, so we force the issue.  */
97 struct __time_t_must_be_integral {
98   unsigned int __floating_time_t_unsupported : (time_t) 1;
99 };
100 #  define GNULIB_defined_struct_time_t_must_be_integral 1
101 # endif
102
103 /* Sleep for at least RQTP seconds unless interrupted,  If interrupted,
104    return -1 and store the remaining time into RMTP.  See
105    <http://www.opengroup.org/susv3xsh/nanosleep.html>.  */
106 # if @GNULIB_NANOSLEEP@
107 #  if @REPLACE_NANOSLEEP@
108 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
109 #    define nanosleep rpl_nanosleep
110 #   endif
111 _GL_FUNCDECL_RPL (nanosleep, int,
112                   (struct timespec const *__rqtp, struct timespec *__rmtp)
113                   _GL_ARG_NONNULL ((1)));
114 _GL_CXXALIAS_RPL (nanosleep, int,
115                   (struct timespec const *__rqtp, struct timespec *__rmtp));
116 #  else
117 #   if ! @HAVE_NANOSLEEP@
118 _GL_FUNCDECL_SYS (nanosleep, int,
119                   (struct timespec const *__rqtp, struct timespec *__rmtp)
120                   _GL_ARG_NONNULL ((1)));
121 #   endif
122 _GL_CXXALIAS_SYS (nanosleep, int,
123                   (struct timespec const *__rqtp, struct timespec *__rmtp));
124 #  endif
125 _GL_CXXALIASWARN (nanosleep);
126 # endif
127
128 /* Return the 'time_t' representation of TP and normalize TP.  */
129 # if @GNULIB_MKTIME@
130 #  if @REPLACE_MKTIME@
131 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
132 #    define mktime rpl_mktime
133 #   endif
134 _GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1)));
135 _GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
136 #  else
137 _GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
138 #  endif
139 _GL_CXXALIASWARN (mktime);
140 # endif
141
142 /* Convert TIMER to RESULT, assuming local time and UTC respectively.  See
143    <http://www.opengroup.org/susv3xsh/localtime_r.html> and
144    <http://www.opengroup.org/susv3xsh/gmtime_r.html>.  */
145 # if @GNULIB_TIME_R@
146 #  if @REPLACE_LOCALTIME_R@
147 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
148 #    undef localtime_r
149 #    define localtime_r rpl_localtime_r
150 #   endif
151 _GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
152                                              struct tm *restrict __result)
153                                             _GL_ARG_NONNULL ((1, 2)));
154 _GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
155                                              struct tm *restrict __result));
156 #  else
157 #   if ! @HAVE_DECL_LOCALTIME_R@
158 _GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
159                                              struct tm *restrict __result)
160                                             _GL_ARG_NONNULL ((1, 2)));
161 #   endif
162 _GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
163                                              struct tm *restrict __result));
164 #  endif
165 #  if @HAVE_DECL_LOCALTIME_R@
166 _GL_CXXALIASWARN (localtime_r);
167 #  endif
168 #  if @REPLACE_LOCALTIME_R@
169 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
170 #    undef gmtime_r
171 #    define gmtime_r rpl_gmtime_r
172 #   endif
173 _GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
174                                           struct tm *restrict __result)
175                                          _GL_ARG_NONNULL ((1, 2)));
176 _GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
177                                           struct tm *restrict __result));
178 #  else
179 #   if ! @HAVE_DECL_LOCALTIME_R@
180 _GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
181                                           struct tm *restrict __result)
182                                          _GL_ARG_NONNULL ((1, 2)));
183 #   endif
184 _GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
185                                           struct tm *restrict __result));
186 #  endif
187 #  if @HAVE_DECL_LOCALTIME_R@
188 _GL_CXXALIASWARN (gmtime_r);
189 #  endif
190 # endif
191
192 /* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
193    the resulting broken-down time into TM.  See
194    <http://www.opengroup.org/susv3xsh/strptime.html>.  */
195 # if @GNULIB_STRPTIME@
196 #  if ! @HAVE_STRPTIME@
197 _GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
198                                      char const *restrict __format,
199                                      struct tm *restrict __tm)
200                                     _GL_ARG_NONNULL ((1, 2, 3)));
201 #  endif
202 _GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
203                                      char const *restrict __format,
204                                      struct tm *restrict __tm));
205 _GL_CXXALIASWARN (strptime);
206 # endif
207
208 /* Convert TM to a time_t value, assuming UTC.  */
209 # if @GNULIB_TIMEGM@
210 #  if @REPLACE_TIMEGM@
211 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
212 #    undef timegm
213 #    define timegm rpl_timegm
214 #   endif
215 _GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
216 _GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
217 #  else
218 #   if ! @HAVE_TIMEGM@
219 _GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
220 #   endif
221 _GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
222 #  endif
223 _GL_CXXALIASWARN (timegm);
224 # endif
225
226 /* Encourage applications to avoid unsafe functions that can overrun
227    buffers when given outlandish struct tm values.  Portable
228    applications should use strftime (or even sprintf) instead.  */
229 # if defined GNULIB_POSIXCHECK
230 #  undef asctime
231 _GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
232                  "better use strftime (or even sprintf) instead");
233 # endif
234 # if defined GNULIB_POSIXCHECK
235 #  undef asctime_r
236 _GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - "
237                  "better use strftime (or even sprintf) instead");
238 # endif
239 # if defined GNULIB_POSIXCHECK
240 #  undef ctime
241 _GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - "
242                  "better use strftime (or even sprintf) instead");
243 # endif
244 # if defined GNULIB_POSIXCHECK
245 #  undef ctime_r
246 _GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - "
247                  "better use strftime (or even sprintf) instead");
248 # endif
249
250 #endif