mach_error.pas 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. {
  2. * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
  3. *
  4. * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  5. *
  6. * This file contains Original Code and/or Modifications of Original Code
  7. * as defined in and that are subject to the Apple Public Source License
  8. * Version 2.0 (the 'License'). You may not use this file except in
  9. * compliance with the License. The rights granted to you under the License
  10. * may not be used to create, or enable the creation or redistribution of,
  11. * unlawful or unlicensed copies of an Apple operating system, or to
  12. * circumvent, violate, or enable the circumvention or violation of, any
  13. * terms of an Apple operating system software license agreement.
  14. *
  15. * Please obtain a copy of the License at
  16. * http://www.opensource.apple.com/apsl/ and read it before using this file.
  17. *
  18. * The Original Code and all software distributed under the License are
  19. * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  20. * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  21. * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  22. * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
  23. * Please see the License for the specific language governing rights and
  24. * limitations under the License.
  25. *
  26. * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
  27. }
  28. { Pascal Translation Updated: Jonas Maebe, <[email protected]>, September 2010 }
  29. {
  30. Modified for use with Free Pascal
  31. Version 308
  32. Please report any bugs to <[email protected]>
  33. }
  34. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  35. {$mode macpas}
  36. {$packenum 1}
  37. {$macro on}
  38. {$inline on}
  39. {$calling mwpascal}
  40. unit mach_error;
  41. interface
  42. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  43. {$setc GAP_INTERFACES_VERSION := $0308}
  44. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  45. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  46. {$endc}
  47. {$ifc defined CPUPOWERPC and defined CPUI386}
  48. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  49. {$endc}
  50. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  51. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  52. {$endc}
  53. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  54. {$setc __ppc__ := 1}
  55. {$elsec}
  56. {$setc __ppc__ := 0}
  57. {$endc}
  58. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  59. {$setc __ppc64__ := 1}
  60. {$elsec}
  61. {$setc __ppc64__ := 0}
  62. {$endc}
  63. {$ifc not defined __i386__ and defined CPUI386}
  64. {$setc __i386__ := 1}
  65. {$elsec}
  66. {$setc __i386__ := 0}
  67. {$endc}
  68. {$ifc not defined __x86_64__ and defined CPUX86_64}
  69. {$setc __x86_64__ := 1}
  70. {$elsec}
  71. {$setc __x86_64__ := 0}
  72. {$endc}
  73. {$ifc not defined __arm__ and defined CPUARM}
  74. {$setc __arm__ := 1}
  75. {$elsec}
  76. {$setc __arm__ := 0}
  77. {$endc}
  78. {$ifc defined cpu64}
  79. {$setc __LP64__ := 1}
  80. {$elsec}
  81. {$setc __LP64__ := 0}
  82. {$endc}
  83. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  84. {$error Conflicting definitions for __ppc__ and __i386__}
  85. {$endc}
  86. {$ifc defined __ppc__ and __ppc__}
  87. {$setc TARGET_CPU_PPC := TRUE}
  88. {$setc TARGET_CPU_PPC64 := FALSE}
  89. {$setc TARGET_CPU_X86 := FALSE}
  90. {$setc TARGET_CPU_X86_64 := FALSE}
  91. {$setc TARGET_CPU_ARM := FALSE}
  92. {$setc TARGET_OS_MAC := TRUE}
  93. {$setc TARGET_OS_IPHONE := FALSE}
  94. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  95. {$elifc defined __ppc64__ and __ppc64__}
  96. {$setc TARGET_CPU_PPC := FALSE}
  97. {$setc TARGET_CPU_PPC64 := TRUE}
  98. {$setc TARGET_CPU_X86 := FALSE}
  99. {$setc TARGET_CPU_X86_64 := FALSE}
  100. {$setc TARGET_CPU_ARM := FALSE}
  101. {$setc TARGET_OS_MAC := TRUE}
  102. {$setc TARGET_OS_IPHONE := FALSE}
  103. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  104. {$elifc defined __i386__ and __i386__}
  105. {$setc TARGET_CPU_PPC := FALSE}
  106. {$setc TARGET_CPU_PPC64 := FALSE}
  107. {$setc TARGET_CPU_X86 := TRUE}
  108. {$setc TARGET_CPU_X86_64 := FALSE}
  109. {$setc TARGET_CPU_ARM := FALSE}
  110. {$ifc defined(iphonesim)}
  111. {$setc TARGET_OS_MAC := FALSE}
  112. {$setc TARGET_OS_IPHONE := TRUE}
  113. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  114. {$elsec}
  115. {$setc TARGET_OS_MAC := TRUE}
  116. {$setc TARGET_OS_IPHONE := FALSE}
  117. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  118. {$endc}
  119. {$elifc defined __x86_64__ and __x86_64__}
  120. {$setc TARGET_CPU_PPC := FALSE}
  121. {$setc TARGET_CPU_PPC64 := FALSE}
  122. {$setc TARGET_CPU_X86 := FALSE}
  123. {$setc TARGET_CPU_X86_64 := TRUE}
  124. {$setc TARGET_CPU_ARM := FALSE}
  125. {$setc TARGET_OS_MAC := TRUE}
  126. {$setc TARGET_OS_IPHONE := FALSE}
  127. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  128. {$elifc defined __arm__ and __arm__}
  129. {$setc TARGET_CPU_PPC := FALSE}
  130. {$setc TARGET_CPU_PPC64 := FALSE}
  131. {$setc TARGET_CPU_X86 := FALSE}
  132. {$setc TARGET_CPU_X86_64 := FALSE}
  133. {$setc TARGET_CPU_ARM := TRUE}
  134. { will require compiler define when/if other Apple devices with ARM cpus ship }
  135. {$setc TARGET_OS_MAC := FALSE}
  136. {$setc TARGET_OS_IPHONE := TRUE}
  137. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  138. {$elsec}
  139. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ is defined.}
  140. {$endc}
  141. {$ifc defined __LP64__ and __LP64__ }
  142. {$setc TARGET_CPU_64 := TRUE}
  143. {$elsec}
  144. {$setc TARGET_CPU_64 := FALSE}
  145. {$endc}
  146. {$ifc defined FPC_BIG_ENDIAN}
  147. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  148. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  149. {$elifc defined FPC_LITTLE_ENDIAN}
  150. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  151. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  152. {$elsec}
  153. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  154. {$endc}
  155. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  156. {$setc CALL_NOT_IN_CARBON := FALSE}
  157. {$setc OLDROUTINENAMES := FALSE}
  158. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  159. {$setc OPAQUE_UPP_TYPES := TRUE}
  160. {$setc OTCARBONAPPLICATION := TRUE}
  161. {$setc OTKERNEL := FALSE}
  162. {$setc PM_USE_SESSION_APIS := TRUE}
  163. {$setc TARGET_API_MAC_CARBON := TRUE}
  164. {$setc TARGET_API_MAC_OS8 := FALSE}
  165. {$setc TARGET_API_MAC_OSX := TRUE}
  166. {$setc TARGET_CARBON := TRUE}
  167. {$setc TARGET_CPU_68K := FALSE}
  168. {$setc TARGET_CPU_MIPS := FALSE}
  169. {$setc TARGET_CPU_SPARC := FALSE}
  170. {$setc TARGET_OS_UNIX := FALSE}
  171. {$setc TARGET_OS_WIN32 := FALSE}
  172. {$setc TARGET_RT_MAC_68881 := FALSE}
  173. {$setc TARGET_RT_MAC_CFM := FALSE}
  174. {$setc TARGET_RT_MAC_MACHO := TRUE}
  175. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  176. {$setc TYPE_BOOL := FALSE}
  177. {$setc TYPE_EXTENDED := FALSE}
  178. {$setc TYPE_LONGLONG := TRUE}
  179. uses MacTypes,kern_return;
  180. {$endc} {not MACOSALLINCLUDE}
  181. {
  182. * @OSF_COPYRIGHT@
  183. }
  184. {
  185. * Mach Operating System
  186. * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
  187. * All Rights Reserved.
  188. *
  189. * Permission to use, copy, modify and distribute this software and its
  190. * documentation is hereby granted, provided that both the copyright
  191. * notice and this permission notice appear in all copies of the
  192. * software, derivative works or modified versions, and any portions
  193. * thereof, and that both notices appear in supporting documentation.
  194. *
  195. * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
  196. * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
  197. * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  198. *
  199. * Carnegie Mellon requests users of this software to return to
  200. *
  201. * Software Distribution Coordinator or [email protected]
  202. * School of Computer Science
  203. * Carnegie Mellon University
  204. * Pittsburgh PA 15213-3890
  205. *
  206. * any improvements or extensions that they make and grant Carnegie Mellon
  207. * the rights to redistribute these changes.
  208. }
  209. {
  210. * File: mach/error.h
  211. * Purpose:
  212. * error module definitions
  213. *
  214. }
  215. type
  216. mach_error_t = kern_return_t;
  217. mach_error_fn_t = function: mach_error_t;
  218. {
  219. * error number layout as follows:
  220. *
  221. * hi lo
  222. * | system(6) | subsystem(12) | code(14) |
  223. }
  224. const
  225. err_none = mach_error_t(0);
  226. ERR_SUCCESS = mach_error_t(0);
  227. ERR_ROUTINE_NIL = nil;
  228. system_emask = (((($3f) and $3f) shl 26));
  229. sub_emask = (((($fff) and $fff) shl 14));
  230. code_emask = $3fff;
  231. { major error systems }
  232. err_kern = ((($0) and $3f) shl 26); { kernel }
  233. err_us = ((($1) and $3f) shl 26); { user space library }
  234. err_server = ((($2) and $3f) shl 26); { user space servers }
  235. err_ipc = ((($3) and $3f) shl 26); { old ipc errors }
  236. err_mach_ipc = ((($4) and $3f) shl 26); { mach-ipc errors }
  237. err_dipc = ((($7) and $3f) shl 26); { distributed ipc }
  238. err_local = ((($3e) and $3f) shl 26); { user defined errors }
  239. err_ipc_compat = ((($3f) and $3f) shl 26); { (compatibility) mach-ipc errors }
  240. const
  241. err_max_system = $3f;
  242. function err_system(x: mach_error_t): mach_error_t; inline;
  243. function err_sub(x: mach_error_t): mach_error_t; inline;
  244. function err_get_system(err: mach_error_t): mach_error_t; inline;
  245. function err_get_sub(err: mach_error_t): mach_error_t; inline;
  246. function err_get_code(err: mach_error_t): mach_error_t; inline;
  247. { unix errors get lumped into one subsystem }
  248. function unix_err(errno: SInt32): mach_error_t; inline;
  249. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  250. implementation
  251. {$push}
  252. {$R-,Q-}
  253. function err_system(x: mach_error_t): mach_error_t; inline;
  254. begin
  255. err_system:=(((x) and $3f) shl 26)
  256. end;
  257. function err_sub(x: mach_error_t): mach_error_t; inline;
  258. begin
  259. err_sub:=(((x) shr 14) and $fff)
  260. end;
  261. function err_get_system(err: mach_error_t): mach_error_t; inline;
  262. begin
  263. err_get_system:=(((err) shr 26) and $3f)
  264. end;
  265. function err_get_sub(err: mach_error_t): mach_error_t; inline;
  266. begin
  267. err_get_sub:=(((err) shr 14) and $fff)
  268. end;
  269. function err_get_code(err: mach_error_t): mach_error_t; inline;
  270. begin
  271. err_get_code:=((err) and $3fff)
  272. end;
  273. function unix_err(errno: SInt32): mach_error_t; inline;
  274. begin
  275. unix_err:=err_kern or (((3) and $fff) shl 14) or errno;
  276. end;
  277. {$pop}
  278. end.
  279. {$endc} {not MACOSALLINCLUDE}