diff options
Diffstat (limited to 'gl/time.in.h')
-rw-r--r-- | gl/time.in.h | 169 |
1 files changed, 135 insertions, 34 deletions
diff --git a/gl/time.in.h b/gl/time.in.h index dec37e85..8e364feb 100644 --- a/gl/time.in.h +++ b/gl/time.in.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* A more-standard <time.h>. | 1 | /* A more-standard <time.h>. |
2 | 2 | ||
3 | Copyright (C) 2007-2008 Free Software Foundation, Inc. | 3 | Copyright (C) 2007-2010 Free Software Foundation, Inc. |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 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 | 6 | it under the terms of the GNU General Public License as published by |
@@ -37,9 +37,14 @@ | |||
37 | 37 | ||
38 | # @INCLUDE_NEXT@ @NEXT_TIME_H@ | 38 | # @INCLUDE_NEXT@ @NEXT_TIME_H@ |
39 | 39 | ||
40 | # ifdef __cplusplus | 40 | /* NetBSD 5.0 mis-defines NULL. */ |
41 | extern "C" { | 41 | # include <stddef.h> |
42 | # endif | 42 | |
43 | /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ | ||
44 | |||
45 | /* The definition of _GL_ARG_NONNULL is copied here. */ | ||
46 | |||
47 | /* The definition of _GL_WARN_ON_USE is copied here. */ | ||
43 | 48 | ||
44 | /* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3). | 49 | /* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3). |
45 | Or they define it with the wrong member names or define it in <sys/time.h> | 50 | Or they define it with the wrong member names or define it in <sys/time.h> |
@@ -48,6 +53,11 @@ extern "C" { | |||
48 | # if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ | 53 | # if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ |
49 | # include <sys/time.h> | 54 | # include <sys/time.h> |
50 | # else | 55 | # else |
56 | |||
57 | # ifdef __cplusplus | ||
58 | extern "C" { | ||
59 | # endif | ||
60 | |||
51 | # undef timespec | 61 | # undef timespec |
52 | # define timespec rpl_timespec | 62 | # define timespec rpl_timespec |
53 | struct timespec | 63 | struct timespec |
@@ -55,64 +65,155 @@ struct timespec | |||
55 | time_t tv_sec; | 65 | time_t tv_sec; |
56 | long int tv_nsec; | 66 | long int tv_nsec; |
57 | }; | 67 | }; |
68 | |||
69 | # ifdef __cplusplus | ||
70 | } | ||
71 | # endif | ||
72 | |||
58 | # endif | 73 | # endif |
59 | # endif | 74 | # endif |
60 | 75 | ||
61 | /* Sleep for at least RQTP seconds unless interrupted, If interrupted, | 76 | /* Sleep for at least RQTP seconds unless interrupted, If interrupted, |
62 | return -1 and store the remaining time into RMTP. See | 77 | return -1 and store the remaining time into RMTP. See |
63 | <http://www.opengroup.org/susv3xsh/nanosleep.html>. */ | 78 | <http://www.opengroup.org/susv3xsh/nanosleep.html>. */ |
64 | # if @REPLACE_NANOSLEEP@ | 79 | # if @GNULIB_NANOSLEEP@ |
65 | # define nanosleep rpl_nanosleep | 80 | # if @REPLACE_NANOSLEEP@ |
66 | int nanosleep (struct timespec const *__rqtp, struct timespec *__rmtp); | 81 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
82 | # define nanosleep rpl_nanosleep | ||
83 | # endif | ||
84 | _GL_FUNCDECL_RPL (nanosleep, int, | ||
85 | (struct timespec const *__rqtp, struct timespec *__rmtp) | ||
86 | _GL_ARG_NONNULL ((1))); | ||
87 | _GL_CXXALIAS_RPL (nanosleep, int, | ||
88 | (struct timespec const *__rqtp, struct timespec *__rmtp)); | ||
89 | # else | ||
90 | # if ! @HAVE_NANOSLEEP@ | ||
91 | _GL_FUNCDECL_SYS (nanosleep, int, | ||
92 | (struct timespec const *__rqtp, struct timespec *__rmtp) | ||
93 | _GL_ARG_NONNULL ((1))); | ||
94 | # endif | ||
95 | _GL_CXXALIAS_SYS (nanosleep, int, | ||
96 | (struct timespec const *__rqtp, struct timespec *__rmtp)); | ||
97 | # endif | ||
98 | _GL_CXXALIASWARN (nanosleep); | ||
99 | # endif | ||
100 | |||
101 | /* Return the 'time_t' representation of TP and normalize TP. */ | ||
102 | # if @GNULIB_MKTIME@ | ||
103 | # if @REPLACE_MKTIME@ | ||
104 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
105 | # define mktime rpl_mktime | ||
106 | # endif | ||
107 | _GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1))); | ||
108 | _GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp)); | ||
109 | # else | ||
110 | _GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp)); | ||
111 | # endif | ||
112 | _GL_CXXALIASWARN (mktime); | ||
67 | # endif | 113 | # endif |
68 | 114 | ||
69 | /* Convert TIMER to RESULT, assuming local time and UTC respectively. See | 115 | /* Convert TIMER to RESULT, assuming local time and UTC respectively. See |
70 | <http://www.opengroup.org/susv3xsh/localtime_r.html> and | 116 | <http://www.opengroup.org/susv3xsh/localtime_r.html> and |
71 | <http://www.opengroup.org/susv3xsh/gmtime_r.html>. */ | 117 | <http://www.opengroup.org/susv3xsh/gmtime_r.html>. */ |
72 | # if @REPLACE_LOCALTIME_R@ | 118 | # if @GNULIB_TIME_R@ |
73 | # undef localtime_r | 119 | # if @REPLACE_LOCALTIME_R@ |
74 | # define localtime_r rpl_localtime_r | 120 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
75 | # undef gmtime_r | 121 | # undef localtime_r |
76 | # define gmtime_r rpl_gmtime_r | 122 | # define localtime_r rpl_localtime_r |
77 | struct tm *localtime_r (time_t const *restrict __timer, | 123 | # endif |
78 | struct tm *restrict __result); | 124 | _GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer, |
79 | struct tm *gmtime_r (time_t const *restrict __timer, | 125 | struct tm *restrict __result) |
80 | struct tm *restrict __result); | 126 | _GL_ARG_NONNULL ((1, 2))); |
127 | _GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer, | ||
128 | struct tm *restrict __result)); | ||
129 | # else | ||
130 | # if ! @HAVE_LOCALTIME_R@ | ||
131 | _GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer, | ||
132 | struct tm *restrict __result) | ||
133 | _GL_ARG_NONNULL ((1, 2))); | ||
134 | # endif | ||
135 | _GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer, | ||
136 | struct tm *restrict __result)); | ||
137 | # endif | ||
138 | _GL_CXXALIASWARN (localtime_r); | ||
139 | # if @REPLACE_LOCALTIME_R@ | ||
140 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
141 | # undef gmtime_r | ||
142 | # define gmtime_r rpl_gmtime_r | ||
143 | # endif | ||
144 | _GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer, | ||
145 | struct tm *restrict __result) | ||
146 | _GL_ARG_NONNULL ((1, 2))); | ||
147 | _GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer, | ||
148 | struct tm *restrict __result)); | ||
149 | # else | ||
150 | # if ! @HAVE_LOCALTIME_R@ | ||
151 | _GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, | ||
152 | struct tm *restrict __result) | ||
153 | _GL_ARG_NONNULL ((1, 2))); | ||
154 | # endif | ||
155 | _GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, | ||
156 | struct tm *restrict __result)); | ||
157 | # endif | ||
158 | _GL_CXXALIASWARN (gmtime_r); | ||
81 | # endif | 159 | # endif |
82 | 160 | ||
83 | /* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store | 161 | /* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store |
84 | the resulting broken-down time into TM. See | 162 | the resulting broken-down time into TM. See |
85 | <http://www.opengroup.org/susv3xsh/strptime.html>. */ | 163 | <http://www.opengroup.org/susv3xsh/strptime.html>. */ |
86 | # if @REPLACE_STRPTIME@ | 164 | # if @GNULIB_STRPTIME@ |
87 | # undef strptime | 165 | # if ! @HAVE_STRPTIME@ |
88 | # define strptime rpl_strptime | 166 | _GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf, |
89 | char *strptime (char const *restrict __buf, char const *restrict __format, | 167 | char const *restrict __format, |
90 | struct tm *restrict __tm); | 168 | struct tm *restrict __tm) |
169 | _GL_ARG_NONNULL ((1, 2, 3))); | ||
170 | # endif | ||
171 | _GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf, | ||
172 | char const *restrict __format, | ||
173 | struct tm *restrict __tm)); | ||
174 | _GL_CXXALIASWARN (strptime); | ||
91 | # endif | 175 | # endif |
92 | 176 | ||
93 | /* Convert TM to a time_t value, assuming UTC. */ | 177 | /* Convert TM to a time_t value, assuming UTC. */ |
94 | # if @REPLACE_TIMEGM@ | 178 | # if @GNULIB_TIMEGM@ |
95 | # undef timegm | 179 | # if @REPLACE_TIMEGM@ |
96 | # define timegm rpl_timegm | 180 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
97 | time_t timegm (struct tm *__tm); | 181 | # undef timegm |
182 | # define timegm rpl_timegm | ||
183 | # endif | ||
184 | _GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1))); | ||
185 | _GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm)); | ||
186 | # else | ||
187 | # if ! @HAVE_TIMEGM@ | ||
188 | _GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1))); | ||
189 | # endif | ||
190 | _GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm)); | ||
191 | # endif | ||
192 | _GL_CXXALIASWARN (timegm); | ||
98 | # endif | 193 | # endif |
99 | 194 | ||
100 | /* Encourage applications to avoid unsafe functions that can overrun | 195 | /* Encourage applications to avoid unsafe functions that can overrun |
101 | buffers when given outlandish struct tm values. Portable | 196 | buffers when given outlandish struct tm values. Portable |
102 | applications should use strftime (or even sprintf) instead. */ | 197 | applications should use strftime (or even sprintf) instead. */ |
103 | # if GNULIB_PORTCHECK | 198 | # if defined GNULIB_POSIXCHECK |
104 | # undef asctime | 199 | # undef asctime |
105 | # define asctime eschew_asctime | 200 | _GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - " |
201 | "better use strftime (or even sprintf) instead"); | ||
202 | # endif | ||
203 | # if defined GNULIB_POSIXCHECK | ||
106 | # undef asctime_r | 204 | # undef asctime_r |
107 | # define asctime_r eschew_asctime_r | 205 | _GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - " |
206 | "better use strftime (or even sprintf) instead"); | ||
207 | # endif | ||
208 | # if defined GNULIB_POSIXCHECK | ||
108 | # undef ctime | 209 | # undef ctime |
109 | # define ctime eschew_ctime | 210 | _GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - " |
110 | # undef ctime_r | 211 | "better use strftime (or even sprintf) instead"); |
111 | # define ctime_r eschew_ctime_r | ||
112 | # endif | 212 | # endif |
113 | 213 | # if defined GNULIB_POSIXCHECK | |
114 | # ifdef __cplusplus | 214 | # undef ctime_r |
115 | } | 215 | _GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - " |
216 | "better use strftime (or even sprintf) instead"); | ||
116 | # endif | 217 | # endif |
117 | 218 | ||
118 | #endif | 219 | #endif |