]>
Commit | Line | Data |
---|---|---|
b4c522fa IB |
1 | /** |
2 | * D header file for POSIX. | |
3 | * | |
4 | * Copyright: Copyright Sean Kelly 2005 - 2009. | |
5 | * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). | |
6 | * Authors: Sean Kelly, Alex Rønne Petersen | |
7 | * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition | |
8 | */ | |
9 | ||
10 | /* Copyright Sean Kelly 2005 - 2009. | |
11 | * Distributed under the Boost Software License, Version 1.0. | |
12 | * (See accompanying file LICENSE or copy at | |
13 | * http://www.boost.org/LICENSE_1_0.txt) | |
14 | */ | |
15 | module core.sys.posix.sys.time; | |
16 | ||
92dd3e71 | 17 | import core.sys.posix.config; |
b4c522fa IB |
18 | public import core.sys.posix.sys.types; // for time_t, suseconds_t |
19 | public import core.sys.posix.sys.select; // for fd_set, FD_CLR() FD_ISSET() FD_SET() FD_ZERO() FD_SETSIZE, select() | |
20 | ||
21 | version (OSX) | |
22 | version = Darwin; | |
23 | else version (iOS) | |
24 | version = Darwin; | |
25 | else version (TVOS) | |
26 | version = Darwin; | |
27 | else version (WatchOS) | |
28 | version = Darwin; | |
29 | ||
30 | version (linux) public import core.sys.linux.sys.time; | |
31 | ||
32 | version (Posix): | |
33 | extern (C) nothrow @nogc: | |
34 | ||
35 | // | |
36 | // XOpen (XSI) | |
37 | // | |
38 | /* | |
39 | struct timeval | |
40 | { | |
41 | time_t tv_sec; | |
42 | suseconds_t tv_usec; | |
43 | } | |
44 | ||
45 | struct itimerval | |
46 | { | |
47 | timeval it_interval; | |
48 | timeval it_value; | |
49 | } | |
50 | ||
51 | ITIMER_REAL | |
52 | ITIMER_VIRTUAL | |
53 | ITIMER_PROF | |
54 | ||
55 | int getitimer(int, itimerval*); | |
56 | int gettimeofday(timeval*, void*); | |
57 | int select(int, fd_set*, fd_set*, fd_set*, timeval*); (defined in core.sys.posix.sys.signal) | |
92dd3e71 IB |
58 | int setitimer(int, const scope itimerval*, itimerval*); |
59 | int utimes(const scope char*, ref const(timeval)[2]); // LEGACY | |
b4c522fa IB |
60 | */ |
61 | ||
62 | version (CRuntime_Glibc) | |
63 | { | |
64 | struct timeval | |
65 | { | |
66 | time_t tv_sec; | |
67 | suseconds_t tv_usec; | |
68 | } | |
69 | ||
70 | struct itimerval | |
71 | { | |
72 | timeval it_interval; | |
73 | timeval it_value; | |
74 | } | |
75 | ||
76 | enum ITIMER_REAL = 0; | |
77 | enum ITIMER_VIRTUAL = 1; | |
78 | enum ITIMER_PROF = 2; | |
79 | ||
80 | int getitimer(int, itimerval*); | |
81 | int gettimeofday(timeval*, void*); | |
92dd3e71 IB |
82 | int setitimer(int, const scope itimerval*, itimerval*); |
83 | int utimes(const scope char*, ref const(timeval)[2]); // LEGACY | |
b4c522fa IB |
84 | } |
85 | else version (CRuntime_Musl) | |
86 | { | |
87 | struct timeval | |
88 | { | |
89 | time_t tv_sec; | |
90 | suseconds_t tv_usec; | |
91 | } | |
92 | int gettimeofday(timeval*, void*); | |
92dd3e71 | 93 | int utimes(const scope char*, ref const(timeval)[2]); |
b4c522fa IB |
94 | } |
95 | else version (Darwin) | |
96 | { | |
97 | struct timeval | |
98 | { | |
99 | time_t tv_sec; | |
100 | suseconds_t tv_usec; | |
101 | } | |
102 | ||
103 | struct itimerval | |
104 | { | |
105 | timeval it_interval; | |
106 | timeval it_value; | |
107 | } | |
108 | ||
109 | // non-standard | |
110 | struct timezone_t | |
111 | { | |
112 | int tz_minuteswest; | |
113 | int tz_dsttime; | |
114 | } | |
115 | ||
116 | int getitimer(int, itimerval*); | |
117 | int gettimeofday(timeval*, timezone_t*); // timezone_t* is normally void* | |
92dd3e71 IB |
118 | int setitimer(int, const scope itimerval*, itimerval*); |
119 | int utimes(const scope char*, ref const(timeval)[2]); | |
b4c522fa IB |
120 | } |
121 | else version (FreeBSD) | |
122 | { | |
123 | struct timeval | |
124 | { | |
125 | time_t tv_sec; | |
126 | suseconds_t tv_usec; | |
127 | } | |
128 | ||
129 | struct itimerval | |
130 | { | |
131 | timeval it_interval; | |
132 | timeval it_value; | |
133 | } | |
134 | ||
135 | // non-standard | |
136 | struct timezone_t | |
137 | { | |
138 | int tz_minuteswest; | |
139 | int tz_dsttime; | |
140 | } | |
141 | ||
142 | int getitimer(int, itimerval*); | |
143 | int gettimeofday(timeval*, timezone_t*); // timezone_t* is normally void* | |
92dd3e71 IB |
144 | int setitimer(int, const scope itimerval*, itimerval*); |
145 | int utimes(const scope char*, ref const(timeval)[2]); | |
b4c522fa IB |
146 | } |
147 | else version (NetBSD) | |
148 | { | |
149 | struct timeval | |
150 | { | |
151 | time_t tv_sec; | |
152 | suseconds_t tv_usec; | |
153 | } | |
154 | ||
155 | struct itimerval | |
156 | { | |
157 | timeval it_interval; | |
158 | timeval it_value; | |
159 | } | |
160 | ||
161 | int getitimer(int, itimerval*); | |
162 | int gettimeofday(timeval*, void*); // timezone_t* is normally void* | |
92dd3e71 IB |
163 | int setitimer(int, const scope itimerval*, itimerval*); |
164 | int utimes(const scope char*, ref const(timeval)[2]); | |
0234a917 IB |
165 | } |
166 | else version (OpenBSD) | |
167 | { | |
168 | struct timeval | |
169 | { | |
170 | time_t tv_sec; | |
171 | suseconds_t tv_usec; | |
172 | } | |
173 | ||
174 | struct itimerval | |
175 | { | |
176 | timeval it_interval; | |
177 | timeval it_value; | |
178 | } | |
179 | ||
180 | // non-standard | |
181 | struct timezone_t | |
182 | { | |
183 | int tz_minuteswest; | |
184 | int tz_dsttime; | |
185 | } | |
186 | ||
187 | int getitimer(int, itimerval*); | |
188 | int gettimeofday(timeval*, timezone_t*); | |
92dd3e71 IB |
189 | int setitimer(int, const scope itimerval*, itimerval*); |
190 | int utimes(const scope char*, ref const(timeval)[2]); | |
b4c522fa IB |
191 | } |
192 | else version (DragonFlyBSD) | |
193 | { | |
194 | struct timeval | |
195 | { | |
196 | time_t tv_sec; | |
197 | suseconds_t tv_usec; | |
198 | } | |
199 | ||
200 | struct itimerval | |
201 | { | |
202 | timeval it_interval; | |
203 | timeval it_value; | |
204 | } | |
205 | ||
206 | // non-standard | |
207 | struct timezone_t | |
208 | { | |
209 | int tz_minuteswest; | |
210 | int tz_dsttime; | |
211 | } | |
212 | ||
213 | int getitimer(int, itimerval*); | |
214 | int gettimeofday(timeval*, timezone_t*); // timezone_t* is normally void* | |
92dd3e71 IB |
215 | int setitimer(int, const scope itimerval*, itimerval*); |
216 | int utimes(const scope char*, ref const(timeval)[2]); | |
b4c522fa IB |
217 | } |
218 | else version (Solaris) | |
219 | { | |
220 | struct timeval | |
221 | { | |
222 | time_t tv_sec; | |
223 | suseconds_t tv_usec; | |
224 | } | |
225 | ||
226 | struct itimerval | |
227 | { | |
228 | timeval it_interval; | |
229 | timeval it_value; | |
230 | } | |
231 | ||
232 | int getitimer(int, itimerval*); | |
233 | int gettimeofday(timeval*, void*); | |
92dd3e71 IB |
234 | int setitimer(int, const scope itimerval*, itimerval*); |
235 | int utimes(const scope char*, ref const(timeval)[2]); | |
b4c522fa IB |
236 | } |
237 | else version (CRuntime_Bionic) | |
238 | { | |
239 | struct timeval | |
240 | { | |
241 | time_t tv_sec; | |
242 | suseconds_t tv_usec; | |
243 | } | |
244 | ||
245 | struct itimerval | |
246 | { | |
247 | timeval it_interval; | |
248 | timeval it_value; | |
249 | } | |
250 | ||
251 | struct timezone_t | |
252 | { | |
253 | int tz_minuteswest; | |
254 | int tz_dsttime; | |
255 | } | |
256 | ||
257 | enum ITIMER_REAL = 0; | |
258 | enum ITIMER_VIRTUAL = 1; | |
259 | enum ITIMER_PROF = 2; | |
260 | ||
261 | int getitimer(int, itimerval*); | |
262 | int gettimeofday(timeval*, timezone_t*); | |
92dd3e71 IB |
263 | int setitimer(int, const scope itimerval*, itimerval*); |
264 | int utimes(const scope char*, ref const(timeval)[2]); | |
b4c522fa IB |
265 | } |
266 | else version (CRuntime_UClibc) | |
267 | { | |
268 | struct timeval | |
269 | { | |
270 | time_t tv_sec; | |
271 | suseconds_t tv_usec; | |
272 | } | |
273 | ||
274 | struct itimerval | |
275 | { | |
276 | timeval it_interval; | |
277 | timeval it_value; | |
278 | } | |
279 | ||
280 | enum ITIMER_REAL = 0; | |
281 | enum ITIMER_VIRTUAL = 1; | |
282 | enum ITIMER_PROF = 2; | |
283 | ||
284 | int getitimer(int, itimerval*); | |
285 | int gettimeofday(timeval*, void*); | |
92dd3e71 IB |
286 | int setitimer(int, const scope itimerval*, itimerval*); |
287 | int utimes(const scope char*, ref const(timeval)[2]); | |
b4c522fa IB |
288 | } |
289 | else | |
290 | { | |
291 | static assert(false, "Unsupported platform"); | |
292 | } |