Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1802 lines
46 KiB

  1. /*
  2. File: Multiprocessing.h
  3. Contains: Multiprocessing interfaces
  4. Version: QuickTime 7.3
  5. Copyright: (c) 2007 (c) 1996-2001 by Apple Computer, Inc. and (c) 1995-1997 DayStar Digital, Inc.
  6. Bugs?: For bug reports, consult the following page on
  7. the World Wide Web:
  8. http://developer.apple.com/bugreporter/
  9. */
  10. /*
  11. ===========================================================================================
  12. *** WARNING: You must properly check the availability of MP services before calling them!
  13. See the section titled "Checking API Availability".
  14. ===========================================================================================
  15. */
  16. #ifndef __MULTIPROCESSING__
  17. #define __MULTIPROCESSING__
  18. #ifndef __MACTYPES__
  19. #include <MacTypes.h>
  20. #endif
  21. #if PRAGMA_ONCE
  22. #pragma once
  23. #endif
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. #if PRAGMA_IMPORT
  28. #pragma import on
  29. #endif
  30. #if PRAGMA_STRUCT_ALIGN
  31. #pragma options align=power
  32. #elif PRAGMA_STRUCT_PACKPUSH
  33. #pragma pack(push, 2)
  34. #elif PRAGMA_STRUCT_PACK
  35. #pragma pack(2)
  36. #endif
  37. /*
  38. ===========================================================================================
  39. This is the header file for version 2.2 of the Mac OS multiprocessing support. This version
  40. has been totally reimplemented and has significant new services. The main goal of the
  41. reimplementation has been to transfer task management into the core operating system to provide
  42. much more reliable and more efficient operation, including on single processor machines.
  43. The memory management has also been massively improved, it is much faster and wastes much
  44. less space. New services include POSIX style per-task storage, timers with millisecond and
  45. microsecond resolutions, memory allocation at a specified alignment, and system pageable
  46. and RAM resident memory pools. See the MP API documentation for details.
  47. The old "DayStar" debugging services (whose names began with an underscore) have been
  48. removed from this header. A very few are still implemented for binary compatibility, or in
  49. cases where they happened to be exposed inappropriately. (E.g. _MPIsFullyInitialized must
  50. be called to see if the MP API is ReallyTruly(tm) usable.) New code and recompiles of old
  51. code should avoid use of these defunct services, except for _MPIsFullyInitialized.
  52. ===========================================================================================
  53. */
  54. /*
  55. ===========================================================================================
  56. The following services are from the original MP API and remain supported in version 2.0:
  57. MPProcessors
  58. MPCreateTask
  59. MPTerminateTask
  60. MPCurrentTaskID
  61. MPYield
  62. MPExit
  63. MPCreateQueue
  64. MPDeleteQueue
  65. MPNotifyQueue
  66. MPWaitOnQueue
  67. MPCreateSemaphore
  68. MPCreateBinarySemaphore (In C only, a macro that calls MPCreateSemaphore.)
  69. MPDeleteSemaphore
  70. MPSignalSemaphore
  71. MPWaitOnSemaphore
  72. MPCreateCriticalRegion
  73. MPDeleteCriticalRegion
  74. MPEnterCriticalRegion
  75. MPExitCriticalRegion
  76. MPAllocate (Deprecated, use MPAllocateAligned for new builds.)
  77. MPFree
  78. MPBlockCopy
  79. MPLibraryIsLoaded (In C only, a macro.)
  80. _MPIsFullyInitialized (See comments about checking for MP API availability.)
  81. ===========================================================================================
  82. */
  83. /*
  84. ===========================================================================================
  85. The following services are new in version 2.0:
  86. MPProcessorsScheduled
  87. MPSetTaskWeight
  88. MPTaskIsPreemptive
  89. MPAllocateTaskStorageIndex
  90. MPDeallocateTaskStorageIndex
  91. MPSetTaskStorageValue
  92. MPGetTaskStorageValue
  93. MPSetQueueReserve
  94. MPCreateEvent
  95. MPDeleteEvent
  96. MPSetEvent
  97. MPWaitForEvent
  98. UpTime
  99. DurationToAbsolute
  100. AbsoluteToDuration
  101. MPDelayUntil
  102. MPCreateTimer
  103. MPDeleteTimer
  104. MPSetTimerNotify
  105. MPArmTimer
  106. MPCancelTimer
  107. MPSetExceptionHandler
  108. MPThrowException
  109. MPDisposeTaskException
  110. MPExtractTaskState
  111. MPSetTaskState
  112. MPRegisterDebugger
  113. MPUnregisterDebugger
  114. MPAllocateAligned (Preferred over MPAllocate.)
  115. MPGetAllocatedBlockSize
  116. MPBlockClear
  117. MPDataToCode
  118. MPRemoteCall (Preferred over _MPRPC.)
  119. ===========================================================================================
  120. */
  121. /*
  122. ===========================================================================================
  123. The following services are new in version 2.1:
  124. MPCreateNotification
  125. MPDeleteNotification
  126. MPModifyNotification
  127. MPCauseNotification
  128. MPGetNextTaskID
  129. MPGetNextCpuID
  130. ===========================================================================================
  131. */
  132. /*
  133. ===========================================================================================
  134. The following services are "unofficial" extensions to the original API. They are not in
  135. the multiprocessing API documentation, but were in previous versions of this header. They
  136. remain supported in version 2.0. They may not be supported in other environments.
  137. _MPRPC (Deprecated, use MPRemoteCall for new builds.)
  138. _MPAllocateSys (Deprecated, use MPAllocateAligned for new builds.)
  139. _MPTaskIsToolboxSafe
  140. _MPLibraryVersion
  141. _MPLibraryIsCompatible
  142. ===========================================================================================
  143. */
  144. /*
  145. ===========================================================================================
  146. The following services were in previous versions of this header for "debugging only" use.
  147. They are NOT implemented in version 2.0. For old builds they can be accessed by defining
  148. the symbol MPIncludeDefunctServices to have a nonzero value.
  149. _MPInitializePrintf
  150. _MPPrintf
  151. _MPDebugStr
  152. _MPStatusPString
  153. _MPStatusCString
  154. ===========================================================================================
  155. */
  156. /*
  157. .
  158. ===========================================================================================
  159. General Types and Constants
  160. ===========================
  161. */
  162. #define MPCopyrightNotice \
  163. "Copyright � 1995-2000 Apple Computer, Inc.\n"
  164. #define MPLibraryName "MPLibrary"
  165. #define MPLibraryCName MPLibraryName
  166. #define MPLibraryPName "\p" MPLibraryName
  167. #define MP_API_Version "2.3"
  168. enum {
  169. MPLibrary_MajorVersion = 2, /* ! When these change be sure to update the build versions*/
  170. MPLibrary_MinorVersion = 3, /* ! used in the startup check in MPInitializeAPI!*/
  171. MPLibrary_Release = 1,
  172. MPLibrary_DevelopmentRevision = 1
  173. };
  174. typedef struct OpaqueMPProcessID* MPProcessID;
  175. typedef struct OpaqueMPTaskID* MPTaskID;
  176. typedef struct OpaqueMPQueueID* MPQueueID;
  177. typedef struct OpaqueMPSemaphoreID* MPSemaphoreID;
  178. typedef struct OpaqueMPCriticalRegionID* MPCriticalRegionID;
  179. typedef struct OpaqueMPTimerID* MPTimerID;
  180. typedef struct OpaqueMPEventID* MPEventID;
  181. typedef struct OpaqueMPAddressSpaceID* MPAddressSpaceID;
  182. typedef struct OpaqueMPNotificationID* MPNotificationID;
  183. typedef struct OpaqueMPCoherenceID* MPCoherenceID;
  184. typedef struct OpaqueMPCpuID* MPCpuID;
  185. typedef struct OpaqueMPAreaID* MPAreaID;
  186. typedef struct OpaqueMPConsoleID* MPConsoleID;
  187. typedef struct OpaqueMPOpaqueID* MPOpaqueID;
  188. enum {
  189. /* Values for MPOpaqueIDClass.*/
  190. kOpaqueAnyID = 0,
  191. kOpaqueProcessID = 1,
  192. kOpaqueTaskID = 2,
  193. kOpaqueTimerID = 3,
  194. kOpaqueQueueID = 4,
  195. kOpaqueSemaphoreID = 5,
  196. kOpaqueCriticalRegionID = 6,
  197. kOpaqueCpuID = 7,
  198. kOpaqueAddressSpaceID = 8,
  199. kOpaqueEventID = 9,
  200. kOpaqueCoherenceID = 10,
  201. kOpaqueAreaID = 11,
  202. kOpaqueNotificationID = 12,
  203. kOpaqueConsoleID = 13
  204. };
  205. typedef UInt32 MPOpaqueIDClass;
  206. enum {
  207. kMPNoID = kInvalidID /* New code should use kInvalidID everywhere.*/
  208. };
  209. typedef OptionBits MPTaskOptions;
  210. typedef UInt32 TaskStorageIndex;
  211. typedef UInt32 TaskStorageValue;
  212. typedef ItemCount MPSemaphoreCount;
  213. typedef UInt32 MPTaskWeight;
  214. typedef UInt32 MPEventFlags;
  215. typedef UInt32 MPExceptionKind;
  216. typedef UInt32 MPTaskStateKind;
  217. typedef UInt32 MPPageSizeClass;
  218. enum {
  219. kDurationImmediate = 0L,
  220. kDurationForever = 0x7FFFFFFF,
  221. kDurationMillisecond = 1,
  222. kDurationMicrosecond = -1
  223. };
  224. /*
  225. .
  226. ===========================================================================================
  227. Process/Processor Services
  228. ==========================
  229. */
  230. /*
  231. * MPProcessors()
  232. *
  233. * Availability:
  234. * Non-Carbon CFM: in MPLibrary 1.0 and later
  235. * CarbonLib: in CarbonLib 1.0 and later
  236. * Mac OS X: in version 10.0 and later
  237. */
  238. EXTERN_API_C( ItemCount )
  239. MPProcessors(void);
  240. /* The physical total.*/
  241. /*
  242. * MPProcessorsScheduled()
  243. *
  244. * Availability:
  245. * Non-Carbon CFM: in MPLibrary 2.0 and later
  246. * CarbonLib: in CarbonLib 1.0 and later
  247. * Mac OS X: in version 10.0 and later
  248. */
  249. EXTERN_API_C( ItemCount )
  250. MPProcessorsScheduled(void);
  251. /* Those currently in use.*/
  252. /*
  253. .
  254. ===========================================================================================
  255. Tasking Services
  256. ================
  257. */
  258. enum {
  259. /* For MPCreateTask options*/
  260. kMPCreateTaskSuspendedMask = 1L << 0,
  261. kMPCreateTaskTakesAllExceptionsMask = 1L << 1,
  262. kMPCreateTaskNotDebuggableMask = 1L << 2,
  263. kMPCreateTaskValidOptionsMask = kMPCreateTaskSuspendedMask | kMPCreateTaskTakesAllExceptionsMask | kMPCreateTaskNotDebuggableMask
  264. };
  265. /* -------------------------------------------------------------------------------------------*/
  266. typedef CALLBACK_API_C( OSStatus , TaskProc )(void * parameter);
  267. /*
  268. * MPCreateTask()
  269. *
  270. * Availability:
  271. * Non-Carbon CFM: in MPLibrary 1.0 and later
  272. * CarbonLib: in CarbonLib 1.0 and later
  273. * Mac OS X: in version 10.0 and later
  274. */
  275. EXTERN_API_C( OSStatus )
  276. MPCreateTask(
  277. TaskProc entryPoint,
  278. void * parameter,
  279. ByteCount stackSize,
  280. MPQueueID notifyQueue,
  281. void * terminationParameter1,
  282. void * terminationParameter2,
  283. MPTaskOptions options,
  284. MPTaskID * task);
  285. /*
  286. * MPTerminateTask()
  287. *
  288. * Availability:
  289. * Non-Carbon CFM: in MPLibrary 1.0 and later
  290. * CarbonLib: in CarbonLib 1.0 and later
  291. * Mac OS X: in version 10.0 and later
  292. */
  293. EXTERN_API_C( OSStatus )
  294. MPTerminateTask(
  295. MPTaskID task,
  296. OSStatus terminationStatus);
  297. /*
  298. * MPSetTaskWeight()
  299. *
  300. * Availability:
  301. * Non-Carbon CFM: in MPLibrary 2.0 and later
  302. * CarbonLib: in CarbonLib 1.0 and later
  303. * Mac OS X: in version 10.0 and later
  304. */
  305. EXTERN_API_C( OSStatus )
  306. MPSetTaskWeight(
  307. MPTaskID task,
  308. MPTaskWeight weight);
  309. /*
  310. * MPTaskIsPreemptive()
  311. *
  312. * Availability:
  313. * Non-Carbon CFM: in MPLibrary 2.0 and later
  314. * CarbonLib: in CarbonLib 1.0 and later
  315. * Mac OS X: in version 10.0 and later
  316. */
  317. EXTERN_API_C( Boolean )
  318. MPTaskIsPreemptive(MPTaskID taskID);
  319. /* May be kInvalidID.*/
  320. /*
  321. * MPExit()
  322. *
  323. * Availability:
  324. * Non-Carbon CFM: in MPLibrary 1.0 and later
  325. * CarbonLib: in CarbonLib 1.0 and later
  326. * Mac OS X: in version 10.0 and later
  327. */
  328. EXTERN_API_C( void )
  329. MPExit(OSStatus status);
  330. /*
  331. * MPYield()
  332. *
  333. * Availability:
  334. * Non-Carbon CFM: in MPLibrary 1.0 and later
  335. * CarbonLib: in CarbonLib 1.0 and later
  336. * Mac OS X: in version 10.0 and later
  337. */
  338. EXTERN_API_C( void )
  339. MPYield(void);
  340. /*
  341. * MPCurrentTaskID()
  342. *
  343. * Availability:
  344. * Non-Carbon CFM: in MPLibrary 1.0 and later
  345. * CarbonLib: in CarbonLib 1.0 and later
  346. * Mac OS X: in version 10.0 and later
  347. */
  348. EXTERN_API_C( MPTaskID )
  349. MPCurrentTaskID(void);
  350. /*
  351. * MPSetTaskType()
  352. *
  353. * Availability:
  354. * Non-Carbon CFM: in MPLibrary 2.3 and later
  355. * CarbonLib: in CarbonLib 1.0 and later
  356. * Mac OS X: in version 10.1 and later
  357. */
  358. EXTERN_API_C( OSStatus )
  359. MPSetTaskType(
  360. MPTaskID task,
  361. OSType taskType);
  362. /* -------------------------------------------------------------------------------------------*/
  363. /*
  364. ---------------------------------------------------
  365. ! The task storage services are new in version 2.0.
  366. */
  367. /*
  368. * MPAllocateTaskStorageIndex()
  369. *
  370. * Availability:
  371. * Non-Carbon CFM: in MPLibrary 2.0 and later
  372. * CarbonLib: in CarbonLib 1.0 and later
  373. * Mac OS X: in version 10.0 and later
  374. */
  375. EXTERN_API_C( OSStatus )
  376. MPAllocateTaskStorageIndex(TaskStorageIndex * index);
  377. /*
  378. * MPDeallocateTaskStorageIndex()
  379. *
  380. * Availability:
  381. * Non-Carbon CFM: in MPLibrary 2.0 and later
  382. * CarbonLib: in CarbonLib 1.0 and later
  383. * Mac OS X: in version 10.0 and later
  384. */
  385. EXTERN_API_C( OSStatus )
  386. MPDeallocateTaskStorageIndex(TaskStorageIndex index);
  387. /*
  388. * MPSetTaskStorageValue()
  389. *
  390. * Availability:
  391. * Non-Carbon CFM: in MPLibrary 2.0 and later
  392. * CarbonLib: in CarbonLib 1.0 and later
  393. * Mac OS X: in version 10.0 and later
  394. */
  395. EXTERN_API_C( OSStatus )
  396. MPSetTaskStorageValue(
  397. TaskStorageIndex index,
  398. TaskStorageValue value);
  399. /*
  400. * MPGetTaskStorageValue()
  401. *
  402. * Availability:
  403. * Non-Carbon CFM: in MPLibrary 2.0 and later
  404. * CarbonLib: in CarbonLib 1.0 and later
  405. * Mac OS X: in version 10.0 and later
  406. */
  407. EXTERN_API_C( TaskStorageValue )
  408. MPGetTaskStorageValue(TaskStorageIndex index);
  409. /*
  410. .
  411. ===========================================================================================
  412. Synchronization Services
  413. ========================
  414. */
  415. /*
  416. * MPCreateQueue()
  417. *
  418. * Availability:
  419. * Non-Carbon CFM: in MPLibrary 1.0 and later
  420. * CarbonLib: in CarbonLib 1.0 and later
  421. * Mac OS X: in version 10.0 and later
  422. */
  423. EXTERN_API_C( OSStatus )
  424. MPCreateQueue(MPQueueID * queue);
  425. /*
  426. * MPDeleteQueue()
  427. *
  428. * Availability:
  429. * Non-Carbon CFM: in MPLibrary 1.0 and later
  430. * CarbonLib: in CarbonLib 1.0 and later
  431. * Mac OS X: in version 10.0 and later
  432. */
  433. EXTERN_API_C( OSStatus )
  434. MPDeleteQueue(MPQueueID queue);
  435. /*
  436. * MPNotifyQueue()
  437. *
  438. * Availability:
  439. * Non-Carbon CFM: in MPLibrary 1.0 and later
  440. * CarbonLib: in CarbonLib 1.0 and later
  441. * Mac OS X: in version 10.0 and later
  442. */
  443. EXTERN_API_C( OSStatus )
  444. MPNotifyQueue(
  445. MPQueueID queue,
  446. void * param1,
  447. void * param2,
  448. void * param3);
  449. /*
  450. * MPWaitOnQueue()
  451. *
  452. * Availability:
  453. * Non-Carbon CFM: in MPLibrary 1.0 and later
  454. * CarbonLib: in CarbonLib 1.0 and later
  455. * Mac OS X: in version 10.0 and later
  456. */
  457. EXTERN_API_C( OSStatus )
  458. MPWaitOnQueue(
  459. MPQueueID queue,
  460. void ** param1,
  461. void ** param2,
  462. void ** param3,
  463. Duration timeout);
  464. /*
  465. * MPSetQueueReserve()
  466. *
  467. * Availability:
  468. * Non-Carbon CFM: in MPLibrary 2.0 and later
  469. * CarbonLib: in CarbonLib 1.0 and later
  470. * Mac OS X: in version 10.0 and later
  471. */
  472. EXTERN_API_C( OSStatus )
  473. MPSetQueueReserve(
  474. MPQueueID queue,
  475. ItemCount count);
  476. /* -------------------------------------------------------------------------------------------*/
  477. /*
  478. * MPCreateSemaphore()
  479. *
  480. * Availability:
  481. * Non-Carbon CFM: in MPLibrary 1.0 and later
  482. * CarbonLib: in CarbonLib 1.0 and later
  483. * Mac OS X: in version 10.0 and later
  484. */
  485. EXTERN_API_C( OSStatus )
  486. MPCreateSemaphore(
  487. MPSemaphoreCount maximumValue,
  488. MPSemaphoreCount initialValue,
  489. MPSemaphoreID * semaphore);
  490. /*
  491. * MPDeleteSemaphore()
  492. *
  493. * Availability:
  494. * Non-Carbon CFM: in MPLibrary 1.0 and later
  495. * CarbonLib: in CarbonLib 1.0 and later
  496. * Mac OS X: in version 10.0 and later
  497. */
  498. EXTERN_API_C( OSStatus )
  499. MPDeleteSemaphore(MPSemaphoreID semaphore);
  500. /*
  501. * MPSignalSemaphore()
  502. *
  503. * Availability:
  504. * Non-Carbon CFM: in MPLibrary 1.0 and later
  505. * CarbonLib: in CarbonLib 1.0 and later
  506. * Mac OS X: in version 10.0 and later
  507. */
  508. EXTERN_API_C( OSStatus )
  509. MPSignalSemaphore(MPSemaphoreID semaphore);
  510. /*
  511. * MPWaitOnSemaphore()
  512. *
  513. * Availability:
  514. * Non-Carbon CFM: in MPLibrary 1.0 and later
  515. * CarbonLib: in CarbonLib 1.0 and later
  516. * Mac OS X: in version 10.0 and later
  517. */
  518. EXTERN_API_C( OSStatus )
  519. MPWaitOnSemaphore(
  520. MPSemaphoreID semaphore,
  521. Duration timeout);
  522. #define MPCreateBinarySemaphore(semaphore) \
  523. MPCreateSemaphore ( 1, 1, (semaphore) )
  524. /* -------------------------------------------------------------------------------------------*/
  525. /*
  526. * MPCreateCriticalRegion()
  527. *
  528. * Availability:
  529. * Non-Carbon CFM: in MPLibrary 1.0 and later
  530. * CarbonLib: in CarbonLib 1.0 and later
  531. * Mac OS X: in version 10.0 and later
  532. */
  533. EXTERN_API_C( OSStatus )
  534. MPCreateCriticalRegion(MPCriticalRegionID * criticalRegion);
  535. /*
  536. * MPDeleteCriticalRegion()
  537. *
  538. * Availability:
  539. * Non-Carbon CFM: in MPLibrary 1.0 and later
  540. * CarbonLib: in CarbonLib 1.0 and later
  541. * Mac OS X: in version 10.0 and later
  542. */
  543. EXTERN_API_C( OSStatus )
  544. MPDeleteCriticalRegion(MPCriticalRegionID criticalRegion);
  545. /*
  546. * MPEnterCriticalRegion()
  547. *
  548. * Availability:
  549. * Non-Carbon CFM: in MPLibrary 1.0 and later
  550. * CarbonLib: in CarbonLib 1.0 and later
  551. * Mac OS X: in version 10.0 and later
  552. */
  553. EXTERN_API_C( OSStatus )
  554. MPEnterCriticalRegion(
  555. MPCriticalRegionID criticalRegion,
  556. Duration timeout);
  557. /*
  558. * MPExitCriticalRegion()
  559. *
  560. * Availability:
  561. * Non-Carbon CFM: in MPLibrary 1.0 and later
  562. * CarbonLib: in CarbonLib 1.0 and later
  563. * Mac OS X: in version 10.0 and later
  564. */
  565. EXTERN_API_C( OSStatus )
  566. MPExitCriticalRegion(MPCriticalRegionID criticalRegion);
  567. /* -------------------------------------------------------------------------------------------*/
  568. /*
  569. * MPCreateEvent()
  570. *
  571. * Availability:
  572. * Non-Carbon CFM: in MPLibrary 2.0 and later
  573. * CarbonLib: in CarbonLib 1.0 and later
  574. * Mac OS X: in version 10.0 and later
  575. */
  576. EXTERN_API( OSStatus )
  577. MPCreateEvent(MPEventID * event);
  578. /*
  579. * MPDeleteEvent()
  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. EXTERN_API_C( OSStatus )
  587. MPDeleteEvent(MPEventID event);
  588. /*
  589. * MPSetEvent()
  590. *
  591. * Availability:
  592. * Non-Carbon CFM: in MPLibrary 2.0 and later
  593. * CarbonLib: in CarbonLib 1.0 and later
  594. * Mac OS X: in version 10.0 and later
  595. */
  596. EXTERN_API_C( OSStatus )
  597. MPSetEvent(
  598. MPEventID event,
  599. MPEventFlags flags);
  600. /*
  601. * MPWaitForEvent()
  602. *
  603. * Availability:
  604. * Non-Carbon CFM: in MPLibrary 2.0 and later
  605. * CarbonLib: in CarbonLib 1.0 and later
  606. * Mac OS X: in version 10.0 and later
  607. */
  608. EXTERN_API( OSStatus )
  609. MPWaitForEvent(
  610. MPEventID event,
  611. MPEventFlags * flags,
  612. Duration timeout);
  613. /*
  614. .
  615. ===========================================================================================
  616. Notification Services (API)
  617. =====================
  618. */
  619. /*
  620. * MPCreateNotification()
  621. *
  622. * Availability:
  623. * Non-Carbon CFM: in MPLibrary 2.1 and later
  624. * CarbonLib: in CarbonLib 1.0 and later
  625. * Mac OS X: in version 10.0 and later
  626. */
  627. EXTERN_API_C( OSStatus )
  628. MPCreateNotification(MPNotificationID * notificationID);
  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. EXTERN_API_C( OSStatus )
  638. MPDeleteNotification(MPNotificationID notificationID);
  639. /*
  640. * MPModifyNotification()
  641. *
  642. * Availability:
  643. * Non-Carbon CFM: in MPLibrary 2.1 and later
  644. * CarbonLib: in CarbonLib 1.0 and later
  645. * Mac OS X: in version 10.0 and later
  646. */
  647. EXTERN_API_C( OSStatus )
  648. MPModifyNotification(
  649. MPNotificationID notificationID,
  650. MPOpaqueID anID,
  651. void * notifyParam1,
  652. void * notifyParam2,
  653. void * notifyParam3);
  654. /*
  655. * MPModifyNotificationParameters()
  656. *
  657. * Availability:
  658. * Non-Carbon CFM: in MPLibrary 2.3 and later
  659. * CarbonLib: in CarbonLib 1.0 and later
  660. * Mac OS X: in version 10.1 and later
  661. */
  662. EXTERN_API_C( OSStatus )
  663. MPModifyNotificationParameters(
  664. MPNotificationID notificationID,
  665. MPOpaqueIDClass kind,
  666. void * notifyParam1,
  667. void * notifyParam2,
  668. void * notifyParam3);
  669. /*
  670. * MPCauseNotification()
  671. *
  672. * Availability:
  673. * Non-Carbon CFM: in MPLibrary 2.1 and later
  674. * CarbonLib: in CarbonLib 1.0 and later
  675. * Mac OS X: in version 10.0 and later
  676. */
  677. EXTERN_API_C( OSStatus )
  678. MPCauseNotification(MPNotificationID notificationID);
  679. /*
  680. .
  681. ===========================================================================================
  682. Timer Services
  683. ==============
  684. */
  685. /*
  686. --------------------------------------------
  687. ! The timer services are new in version 2.0.
  688. */
  689. #if 0
  690. /* For now these are taken from DriverServices, should be in a better place.*/
  691. #if CALL_NOT_IN_CARBON
  692. /*
  693. * UpTime()
  694. *
  695. * Availability:
  696. * Non-Carbon CFM: not available
  697. * CarbonLib: not available
  698. * Mac OS X: not available
  699. */
  700. EXTERN_API_C( AbsoluteTime )
  701. UpTime(void);
  702. /*
  703. * DurationToAbsolute()
  704. *
  705. * Availability:
  706. * Non-Carbon CFM: not available
  707. * CarbonLib: not available
  708. * Mac OS X: not available
  709. */
  710. EXTERN_API_C( AbsoluteTime )
  711. DurationToAbsolute(Duration duration);
  712. /*
  713. * AbsoluteToDuration()
  714. *
  715. * Availability:
  716. * Non-Carbon CFM: not available
  717. * CarbonLib: not available
  718. * Mac OS X: not available
  719. */
  720. EXTERN_API_C( Duration )
  721. AbsoluteToDuration(AbsoluteTime time);
  722. #endif /* CALL_NOT_IN_CARBON */
  723. #endif /* 0 */
  724. enum {
  725. /* For MPArmTimer options*/
  726. kMPPreserveTimerIDMask = 1L << 0,
  727. kMPTimeIsDeltaMask = 1L << 1,
  728. kMPTimeIsDurationMask = 1L << 2
  729. };
  730. /*
  731. * MPDelayUntil()
  732. *
  733. * Availability:
  734. * Non-Carbon CFM: in MPLibrary 2.0 and later
  735. * CarbonLib: in CarbonLib 1.0 and later
  736. * Mac OS X: in version 10.0 and later
  737. */
  738. EXTERN_API_C( OSStatus )
  739. MPDelayUntil(AbsoluteTime * expirationTime);
  740. #if CALL_NOT_IN_CARBON
  741. /*
  742. * MPDelayUntilSys()
  743. *
  744. * Availability:
  745. * Non-Carbon CFM: in MPLibrary 2.1 and later
  746. * CarbonLib: not available
  747. * Mac OS X: not available
  748. */
  749. EXTERN_API( OSStatus )
  750. MPDelayUntilSys(AbsoluteTime * expirationTime);
  751. #endif /* CALL_NOT_IN_CARBON */
  752. /*
  753. * MPCreateTimer()
  754. *
  755. * Availability:
  756. * Non-Carbon CFM: in MPLibrary 2.0 and later
  757. * CarbonLib: in CarbonLib 1.0 and later
  758. * Mac OS X: in version 10.0 and later
  759. */
  760. EXTERN_API_C( OSStatus )
  761. MPCreateTimer(MPTimerID * timerID);
  762. /*
  763. * MPDeleteTimer()
  764. *
  765. * Availability:
  766. * Non-Carbon CFM: in MPLibrary 2.0 and later
  767. * CarbonLib: in CarbonLib 1.0 and later
  768. * Mac OS X: in version 10.0 and later
  769. */
  770. EXTERN_API_C( OSStatus )
  771. MPDeleteTimer(MPTimerID timerID);
  772. /*
  773. * MPSetTimerNotify()
  774. *
  775. * Availability:
  776. * Non-Carbon CFM: in MPLibrary 2.0 and later
  777. * CarbonLib: in CarbonLib 1.0 and later
  778. * Mac OS X: in version 10.0 and later
  779. */
  780. EXTERN_API_C( OSStatus )
  781. MPSetTimerNotify(
  782. MPTimerID timerID,
  783. MPOpaqueID anID,
  784. void * notifyParam1,
  785. void * notifyParam2,
  786. void * notifyParam3);
  787. /*
  788. * MPArmTimer()
  789. *
  790. * Availability:
  791. * Non-Carbon CFM: in MPLibrary 2.0 and later
  792. * CarbonLib: in CarbonLib 1.0 and later
  793. * Mac OS X: in version 10.0 and later
  794. */
  795. EXTERN_API_C( OSStatus )
  796. MPArmTimer(
  797. MPTimerID timerID,
  798. AbsoluteTime * expirationTime,
  799. OptionBits options);
  800. /*
  801. * MPCancelTimer()
  802. *
  803. * Availability:
  804. * Non-Carbon CFM: in MPLibrary 2.0 and later
  805. * CarbonLib: in CarbonLib 1.0 and later
  806. * Mac OS X: in version 10.0 and later
  807. */
  808. EXTERN_API_C( OSStatus )
  809. MPCancelTimer(
  810. MPTimerID timerID,
  811. AbsoluteTime * timeRemaining);
  812. /*
  813. .
  814. ===========================================================================================
  815. Memory Services
  816. ===============
  817. */
  818. enum {
  819. /* Maximum allocation request size is 1GB.*/
  820. kMPMaxAllocSize = 1024L * 1024 * 1024
  821. };
  822. enum {
  823. /* Values for the alignment parameter to MPAllocateAligned.*/
  824. kMPAllocateDefaultAligned = 0,
  825. kMPAllocate8ByteAligned = 3,
  826. kMPAllocate16ByteAligned = 4,
  827. kMPAllocate32ByteAligned = 5,
  828. kMPAllocate1024ByteAligned = 10,
  829. kMPAllocate4096ByteAligned = 12,
  830. kMPAllocateMaxAlignment = 16, /* Somewhat arbitrary limit on expectations.*/
  831. kMPAllocateAltiVecAligned = kMPAllocate16ByteAligned, /* The P.C. name.*/
  832. kMPAllocateVMXAligned = kMPAllocateAltiVecAligned, /* The older, common name.*/
  833. kMPAllocateVMPageAligned = 254, /* Pseudo value, converted at runtime.*/
  834. kMPAllocateInterlockAligned = 255 /* Pseudo value, converted at runtime.*/
  835. };
  836. enum {
  837. /* Values for the options parameter to MPAllocateAligned.*/
  838. kMPAllocateClearMask = 0x0001, /* Zero the allocated block.*/
  839. kMPAllocateGloballyMask = 0x0002, /* Allocate from the globally visible pool.*/
  840. kMPAllocateResidentMask = 0x0004, /* Allocate from the RAM-resident pool.*/
  841. kMPAllocateNoGrowthMask = 0x0010, /* Do not attempt to grow the pool.*/
  842. kMPAllocateNoCreateMask = 0x0020 /* Do not attempt to create the pool if it doesn't exist yet.*/
  843. };
  844. /* -------------------------------------------------------------------------------------------*/
  845. /*
  846. * MPAllocateAligned()
  847. *
  848. * Availability:
  849. * Non-Carbon CFM: in MPLibrary 2.0 and later
  850. * CarbonLib: in CarbonLib 1.0 and later
  851. * Mac OS X: in version 10.0 and later
  852. */
  853. EXTERN_API_C( LogicalAddress )
  854. MPAllocateAligned(
  855. ByteCount size,
  856. UInt8 alignment,
  857. OptionBits options);
  858. /* ! MPAllocateAligned is new in version 2.0.*/
  859. /*
  860. * MPAllocate()
  861. *
  862. * Availability:
  863. * Non-Carbon CFM: in MPLibrary 1.0 and later
  864. * CarbonLib: in CarbonLib 1.0 and later
  865. * Mac OS X: in version 10.0 and later
  866. */
  867. EXTERN_API_C( LogicalAddress )
  868. MPAllocate(ByteCount size);
  869. /* Use MPAllocateAligned instead.*/
  870. /*
  871. * MPFree()
  872. *
  873. * Availability:
  874. * Non-Carbon CFM: in MPLibrary 1.0 and later
  875. * CarbonLib: in CarbonLib 1.0 and later
  876. * Mac OS X: in version 10.0 and later
  877. */
  878. EXTERN_API_C( void )
  879. MPFree(LogicalAddress object);
  880. /*
  881. * MPGetAllocatedBlockSize()
  882. *
  883. * Availability:
  884. * Non-Carbon CFM: in MPLibrary 2.0 and later
  885. * CarbonLib: in CarbonLib 1.0 and later
  886. * Mac OS X: in version 10.0 and later
  887. */
  888. EXTERN_API_C( ByteCount )
  889. MPGetAllocatedBlockSize(LogicalAddress object);
  890. /* -------------------------------------------------------------------------------------------*/
  891. /*
  892. * MPBlockCopy()
  893. *
  894. * Availability:
  895. * Non-Carbon CFM: in MPLibrary 1.0 and later
  896. * CarbonLib: in CarbonLib 1.0 and later
  897. * Mac OS X: in version 10.0 and later
  898. */
  899. EXTERN_API_C( void )
  900. MPBlockCopy(
  901. LogicalAddress source,
  902. LogicalAddress destination,
  903. ByteCount size);
  904. /*
  905. * MPBlockClear()
  906. *
  907. * Availability:
  908. * Non-Carbon CFM: in MPLibrary 2.0 and later
  909. * CarbonLib: in CarbonLib 1.0 and later
  910. * Mac OS X: in version 10.0 and later
  911. */
  912. EXTERN_API_C( void )
  913. MPBlockClear(
  914. LogicalAddress address,
  915. ByteCount size);
  916. /* ! MPBlockClear is new in version 2.0.*/
  917. /*
  918. * MPDataToCode()
  919. *
  920. * Availability:
  921. * Non-Carbon CFM: in MPLibrary 2.0 and later
  922. * CarbonLib: in CarbonLib 1.0 and later
  923. * Mac OS X: in version 10.0 and later
  924. */
  925. EXTERN_API_C( void )
  926. MPDataToCode(
  927. LogicalAddress address,
  928. ByteCount size);
  929. /* ! MPDataToCode is new in version 2.0.*/
  930. /*
  931. .
  932. ===========================================================================================
  933. Exception/Debugging Services
  934. ============================
  935. */
  936. /*
  937. -------------------------------------------------------------------------------------------
  938. *** Important Note ***
  939. ----------------------
  940. The functions MPExtractTaskState and MPSetTaskState infer the size of the "info" buffer
  941. from the "kind" parameter. A given value for MPTaskStateKind will always refer to a
  942. single specific physical buffer layout. Should new register sets be added, or the size
  943. or number of any registers change, new values of MPTaskStateKind will be introduced to
  944. refer to the new buffer layouts.
  945. The following types for the buffers are in MachineExceptions. The correspondence between
  946. MPTaskStateKind values and MachineExceptions types is:
  947. kMPTaskStateRegisters -> RegisterInformation
  948. kMPTaskStateFPU -> FPUInformation
  949. kMPTaskStateVectors -> VectorInformation
  950. kMPTaskStateMachine -> MachineInformation
  951. kMPTaskState32BitMemoryException -> ExceptionInfo for old-style 32-bit memory exceptions
  952. For reference, on PowerPC the MachineExceptions types contain:
  953. RegisterInformation -> The GPRs, 32 values of 64 bits each.
  954. FPUInformation -> The FPRs plus FPSCR, 32 values of 64 bits each, one value of
  955. 32 bits.
  956. VectorInformation -> The AltiVec vector registers plus VSCR and VRSave, 32 values
  957. of 128 bits each, one value of 128 bits, and one 32 bit value.
  958. MachineInformation -> The CTR, LR, PC, each of 64 bits. The CR, XER, MSR, MQ,
  959. exception kind, and DSISR, each of 32 bits. The 64 bit DAR.
  960. ExceptionInfo -> Only memory exceptions are specified, 4 fields of 32 bits each.
  961. Note that this type only covers memory exceptions on 32-bit CPUs!
  962. The following types are declared here:
  963. kMPTaskStateTaskInfo -> MPTaskInfo
  964. */
  965. enum {
  966. /* Values for the TaskStateKind to MPExtractTaskState and MPSetTaskState.*/
  967. kMPTaskStateRegisters = 0, /* The task general registers.*/
  968. kMPTaskStateFPU = 1, /* The task floating point registers*/
  969. kMPTaskStateVectors = 2, /* The task vector registers*/
  970. kMPTaskStateMachine = 3, /* The task machine registers*/
  971. kMPTaskState32BitMemoryException = 4, /* The task memory exception information for 32-bit CPUs.*/
  972. kMPTaskStateTaskInfo = 5 /* Static and dynamic information about the task.*/
  973. };
  974. enum {
  975. /* Option bits and numbers for MPDisposeTaskException.*/
  976. kMPTaskPropagate = 0, /* The exception is propagated.*/
  977. kMPTaskResumeStep = 1, /* The task is resumed and single step is enabled.*/
  978. kMPTaskResumeBranch = 2, /* The task is resumed and branch stepping is enabled.*/
  979. kMPTaskResumeMask = 0x0000, /* The task is resumed.*/
  980. kMPTaskPropagateMask = 1 << kMPTaskPropagate, /* The exception is propagated.*/
  981. kMPTaskResumeStepMask = 1 << kMPTaskResumeStep, /* The task is resumed and single step is enabled.*/
  982. kMPTaskResumeBranchMask = 1 << kMPTaskResumeBranch /* The task is resumed and branch stepping is enabled.*/
  983. };
  984. enum {
  985. /* For kMPTaskStateTaskInfo, the task's runState*/
  986. kMPTaskBlocked = 0, /* Task is blocked (queued on resource)*/
  987. kMPTaskReady = 1, /* Task is runnable*/
  988. kMPTaskRunning = 2 /* Task is running*/
  989. };
  990. enum {
  991. /* For kMPTaskStateTaskInfo, the version of the MPTaskInfo structure requested.*/
  992. kMPTaskInfoVersion = 3
  993. };
  994. struct MPTaskInfo {
  995. PBVersion version; /* Version 3 of the data structure requested*/
  996. OSType name; /* Task name*/
  997. OSType queueName; /* Task's queue owner name*/
  998. UInt16 runState; /* Running, ready, blocked*/
  999. UInt16 lastCPU; /* Address of CPU where task previously ran*/
  1000. UInt32 weight; /* Processing weight: 1 - 10,000*/
  1001. MPProcessID processID; /* Owning process ID*/
  1002. AbsoluteTime cpuTime; /* Accumulated task time*/
  1003. AbsoluteTime schedTime; /* Time when last scheduled*/
  1004. AbsoluteTime creationTime; /* Time when task created*/
  1005. ItemCount codePageFaults; /* Page faults from code execution*/
  1006. ItemCount dataPageFaults; /* Page faults from data access*/
  1007. ItemCount preemptions; /* Number of times task was preempted*/
  1008. MPCpuID cpuID; /* ID of CPU where task previously ran.*/
  1009. MPOpaqueID blockedObject; /* ID of blocked object.*/
  1010. MPAddressSpaceID spaceID; /* Address space ID of this task.*/
  1011. LogicalAddress stackBase; /* Base of stack (lowest address).*/
  1012. LogicalAddress stackLimit; /* Stack limit (highest address).*/
  1013. LogicalAddress stackCurr; /* Current stack address.*/
  1014. };
  1015. typedef struct MPTaskInfo MPTaskInfo;
  1016. /*
  1017. Upon a task exception, the following message is sent to the designated queue:
  1018. 1. The MPTaskID,
  1019. 2. The exception kind. These are enumerated in the interfaces header MachineExceptions.h
  1020. 3. N/A
  1021. */
  1022. /* -------------------------------------------------------------------------------------------*/
  1023. /*
  1024. * MPSetExceptionHandler()
  1025. *
  1026. * Availability:
  1027. * Non-Carbon CFM: in MPLibrary 2.0 and later
  1028. * CarbonLib: in CarbonLib 1.0 and later
  1029. * Mac OS X: in version 10.0 and later
  1030. */
  1031. EXTERN_API_C( OSStatus )
  1032. MPSetExceptionHandler(
  1033. MPTaskID task,
  1034. MPQueueID exceptionQ);
  1035. /*
  1036. * MPDisposeTaskException()
  1037. *
  1038. * Availability:
  1039. * Non-Carbon CFM: in MPLibrary 2.0 and later
  1040. * CarbonLib: in CarbonLib 1.0 and later
  1041. * Mac OS X: in version 10.0 and later
  1042. */
  1043. EXTERN_API_C( OSStatus )
  1044. MPDisposeTaskException(
  1045. MPTaskID task,
  1046. OptionBits action);
  1047. /*
  1048. * MPExtractTaskState()
  1049. *
  1050. * Availability:
  1051. * Non-Carbon CFM: in MPLibrary 2.0 and later
  1052. * CarbonLib: in CarbonLib 1.0 and later
  1053. * Mac OS X: in version 10.0 and later
  1054. */
  1055. EXTERN_API_C( OSStatus )
  1056. MPExtractTaskState(
  1057. MPTaskID task,
  1058. MPTaskStateKind kind,
  1059. void * info);
  1060. /*
  1061. * MPSetTaskState()
  1062. *
  1063. * Availability:
  1064. * Non-Carbon CFM: in MPLibrary 2.0 and later
  1065. * CarbonLib: in CarbonLib 1.0 and later
  1066. * Mac OS X: in version 10.0 and later
  1067. */
  1068. EXTERN_API_C( OSStatus )
  1069. MPSetTaskState(
  1070. MPTaskID task,
  1071. MPTaskStateKind kind,
  1072. void * info);
  1073. /*
  1074. * MPThrowException()
  1075. *
  1076. * Availability:
  1077. * Non-Carbon CFM: in MPLibrary 2.0 and later
  1078. * CarbonLib: in CarbonLib 1.0 and later
  1079. * Mac OS X: in version 10.0 and later
  1080. */
  1081. EXTERN_API_C( OSStatus )
  1082. MPThrowException(
  1083. MPTaskID task,
  1084. MPExceptionKind kind);
  1085. /* -------------------------------------------------------------------------------------------*/
  1086. typedef UInt32 MPDebuggerLevel;
  1087. enum {
  1088. kMPLowLevelDebugger = 0x00000000, /* MacsBug-like*/
  1089. kMPMidLevelDebugger = 0x10000000, /* Jasik-like*/
  1090. kMPHighLevelDebugger = 0x20000000 /* Metrowerks-like*/
  1091. };
  1092. /*
  1093. * MPRegisterDebugger()
  1094. *
  1095. * Availability:
  1096. * Non-Carbon CFM: in MPLibrary 2.0 and later
  1097. * CarbonLib: in CarbonLib 1.0 and later
  1098. * Mac OS X: in version 10.0 and later
  1099. */
  1100. EXTERN_API_C( OSStatus )
  1101. MPRegisterDebugger(
  1102. MPQueueID queue,
  1103. MPDebuggerLevel level);
  1104. /*
  1105. * MPUnregisterDebugger()
  1106. *
  1107. * Availability:
  1108. * Non-Carbon CFM: in MPLibrary 2.0 and later
  1109. * CarbonLib: in CarbonLib 1.0 and later
  1110. * Mac OS X: in version 10.0 and later
  1111. */
  1112. EXTERN_API_C( OSStatus )
  1113. MPUnregisterDebugger(MPQueueID queue);
  1114. /*
  1115. .
  1116. ===========================================================================================
  1117. Remote Call Services
  1118. ====================
  1119. */
  1120. typedef CALLBACK_API_C( void *, MPRemoteProcedure )(void * parameter);
  1121. typedef UInt8 MPRemoteContext;
  1122. enum {
  1123. kMPAnyRemoteContext = 0,
  1124. kMPOwningProcessRemoteContext = 1,
  1125. kMPInterruptRemoteContext = 2,
  1126. kMPAsyncInterruptRemoteContext = 3
  1127. };
  1128. /*
  1129. * MPRemoteCall()
  1130. *
  1131. * Availability:
  1132. * Non-Carbon CFM: in MPLibrary 2.0 and later
  1133. * CarbonLib: in CarbonLib 1.0 and later
  1134. * Mac OS X: in version 10.0 and later
  1135. */
  1136. EXTERN_API_C( void * )
  1137. MPRemoteCall(
  1138. MPRemoteProcedure remoteProc,
  1139. void * parameter,
  1140. MPRemoteContext context);
  1141. /* ! MPRemoteCall is new in version 2.0.*/
  1142. /*
  1143. .
  1144. ===========================================================================================
  1145. Checking API Availability
  1146. =========================
  1147. */
  1148. /*
  1149. ===========================================================================================
  1150. *** WARNING: You must properly check the availability of MP services before calling them!
  1151. ===========================================================================================
  1152. Checking for the availability of the MP API is rather ugly. This is a historical problem,
  1153. caused by the original implementation letting itself get prepared when it really wasn't
  1154. usable and complicated by some important clients then depending on weak linking to "work".
  1155. (And further complicated by CFM not supporting "deferred" imports, which is how many
  1156. programmers think weak imports work.)
  1157. The end result is that the MP API library may get prepared by CFM but be totally unusable.
  1158. This means that if you import from the MP API library, you cannot simply check for a
  1159. resolved import to decide if MP services are available. Worse, if you explicitly prepare
  1160. the MP API library you cannot assume that a noErr result from GetSharedLibrary means that
  1161. MP services are available.
  1162. o If you import from the MP API library you MUST:
  1163. Use the MPLibraryIsLoaded macro (or equivalent code in languages other than C) to tell
  1164. if the MP API services are available. It is not sufficient to simply check that an
  1165. imported symbol is resolved as is commonly done for other libraries. The macro expands
  1166. to the expression:
  1167. ( ( (UInt32)_MPIsFullyInitialized != (UInt32)kUnresolvedCFragSymbolAddress ) &&
  1168. ( _MPIsFullyInitialized () ) )
  1169. This checks if the imported symbol _MPIsFullyInitialized is resolved and if resolved
  1170. calls it. Both parts must succeed for the MP API services to be available.
  1171. o If you explicitly prepare the MP API library you MUST:
  1172. Use code similar to the following example to tell if the MP API services are available.
  1173. It is not sufficient to depend on just a noErr result from GetSharedLibrary.
  1174. OSErr err;
  1175. Boolean mpIsAvailable = false;
  1176. CFragConnectionID connID = kInvalidID;
  1177. MPIsFullyInitializedProc mpIsFullyInitialized = NULL;
  1178. err = GetSharedLibrary ( "\pMPLibrary", kCompiledCFragArch, kReferenceCFrag,
  1179. &connID, NULL, NULL );
  1180. if ( err == noErr ) {
  1181. err = FindSymbol ( connID, "\p_MPIsFullyInitialized",
  1182. (Ptr *) &mpIsFullyInitialized, NULL );
  1183. }
  1184. if ( err == noErr ) {
  1185. mpIsAvailable = (* mpIsFullyInitialized) ();
  1186. }
  1187. ===========================================================================================
  1188. */
  1189. /*
  1190. * _MPIsFullyInitialized()
  1191. *
  1192. * Availability:
  1193. * Non-Carbon CFM: in MPLibrary 1.0 and later
  1194. * CarbonLib: in CarbonLib 1.0 and later
  1195. * Mac OS X: in version 10.0 and later
  1196. */
  1197. EXTERN_API_C( Boolean )
  1198. _MPIsFullyInitialized(void);
  1199. typedef CALLBACK_API_C( Boolean , MPIsFullyInitializedProc )(void);
  1200. #define kMPUnresolvedCFragSymbolAddress 0
  1201. #define MPLibraryIsLoaded() \
  1202. ( ( (UInt32)_MPIsFullyInitialized != (UInt32)kMPUnresolvedCFragSymbolAddress ) && \
  1203. ( _MPIsFullyInitialized () ) )
  1204. /*
  1205. .
  1206. ===========================================================================================
  1207. Miscellaneous Services
  1208. ======================
  1209. */
  1210. /*
  1211. * _MPLibraryVersion()
  1212. *
  1213. * Availability:
  1214. * Non-Carbon CFM: in MPLibrary 1.0 and later
  1215. * CarbonLib: in CarbonLib 1.0 and later
  1216. * Mac OS X: in version 10.0 and later
  1217. */
  1218. EXTERN_API_C( void )
  1219. _MPLibraryVersion(
  1220. const char ** versionCString,
  1221. UInt32 * major,
  1222. UInt32 * minor,
  1223. UInt32 * release,
  1224. UInt32 * revision);
  1225. /*
  1226. .
  1227. ===========================================================================================
  1228. Unofficial Services
  1229. ===================
  1230. */
  1231. /*
  1232. ===========================================================================================
  1233. *** WARNING ***
  1234. These services are not part of the officially documented multiprocessing API. They may not
  1235. be avaliable in future versions of Mac OS multiprocessing support, or in environments that
  1236. have a different underlying OS architecture such as Mac OS on top of a microkernel, the
  1237. Mac OS Blue Box under Mac OS X, native MP support in Mac OS X, etc.
  1238. ===========================================================================================
  1239. */
  1240. #if CALL_NOT_IN_CARBON
  1241. #if CALL_NOT_IN_CARBON
  1242. /*
  1243. * _MPAllocateSys()
  1244. *
  1245. * Availability:
  1246. * Non-Carbon CFM: in MPLibrary 1.0 and later
  1247. * CarbonLib: not available
  1248. * Mac OS X: not available
  1249. */
  1250. EXTERN_API_C( LogicalAddress )
  1251. _MPAllocateSys(ByteCount size);
  1252. /* Use MPAllocateAligned instead.*/
  1253. /*
  1254. * _MPRPC()
  1255. *
  1256. * Availability:
  1257. * Non-Carbon CFM: in MPLibrary 1.0 and later
  1258. * CarbonLib: not available
  1259. * Mac OS X: not available
  1260. */
  1261. EXTERN_API_C( void * )
  1262. _MPRPC(
  1263. MPRemoteProcedure remoteProc,
  1264. void * parameter);
  1265. /* Use _MPRemoteCall instead.*/
  1266. /*
  1267. * _MPTaskIsToolboxSafe()
  1268. *
  1269. * Availability:
  1270. * Non-Carbon CFM: in MPLibrary 1.0 and later
  1271. * CarbonLib: not available
  1272. * Mac OS X: not available
  1273. */
  1274. EXTERN_API_C( Boolean )
  1275. _MPTaskIsToolboxSafe(MPTaskID task);
  1276. #endif /* CALL_NOT_IN_CARBON */
  1277. #endif /* CALL_NOT_IN_CARBON */
  1278. /*
  1279. * _MPLibraryIsCompatible()
  1280. *
  1281. * Availability:
  1282. * Non-Carbon CFM: in MPLibrary 1.0 and later
  1283. * CarbonLib: in CarbonLib 1.0 and later
  1284. * Mac OS X: in version 10.0 and later
  1285. */
  1286. EXTERN_API_C( Boolean )
  1287. _MPLibraryIsCompatible(
  1288. const char * versionCString,
  1289. UInt32 major,
  1290. UInt32 minor,
  1291. UInt32 release,
  1292. UInt32 revision);
  1293. #define MPRPC _MPRPC
  1294. #define MPTaskIsToolboxSafe _MPTaskIsToolboxSafe
  1295. /*
  1296. .
  1297. ===========================================================================================
  1298. Defunct Services
  1299. ================
  1300. */
  1301. #if CALL_NOT_IN_CARBON
  1302. #ifndef MPIncludeDefunctServices
  1303. #define MPIncludeDefunctServices 0
  1304. #endif /* !defined(MPIncludeDefunctServices) */
  1305. #if MPIncludeDefunctServices
  1306. #if CALL_NOT_IN_CARBON
  1307. /*
  1308. * _MPDebugStr()
  1309. *
  1310. * Availability:
  1311. * Non-Carbon CFM: in MPLibraryObsolete 1.0 and later
  1312. * CarbonLib: not available
  1313. * Mac OS X: not available
  1314. */
  1315. EXTERN_API_C( void )
  1316. _MPDebugStr(ConstStr255Param msg);
  1317. /*
  1318. * _MPStatusPString()
  1319. *
  1320. * Availability:
  1321. * Non-Carbon CFM: in MPLibraryObsolete 1.0 and later
  1322. * CarbonLib: not available
  1323. * Mac OS X: not available
  1324. */
  1325. EXTERN_API_C( StringPtr )
  1326. _MPStatusPString(OSStatus status);
  1327. /*
  1328. * _MPStatusCString()
  1329. *
  1330. * Availability:
  1331. * Non-Carbon CFM: in MPLibraryObsolete 1.0 and later
  1332. * CarbonLib: not available
  1333. * Mac OS X: not available
  1334. */
  1335. EXTERN_API_C( const char * )
  1336. _MPStatusCString(OSStatus status);
  1337. #endif /* CALL_NOT_IN_CARBON */
  1338. #include <stdarg.h>
  1339. typedef CALLBACK_API_C( void , MPPrintfHandler )(MPTaskID taskID, const char *format, va_list args);
  1340. #if CALL_NOT_IN_CARBON
  1341. /*
  1342. * _MPInitializePrintf()
  1343. *
  1344. * Availability:
  1345. * Non-Carbon CFM: in MPLibraryObsolete 1.0 and later
  1346. * CarbonLib: not available
  1347. * Mac OS X: not available
  1348. */
  1349. EXTERN_API_C( void )
  1350. _MPInitializePrintf(MPPrintfHandler pfn);
  1351. /*
  1352. * _MPPrintf()
  1353. *
  1354. * Availability:
  1355. * Non-Carbon CFM: in MPLibraryObsolete 1.0 and later
  1356. * CarbonLib: not available
  1357. * Mac OS X: not available
  1358. */
  1359. EXTERN_API_C( void )
  1360. _MPPrintf(const char * format, ...);
  1361. #endif /* CALL_NOT_IN_CARBON */
  1362. #endif /* MPIncludeDefunctServices */
  1363. #endif /* CALL_NOT_IN_CARBON */
  1364. /* ===========================================================================================*/
  1365. #if PRAGMA_STRUCT_ALIGN
  1366. #pragma options align=reset
  1367. #elif PRAGMA_STRUCT_PACKPUSH
  1368. #pragma pack(pop)
  1369. #elif PRAGMA_STRUCT_PACK
  1370. #pragma pack()
  1371. #endif
  1372. #ifdef PRAGMA_IMPORT_OFF
  1373. #pragma import off
  1374. #elif PRAGMA_IMPORT
  1375. #pragma import reset
  1376. #endif
  1377. #ifdef __cplusplus
  1378. }
  1379. #endif
  1380. #endif /* __MULTIPROCESSING__ */