OSUtils.pas 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870
  1. {
  2. File: CarbonCore/OSUtils.h
  3. Contains: OS Utilities Interfaces.
  4. The contents of this header file are deprecated.
  5. Copyright: © 1985-2011 by Apple Inc. All rights reserved.
  6. }
  7. {
  8. Modified for use with Free Pascal
  9. Version 308
  10. Please report any bugs to <[email protected]>
  11. }
  12. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  13. {$mode macpas}
  14. {$modeswitch cblocks}
  15. {$packenum 1}
  16. {$macro on}
  17. {$inline on}
  18. {$calling mwpascal}
  19. unit OSUtils;
  20. interface
  21. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  22. {$setc GAP_INTERFACES_VERSION := $0308}
  23. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  24. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  25. {$endc}
  26. {$ifc defined CPUPOWERPC and defined CPUI386}
  27. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  28. {$endc}
  29. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  30. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  31. {$endc}
  32. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  33. {$setc __ppc__ := 1}
  34. {$elsec}
  35. {$setc __ppc__ := 0}
  36. {$endc}
  37. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  38. {$setc __ppc64__ := 1}
  39. {$elsec}
  40. {$setc __ppc64__ := 0}
  41. {$endc}
  42. {$ifc not defined __i386__ and defined CPUI386}
  43. {$setc __i386__ := 1}
  44. {$elsec}
  45. {$setc __i386__ := 0}
  46. {$endc}
  47. {$ifc not defined __x86_64__ and defined CPUX86_64}
  48. {$setc __x86_64__ := 1}
  49. {$elsec}
  50. {$setc __x86_64__ := 0}
  51. {$endc}
  52. {$ifc not defined __arm__ and defined CPUARM}
  53. {$setc __arm__ := 1}
  54. {$elsec}
  55. {$setc __arm__ := 0}
  56. {$endc}
  57. {$ifc not defined __arm64__ and defined CPUAARCH64}
  58. {$setc __arm64__ := 1}
  59. {$elsec}
  60. {$setc __arm64__ := 0}
  61. {$endc}
  62. {$ifc defined cpu64}
  63. {$setc __LP64__ := 1}
  64. {$elsec}
  65. {$setc __LP64__ := 0}
  66. {$endc}
  67. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  68. {$error Conflicting definitions for __ppc__ and __i386__}
  69. {$endc}
  70. {$ifc defined __ppc__ and __ppc__}
  71. {$setc TARGET_CPU_PPC := TRUE}
  72. {$setc TARGET_CPU_PPC64 := FALSE}
  73. {$setc TARGET_CPU_X86 := FALSE}
  74. {$setc TARGET_CPU_X86_64 := FALSE}
  75. {$setc TARGET_CPU_ARM := FALSE}
  76. {$setc TARGET_CPU_ARM64 := FALSE}
  77. {$setc TARGET_OS_MAC := TRUE}
  78. {$setc TARGET_OS_IPHONE := FALSE}
  79. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  80. {$setc TARGET_OS_EMBEDDED := FALSE}
  81. {$elifc defined __ppc64__ and __ppc64__}
  82. {$setc TARGET_CPU_PPC := FALSE}
  83. {$setc TARGET_CPU_PPC64 := TRUE}
  84. {$setc TARGET_CPU_X86 := FALSE}
  85. {$setc TARGET_CPU_X86_64 := FALSE}
  86. {$setc TARGET_CPU_ARM := FALSE}
  87. {$setc TARGET_CPU_ARM64 := FALSE}
  88. {$setc TARGET_OS_MAC := TRUE}
  89. {$setc TARGET_OS_IPHONE := FALSE}
  90. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  91. {$setc TARGET_OS_EMBEDDED := FALSE}
  92. {$elifc defined __i386__ and __i386__}
  93. {$setc TARGET_CPU_PPC := FALSE}
  94. {$setc TARGET_CPU_PPC64 := FALSE}
  95. {$setc TARGET_CPU_X86 := TRUE}
  96. {$setc TARGET_CPU_X86_64 := FALSE}
  97. {$setc TARGET_CPU_ARM := FALSE}
  98. {$setc TARGET_CPU_ARM64 := FALSE}
  99. {$ifc defined iphonesim}
  100. {$setc TARGET_OS_MAC := FALSE}
  101. {$setc TARGET_OS_IPHONE := TRUE}
  102. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  103. {$elsec}
  104. {$setc TARGET_OS_MAC := TRUE}
  105. {$setc TARGET_OS_IPHONE := FALSE}
  106. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  107. {$endc}
  108. {$setc TARGET_OS_EMBEDDED := FALSE}
  109. {$elifc defined __x86_64__ and __x86_64__}
  110. {$setc TARGET_CPU_PPC := FALSE}
  111. {$setc TARGET_CPU_PPC64 := FALSE}
  112. {$setc TARGET_CPU_X86 := FALSE}
  113. {$setc TARGET_CPU_X86_64 := TRUE}
  114. {$setc TARGET_CPU_ARM := FALSE}
  115. {$setc TARGET_CPU_ARM64 := FALSE}
  116. {$ifc defined iphonesim}
  117. {$setc TARGET_OS_MAC := FALSE}
  118. {$setc TARGET_OS_IPHONE := TRUE}
  119. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  120. {$elsec}
  121. {$setc TARGET_OS_MAC := TRUE}
  122. {$setc TARGET_OS_IPHONE := FALSE}
  123. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  124. {$endc}
  125. {$setc TARGET_OS_EMBEDDED := FALSE}
  126. {$elifc defined __arm__ and __arm__}
  127. {$setc TARGET_CPU_PPC := FALSE}
  128. {$setc TARGET_CPU_PPC64 := FALSE}
  129. {$setc TARGET_CPU_X86 := FALSE}
  130. {$setc TARGET_CPU_X86_64 := FALSE}
  131. {$setc TARGET_CPU_ARM := TRUE}
  132. {$setc TARGET_CPU_ARM64 := FALSE}
  133. {$setc TARGET_OS_MAC := FALSE}
  134. {$setc TARGET_OS_IPHONE := TRUE}
  135. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  136. {$setc TARGET_OS_EMBEDDED := TRUE}
  137. {$elifc defined __arm64__ and __arm64__}
  138. {$setc TARGET_CPU_PPC := FALSE}
  139. {$setc TARGET_CPU_PPC64 := FALSE}
  140. {$setc TARGET_CPU_X86 := FALSE}
  141. {$setc TARGET_CPU_X86_64 := FALSE}
  142. {$setc TARGET_CPU_ARM := FALSE}
  143. {$setc TARGET_CPU_ARM64 := TRUE}
  144. {$ifc defined ios}
  145. {$setc TARGET_OS_MAC := FALSE}
  146. {$setc TARGET_OS_IPHONE := TRUE}
  147. {$setc TARGET_OS_EMBEDDED := TRUE}
  148. {$elsec}
  149. {$setc TARGET_OS_MAC := TRUE}
  150. {$setc TARGET_OS_IPHONE := FALSE}
  151. {$setc TARGET_OS_EMBEDDED := FALSE}
  152. {$endc}
  153. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  154. {$elsec}
  155. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
  156. {$endc}
  157. {$ifc defined __LP64__ and __LP64__ }
  158. {$setc TARGET_CPU_64 := TRUE}
  159. {$elsec}
  160. {$setc TARGET_CPU_64 := FALSE}
  161. {$endc}
  162. {$ifc defined FPC_BIG_ENDIAN}
  163. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  164. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  165. {$elifc defined FPC_LITTLE_ENDIAN}
  166. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  167. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  168. {$elsec}
  169. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  170. {$endc}
  171. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  172. {$setc CALL_NOT_IN_CARBON := FALSE}
  173. {$setc OLDROUTINENAMES := FALSE}
  174. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  175. {$setc OPAQUE_UPP_TYPES := TRUE}
  176. {$setc OTCARBONAPPLICATION := TRUE}
  177. {$setc OTKERNEL := FALSE}
  178. {$setc PM_USE_SESSION_APIS := TRUE}
  179. {$setc TARGET_API_MAC_CARBON := TRUE}
  180. {$setc TARGET_API_MAC_OS8 := FALSE}
  181. {$setc TARGET_API_MAC_OSX := TRUE}
  182. {$setc TARGET_CARBON := TRUE}
  183. {$setc TARGET_CPU_68K := FALSE}
  184. {$setc TARGET_CPU_MIPS := FALSE}
  185. {$setc TARGET_CPU_SPARC := FALSE}
  186. {$setc TARGET_OS_UNIX := FALSE}
  187. {$setc TARGET_OS_WIN32 := FALSE}
  188. {$setc TARGET_RT_MAC_68881 := FALSE}
  189. {$setc TARGET_RT_MAC_CFM := FALSE}
  190. {$setc TARGET_RT_MAC_MACHO := TRUE}
  191. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  192. {$setc TYPE_BOOL := FALSE}
  193. {$setc TYPE_EXTENDED := FALSE}
  194. {$setc TYPE_LONGLONG := TRUE}
  195. uses MacTypes,CFBase;
  196. {$endc} {not MACOSALLINCLUDE}
  197. {$ifc TARGET_OS_MAC}
  198. {$ALIGN POWER}
  199. { HandToHand and other memory utilties were moved to MacMemory.h }
  200. { Date and Time utilties were moved to DateTimeUtils.h }
  201. {$ALIGN MAC68K}
  202. const
  203. { result types for RelString Call }
  204. sortsBefore = -1; {first string < second string}
  205. sortsEqual = 0; {first string = second string}
  206. sortsAfter = 1; {first string > second string}
  207. const
  208. dummyType = 0;
  209. vType = 1;
  210. ioQType = 2;
  211. drvQType = 3;
  212. evType = 4;
  213. fsQType = 5;
  214. sIQType = 6;
  215. dtQType = 7;
  216. nmType = 8;
  217. type
  218. QTypes = SignedByte;
  219. QElemPtr = ^QElem;
  220. QElem = record
  221. qLink: QElemPtr;
  222. qType: SInt16;
  223. qData: array [0..0] of SInt16;
  224. end;
  225. type
  226. QHdr = record
  227. qFlags: {volatile} SInt16;
  228. qHead: {volatile} QElemPtr;
  229. qTail: {volatile} QElemPtr;
  230. end;
  231. QHdrPtr = ^QHdr;
  232. {
  233. In order for MachineLocation to be endian-safe, a new member
  234. has been added to the 'u' union in the structure. You are
  235. encouraged to use the new member instead of the old one.
  236. If your code looked like this:
  237. MachineLocation.u.dlsDelta = isDLS? 0x80: 0x00;
  238. you should change it to this:
  239. MachineLocation.u.dls.Delta = isDLS? 0x80: 0x00;
  240. to be endian safe. The gmtDelta remains the same; the low 24-bits
  241. are used. Remember that order of assignment DOES matter:
  242. This will overwrite results:
  243. MachineLocation.u.dls.Delta = 0xAA; // u = 0xAAGGGGGG; G=Garbage
  244. MachineLocation.u.gmtDelta = 0xBBBBBB; // u = 0x00BBBBBB;
  245. when in fact reversing the assignment would have preserved the values:
  246. MachineLocation.u.gmtDelta = 0xBBBBBB; // u = 0x00BBBBBB;
  247. MachineLocation.u.dls.Delta = 0xAA; // u = 0xAABBBBBB;
  248. NOTE: The information regarding dlsDelta in Inside Mac is INCORRECT.
  249. It's always 0x80 for daylight-saving time or 0x00 for standard time.
  250. }
  251. type
  252. MachineLocationPtr = ^MachineLocation;
  253. MachineLocation = packed record
  254. latitude: Fract;
  255. longitude: Fract;
  256. case SInt16 of
  257. {$ifc TARGET_RT_BIG_ENDIAN}
  258. 0: (
  259. dlsDelta: SInt8; { signed byte; daylight savings delta }
  260. );
  261. {$endc}
  262. 1: (
  263. gmtDelta: SIGNEDLONG; { use low 24-bits only }
  264. );
  265. 2: (
  266. {$ifc TARGET_RT_LITTLE_ENDIAN}
  267. pad0,pad1,pad2: SInt8;
  268. {$endc}
  269. Delta: SInt8;
  270. );
  271. end;
  272. {
  273. * IsMetric() *** DEPRECATED ***
  274. *
  275. * Deprecated:
  276. * Use CFLocaleGetValue() and the property kCFLocaleUsesMetricSystem
  277. * to determine this value.
  278. *
  279. * Summary:
  280. * Verifies whether the current script system is using the metric
  281. * system or the English system of measurement.
  282. *
  283. * Discussion:
  284. * The IsMetric function examines the metricSys field of the
  285. * numeric-format resource (resource type 'itl0') to determine if
  286. * the current script is using the metric system. A value of 255 in
  287. * the metricSys field indicates that the metric system
  288. * (centimeters, kilometers, milligrams, degrees Celsius, and so on)
  289. * is being used. A value of 0 in the metricSys field indicates that
  290. * the English system of measurement (inches, miles, ounces, degrees
  291. * Fahrenheit, and so on) is used.
  292. * If you want to use units of measurement different from that of
  293. * the current script, you need to override the value of the
  294. * metricSys field in the current numeric-format resource. You can
  295. * do this by using your own version of the numeric-format resource
  296. * instead of the current script systemÕs default international
  297. * resource.
  298. * The IsMetric function is the same as the IUMetric function, which
  299. * was previously available with the International Utilities Package.
  300. *
  301. * Mac OS X threading:
  302. * Not thread safe
  303. *
  304. * Result:
  305. * TRUE if the metric system is being used; FALSE if the English
  306. * system is being used.
  307. *
  308. * Availability:
  309. * Mac OS X: in version 10.0 and later in CoreServices.framework but deprecated in 10.7
  310. * CarbonLib: in CarbonLib 1.0 and later
  311. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  312. }
  313. function IsMetric: Boolean; external name '_IsMetric';
  314. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_7, __IPHONE_NA, __IPHONE_NA) *)
  315. {
  316. * Delay()
  317. *
  318. * Summary:
  319. * Delays execture for the specified amount of time.
  320. *
  321. * Mac OS X threading:
  322. * Thread safe
  323. *
  324. * Parameters:
  325. *
  326. * numTicks:
  327. * the number of ticks to delay for
  328. *
  329. * finalTicks:
  330. * on return, if not NULL, will contain the value of TickCount()
  331. * at the end of the delay period
  332. *
  333. * Availability:
  334. * Mac OS X: in version 10.0 and later in CoreServices.framework
  335. * CarbonLib: in CarbonLib 1.0 and later
  336. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  337. }
  338. procedure Delay( numTicks: UNSIGNEDLONG; var finalTicks: UNSIGNEDLONG ); external name '_Delay';
  339. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  340. {
  341. * Enqueue()
  342. *
  343. * Summary:
  344. * Atomically adds a queue element to the given queue
  345. *
  346. * Discussion:
  347. * A queue ( represented by a QHdrPtr ) is a singly linked list of
  348. * elements. Enqueue inserts the given element into the queue in a
  349. * multi-thread safe way. If the element is already in the queue,
  350. * or in some other queue, the data structures will be corrupted and
  351. * will likely cause a crash or infinite loop.
  352. *
  353. * Mac OS X threading:
  354. * Thread safe
  355. *
  356. * Parameters:
  357. *
  358. * qElement:
  359. * a pointer to the element to be inserted
  360. *
  361. * qHeader:
  362. * a pointer to the queue header.
  363. *
  364. * Availability:
  365. * Mac OS X: in version 10.0 and later in CoreServices.framework
  366. * CarbonLib: in CarbonLib 1.0 and later
  367. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  368. }
  369. procedure Enqueue( qElement: QElemPtr; qHeader: QHdrPtr ); external name '_Enqueue';
  370. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  371. {
  372. * Dequeue()
  373. *
  374. * Summary:
  375. * Atomically removes a queue element from the given queue
  376. *
  377. * Discussion:
  378. * A queue ( represented by a QHdrPtr ) is a singly linked list of
  379. * elements. Dequeue removes the given element from the queue in a
  380. * multi-thread safe way. If the element is not in the queue, qErr
  381. * is returned.
  382. *
  383. * Mac OS X threading:
  384. * Thread safe
  385. *
  386. * Parameters:
  387. *
  388. * qElement:
  389. * a pointer to the element to be removed
  390. *
  391. * qHeader:
  392. * a pointer to the queue header.
  393. *
  394. * Availability:
  395. * Mac OS X: in version 10.0 and later in CoreServices.framework
  396. * CarbonLib: in CarbonLib 1.0 and later
  397. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  398. }
  399. function Dequeue( qElement: QElemPtr; qHeader: QHdrPtr ): OSErr; external name '_Dequeue';
  400. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  401. {$ifc not TARGET_CPU_64}
  402. {
  403. * MakeDataExecutable()
  404. *
  405. * Summary:
  406. * Notifies the system that the specified data is subject to
  407. * execution.
  408. *
  409. * Discussion:
  410. * On some computer architectures it is necessary to tell the
  411. * processor that an area of memory should be made executable. This
  412. * function does the necessary operations ( if possible ) to make it
  413. * possible to execute code in the given address range.
  414. * MakeDataExecutable is not supported for 64-bit applications. Use
  415. * sys_icache_invalidate(3) and/or mprotect(2) as appropriate.
  416. *
  417. * Mac OS X threading:
  418. * Thread safe
  419. *
  420. * Parameters:
  421. *
  422. * baseAddress:
  423. * the starting address to be made executable
  424. *
  425. * length:
  426. * the length of the data pointed to by the baseAddress parameter.
  427. *
  428. * Availability:
  429. * Mac OS X: in version 10.0 and later in CoreServices.framework [32-bit only]
  430. * CarbonLib: in CarbonLib 1.0 and later
  431. * Non-Carbon CFM: in InterfaceLib 7.5 and later
  432. }
  433. procedure MakeDataExecutable( baseAddress: UnivPtr; length: UNSIGNEDLONG ); external name '_MakeDataExecutable';
  434. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  435. {$endc} {not TARGET_CPU_64}
  436. {
  437. * ReadLocation()
  438. *
  439. * Summary:
  440. * Obtains information about a geographic location or time zone.
  441. *
  442. * Discussion:
  443. * The latitude and longitude are stored as Fract values, giving
  444. * accuracy to within one foot. For example, a Fract value of 1.0
  445. * equals 90 degrees Ð1.0 equals Ð90 degrees and Ð2.0 equals Ð180
  446. * degrees.
  447. * To convert these values to a degrees format, you need to convert
  448. * the Fract values first to the Fixed data type, then to the
  449. * LongInt data type. Use the Mathematical and Logical Utilities
  450. * functions Fract2Fix and Fix2Long to accomplish this task.
  451. * The DST value is a signed byte value that specifies the offset
  452. * for the hour fieldÑwhether to add one hour, subtract one hour, or
  453. * make no change at all.
  454. * The GMT value is in seconds east of GMT. For example, San
  455. * Francisco is at Ð28,800 seconds (8 hours * 3,600 seconds per
  456. * hour) east of GMT. The gmtDelta field is a 3-byte value contained
  457. * in a long word, so you must take care to get it properly.
  458. * For more information on the Fract data type and the conversion
  459. * routines Long2Fix, Fix2Fract, Fract2Fix, and Fix2Long, see
  460. * Mathematical and Logical Utilities.
  461. *
  462. * Mac OS X threading:
  463. * Not thread safe
  464. *
  465. * Parameters:
  466. *
  467. * loc:
  468. * On return, the fields of the geographic location structure
  469. * containing the geographic location and the time-zone
  470. * information.
  471. * You can get values for the latitude, longitude, daylight
  472. * savings time (DST), or Greenwich mean time (GMT). If the
  473. * geographic location record has never been set, all fields
  474. * contain 0.
  475. *
  476. * Availability:
  477. * Mac OS X: in version 10.0 and later in CoreServices.framework
  478. * CarbonLib: in CarbonLib 1.0 and later
  479. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  480. }
  481. procedure ReadLocation( var loc: MachineLocation ); external name '_ReadLocation';
  482. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  483. {
  484. * TickCount()
  485. *
  486. * Summary:
  487. * Obtains the current number of ticks (a tick is approximately 1/60
  488. * of a second) approximately since the system last started up.
  489. *
  490. * Discussion:
  491. * The TickCount function returns an unsigned 32-bit integer that
  492. * indicates the current number of ticks since the system last
  493. * started up. You can use this value to compare the number of ticks
  494. * that have elapsed since a given event or other action occurred.
  495. * For example, you could compare the current value returned by
  496. * TickCount with the value of the when field of an event
  497. * structure.
  498. * The tick count rolls over in approximately 2 years 3 months,
  499. * which means you should not use this to time intervals which may
  500. * exceed ( or even approach ) this interval.
  501. * Do not rely on the tick count being exact; it is usually accurate
  502. * to within one tick, but this level of accuracy is not guaranteed.
  503. *
  504. * Mac OS X threading:
  505. * Thread safe
  506. *
  507. * Result:
  508. * the tick count
  509. *
  510. * Availability:
  511. * Mac OS X: in version 10.0 and later in CoreServices.framework
  512. * CarbonLib: in CarbonLib 1.0 and later
  513. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  514. }
  515. function TickCount: UInt32; external name '_TickCount';
  516. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  517. {
  518. * CSCopyUserName()
  519. *
  520. * Summary:
  521. * Returns a reference to the CFString that represents the user name.
  522. *
  523. * Mac OS X threading:
  524. * Thread safe
  525. *
  526. * Parameters:
  527. *
  528. * useShortName:
  529. * A Boolean value that specifies whether to return the short name
  530. * or full name of the user.
  531. *
  532. * Result:
  533. * the requested name in a CFStringRef. You should release this
  534. * when you are done with it.
  535. *
  536. * Availability:
  537. * Mac OS X: in version 10.0 and later in CoreServices.framework
  538. * CarbonLib: in CarbonLib 1.5 and later
  539. * Non-Carbon CFM: not available
  540. }
  541. function CSCopyUserName( useShortName: Boolean ): CFStringRef; external name '_CSCopyUserName';
  542. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  543. {
  544. * CSCopyMachineName()
  545. *
  546. * Summary:
  547. * Returns a reference to the CFString that represents the computer
  548. * name.
  549. *
  550. * Mac OS X threading:
  551. * Thread safe
  552. *
  553. * Result:
  554. * the name of this machine in a CFStringRef. You should release
  555. * this when you are done with it.
  556. *
  557. * Availability:
  558. * Mac OS X: in version 10.0 and later in CoreServices.framework
  559. * CarbonLib: in CarbonLib 1.5 and later
  560. * Non-Carbon CFM: not available
  561. }
  562. function CSCopyMachineName: CFStringRef; external name '_CSCopyMachineName';
  563. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  564. const
  565. useFree = 0;
  566. useATalk = 1;
  567. useAsync = 2;
  568. useExtClk = 3; {Externally clocked}
  569. useMIDI = 4;
  570. const
  571. false32b = 0; {24 bit addressing error}
  572. true32b = 1; {32 bit addressing error}
  573. type
  574. SysPPtr = UnivPtr;
  575. function GetMMUMode: SInt8; inline;
  576. procedure SwapMMUMode( var mode: SInt8 ); inline;
  577. {$ifc not TARGET_CPU_64}
  578. {
  579. * GetSysPPtr() *** DEPRECATED ***
  580. *
  581. * Deprecated:
  582. * Don't use this function; it always returns NULL on Mac OS X.
  583. *
  584. * Availability:
  585. * Mac OS X: in version 10.0 and later in CoreServices.framework [32-bit only] but deprecated in 10.4
  586. * CarbonLib: in CarbonLib 1.0 and later
  587. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  588. }
  589. function GetSysPPtr: SysPPtr; external name '_GetSysPPtr';
  590. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_4, __IPHONE_NA, __IPHONE_NA) *)
  591. {
  592. NOTE: SysBeep() has been moved to Sound.h.
  593. We could not automatically #include Sound.h in this file
  594. because Sound.h indirectly #include's OSUtils.h which
  595. would make a circular include.
  596. }
  597. {$endc} {not TARGET_CPU_64}
  598. type
  599. DeferredTaskProcPtr = procedure( dtParam: SIGNEDLONG );
  600. DeferredTaskUPP = DeferredTaskProcPtr;
  601. {
  602. * NewDeferredTaskUPP()
  603. *
  604. * Availability:
  605. * Mac OS X: in version 10.0 and later in CoreServices.framework
  606. * CarbonLib: in CarbonLib 1.0 and later
  607. * Non-Carbon CFM: available as macro/inline
  608. }
  609. function NewDeferredTaskUPP( userRoutine: DeferredTaskProcPtr ): DeferredTaskUPP; external name '_NewDeferredTaskUPP';
  610. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  611. {
  612. * DisposeDeferredTaskUPP()
  613. *
  614. * Availability:
  615. * Mac OS X: in version 10.0 and later in CoreServices.framework
  616. * CarbonLib: in CarbonLib 1.0 and later
  617. * Non-Carbon CFM: available as macro/inline
  618. }
  619. procedure DisposeDeferredTaskUPP( userUPP: DeferredTaskUPP ); external name '_DisposeDeferredTaskUPP';
  620. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  621. {
  622. * InvokeDeferredTaskUPP()
  623. *
  624. * Availability:
  625. * Mac OS X: in version 10.0 and later in CoreServices.framework
  626. * CarbonLib: in CarbonLib 1.0 and later
  627. * Non-Carbon CFM: available as macro/inline
  628. }
  629. procedure InvokeDeferredTaskUPP( dtParam: SIGNEDLONG; userUPP: DeferredTaskUPP ); external name '_InvokeDeferredTaskUPP';
  630. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  631. type
  632. DeferredTask = record
  633. qLink: {volatile} QElemPtr;
  634. qType: SInt16;
  635. dtFlags: {volatile} SInt16;
  636. dtAddr: DeferredTaskUPP;
  637. dtParam: SIGNEDLONG;
  638. dtReserved: SIGNEDLONG;
  639. end;
  640. DeferredTaskPtr = ^DeferredTask;
  641. {$ifc not TARGET_CPU_64}
  642. {
  643. * DTInstall() *** DEPRECATED ***
  644. *
  645. * Deprecated:
  646. * The Deferred Task Manager is deprecated. Look into restructuring
  647. * your code to use threads, or MPTasks, or some other threading
  648. * solution.
  649. *
  650. * Summary:
  651. * Adds the specified task record to the deferred-task queue.
  652. *
  653. * Mac OS X threading:
  654. * Thread safe
  655. *
  656. * Availability:
  657. * Mac OS X: in version 10.0 and later in CoreServices.framework [32-bit only] but deprecated in 10.4
  658. * CarbonLib: in CarbonLib 1.0 and later
  659. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  660. }
  661. function DTInstall( dtTaskPtr: DeferredTaskPtr ): OSErr; external name '_DTInstall';
  662. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_4, __IPHONE_NA, __IPHONE_NA) *)
  663. {
  664. * DTUninstall() *** DEPRECATED ***
  665. *
  666. * Deprecated:
  667. * The Deferred Task Manager is deprecated. Look into restructuring
  668. * your code to use threads, or MPTasks, or some other threading
  669. * solution.
  670. *
  671. * Summary:
  672. * Adds the specified task record to the deferred-task queue.
  673. *
  674. * Mac OS X threading:
  675. * Thread safe
  676. *
  677. * Availability:
  678. * Mac OS X: in version 10.0 and later in CoreServices.framework [32-bit only] but deprecated in 10.4
  679. * CarbonLib: not available
  680. * Non-Carbon CFM: not available
  681. }
  682. function DTUninstall( dtTaskPtr: DeferredTaskPtr ): OSErr; external name '_DTUninstall';
  683. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_4, __IPHONE_NA, __IPHONE_NA) *)
  684. {
  685. * SetCurrentA5() *** DEPRECATED ***
  686. *
  687. * Deprecated:
  688. * You no longer need to use SetCurrentA5() on Mac OS X.
  689. *
  690. * Mac OS X threading:
  691. * Thread safe
  692. *
  693. * Availability:
  694. * Mac OS X: in version 10.0 and later in CoreServices.framework [32-bit only] but deprecated in 10.4
  695. * CarbonLib: in CarbonLib 1.0 and later
  696. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  697. }
  698. function SetCurrentA5: SIGNEDLONG; external name '_SetCurrentA5';
  699. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_4, __IPHONE_NA, __IPHONE_NA) *)
  700. {
  701. * SetA5() *** DEPRECATED ***
  702. *
  703. * Deprecated:
  704. * You no longer need to use SetA5() on Mac OS X.
  705. *
  706. * Mac OS X threading:
  707. * Thread safe
  708. *
  709. * Availability:
  710. * Mac OS X: in version 10.0 and later in CoreServices.framework [32-bit only] but deprecated in 10.4
  711. * CarbonLib: in CarbonLib 1.0 and later
  712. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  713. }
  714. function SetA5( newA5: SIGNEDLONG ): SIGNEDLONG; external name '_SetA5';
  715. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_4, __IPHONE_NA, __IPHONE_NA) *)
  716. {
  717. * InitUtil() *** DEPRECATED ***
  718. *
  719. * Deprecated:
  720. * It is not necessary to call InitUtil on Mac OS X. You should
  721. * remove all calls to this from your code.
  722. *
  723. * Mac OS X threading:
  724. * Thread safe
  725. *
  726. * Availability:
  727. * Mac OS X: in version 10.0 and later in CoreServices.framework [32-bit only] but deprecated in 10.3
  728. * CarbonLib: in CarbonLib 1.0 and later
  729. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  730. }
  731. function InitUtil: OSErr; external name '_InitUtil';
  732. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_3, __IPHONE_NA, __IPHONE_NA) *)
  733. {
  734. * WriteParam() *** DEPRECATED ***
  735. *
  736. * Deprecated:
  737. * This function no longer does anything on Mac OS X; you should
  738. * remove all calls to it from your code.
  739. *
  740. * Mac OS X threading:
  741. * Not thread safe
  742. *
  743. * Availability:
  744. * Mac OS X: in version 10.0 and later in CoreServices.framework [32-bit only] but deprecated in 10.4
  745. * CarbonLib: in CarbonLib 1.0 and later
  746. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  747. }
  748. function WriteParam: OSErr; external name '_WriteParam';
  749. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_4, __IPHONE_NA, __IPHONE_NA) *)
  750. {
  751. * WriteLocation() *** DEPRECATED ***
  752. *
  753. * Deprecated:
  754. * WriteLocation can not be used to set the geographic information
  755. * on Mac OS X. You should remove all calls to this function from
  756. * your code.
  757. *
  758. * Mac OS X threading:
  759. * Not thread safe
  760. *
  761. * Availability:
  762. * Mac OS X: in version 10.0 and later in CoreServices.framework [32-bit only] but deprecated in 10.0
  763. * CarbonLib: in CarbonLib 1.0 and later
  764. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  765. }
  766. procedure WriteLocation( const (*var*) loc: MachineLocation ); external name '_WriteLocation';
  767. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_1, __IPHONE_NA, __IPHONE_NA) *)
  768. {$endc} {not TARGET_CPU_64}
  769. {$endc} {TARGET_OS_MAC}
  770. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  771. implementation
  772. {$ifc TARGET_OS_MAC}
  773. {$R-}
  774. function GetMMUMode: SInt8; inline;
  775. begin
  776. GetMMUMode:= true32b
  777. end;
  778. procedure SwapMMUMode( var mode: SInt8 ); inline;
  779. begin
  780. mode := true32b;
  781. end;
  782. {$endc} {TARGET_OS_MAC}
  783. end.
  784. {$endc} {not MACOSALLINCLUDE}