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