Print this page
remove support for non-ANSI compilation
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/head/time.h
+++ new/usr/src/head/time.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /* Copyright (c) 1988 AT&T */
22 22 /* All Rights Reserved */
23 23
24 24
25 25 /*
26 + * Copyright 2014 Garrett D'Amore <garrett@damore.org>
27 + *
26 28 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
27 29 * Use is subject to license terms.
28 30 */
29 31 /*
30 32 * Copyright 2010 Nexenta Systems, Inc. Al rights reserved.
31 - * Copyright 2014 Garrett D'Amore <garrett@damore.org>
32 33 */
33 34
34 35 #ifndef _TIME_H
35 36 #define _TIME_H
36 37
37 38 #include <sys/feature_tests.h>
38 39 #include <iso/time_iso.h>
39 40 #if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
40 41 (_POSIX_C_SOURCE > 2) || defined(__EXTENSIONS__)
41 42 #include <sys/types.h>
42 43 #include <sys/time_impl.h>
43 44 #endif /* (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) ... */
44 45
45 46 /*
46 47 * Allow global visibility for symbols defined in
47 48 * C++ "std" namespace in <iso/time_iso.h>.
48 49 */
49 50 #if __cplusplus >= 199711L
50 51 using std::size_t;
51 52 using std::clock_t;
52 53 using std::time_t;
53 54 using std::tm;
54 55 using std::asctime;
55 56 using std::clock;
56 57 using std::ctime;
57 58 using std::difftime;
58 59 using std::gmtime;
59 60 using std::localtime;
60 61 using std::mktime;
61 62 using std::time;
62 63 using std::strftime;
63 64 #endif
64 65
65 66 #ifdef __cplusplus
66 67 extern "C" {
67 68 #endif
68 69
↓ open down ↓ |
27 lines elided |
↑ open up ↑ |
69 70 #ifndef _CLOCKID_T
70 71 #define _CLOCKID_T
71 72 typedef int clockid_t;
72 73 #endif
73 74
74 75 #ifndef _TIMER_T
75 76 #define _TIMER_T
76 77 typedef int timer_t;
77 78 #endif
78 79
79 -#if defined(__STDC__)
80 -
81 80 #if defined(__EXTENSIONS__) || \
82 81 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
83 82 (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_REENTRANT)
84 83 extern struct tm *gmtime_r(const time_t *_RESTRICT_KYWD,
85 84 struct tm *_RESTRICT_KYWD);
86 85 extern struct tm *localtime_r(const time_t *_RESTRICT_KYWD,
87 86 struct tm *_RESTRICT_KYWD);
88 87 #endif
89 88
90 89 #if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
91 90 defined(_XPG4) || defined(__EXTENSIONS__)
92 91
93 92 #ifdef _STRPTIME_DONTZERO
94 93 #ifdef __PRAGMA_REDEFINE_EXTNAME
95 94 #pragma redefine_extname strptime __strptime_dontzero
96 95 #else /* __PRAGMA_REDEFINE_EXTNAME */
97 96 extern char *__strptime_dontzero(const char *, const char *, struct tm *);
98 97 #define strptime __strptime_dontzero
99 98 #endif /* __PRAGMA_REDEFINE_EXTNAME */
100 99 #endif /* _STRPTIME_DONTZERO */
101 100
102 101 extern char *strptime(const char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
103 102 struct tm *_RESTRICT_KYWD);
104 103
105 104 #endif /* (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))... */
106 105
107 106 #if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
108 107 (_POSIX_C_SOURCE > 2) || defined(__EXTENSIONS__)
109 108 /*
110 109 * Neither X/Open nor POSIX allow the inclusion of <signal.h> for the
111 110 * definition of the sigevent structure. Both require the inclusion
112 111 * of <signal.h> and <time.h> when using the timer_create() function.
113 112 * However, X/Open also specifies that the sigevent structure be defined
114 113 * in <time.h> as described in the header <signal.h>. This prevents
115 114 * compiler warnings for applications that only include <time.h> and not
116 115 * also <signal.h>. The sigval union and the sigevent structure is
117 116 * therefore defined both here and in <sys/siginfo.h> which gets included
118 117 * via inclusion of <signal.h>.
119 118 */
120 119 #ifndef _SIGVAL
121 120 #define _SIGVAL
122 121 union sigval {
123 122 int sival_int; /* integer value */
124 123 void *sival_ptr; /* pointer value */
125 124 };
126 125 #endif /* _SIGVAL */
127 126
128 127 #ifndef _SIGEVENT
129 128 #define _SIGEVENT
130 129 struct sigevent {
131 130 int sigev_notify; /* notification mode */
132 131 int sigev_signo; /* signal number */
133 132 union sigval sigev_value; /* signal value */
134 133 void (*sigev_notify_function)(union sigval);
135 134 pthread_attr_t *sigev_notify_attributes;
136 135 int __sigev_pad2;
137 136 };
138 137 #endif /* _SIGEVENT */
139 138
140 139 extern int clock_getres(clockid_t, struct timespec *);
141 140 extern int clock_gettime(clockid_t, struct timespec *);
142 141 extern int clock_settime(clockid_t, const struct timespec *);
143 142 extern int timer_create(clockid_t, struct sigevent *_RESTRICT_KYWD,
144 143 timer_t *_RESTRICT_KYWD);
145 144 extern int timer_delete(timer_t);
146 145 extern int timer_getoverrun(timer_t);
147 146 extern int timer_gettime(timer_t, struct itimerspec *);
148 147 extern int timer_settime(timer_t, int, const struct itimerspec *_RESTRICT_KYWD,
149 148 struct itimerspec *_RESTRICT_KYWD);
150 149
151 150 extern int nanosleep(const struct timespec *, struct timespec *);
152 151 extern int clock_nanosleep(clockid_t, int,
153 152 const struct timespec *, struct timespec *);
154 153
155 154 #endif /* (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))... */
156 155
157 156 #if !defined(_STRICT_STDC) || defined(__XOPEN_OR_POSIX) || \
158 157 defined(__EXTENSIONS__)
159 158
160 159 extern void tzset(void);
161 160 extern char *tzname[2];
162 161
163 162 /* CLK_TCK marked as LEGACY in SUSv2 and removed in SUSv3 */
164 163 #if !defined(_XPG6) || defined(__EXTENSIONS__)
165 164 #ifndef CLK_TCK
166 165 extern long _sysconf(int); /* System Private interface to sysconf() */
167 166 #define CLK_TCK ((clock_t)_sysconf(3)) /* clock ticks per second */
168 167 /* 3 is _SC_CLK_TCK */
169 168 #endif
170 169 #endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
171 170
172 171 #if (!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)) || \
173 172 defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
174 173 extern long timezone;
175 174 extern int daylight;
176 175 #endif
177 176
178 177 #endif /* !defined(_STRICT_STDC) || defined(__XOPEN_OR_POSIX)... */
179 178
180 179 #if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
181 180 defined(__EXTENSIONS__)
182 181 extern time_t timegm(struct tm *);
183 182 extern int cftime(char *, char *, const time_t *);
184 183 extern int ascftime(char *, const char *, const struct tm *);
185 184 extern long altzone;
186 185 #endif
187 186
188 187 #if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
189 188 defined(_XPG4_2) || defined(__EXTENSIONS__)
↓ open down ↓ |
99 lines elided |
↑ open up ↑ |
190 189 extern struct tm *getdate(const char *);
191 190 #ifdef _REENTRANT
192 191 #undef getdate_err
193 192 #define getdate_err *(int *)_getdate_err_addr()
194 193 extern int *_getdate_err_addr(void);
195 194 #else
196 195 extern int getdate_err;
197 196 #endif /* _REENTRANT */
198 197 #endif /* (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))... */
199 198
200 -#else /* __STDC__ */
201 -
202 -extern int cftime(), ascftime();
203 -extern void tzset();
204 -extern time_t timegm();
205 -
206 -#ifdef _STRPTIME_DONTZERO
207 -#ifdef __PRAGMA_REDEFINE_EXTNAME
208 -#pragma redefine_extname strptime __strptime_dontzero
209 -#else /* __PRAGMA_REDEFINE_EXTNAME */
210 -extern char *__strptime_dontzero();
211 -#define strptime __strptime_dontzero
212 -#endif /* __PRAGMA_REDEFINE_EXTNAME */
213 -#endif /* _STRPTIME_DONTZERO */
214 -
215 -extern char *strptime();
216 -
217 -#if defined(__EXTENSIONS__) || \
218 - (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
219 - (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_REENTRANT)
220 -extern struct tm *gmtime_r();
221 -extern struct tm *localtime_r();
222 -#endif
223 -
224 -extern long timezone, altzone;
225 -extern int daylight;
226 -extern char *tzname[2];
227 -
228 -#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
229 -extern struct tm *getdate();
230 -#ifdef _REENTRANT
231 -#undef getdate_err
232 -#define getdate_err *(int *)_getdate_err_addr()
233 -extern int *_getdate_err_addr();
234 -#else
235 -extern int getdate_err;
236 -#endif /* _REENTRANT */
237 -#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
238 -
239 -#endif /* __STDC__ */
240 -
241 199 /*
242 200 * ctime_r() & asctime_r() prototypes are defined here.
243 201 */
244 202
245 203 /*
246 204 * Previous releases of Solaris, starting at 2.3, provided definitions of
247 205 * various functions as specified in POSIX.1c, Draft 6. For some of these
248 206 * functions, the final POSIX 1003.1c standard had a different number of
249 207 * arguments and return values.
250 208 *
251 209 * The following segment of this header provides support for the standard
252 210 * interfaces while supporting applications written under earlier
253 211 * releases. The application defines appropriate values of the feature
254 212 * test macros _POSIX_C_SOURCE and _POSIX_PTHREAD_SEMANTICS to indicate
255 213 * whether it was written to expect the Draft 6 or standard versions of
256 214 * these interfaces, before including this header. This header then
257 215 * provides a mapping from the source version of the interface to an
258 216 * appropriate binary interface. Such mappings permit an application
259 217 * to be built from libraries and objects which have mixed expectations
260 218 * of the definitions of these functions.
261 219 *
262 220 * For applications using the Draft 6 definitions, the binary symbol is the
263 221 * same as the source symbol, and no explicit mapping is needed. For the
264 222 * standard interface, the function func() is mapped to the binary symbol
265 223 * _posix_func(). The preferred mechanism for the remapping is a compiler
266 224 * #pragma. If the compiler does not provide such a #pragma, the header file
267 225 * defines a static function func() which calls the _posix_func() version;
268 226 * this has to be done instead of #define since POSIX specifies that an
269 227 * application can #undef the symbol and still be bound to the correct
270 228 * implementation. Unfortunately, the statics confuse lint so we fallback to
↓ open down ↓ |
20 lines elided |
↑ open up ↑ |
271 229 * #define in that case.
272 230 *
273 231 * NOTE: Support for the Draft 6 definitions is provided for compatibility
274 232 * only. New applications/libraries should use the standard definitions.
275 233 */
276 234
277 235 #if defined(__EXTENSIONS__) || defined(_REENTRANT) || \
278 236 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
279 237 (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
280 238
281 -#if defined(__STDC__)
282 -
283 239 #if (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
284 240
285 241 #ifdef __PRAGMA_REDEFINE_EXTNAME
286 242 #pragma redefine_extname ctime_r __posix_ctime_r
287 243 #pragma redefine_extname asctime_r __posix_asctime_r
288 244 extern char *asctime_r(const struct tm *_RESTRICT_KYWD, char *_RESTRICT_KYWD);
289 245 extern char *ctime_r(const time_t *, char *);
290 246 #else /* __PRAGMA_REDEFINE_EXTNAME */
291 247
292 248 extern char *__posix_asctime_r(const struct tm *_RESTRICT_KYWD,
293 249 char *_RESTRICT_KYWD);
294 250 extern char *__posix_ctime_r(const time_t *, char *);
295 251
296 252 #ifdef __lint
297 253
298 254 #define ctime_r __posix_ctime_r
299 255 #define asctime_r __posix_asctime_r
300 256
301 257 #else /* !__lint */
302 258
303 259 static char *
304 260 asctime_r(const struct tm *_RESTRICT_KYWD __tm, char *_RESTRICT_KYWD __buf)
305 261 {
306 262 return (__posix_asctime_r(__tm, __buf));
307 263 }
308 264
309 265 static char *
310 266 ctime_r(const time_t *__time, char *__buf)
311 267 {
312 268 return (__posix_ctime_r(__time, __buf));
313 269 }
314 270
↓ open down ↓ |
22 lines elided |
↑ open up ↑ |
315 271 #endif /* !__lint */
316 272 #endif /* __PRAGMA_REDEFINE_EXTNAME */
317 273
318 274 #else /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
319 275
320 276 extern char *asctime_r(const struct tm *, char *, int);
321 277 extern char *ctime_r(const time_t *, char *, int);
322 278
323 279 #endif /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
324 280
325 -#else /* __STDC__ */
326 -
327 -#if (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
328 -
329 -#ifdef __PRAGMA_REDEFINE_EXTNAME
330 -#pragma redefine_extname asctime_r __posix_asctime_r
331 -#pragma redefine_extname ctime_r __posix_ctime_r
332 -extern char *asctime_r();
333 -extern char *ctime_r();
334 -#else /* __PRAGMA_REDEFINE_EXTNAME */
335 -
336 -extern char *__posix_asctime_r();
337 -extern char *__posix_ctime_r();
338 -
339 -#ifdef __lint
340 -
341 -#define asctime_r __posix_asctime_r
342 -#define ctime_r __posix_ctime_r
343 -
344 -#else /* !__lint */
345 -
346 -static char *
347 -asctime_r(__tm, __buf)
348 - struct tm *__tm;
349 - char *__buf;
350 -{
351 - return (__posix_asctime_r(__tm, __buf));
352 -}
353 -static char *
354 -ctime_r(__time, __buf)
355 - time_t *__time;
356 - char *__buf;
357 -{
358 - return (__posix_ctime_r(__time, __buf));
359 -}
360 -
361 -#endif /* !__lint */
362 -#endif /* __PRAGMA_REDEFINE_EXTNAME */
363 -
364 -#else /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
365 -
366 -extern char *asctime_r();
367 -extern char *ctime_r();
368 -
369 -#endif /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
370 -
371 -#endif /* __STDC__ */
372 -
373 281 #endif /* defined(__EXTENSIONS__) || defined(_REENTRANT)... */
374 282
375 283
376 284 #if defined(_XPG7) || !defined(_STRICT_SYMBOLS)
377 285
378 286 #ifndef _LOCALE_T
379 287 #define _LOCALE_T
380 288 typedef struct _locale *locale_t;
381 289 #endif
382 290
383 -#if defined(__STDC__)
384 291 extern size_t strftime_l(char *_RESTRICT_KYWD, size_t,
385 292 const char *_RESTRICT_KYWD, const struct tm *_RESTRICT_KYWD, locale_t);
386 -#else /* __STDC__ */
387 -extern size_t strftime_l();
388 -#endif /* __STDC__ */
389 293
390 294 #endif /* defined(_XPG7) || !defined(_STRICT_SYMBOLS) */
391 295
392 296 #ifdef __cplusplus
393 297 }
394 298 #endif
395 299
396 300 #endif /* _TIME_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX