| @@ -1,294 +1,294 @@ | | | @@ -1,294 +1,294 @@ |
1 | /* $NetBSD: time.h,v 1.61.2.3 2008/12/28 18:38:55 christos Exp $ */ | | 1 | /* $NetBSD: time.h,v 1.61.2.4 2009/01/04 04:22:10 christos Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1982, 1986, 1993 | | 4 | * Copyright (c) 1982, 1986, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
15 | * 3. Neither the name of the University nor the names of its contributors | | 15 | * 3. Neither the name of the University nor the names of its contributors |
16 | * may be used to endorse or promote products derived from this software | | 16 | * may be used to endorse or promote products derived from this software |
17 | * without specific prior written permission. | | 17 | * without specific prior written permission. |
18 | * | | 18 | * |
19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | | 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
29 | * SUCH DAMAGE. | | 29 | * SUCH DAMAGE. |
30 | * | | 30 | * |
31 | * @(#)time.h 8.5 (Berkeley) 5/4/95 | | 31 | * @(#)time.h 8.5 (Berkeley) 5/4/95 |
32 | */ | | 32 | */ |
33 | | | 33 | |
34 | #ifndef _SYS_TIME_H_ | | 34 | #ifndef _SYS_TIME_H_ |
35 | #define _SYS_TIME_H_ | | 35 | #define _SYS_TIME_H_ |
36 | | | 36 | |
37 | #include <sys/featuretest.h> | | 37 | #include <sys/featuretest.h> |
38 | #include <sys/types.h> | | 38 | #include <sys/types.h> |
39 | | | 39 | |
40 | /* | | 40 | /* |
41 | * Structure returned by gettimeofday(2) system call, | | 41 | * Structure returned by gettimeofday(2) system call, |
42 | * and used in other calls. | | 42 | * and used in other calls. |
43 | */ | | 43 | */ |
44 | struct timeval { | | 44 | struct timeval { |
45 | time_t tv_sec; /* seconds */ | | 45 | time_t tv_sec; /* seconds */ |
46 | suseconds_t tv_usec; /* and microseconds */ | | 46 | suseconds_t tv_usec; /* and microseconds */ |
47 | }; | | 47 | }; |
48 | | | 48 | |
49 | /* | | 49 | /* |
50 | * Structure defined by POSIX.1b to be like a timeval. | | 50 | * Structure defined by POSIX.1b to be like a timeval. |
51 | */ | | 51 | */ |
52 | struct timespec { | | 52 | struct timespec { |
53 | time_t tv_sec; /* seconds */ | | 53 | time_t tv_sec; /* seconds */ |
54 | long tv_nsec; /* and nanoseconds */ | | 54 | long tv_nsec; /* and nanoseconds */ |
55 | }; | | 55 | }; |
56 | | | 56 | |
57 | #if defined(_NETBSD_SOURCE) | | 57 | #if defined(_NETBSD_SOURCE) |
58 | #define TIMEVAL_TO_TIMESPEC(tv, ts) do { \ | | 58 | #define TIMEVAL_TO_TIMESPEC(tv, ts) do { \ |
59 | (ts)->tv_sec = (tv)->tv_sec; \ | | 59 | (ts)->tv_sec = (tv)->tv_sec; \ |
60 | (ts)->tv_nsec = (tv)->tv_usec * 1000; \ | | 60 | (ts)->tv_nsec = (tv)->tv_usec * 1000; \ |
61 | } while (/*CONSTCOND*/0) | | 61 | } while (/*CONSTCOND*/0) |
62 | #define TIMESPEC_TO_TIMEVAL(tv, ts) do { \ | | 62 | #define TIMESPEC_TO_TIMEVAL(tv, ts) do { \ |
63 | (tv)->tv_sec = (ts)->tv_sec; \ | | 63 | (tv)->tv_sec = (ts)->tv_sec; \ |
64 | (tv)->tv_usec = (ts)->tv_nsec / 1000; \ | | 64 | (tv)->tv_usec = (ts)->tv_nsec / 1000; \ |
65 | } while (/*CONSTCOND*/0) | | 65 | } while (/*CONSTCOND*/0) |
66 | | | 66 | |
67 | /* | | 67 | /* |
68 | * Note: timezone is obsolete. All timezone handling is now in | | 68 | * Note: timezone is obsolete. All timezone handling is now in |
69 | * userland. Its just here for back compatibility. | | 69 | * userland. Its just here for back compatibility. |
70 | */ | | 70 | */ |
71 | struct timezone { | | 71 | struct timezone { |
72 | int tz_minuteswest; /* minutes west of Greenwich */ | | 72 | int tz_minuteswest; /* minutes west of Greenwich */ |
73 | int tz_dsttime; /* type of dst correction */ | | 73 | int tz_dsttime; /* type of dst correction */ |
74 | }; | | 74 | }; |
75 | | | 75 | |
76 | /* Operations on timevals. */ | | 76 | /* Operations on timevals. */ |
77 | #define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0L | | 77 | #define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0L |
78 | #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) | | 78 | #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) |
79 | #define timercmp(tvp, uvp, cmp) \ | | 79 | #define timercmp(tvp, uvp, cmp) \ |
80 | (((tvp)->tv_sec == (uvp)->tv_sec) ? \ | | 80 | (((tvp)->tv_sec == (uvp)->tv_sec) ? \ |
81 | ((tvp)->tv_usec cmp (uvp)->tv_usec) : \ | | 81 | ((tvp)->tv_usec cmp (uvp)->tv_usec) : \ |
82 | ((tvp)->tv_sec cmp (uvp)->tv_sec)) | | 82 | ((tvp)->tv_sec cmp (uvp)->tv_sec)) |
83 | #define timeradd(tvp, uvp, vvp) \ | | 83 | #define timeradd(tvp, uvp, vvp) \ |
84 | do { \ | | 84 | do { \ |
85 | (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \ | | 85 | (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \ |
86 | (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \ | | 86 | (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \ |
87 | if ((vvp)->tv_usec >= 1000000) { \ | | 87 | if ((vvp)->tv_usec >= 1000000) { \ |
88 | (vvp)->tv_sec++; \ | | 88 | (vvp)->tv_sec++; \ |
89 | (vvp)->tv_usec -= 1000000; \ | | 89 | (vvp)->tv_usec -= 1000000; \ |
90 | } \ | | 90 | } \ |
91 | } while (/* CONSTCOND */ 0) | | 91 | } while (/* CONSTCOND */ 0) |
92 | #define timersub(tvp, uvp, vvp) \ | | 92 | #define timersub(tvp, uvp, vvp) \ |
93 | do { \ | | 93 | do { \ |
94 | (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \ | | 94 | (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \ |
95 | (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \ | | 95 | (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \ |
96 | if ((vvp)->tv_usec < 0) { \ | | 96 | if ((vvp)->tv_usec < 0) { \ |
97 | (vvp)->tv_sec--; \ | | 97 | (vvp)->tv_sec--; \ |
98 | (vvp)->tv_usec += 1000000; \ | | 98 | (vvp)->tv_usec += 1000000; \ |
99 | } \ | | 99 | } \ |
100 | } while (/* CONSTCOND */ 0) | | 100 | } while (/* CONSTCOND */ 0) |
101 | | | 101 | |
102 | /* | | 102 | /* |
103 | * hide bintime for _STANDALONE because this header is used for hpcboot.exe, | | 103 | * hide bintime for _STANDALONE because this header is used for hpcboot.exe, |
104 | * which is built with compilers which don't recognize LL suffix. | | 104 | * which is built with compilers which don't recognize LL suffix. |
105 | * http://mail-index.NetBSD.org/tech-userlevel/2008/02/27/msg000181.html | | 105 | * http://mail-index.NetBSD.org/tech-userlevel/2008/02/27/msg000181.html |
106 | */ | | 106 | */ |
107 | #if !defined(_STANDALONE) | | 107 | #if !defined(_STANDALONE) |
108 | struct bintime { | | 108 | struct bintime { |
109 | time_t sec; | | 109 | time_t sec; |
110 | uint64_t frac; | | 110 | uint64_t frac; |
111 | }; | | 111 | }; |
112 | | | 112 | |
113 | static __inline void | | 113 | static __inline void |
114 | bintime_addx(struct bintime *bt, uint64_t x) | | 114 | bintime_addx(struct bintime *bt, uint64_t x) |
115 | { | | 115 | { |
116 | uint64_t u; | | 116 | uint64_t u; |
117 | | | 117 | |
118 | u = bt->frac; | | 118 | u = bt->frac; |
119 | bt->frac += x; | | 119 | bt->frac += x; |
120 | if (u > bt->frac) | | 120 | if (u > bt->frac) |
121 | bt->sec++; | | 121 | bt->sec++; |
122 | } | | 122 | } |
123 | | | 123 | |
124 | static __inline void | | 124 | static __inline void |
125 | bintime_add(struct bintime *bt, const struct bintime *bt2) | | 125 | bintime_add(struct bintime *bt, const struct bintime *bt2) |
126 | { | | 126 | { |
127 | uint64_t u; | | 127 | uint64_t u; |
128 | | | 128 | |
129 | u = bt->frac; | | 129 | u = bt->frac; |
130 | bt->frac += bt2->frac; | | 130 | bt->frac += bt2->frac; |
131 | if (u > bt->frac) | | 131 | if (u > bt->frac) |
132 | bt->sec++; | | 132 | bt->sec++; |
133 | bt->sec += bt2->sec; | | 133 | bt->sec += bt2->sec; |
134 | } | | 134 | } |
135 | | | 135 | |
136 | static __inline void | | 136 | static __inline void |
137 | bintime_sub(struct bintime *bt, const struct bintime *bt2) | | 137 | bintime_sub(struct bintime *bt, const struct bintime *bt2) |
138 | { | | 138 | { |
139 | uint64_t u; | | 139 | uint64_t u; |
140 | | | 140 | |
141 | u = bt->frac; | | 141 | u = bt->frac; |
142 | bt->frac -= bt2->frac; | | 142 | bt->frac -= bt2->frac; |
143 | if (u < bt->frac) | | 143 | if (u < bt->frac) |
144 | bt->sec--; | | 144 | bt->sec--; |
145 | bt->sec -= bt2->sec; | | 145 | bt->sec -= bt2->sec; |
146 | } | | 146 | } |
147 | | | 147 | |
148 | /*- | | 148 | /*- |
149 | * Background information: | | 149 | * Background information: |
150 | * | | 150 | * |
151 | * When converting between timestamps on parallel timescales of differing | | 151 | * When converting between timestamps on parallel timescales of differing |
152 | * resolutions it is historical and scientific practice to round down rather | | 152 | * resolutions it is historical and scientific practice to round down rather |
153 | * than doing 4/5 rounding. | | 153 | * than doing 4/5 rounding. |
154 | * | | 154 | * |
155 | * The date changes at midnight, not at noon. | | 155 | * The date changes at midnight, not at noon. |
156 | * | | 156 | * |
157 | * Even at 15:59:59.999999999 it's not four'o'clock. | | 157 | * Even at 15:59:59.999999999 it's not four'o'clock. |
158 | * | | 158 | * |
159 | * time_second ticks after N.999999999 not after N.4999999999 | | 159 | * time_second ticks after N.999999999 not after N.4999999999 |
160 | */ | | 160 | */ |
161 | | | 161 | |
162 | static __inline void | | 162 | static __inline void |
163 | bintime2timespec(const struct bintime *bt, struct timespec *ts) | | 163 | bintime2timespec(const struct bintime *bt, struct timespec *ts) |
164 | { | | 164 | { |
165 | | | 165 | |
166 | ts->tv_sec = bt->sec; | | 166 | ts->tv_sec = bt->sec; |
167 | ts->tv_nsec = | | 167 | ts->tv_nsec = |
168 | (long)(((uint64_t)1000000000 * (uint32_t)(bt->frac >> 32)) >> 32); | | 168 | (long)(((uint64_t)1000000000 * (uint32_t)(bt->frac >> 32)) >> 32); |
169 | } | | 169 | } |
170 | | | 170 | |
171 | static __inline void | | 171 | static __inline void |
172 | timespec2bintime(const struct timespec *ts, struct bintime *bt) | | 172 | timespec2bintime(const struct timespec *ts, struct bintime *bt) |
173 | { | | 173 | { |
174 | | | 174 | |
175 | bt->sec = ts->tv_sec; | | 175 | bt->sec = ts->tv_sec; |
176 | /* 18446744073 = int(2^64 / 1000000000) */ | | 176 | /* 18446744073 = int(2^64 / 1000000000) */ |
177 | bt->frac = ts->tv_nsec * (uint64_t)18446744073LL; | | 177 | bt->frac = ts->tv_nsec * (uint64_t)18446744073LL; |
178 | } | | 178 | } |
179 | | | 179 | |
180 | static __inline void | | 180 | static __inline void |
181 | bintime2timeval(const struct bintime *bt, struct timeval *tv) | | 181 | bintime2timeval(const struct bintime *bt, struct timeval *tv) |
182 | { | | 182 | { |
183 | | | 183 | |
184 | tv->tv_sec = bt->sec; | | 184 | tv->tv_sec = bt->sec; |
185 | tv->tv_usec = | | 185 | tv->tv_usec = |
186 | (long)(((uint64_t)1000000 * (uint32_t)(bt->frac >> 32)) >> 32); | | 186 | (suseconds_t)(((uint64_t)1000000 * (uint32_t)(bt->frac >> 32)) >> 32); |
187 | } | | 187 | } |
188 | | | 188 | |
189 | static __inline void | | 189 | static __inline void |
190 | timeval2bintime(const struct timeval *tv, struct bintime *bt) | | 190 | timeval2bintime(const struct timeval *tv, struct bintime *bt) |
191 | { | | 191 | { |
192 | | | 192 | |
193 | bt->sec = tv->tv_sec; | | 193 | bt->sec = tv->tv_sec; |
194 | /* 18446744073709 = int(2^64 / 1000000) */ | | 194 | /* 18446744073709 = int(2^64 / 1000000) */ |
195 | bt->frac = tv->tv_usec * (uint64_t)18446744073709LL; | | 195 | bt->frac = tv->tv_usec * (uint64_t)18446744073709LL; |
196 | } | | 196 | } |
197 | #endif /* !defined(_STANDALONE) */ | | 197 | #endif /* !defined(_STANDALONE) */ |
198 | | | 198 | |
199 | /* Operations on timespecs. */ | | 199 | /* Operations on timespecs. */ |
200 | #define timespecclear(tsp) (tsp)->tv_sec = (time_t)((tsp)->tv_nsec = 0L) | | 200 | #define timespecclear(tsp) (tsp)->tv_sec = (time_t)((tsp)->tv_nsec = 0L) |
201 | #define timespecisset(tsp) ((tsp)->tv_sec || (tsp)->tv_nsec) | | 201 | #define timespecisset(tsp) ((tsp)->tv_sec || (tsp)->tv_nsec) |
202 | #define timespeccmp(tsp, usp, cmp) \ | | 202 | #define timespeccmp(tsp, usp, cmp) \ |
203 | (((tsp)->tv_sec == (usp)->tv_sec) ? \ | | 203 | (((tsp)->tv_sec == (usp)->tv_sec) ? \ |
204 | ((tsp)->tv_nsec cmp (usp)->tv_nsec) : \ | | 204 | ((tsp)->tv_nsec cmp (usp)->tv_nsec) : \ |
205 | ((tsp)->tv_sec cmp (usp)->tv_sec)) | | 205 | ((tsp)->tv_sec cmp (usp)->tv_sec)) |
206 | #define timespecadd(tsp, usp, vsp) \ | | 206 | #define timespecadd(tsp, usp, vsp) \ |
207 | do { \ | | 207 | do { \ |
208 | (vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec; \ | | 208 | (vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec; \ |
209 | (vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec; \ | | 209 | (vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec; \ |
210 | if ((vsp)->tv_nsec >= 1000000000L) { \ | | 210 | if ((vsp)->tv_nsec >= 1000000000L) { \ |
211 | (vsp)->tv_sec++; \ | | 211 | (vsp)->tv_sec++; \ |
212 | (vsp)->tv_nsec -= 1000000000L; \ | | 212 | (vsp)->tv_nsec -= 1000000000L; \ |
213 | } \ | | 213 | } \ |
214 | } while (/* CONSTCOND */ 0) | | 214 | } while (/* CONSTCOND */ 0) |
215 | #define timespecsub(tsp, usp, vsp) \ | | 215 | #define timespecsub(tsp, usp, vsp) \ |
216 | do { \ | | 216 | do { \ |
217 | (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \ | | 217 | (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \ |
218 | (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \ | | 218 | (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \ |
219 | if ((vsp)->tv_nsec < 0) { \ | | 219 | if ((vsp)->tv_nsec < 0) { \ |
220 | (vsp)->tv_sec--; \ | | 220 | (vsp)->tv_sec--; \ |
221 | (vsp)->tv_nsec += 1000000000L; \ | | 221 | (vsp)->tv_nsec += 1000000000L; \ |
222 | } \ | | 222 | } \ |
223 | } while (/* CONSTCOND */ 0) | | 223 | } while (/* CONSTCOND */ 0) |
224 | #define timespec2ns(x) (((uint64_t)(x)->tv_sec) * 1000000000L + (x)->tv_nsec) | | 224 | #define timespec2ns(x) (((uint64_t)(x)->tv_sec) * 1000000000L + (x)->tv_nsec) |
225 | #endif /* _NETBSD_SOURCE */ | | 225 | #endif /* _NETBSD_SOURCE */ |
226 | | | 226 | |
227 | /* | | 227 | /* |
228 | * Names of the interval timers, and structure | | 228 | * Names of the interval timers, and structure |
229 | * defining a timer setting. | | 229 | * defining a timer setting. |
230 | */ | | 230 | */ |
231 | #define ITIMER_REAL 0 | | 231 | #define ITIMER_REAL 0 |
232 | #define ITIMER_VIRTUAL 1 | | 232 | #define ITIMER_VIRTUAL 1 |
233 | #define ITIMER_PROF 2 | | 233 | #define ITIMER_PROF 2 |
234 | | | 234 | |
235 | struct itimerval { | | 235 | struct itimerval { |
236 | struct timeval it_interval; /* timer interval */ | | 236 | struct timeval it_interval; /* timer interval */ |
237 | struct timeval it_value; /* current value */ | | 237 | struct timeval it_value; /* current value */ |
238 | }; | | 238 | }; |
239 | | | 239 | |
240 | /* | | 240 | /* |
241 | * Structure defined by POSIX.1b to be like a itimerval, but with | | 241 | * Structure defined by POSIX.1b to be like a itimerval, but with |
242 | * timespecs. Used in the timer_*() system calls. | | 242 | * timespecs. Used in the timer_*() system calls. |
243 | */ | | 243 | */ |
244 | struct itimerspec { | | 244 | struct itimerspec { |
245 | struct timespec it_interval; | | 245 | struct timespec it_interval; |
246 | struct timespec it_value; | | 246 | struct timespec it_value; |
247 | }; | | 247 | }; |
248 | | | 248 | |
249 | #define CLOCK_REALTIME 0 | | 249 | #define CLOCK_REALTIME 0 |
250 | #define CLOCK_VIRTUAL 1 | | 250 | #define CLOCK_VIRTUAL 1 |
251 | #define CLOCK_PROF 2 | | 251 | #define CLOCK_PROF 2 |
252 | #define CLOCK_MONOTONIC 3 | | 252 | #define CLOCK_MONOTONIC 3 |
253 | | | 253 | |
254 | #define TIMER_RELTIME 0x0 /* relative timer */ | | 254 | #define TIMER_RELTIME 0x0 /* relative timer */ |
255 | #define TIMER_ABSTIME 0x1 /* absolute timer */ | | 255 | #define TIMER_ABSTIME 0x1 /* absolute timer */ |
256 | | | 256 | |
257 | #ifdef _KERNEL | | 257 | #ifdef _KERNEL |
258 | #include <sys/timevar.h> | | 258 | #include <sys/timevar.h> |
259 | #else /* !_KERNEL */ | | 259 | #else /* !_KERNEL */ |
260 | #ifndef _STANDALONE | | 260 | #ifndef _STANDALONE |
261 | #if (_POSIX_C_SOURCE - 0) >= 200112L || \ | | 261 | #if (_POSIX_C_SOURCE - 0) >= 200112L || \ |
262 | (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \ | | 262 | (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \ |
263 | (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE) | | 263 | (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE) |
264 | #include <sys/select.h> | | 264 | #include <sys/select.h> |
265 | #endif | | 265 | #endif |
266 | | | 266 | |
267 | #include <sys/cdefs.h> | | 267 | #include <sys/cdefs.h> |
268 | #include <time.h> | | 268 | #include <time.h> |
269 | | | 269 | |
270 | __BEGIN_DECLS | | 270 | __BEGIN_DECLS |
271 | #ifndef __LIBC12_SOURCE__ | | 271 | #ifndef __LIBC12_SOURCE__ |
272 | #if (_POSIX_C_SOURCE - 0) >= 200112L || \ | | 272 | #if (_POSIX_C_SOURCE - 0) >= 200112L || \ |
273 | defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) | | 273 | defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) |
274 | int getitimer(int, struct itimerval *) __RENAME(__getitimer50); | | 274 | int getitimer(int, struct itimerval *) __RENAME(__getitimer50); |
275 | int gettimeofday(struct timeval * __restrict, void *__restrict) | | 275 | int gettimeofday(struct timeval * __restrict, void *__restrict) |
276 | __RENAME(__gettimeofday50); | | 276 | __RENAME(__gettimeofday50); |
277 | int setitimer(int, const struct itimerval * __restrict, | | 277 | int setitimer(int, const struct itimerval * __restrict, |
278 | struct itimerval * __restrict) __RENAME(__setitimer50); | | 278 | struct itimerval * __restrict) __RENAME(__setitimer50); |
279 | int utimes(const char *, const struct timeval [2]) __RENAME(__utimes50); | | 279 | int utimes(const char *, const struct timeval [2]) __RENAME(__utimes50); |
280 | #endif /* _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE || _NETBSD_SOURCE */ | | 280 | #endif /* _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE || _NETBSD_SOURCE */ |
281 | | | 281 | |
282 | #if defined(_NETBSD_SOURCE) || defined(HAVE_NBTOOL_CONFIG_H) | | 282 | #if defined(_NETBSD_SOURCE) || defined(HAVE_NBTOOL_CONFIG_H) |
283 | int adjtime(const struct timeval *, struct timeval *) __RENAME(__adjtime50); | | 283 | int adjtime(const struct timeval *, struct timeval *) __RENAME(__adjtime50); |
284 | int futimes(int, const struct timeval [2]) __RENAME(__futimes50); | | 284 | int futimes(int, const struct timeval [2]) __RENAME(__futimes50); |
285 | int lutimes(const char *, const struct timeval [2]) __RENAME(__lutimes50); | | 285 | int lutimes(const char *, const struct timeval [2]) __RENAME(__lutimes50); |
286 | int settimeofday(const struct timeval * __restrict, | | 286 | int settimeofday(const struct timeval * __restrict, |
287 | const void *__restrict) __RENAME(__settimeofday50); | | 287 | const void *__restrict) __RENAME(__settimeofday50); |
288 | #endif /* _NETBSD_SOURCE */ | | 288 | #endif /* _NETBSD_SOURCE */ |
289 | #endif /* __LIBC12_SOURCE__ */ | | 289 | #endif /* __LIBC12_SOURCE__ */ |
290 | __END_DECLS | | 290 | __END_DECLS |
291 | | | 291 | |
292 | #endif /* !_STANDALONE */ | | 292 | #endif /* !_STANDALONE */ |
293 | #endif /* !_KERNEL */ | | 293 | #endif /* !_KERNEL */ |
294 | #endif /* !_SYS_TIME_H_ */ | | 294 | #endif /* !_SYS_TIME_H_ */ |