2 * D header file for POSIX.
4 * Copyright: Public Domain
5 * License: Public Domain
7 * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
9 module core.sys.posix.time;
11 private import core.sys.posix.config;
12 public import core.stdc.time;
13 public import core.sys.posix.sys.types;
14 public import core.sys.posix.signal; // for sigevent
19 // Required (defined in core.stdc.time)
22 char* asctime(in tm*);
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*);
29 size_t strftime(char*, size_t, in char*, in tm*);
35 time_t timegm(tm*); // non-standard
37 else version( darwin )
39 time_t timegm(tm*); // non-standard
41 else version( freebsd )
43 time_t timegm(tm*); // non-standard
48 // (defined in core.stdc.time)
56 // Process CPU-Time Clocks (CPT)
59 int clock_getcpuclockid(pid_t, clockid_t*);
63 // Clock Selection (CS)
66 int clock_nanosleep(clockid_t, int, in timespec*, timespec*);
70 // Monotonic Clock (MON)
80 CLOCK_PROCESS_CPUTIME_ID (TMR|CPT)
81 CLOCK_THREAD_CPUTIME_ID (TMR|TCT)
83 NOTE: timespec must be defined in core.sys.posix.signal to break
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*);
117 const CLOCK_PROCESS_CPUTIME_ID = 2; // (TMR|CPT)
118 const CLOCK_THREAD_CPUTIME_ID = 3; // (TMR|TCT)
120 // NOTE: See above for why this is commented out.
130 timespec it_interval;
134 const CLOCK_REALTIME = 0;
135 const TIMER_ABSTIME = 0x01;
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*);
150 else version( darwin )
152 int nanosleep(in timespec*, timespec*);
154 else version( freebsd )
156 const CLOCK_PROCESS_CPUTIME_ID = 2; // (TMR|CPT)
157 const CLOCK_THREAD_CPUTIME_ID = 3; // (TMR|TCT)
159 // NOTE: See above for why this is commented out.
169 timespec it_interval;
173 const CLOCK_REALTIME = 0;
174 const TIMER_ABSTIME = 0x01;
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*);
192 // Thread-Safe Functions (TSF)
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*);
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*);
208 else version( darwin )
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*);
215 else version( freebsd )
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*);
232 tm* getdate(in char*);
233 char* strptime(in char*, in char*, tm*);
239 extern c_long timezone;
241 tm* getdate(in char*);
242 char* strptime(in char*, in char*, tm*);
244 else version( darwin )
246 extern c_long timezone;
248 tm* getdate(in char*);
249 char* strptime(in char*, in char*, tm*);
251 else version( freebsd )
253 extern c_long timezone;
255 //tm* getdate(in char*);
256 char* strptime(in char*, in char*, tm*);