Ticket #2342: usr-include-time.h

File usr-include-time.h, 10.6 KB (added by maeder, 6 years ago)

The (normal) time.h file not from /usr/include/sys

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