5abbdad4d6a81d9332b24be5b64adbf9e03e64b1
[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-2011 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, write to the Free Software Foundation,
19    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
20
21 #if __GNUC__ >= 3
22 @PRAGMA_SYSTEM_HEADER@
23 #endif
24 @PRAGMA_COLUMNS@
25
26 /* Don't get in the way of glibc when it includes time.h merely to
27    declare a few standard symbols, rather than to declare all the
28    symbols.  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 _GL_TIME_H)
34
35 # @INCLUDE_NEXT@ @NEXT_TIME_H@
36
37 #else
38
39 # define _GL_TIME_H
40
41 # @INCLUDE_NEXT@ @NEXT_TIME_H@
42
43 /* NetBSD 5.0 mis-defines NULL.  */
44 # include <stddef.h>
45
46 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
47
48 /* The definition of _GL_ARG_NONNULL is copied here.  */
49
50 /* The definition of _GL_WARN_ON_USE is copied here.  */
51
52 /* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3).
53    Or they define it with the wrong member names or define it in <sys/time.h>
54    (e.g., FreeBSD circa 1997).  Stock Mingw does not define it, but the
55    pthreads-win32 library defines it in <pthread.h>.  */
56 # if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@
57 #  if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
58 #   include <sys/time.h>
59 #  elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
60 #   include <pthread.h>
61 /* The pthreads-win32 <pthread.h> also defines a couple of broken macros.  */
62 #   undef asctime_r
63 #   undef ctime_r
64 #   undef gmtime_r
65 #   undef localtime_r
66 #   undef rand_r
67 #   undef strtok_r
68 #  else
69
70 #   ifdef __cplusplus
71 extern "C" {
72 #   endif
73
74 #   if !GNULIB_defined_struct_timespec
75 #    undef timespec
76 #    define timespec rpl_timespec
77 struct timespec
78 {
79   time_t tv_sec;
80   long int tv_nsec;
81 };
82 #    define GNULIB_defined_struct_timespec 1
83 #   endif
84
85 #   ifdef __cplusplus
86 }
87 #   endif
88
89 #  endif
90 # endif
91
92 # if !GNULIB_defined_struct_time_t_must_be_integral
93 /* Per http://austingroupbugs.net/view.php?id=327, POSIX requires
94    time_t to be an integer type, even though C99 permits floating
95    point.  We don't know of any implementation that uses floating
96    point, and it is much easier to write code that doesn't have to
97    worry about that corner case, so we force the issue.  */
98 struct __time_t_must_be_integral {
99   unsigned int __floating_time_t_unsupported : (time_t) 1;
100 };
101 #  define GNULIB_defined_struct_time_t_must_be_integral 1
102 # endif
103
104 /* Sleep for at least RQTP seconds unless interrupted,  If interrupted,
105    return -1 and store the remaining time into RMTP.  See
106    <http://www.opengroup.org/susv3xsh/nanosleep.html>.  */
107 # if @GNULIB_NANOSLEEP@
108 #  if @REPLACE_NANOSLEEP@
109 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
110 #    define nanosleep rpl_nanosleep
111 #   endif
112 _GL_FUNCDECL_RPL (nanosleep, int,
113                   (struct timespec const *__rqtp, struct timespec *__rmtp)
114                   _GL_ARG_NONNULL ((1)));
115 _GL_CXXALIAS_RPL (nanosleep, int,
116                   (struct timespec const *__rqtp, struct timespec *__rmtp));
117 #  else
118 #   if ! @HAVE_NANOSLEEP@
119 _GL_FUNCDECL_SYS (nanosleep, int,
120                   (struct timespec const *__rqtp, struct timespec *__rmtp)
121                   _GL_ARG_NONNULL ((1)));
122 #   endif
123 _GL_CXXALIAS_SYS (nanosleep, int,
124                   (struct timespec const *__rqtp, struct timespec *__rmtp));
125 #  endif
126 _GL_CXXALIASWARN (nanosleep);
127 # endif
128
129 /* Return the 'time_t' representation of TP and normalize TP.  */
130 # if @GNULIB_MKTIME@
131 #  if @REPLACE_MKTIME@
132 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
133 #    define mktime rpl_mktime
134 #   endif
135 _GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1)));
136 _GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
137 #  else
138 _GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
139 #  endif
140 _GL_CXXALIASWARN (mktime);
141 # endif
142
143 /* Convert TIMER to RESULT, assuming local time and UTC respectively.  See
144    <http://www.opengroup.org/susv3xsh/localtime_r.html> and
145    <http://www.opengroup.org/susv3xsh/gmtime_r.html>.  */
146 # if @GNULIB_TIME_R@
147 #  if @REPLACE_LOCALTIME_R@
148 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
149 #    undef localtime_r
150 #    define localtime_r rpl_localtime_r
151 #   endif
152 _GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
153                                              struct tm *restrict __result)
154                                             _GL_ARG_NONNULL ((1, 2)));
155 _GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
156                                              struct tm *restrict __result));
157 #  else
158 #   if ! @HAVE_DECL_LOCALTIME_R@
159 _GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
160                                              struct tm *restrict __result)
161                                             _GL_ARG_NONNULL ((1, 2)));
162 #   endif
163 _GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
164                                              struct tm *restrict __result));
165 #  endif
166 #  if @HAVE_DECL_LOCALTIME_R@
167 _GL_CXXALIASWARN (localtime_r);
168 #  endif
169 #  if @REPLACE_LOCALTIME_R@
170 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
171 #    undef gmtime_r
172 #    define gmtime_r rpl_gmtime_r
173 #   endif
174 _GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
175                                           struct tm *restrict __result)
176                                          _GL_ARG_NONNULL ((1, 2)));
177 _GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
178                                           struct tm *restrict __result));
179 #  else
180 #   if ! @HAVE_DECL_LOCALTIME_R@
181 _GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
182                                           struct tm *restrict __result)
183                                          _GL_ARG_NONNULL ((1, 2)));
184 #   endif
185 _GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
186                                           struct tm *restrict __result));
187 #  endif
188 #  if @HAVE_DECL_LOCALTIME_R@
189 _GL_CXXALIASWARN (gmtime_r);
190 #  endif
191 # endif
192
193 /* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
194    the resulting broken-down time into TM.  See
195    <http://www.opengroup.org/susv3xsh/strptime.html>.  */
196 # if @GNULIB_STRPTIME@
197 #  if ! @HAVE_STRPTIME@
198 _GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
199                                      char const *restrict __format,
200                                      struct tm *restrict __tm)
201                                     _GL_ARG_NONNULL ((1, 2, 3)));
202 #  endif
203 _GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
204                                      char const *restrict __format,
205                                      struct tm *restrict __tm));
206 _GL_CXXALIASWARN (strptime);
207 # endif
208
209 /* Convert TM to a time_t value, assuming UTC.  */
210 # if @GNULIB_TIMEGM@
211 #  if @REPLACE_TIMEGM@
212 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
213 #    undef timegm
214 #    define timegm rpl_timegm
215 #   endif
216 _GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
217 _GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
218 #  else
219 #   if ! @HAVE_TIMEGM@
220 _GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
221 #   endif
222 _GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
223 #  endif
224 _GL_CXXALIASWARN (timegm);
225 # endif
226
227 /* Encourage applications to avoid unsafe functions that can overrun
228    buffers when given outlandish struct tm values.  Portable
229    applications should use strftime (or even sprintf) instead.  */
230 # if defined GNULIB_POSIXCHECK
231 #  undef asctime
232 _GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
233                  "better use strftime (or even sprintf) instead");
234 # endif
235 # if defined GNULIB_POSIXCHECK
236 #  undef asctime_r
237 _GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - "
238                  "better use strftime (or even sprintf) instead");
239 # endif
240 # if defined GNULIB_POSIXCHECK
241 #  undef ctime
242 _GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - "
243                  "better use strftime (or even sprintf) instead");
244 # endif
245 # if defined GNULIB_POSIXCHECK
246 #  undef ctime_r
247 _GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - "
248                  "better use strftime (or even sprintf) instead");
249 # endif
250
251 #endif