29
27
without adding our own declarations. */
30
28
#if (defined __need_time_t || defined __need_clock_t \
31
29
|| defined __need_timespec \
32
|| defined _GL_TIME_H)
30
|| defined _@GUARD_PREFIX@_TIME_H)
34
32
# @INCLUDE_NEXT@ @NEXT_TIME_H@
36
# define _@GUARD_PREFIX@_TIME_H
40
38
# @INCLUDE_NEXT@ @NEXT_TIME_H@
42
40
/* NetBSD 5.0 mis-defines NULL. */
43
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
45
45
/* The definition of _GL_ARG_NONNULL is copied here. */
47
/* The definition of _GL_WARN_ON_USE is copied here. */
51
49
/* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3).
52
50
Or they define it with the wrong member names or define it in <sys/time.h>
53
(e.g., FreeBSD circa 1997). */
51
(e.g., FreeBSD circa 1997). Stock Mingw does not define it, but the
52
pthreads-win32 library defines it in <pthread.h>. */
54
53
# if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@
55
54
# if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
56
55
# include <sys/time.h>
56
# elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
58
/* The pthreads-win32 <pthread.h> also defines a couple of broken macros. */
59
# define timespec rpl_timespec
71
# if !GNULIB_defined_struct_timespec
73
# define timespec rpl_timespec
79
# define GNULIB_defined_struct_timespec 1
89
# if !GNULIB_defined_struct_time_t_must_be_integral
90
/* Per http://austingroupbugs.net/view.php?id=327, POSIX requires
91
time_t to be an integer type, even though C99 permits floating
92
point. We don't know of any implementation that uses floating
93
point, and it is much easier to write code that doesn't have to
94
worry about that corner case, so we force the issue. */
95
struct __time_t_must_be_integral {
96
unsigned int __floating_time_t_unsupported : (time_t) 1;
98
# define GNULIB_defined_struct_time_t_must_be_integral 1
68
101
/* Sleep for at least RQTP seconds unless interrupted, If interrupted,
69
102
return -1 and store the remaining time into RMTP. See
70
103
<http://www.opengroup.org/susv3xsh/nanosleep.html>. */
71
# if @REPLACE_NANOSLEEP@
72
# define nanosleep rpl_nanosleep
73
extern int nanosleep (struct timespec const *__rqtp, struct timespec *__rmtp)
74
_GL_ARG_NONNULL ((1));
104
# if @GNULIB_NANOSLEEP@
105
# if @REPLACE_NANOSLEEP@
106
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
107
# define nanosleep rpl_nanosleep
109
_GL_FUNCDECL_RPL (nanosleep, int,
110
(struct timespec const *__rqtp, struct timespec *__rmtp)
111
_GL_ARG_NONNULL ((1)));
112
_GL_CXXALIAS_RPL (nanosleep, int,
113
(struct timespec const *__rqtp, struct timespec *__rmtp));
115
# if ! @HAVE_NANOSLEEP@
116
_GL_FUNCDECL_SYS (nanosleep, int,
117
(struct timespec const *__rqtp, struct timespec *__rmtp)
118
_GL_ARG_NONNULL ((1)));
120
_GL_CXXALIAS_SYS (nanosleep, int,
121
(struct timespec const *__rqtp, struct timespec *__rmtp));
123
_GL_CXXALIASWARN (nanosleep);
77
126
/* Return the 'time_t' representation of TP and normalize TP. */
79
# define mktime rpl_mktime
80
extern time_t mktime (struct tm *__tp) _GL_ARG_NONNULL ((1));
128
# if @REPLACE_MKTIME@
129
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
130
# define mktime rpl_mktime
132
_GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1)));
133
_GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
135
_GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
137
_GL_CXXALIASWARN (mktime);
83
140
/* Convert TIMER to RESULT, assuming local time and UTC respectively. See
84
141
<http://www.opengroup.org/susv3xsh/localtime_r.html> and
85
142
<http://www.opengroup.org/susv3xsh/gmtime_r.html>. */
86
# if @REPLACE_LOCALTIME_R@
88
# define localtime_r rpl_localtime_r
90
# define gmtime_r rpl_gmtime_r
91
extern struct tm *localtime_r (time_t const *restrict __timer,
92
struct tm *restrict __result)
93
_GL_ARG_NONNULL ((1, 2));
94
extern struct tm *gmtime_r (time_t const *restrict __timer,
95
struct tm *restrict __result)
96
_GL_ARG_NONNULL ((1, 2));
144
# if @REPLACE_LOCALTIME_R@
145
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
147
# define localtime_r rpl_localtime_r
149
_GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
150
struct tm *restrict __result)
151
_GL_ARG_NONNULL ((1, 2)));
152
_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
153
struct tm *restrict __result));
155
# if ! @HAVE_DECL_LOCALTIME_R@
156
_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
157
struct tm *restrict __result)
158
_GL_ARG_NONNULL ((1, 2)));
160
_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
161
struct tm *restrict __result));
163
# if @HAVE_DECL_LOCALTIME_R@
164
_GL_CXXALIASWARN (localtime_r);
166
# if @REPLACE_LOCALTIME_R@
167
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
169
# define gmtime_r rpl_gmtime_r
171
_GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
172
struct tm *restrict __result)
173
_GL_ARG_NONNULL ((1, 2)));
174
_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
175
struct tm *restrict __result));
177
# if ! @HAVE_DECL_LOCALTIME_R@
178
_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
179
struct tm *restrict __result)
180
_GL_ARG_NONNULL ((1, 2)));
182
_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
183
struct tm *restrict __result));
185
# if @HAVE_DECL_LOCALTIME_R@
186
_GL_CXXALIASWARN (gmtime_r);
99
190
/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
100
191
the resulting broken-down time into TM. See
101
192
<http://www.opengroup.org/susv3xsh/strptime.html>. */
102
# if @REPLACE_STRPTIME@
104
# define strptime rpl_strptime
105
extern char *strptime (char const *restrict __buf,
106
char const *restrict __format,
107
struct tm *restrict __tm)
108
_GL_ARG_NONNULL ((1, 2, 3));
193
# if @GNULIB_STRPTIME@
194
# if ! @HAVE_STRPTIME@
195
_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
196
char const *restrict __format,
197
struct tm *restrict __tm)
198
_GL_ARG_NONNULL ((1, 2, 3)));
200
_GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
201
char const *restrict __format,
202
struct tm *restrict __tm));
203
_GL_CXXALIASWARN (strptime);
111
206
/* Convert TM to a time_t value, assuming UTC. */
112
# if @REPLACE_TIMEGM@
114
# define timegm rpl_timegm
115
extern time_t timegm (struct tm *__tm) _GL_ARG_NONNULL ((1));
208
# if @REPLACE_TIMEGM@
209
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
211
# define timegm rpl_timegm
213
_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
214
_GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
217
_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
219
_GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
221
_GL_CXXALIASWARN (timegm);
118
224
/* Encourage applications to avoid unsafe functions that can overrun
119
225
buffers when given outlandish struct tm values. Portable
120
226
applications should use strftime (or even sprintf) instead. */
121
# if GNULIB_PORTCHECK
227
# if defined GNULIB_POSIXCHECK
123
# define asctime eschew_asctime
229
_GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
230
"better use strftime (or even sprintf) instead");
232
# if defined GNULIB_POSIXCHECK
124
233
# undef asctime_r
125
# define asctime_r eschew_asctime_r
234
_GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - "
235
"better use strftime (or even sprintf) instead");
237
# if defined GNULIB_POSIXCHECK
127
# define ctime eschew_ctime
239
_GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - "
240
"better use strftime (or even sprintf) instead");
242
# if defined GNULIB_POSIXCHECK
129
# define ctime_r eschew_ctime_r
244
_GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - "
245
"better use strftime (or even sprintf) instead");