comparison druntime/import/stdc/posix/time.d @ 760:6f33b427bfd1

Seems like hg ignores .di files, so I missed a bunch of stuff. complete druntime should be there now :)
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Wed, 12 Nov 2008 00:19:18 +0100
parents
children
comparison
equal deleted inserted replaced
759:d3eb054172f9 760:6f33b427bfd1
1 /**
2 * D header file for POSIX.
3 *
4 * Copyright: Public Domain
5 * License: Public Domain
6 * Authors: Sean Kelly
7 * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
8 */
9 module stdc.posix.time;
10
11 private import stdc.posix.config;
12 public import stdc.time;
13 public import stdc.posix.sys.types;
14 public import stdc.posix.signal; // for sigevent
15
16 extern (C):
17
18 //
19 // Required (defined in stdc.time)
20 //
21 /*
22 char* asctime(in tm*);
23 clock_t clock();
24 char* ctime(in time_t*);
25 double difftime(time_t, time_t);
26 tm* gmtime(in time_t*);
27 tm* localtime(in time_t*);
28 time_t mktime(tm*);
29 size_t strftime(char*, size_t, in char*, in tm*);
30 time_t time(time_t*);
31 */
32
33 version( linux )
34 {
35 time_t timegm(tm*); // non-standard
36 }
37 else version( darwin )
38 {
39 time_t timegm(tm*); // non-standard
40 }
41 else version( freebsd )
42 {
43 time_t timegm(tm*); // non-standard
44 }
45
46 //
47 // C Extension (CX)
48 // (defined in stdc.time)
49 //
50 /*
51 char* tzname[];
52 void tzset();
53 */
54
55 //
56 // Process CPU-Time Clocks (CPT)
57 //
58 /*
59 int clock_getcpuclockid(pid_t, clockid_t*);
60 */
61
62 //
63 // Clock Selection (CS)
64 //
65 /*
66 int clock_nanosleep(clockid_t, int, in timespec*, timespec*);
67 */
68
69 //
70 // Monotonic Clock (MON)
71 //
72 /*
73 CLOCK_MONOTONIC
74 */
75
76 //
77 // Timer (TMR)
78 //
79 /*
80 CLOCK_PROCESS_CPUTIME_ID (TMR|CPT)
81 CLOCK_THREAD_CPUTIME_ID (TMR|TCT)
82
83 NOTE: timespec must be defined in stdc.posix.signal to break
84 a circular import.
85
86 struct timespec
87 {
88 time_t tv_sec;
89 int tv_nsec;
90 }
91
92 struct itimerspec
93 {
94 timespec it_interval;
95 timespec it_value;
96 }
97
98 CLOCK_REALTIME
99 TIMER_ABSTIME
100
101 clockid_t
102 timer_t
103
104 int clock_getres(clockid_t, timespec*);
105 int clock_gettime(clockid_t, timespec*);
106 int clock_settime(clockid_t, in timespec*);
107 int nanosleep(in timespec*, timespec*);
108 int timer_create(clockid_t, sigevent*, timer_t*);
109 int timer_delete(timer_t);
110 int timer_gettime(timer_t, itimerspec*);
111 int timer_getoverrun(timer_t);
112 int timer_settime(timer_t, int, in itimerspec*, itimerspec*);
113 */
114
115 version( linux )
116 {
117 const CLOCK_PROCESS_CPUTIME_ID = 2; // (TMR|CPT)
118 const CLOCK_THREAD_CPUTIME_ID = 3; // (TMR|TCT)
119
120 // NOTE: See above for why this is commented out.
121 //
122 //struct timespec
123 //{
124 // time_t tv_sec;
125 // c_long tv_nsec;
126 //}
127
128 struct itimerspec
129 {
130 timespec it_interval;
131 timespec it_value;
132 }
133
134 const CLOCK_REALTIME = 0;
135 const TIMER_ABSTIME = 0x01;
136
137 alias int clockid_t;
138 alias int timer_t;
139
140 int clock_getres(clockid_t, timespec*);
141 //int clock_gettime(clockid_t, timespec*);
142 //int clock_settime(clockid_t, in timespec*);
143 int nanosleep(in timespec*, timespec*);
144 int timer_create(clockid_t, sigevent*, timer_t*);
145 int timer_delete(timer_t);
146 int timer_gettime(timer_t, itimerspec*);
147 int timer_getoverrun(timer_t);
148 int timer_settime(timer_t, int, in itimerspec*, itimerspec*);
149 }
150 else version( darwin )
151 {
152 int nanosleep(in timespec*, timespec*);
153 }
154 else version( freebsd )
155 {
156 const CLOCK_PROCESS_CPUTIME_ID = 2; // (TMR|CPT)
157 const CLOCK_THREAD_CPUTIME_ID = 3; // (TMR|TCT)
158
159 // NOTE: See above for why this is commented out.
160 //
161 //struct timespec
162 //{
163 // time_t tv_sec;
164 // c_long tv_nsec;
165 //}
166
167 struct itimerspec
168 {
169 timespec it_interval;
170 timespec it_value;
171 }
172
173 const CLOCK_REALTIME = 0;
174 const TIMER_ABSTIME = 0x01;
175
176 alias int clockid_t;
177 alias int timer_t;
178
179 int clock_getres(clockid_t, timespec*);
180 int clock_gettime(clockid_t, timespec*);
181 int clock_settime(clockid_t, in timespec*);
182 int nanosleep(in timespec*, timespec*);
183 int timer_create(clockid_t, sigevent*, timer_t*);
184 int timer_delete(timer_t);
185 int timer_gettime(timer_t, itimerspec*);
186 int timer_getoverrun(timer_t);
187 int timer_settime(timer_t, int, in itimerspec*, itimerspec*);
188 }
189
190
191 //
192 // Thread-Safe Functions (TSF)
193 //
194 /*
195 char* asctime_r(in tm*, char*);
196 char* ctime_r(in time_t*, char*);
197 tm* gmtime_r(in time_t*, tm*);
198 tm* localtime_r(in time_t*, tm*);
199 */
200
201 version( linux )
202 {
203 char* asctime_r(in tm*, char*);
204 char* ctime_r(in time_t*, char*);
205 tm* gmtime_r(in time_t*, tm*);
206 tm* localtime_r(in time_t*, tm*);
207 }
208 else version( darwin )
209 {
210 char* asctime_r(in tm*, char*);
211 char* ctime_r(in time_t*, char*);
212 tm* gmtime_r(in time_t*, tm*);
213 tm* localtime_r(in time_t*, tm*);
214 }
215 else version( freebsd )
216 {
217 char* asctime_r(in tm*, char*);
218 char* ctime_r(in time_t*, char*);
219 tm* gmtime_r(in time_t*, tm*);
220 tm* localtime_r(in time_t*, tm*);
221 }
222
223 //
224 // XOpen (XSI)
225 //
226 /*
227 getdate_err
228
229 int daylight;
230 int timezone;
231
232 tm* getdate(in char*);
233 char* strptime(in char*, in char*, tm*);
234 */
235
236 version( linux )
237 {
238 extern int daylight;
239 extern c_long timezone;
240
241 tm* getdate(in char*);
242 char* strptime(in char*, in char*, tm*);
243 }
244 else version( darwin )
245 {
246 extern c_long timezone;
247
248 tm* getdate(in char*);
249 char* strptime(in char*, in char*, tm*);
250 }
251 else version( freebsd )
252 {
253 extern c_long timezone;
254
255 //tm* getdate(in char*);
256 char* strptime(in char*, in char*, tm*);
257 }