comparison dstep/coreservices/carboncore/Multiprocessing.d @ 11:07194b026fa4

Added bindings to a couple of frameworks, new license + some other things
author Jacob Carlborg <doob@me.com>
date Sat, 01 Aug 2009 15:03:28 +0200
parents
children
comparison
equal deleted inserted replaced
10:27e00625790b 11:07194b026fa4
1 /**
2 * Copyright: Copyright (c) 2009 Jacob Carlborg.
3 * Authors: Jacob Carlborg
4 * Version: Initial created: Jul 21, 2009
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
6 */
7 module dstep.coreservices.carboncore.Multiprocessing;
8
9 //import dstep.AvailabilityMacros;
10 import dstep.coreservices.carboncore.MacTypes;
11 //import dstep.stdarg;
12
13 struct OpaqueMPProcessID;
14 struct OpaqueMPTaskID;
15 struct OpaqueMPQueueID;
16 struct OpaqueMPSemaphoreID;
17 struct OpaqueMPCriticalRegionID;
18 struct OpaqueMPTimerID;
19 struct OpaqueMPEventID;
20 struct OpaqueMPAddressSpaceID;
21 struct OpaqueMPNotificationID;
22 struct OpaqueMPCoherenceID;
23 struct OpaqueMPCpuID;
24 struct OpaqueMPAreaID;
25 struct OpaqueMPConsoleID;
26 struct OpaqueMPOpaqueID;
27
28
29 alias OpaqueMPProcessID* MPProcessID;
30 alias OpaqueMPTaskID* MPTaskID;
31 alias OpaqueMPQueueID* MPQueueID;
32 alias OpaqueMPSemaphoreID* MPSemaphoreID;
33 alias OpaqueMPCriticalRegionID* MPCriticalRegionID;
34 alias OpaqueMPTimerID* MPTimerID;
35 alias OpaqueMPEventID* MPEventID;
36 alias OpaqueMPAddressSpaceID* MPAddressSpaceID;
37 alias OpaqueMPNotificationID* MPNotificationID;
38 alias OpaqueMPCoherenceID* MPCoherenceID;
39 alias OpaqueMPCpuID* MPCpuID;
40 alias OpaqueMPAreaID* MPAreaID;
41 alias OpaqueMPConsoleID* MPConsoleID;
42 alias OpaqueMPOpaqueID* MPOpaqueID;
43 alias uint MPOpaqueIDClass;
44 alias uint MPTaskOptions;
45 alias uint TaskStorageIndex;
46 alias LogicalAddress TaskStorageValue;
47 alias uint MPSemaphoreCount;
48 alias uint MPTaskWeight;
49 alias uint MPEventFlags;
50 alias uint MPExceptionKind;
51 alias uint MPTaskStateKind;
52 alias uint MPPageSizeClass;
53 alias uint MPDebuggerLevel;
54 alias ubyte MPRemoteContext;
55
56 extern (C)
57 {
58 alias ubyte function () MPIsFullyInitializedProc;
59 alias void * function (void*) MPRemoteProcedure;
60 alias int function (void*) TaskProc;
61 }
62
63 enum
64 {
65 MPLibrary_MajorVersion = 2,
66 MPLibrary_MinorVersion = 3,
67 MPLibrary_Release = 1,
68 MPLibrary_DevelopmentRevision = 1
69 }
70
71 enum
72 {
73 kOpaqueAnyID = 0,
74 kOpaqueProcessID = 1,
75 kOpaqueTaskID = 2,
76 kOpaqueTimerID = 3,
77 kOpaqueQueueID = 4,
78 kOpaqueSemaphoreID = 5,
79 kOpaqueCriticalRegionID = 6,
80 kOpaqueCpuID = 7,
81 kOpaqueAddressSpaceID = 8,
82 kOpaqueEventID = 9,
83 kOpaqueCoherenceID = 10,
84 kOpaqueAreaID = 11,
85 kOpaqueNotificationID = 12,
86 kOpaqueConsoleID = 13
87 }
88
89 enum
90 {
91 kMPNoID = 0
92 }
93
94 enum
95 {
96 kDurationImmediate = 0L,
97 kDurationForever = 0x7FFFFFFF,
98 kDurationMillisecond = 1,
99 kDurationMicrosecond = -1
100 }
101
102 enum
103 {
104 kMPCreateTaskSuspendedMask = 1L << 0,
105 kMPCreateTaskTakesAllExceptionsMask = 1L << 1,
106 kMPCreateTaskNotDebuggableMask = 1L << 2,
107 kMPCreateTaskValidOptionsMask = kMPCreateTaskSuspendedMask | kMPCreateTaskTakesAllExceptionsMask | kMPCreateTaskNotDebuggableMask
108 }
109
110 enum
111 {
112 kMPPreserveTimerIDMask = 1L << 0,
113 kMPTimeIsDeltaMask = 1L << 1,
114 kMPTimeIsDurationMask = 1L << 2
115 }
116
117 enum
118 {
119 kMPMaxAllocSize = 1024L * 1024 * 1024
120 }
121
122 enum
123 {
124 kMPAllocateDefaultAligned = 0,
125 kMPAllocate8ByteAligned = 3,
126 kMPAllocate16ByteAligned = 4,
127 kMPAllocate32ByteAligned = 5,
128 kMPAllocate1024ByteAligned = 10,
129 kMPAllocate4096ByteAligned = 12,
130 kMPAllocateMaxAlignment = 16,
131 kMPAllocateAltiVecAligned = kMPAllocate16ByteAligned,
132 kMPAllocateVMXAligned = kMPAllocateAltiVecAligned,
133 kMPAllocateVMPageAligned = 254,
134 kMPAllocateInterlockAligned = 255
135 }
136
137 enum
138 {
139 kMPAllocateClearMask = 0x0001,
140 kMPAllocateGloballyMask = 0x0002,
141 kMPAllocateResidentMask = 0x0004,
142 kMPAllocateNoGrowthMask = 0x0010,
143 kMPAllocateNoCreateMask = 0x0020
144 }
145
146 enum
147 {
148 kMPTaskStateRegisters = 0,
149 kMPTaskStateFPU = 1,
150 kMPTaskStateVectors = 2,
151 kMPTaskStateMachine = 3,
152 kMPTaskState32BitMemoryException = 4,
153 kMPTaskStateTaskInfo = 5
154 }
155
156 enum
157 {
158 kMPTaskPropagate = 0,
159 kMPTaskResumeStep = 1,
160 kMPTaskResumeBranch = 2,
161 kMPTaskResumeMask = 0x0000,
162 kMPTaskPropagateMask = 1 << kMPTaskPropagate,
163 kMPTaskResumeStepMask = 1 << kMPTaskResumeStep,
164 kMPTaskResumeBranchMask = 1 << kMPTaskResumeBranch
165 }
166
167 enum
168 {
169 kMPTaskBlocked = 0,
170 kMPTaskReady = 1,
171 kMPTaskRunning = 2
172 }
173
174 enum
175 {
176 kMPTaskInfoVersion = 3
177 }
178
179 enum
180 {
181 kMPLowLevelDebugger = 0x00000000,
182 kMPMidLevelDebugger = 0x10000000,
183 kMPHighLevelDebugger = 0x20000000
184 }
185
186 enum
187 {
188 kMPAnyRemoteContext = 0,
189 kMPOwningProcessRemoteContext = 1,
190 kMPInterruptRemoteContext = 2,
191 kMPAsyncInterruptRemoteContext = 3
192 }
193
194 struct MPTaskInfoVersion2
195 {
196 uint version_;
197 uint name;
198 uint queueName;
199 ushort runState;
200 ushort lastCPU;
201 uint weight;
202 MPProcessID processID;
203 AbsoluteTime cpuTime;
204 AbsoluteTime schedTime;
205 AbsoluteTime creationTime;
206 uint codePageFaults;
207 uint dataPageFaults;
208 uint preemptions;
209 MPCpuID cpuID;
210 }
211
212
213 struct MPTaskInfo
214 {
215 uint version_;
216 uint name;
217 uint queueName;
218 ushort runState;
219 ushort lastCPU;
220 uint weight;
221 MPProcessID processID;
222 AbsoluteTime cpuTime;
223 AbsoluteTime schedTime;
224 AbsoluteTime creationTime;
225 uint codePageFaults;
226 uint dataPageFaults;
227 uint preemptions;
228 MPCpuID cpuID;
229 MPOpaqueID blockedObject;
230 MPAddressSpaceID spaceID;
231 LogicalAddress stackBase;
232 LogicalAddress stackLimit;
233 LogicalAddress stackCurr;
234 }
235
236 extern (C)
237 {
238 uint MPProcessors ();
239 uint MPProcessorsScheduled ();
240 int MPCreateTask (TaskProc entryPoint, void* parameter, uint stackSize, MPQueueID notifyQueue, void* terminationParameter1, void* terminationParameter2, uint options, MPTaskID* task);
241 int MPTerminateTask (MPTaskID task, int terminationStatus);
242 int MPSetTaskWeight (MPTaskID task, uint weight);
243 ubyte MPTaskIsPreemptive (MPTaskID taskID);
244 void MPExit (int status);
245 void MPYield ();
246 MPTaskID MPCurrentTaskID ();
247 int MPSetTaskType (MPTaskID task, uint taskType);
248 int MPAllocateTaskStorageIndex (TaskStorageIndex* taskIndex);
249 int MPDeallocateTaskStorageIndex (uint taskIndex);
250 int MPSetTaskStorageValue (uint taskIndex, TaskStorageValue value);
251 TaskStorageValue MPGetTaskStorageValue (uint taskIndex);
252 int MPCreateQueue (MPQueueID* queue);
253 int MPDeleteQueue (MPQueueID queue);
254 int MPNotifyQueue (MPQueueID queue, void* param1, void* param2, void* param3);
255 int MPWaitOnQueue (MPQueueID queue, void** param1, void** param2, void** param3, int timeout);
256 int MPSetQueueReserve (MPQueueID queue, uint count);
257 int MPCreateSemaphore (uint maximumValue, uint initialValue, MPSemaphoreID* semaphore);
258 int MPDeleteSemaphore (MPSemaphoreID semaphore);
259 int MPSignalSemaphore (MPSemaphoreID semaphore);
260 int MPWaitOnSemaphore (MPSemaphoreID semaphore, int timeout);
261 int MPCreateCriticalRegion (MPCriticalRegionID* criticalRegion);
262 int MPDeleteCriticalRegion (MPCriticalRegionID criticalRegion);
263 int MPEnterCriticalRegion (MPCriticalRegionID criticalRegion, int timeout);
264 int MPExitCriticalRegion (MPCriticalRegionID criticalRegion);
265 int MPCreateEvent (MPEventID* event);
266 int MPDeleteEvent (MPEventID event);
267 int MPSetEvent (MPEventID event, uint flags);
268 int MPWaitForEvent (MPEventID event, MPEventFlags* flags, int timeout);
269 int MPCreateNotification (MPNotificationID* notificationID);
270 int MPDeleteNotification (MPNotificationID notificationID);
271 int MPModifyNotification (MPNotificationID notificationID, MPOpaqueID anID, void* notifyParam1, void* notifyParam2, void* notifyParam3);
272 int MPModifyNotificationParameters (MPNotificationID notificationID, uint kind, void* notifyParam1, void* notifyParam2, void* notifyParam3);
273 int MPCauseNotification (MPNotificationID notificationID);
274 int MPDelayUntil (AbsoluteTime* expirationTime);
275 int MPCreateTimer (MPTimerID* timerID);
276 int MPDeleteTimer (MPTimerID timerID);
277 int MPSetTimerNotify (MPTimerID timerID, MPOpaqueID anID, void* notifyParam1, void* notifyParam2, void* notifyParam3);
278 int MPArmTimer (MPTimerID timerID, AbsoluteTime* expirationTime, uint options);
279 int MPCancelTimer (MPTimerID timerID, AbsoluteTime* timeRemaining);
280 LogicalAddress MPAllocateAligned (uint size, ubyte alignment, uint options);
281 LogicalAddress MPAllocate (uint size);
282 void MPFree (LogicalAddress object);
283 uint MPGetAllocatedBlockSize (LogicalAddress object);
284 void MPBlockCopy (LogicalAddress source, LogicalAddress destination, uint size);
285 void MPBlockClear (LogicalAddress address, uint size);
286 int MPSetExceptionHandler (MPTaskID task, MPQueueID exceptionQ);
287 int MPDisposeTaskException (MPTaskID task, uint action);
288 int MPExtractTaskState (MPTaskID task, uint kind, void* info);
289 int MPSetTaskState (MPTaskID task, uint kind, void* info);
290 int MPThrowException (MPTaskID task, uint kind);
291 int MPRegisterDebugger (MPQueueID queue, uint level);
292 int MPUnregisterDebugger (MPQueueID queue);
293 void* MPRemoteCall (MPRemoteProcedure remoteProc, void* parameter, ubyte context);
294 void* MPRemoteCallCFM (MPRemoteProcedure remoteProc, void* parameter, ubyte context);
295 ubyte _MPIsFullyInitialized ();
296 void _MPLibraryVersion (char** versionCString, UInt32* major, UInt32* minor, UInt32* release, UInt32* revision);
297 ubyte _MPLibraryIsCompatible (char* versionCString, uint major, uint minor, uint release, uint revision);
298 }