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