Use Gnulib's `isnan' and `isinf' modules.
[bpt/guile.git] / lib / time.in.h
CommitLineData
e65fc94b
LC
1/* A more-standard <time.h>.
2
61cd9dc9 3 Copyright (C) 2007-2010 Free Software Foundation, Inc.
e65fc94b
LC
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9
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 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser 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. */
18
aa7a939c 19#if __GNUC__ >= 3
e65fc94b 20@PRAGMA_SYSTEM_HEADER@
aa7a939c 21#endif
e65fc94b
LC
22
23/* Don't get in the way of glibc when it includes time.h merely to
24 declare a few standard symbols, rather than to declare all the
25 symbols. Also, Solaris 8 <time.h> eventually includes itself
26 recursively; if that is happening, just include the system <time.h>
27 without adding our own declarations. */
28#if (defined __need_time_t || defined __need_clock_t \
29 || defined __need_timespec \
30 || defined _GL_TIME_H)
31
32# @INCLUDE_NEXT@ @NEXT_TIME_H@
33
34#else
35
36# define _GL_TIME_H
37
38# @INCLUDE_NEXT@ @NEXT_TIME_H@
39
8912421c 40/* NetBSD 5.0 mis-defines NULL. */
a927b6c1 41# include <stddef.h>
8912421c 42
f4c79b3c
LC
43/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
44
1cd4fffc
LC
45/* The definition of _GL_ARG_NONNULL is copied here. */
46
f4c79b3c
LC
47/* The definition of _GL_WARN_ON_USE is copied here. */
48
e65fc94b
LC
49/* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3).
50 Or they define it with the wrong member names or define it in <sys/time.h>
6f32e5c7
LC
51 (e.g., FreeBSD circa 1997). Stock Mingw does not define it, but the
52 pthreads-win32 library defines it in <pthread.h>. */
e65fc94b
LC
53# if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@
54# if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
55# include <sys/time.h>
6f32e5c7
LC
56# elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
57# include <pthread.h>
58/* The pthreads-win32 <pthread.h> also defines a couple of broken macros. */
59# undef asctime_r
60# undef ctime_r
61# undef gmtime_r
62# undef localtime_r
63# undef rand_r
64# undef strtok_r
e65fc94b 65# else
a927b6c1
LC
66
67# ifdef __cplusplus
68extern "C" {
69# endif
70
e65fc94b
LC
71# undef timespec
72# define timespec rpl_timespec
73struct timespec
74{
75 time_t tv_sec;
76 long int tv_nsec;
77};
e65fc94b 78
a927b6c1 79# ifdef __cplusplus
f4c79b3c 80}
a927b6c1
LC
81# endif
82
83# endif
f4c79b3c
LC
84# endif
85
e65fc94b
LC
86/* Sleep for at least RQTP seconds unless interrupted, If interrupted,
87 return -1 and store the remaining time into RMTP. See
88 <http://www.opengroup.org/susv3xsh/nanosleep.html>. */
f4c79b3c
LC
89# if @GNULIB_NANOSLEEP@
90# if @REPLACE_NANOSLEEP@
91# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
92# define nanosleep rpl_nanosleep
93# endif
94_GL_FUNCDECL_RPL (nanosleep, int,
95 (struct timespec const *__rqtp, struct timespec *__rmtp)
96 _GL_ARG_NONNULL ((1)));
97_GL_CXXALIAS_RPL (nanosleep, int,
98 (struct timespec const *__rqtp, struct timespec *__rmtp));
99# else
a927b6c1
LC
100# if ! @HAVE_NANOSLEEP@
101_GL_FUNCDECL_SYS (nanosleep, int,
102 (struct timespec const *__rqtp, struct timespec *__rmtp)
103 _GL_ARG_NONNULL ((1)));
104# endif
f4c79b3c
LC
105_GL_CXXALIAS_SYS (nanosleep, int,
106 (struct timespec const *__rqtp, struct timespec *__rmtp));
107# endif
108_GL_CXXALIASWARN (nanosleep);
e65fc94b
LC
109# endif
110
25361e4b 111/* Return the 'time_t' representation of TP and normalize TP. */
f4c79b3c
LC
112# if @GNULIB_MKTIME@
113# if @REPLACE_MKTIME@
114# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
115# define mktime rpl_mktime
116# endif
117_GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1)));
118_GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
119# else
120_GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
121# endif
122_GL_CXXALIASWARN (mktime);
25361e4b
LC
123# endif
124
e65fc94b
LC
125/* Convert TIMER to RESULT, assuming local time and UTC respectively. See
126 <http://www.opengroup.org/susv3xsh/localtime_r.html> and
127 <http://www.opengroup.org/susv3xsh/gmtime_r.html>. */
f4c79b3c
LC
128# if @GNULIB_TIME_R@
129# if @REPLACE_LOCALTIME_R@
130# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
131# undef localtime_r
132# define localtime_r rpl_localtime_r
133# endif
134_GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
135 struct tm *restrict __result)
136 _GL_ARG_NONNULL ((1, 2)));
137_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
138 struct tm *restrict __result));
139# else
a927b6c1
LC
140# if ! @HAVE_LOCALTIME_R@
141_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
142 struct tm *restrict __result)
143 _GL_ARG_NONNULL ((1, 2)));
144# endif
f4c79b3c
LC
145_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
146 struct tm *restrict __result));
147# endif
148_GL_CXXALIASWARN (localtime_r);
149# if @REPLACE_LOCALTIME_R@
150# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
151# undef gmtime_r
152# define gmtime_r rpl_gmtime_r
153# endif
154_GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
155 struct tm *restrict __result)
156 _GL_ARG_NONNULL ((1, 2)));
157_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
158 struct tm *restrict __result));
159# else
a927b6c1
LC
160# if ! @HAVE_LOCALTIME_R@
161_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
162 struct tm *restrict __result)
163 _GL_ARG_NONNULL ((1, 2)));
164# endif
f4c79b3c
LC
165_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
166 struct tm *restrict __result));
167# endif
168_GL_CXXALIASWARN (gmtime_r);
e65fc94b
LC
169# endif
170
171/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
172 the resulting broken-down time into TM. See
173 <http://www.opengroup.org/susv3xsh/strptime.html>. */
f4c79b3c 174# if @GNULIB_STRPTIME@
a927b6c1
LC
175# if ! @HAVE_STRPTIME@
176_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
f4c79b3c
LC
177 char const *restrict __format,
178 struct tm *restrict __tm)
179 _GL_ARG_NONNULL ((1, 2, 3)));
a927b6c1 180# endif
f4c79b3c
LC
181_GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
182 char const *restrict __format,
183 struct tm *restrict __tm));
f4c79b3c 184_GL_CXXALIASWARN (strptime);
e65fc94b
LC
185# endif
186
187/* Convert TM to a time_t value, assuming UTC. */
f4c79b3c
LC
188# if @GNULIB_TIMEGM@
189# if @REPLACE_TIMEGM@
190# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
191# undef timegm
192# define timegm rpl_timegm
193# endif
194_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
195_GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
196# else
a927b6c1
LC
197# if ! @HAVE_TIMEGM@
198_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
199# endif
f4c79b3c
LC
200_GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
201# endif
202_GL_CXXALIASWARN (timegm);
e65fc94b
LC
203# endif
204
205/* Encourage applications to avoid unsafe functions that can overrun
206 buffers when given outlandish struct tm values. Portable
207 applications should use strftime (or even sprintf) instead. */
a927b6c1 208# if defined GNULIB_POSIXCHECK
e65fc94b 209# undef asctime
a927b6c1
LC
210_GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
211 "better use strftime (or even sprintf) instead");
212# endif
213# if defined GNULIB_POSIXCHECK
e65fc94b 214# undef asctime_r
a927b6c1
LC
215_GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - "
216 "better use strftime (or even sprintf) instead");
217# endif
218# if defined GNULIB_POSIXCHECK
e65fc94b 219# undef ctime
a927b6c1
LC
220_GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - "
221 "better use strftime (or even sprintf) instead");
222# endif
223# if defined GNULIB_POSIXCHECK
e65fc94b 224# undef ctime_r
a927b6c1
LC
225_GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - "
226 "better use strftime (or even sprintf) instead");
e65fc94b
LC
227# endif
228
e65fc94b 229#endif