Mercurial > projects > ldc
comparison tango/tango/stdc/posix/sys/types.d @ 132:1700239cab2e trunk
[svn r136] MAJOR UNSTABLE UPDATE!!!
Initial commit after moving to Tango instead of Phobos.
Lots of bugfixes...
This build is not suitable for most things.
author | lindquist |
---|---|
date | Fri, 11 Jan 2008 17:57:40 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
131:5825d48b27d1 | 132:1700239cab2e |
---|---|
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 tango.stdc.posix.sys.types; | |
10 | |
11 private import tango.stdc.posix.config; | |
12 private import tango.stdc.stdint; | |
13 public import tango.stdc.stddef; // for size_t | |
14 public import tango.stdc.time; // for clock_t, time_t | |
15 | |
16 extern (C): | |
17 | |
18 // | |
19 // Required | |
20 // | |
21 /* | |
22 blkcnt_t | |
23 blksize_t | |
24 dev_t | |
25 gid_t | |
26 ino_t | |
27 mode_t | |
28 nlink_t | |
29 off_t | |
30 pid_t | |
31 size_t | |
32 ssize_t | |
33 time_t | |
34 uid_t | |
35 */ | |
36 | |
37 version( linux ) | |
38 { | |
39 static if( __USE_FILE_OFFSET64 ) | |
40 { | |
41 alias long blkcnt_t; | |
42 alias ulong ino_t; | |
43 alias long off_t; | |
44 } | |
45 else | |
46 { | |
47 alias c_long blkcnt_t; | |
48 alias c_ulong ino_t; | |
49 alias c_long off_t; | |
50 } | |
51 alias c_long blksize_t; | |
52 alias ulong dev_t; | |
53 alias uint gid_t; | |
54 alias uint mode_t; | |
55 alias uint nlink_t; | |
56 alias int pid_t; | |
57 //size_t (defined in tango.stdc.stddef) | |
58 alias int ssize_t; | |
59 //time_t (defined in tango.stdc.time) | |
60 alias uint uid_t; | |
61 } | |
62 else version( darwin ) | |
63 { | |
64 alias long blkcnt_t; | |
65 alias int blksize_t; | |
66 alias int dev_t; | |
67 alias uint gid_t; | |
68 alias uint ino_t; | |
69 alias ushort mode_t; | |
70 alias ushort nlink_t; | |
71 alias long off_t; | |
72 alias int pid_t; | |
73 //size_t (defined in tango.stdc.stddef) | |
74 alias size_t ssize_t; | |
75 //time_t (defined in tango.stdc.time) | |
76 alias uint uid_t; | |
77 } | |
78 | |
79 // | |
80 // XOpen (XSI) | |
81 // | |
82 /* | |
83 clock_t | |
84 fsblkcnt_t | |
85 fsfilcnt_t | |
86 id_t | |
87 key_t | |
88 suseconds_t | |
89 useconds_t | |
90 */ | |
91 | |
92 version( linux ) | |
93 { | |
94 static if( __USE_FILE_OFFSET64 ) | |
95 { | |
96 alias ulong fsblkcnt_t; | |
97 alias ulong fsfilcnt_t; | |
98 } | |
99 else | |
100 { | |
101 alias c_ulong fsblkcnt_t; | |
102 alias c_ulong fsfilcnt_t; | |
103 } | |
104 // clock_t (defined in tango.stdc.time) | |
105 alias uint id_t; | |
106 alias int key_t; | |
107 alias c_long suseconds_t; | |
108 alias uint useconds_t; | |
109 } | |
110 else version( darwin ) | |
111 { | |
112 //clock_t | |
113 alias uint fsblkcnt_t; | |
114 alias uint fsfilcnt_t; | |
115 alias uint id_t; | |
116 // key_t | |
117 alias int suseconds_t; | |
118 alias uint useconds_t; | |
119 } | |
120 | |
121 // | |
122 // Thread (THR) | |
123 // | |
124 /* | |
125 pthread_attr_t | |
126 pthread_cond_t | |
127 pthread_condattr_t | |
128 pthread_key_t | |
129 pthread_mutex_t | |
130 pthread_mutexattr_t | |
131 pthread_once_t | |
132 pthread_rwlock_t | |
133 pthread_rwlockattr_t | |
134 pthread_t | |
135 */ | |
136 | |
137 version( linux ) | |
138 { | |
139 private struct __sched_param | |
140 { | |
141 int __sched_priority; | |
142 } | |
143 | |
144 struct pthread_attr_t | |
145 { | |
146 int __detachstate; | |
147 int __schedpolicy; | |
148 __sched_param __schedparam; | |
149 int __inheritsched; | |
150 int __scope; | |
151 size_t __guardsize; | |
152 int __stackaddr_set; | |
153 void* __stackaddr; | |
154 size_t __stacksize; | |
155 } | |
156 | |
157 private alias int __atomic_lock_t; | |
158 | |
159 private struct _pthread_fastlock | |
160 { | |
161 c_long __status; | |
162 __atomic_lock_t __spinlock; | |
163 } | |
164 | |
165 private alias void* _pthread_descr; | |
166 | |
167 private alias long __pthread_cond_align_t; | |
168 | |
169 struct pthread_cond_t | |
170 { | |
171 _pthread_fastlock __c_lock; | |
172 _pthread_descr __c_waiting; | |
173 char[48 - | |
174 _pthread_fastlock.sizeof - | |
175 _pthread_descr.sizeof - | |
176 __pthread_cond_align_t.sizeof] | |
177 __padding; | |
178 __pthread_cond_align_t __align; | |
179 } | |
180 | |
181 struct pthread_condattr_t | |
182 { | |
183 int __dummy; | |
184 } | |
185 | |
186 alias uint pthread_key_t; | |
187 | |
188 struct pthread_mutex_t | |
189 { | |
190 int __m_reserved; | |
191 int __m_count; | |
192 _pthread_descr __m_owner; | |
193 int __m_kind; | |
194 _pthread_fastlock __m_lock; | |
195 } | |
196 | |
197 struct pthread_mutexattr_t | |
198 { | |
199 int __mutexkind; | |
200 } | |
201 | |
202 alias int pthread_once_t; | |
203 | |
204 struct pthread_rwlock_t | |
205 { | |
206 _pthread_fastlock __rw_lock; | |
207 int __rw_readers; | |
208 _pthread_descr __rw_writer; | |
209 _pthread_descr __rw_read_waiting; | |
210 _pthread_descr __rw_write_waiting; | |
211 int __rw_kind; | |
212 int __rw_pshared; | |
213 } | |
214 | |
215 struct pthread_rwlockattr_t | |
216 { | |
217 int __lockkind; | |
218 int __pshared; | |
219 } | |
220 | |
221 alias c_ulong pthread_t; | |
222 } | |
223 else version( darwin ) | |
224 { | |
225 private | |
226 { | |
227 // #if defined(__LP64__) | |
228 // FIXME: what is LP64, is it important enough to be included? | |
229 version( LP64 ) | |
230 { | |
231 const __PTHREAD_SIZE__ = 1168; | |
232 const __PTHREAD_ATTR_SIZE__ = 56; | |
233 const __PTHREAD_MUTEXATTR_SIZE__ = 8; | |
234 const __PTHREAD_MUTEX_SIZE__ = 56; | |
235 const __PTHREAD_CONDATTR_SIZE__ = 8; | |
236 const __PTHREAD_COND_SIZE__ = 40; | |
237 const __PTHREAD_ONCE_SIZE__ = 8; | |
238 const __PTHREAD_RWLOCK_SIZE__ = 192; | |
239 const __PTHREAD_RWLOCKATTR_SIZE__ = 16; | |
240 } | |
241 else | |
242 { | |
243 const __PTHREAD_SIZE__ = 596; | |
244 const __PTHREAD_ATTR_SIZE__ = 36; | |
245 const __PTHREAD_MUTEXATTR_SIZE__ = 8; | |
246 const __PTHREAD_MUTEX_SIZE__ = 40; | |
247 const __PTHREAD_CONDATTR_SIZE__ = 4; | |
248 const __PTHREAD_COND_SIZE__ = 24; | |
249 const __PTHREAD_ONCE_SIZE__ = 4; | |
250 const __PTHREAD_RWLOCK_SIZE__ = 124; | |
251 const __PTHREAD_RWLOCKATTR_SIZE__ = 12; | |
252 } | |
253 } | |
254 | |
255 struct pthread_handler_rec | |
256 { | |
257 void function(void*) __routine; | |
258 void* __arg; | |
259 pthread_handler_rec* __next; | |
260 } | |
261 | |
262 struct pthread_attr_t | |
263 { | |
264 c_long __sig; | |
265 byte[__PTHREAD_ATTR_SIZE__] __opaque; | |
266 } | |
267 | |
268 struct pthread_cond_t | |
269 { | |
270 c_long __sig; | |
271 byte[__PTHREAD_COND_SIZE__] __opaque; | |
272 } | |
273 | |
274 struct pthread_condattr_t | |
275 { | |
276 c_long __sig; | |
277 byte[__PTHREAD_CONDATTR_SIZE__] __opaque; | |
278 } | |
279 | |
280 alias c_ulong pthread_key_t; | |
281 | |
282 struct pthread_mutex_t | |
283 { | |
284 c_long __sig; | |
285 byte[__PTHREAD_MUTEX_SIZE__] __opaque; | |
286 } | |
287 | |
288 struct pthread_mutexattr_t | |
289 { | |
290 c_long __sig; | |
291 byte[__PTHREAD_MUTEXATTR_SIZE__] __opaque; | |
292 } | |
293 | |
294 struct pthread_once_t | |
295 { | |
296 c_long __sig; | |
297 byte[__PTHREAD_ONCE_SIZE__] __opaque; | |
298 } | |
299 | |
300 struct pthread_rwlock_t | |
301 { | |
302 c_long __sig; | |
303 byte[__PTHREAD_RWLOCK_SIZE__] __opaque; | |
304 } | |
305 | |
306 struct pthread_rwlockattr_t | |
307 { | |
308 c_long __sig; | |
309 byte[__PTHREAD_RWLOCKATTR_SIZE__] __opaque; | |
310 } | |
311 | |
312 private struct _opaque_pthread_t | |
313 { | |
314 c_long __sig; | |
315 pthread_handler_rec* __cleanup_stack; | |
316 byte[__PTHREAD_SIZE__] __opaque; | |
317 } | |
318 | |
319 alias _opaque_pthread_t* pthread_t; | |
320 } | |
321 | |
322 // | |
323 // Barrier (BAR) | |
324 // | |
325 /* | |
326 pthread_barrier_t | |
327 pthread_barrierattr_t | |
328 */ | |
329 | |
330 version( linux ) | |
331 { | |
332 struct pthread_barrier_t | |
333 { | |
334 _pthread_fastlock __ba_lock; | |
335 int __ba_required; | |
336 int __ba_present; | |
337 _pthread_descr __ba_waiting; | |
338 } | |
339 | |
340 struct pthread_barrierattr_t | |
341 { | |
342 int __pshared; | |
343 } | |
344 } | |
345 else version( darwin ) | |
346 { | |
347 // NOTE: The following definitions are Tango-specific because darwin does | |
348 // not support them directly. | |
349 | |
350 struct pthread_barrier_t | |
351 { | |
352 pthread_mutex_t b_lock; | |
353 pthread_cond_t b_cond; | |
354 int b_count; | |
355 int b_waiters; | |
356 int b_generation; | |
357 } | |
358 | |
359 struct pthread_barrierattr_t | |
360 { | |
361 int pshared; | |
362 } | |
363 } | |
364 | |
365 // | |
366 // Spin (SPN) | |
367 // | |
368 /* | |
369 pthread_spinlock_t | |
370 */ | |
371 | |
372 version( linux ) | |
373 { | |
374 alias int pthread_spinlock_t; // volatile | |
375 } | |
376 else version( darwin ) | |
377 { | |
378 struct pthread_spinlock_t; | |
379 } | |
380 | |
381 // | |
382 // Timer (TMR) | |
383 // | |
384 /* | |
385 clockid_t | |
386 timer_t | |
387 */ | |
388 | |
389 // | |
390 // Trace (TRC) | |
391 // | |
392 /* | |
393 trace_attr_t | |
394 trace_event_id_t | |
395 trace_event_set_t | |
396 trace_id_t | |
397 */ |