]> git.cworth.org Git - tar/blob - gnu/time.in.h
Imported Upstream version 1.24
[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-2010 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 #   undef timespec
75 #   define timespec rpl_timespec
76 struct timespec
77 {
78   time_t tv_sec;
79   long int tv_nsec;
80 };
81
82 #   ifdef __cplusplus
83 }
84 #   endif
85
86 #  endif
87 # endif
88
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
98 /* Sleep for at least RQTP seconds unless interrupted,  If interrupted,
99    return -1 and store the remaining time into RMTP.  See
100    <http://www.opengroup.org/susv3xsh/nanosleep.html>.  */
101 # if @GNULIB_NANOSLEEP@
102 #  if @REPLACE_NANOSLEEP@
103 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
104 #    define nanosleep rpl_nanosleep
105 #   endif
106 _GL_FUNCDECL_RPL (nanosleep, int,
107                   (struct timespec const *__rqtp, struct timespec *__rmtp)
108                   _GL_ARG_NONNULL ((1)));
109 _GL_CXXALIAS_RPL (nanosleep, int,
110                   (struct timespec const *__rqtp, struct timespec *__rmtp));
111 #  else
112 #   if ! @HAVE_NANOSLEEP@
113 _GL_FUNCDECL_SYS (nanosleep, int,
114                   (struct timespec const *__rqtp, struct timespec *__rmtp)
115                   _GL_ARG_NONNULL ((1)));
116 #   endif
117 _GL_CXXALIAS_SYS (nanosleep, int,
118                   (struct timespec const *__rqtp, struct timespec *__rmtp));
119 #  endif
120 _GL_CXXALIASWARN (nanosleep);
121 # endif
122
123 /* Return the 'time_t' representation of TP and normalize TP.  */
124 # if @GNULIB_MKTIME@
125 #  if @REPLACE_MKTIME@
126 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
127 #    define mktime rpl_mktime
128 #   endif
129 _GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1)));
130 _GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
131 #  else
132 _GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
133 #  endif
134 _GL_CXXALIASWARN (mktime);
135 # endif
136
137 /* Convert TIMER to RESULT, assuming local time and UTC respectively.  See
138    <http://www.opengroup.org/susv3xsh/localtime_r.html> and
139    <http://www.opengroup.org/susv3xsh/gmtime_r.html>.  */
140 # if @GNULIB_TIME_R@
141 #  if @REPLACE_LOCALTIME_R@
142 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
143 #    undef localtime_r
144 #    define localtime_r rpl_localtime_r
145 #   endif
146 _GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
147                                              struct tm *restrict __result)
148                                             _GL_ARG_NONNULL ((1, 2)));
149 _GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
150                                              struct tm *restrict __result));
151 #  else
152 #   if ! @HAVE_LOCALTIME_R@
153 _GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
154                                              struct tm *restrict __result)
155                                             _GL_ARG_NONNULL ((1, 2)));
156 #   endif
157 _GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
158                                              struct tm *restrict __result));
159 #  endif
160 _GL_CXXALIASWARN (localtime_r);
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_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 _GL_CXXALIASWARN (gmtime_r);
181 # endif
182
183 /* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
184    the resulting broken-down time into TM.  See
185    <http://www.opengroup.org/susv3xsh/strptime.html>.  */
186 # if @GNULIB_STRPTIME@
187 #  if ! @HAVE_STRPTIME@
188 _GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
189                                      char const *restrict __format,
190                                      struct tm *restrict __tm)
191                                     _GL_ARG_NONNULL ((1, 2, 3)));
192 #  endif
193 _GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
194                                      char const *restrict __format,
195                                      struct tm *restrict __tm));
196 _GL_CXXALIASWARN (strptime);
197 # endif
198
199 /* Convert TM to a time_t value, assuming UTC.  */
200 # if @GNULIB_TIMEGM@
201 #  if @REPLACE_TIMEGM@
202 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
203 #    undef timegm
204 #    define timegm rpl_timegm
205 #   endif
206 _GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
207 _GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
208 #  else
209 #   if ! @HAVE_TIMEGM@
210 _GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
211 #   endif
212 _GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
213 #  endif
214 _GL_CXXALIASWARN (timegm);
215 # endif
216
217 /* Encourage applications to avoid unsafe functions that can overrun
218    buffers when given outlandish struct tm values.  Portable
219    applications should use strftime (or even sprintf) instead.  */
220 # if defined GNULIB_POSIXCHECK
221 #  undef asctime
222 _GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
223                  "better use strftime (or even sprintf) instead");
224 # endif
225 # if defined GNULIB_POSIXCHECK
226 #  undef asctime_r
227 _GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - "
228                  "better use strftime (or even sprintf) instead");
229 # endif
230 # if defined GNULIB_POSIXCHECK
231 #  undef ctime
232 _GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - "
233                  "better use strftime (or even sprintf) instead");
234 # endif
235 # if defined GNULIB_POSIXCHECK
236 #  undef ctime_r
237 _GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - "
238                  "better use strftime (or even sprintf) instead");
239 # endif
240
241 #endif