MacOSXPosix.pas 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. {
  2. Copyright (c) 2000-2003, Apple, Inc. All rights reserved.
  3. }
  4. { Pascal Translation: Peter N Lewis, <[email protected]>, 2004 }
  5. {
  6. Modified for use with Free Pascal
  7. Version 308
  8. Please report any bugs to <[email protected]>
  9. }
  10. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  11. {$mode macpas}
  12. {$modeswitch cblocks}
  13. {$packenum 1}
  14. {$macro on}
  15. {$inline on}
  16. {$calling mwpascal}
  17. unit MacOSXPosix;
  18. interface
  19. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  20. {$setc GAP_INTERFACES_VERSION := $0308}
  21. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  22. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  23. {$endc}
  24. {$ifc defined CPUPOWERPC and defined CPUI386}
  25. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  26. {$endc}
  27. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  28. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  29. {$endc}
  30. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  31. {$setc __ppc__ := 1}
  32. {$elsec}
  33. {$setc __ppc__ := 0}
  34. {$endc}
  35. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  36. {$setc __ppc64__ := 1}
  37. {$elsec}
  38. {$setc __ppc64__ := 0}
  39. {$endc}
  40. {$ifc not defined __i386__ and defined CPUI386}
  41. {$setc __i386__ := 1}
  42. {$elsec}
  43. {$setc __i386__ := 0}
  44. {$endc}
  45. {$ifc not defined __x86_64__ and defined CPUX86_64}
  46. {$setc __x86_64__ := 1}
  47. {$elsec}
  48. {$setc __x86_64__ := 0}
  49. {$endc}
  50. {$ifc not defined __arm__ and defined CPUARM}
  51. {$setc __arm__ := 1}
  52. {$elsec}
  53. {$setc __arm__ := 0}
  54. {$endc}
  55. {$ifc not defined __arm64__ and defined CPUAARCH64}
  56. {$setc __arm64__ := 1}
  57. {$elsec}
  58. {$setc __arm64__ := 0}
  59. {$endc}
  60. {$ifc defined cpu64}
  61. {$setc __LP64__ := 1}
  62. {$elsec}
  63. {$setc __LP64__ := 0}
  64. {$endc}
  65. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  66. {$error Conflicting definitions for __ppc__ and __i386__}
  67. {$endc}
  68. {$ifc defined __ppc__ and __ppc__}
  69. {$setc TARGET_CPU_PPC := TRUE}
  70. {$setc TARGET_CPU_PPC64 := FALSE}
  71. {$setc TARGET_CPU_X86 := FALSE}
  72. {$setc TARGET_CPU_X86_64 := FALSE}
  73. {$setc TARGET_CPU_ARM := FALSE}
  74. {$setc TARGET_CPU_ARM64 := FALSE}
  75. {$setc TARGET_OS_MAC := TRUE}
  76. {$setc TARGET_OS_IPHONE := FALSE}
  77. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  78. {$setc TARGET_OS_EMBEDDED := FALSE}
  79. {$elifc defined __ppc64__ and __ppc64__}
  80. {$setc TARGET_CPU_PPC := FALSE}
  81. {$setc TARGET_CPU_PPC64 := TRUE}
  82. {$setc TARGET_CPU_X86 := FALSE}
  83. {$setc TARGET_CPU_X86_64 := FALSE}
  84. {$setc TARGET_CPU_ARM := FALSE}
  85. {$setc TARGET_CPU_ARM64 := FALSE}
  86. {$setc TARGET_OS_MAC := TRUE}
  87. {$setc TARGET_OS_IPHONE := FALSE}
  88. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  89. {$setc TARGET_OS_EMBEDDED := FALSE}
  90. {$elifc defined __i386__ and __i386__}
  91. {$setc TARGET_CPU_PPC := FALSE}
  92. {$setc TARGET_CPU_PPC64 := FALSE}
  93. {$setc TARGET_CPU_X86 := TRUE}
  94. {$setc TARGET_CPU_X86_64 := FALSE}
  95. {$setc TARGET_CPU_ARM := FALSE}
  96. {$setc TARGET_CPU_ARM64 := FALSE}
  97. {$ifc defined(iphonesim)}
  98. {$setc TARGET_OS_MAC := FALSE}
  99. {$setc TARGET_OS_IPHONE := TRUE}
  100. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  101. {$elsec}
  102. {$setc TARGET_OS_MAC := TRUE}
  103. {$setc TARGET_OS_IPHONE := FALSE}
  104. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  105. {$endc}
  106. {$setc TARGET_OS_EMBEDDED := FALSE}
  107. {$elifc defined __x86_64__ and __x86_64__}
  108. {$setc TARGET_CPU_PPC := FALSE}
  109. {$setc TARGET_CPU_PPC64 := FALSE}
  110. {$setc TARGET_CPU_X86 := FALSE}
  111. {$setc TARGET_CPU_X86_64 := TRUE}
  112. {$setc TARGET_CPU_ARM := FALSE}
  113. {$setc TARGET_CPU_ARM64 := FALSE}
  114. {$ifc defined(iphonesim)}
  115. {$setc TARGET_OS_MAC := FALSE}
  116. {$setc TARGET_OS_IPHONE := TRUE}
  117. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  118. {$elsec}
  119. {$setc TARGET_OS_MAC := TRUE}
  120. {$setc TARGET_OS_IPHONE := FALSE}
  121. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  122. {$endc}
  123. {$setc TARGET_OS_EMBEDDED := FALSE}
  124. {$elifc defined __arm__ and __arm__}
  125. {$setc TARGET_CPU_PPC := FALSE}
  126. {$setc TARGET_CPU_PPC64 := FALSE}
  127. {$setc TARGET_CPU_X86 := FALSE}
  128. {$setc TARGET_CPU_X86_64 := FALSE}
  129. {$setc TARGET_CPU_ARM := TRUE}
  130. {$setc TARGET_CPU_ARM64 := FALSE}
  131. { will require compiler define when/if other Apple devices with ARM cpus ship }
  132. {$setc TARGET_OS_MAC := FALSE}
  133. {$setc TARGET_OS_IPHONE := TRUE}
  134. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  135. {$setc TARGET_OS_EMBEDDED := TRUE}
  136. {$elifc defined __arm64__ and __arm64__}
  137. {$setc TARGET_CPU_PPC := FALSE}
  138. {$setc TARGET_CPU_PPC64 := FALSE}
  139. {$setc TARGET_CPU_X86 := FALSE}
  140. {$setc TARGET_CPU_X86_64 := FALSE}
  141. {$setc TARGET_CPU_ARM := FALSE}
  142. {$setc TARGET_CPU_ARM64 := TRUE}
  143. { will require compiler define when/if other Apple devices with ARM cpus ship }
  144. {$setc TARGET_OS_MAC := FALSE}
  145. {$setc TARGET_OS_IPHONE := TRUE}
  146. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  147. {$setc TARGET_OS_EMBEDDED := TRUE}
  148. {$elsec}
  149. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
  150. {$endc}
  151. {$ifc defined __LP64__ and __LP64__ }
  152. {$setc TARGET_CPU_64 := TRUE}
  153. {$elsec}
  154. {$setc TARGET_CPU_64 := FALSE}
  155. {$endc}
  156. {$ifc defined FPC_BIG_ENDIAN}
  157. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  158. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  159. {$elifc defined FPC_LITTLE_ENDIAN}
  160. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  161. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  162. {$elsec}
  163. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  164. {$endc}
  165. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  166. {$setc CALL_NOT_IN_CARBON := FALSE}
  167. {$setc OLDROUTINENAMES := FALSE}
  168. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  169. {$setc OPAQUE_UPP_TYPES := TRUE}
  170. {$setc OTCARBONAPPLICATION := TRUE}
  171. {$setc OTKERNEL := FALSE}
  172. {$setc PM_USE_SESSION_APIS := TRUE}
  173. {$setc TARGET_API_MAC_CARBON := TRUE}
  174. {$setc TARGET_API_MAC_OS8 := FALSE}
  175. {$setc TARGET_API_MAC_OSX := TRUE}
  176. {$setc TARGET_CARBON := TRUE}
  177. {$setc TARGET_CPU_68K := FALSE}
  178. {$setc TARGET_CPU_MIPS := FALSE}
  179. {$setc TARGET_CPU_SPARC := FALSE}
  180. {$setc TARGET_OS_UNIX := FALSE}
  181. {$setc TARGET_OS_WIN32 := FALSE}
  182. {$setc TARGET_RT_MAC_68881 := FALSE}
  183. {$setc TARGET_RT_MAC_CFM := FALSE}
  184. {$setc TARGET_RT_MAC_MACHO := TRUE}
  185. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  186. {$setc TYPE_BOOL := FALSE}
  187. {$setc TYPE_EXTENDED := FALSE}
  188. {$setc TYPE_LONGLONG := TRUE}
  189. uses MacTypes;
  190. {$endc} {not MACOSALLINCLUDE}
  191. {$ALIGN MAC68K}
  192. type
  193. { sys/types }
  194. u_quad_t = UInt64; { quads }
  195. quad_t = SInt64;
  196. qaddr_t = ^quad_t;
  197. caddr_t = Ptr; { core address }
  198. daddr_t = SInt32; { disk address }
  199. dev_t = UInt32; { device number }
  200. fixpt_t = UInt32; { fixed point number }
  201. gid_t = UInt32; { group id }
  202. gid_t_ptr = ^gid_t;
  203. in_addr_t = UInt32; { base type for internet address }
  204. in_port_t = UInt16;
  205. {$ifc TARGET_CPU_ARM}
  206. ino_t = UInt64; { inode number }
  207. {$elsec}
  208. ino_t = UInt32; { inode number }
  209. {$endc}
  210. key_t = SInt32; { IPC key (for Sys V IPC) }
  211. mode_t = UInt16; { permissions }
  212. nlink_t = UInt16; { link count }
  213. off_t = quad_t; { file offset }
  214. pid_t = SInt32; { process id }
  215. rlim_t = quad_t; { resource limit }
  216. segsz_t = SInt32; { segment size }
  217. swblk_t = SInt32; { swap offset }
  218. uid_t = UInt32; { user id }
  219. uid_t_ptr = ^uid_t;
  220. id_t = UInt32; { can hold pid_t, gid_t, or uid_t }
  221. id_t_ptr = ^id_t;
  222. useconds_t = UInt32; { microseconds (unsigned) }
  223. mach_port_name_t = UInt32; { represents a name of a port right }
  224. mach_port_t = UInt32; { reference added or deleted to a port right }
  225. mach_msg_bits_t = UInt32;
  226. natural_t = UInt32; {Êalso on 64 bit systems! }
  227. integer_t = SInt32; { also on 64 bit systems! }
  228. mach_msg_size_t = natural_t;
  229. mach_msg_id_t = integer_t;
  230. mach_msg_header_t = record
  231. msgh_bits: mach_msg_bits_t;
  232. msgh_size: mach_msg_size_t;
  233. msgh_remote_port: mach_port_t;
  234. msgh_local_port: mach_port_t;
  235. msgh_reserved: mach_msg_size_t;
  236. msgh_id: mach_msg_id_t;
  237. end;
  238. type
  239. sockaddr = packed record
  240. sin_len: UInt8;
  241. sin_family: UInt8;
  242. sa_data: packed array[0..13] of UInt8;
  243. end;
  244. sockaddr_ptr = ^sockaddr;
  245. sockaddr_in = packed record
  246. sin_len: UInt8;
  247. sin_family: UInt8;
  248. sin_port: UInt16;
  249. sin_addr: UInt32;
  250. sin_zero: packed array[0..7] of UInt8;
  251. end;
  252. sockaddr_in_ptr = ^sockaddr_in;
  253. socklen_t = UInt32;
  254. dispatch_queue_s = record
  255. end;
  256. dispatch_queue_t = ^dispatch_queue_s;
  257. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  258. end.
  259. {$endc} {not MACOSALLINCLUDE}