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