Multiprocessing.pas 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498
  1. {
  2. File: Multiprocessing.p
  3. Contains: Multiprocessing interfaces
  4. Version: Technology: Multiprocessing API version 2.4, integrated NanoKernel support
  5. Release: Universal Interfaces 3.4.2
  6. Copyright: © 1995-2002 DayStar Digital, Inc.
  7. Bugs?: For bug reports, consult the following page on
  8. the World Wide Web:
  9. http://www.freepascal.org/bugs.html
  10. }
  11. {
  12. ===========================================================================================
  13. *** WARNING: You must properly check the availability of MP services before calling them!
  14. See the section titled "Checking API Availability".
  15. ===========================================================================================
  16. }
  17. {
  18. Modified for use with Free Pascal
  19. Version 200
  20. Please report any bugs to <[email protected]>
  21. }
  22. {$mode macpas}
  23. {$packenum 1}
  24. {$macro on}
  25. {$inline on}
  26. {$CALLING MWPASCAL}
  27. unit Multiprocessing;
  28. interface
  29. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  30. {$setc GAP_INTERFACES_VERSION := $0200}
  31. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  32. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  33. {$endc}
  34. {$ifc defined CPUPOWERPC and defined CPUI386}
  35. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  36. {$endc}
  37. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  38. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  39. {$endc}
  40. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  41. {$setc __ppc__ := 1}
  42. {$elsec}
  43. {$setc __ppc__ := 0}
  44. {$endc}
  45. {$ifc not defined __i386__ and defined CPUI386}
  46. {$setc __i386__ := 1}
  47. {$elsec}
  48. {$setc __i386__ := 0}
  49. {$endc}
  50. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  51. {$error Conflicting definitions for __ppc__ and __i386__}
  52. {$endc}
  53. {$ifc defined __ppc__ and __ppc__}
  54. {$setc TARGET_CPU_PPC := TRUE}
  55. {$setc TARGET_CPU_X86 := FALSE}
  56. {$elifc defined __i386__ and __i386__}
  57. {$setc TARGET_CPU_PPC := FALSE}
  58. {$setc TARGET_CPU_X86 := TRUE}
  59. {$elsec}
  60. {$error Neither __ppc__ nor __i386__ is defined.}
  61. {$endc}
  62. {$setc TARGET_CPU_PPC_64 := FALSE}
  63. {$ifc defined FPC_BIG_ENDIAN}
  64. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  65. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  66. {$elifc defined FPC_LITTLE_ENDIAN}
  67. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  68. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  69. {$elsec}
  70. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  71. {$endc}
  72. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  73. {$setc CALL_NOT_IN_CARBON := FALSE}
  74. {$setc OLDROUTINENAMES := FALSE}
  75. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  76. {$setc OPAQUE_UPP_TYPES := TRUE}
  77. {$setc OTCARBONAPPLICATION := TRUE}
  78. {$setc OTKERNEL := FALSE}
  79. {$setc PM_USE_SESSION_APIS := TRUE}
  80. {$setc TARGET_API_MAC_CARBON := TRUE}
  81. {$setc TARGET_API_MAC_OS8 := FALSE}
  82. {$setc TARGET_API_MAC_OSX := TRUE}
  83. {$setc TARGET_CARBON := TRUE}
  84. {$setc TARGET_CPU_68K := FALSE}
  85. {$setc TARGET_CPU_MIPS := FALSE}
  86. {$setc TARGET_CPU_SPARC := FALSE}
  87. {$setc TARGET_OS_MAC := TRUE}
  88. {$setc TARGET_OS_UNIX := FALSE}
  89. {$setc TARGET_OS_WIN32 := FALSE}
  90. {$setc TARGET_RT_MAC_68881 := FALSE}
  91. {$setc TARGET_RT_MAC_CFM := FALSE}
  92. {$setc TARGET_RT_MAC_MACHO := TRUE}
  93. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  94. {$setc TYPE_BOOL := FALSE}
  95. {$setc TYPE_EXTENDED := FALSE}
  96. {$setc TYPE_LONGLONG := TRUE}
  97. uses MacTypes;
  98. {$ALIGN POWER}
  99. {
  100. ===========================================================================================
  101. This is the header file for version 2.4 of the Mac OS multiprocessing support. This version
  102. has been totally reimplemented and has significant new services. The main goal of the
  103. reimplementation has been to transfer task management into the core operating system to provide
  104. much more reliable and more efficient operation, including on single processor machines.
  105. The memory management has also been massively improved, it is much faster and wastes much
  106. less space. New services include POSIX style per-task storage, timers with millisecond and
  107. microsecond resolutions, memory allocation at a specified alignment, and system pageable
  108. and RAM resident memory pools. See the MP API documentation for details.
  109. The old "DayStar" debugging services (whose names began with an underscore) have been
  110. removed from this header. A very few are still implemented for binary compatibility, or in
  111. cases where they happened to be exposed inappropriately. (E.g. _MPIsFullyInitialized must
  112. be called to see if the MP API is ReallyTrulyª usable.) New code and recompiles of old
  113. code should avoid use of these defunct services, except for _MPIsFullyInitialized.
  114. ===========================================================================================
  115. }
  116. {
  117. ===========================================================================================
  118. The following services are from the original MP API and remain supported in version 2.0:
  119. MPProcessors
  120. MPCreateTask
  121. MPTerminateTask
  122. MPCurrentTaskID
  123. MPYield
  124. MPExit
  125. MPCreateQueue
  126. MPDeleteQueue
  127. MPNotifyQueue
  128. MPWaitOnQueue
  129. MPCreateSemaphore
  130. MPCreateBinarySemaphore (In C only, a macro that calls MPCreateSemaphore.)
  131. MPDeleteSemaphore
  132. MPSignalSemaphore
  133. MPWaitOnSemaphore
  134. MPCreateCriticalRegion
  135. MPDeleteCriticalRegion
  136. MPEnterCriticalRegion
  137. MPExitCriticalRegion
  138. MPAllocate (Deprecated, use MPAllocateAligned for new builds.)
  139. MPFree
  140. MPBlockCopy
  141. MPLibraryIsLoaded (In C only, a macro.)
  142. _MPIsFullyInitialized (See comments about checking for MP API availability.)
  143. ===========================================================================================
  144. }
  145. {
  146. ===========================================================================================
  147. The following services are new in version 2.0:
  148. MPProcessorsScheduled
  149. MPSetTaskWeight
  150. MPTaskIsPreemptive
  151. MPAllocateTaskStorageIndex
  152. MPDeallocateTaskStorageIndex
  153. MPSetTaskStorageValue
  154. MPGetTaskStorageValue
  155. MPSetQueueReserve
  156. MPCreateEvent
  157. MPDeleteEvent
  158. MPSetEvent
  159. MPWaitForEvent
  160. UpTime
  161. DurationToAbsolute
  162. AbsoluteToDuration
  163. MPDelayUntil
  164. MPCreateTimer
  165. MPDeleteTimer
  166. MPSetTimerNotify
  167. MPArmTimer
  168. MPCancelTimer
  169. MPSetExceptionHandler
  170. MPThrowException
  171. MPDisposeTaskException
  172. MPExtractTaskState
  173. MPSetTaskState
  174. MPRegisterDebugger
  175. MPUnregisterDebugger
  176. MPAllocateAligned (Preferred over MPAllocate.)
  177. MPGetAllocatedBlockSize
  178. MPBlockClear
  179. MPDataToCode
  180. MPRemoteCall (Preferred over _MPRPC.)
  181. ===========================================================================================
  182. }
  183. {
  184. ===========================================================================================
  185. The following services are new in version 2.1:
  186. MPCreateNotification
  187. MPDeleteNotification
  188. MPModifyNotification
  189. MPCauseNotification
  190. MPGetNextTaskID
  191. MPGetNextCpuID
  192. ===========================================================================================
  193. }
  194. {
  195. ===========================================================================================
  196. The following services are "unofficial" extensions to the original API. They are not in
  197. the multiprocessing API documentation, but were in previous versions of this header. They
  198. remain supported in version 2.0. They may not be supported in other environments.
  199. _MPRPC (Deprecated, use MPRemoteCall for new builds.)
  200. _MPAllocateSys (Deprecated, use MPAllocateAligned for new builds.)
  201. _MPTaskIsToolboxSafe
  202. _MPLibraryVersion
  203. _MPLibraryIsCompatible
  204. ===========================================================================================
  205. }
  206. {
  207. ===========================================================================================
  208. The following services were in previous versions of this header for "debugging only" use.
  209. They are NOT implemented in version 2.0. For old builds they can be accessed by defining
  210. the symbol MPIncludeDefunctServices to have a nonzero value.
  211. _MPInitializePrintf
  212. _MPPrintf
  213. _MPDebugStr
  214. _MPStatusPString
  215. _MPStatusCString
  216. ===========================================================================================
  217. }
  218. {
  219. ¤
  220. ===========================================================================================
  221. General Types and Constants
  222. ===========================
  223. }
  224. const
  225. MPLibrary_MajorVersion = 2; { ! When these change be sure to update the build versions }
  226. MPLibrary_MinorVersion = 4; { ! used in the startup check in MPInitializeAPI! }
  227. MPLibrary_Release = 1;
  228. MPLibrary_DevelopmentRevision = 1;
  229. type
  230. MPProcessID = ^SInt32; { an opaque 32-bit type }
  231. MPProcessIDPtr = ^MPProcessID; { when a var xx:MPProcessID parameter can be nil, it is changed to xx: MPProcessIDPtr }
  232. MPTaskID = ^SInt32; { an opaque 32-bit type }
  233. MPTaskIDPtr = ^MPTaskID; { when a var xx:MPTaskID parameter can be nil, it is changed to xx: MPTaskIDPtr }
  234. MPQueueID = ^SInt32; { an opaque 32-bit type }
  235. MPQueueIDPtr = ^MPQueueID; { when a var xx:MPQueueID parameter can be nil, it is changed to xx: MPQueueIDPtr }
  236. MPSemaphoreID = ^SInt32; { an opaque 32-bit type }
  237. MPSemaphoreIDPtr = ^MPSemaphoreID; { when a var xx:MPSemaphoreID parameter can be nil, it is changed to xx: MPSemaphoreIDPtr }
  238. MPCriticalRegionID = ^SInt32; { an opaque 32-bit type }
  239. MPCriticalRegionIDPtr = ^MPCriticalRegionID; { when a var xx:MPCriticalRegionID parameter can be nil, it is changed to xx: MPCriticalRegionIDPtr }
  240. MPTimerID = ^SInt32; { an opaque 32-bit type }
  241. MPTimerIDPtr = ^MPTimerID; { when a var xx:MPTimerID parameter can be nil, it is changed to xx: MPTimerIDPtr }
  242. MPEventID = ^SInt32; { an opaque 32-bit type }
  243. MPEventIDPtr = ^MPEventID; { when a var xx:MPEventID parameter can be nil, it is changed to xx: MPEventIDPtr }
  244. MPAddressSpaceID = ^SInt32; { an opaque 32-bit type }
  245. MPAddressSpaceIDPtr = ^MPAddressSpaceID; { when a var xx:MPAddressSpaceID parameter can be nil, it is changed to xx: MPAddressSpaceIDPtr }
  246. MPNotificationID = ^SInt32; { an opaque 32-bit type }
  247. MPNotificationIDPtr = ^MPNotificationID; { when a var xx:MPNotificationID parameter can be nil, it is changed to xx: MPNotificationIDPtr }
  248. MPCoherenceID = ^SInt32; { an opaque 32-bit type }
  249. MPCoherenceIDPtr = ^MPCoherenceID; { when a var xx:MPCoherenceID parameter can be nil, it is changed to xx: MPCoherenceIDPtr }
  250. MPCpuID = ^SInt32; { an opaque 32-bit type }
  251. MPCpuIDPtr = ^MPCpuID; { when a var xx:MPCpuID parameter can be nil, it is changed to xx: MPCpuIDPtr }
  252. MPAreaID = ^SInt32; { an opaque 32-bit type }
  253. MPAreaIDPtr = ^MPAreaID; { when a var xx:MPAreaID parameter can be nil, it is changed to xx: MPAreaIDPtr }
  254. MPConsoleID = ^SInt32; { an opaque 32-bit type }
  255. MPConsoleIDPtr = ^MPConsoleID; { when a var xx:MPConsoleID parameter can be nil, it is changed to xx: MPConsoleIDPtr }
  256. MPOpaqueID = ^SInt32; { an opaque 32-bit type }
  257. MPOpaqueIDPtr = ^MPOpaqueID; { when a var xx:MPOpaqueID parameter can be nil, it is changed to xx: MPOpaqueIDPtr }
  258. const
  259. { Values for MPOpaqueIDClass. }
  260. kOpaqueAnyID = 0;
  261. kOpaqueProcessID = 1;
  262. kOpaqueTaskID = 2;
  263. kOpaqueTimerID = 3;
  264. kOpaqueQueueID = 4;
  265. kOpaqueSemaphoreID = 5;
  266. kOpaqueCriticalRegionID = 6;
  267. kOpaqueCpuID = 7;
  268. kOpaqueAddressSpaceID = 8;
  269. kOpaqueEventID = 9;
  270. kOpaqueCoherenceID = 10;
  271. kOpaqueAreaID = 11;
  272. kOpaqueNotificationID = 12;
  273. kOpaqueConsoleID = 13;
  274. type
  275. MPOpaqueIDClass = UInt32;
  276. const
  277. kMPNoID = 0; { New code should use kInvalidID everywhere. }
  278. type
  279. MPTaskOptions = OptionBits;
  280. TaskStorageIndex = UInt32;
  281. TaskStorageValue = UInt32;
  282. MPSemaphoreCount = ItemCount;
  283. MPTaskWeight = UInt32;
  284. MPEventFlags = UInt32;
  285. MPEventFlagsPtr = ^MPEventFlags; { when a VAR xx: MPEventFlags parameter can be nil, it is changed to xx: MPEventFlagsPtr }
  286. MPExceptionKind = UInt32;
  287. MPTaskStateKind = UInt32;
  288. MPPageSizeClass = UInt32;
  289. const
  290. kDurationImmediate = 0;
  291. kDurationForever = $7FFFFFFF;
  292. kDurationMillisecond = 1;
  293. kDurationMicrosecond = -1;
  294. {
  295. ¤
  296. ===========================================================================================
  297. Process/Processor Services
  298. ==========================
  299. }
  300. {
  301. * MPProcessors()
  302. *
  303. * Availability:
  304. * Non-Carbon CFM: in MPLibrary 1.0 and later
  305. * CarbonLib: in CarbonLib 1.0 and later
  306. * Mac OS X: in version 10.0 and later
  307. }
  308. function MPProcessors: ItemCount; external name '_MPProcessors';
  309. { The physical total. }
  310. {
  311. * MPProcessorsScheduled()
  312. *
  313. * Availability:
  314. * Non-Carbon CFM: in MPLibrary 2.0 and later
  315. * CarbonLib: in CarbonLib 1.0 and later
  316. * Mac OS X: in version 10.0 and later
  317. }
  318. function MPProcessorsScheduled: ItemCount; external name '_MPProcessorsScheduled';
  319. { Those currently in use. }
  320. {
  321. ¤
  322. ===========================================================================================
  323. Tasking Services
  324. ================
  325. }
  326. const
  327. { For MPCreateTask options }
  328. kMPCreateTaskTakesAllExceptionsMask = $00000002;
  329. kMPCreateTaskNotDebuggableMask = $00000004;
  330. kMPCreateTaskValidOptionsMask = $00000006;
  331. { ------------------------------------------------------------------------------------------- }
  332. type
  333. {$ifc TYPED_FUNCTION_POINTERS}
  334. TaskProc = function(parameter: UnivPtr): OSStatus;
  335. {$elsec}
  336. TaskProc = ProcPtr;
  337. {$endc}
  338. {
  339. * MPCreateTask()
  340. *
  341. * Availability:
  342. * Non-Carbon CFM: in MPLibrary 1.0 and later
  343. * CarbonLib: in CarbonLib 1.0 and later
  344. * Mac OS X: in version 10.0 and later
  345. }
  346. function MPCreateTask(entryPoint: TaskProc; parameter: UnivPtr; stackSize: ByteCount; notifyQueue: MPQueueID; terminationParameter1: UnivPtr; terminationParameter2: UnivPtr; options: MPTaskOptions; task: MPTaskIDPtr): OSStatus; external name '_MPCreateTask';
  347. {
  348. * MPTerminateTask()
  349. *
  350. * Availability:
  351. * Non-Carbon CFM: in MPLibrary 1.0 and later
  352. * CarbonLib: in CarbonLib 1.0 and later
  353. * Mac OS X: in version 10.0 and later
  354. }
  355. function MPTerminateTask(task: MPTaskID; terminationStatus: OSStatus): OSStatus; external name '_MPTerminateTask';
  356. {
  357. * MPSetTaskWeight()
  358. *
  359. * Availability:
  360. * Non-Carbon CFM: in MPLibrary 2.0 and later
  361. * CarbonLib: in CarbonLib 1.0 and later
  362. * Mac OS X: in version 10.0 and later
  363. }
  364. function MPSetTaskWeight(task: MPTaskID; weight: MPTaskWeight): OSStatus; external name '_MPSetTaskWeight';
  365. {
  366. * MPTaskIsPreemptive()
  367. *
  368. * Availability:
  369. * Non-Carbon CFM: in MPLibrary 2.0 and later
  370. * CarbonLib: in CarbonLib 1.0 and later
  371. * Mac OS X: in version 10.0 and later
  372. }
  373. function MPTaskIsPreemptive(taskID: MPTaskID): boolean; external name '_MPTaskIsPreemptive';
  374. { May be kInvalidID. }
  375. {
  376. * MPExit()
  377. *
  378. * Availability:
  379. * Non-Carbon CFM: in MPLibrary 1.0 and later
  380. * CarbonLib: in CarbonLib 1.0 and later
  381. * Mac OS X: in version 10.0 and later
  382. }
  383. procedure MPExit(status: OSStatus); external name '_MPExit';
  384. {
  385. * MPYield()
  386. *
  387. * Availability:
  388. * Non-Carbon CFM: in MPLibrary 1.0 and later
  389. * CarbonLib: in CarbonLib 1.0 and later
  390. * Mac OS X: in version 10.0 and later
  391. }
  392. procedure MPYield; external name '_MPYield';
  393. {
  394. * MPCurrentTaskID()
  395. *
  396. * Availability:
  397. * Non-Carbon CFM: in MPLibrary 1.0 and later
  398. * CarbonLib: in CarbonLib 1.0 and later
  399. * Mac OS X: in version 10.0 and later
  400. }
  401. function MPCurrentTaskID: MPTaskID; external name '_MPCurrentTaskID';
  402. {
  403. * MPSetTaskType()
  404. *
  405. * Availability:
  406. * Non-Carbon CFM: in MPLibrary 2.3 and later
  407. * CarbonLib: in CarbonLib 1.0 and later
  408. * Mac OS X: in version 10.0 and later
  409. }
  410. function MPSetTaskType(task: MPTaskID; taskType: OSType): OSStatus; external name '_MPSetTaskType';
  411. { ------------------------------------------------------------------------------------------- }
  412. {
  413. ---------------------------------------------------
  414. ! The task storage services are new in version 2.0.
  415. }
  416. {
  417. * MPAllocateTaskStorageIndex()
  418. *
  419. * Availability:
  420. * Non-Carbon CFM: in MPLibrary 2.0 and later
  421. * CarbonLib: in CarbonLib 1.0 and later
  422. * Mac OS X: in version 10.0 and later
  423. }
  424. function MPAllocateTaskStorageIndex(var index: TaskStorageIndex): OSStatus; external name '_MPAllocateTaskStorageIndex';
  425. {
  426. * MPDeallocateTaskStorageIndex()
  427. *
  428. * Availability:
  429. * Non-Carbon CFM: in MPLibrary 2.0 and later
  430. * CarbonLib: in CarbonLib 1.0 and later
  431. * Mac OS X: in version 10.0 and later
  432. }
  433. function MPDeallocateTaskStorageIndex(index: TaskStorageIndex): OSStatus; external name '_MPDeallocateTaskStorageIndex';
  434. {
  435. * MPSetTaskStorageValue()
  436. *
  437. * Availability:
  438. * Non-Carbon CFM: in MPLibrary 2.0 and later
  439. * CarbonLib: in CarbonLib 1.0 and later
  440. * Mac OS X: in version 10.0 and later
  441. }
  442. function MPSetTaskStorageValue(index: TaskStorageIndex; value: TaskStorageValue): OSStatus; external name '_MPSetTaskStorageValue';
  443. {
  444. * MPGetTaskStorageValue()
  445. *
  446. * Availability:
  447. * Non-Carbon CFM: in MPLibrary 2.0 and later
  448. * CarbonLib: in CarbonLib 1.0 and later
  449. * Mac OS X: in version 10.0 and later
  450. }
  451. function MPGetTaskStorageValue(index: TaskStorageIndex): TaskStorageValue; external name '_MPGetTaskStorageValue';
  452. {
  453. ¤
  454. ===========================================================================================
  455. Synchronization Services
  456. ========================
  457. }
  458. {
  459. * MPCreateQueue()
  460. *
  461. * Availability:
  462. * Non-Carbon CFM: in MPLibrary 1.0 and later
  463. * CarbonLib: in CarbonLib 1.0 and later
  464. * Mac OS X: in version 10.0 and later
  465. }
  466. function MPCreateQueue(var queue: MPQueueID): OSStatus; external name '_MPCreateQueue';
  467. {
  468. * MPDeleteQueue()
  469. *
  470. * Availability:
  471. * Non-Carbon CFM: in MPLibrary 1.0 and later
  472. * CarbonLib: in CarbonLib 1.0 and later
  473. * Mac OS X: in version 10.0 and later
  474. }
  475. function MPDeleteQueue(queue: MPQueueID): OSStatus; external name '_MPDeleteQueue';
  476. {
  477. * MPNotifyQueue()
  478. *
  479. * Availability:
  480. * Non-Carbon CFM: in MPLibrary 1.0 and later
  481. * CarbonLib: in CarbonLib 1.0 and later
  482. * Mac OS X: in version 10.0 and later
  483. }
  484. function MPNotifyQueue(queue: MPQueueID; param1: UnivPtr; param2: UnivPtr; param3: UnivPtr): OSStatus; external name '_MPNotifyQueue';
  485. {
  486. * MPWaitOnQueue()
  487. *
  488. * Availability:
  489. * Non-Carbon CFM: in MPLibrary 1.0 and later
  490. * CarbonLib: in CarbonLib 1.0 and later
  491. * Mac OS X: in version 10.0 and later
  492. }
  493. function MPWaitOnQueue(queue: MPQueueID; param1: UnivPtr; param2: UnivPtr; param3: UnivPtr; timeout: Duration): OSStatus; external name '_MPWaitOnQueue';
  494. {
  495. * MPSetQueueReserve()
  496. *
  497. * Availability:
  498. * Non-Carbon CFM: in MPLibrary 2.0 and later
  499. * CarbonLib: in CarbonLib 1.0 and later
  500. * Mac OS X: in version 10.0 and later
  501. }
  502. function MPSetQueueReserve(queue: MPQueueID; count: ItemCount): OSStatus; external name '_MPSetQueueReserve';
  503. { ------------------------------------------------------------------------------------------- }
  504. {
  505. * MPCreateSemaphore()
  506. *
  507. * Availability:
  508. * Non-Carbon CFM: in MPLibrary 1.0 and later
  509. * CarbonLib: in CarbonLib 1.0 and later
  510. * Mac OS X: in version 10.0 and later
  511. }
  512. function MPCreateSemaphore(maximumValue: MPSemaphoreCount; initialValue: MPSemaphoreCount; var semaphore: MPSemaphoreID): OSStatus; external name '_MPCreateSemaphore';
  513. {
  514. * MPDeleteSemaphore()
  515. *
  516. * Availability:
  517. * Non-Carbon CFM: in MPLibrary 1.0 and later
  518. * CarbonLib: in CarbonLib 1.0 and later
  519. * Mac OS X: in version 10.0 and later
  520. }
  521. function MPDeleteSemaphore(semaphore: MPSemaphoreID): OSStatus; external name '_MPDeleteSemaphore';
  522. {
  523. * MPSignalSemaphore()
  524. *
  525. * Availability:
  526. * Non-Carbon CFM: in MPLibrary 1.0 and later
  527. * CarbonLib: in CarbonLib 1.0 and later
  528. * Mac OS X: in version 10.0 and later
  529. }
  530. function MPSignalSemaphore(semaphore: MPSemaphoreID): OSStatus; external name '_MPSignalSemaphore';
  531. {
  532. * MPWaitOnSemaphore()
  533. *
  534. * Availability:
  535. * Non-Carbon CFM: in MPLibrary 1.0 and later
  536. * CarbonLib: in CarbonLib 1.0 and later
  537. * Mac OS X: in version 10.0 and later
  538. }
  539. function MPWaitOnSemaphore(semaphore: MPSemaphoreID; timeout: Duration): OSStatus; external name '_MPWaitOnSemaphore';
  540. { ------------------------------------------------------------------------------------------- }
  541. {
  542. * MPCreateCriticalRegion()
  543. *
  544. * Availability:
  545. * Non-Carbon CFM: in MPLibrary 1.0 and later
  546. * CarbonLib: in CarbonLib 1.0 and later
  547. * Mac OS X: in version 10.0 and later
  548. }
  549. function MPCreateCriticalRegion(var criticalRegion: MPCriticalRegionID): OSStatus; external name '_MPCreateCriticalRegion';
  550. {
  551. * MPDeleteCriticalRegion()
  552. *
  553. * Availability:
  554. * Non-Carbon CFM: in MPLibrary 1.0 and later
  555. * CarbonLib: in CarbonLib 1.0 and later
  556. * Mac OS X: in version 10.0 and later
  557. }
  558. function MPDeleteCriticalRegion(criticalRegion: MPCriticalRegionID): OSStatus; external name '_MPDeleteCriticalRegion';
  559. {
  560. * MPEnterCriticalRegion()
  561. *
  562. * Availability:
  563. * Non-Carbon CFM: in MPLibrary 1.0 and later
  564. * CarbonLib: in CarbonLib 1.0 and later
  565. * Mac OS X: in version 10.0 and later
  566. }
  567. function MPEnterCriticalRegion(criticalRegion: MPCriticalRegionID; timeout: Duration): OSStatus; external name '_MPEnterCriticalRegion';
  568. {
  569. * MPExitCriticalRegion()
  570. *
  571. * Availability:
  572. * Non-Carbon CFM: in MPLibrary 1.0 and later
  573. * CarbonLib: in CarbonLib 1.0 and later
  574. * Mac OS X: in version 10.0 and later
  575. }
  576. function MPExitCriticalRegion(criticalRegion: MPCriticalRegionID): OSStatus; external name '_MPExitCriticalRegion';
  577. { ------------------------------------------------------------------------------------------- }
  578. {
  579. * MPCreateEvent()
  580. *
  581. * Availability:
  582. * Non-Carbon CFM: in MPLibrary 2.0 and later
  583. * CarbonLib: in CarbonLib 1.0 and later
  584. * Mac OS X: in version 10.0 and later
  585. }
  586. function MPCreateEvent(var event: MPEventID): OSStatus; external name '_MPCreateEvent';
  587. {
  588. * MPDeleteEvent()
  589. *
  590. * Availability:
  591. * Non-Carbon CFM: in MPLibrary 2.0 and later
  592. * CarbonLib: in CarbonLib 1.0 and later
  593. * Mac OS X: in version 10.0 and later
  594. }
  595. function MPDeleteEvent(event: MPEventID): OSStatus; external name '_MPDeleteEvent';
  596. {
  597. * MPSetEvent()
  598. *
  599. * Availability:
  600. * Non-Carbon CFM: in MPLibrary 2.0 and later
  601. * CarbonLib: in CarbonLib 1.0 and later
  602. * Mac OS X: in version 10.0 and later
  603. }
  604. function MPSetEvent(event: MPEventID; flags: MPEventFlags): OSStatus; external name '_MPSetEvent';
  605. {
  606. * MPWaitForEvent()
  607. *
  608. * Availability:
  609. * Non-Carbon CFM: in MPLibrary 2.0 and later
  610. * CarbonLib: in CarbonLib 1.0 and later
  611. * Mac OS X: in version 10.0 and later
  612. }
  613. function MPWaitForEvent(event: MPEventID; flags: MPEventFlagsPtr; timeout: Duration): OSStatus; external name '_MPWaitForEvent';
  614. {
  615. ¤
  616. ===========================================================================================
  617. Notification Services (API)
  618. =====================
  619. }
  620. {
  621. * MPCreateNotification()
  622. *
  623. * Availability:
  624. * Non-Carbon CFM: in MPLibrary 2.1 and later
  625. * CarbonLib: in CarbonLib 1.0 and later
  626. * Mac OS X: in version 10.0 and later
  627. }
  628. function MPCreateNotification(var notificationID: MPNotificationID): OSStatus; external name '_MPCreateNotification';
  629. {
  630. * MPDeleteNotification()
  631. *
  632. * Availability:
  633. * Non-Carbon CFM: in MPLibrary 2.1 and later
  634. * CarbonLib: in CarbonLib 1.0 and later
  635. * Mac OS X: in version 10.0 and later
  636. }
  637. function MPDeleteNotification(notificationID: MPNotificationID): OSStatus; external name '_MPDeleteNotification';
  638. {
  639. * MPModifyNotification()
  640. *
  641. * Availability:
  642. * Non-Carbon CFM: in MPLibrary 2.1 and later
  643. * CarbonLib: in CarbonLib 1.0 and later
  644. * Mac OS X: in version 10.0 and later
  645. }
  646. function MPModifyNotification(notificationID: MPNotificationID; anID: MPOpaqueID; notifyParam1: UnivPtr; notifyParam2: UnivPtr; notifyParam3: UnivPtr): OSStatus; external name '_MPModifyNotification';
  647. {
  648. * MPModifyNotificationParameters()
  649. *
  650. * Availability:
  651. * Non-Carbon CFM: in MPLibrary 2.3 and later
  652. * CarbonLib: in CarbonLib 1.0 and later
  653. * Mac OS X: in version 10.0 and later
  654. }
  655. function MPModifyNotificationParameters(notificationID: MPNotificationID; kind: MPOpaqueIDClass; notifyParam1: UnivPtr; notifyParam2: UnivPtr; notifyParam3: UnivPtr): OSStatus; external name '_MPModifyNotificationParameters';
  656. {
  657. * MPCauseNotification()
  658. *
  659. * Availability:
  660. * Non-Carbon CFM: in MPLibrary 2.1 and later
  661. * CarbonLib: in CarbonLib 1.0 and later
  662. * Mac OS X: in version 10.0 and later
  663. }
  664. function MPCauseNotification(notificationID: MPNotificationID): OSStatus; external name '_MPCauseNotification';
  665. {
  666. ¤
  667. ===========================================================================================
  668. Timer Services
  669. ==============
  670. }
  671. {
  672. --------------------------------------------
  673. ! The timer services are new in version 2.0.
  674. }
  675. {
  676. Utilities you might want to use from DriverServices
  677. extern AbsoluteTime UpTime ( void );
  678. extern AbsoluteTime DurationToAbsolute ( Duration duration );
  679. extern Duration AbsoluteToDuration ( AbsoluteTime time );
  680. }
  681. const
  682. { For MPArmTimer options }
  683. kMPPreserveTimerIDMask = $00000001;
  684. kMPTimeIsDeltaMask = $00000002;
  685. kMPTimeIsDurationMask = $00000004;
  686. {
  687. * MPDelayUntil()
  688. *
  689. * Availability:
  690. * Non-Carbon CFM: in MPLibrary 2.0 and later
  691. * CarbonLib: in CarbonLib 1.0 and later
  692. * Mac OS X: in version 10.0 and later
  693. }
  694. function MPDelayUntil(var expirationTime: AbsoluteTime): OSStatus; external name '_MPDelayUntil';
  695. {$ifc CALL_NOT_IN_CARBON}
  696. {
  697. * MPDelayUntilSys()
  698. *
  699. * Availability:
  700. * Non-Carbon CFM: in MPLibrary 2.1 and later
  701. * CarbonLib: not available
  702. * Mac OS X: not available
  703. }
  704. function MPDelayUntilSys(var expirationTime: AbsoluteTime): OSStatus; external name '_MPDelayUntilSys';
  705. {$endc} {CALL_NOT_IN_CARBON}
  706. {
  707. * MPCreateTimer()
  708. *
  709. * Availability:
  710. * Non-Carbon CFM: in MPLibrary 2.0 and later
  711. * CarbonLib: in CarbonLib 1.0 and later
  712. * Mac OS X: in version 10.0 and later
  713. }
  714. function MPCreateTimer(var timerID: MPTimerID): OSStatus; external name '_MPCreateTimer';
  715. {
  716. * MPDeleteTimer()
  717. *
  718. * Availability:
  719. * Non-Carbon CFM: in MPLibrary 2.0 and later
  720. * CarbonLib: in CarbonLib 1.0 and later
  721. * Mac OS X: in version 10.0 and later
  722. }
  723. function MPDeleteTimer(timerID: MPTimerID): OSStatus; external name '_MPDeleteTimer';
  724. {
  725. * MPSetTimerNotify()
  726. *
  727. * Availability:
  728. * Non-Carbon CFM: in MPLibrary 2.0 and later
  729. * CarbonLib: in CarbonLib 1.0 and later
  730. * Mac OS X: in version 10.0 and later
  731. }
  732. function MPSetTimerNotify(timerID: MPTimerID; anID: MPOpaqueID; notifyParam1: UnivPtr; notifyParam2: UnivPtr; notifyParam3: UnivPtr): OSStatus; external name '_MPSetTimerNotify';
  733. {
  734. * MPArmTimer()
  735. *
  736. * Availability:
  737. * Non-Carbon CFM: in MPLibrary 2.0 and later
  738. * CarbonLib: in CarbonLib 1.0 and later
  739. * Mac OS X: in version 10.0 and later
  740. }
  741. function MPArmTimer(timerID: MPTimerID; var expirationTime: AbsoluteTime; options: OptionBits): OSStatus; external name '_MPArmTimer';
  742. {
  743. * MPCancelTimer()
  744. *
  745. * Availability:
  746. * Non-Carbon CFM: in MPLibrary 2.0 and later
  747. * CarbonLib: in CarbonLib 1.0 and later
  748. * Mac OS X: in version 10.0 and later
  749. }
  750. function MPCancelTimer(timerID: MPTimerID; timeRemaining: AbsoluteTimePtr): OSStatus; external name '_MPCancelTimer';
  751. {
  752. ¤
  753. ===========================================================================================
  754. Memory Services
  755. ===============
  756. }
  757. const
  758. { Maximum allocation request size is 1GB. }
  759. kMPMaxAllocSize = 1073741824;
  760. { Values for the alignment parameter to MPAllocateAligned. }
  761. kMPAllocateDefaultAligned = 0;
  762. kMPAllocate8ByteAligned = 3;
  763. kMPAllocate16ByteAligned = 4;
  764. kMPAllocate32ByteAligned = 5;
  765. kMPAllocate1024ByteAligned = 10;
  766. kMPAllocate4096ByteAligned = 12;
  767. kMPAllocateMaxAlignment = 16; { Somewhat arbitrary limit on expectations. }
  768. kMPAllocateAltiVecAligned = 4; { The P.C. name. }
  769. kMPAllocateVMXAligned = 4; { The older, common name. }
  770. kMPAllocateVMPageAligned = 254; { Pseudo value, converted at runtime. }
  771. kMPAllocateInterlockAligned = 255; { Pseudo value, converted at runtime. }
  772. { Values for the options parameter to MPAllocateAligned. }
  773. kMPAllocateClearMask = $0001; { Zero the allocated block. }
  774. kMPAllocateGloballyMask = $0002; { Allocate from the globally visible pool. }
  775. kMPAllocateResidentMask = $0004; { Allocate from the RAM-resident pool. }
  776. kMPAllocateNoGrowthMask = $0010; { Do not attempt to grow the pool. }
  777. kMPAllocateNoCreateMask = $0020; { Do not attempt to create the pool if it doesn't exist yet. }
  778. { ------------------------------------------------------------------------------------------- }
  779. {
  780. * MPAllocateAligned()
  781. *
  782. * Availability:
  783. * Non-Carbon CFM: in MPLibrary 2.0 and later
  784. * CarbonLib: in CarbonLib 1.0 and later
  785. * Mac OS X: in version 10.0 and later
  786. }
  787. function MPAllocateAligned(size: ByteCount; alignment: ByteParameter; options: OptionBits): LogicalAddress; external name '_MPAllocateAligned';
  788. { ! MPAllocateAligned is new in version 2.0. }
  789. {
  790. * MPAllocate()
  791. *
  792. * Availability:
  793. * Non-Carbon CFM: in MPLibrary 1.0 and later
  794. * CarbonLib: in CarbonLib 1.0 and later
  795. * Mac OS X: in version 10.0 and later
  796. }
  797. function MPAllocate(size: ByteCount): LogicalAddress; external name '_MPAllocate';
  798. { Use MPAllocateAligned instead. }
  799. {
  800. * MPFree()
  801. *
  802. * Availability:
  803. * Non-Carbon CFM: in MPLibrary 1.0 and later
  804. * CarbonLib: in CarbonLib 1.0 and later
  805. * Mac OS X: in version 10.0 and later
  806. }
  807. procedure MPFree(objct: LogicalAddress); external name '_MPFree';
  808. {
  809. * MPGetAllocatedBlockSize()
  810. *
  811. * Availability:
  812. * Non-Carbon CFM: in MPLibrary 2.0 and later
  813. * CarbonLib: in CarbonLib 1.0 and later
  814. * Mac OS X: in version 10.0 and later
  815. }
  816. function MPGetAllocatedBlockSize(objct: LogicalAddress): ByteCount; external name '_MPGetAllocatedBlockSize';
  817. { ------------------------------------------------------------------------------------------- }
  818. {
  819. * MPBlockCopy()
  820. *
  821. * Availability:
  822. * Non-Carbon CFM: in MPLibrary 1.0 and later
  823. * CarbonLib: in CarbonLib 1.0 and later
  824. * Mac OS X: in version 10.0 and later
  825. }
  826. procedure MPBlockCopy(source: LogicalAddress; destination: LogicalAddress; size: ByteCount); external name '_MPBlockCopy';
  827. {
  828. * MPBlockClear()
  829. *
  830. * Availability:
  831. * Non-Carbon CFM: in MPLibrary 2.0 and later
  832. * CarbonLib: in CarbonLib 1.0 and later
  833. * Mac OS X: in version 10.0 and later
  834. }
  835. procedure MPBlockClear(address: LogicalAddress; size: ByteCount); external name '_MPBlockClear';
  836. { ! MPBlockClear is new in version 2.0. }
  837. {
  838. * MPDataToCode()
  839. *
  840. * Availability:
  841. * Non-Carbon CFM: in MPLibrary 2.0 and later
  842. * CarbonLib: in CarbonLib 1.0 and later
  843. * Mac OS X: in version 10.0 and later
  844. }
  845. procedure MPDataToCode(address: LogicalAddress; size: ByteCount); external name '_MPDataToCode';
  846. { ! MPDataToCode is new in version 2.0. }
  847. {
  848. ¤
  849. ===========================================================================================
  850. Exception/Debugging Services
  851. ============================
  852. }
  853. {
  854. -------------------------------------------------------------------------------------------
  855. *** Important Note ***
  856. ----------------------
  857. The functions MPExtractTaskState and MPSetTaskState infer the size of the "info" buffer
  858. from the "kind" parameter. A given value for MPTaskStateKind will always refer to a
  859. single specific physical buffer layout. Should new register sets be added, or the size
  860. or number of any registers change, new values of MPTaskStateKind will be introduced to
  861. refer to the new buffer layouts.
  862. The following types for the buffers are in MachineExceptions. The correspondence between
  863. MPTaskStateKind values and MachineExceptions types is:
  864. kMPTaskStateRegisters -> RegisterInformation
  865. kMPTaskStateFPU -> FPUInformation
  866. kMPTaskStateVectors -> VectorInformation
  867. kMPTaskStateMachine -> MachineInformation
  868. kMPTaskState32BitMemoryException -> ExceptionInfo for old-style 32-bit memory exceptions
  869. For reference, on PowerPC the MachineExceptions types contain:
  870. RegisterInformation -> The GPRs, 32 values of 64 bits each.
  871. FPUInformation -> The FPRs plus FPSCR, 32 values of 64 bits each, one value of
  872. 32 bits.
  873. VectorInformation -> The AltiVec vector registers plus VSCR and VRSave, 32 values
  874. of 128 bits each, one value of 128 bits, and one 32 bit value.
  875. MachineInformation -> The CTR, LR, PC, each of 64 bits. The CR, XER, MSR, MQ,
  876. exception kind, and DSISR, each of 32 bits. The 64 bit DAR.
  877. ExceptionInfo -> Only memory exceptions are specified, 4 fields of 32 bits each.
  878. Note that this type only covers memory exceptions on 32-bit CPUs!
  879. The following types are declared here:
  880. kMPTaskStateTaskInfo -> MPTaskInfo
  881. }
  882. const
  883. { Values for the TaskStateKind to MPExtractTaskState and MPSetTaskState. }
  884. kMPTaskStateRegisters = 0; { The task general registers. }
  885. kMPTaskStateFPU = 1; { The task floating point registers }
  886. kMPTaskStateVectors = 2; { The task vector registers }
  887. kMPTaskStateMachine = 3; { The task machine registers }
  888. kMPTaskState32BitMemoryException = 4; { The task memory exception information for 32-bit CPUs. }
  889. kMPTaskStateTaskInfo = 5; { Static and dynamic information about the task. }
  890. { Option bits and numbers for MPDisposeTaskException. }
  891. kMPTaskPropagate = 0; { The exception is propagated. }
  892. kMPTaskResumeStep = 1; { The task is resumed and single step is enabled. }
  893. kMPTaskResumeBranch = 2; { The task is resumed and branch stepping is enabled. }
  894. kMPTaskResumeMask = $0000; { The task is resumed. }
  895. kMPTaskPropagateMask = $01; { The exception is propagated. }
  896. kMPTaskResumeStepMask = $02; { The task is resumed and single step is enabled. }
  897. kMPTaskResumeBranchMask = $04; { The task is resumed and branch stepping is enabled. }
  898. { For kMPTaskStateTaskInfo, the task's runState }
  899. kMPTaskBlocked = 0; { Task is blocked (queued on resource) }
  900. kMPTaskReady = 1; { Task is runnable }
  901. kMPTaskRunning = 2; { Task is running }
  902. { For kMPTaskStateTaskInfo, the version of the MPTaskInfo structure requested. }
  903. kMPTaskInfoVersion = 3;
  904. type
  905. MPTaskInfoPtr = ^MPTaskInfo;
  906. MPTaskInfo = record
  907. version: PBVersion; { Version 3 of the data structure requested }
  908. name: OSType; { Task name }
  909. queueName: OSType; { Task's queue owner name }
  910. runState: UInt16; { Running, ready, blocked }
  911. lastCPU: UInt16; { Address of CPU where task previously ran }
  912. weight: UInt32; { Processing weight: 1 - 10,000 }
  913. processID: MPProcessID; { Owning process ID }
  914. cpuTime: AbsoluteTime; { Accumulated task time }
  915. schedTime: AbsoluteTime; { Time when last scheduled }
  916. creationTime: AbsoluteTime; { Time when task created }
  917. codePageFaults: ItemCount; { Page faults from code execution }
  918. dataPageFaults: ItemCount; { Page faults from data access }
  919. preemptions: ItemCount; { Number of times task was preempted }
  920. cpuID: MPCpuID; { ID of CPU where task previously ran. }
  921. blockedObject: MPOpaqueID; { ID of blocked object. }
  922. spaceID: MPAddressSpaceID; { Address space ID of this task. }
  923. stackBase: LogicalAddress; { Base of stack (lowest address). }
  924. stackLimit: LogicalAddress; { Stack limit (highest address). }
  925. stackCurr: LogicalAddress; { Current stack address. }
  926. end;
  927. {
  928. Upon a task exception, the following message is sent to the designated queue:
  929. 1. The MPTaskID,
  930. 2. The exception kind. These are enumerated in the interfaces header MachineExceptions.h
  931. 3. N/A
  932. }
  933. { ------------------------------------------------------------------------------------------- }
  934. {
  935. * MPSetExceptionHandler()
  936. *
  937. * Availability:
  938. * Non-Carbon CFM: in MPLibrary 2.0 and later
  939. * CarbonLib: in CarbonLib 1.0 and later
  940. * Mac OS X: in version 10.0 and later
  941. }
  942. function MPSetExceptionHandler(task: MPTaskID; exceptionQ: MPQueueID): OSStatus; external name '_MPSetExceptionHandler';
  943. {
  944. * MPDisposeTaskException()
  945. *
  946. * Availability:
  947. * Non-Carbon CFM: in MPLibrary 2.0 and later
  948. * CarbonLib: in CarbonLib 1.0 and later
  949. * Mac OS X: in version 10.0 and later
  950. }
  951. function MPDisposeTaskException(task: MPTaskID; action: OptionBits): OSStatus; external name '_MPDisposeTaskException';
  952. {
  953. * MPExtractTaskState()
  954. *
  955. * Availability:
  956. * Non-Carbon CFM: in MPLibrary 2.0 and later
  957. * CarbonLib: in CarbonLib 1.0 and later
  958. * Mac OS X: in version 10.0 and later
  959. }
  960. function MPExtractTaskState(task: MPTaskID; kind: MPTaskStateKind; info: UnivPtr): OSStatus; external name '_MPExtractTaskState';
  961. {
  962. * MPSetTaskState()
  963. *
  964. * Availability:
  965. * Non-Carbon CFM: in MPLibrary 2.0 and later
  966. * CarbonLib: in CarbonLib 1.0 and later
  967. * Mac OS X: in version 10.0 and later
  968. }
  969. function MPSetTaskState(task: MPTaskID; kind: MPTaskStateKind; info: UnivPtr): OSStatus; external name '_MPSetTaskState';
  970. {
  971. * MPThrowException()
  972. *
  973. * Availability:
  974. * Non-Carbon CFM: in MPLibrary 2.0 and later
  975. * CarbonLib: in CarbonLib 1.0 and later
  976. * Mac OS X: in version 10.0 and later
  977. }
  978. function MPThrowException(task: MPTaskID; kind: MPExceptionKind): OSStatus; external name '_MPThrowException';
  979. { ------------------------------------------------------------------------------------------- }
  980. type
  981. MPDebuggerLevel = UInt32;
  982. const
  983. kMPLowLevelDebugger = $00000000; { MacsBug-like }
  984. kMPMidLevelDebugger = $10000000; { Jasik-like }
  985. kMPHighLevelDebugger = $20000000; { Metrowerks-like }
  986. {
  987. * MPRegisterDebugger()
  988. *
  989. * Availability:
  990. * Non-Carbon CFM: in MPLibrary 2.0 and later
  991. * CarbonLib: in CarbonLib 1.0 and later
  992. * Mac OS X: in version 10.0 and later
  993. }
  994. function MPRegisterDebugger(queue: MPQueueID; level: MPDebuggerLevel): OSStatus; external name '_MPRegisterDebugger';
  995. {
  996. * MPUnregisterDebugger()
  997. *
  998. * Availability:
  999. * Non-Carbon CFM: in MPLibrary 2.0 and later
  1000. * CarbonLib: in CarbonLib 1.0 and later
  1001. * Mac OS X: in version 10.0 and later
  1002. }
  1003. function MPUnregisterDebugger(queue: MPQueueID): OSStatus; external name '_MPUnregisterDebugger';
  1004. {
  1005. ¤
  1006. ===========================================================================================
  1007. Remote Call Services
  1008. ====================
  1009. }
  1010. type
  1011. {$ifc TYPED_FUNCTION_POINTERS}
  1012. MPRemoteProcedure = function(parameter: UnivPtr): Ptr;
  1013. {$elsec}
  1014. MPRemoteProcedure = ProcPtr;
  1015. {$endc}
  1016. MPRemoteContext = UInt8;
  1017. const
  1018. kMPAnyRemoteContext = 0;
  1019. kMPOwningProcessRemoteContext = 1;
  1020. kMPInterruptRemoteContext = 2;
  1021. kMPAsyncInterruptRemoteContext = 3;
  1022. {
  1023. * MPRemoteCall()
  1024. *
  1025. * Availability:
  1026. * Non-Carbon CFM: in MPLibrary 2.0 and later
  1027. * CarbonLib: in CarbonLib 1.0 and later
  1028. * Mac OS X: in version 10.0 and later
  1029. }
  1030. function MPRemoteCall(remoteProc: MPRemoteProcedure; parameter: UnivPtr; context: ByteParameter): Ptr; external name '_MPRemoteCall';
  1031. { ! MPRemoteCall is new in version 2.0. }
  1032. {
  1033. ¤
  1034. ===========================================================================================
  1035. Checking API Availability
  1036. =========================
  1037. }
  1038. {
  1039. ===========================================================================================
  1040. *** WARNING: You must properly check the availability of MP services before calling them!
  1041. ===========================================================================================
  1042. Checking for the availability of the MP API is rather ugly. This is a historical problem,
  1043. caused by the original implementation letting itself get prepared when it really wasn't
  1044. usable and complicated by some important clients then depending on weak linking to "work".
  1045. (And further complicated by CFM not supporting "deferred" imports, which is how many
  1046. programmers think weak imports work.)
  1047. The end result is that the MP API library may get prepared by CFM but be totally unusable.
  1048. This means that if you import from the MP API library, you cannot simply check for a
  1049. resolved import to decide if MP services are available. Worse, if you explicitly prepare
  1050. the MP API library you cannot assume that a noErr result from GetSharedLibrary means that
  1051. MP services are available.
  1052. ¥ If you import from the MP API library you MUST:
  1053. Use the MPLibraryIsLoaded macro (or equivalent code in languages other than C) to tell
  1054. if the MP API services are available. It is not sufficient to simply check that an
  1055. imported symbol is resolved as is commonly done for other libraries. The macro expands
  1056. to the expression:
  1057. ( ( (UInt32)_MPIsFullyInitialized != (UInt32)kUnresolvedCFragSymbolAddress ) &&
  1058. ( _MPIsFullyInitialized () ) )
  1059. This checks if the imported symbol _MPIsFullyInitialized is resolved and if resolved
  1060. calls it. Both parts must succeed for the MP API services to be available.
  1061. ¥ If you explicitly prepare the MP API library you MUST:
  1062. Use code similar to the following example to tell if the MP API services are available.
  1063. It is not sufficient to depend on just a noErr result from GetSharedLibrary.
  1064. OSErr err;
  1065. Boolean mpIsAvailable = false;
  1066. CFragConnectionID connID = kInvalidID;
  1067. MPIsFullyInitializedProc mpIsFullyInitialized = NULL;
  1068. err = GetSharedLibrary ( "\pMPLibrary", kCompiledCFragArch, kReferenceCFrag,
  1069. &connID, NULL, NULL );
  1070. if ( err == noErr ) (
  1071. err = FindSymbol ( connID, "\p_MPIsFullyInitialized",
  1072. (Ptr *) &mpIsFullyInitialized, NULL );
  1073. )
  1074. if ( err == noErr ) (
  1075. mpIsAvailable = (* mpIsFullyInitialized) ();
  1076. )
  1077. ===========================================================================================
  1078. }
  1079. {
  1080. * _MPIsFullyInitialized()
  1081. *
  1082. * Availability:
  1083. * Non-Carbon CFM: in MPLibrary 1.0 and later
  1084. * CarbonLib: in CarbonLib 1.0 and later
  1085. * Mac OS X: in version 10.0 and later
  1086. }
  1087. function _MPIsFullyInitialized: boolean; external name '__MPIsFullyInitialized';
  1088. type
  1089. {$ifc TYPED_FUNCTION_POINTERS}
  1090. MPIsFullyInitializedProc = function: boolean;
  1091. {$elsec}
  1092. MPIsFullyInitializedProc = ProcPtr;
  1093. {$endc}
  1094. {
  1095. ===========================================================================================
  1096. The MPLibraryIsLoaded service is a macro under C that expands to the logical expression:
  1097. ( (UInt32)MPProcessors != (UInt32)kUnresolvedCFragSymbolAddress )
  1098. The intention is to check if the imported symbol MPProcessors is resolved. For other
  1099. languages use the equivalent expression.
  1100. ===========================================================================================
  1101. }
  1102. {
  1103. ¤
  1104. ===========================================================================================
  1105. Miscellaneous Services
  1106. ======================
  1107. }
  1108. {
  1109. * _MPLibraryVersion()
  1110. *
  1111. * Availability:
  1112. * Non-Carbon CFM: in MPLibrary 1.0 and later
  1113. * CarbonLib: in CarbonLib 1.0 and later
  1114. * Mac OS X: in version 10.0 and later
  1115. }
  1116. procedure _MPLibraryVersion(versionCString: ConstCStringPtrPtr; major: UInt32Ptr; minor: UInt32Ptr; release: UInt32Ptr; revision: UInt32Ptr); external name '__MPLibraryVersion';
  1117. {
  1118. ¤
  1119. ===========================================================================================
  1120. Unofficial Services
  1121. ===================
  1122. }
  1123. {
  1124. ===========================================================================================
  1125. *** WARNING ***
  1126. These services are not part of the officially documented multiprocessing API. They may not
  1127. be avaliable in future versions of Mac OS multiprocessing support, or in environments that
  1128. have a different underlying OS architecture such as Mac OS on top of a microkernel, the
  1129. Mac OS Blue Box under Mac OS X, native MP support in Mac OS X, etc.
  1130. ===========================================================================================
  1131. }
  1132. {$ifc CALL_NOT_IN_CARBON}
  1133. {$ifc CALL_NOT_IN_CARBON}
  1134. {
  1135. * _MPAllocateSys()
  1136. *
  1137. * Availability:
  1138. * Non-Carbon CFM: in MPLibrary 1.0 and later
  1139. * CarbonLib: not available
  1140. * Mac OS X: not available
  1141. }
  1142. function _MPAllocateSys(size: ByteCount): LogicalAddress; external name '__MPAllocateSys';
  1143. { Use MPAllocateAligned instead. }
  1144. {
  1145. * _MPRPC()
  1146. *
  1147. * Availability:
  1148. * Non-Carbon CFM: in MPLibrary 1.0 and later
  1149. * CarbonLib: not available
  1150. * Mac OS X: not available
  1151. }
  1152. function _MPRPC(remoteProc: MPRemoteProcedure; parameter: UnivPtr): Ptr; external name '__MPRPC';
  1153. { Use _MPRemoteCall instead. }
  1154. {
  1155. * _MPTaskIsToolboxSafe()
  1156. *
  1157. * Availability:
  1158. * Non-Carbon CFM: in MPLibrary 1.0 and later
  1159. * CarbonLib: not available
  1160. * Mac OS X: not available
  1161. }
  1162. function _MPTaskIsToolboxSafe(task: MPTaskID): boolean; external name '__MPTaskIsToolboxSafe';
  1163. {$endc} {CALL_NOT_IN_CARBON}
  1164. {$endc} {CALL_NOT_IN_CARBON}
  1165. {
  1166. * _MPLibraryIsCompatible()
  1167. *
  1168. * Availability:
  1169. * Non-Carbon CFM: in MPLibrary 1.0 and later
  1170. * CarbonLib: in CarbonLib 1.0 and later
  1171. * Mac OS X: in version 10.0 and later
  1172. }
  1173. function _MPLibraryIsCompatible(versionCString: ConstCStringPtr; major: UInt32; minor: UInt32; release: UInt32; revision: UInt32): boolean; external name '__MPLibraryIsCompatible';
  1174. {
  1175. ¤
  1176. ===========================================================================================
  1177. Defunct Services
  1178. ================
  1179. }
  1180. {$ifc CALL_NOT_IN_CARBON}
  1181. {$ifc undefined MPIncludeDefunctServices}
  1182. {$setc MPIncludeDefunctServices := 0}
  1183. {$endc}
  1184. {$ifc MPIncludeDefunctServices}
  1185. {$ifc CALL_NOT_IN_CARBON}
  1186. {
  1187. * _MPDebugStr()
  1188. *
  1189. * Availability:
  1190. * Non-Carbon CFM: in MPLibraryObsolete 1.0 and later
  1191. * CarbonLib: not available
  1192. * Mac OS X: not available
  1193. }
  1194. procedure _MPDebugStr(const (*var*) msg: Str255); external name '__MPDebugStr';
  1195. {
  1196. * _MPStatusPString()
  1197. *
  1198. * Availability:
  1199. * Non-Carbon CFM: in MPLibraryObsolete 1.0 and later
  1200. * CarbonLib: not available
  1201. * Mac OS X: not available
  1202. }
  1203. function _MPStatusPString(status: OSStatus): StringPtr; external name '__MPStatusPString';
  1204. {
  1205. * _MPStatusCString()
  1206. *
  1207. * Availability:
  1208. * Non-Carbon CFM: in MPLibraryObsolete 1.0 and later
  1209. * CarbonLib: not available
  1210. * Mac OS X: not available
  1211. }
  1212. function _MPStatusCString(status: OSStatus): ConstCStringPtr; external name '__MPStatusCString';
  1213. {$endc} {CALL_NOT_IN_CARBON}
  1214. {$endc} {MPIncludeDefunctServices}
  1215. {$endc} {CALL_NOT_IN_CARBON}
  1216. { =========================================================================================== }
  1217. {$ALIGN MAC68K}
  1218. end.