comparison druntime/import/core/sys/posix/sys/types.d @ 1458:e0b2d67cfe7c

Added druntime (this should be removed once it works).
author Robert Clipsham <robert@octarineparrot.com>
date Tue, 02 Jun 2009 17:43:06 +0100
parents
children
comparison
equal deleted inserted replaced
1456:7b218ec1044f 1458:e0b2d67cfe7c
1 /**
2 * D header file for POSIX.
3 *
4 * Copyright: Copyright Sean Kelly 2005 - 2009.
5 * License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
6 * Authors: Sean Kelly
7 * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
8 *
9 * Copyright Sean Kelly 2005 - 2009.
10 * Distributed under the Boost Software License, Version 1.0.
11 * (See accompanying file LICENSE_1_0.txt or copy at
12 * http://www.boost.org/LICENSE_1_0.txt)
13 */
14 module core.sys.posix.sys.types;
15
16 private import core.sys.posix.config;
17 private import core.stdc.stdint;
18 public import core.stdc.stddef; // for size_t
19 public import core.stdc.time; // for clock_t, time_t
20
21 extern (C):
22
23 //
24 // Required
25 //
26 /*
27 blkcnt_t
28 blksize_t
29 dev_t
30 gid_t
31 ino_t
32 mode_t
33 nlink_t
34 off_t
35 pid_t
36 size_t
37 ssize_t
38 time_t
39 uid_t
40 */
41
42 version( linux )
43 {
44 static if( __USE_FILE_OFFSET64 )
45 {
46 alias long blkcnt_t;
47 alias ulong ino_t;
48 alias long off_t;
49 }
50 else
51 {
52 alias c_long blkcnt_t;
53 alias c_ulong ino_t;
54 alias c_long off_t;
55 }
56 alias c_long blksize_t;
57 alias ulong dev_t;
58 alias uint gid_t;
59 alias uint mode_t;
60 alias c_ulong nlink_t;
61 alias int pid_t;
62 //size_t (defined in core.stdc.stddef)
63 alias c_long ssize_t;
64 //time_t (defined in core.stdc.time)
65 alias uint uid_t;
66 }
67 else version( OSX )
68 {
69 alias long blkcnt_t;
70 alias int blksize_t;
71 alias int dev_t;
72 alias uint gid_t;
73 alias uint ino_t;
74 alias ushort mode_t;
75 alias ushort nlink_t;
76 alias long off_t;
77 alias int pid_t;
78 //size_t (defined in core.stdc.stddef)
79 alias size_t ssize_t;
80 //time_t (defined in core.stdc.time)
81 alias uint uid_t;
82 }
83 else version( freebsd )
84 {
85 alias long blkcnt_t;
86 alias uint blksize_t;
87 alias uint dev_t;
88 alias uint gid_t;
89 alias uint ino_t;
90 alias ushort mode_t;
91 alias ushort nlink_t;
92 alias long off_t;
93 alias int pid_t;
94 //size_t (defined in core.stdc.stddef)
95 alias size_t ssize_t;
96 //time_t (defined in core.stdc.time)
97 alias uint uid_t;
98 alias uint fflags_t;
99 }
100
101 //
102 // XOpen (XSI)
103 //
104 /*
105 clock_t
106 fsblkcnt_t
107 fsfilcnt_t
108 id_t
109 key_t
110 suseconds_t
111 useconds_t
112 */
113
114 version( linux )
115 {
116 static if( __USE_FILE_OFFSET64 )
117 {
118 alias ulong fsblkcnt_t;
119 alias ulong fsfilcnt_t;
120 }
121 else
122 {
123 alias c_ulong fsblkcnt_t;
124 alias c_ulong fsfilcnt_t;
125 }
126 // clock_t (defined in core.stdc.time)
127 alias uint id_t;
128 alias int key_t;
129 alias c_long suseconds_t;
130 alias uint useconds_t;
131 }
132 else version( OSX )
133 {
134 //clock_t
135 alias uint fsblkcnt_t;
136 alias uint fsfilcnt_t;
137 alias uint id_t;
138 // key_t
139 alias int suseconds_t;
140 alias uint useconds_t;
141 }
142 else version( freebsd )
143 {
144 //clock_t
145 alias ulong fsblkcnt_t;
146 alias ulong fsfilcnt_t;
147 alias long id_t;
148 alias c_long key_t;
149 alias c_long suseconds_t;
150 alias uint useconds_t;
151 }
152
153 //
154 // Thread (THR)
155 //
156 /*
157 pthread_attr_t
158 pthread_cond_t
159 pthread_condattr_t
160 pthread_key_t
161 pthread_mutex_t
162 pthread_mutexattr_t
163 pthread_once_t
164 pthread_rwlock_t
165 pthread_rwlockattr_t
166 pthread_t
167 */
168
169 version( linux )
170 {
171 private struct __sched_param
172 {
173 int __sched_priority;
174 }
175
176 struct pthread_attr_t
177 {
178 int __detachstate;
179 int __schedpolicy;
180 __sched_param __schedparam;
181 int __inheritsched;
182 int __scope;
183 size_t __guardsize;
184 int __stackaddr_set;
185 void* __stackaddr;
186 size_t __stacksize;
187 }
188
189 private alias int __atomic_lock_t;
190
191 private struct _pthread_fastlock
192 {
193 c_long __status;
194 __atomic_lock_t __spinlock;
195 }
196
197 private alias void* _pthread_descr;
198
199 private alias long __pthread_cond_align_t;
200
201 struct pthread_cond_t
202 {
203 _pthread_fastlock __c_lock;
204 _pthread_descr __c_waiting;
205 char[48 -
206 _pthread_fastlock.sizeof -
207 _pthread_descr.sizeof -
208 __pthread_cond_align_t.sizeof]
209 __padding;
210 __pthread_cond_align_t __align;
211 }
212
213 struct pthread_condattr_t
214 {
215 int __dummy;
216 }
217
218 alias uint pthread_key_t;
219
220 struct pthread_mutex_t
221 {
222 int __m_reserved;
223 int __m_count;
224 _pthread_descr __m_owner;
225 int __m_kind;
226 _pthread_fastlock __m_lock;
227 }
228
229 struct pthread_mutexattr_t
230 {
231 int __mutexkind;
232 }
233
234 alias int pthread_once_t;
235
236 struct pthread_rwlock_t
237 {
238 _pthread_fastlock __rw_lock;
239 int __rw_readers;
240 _pthread_descr __rw_writer;
241 _pthread_descr __rw_read_waiting;
242 _pthread_descr __rw_write_waiting;
243 int __rw_kind;
244 int __rw_pshared;
245 }
246
247 struct pthread_rwlockattr_t
248 {
249 int __lockkind;
250 int __pshared;
251 }
252
253 alias c_ulong pthread_t;
254 }
255 else version( OSX )
256 {
257 version( X86_64 )
258 {
259 enum __PTHREAD_SIZE__ = 1168;
260 enum __PTHREAD_ATTR_SIZE__ = 56;
261 enum __PTHREAD_MUTEXATTR_SIZE__ = 8;
262 enum __PTHREAD_MUTEX_SIZE__ = 56;
263 enum __PTHREAD_CONDATTR_SIZE__ = 8;
264 enum __PTHREAD_COND_SIZE__ = 40;
265 enum __PTHREAD_ONCE_SIZE__ = 8;
266 enum __PTHREAD_RWLOCK_SIZE__ = 192;
267 enum __PTHREAD_RWLOCKATTR_SIZE__ = 16;
268 }
269 else version( X86 )
270 {
271 enum __PTHREAD_SIZE__ = 596;
272 enum __PTHREAD_ATTR_SIZE__ = 36;
273 enum __PTHREAD_MUTEXATTR_SIZE__ = 8;
274 enum __PTHREAD_MUTEX_SIZE__ = 40;
275 enum __PTHREAD_CONDATTR_SIZE__ = 4;
276 enum __PTHREAD_COND_SIZE__ = 24;
277 enum __PTHREAD_ONCE_SIZE__ = 4;
278 enum __PTHREAD_RWLOCK_SIZE__ = 124;
279 enum __PTHREAD_RWLOCKATTR_SIZE__ = 12;
280 }
281
282 struct pthread_handler_rec
283 {
284 void function(void*) __routine;
285 void* __arg;
286 pthread_handler_rec* __next;
287 }
288
289 struct pthread_attr_t
290 {
291 c_long __sig;
292 byte[__PTHREAD_ATTR_SIZE__] __opaque;
293 }
294
295 struct pthread_cond_t
296 {
297 c_long __sig;
298 byte[__PTHREAD_COND_SIZE__] __opaque;
299 }
300
301 struct pthread_condattr_t
302 {
303 c_long __sig;
304 byte[__PTHREAD_CONDATTR_SIZE__] __opaque;
305 }
306
307 alias c_ulong pthread_key_t;
308
309 struct pthread_mutex_t
310 {
311 c_long __sig;
312 byte[__PTHREAD_MUTEX_SIZE__] __opaque;
313 }
314
315 struct pthread_mutexattr_t
316 {
317 c_long __sig;
318 byte[__PTHREAD_MUTEXATTR_SIZE__] __opaque;
319 }
320
321 struct pthread_once_t
322 {
323 c_long __sig;
324 byte[__PTHREAD_ONCE_SIZE__] __opaque;
325 }
326
327 struct pthread_rwlock_t
328 {
329 c_long __sig;
330 byte[__PTHREAD_RWLOCK_SIZE__] __opaque;
331 }
332
333 struct pthread_rwlockattr_t
334 {
335 c_long __sig;
336 byte[__PTHREAD_RWLOCKATTR_SIZE__] __opaque;
337 }
338
339 private struct _opaque_pthread_t
340 {
341 c_long __sig;
342 pthread_handler_rec* __cleanup_stack;
343 byte[__PTHREAD_SIZE__] __opaque;
344 }
345
346 alias _opaque_pthread_t* pthread_t;
347 }
348 else version( freebsd )
349 {
350 alias int lwpid_t;
351
352 alias void* pthread_attr_t;
353 alias void* pthread_cond_t;
354 alias void* pthread_condattr_t;
355 alias void* pthread_key_t;
356 alias void* pthread_mutex_t;
357 alias void* pthread_mutexattr_t;
358 alias void* pthread_once_t;
359 alias void* pthread_rwlock_t;
360 alias void* pthread_rwlockattr_t;
361 alias void* pthread_t;
362 }
363
364 //
365 // Barrier (BAR)
366 //
367 /*
368 pthread_barrier_t
369 pthread_barrierattr_t
370 */
371
372 version( linux )
373 {
374 struct pthread_barrier_t
375 {
376 _pthread_fastlock __ba_lock;
377 int __ba_required;
378 int __ba_present;
379 _pthread_descr __ba_waiting;
380 }
381
382 struct pthread_barrierattr_t
383 {
384 int __pshared;
385 }
386 }
387 else version( freebsd )
388 {
389 alias void* pthread_barrier_t;
390 alias void* pthread_barrierattr_t;
391 }
392
393 //
394 // Spin (SPN)
395 //
396 /*
397 pthread_spinlock_t
398 */
399
400 version( linux )
401 {
402 alias int pthread_spinlock_t; // volatile
403 }
404 else version( OSX )
405 {
406 //struct pthread_spinlock_t;
407 }
408 else version( freebsd )
409 {
410 alias void* pthread_spinlock_t;
411 }
412
413 //
414 // Timer (TMR)
415 //
416 /*
417 clockid_t
418 timer_t
419 */
420
421 //
422 // Trace (TRC)
423 //
424 /*
425 trace_attr_t
426 trace_event_id_t
427 trace_event_set_t
428 trace_id_t
429 */