mega_sas: suppress set but not used warnings
[unleashed.git] / include / time.h
blob1c7f34771f4e15311591322b13ec730d3b224da3
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
21 /* Copyright (c) 1988 AT&T */
22 /* All Rights Reserved */
26 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
28 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
29 * Use is subject to license terms.
32 * Copyright 2010 Nexenta Systems, Inc. Al rights reserved.
33 * Copyright 2016 Joyent, Inc.
36 #ifndef _TIME_H
37 #define _TIME_H
39 #include <sys/feature_tests.h>
40 #include <iso/time_iso.h>
42 * C11 requires sys/time_impl.h for the definition of the struct timespec.
44 #if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
45 (_POSIX_C_SOURCE > 2) || defined(__EXTENSIONS__) || defined(_STDC_C11)
46 #include <sys/types.h>
47 #include <sys/time_impl.h>
48 #endif /* (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) ... */
51 * Allow global visibility for symbols defined in
52 * C++ "std" namespace in <iso/time_iso.h>.
54 #if __cplusplus >= 199711L
55 using std::size_t;
56 using std::clock_t;
57 using std::time_t;
58 using std::tm;
59 using std::asctime;
60 using std::clock;
61 using std::ctime;
62 using std::difftime;
63 using std::gmtime;
64 using std::localtime;
65 using std::mktime;
66 using std::time;
67 using std::strftime;
68 #endif
70 #ifdef __cplusplus
71 extern "C" {
72 #endif
74 #ifndef _CLOCKID_T
75 #define _CLOCKID_T
76 typedef int clockid_t;
77 #endif
79 #ifndef _TIMER_T
80 #define _TIMER_T
81 typedef int timer_t;
82 #endif
84 extern char *asctime_r(const struct tm *_RESTRICT_KYWD, char *_RESTRICT_KYWD);
85 extern char *ctime_r(const time_t *, char *);
86 extern struct tm *gmtime_r(const time_t *_RESTRICT_KYWD,
87 struct tm *_RESTRICT_KYWD);
88 extern struct tm *localtime_r(const time_t *_RESTRICT_KYWD,
89 struct tm *_RESTRICT_KYWD);
91 #if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
92 defined(_XPG4) || defined(__EXTENSIONS__)
94 #ifdef _STRPTIME_DONTZERO
95 #ifdef __PRAGMA_REDEFINE_EXTNAME
96 #pragma redefine_extname strptime __strptime_dontzero
97 #else /* __PRAGMA_REDEFINE_EXTNAME */
98 extern char *__strptime_dontzero(const char *, const char *, struct tm *);
99 #define strptime __strptime_dontzero
100 #endif /* __PRAGMA_REDEFINE_EXTNAME */
101 #endif /* _STRPTIME_DONTZERO */
103 extern char *strptime(const char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
104 struct tm *_RESTRICT_KYWD);
106 #endif /* (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))... */
108 #if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
109 (_POSIX_C_SOURCE > 2) || defined(__EXTENSIONS__)
111 * Neither X/Open nor POSIX allow the inclusion of <signal.h> for the
112 * definition of the sigevent structure. Both require the inclusion
113 * of <signal.h> and <time.h> when using the timer_create() function.
114 * However, X/Open also specifies that the sigevent structure be defined
115 * in <time.h> as described in the header <signal.h>. This prevents
116 * compiler warnings for applications that only include <time.h> and not
117 * also <signal.h>. The sigval union and the sigevent structure is
118 * therefore defined both here and in <sys/siginfo.h> which gets included
119 * via inclusion of <signal.h>.
121 #ifndef _SIGVAL
122 #define _SIGVAL
123 union sigval {
124 int sival_int; /* integer value */
125 void *sival_ptr; /* pointer value */
127 #endif /* _SIGVAL */
129 #ifndef _SIGEVENT
130 #define _SIGEVENT
131 struct sigevent {
132 int sigev_notify; /* notification mode */
133 int sigev_signo; /* signal number */
134 union sigval sigev_value; /* signal value */
135 void (*sigev_notify_function)(union sigval);
136 pthread_attr_t *sigev_notify_attributes;
137 int __sigev_pad2;
139 #endif /* _SIGEVENT */
141 extern int clock_getres(clockid_t, struct timespec *);
142 extern int clock_gettime(clockid_t, struct timespec *);
143 extern int clock_settime(clockid_t, const struct timespec *);
144 extern int timer_create(clockid_t, struct sigevent *_RESTRICT_KYWD,
145 timer_t *_RESTRICT_KYWD);
146 extern int timer_delete(timer_t);
147 extern int timer_getoverrun(timer_t);
148 extern int timer_gettime(timer_t, struct itimerspec *);
149 extern int timer_settime(timer_t, int, const struct itimerspec *_RESTRICT_KYWD,
150 struct itimerspec *_RESTRICT_KYWD);
152 extern int nanosleep(const struct timespec *, struct timespec *);
153 extern int clock_nanosleep(clockid_t, int,
154 const struct timespec *, struct timespec *);
156 #endif /* (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))... */
158 #if !defined(_STRICT_STDC) || defined(__XOPEN_OR_POSIX) || \
159 defined(__EXTENSIONS__)
161 extern void tzset(void);
162 extern char *tzname[2];
164 /* CLK_TCK marked as LEGACY in SUSv2 and removed in SUSv3 */
165 #if !defined(_XPG6) || defined(__EXTENSIONS__)
166 #ifndef CLK_TCK
167 extern long _sysconf(int); /* System Private interface to sysconf() */
168 #define CLK_TCK ((clock_t)_sysconf(3)) /* clock ticks per second */
169 /* 3 is _SC_CLK_TCK */
170 #endif
171 #endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
173 #if (!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)) || \
174 defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
175 extern long timezone;
176 extern int daylight;
177 #endif
179 #endif /* !defined(_STRICT_STDC) || defined(__XOPEN_OR_POSIX)... */
181 #if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
182 defined(__EXTENSIONS__)
183 extern time_t timegm(struct tm *);
184 extern int cftime(char *, char *, const time_t *);
185 extern int ascftime(char *, const char *, const struct tm *);
186 extern long altzone;
187 #endif
189 #if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
190 defined(_XPG4_2) || defined(__EXTENSIONS__)
191 extern struct tm *getdate(const char *);
192 #undef getdate_err
193 #define getdate_err *(int *)_getdate_err_addr()
194 extern int *_getdate_err_addr(void);
195 #endif /* (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))... */
197 #if defined(_XPG7) || !defined(_STRICT_SYMBOLS)
199 #ifndef _LOCALE_T
200 #define _LOCALE_T
201 typedef struct _locale *locale_t;
202 #endif
204 extern size_t strftime_l(char *_RESTRICT_KYWD, size_t,
205 const char *_RESTRICT_KYWD, const struct tm *_RESTRICT_KYWD, locale_t);
207 #endif /* defined(_XPG7) || !defined(_STRICT_SYMBOLS) */
209 #if !defined(_STRICT_SYMBOLS) || defined(_STDC_C11)
212 * Note, the C11 standard requires that all the various base values that are
213 * passed into timespec_get() be non-zero. Hence why TIME_UTC starts at one.
215 #define TIME_UTC 0x1 /* timespec_get base */
217 extern int timespec_get(struct timespec *, int);
218 #endif
220 #ifdef __cplusplus
222 #endif
224 #endif /* _TIME_H */