浏览代码

r329 | jonas | 2010-09-19 17:17:21 +0200 (Sun, 19 Sep 2010) | 3 lines

  + translation of IOSurface.framework and some IOKit and mach headers
    it depends on (for new Cocoa headers)

git-svn-id: trunk@16011 -
Jonas Maebe 15 年之前
父节点
当前提交
d628276c98

+ 4 - 0
.gitattributes

@@ -5606,6 +5606,8 @@ packages/univint/src/IBCarbonRuntime.pas svneol=native#text/plain
 packages/univint/src/ICAApplication.pas svneol=native#text/plain
 packages/univint/src/ICACamera.pas svneol=native#text/plain
 packages/univint/src/ICADevice.pas svneol=native#text/plain
+packages/univint/src/IOKitReturn.pas svneol=native#text/plain
+packages/univint/src/IOSurfaceAPI.pas svneol=native#text/plain
 packages/univint/src/IconStorage.pas svneol=native#text/plain
 packages/univint/src/Icons.pas svneol=native#text/plain
 packages/univint/src/IconsCore.pas svneol=native#text/plain
@@ -5769,9 +5771,11 @@ packages/univint/src/fp.pas svneol=native#text/plain
 packages/univint/src/gliContexts.pas svneol=native#text/plain
 packages/univint/src/gliDispatch.pas svneol=native#text/plain
 packages/univint/src/gluContext.pas svneol=native#text/plain
+packages/univint/src/kern_return.pas svneol=native#text/plain
 packages/univint/src/macgl.pas svneol=native#text/plain
 packages/univint/src/macglext.pas svneol=native#text/plain
 packages/univint/src/macglu.pas svneol=native#text/plain
+packages/univint/src/mach_error.pas svneol=native#text/plain
 packages/univint/src/vBLAS.pas svneol=native#text/plain
 packages/univint/src/vDSP.pas svneol=native#text/plain
 packages/univint/src/x509defs.pas svneol=native#text/plain

文件差异内容过多而无法显示
+ 0 - 0
packages/univint/Makefile


+ 4 - 3
packages/univint/Makefile.fpc

@@ -63,7 +63,8 @@ implicitunits=ABActions ABAddressBook ABGlobals ABPeoplePicker ABTypedefs AEData
   HITextViews HITheme HIToolbar HIToolbox HIToolboxDebugging HIView \
   HIWindowViews HTMLRendering HostTime IBCarbonRuntime ICAApplication \
   ICACamera ICADevice IconStorage Icons IconsCore ImageCodec \
-  ImageCompression InternetConfig IntlResources KeyEvents Keyboards \
+  ImageCompression InternetConfig IntlResources \
+  IOKitReturn IOSurfaceAPI KeyEvents Keyboards \
   KeychainCore KeychainHI LSInfo LSOpen LSQuarantine LSSharedFileList \
   LanguageAnalysis Lists LowMem MDExternalDatastore MDImporter MDItem \
   MDLineage MDQuery MDSchema MIDIDriver MIDIServices MIDISetup \
@@ -95,8 +96,8 @@ implicitunits=ABActions ABAddressBook ABGlobals ABPeoplePicker ABTypedefs AEData
   URLAccess UTCUtils UTCoreTypes UTType UnicodeConverter UnicodeUtilities \
   UniversalAccess Video WSMethodInvocation WSProtocolHandler WSTypes cblas \
   certextensions cssmapple cssmconfig cssmerr cssmkrapi cssmtype \
-  fenv fp gliContexts gliDispatch gluContext macgl macglext macglu vBLAS \
-  vDSP x509defs xattr 
+  fenv fp gliContexts gliDispatch gluContext kern_return macgl macglext \
+  macglu mach_error vBLAS vDSP x509defs xattr 
 exampledirs=examples
 
 [libs]

+ 317 - 0
packages/univint/src/IOKitReturn.pas

@@ -0,0 +1,317 @@
+{
+ * Copyright (c) 1998-2002 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
+ * 
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
+ }
+{       Pascal Translation Updated:  Jonas Maebe, <[email protected]>, September 2010 }
+{
+    Modified for use with Free Pascal
+    Version 308
+    Please report any bugs to <[email protected]>
+}
+
+{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
+{$mode macpas}
+{$packenum 1}
+{$macro on}
+{$inline on}
+{$calling mwpascal}
+
+unit IOKitReturn;
+interface
+{$setc UNIVERSAL_INTERFACES_VERSION := $0400}
+{$setc GAP_INTERFACES_VERSION := $0308}
+
+{$ifc not defined USE_CFSTR_CONSTANT_MACROS}
+    {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
+{$endc}
+
+{$ifc defined CPUPOWERPC and defined CPUI386}
+	{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
+{$endc}
+{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
+	{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
+{$endc}
+
+{$ifc not defined __ppc__ and defined CPUPOWERPC32}
+	{$setc __ppc__ := 1}
+{$elsec}
+	{$setc __ppc__ := 0}
+{$endc}
+{$ifc not defined __ppc64__ and defined CPUPOWERPC64}
+	{$setc __ppc64__ := 1}
+{$elsec}
+	{$setc __ppc64__ := 0}
+{$endc}
+{$ifc not defined __i386__ and defined CPUI386}
+	{$setc __i386__ := 1}
+{$elsec}
+	{$setc __i386__ := 0}
+{$endc}
+{$ifc not defined __x86_64__ and defined CPUX86_64}
+	{$setc __x86_64__ := 1}
+{$elsec}
+	{$setc __x86_64__ := 0}
+{$endc}
+{$ifc not defined __arm__ and defined CPUARM}
+	{$setc __arm__ := 1}
+{$elsec}
+	{$setc __arm__ := 0}
+{$endc}
+
+{$ifc defined cpu64}
+  {$setc __LP64__ := 1}
+{$elsec}
+  {$setc __LP64__ := 0}
+{$endc}
+
+
+{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
+	{$error Conflicting definitions for __ppc__ and __i386__}
+{$endc}
+
+{$ifc defined __ppc__ and __ppc__}
+	{$setc TARGET_CPU_PPC := TRUE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$elifc defined __ppc64__ and __ppc64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := TRUE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$elifc defined __i386__ and __i386__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := TRUE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+{$ifc defined(iphonesim)}
+ 	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
+{$elsec}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$endc}
+{$elifc defined __x86_64__ and __x86_64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := TRUE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$elifc defined __arm__ and __arm__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := TRUE}
+	{ will require compiler define when/if other Apple devices with ARM cpus ship }
+	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$elsec}
+	{$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ is defined.}
+{$endc}
+
+{$ifc defined __LP64__ and __LP64__ }
+  {$setc TARGET_CPU_64 := TRUE}
+{$elsec}
+  {$setc TARGET_CPU_64 := FALSE}
+{$endc}
+
+{$ifc defined FPC_BIG_ENDIAN}
+	{$setc TARGET_RT_BIG_ENDIAN := TRUE}
+	{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
+{$elifc defined FPC_LITTLE_ENDIAN}
+	{$setc TARGET_RT_BIG_ENDIAN := FALSE}
+	{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
+{$elsec}
+	{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
+{$endc}
+{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
+{$setc CALL_NOT_IN_CARBON := FALSE}
+{$setc OLDROUTINENAMES := FALSE}
+{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
+{$setc OPAQUE_UPP_TYPES := TRUE}
+{$setc OTCARBONAPPLICATION := TRUE}
+{$setc OTKERNEL := FALSE}
+{$setc PM_USE_SESSION_APIS := TRUE}
+{$setc TARGET_API_MAC_CARBON := TRUE}
+{$setc TARGET_API_MAC_OS8 := FALSE}
+{$setc TARGET_API_MAC_OSX := TRUE}
+{$setc TARGET_CARBON := TRUE}
+{$setc TARGET_CPU_68K := FALSE}
+{$setc TARGET_CPU_MIPS := FALSE}
+{$setc TARGET_CPU_SPARC := FALSE}
+{$setc TARGET_OS_UNIX := FALSE}
+{$setc TARGET_OS_WIN32 := FALSE}
+{$setc TARGET_RT_MAC_68881 := FALSE}
+{$setc TARGET_RT_MAC_CFM := FALSE}
+{$setc TARGET_RT_MAC_MACHO := TRUE}
+{$setc TYPED_FUNCTION_POINTERS := TRUE}
+{$setc TYPE_BOOL := FALSE}
+{$setc TYPE_EXTENDED := FALSE}
+{$setc TYPE_LONGLONG := TRUE}
+uses MacTypes,kern_return,mach_error;
+{$endc} {not MACOSALLINCLUDE}
+
+
+{
+ * HISTORY
+ }
+ 
+{
+ * Core IOReturn values. Others may be family defined.
+ }
+
+type
+	IOReturn = kern_return_t;
+
+const
+  sys_iokit = ((($38) and $3f) shl 26);
+  sub_iokit_common = (((0) and $fff) shl 14);
+  sub_iokit_usb = (((1) and $fff) shl 14);
+  sub_iokit_firewire = (((2) and $fff) shl 14);
+  sub_iokit_block_storage = (((4) and $fff) shl 14);
+  sub_iokit_graphics = (((5) and $fff) shl 14);
+  sub_iokit_networking = (((6) and $fff) shl 14);
+  sub_iokit_bluetooth = (((8) and $fff) shl 14);
+  sub_iokit_pmu = (((9) and $fff) shl 14);
+  sub_iokit_acpi = (((10) and $fff) shl 14);
+  sub_iokit_smbus = (((11) and $fff) shl 14);
+  sub_iokit_ahci = (((12) and $fff) shl 14);
+  sub_iokit_powermanagement = (((13) and $fff) shl 14);
+//#define sub_iokit_hidsystem             (((14) and $fff) shl 14)
+//#define sub_iokit_pccard                (((21) and $fff) shl 14)
+
+  sub_iokit_vendor_specific = (((-2) and $fff) shl 14);
+  sub_iokit_reserved = (((-1) and $fff) shl 14);
+
+
+function iokit_common_err(ret: IOReturn): IOReturn; inline;
+function iokit_family_err(sub, ret: IOReturn): IOReturn; inline;
+function iokit_vendor_specific_err(ret: IOReturn): IOReturn; inline;
+
+const
+  kIOReturnSuccess = KERN_SUCCESS;            // OK
+  kIOReturnError = (sys_iokit or sub_iokit_common or $2bc); // general error 	
+  kIOReturnNoMemory = (sys_iokit or sub_iokit_common or $2bd); // can't allocate memory 
+  kIOReturnNoResources = (sys_iokit or sub_iokit_common or $2be); // resource shortage 
+  kIOReturnIPCError = (sys_iokit or sub_iokit_common or $2bf); // error during IPC 
+  kIOReturnNoDevice = (sys_iokit or sub_iokit_common or $2c0); // no such device 
+  kIOReturnNotPrivileged = (sys_iokit or sub_iokit_common or $2c1); // privilege violation 
+  kIOReturnBadArgument = (sys_iokit or sub_iokit_common or $2c2); // invalid argument 
+  kIOReturnLockedRead = (sys_iokit or sub_iokit_common or $2c3); // device read locked 
+  kIOReturnLockedWrite = (sys_iokit or sub_iokit_common or $2c4); // device write locked 
+  kIOReturnExclusiveAccess = (sys_iokit or sub_iokit_common or $2c5); // exclusive access and
+                                                         //   device already open 
+  kIOReturnBadMessageID = (sys_iokit or sub_iokit_common or $2c6); // sent/received messages
+                                                         //   had different msg_id
+  kIOReturnUnsupported = (sys_iokit or sub_iokit_common or $2c7); // unsupported function 
+  kIOReturnVMError = (sys_iokit or sub_iokit_common or $2c8); // misc. VM failure 
+  kIOReturnInternalError = (sys_iokit or sub_iokit_common or $2c9); // internal error 
+  kIOReturnIOError = (sys_iokit or sub_iokit_common or $2ca); // General I/O error 
+//#define kIOReturn???Error      (sys_iokit or sub_iokit_common or $2cb) // ??? 
+  kIOReturnCannotLock = (sys_iokit or sub_iokit_common or $2cc); // can't acquire lock
+  kIOReturnNotOpen = (sys_iokit or sub_iokit_common or $2cd); // device not open 
+  kIOReturnNotReadable = (sys_iokit or sub_iokit_common or $2ce); // read not supported 
+  kIOReturnNotWritable = (sys_iokit or sub_iokit_common or $2cf); // write not supported 
+  kIOReturnNotAligned = (sys_iokit or sub_iokit_common or $2d0); // alignment error 
+  kIOReturnBadMedia = (sys_iokit or sub_iokit_common or $2d1); // Media Error 
+  kIOReturnStillOpen = (sys_iokit or sub_iokit_common or $2d2); // device(s) still open 
+  kIOReturnRLDError = (sys_iokit or sub_iokit_common or $2d3); // rld failure 
+  kIOReturnDMAError = (sys_iokit or sub_iokit_common or $2d4); // DMA failure 
+  kIOReturnBusy = (sys_iokit or sub_iokit_common or $2d5); // Device Busy 
+  kIOReturnTimeout = (sys_iokit or sub_iokit_common or $2d6); // I/O Timeout 
+  kIOReturnOffline = (sys_iokit or sub_iokit_common or $2d7); // device offline 
+  kIOReturnNotReady = (sys_iokit or sub_iokit_common or $2d8); // not ready 
+  kIOReturnNotAttached = (sys_iokit or sub_iokit_common or $2d9); // device not attached 
+  kIOReturnNoChannels = (sys_iokit or sub_iokit_common or $2da); // no DMA channels left
+  kIOReturnNoSpace = (sys_iokit or sub_iokit_common or $2db); // no space for data 
+//#define kIOReturn???Error      (sys_iokit or sub_iokit_common or $2dc) // ??? 
+  kIOReturnPortExists = (sys_iokit or sub_iokit_common or $2dd); // port already exists
+  kIOReturnCannotWire = (sys_iokit or sub_iokit_common or $2de); // can't wire down 
+                                                         //   physical memory
+  kIOReturnNoInterrupt = (sys_iokit or sub_iokit_common or $2df); // no interrupt attached
+  kIOReturnNoFrames = (sys_iokit or sub_iokit_common or $2e0); // no DMA frames enqueued
+  kIOReturnMessageTooLarge = (sys_iokit or sub_iokit_common or $2e1); // oversized msg received
+                                                         //   on interrupt port
+  kIOReturnNotPermitted = (sys_iokit or sub_iokit_common or $2e2); // not permitted
+  kIOReturnNoPower = (sys_iokit or sub_iokit_common or $2e3); // no power to device
+  kIOReturnNoMedia = (sys_iokit or sub_iokit_common or $2e4); // media not present
+  kIOReturnUnformattedMedia = (sys_iokit or sub_iokit_common or $2e5); // media not formatted
+  kIOReturnUnsupportedMode = (sys_iokit or sub_iokit_common or $2e6); // no such mode
+  kIOReturnUnderrun = (sys_iokit or sub_iokit_common or $2e7); // data underrun
+  kIOReturnOverrun = (sys_iokit or sub_iokit_common or $2e8); // data overrun
+  kIOReturnDeviceError = (sys_iokit or sub_iokit_common or $2e9); // the device is not working properly!
+  kIOReturnNoCompletion = (sys_iokit or sub_iokit_common or $2ea); // a completion routine is required
+  kIOReturnAborted = (sys_iokit or sub_iokit_common or $2eb); // operation aborted
+  kIOReturnNoBandwidth = (sys_iokit or sub_iokit_common or $2ec); // bus bandwidth would be exceeded
+  kIOReturnNotResponding = (sys_iokit or sub_iokit_common or $2ed); // device not responding
+  kIOReturnIsoTooOld = (sys_iokit or sub_iokit_common or $2ee); // isochronous I/O request for distant past!
+  kIOReturnIsoTooNew = (sys_iokit or sub_iokit_common or $2ef); // isochronous I/O request for distant future
+  kIOReturnNotFound = (sys_iokit or sub_iokit_common or $2f0); // data was not found
+  kIOReturnInvalid = (sys_iokit or sub_iokit_common or $1);   // should never be seen
+
+{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
+implementation
+
+
+{$push}
+{$R-,Q-}
+
+function iokit_common_err(ret: IOReturn): IOReturn; inline;
+begin
+  iokit_common_err:=(sys_iokit or sub_iokit_common or (ret))
+end;
+
+function iokit_family_err(sub, ret: IOReturn): IOReturn; inline;
+begin
+  iokit_family_err:=(sys_iokit or (sub) or (ret))
+end;
+
+function iokit_vendor_specific_err(ret: IOReturn): IOReturn; inline;
+begin
+  iokit_vendor_specific_err:=(sys_iokit or sub_iokit_vendor_specific or (ret))
+end;
+
+{$pop}
+
+end.
+
+{$endc} {not MACOSALLINCLUDE}

+ 475 - 0
packages/univint/src/IOSurfaceAPI.pas

@@ -0,0 +1,475 @@
+{
+ *  IOSurface.h
+ *  IOSurface
+ *
+ *  Copyright 2006-2008 Apple Computer, Inc. All rights reserved.
+ *
+ }
+{       Pascal Translation Updated:  Jonas Maebe, <[email protected]>, September 2010 }
+{
+    Modified for use with Free Pascal
+    Version 308
+    Please report any bugs to <[email protected]>
+}
+
+{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
+{$mode macpas}
+{$packenum 1}
+{$macro on}
+{$inline on}
+{$calling mwpascal}
+
+unit IOSurfaceAPI;
+interface
+{$setc UNIVERSAL_INTERFACES_VERSION := $0400}
+{$setc GAP_INTERFACES_VERSION := $0308}
+
+{$ifc not defined USE_CFSTR_CONSTANT_MACROS}
+    {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
+{$endc}
+
+{$ifc defined CPUPOWERPC and defined CPUI386}
+	{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
+{$endc}
+{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
+	{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
+{$endc}
+
+{$ifc not defined __ppc__ and defined CPUPOWERPC32}
+	{$setc __ppc__ := 1}
+{$elsec}
+	{$setc __ppc__ := 0}
+{$endc}
+{$ifc not defined __ppc64__ and defined CPUPOWERPC64}
+	{$setc __ppc64__ := 1}
+{$elsec}
+	{$setc __ppc64__ := 0}
+{$endc}
+{$ifc not defined __i386__ and defined CPUI386}
+	{$setc __i386__ := 1}
+{$elsec}
+	{$setc __i386__ := 0}
+{$endc}
+{$ifc not defined __x86_64__ and defined CPUX86_64}
+	{$setc __x86_64__ := 1}
+{$elsec}
+	{$setc __x86_64__ := 0}
+{$endc}
+{$ifc not defined __arm__ and defined CPUARM}
+	{$setc __arm__ := 1}
+{$elsec}
+	{$setc __arm__ := 0}
+{$endc}
+
+{$ifc defined cpu64}
+  {$setc __LP64__ := 1}
+{$elsec}
+  {$setc __LP64__ := 0}
+{$endc}
+
+
+{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
+	{$error Conflicting definitions for __ppc__ and __i386__}
+{$endc}
+
+{$ifc defined __ppc__ and __ppc__}
+	{$setc TARGET_CPU_PPC := TRUE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$elifc defined __ppc64__ and __ppc64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := TRUE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$elifc defined __i386__ and __i386__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := TRUE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+{$ifc defined(iphonesim)}
+ 	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
+{$elsec}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$endc}
+{$elifc defined __x86_64__ and __x86_64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := TRUE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$elifc defined __arm__ and __arm__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := TRUE}
+	{ will require compiler define when/if other Apple devices with ARM cpus ship }
+	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$elsec}
+	{$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ is defined.}
+{$endc}
+
+{$ifc defined __LP64__ and __LP64__ }
+  {$setc TARGET_CPU_64 := TRUE}
+{$elsec}
+  {$setc TARGET_CPU_64 := FALSE}
+{$endc}
+
+{$ifc defined FPC_BIG_ENDIAN}
+	{$setc TARGET_RT_BIG_ENDIAN := TRUE}
+	{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
+{$elifc defined FPC_LITTLE_ENDIAN}
+	{$setc TARGET_RT_BIG_ENDIAN := FALSE}
+	{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
+{$elsec}
+	{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
+{$endc}
+{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
+{$setc CALL_NOT_IN_CARBON := FALSE}
+{$setc OLDROUTINENAMES := FALSE}
+{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
+{$setc OPAQUE_UPP_TYPES := TRUE}
+{$setc OTCARBONAPPLICATION := TRUE}
+{$setc OTKERNEL := FALSE}
+{$setc PM_USE_SESSION_APIS := TRUE}
+{$setc TARGET_API_MAC_CARBON := TRUE}
+{$setc TARGET_API_MAC_OS8 := FALSE}
+{$setc TARGET_API_MAC_OSX := TRUE}
+{$setc TARGET_CARBON := TRUE}
+{$setc TARGET_CPU_68K := FALSE}
+{$setc TARGET_CPU_MIPS := FALSE}
+{$setc TARGET_CPU_SPARC := FALSE}
+{$setc TARGET_OS_UNIX := FALSE}
+{$setc TARGET_OS_WIN32 := FALSE}
+{$setc TARGET_RT_MAC_68881 := FALSE}
+{$setc TARGET_RT_MAC_CFM := FALSE}
+{$setc TARGET_RT_MAC_MACHO := TRUE}
+{$setc TYPED_FUNCTION_POINTERS := TRUE}
+{$setc TYPE_BOOL := FALSE}
+{$setc TYPE_EXTENDED := FALSE}
+{$setc TYPE_LONGLONG := TRUE}
+uses MacTypes,MacOSXPosix,CFBase,CFDictionary,IOKitReturn;
+{$endc} {not MACOSALLINCLUDE}
+
+
+{$ifc TARGET_OS_MAC}
+
+type
+	IOSurfaceRef = ^__IOSurface; { an opaque type }
+	__IOSurface = record end;
+
+type
+	IOSurfaceID = UInt32;
+
+{ The following list of properties are used with the CFDictionary passed to IOSurfaceCreate(). }
+
+{ kIOSurfaceAllocSize    - CFNumber of the total allocation size of the buffer including all planes.    
+				    Defaults to BufferHeight * BytesPerRow if not specified.   Must be specified for
+				    dimensionless buffers. }
+var kIOSurfaceAllocSize: CFStringRef; external name '_kIOSurfaceAllocSize'; (* attribute const *)
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ kIOSurfaceWidth  - CFNumber for the width of the IOSurface buffer in pixels.  Required for planar IOSurfaces. }
+var kIOSurfaceWidth: CFStringRef; external name '_kIOSurfaceWidth'; (* attribute const *)
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ kIOSurfaceHeight - CFNumber for the height of the IOSurface buffer in pixels. Required for planar IOSurfaces. }
+var kIOSurfaceHeight: CFStringRef; external name '_kIOSurfaceHeight'; (* attribute const *)
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ kIOSurfaceBytesPerRow - CFNumber for the bytes per row of the buffer.   If not specified, IOSurface will first calculate
+                                   the number full elements required on each row (by rounding up), multiplied by the bytes per element
+				   for this buffer.   That value will then be appropriately aligned. }
+var kIOSurfaceBytesPerRow: CFStringRef; external name '_kIOSurfaceBytesPerRow'; (* attribute const *)
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ Optional properties for non-planar two dimensional images }
+ 
+{ kIOSurfaceBitsPerElement - CFNumber for the total number of bytes in an element.  Default to 1. }
+var kIOSurfaceBytesPerElement: CFStringRef; external name '_kIOSurfaceBytesPerElement'; (* attribute const *)
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ kIOSurfaceElementWidth   - CFNumber for how many pixels wide each element is.   Defaults to 1. } 
+var kIOSurfaceElementWidth: CFStringRef; external name '_kIOSurfaceElementWidth'; (* attribute const *)
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ kIOSurfaceElementHeight  - CFNumber for how many pixels high each element is.   Defaults to 1. } 
+var kIOSurfaceElementHeight: CFStringRef; external name '_kIOSurfaceElementHeight'; (* attribute const *)
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ kIOSurfaceOffset - CFNumber for the starting offset into the buffer.  Defaults to 0. }
+var kIOSurfaceOffset: CFStringRef; external name '_kIOSurfaceOffset'; (* attribute const *)
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ Properties for planar surface buffers }
+
+{ kIOSurfacePlaneInfo    - CFArray describing each image plane in the buffer as a CFDictionary.   The CFArray must have at least one entry. }
+var kIOSurfacePlaneInfo: CFStringRef; external name '_kIOSurfacePlaneInfo'; (* attribute const *)
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ kIOSurfacePlaneWidth  - CFNumber for the width of this plane in pixels.  Required for image planes. }
+var kIOSurfacePlaneWidth: CFStringRef; external name '_kIOSurfacePlaneWidth'; (* attribute const *)
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ kIOSurfacePlaneHeight  - CFNumber for the height of this plane in pixels.  Required for image planes. }
+var kIOSurfacePlaneHeight: CFStringRef; external name '_kIOSurfacePlaneHeight'; (* attribute const *)
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ kIOSurfacePlaneBytesPerRow    - CFNumber for the bytes per row of this plane.  If not specified, IOSurface will first calculate
+                                   the number full elements required on each row (by rounding up), multiplied by the bytes per element
+				   for this plane.   That value will then be appropriately aligned. }
+var kIOSurfacePlaneBytesPerRow: CFStringRef; external name '_kIOSurfacePlaneBytesPerRow'; (* attribute const *)
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ kIOSurfacePlaneOffset  - CFNumber for the offset into the buffer for this plane.  If not specified then IOSurface
+   will lay out each plane sequentially based on the previous plane's allocation size. }
+var kIOSurfacePlaneOffset: CFStringRef; external name '_kIOSurfacePlaneOffset'; (* attribute const *)
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ kIOSurfacePlaneSize    - CFNumber for the total data size of this plane.  Defaults to plane height * plane bytes per row if not specified. }
+var kIOSurfacePlaneSize: CFStringRef; external name '_kIOSurfacePlaneSize'; (* attribute const *)
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ Optional properties for planar surface buffers }
+
+{ kIOSurfacePlaneBase    - CFNumber for the base offset into the buffer for this plane. Optional, defaults to the plane offset }
+var kIOSurfacePlaneBase: CFStringRef; external name '_kIOSurfacePlaneBase'; (* attribute const *)
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ kIOSurfacePlaneBytesPerElement    - CFNumber for the bytes per element of this plane.  Optional, default is 1. }
+var kIOSurfacePlaneBytesPerElement: CFStringRef; external name '_kIOSurfacePlaneBytesPerElement'; (* attribute const *)
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ kIOSurfacePlaneElementWidth    - CFNumber for the element width of this plane.  Optional, default is 1. }
+var kIOSurfacePlaneElementWidth: CFStringRef; external name '_kIOSurfacePlaneElementWidth'; (* attribute const *)
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ kIOSurfacePlaneElementHeight   - CFNumber for the element height of this plane.  Optional, default is 1. }
+var kIOSurfacePlaneElementHeight: CFStringRef; external name '_kIOSurfacePlaneElementHeight'; (* attribute const *)
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ Optional properties global to the entire IOSurface }
+
+{ kIOSurfaceCacheMode		- CFNumber for the CPU cache mode to be used for the allocation.  Default is kIOMapDefaultCache. }
+var kIOSurfaceCacheMode: CFStringRef; external name '_kIOSurfaceCacheMode'; (* attribute const *)
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ kIOSurfaceIsGlobal - CFBoolean     If true, the IOSurface may be looked up by any task in the system by its ID. }
+var kIOSurfaceIsGlobal: CFStringRef; external name '_kIOSurfaceIsGlobal'; (* attribute const *)
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ kIOSurfacePixelFormat - CFNumber	A 32-bit unsigned integer that stores the traditional Mac OS X buffer format  }
+var kIOSurfacePixelFormat: CFStringRef; external name '_kIOSurfacePixelFormat'; (* attribute const *)
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+function IOSurfaceGetTypeID: CFTypeID; external name '_IOSurfaceGetTypeID';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ Create a brand new IOSurface object }
+function IOSurfaceCreate( properties: CFDictionaryRef ): IOSurfaceRef; external name '_IOSurfaceCreate';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ Perform an atomic lookup and retain of a IOSurface by its IOSurfaceID.
+   Note: Performing multiple lookups of the same IOSurface will *NOT* return
+   the same IOSurfaceRef.   If you need to compare two IOSurface objects
+   for equality, you must either do so by comparing their IOSurfaceIDs, or by 
+   using CFEqual(). }
+function IOSurfaceLookup( csid: IOSurfaceID ): IOSurfaceRef; external name '_IOSurfaceLookup';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ Retrieve the unique IOSurfaceID value for a IOSurface }
+function IOSurfaceGetID( buffer: IOSurfaceRef ): IOSurfaceID; external name '_IOSurfaceGetID';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+	
+const
+// If you are not going to modify the data while you hold the lock, you should set this flag to avoid invalidating
+	// any existing caches of the buffer contents.  This flag should be passed both to the lock and unlock functions.
+	// Non-symmentrical usage of this flag will result in undefined behavior.
+	kIOSurfaceLockReadOnly = $00000001;
+	
+	// If you want to detect/avoid a potentially expensive paging operation (such as readback from a GPU to system memory)
+	// when you lock the buffer, you may include this flag.   If locking the buffer requires a readback, the lock will
+	// fail with an error return of kIOReturnCannotLock.
+	kIOSurfaceLockAvoidSync = $00000002;
+			
+{ "Lock" or "Unlock" a IOSurface for reading or writing.
+
+    The term "lock" is used loosely in this context, and is simply used along with the
+    "unlock" information to put a bound on CPU access to the raw IOSurface data.
+    
+    If the seed parameter is non-NULL, IOSurfaceLock() will store the buffer's
+    internal modification seed value at the time you made the lock call.   You can compare
+    this value to a value returned previously to determine of the contents of the buffer
+    has been changed since the last lock.
+    
+    In the case of IOSurfaceUnlock(), the seed value returned will be the internal
+    seed value at the time of the unlock.  If you locked the buffer for writing, this value
+    will be incremented as the unlock is performed and the new value will be returned.
+    
+    See the kIOSurfaceLock enums for more information.
+    
+    Note: Locking and unlocking a IOSurface is not a particularly cheap operation,
+    so care should be taken to avoid the calls whenever possible.   The seed values are 
+    particularly useful for keeping a cache of the buffer contents.
+}
+function IOSurfaceLock( buffer: IOSurfaceRef; options: UInt32; var seed: UInt32 ): IOReturn; external name '_IOSurfaceLock';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)	
+function IOSurfaceUnlock( buffer: IOSurfaceRef; options: UInt32; var seed: UInt32 ): IOReturn; external name '_IOSurfaceUnlock';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ These routines are all fairly self explanatory.  0 is returned if buffer is invalid or NULL }
+function IOSurfaceGetAllocSize( buffer: IOSurfaceRef ): size_t; external name '_IOSurfaceGetAllocSize';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+function IOSurfaceGetWidth( buffer: IOSurfaceRef ): size_t; external name '_IOSurfaceGetWidth';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+	
+function IOSurfaceGetHeight( buffer: IOSurfaceRef ): size_t; external name '_IOSurfaceGetHeight';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+function IOSurfaceGetBytesPerElement( buffer: IOSurfaceRef ): size_t; external name '_IOSurfaceGetBytesPerElement';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+function IOSurfaceGetBytesPerRow( buffer: IOSurfaceRef ): size_t; external name '_IOSurfaceGetBytesPerRow';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+function IOSurfaceGetBaseAddress( buffer: IOSurfaceRef ): UnivPtr; external name '_IOSurfaceGetBaseAddress';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+function IOSurfaceGetElementWidth( buffer: IOSurfaceRef ): size_t; external name '_IOSurfaceGetElementWidth';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+function IOSurfaceGetElementHeight( buffer: IOSurfaceRef ): size_t; external name '_IOSurfaceGetElementHeight';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+function IOSurfaceGetPixelFormat( buffer: IOSurfaceRef ): OSType; external name '_IOSurfaceGetPixelFormat';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ This will return the current seed value of the buffer and is a cheap call to make to see
+   if the contents of the buffer have changed since the last lock/unlock. }
+function IOSurfaceGetSeed( buffer: IOSurfaceRef ): UInt32; external name '_IOSurfaceGetSeed';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ Return the number of planes in this buffer.  May be 0.   Returns 0 for an invalid or NULL buffer pointer. }
+function IOSurfaceGetPlaneCount( buffer: IOSurfaceRef ): size_t; external name '_IOSurfaceGetPlaneCount';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ These routines return information about a particular plane of a IOSurface.   
+
+   If the planeIndex is greater than or equal to the plane count of the IOSurface, zero
+   is returned.... with one exception.   If this IOSurface has zero planes and a planeIndex
+   of zero is passed in, the routines function just like the non-planar APIs.  This is to allow
+   higher level code to treat planar and non-planar buffers is a more uniform fashion. }
+
+function IOSurfaceGetWidthOfPlane( buffer: IOSurfaceRef; planeIndex: size_t ): size_t; external name '_IOSurfaceGetWidthOfPlane';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+function IOSurfaceGetHeightOfPlane( buffer: IOSurfaceRef; planeIndex: size_t ): size_t; external name '_IOSurfaceGetHeightOfPlane';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+function IOSurfaceGetBytesPerElementOfPlane( buffer: IOSurfaceRef; planeIndex: size_t ): size_t; external name '_IOSurfaceGetBytesPerElementOfPlane';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+function IOSurfaceGetBytesPerRowOfPlane( buffer: IOSurfaceRef; planeIndex: size_t ): size_t; external name '_IOSurfaceGetBytesPerRowOfPlane';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+function IOSurfaceGetBaseAddressOfPlane( buffer: IOSurfaceRef; planeIndex: size_t ): UnivPtr; external name '_IOSurfaceGetBaseAddressOfPlane';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+function IOSurfaceGetElementWidthOfPlane( buffer: IOSurfaceRef; planeIndex: size_t ): size_t; external name '_IOSurfaceGetElementWidthOfPlane';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+function IOSurfaceGetElementHeightOfPlane( buffer: IOSurfaceRef; planeIndex: size_t ): size_t; external name '_IOSurfaceGetElementHeightOfPlane';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ These calls let you attach CF property list types to a IOSurface buffer.  These calls are 
+   expensive (they essentially must serialize the data into the kernel) and thus should be avoided whenever
+   possible.   Note:  These functions can not be used to change the underlying surface properties. }
+procedure IOSurfaceSetValue( buffer: IOSurfaceRef; key: CFStringRef; value: CFTypeRef ); external name '_IOSurfaceSetValue';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+function IOSurfaceCopyValue( buffer: IOSurfaceRef; key: CFStringRef ): CFTypeRef; external name '_IOSurfaceCopyValue';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+procedure IOSurfaceRemoveValue( buffer: IOSurfaceRef; key: CFStringRef ); external name '_IOSurfaceRemoveValue';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ This call lets you get a mach_port_t that holds a reference to the IOSurface. This is useful 
+   if you need to atomically or securely pass an IOSurface to another task without making the surface global to
+   the entire system.  The returned port must be deallocated with mach_port_deallocate or the equivalent.  }
+function IOSurfaceCreateMachPort( buffer: IOSurfaceRef ): mach_port_t; external name '_IOSurfaceCreateMachPort';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ This call lets you take a mach_port_t created via IOSurfaceCreatePort() and recreate an IOSurfaceRef from it.
+   Note: This call does NOT destroy the port. }
+function IOSurfaceLookupFromMachPort( port: mach_port_t ): IOSurfaceRef; external name '_IOSurfaceLookupFromMachPort';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ 
+   IOSurfaceGetPropertyMaximum() will return the maximum of a given property that is guaranteed to be 
+   compatible with all of the current devices (GPUs, etc.) in the system.   The most important ones being:
+   
+   kIOSurfaceBytesPerRow
+   kIOSurfaceWidth
+   kIOSurfaceHeight
+   kIOSurfacePlaneBytesPerRow
+   kIOSurfacePlaneWidth
+   kIOSurfacePlaneHeight
+   
+   For the width and height properties, the maximum values are the largest that are guaranteed to work
+   for both reading and writing.   In OpenGL terms this translates into the largest size that will work
+   for both textures and render targets.
+   
+   This function returns 0 for properties that have no predefined limit or where the concept of a limit
+   would be considered invalid (such as kIOSurfacePixelFormat).
+      
+}   
+function IOSurfaceGetPropertyMaximum( property: CFStringRef ): size_t; external name '_IOSurfaceGetPropertyMaximum';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+
+{ 
+   If a property has a particular alignment requirement, then IOSurfaceGetPropertyAlignment() will return it.  
+   If the property has no alignment requirement then 1 will be returned.   The following properties 
+   should always be aligned if you choose calculate them yourself:
+   
+   kIOSurfaceBytesPerRow
+   kIOSurfaceOffset
+   
+   kIOSurfacePlaneBase
+   kIOSurfacePlaneOffset
+   kIOSurfacePlaneBytesPerRow
+   
+}   
+function IOSurfaceGetPropertyAlignment( property: CFStringRef ): size_t; external name '_IOSurfaceGetPropertyAlignment';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{ This is a convenience function to automatically align property values.  For properties with no alignment
+   requirements, the original value will be returned. }
+function IOSurfaceAlignProperty( property: CFStringRef; value: size_t ): size_t; external name '_IOSurfaceAlignProperty';
+(* IOSFC_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA) *)
+
+{$endc} {TARGET_OS_MAC}
+{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
+
+end.
+{$endc} {not MACOSALLINCLUDE}

+ 4 - 0
packages/univint/src/MacOS.pas

@@ -283,6 +283,8 @@ uses
   ICAApplication,
   ICACamera,
   ICADevice,
+  IOKitReturn,
+  IOSurfaceAPI,
   IconStorage,
   Icons,
   IconsCore,
@@ -444,9 +446,11 @@ uses
   gliContexts,
   gliDispatch,
   gluContext,
+  kern_return,
   macgl,
   macglext,
   macglu,
+  mach_error,
   vBLAS,
   vDSP,
   x509defs,

+ 71 - 0
packages/univint/src/MacOSAll.pas

@@ -230,12 +230,16 @@ interface
 {$i fp.pas}
 {unit gliContexts}
 {$i gliContexts.pas}
+{unit kern_return}
+{$i kern_return.pas}
 {unit macgl}
 {$i macgl.pas}
 {unit macglext}
 {$i macglext.pas}
 {unit macglu}
 {$i macglu.pas}
+{unit mach_error}
+{$i mach_error.pas}
 {unit vBLAS}
 {$i vBLAS.pas}
 {unit vDSP}
@@ -384,6 +388,8 @@ interface
 {$i HostTime.pas}
 {unit ICACamera}
 {$i ICACamera.pas}
+{unit IOKitReturn}
+{$i IOKitReturn.pas}
 {unit IconStorage}
 {$i IconStorage.pas}
 {unit IntlResources}
@@ -530,6 +536,8 @@ interface
 {$i Events.pas}
 {unit HITextLengthFilter}
 {$i HITextLengthFilter.pas}
+{unit IOSurfaceAPI}
+{$i IOSurfaceAPI.pas}
 {unit MDItem}
 {$i MDItem.pas}
 {unit MDQuery}
@@ -1094,6 +1102,46 @@ end;
 
 {$endc} {TARGET_OS_MAC}
 
+{implementation of unit mach_error}
+
+
+{$push}
+{$R-,Q-}
+
+function err_system(x: mach_error_t): mach_error_t; inline;
+begin
+  err_system:=(((x) and $3f) shl 26)
+end;
+
+function err_sub(x: mach_error_t): mach_error_t; inline;
+begin
+  err_sub:=(((x) shr 14) and $fff)
+end;
+
+
+function err_get_system(err: mach_error_t): mach_error_t; inline;
+begin
+  err_get_system:=(((err) shr 26) and $3f)
+end;
+
+function err_get_sub(err: mach_error_t): mach_error_t; inline;
+begin
+  err_get_sub:=(((err) shr 14) and $fff)
+end;
+
+function err_get_code(err: mach_error_t): mach_error_t; inline;
+begin
+  err_get_code:=((err) and $3fff)
+end;
+
+
+function unix_err(errno: SInt32): mach_error_t; inline;
+begin
+  unix_err:=err_kern or (((3) and $fff) shl 14) or errno;
+end;
+
+{$pop}
+
 {implementation of unit CFByteOrders}
 
 
@@ -1714,6 +1762,29 @@ end;
 
 
 
+{implementation of unit IOKitReturn}
+
+
+{$push}
+{$R-,Q-}
+
+function iokit_common_err(ret: IOReturn): IOReturn; inline;
+begin
+  iokit_common_err:=(sys_iokit or sub_iokit_common or (ret))
+end;
+
+function iokit_family_err(sub, ret: IOReturn): IOReturn; inline;
+begin
+  iokit_family_err:=(sys_iokit or (sub) or (ret))
+end;
+
+function iokit_vendor_specific_err(ret: IOReturn): IOReturn; inline;
+begin
+  iokit_vendor_specific_err:=(sys_iokit or sub_iokit_vendor_specific or (ret))
+end;
+
+{$pop}
+
 {implementation of unit MIDIServices}
 {$ifc TARGET_OS_MAC}
 

+ 540 - 0
packages/univint/src/kern_return.pas

@@ -0,0 +1,540 @@
+{
+ * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
+ * 
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
+ }
+{       Pascal Translation Updated:  Jonas Maebe, <[email protected]>, September 2010 }
+{
+    Modified for use with Free Pascal
+    Version 308
+    Please report any bugs to <[email protected]>
+}
+
+{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
+{$mode macpas}
+{$packenum 1}
+{$macro on}
+{$inline on}
+{$calling mwpascal}
+
+unit kern_return;
+interface
+{$setc UNIVERSAL_INTERFACES_VERSION := $0400}
+{$setc GAP_INTERFACES_VERSION := $0308}
+
+{$ifc not defined USE_CFSTR_CONSTANT_MACROS}
+    {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
+{$endc}
+
+{$ifc defined CPUPOWERPC and defined CPUI386}
+	{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
+{$endc}
+{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
+	{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
+{$endc}
+
+{$ifc not defined __ppc__ and defined CPUPOWERPC32}
+	{$setc __ppc__ := 1}
+{$elsec}
+	{$setc __ppc__ := 0}
+{$endc}
+{$ifc not defined __ppc64__ and defined CPUPOWERPC64}
+	{$setc __ppc64__ := 1}
+{$elsec}
+	{$setc __ppc64__ := 0}
+{$endc}
+{$ifc not defined __i386__ and defined CPUI386}
+	{$setc __i386__ := 1}
+{$elsec}
+	{$setc __i386__ := 0}
+{$endc}
+{$ifc not defined __x86_64__ and defined CPUX86_64}
+	{$setc __x86_64__ := 1}
+{$elsec}
+	{$setc __x86_64__ := 0}
+{$endc}
+{$ifc not defined __arm__ and defined CPUARM}
+	{$setc __arm__ := 1}
+{$elsec}
+	{$setc __arm__ := 0}
+{$endc}
+
+{$ifc defined cpu64}
+  {$setc __LP64__ := 1}
+{$elsec}
+  {$setc __LP64__ := 0}
+{$endc}
+
+
+{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
+	{$error Conflicting definitions for __ppc__ and __i386__}
+{$endc}
+
+{$ifc defined __ppc__ and __ppc__}
+	{$setc TARGET_CPU_PPC := TRUE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$elifc defined __ppc64__ and __ppc64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := TRUE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$elifc defined __i386__ and __i386__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := TRUE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+{$ifc defined(iphonesim)}
+ 	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
+{$elsec}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$endc}
+{$elifc defined __x86_64__ and __x86_64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := TRUE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$elifc defined __arm__ and __arm__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := TRUE}
+	{ will require compiler define when/if other Apple devices with ARM cpus ship }
+	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$elsec}
+	{$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ is defined.}
+{$endc}
+
+{$ifc defined __LP64__ and __LP64__ }
+  {$setc TARGET_CPU_64 := TRUE}
+{$elsec}
+  {$setc TARGET_CPU_64 := FALSE}
+{$endc}
+
+{$ifc defined FPC_BIG_ENDIAN}
+	{$setc TARGET_RT_BIG_ENDIAN := TRUE}
+	{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
+{$elifc defined FPC_LITTLE_ENDIAN}
+	{$setc TARGET_RT_BIG_ENDIAN := FALSE}
+	{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
+{$elsec}
+	{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
+{$endc}
+{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
+{$setc CALL_NOT_IN_CARBON := FALSE}
+{$setc OLDROUTINENAMES := FALSE}
+{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
+{$setc OPAQUE_UPP_TYPES := TRUE}
+{$setc OTCARBONAPPLICATION := TRUE}
+{$setc OTKERNEL := FALSE}
+{$setc PM_USE_SESSION_APIS := TRUE}
+{$setc TARGET_API_MAC_CARBON := TRUE}
+{$setc TARGET_API_MAC_OS8 := FALSE}
+{$setc TARGET_API_MAC_OSX := TRUE}
+{$setc TARGET_CARBON := TRUE}
+{$setc TARGET_CPU_68K := FALSE}
+{$setc TARGET_CPU_MIPS := FALSE}
+{$setc TARGET_CPU_SPARC := FALSE}
+{$setc TARGET_OS_UNIX := FALSE}
+{$setc TARGET_OS_WIN32 := FALSE}
+{$setc TARGET_RT_MAC_68881 := FALSE}
+{$setc TARGET_RT_MAC_CFM := FALSE}
+{$setc TARGET_RT_MAC_MACHO := TRUE}
+{$setc TYPED_FUNCTION_POINTERS := TRUE}
+{$setc TYPE_BOOL := FALSE}
+{$setc TYPE_EXTENDED := FALSE}
+{$setc TYPE_LONGLONG := TRUE}
+uses MacTypes;
+{$endc} {not MACOSALLINCLUDE}
+
+
+{
+ * @OSF_COPYRIGHT@
+ }
+{ 
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
+ * All Rights Reserved.
+ * 
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ * 
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ * 
+ * Carnegie Mellon requests users of this software to return to
+ * 
+ *  Software Distribution Coordinator  or  [email protected]
+ *  School of Computer Science
+ *  Carnegie Mellon University
+ *  Pittsburgh PA 15213-3890
+ * 
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ }
+{
+ *	File:	h/kern_return.h
+ *	Author:	Avadis Tevanian, Jr.
+ *	Date:	1985
+ *
+ *	Kernel return codes.
+ *
+ }
+
+
+const
+	KERN_SUCCESS = 0;
+
+const
+	KERN_INVALID_ADDRESS = 1;
+		{ Specified address is not currently valid.
+		 }
+
+const
+	KERN_PROTECTION_FAILURE = 2;
+		{ Specified memory is valid, but does not permit the
+		 * required forms of access.
+		 }
+
+const
+	KERN_NO_SPACE = 3;
+		{ The address range specified is already in use, or
+		 * no address range of the size specified could be
+		 * found.
+		 }
+
+const
+	KERN_INVALID_ARGUMENT = 4;
+		{ The function requested was not applicable to this
+		 * type of argument, or an argument is invalid
+		 }
+
+const
+	KERN_FAILURE = 5;
+		{ The function could not be performed.  A catch-all.
+		 }
+
+const
+	KERN_RESOURCE_SHORTAGE = 6;
+		{ A system resource could not be allocated to fulfill
+		 * this request.  This failure may not be permanent.
+		 }
+
+const
+	KERN_NOT_RECEIVER = 7;
+		{ The task in question does not hold receive rights
+		 * for the port argument.
+		 }
+
+const
+	KERN_NO_ACCESS = 8;
+		{ Bogus access restriction.
+		 }
+
+const
+	KERN_MEMORY_FAILURE = 9;
+		{ During a page fault, the target address refers to a
+		 * memory object that has been destroyed.  This
+		 * failure is permanent.
+		 }
+
+const
+	KERN_MEMORY_ERROR = 10;
+		{ During a page fault, the memory object indicated
+		 * that the data could not be returned.  This failure
+		 * may be temporary; future attempts to access this
+		 * same data may succeed, as defined by the memory
+		 * object.
+		 }
+
+const
+	KERN_ALREADY_IN_SET = 11;
+		{ The receive right is already a member of the portset.
+		 }
+
+const
+	KERN_NOT_IN_SET = 12;
+		{ The receive right is not a member of a port set.
+		 }
+
+const
+	KERN_NAME_EXISTS = 13;
+		{ The name already denotes a right in the task.
+		 }
+
+const
+	KERN_ABORTED = 14;
+		{ The operation was aborted.  Ipc code will
+		 * catch this and reflect it as a message error.
+		 }
+
+const
+	KERN_INVALID_NAME = 15;
+		{ The name doesn't denote a right in the task.
+		 }
+
+const
+	KERN_INVALID_TASK = 16;
+		{ Target task isn't an active task.
+		 }
+
+const
+	KERN_INVALID_RIGHT = 17;
+		{ The name denotes a right, but not an appropriate right.
+		 }
+
+const
+	KERN_INVALID_VALUE = 18;
+		{ A blatant range error.
+		 }
+
+const
+	KERN_UREFS_OVERFLOW = 19;
+		{ Operation would overflow limit on user-references.
+		 }
+
+const
+	KERN_INVALID_CAPABILITY = 20;
+		{ The supplied (port) capability is improper.
+		 }
+
+const
+	KERN_RIGHT_EXISTS = 21;
+		{ The task already has send or receive rights
+		 * for the port under another name.
+		 }
+
+const
+	KERN_INVALID_HOST = 22;
+		{ Target host isn't actually a host.
+		 }
+
+const
+	KERN_MEMORY_PRESENT = 23;
+		{ An attempt was made to supply "precious" data
+		 * for memory that is already present in a
+		 * memory object.
+		 }
+
+const
+	KERN_MEMORY_DATA_MOVED = 24;
+		{ A page was requested of a memory manager via
+		 * memory_object_data_request for an object using
+		 * a MEMORY_OBJECT_COPY_CALL strategy, with the
+		 * VM_PROT_WANTS_COPY flag being used to specify
+		 * that the page desired is for a copy of the
+		 * object, and the memory manager has detected
+		 * the page was pushed into a copy of the object
+		 * while the kernel was walking the shadow chain
+		 * from the copy to the object. This error code
+		 * is delivered via memory_object_data_error
+		 * and is handled by the kernel (it forces the
+		 * kernel to restart the fault). It will not be
+		 * seen by users.
+		 }
+
+const
+	KERN_MEMORY_RESTART_COPY = 25;
+		{ A strategic copy was attempted of an object
+		 * upon which a quicker copy is now possible.
+		 * The caller should retry the copy using
+		 * vm_object_copy_quickly. This error code
+		 * is seen only by the kernel.
+		 }
+
+const
+	KERN_INVALID_PROCESSOR_SET = 26;
+		{ An argument applied to assert processor set privilege
+		 * was not a processor set control port.
+		 }
+
+const
+	KERN_POLICY_LIMIT = 27;
+		{ The specified scheduling attributes exceed the thread's
+		 * limits.
+		 }
+
+const
+	KERN_INVALID_POLICY = 28;
+		{ The specified scheduling policy is not currently
+		 * enabled for the processor set.
+		 }
+
+const
+	KERN_INVALID_OBJECT = 29;
+		{ The external memory manager failed to initialize the
+		 * memory object.
+		 }
+
+const
+	KERN_ALREADY_WAITING = 30;
+		{ A thread is attempting to wait for an event for which 
+		 * there is already a waiting thread.
+		 }
+
+const
+	KERN_DEFAULT_SET = 31;
+		{ An attempt was made to destroy the default processor
+		 * set.
+		 }
+
+const
+	KERN_EXCEPTION_PROTECTED = 32;
+		{ An attempt was made to fetch an exception port that is
+		 * protected, or to abort a thread while processing a
+		 * protected exception.
+		 }
+
+const
+	KERN_INVALID_LEDGER = 33;
+		{ A ledger was required but not supplied.
+		 }
+
+const
+	KERN_INVALID_MEMORY_CONTROL = 34;
+		{ The port was not a memory cache control port.
+		 }
+
+const
+	KERN_INVALID_SECURITY = 35;
+		{ An argument supplied to assert security privilege 	
+		 * was not a host security port.
+		 }
+		
+const
+	KERN_NOT_DEPRESSED = 36;
+		{ thread_depress_abort was called on a thread which
+		 * was not currently depressed.
+		 }
+		
+const
+	KERN_TERMINATED = 37;
+		{ Object has been terminated and is no longer available
+		 }
+
+const
+	KERN_LOCK_SET_DESTROYED = 38;
+		{ Lock set has been destroyed and is no longer available.
+		 }
+
+const
+	KERN_LOCK_UNSTABLE = 39;
+		{ The thread holding the lock terminated before releasing
+		 * the lock
+		 }
+
+const
+	KERN_LOCK_OWNED = 40;
+		{ The lock is already owned by another thread
+		 }
+
+const
+	KERN_LOCK_OWNED_SELF = 41;
+		{ The lock is already owned by the calling thread
+		 }
+
+const
+	KERN_SEMAPHORE_DESTROYED = 42;
+		{ Semaphore has been destroyed and is no longer available.
+		 }
+
+const
+	KERN_RPC_SERVER_TERMINATED = 43;
+		{ Return from RPC indicating the target server was 
+		 * terminated before it successfully replied 
+		 }
+
+const
+	KERN_RPC_TERMINATE_ORPHAN = 44;
+		{ Terminate an orphaned activation.
+		 }
+
+const
+	KERN_RPC_CONTINUE_ORPHAN = 45;
+		{ Allow an orphaned activation to continue executing.
+		 }
+
+const
+	KERN_NOT_SUPPORTED = 46;
+		{ Empty thread activation (No thread linked to it)
+		 }
+
+const
+	KERN_NODE_DOWN = 47;
+		{ Remote node down or inaccessible.
+		 }
+
+const
+	KERN_NOT_WAITING = 48;
+		{ A signalled thread was not actually waiting. }
+
+const
+	KERN_OPERATION_TIMED_OUT = 49;
+		{ Some thread-oriented operation (semaphore_wait) timed out
+		 }
+
+const
+	KERN_CODESIGN_ERROR = 50;
+		{ During a page fault, indicates that the page was rejected
+		 * as a result of a signature check.
+		 }
+
+const
+	KERN_RETURN_MAX = $100;
+		{ Maximum return value allowable
+		 }
+
+{ cpu-specific, but the same for ppc and x86 at least, both on 32 and 64 bit -> presumably also on ARM }
+type
+	kern_return_t = SInt32;
+{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
+
+end.
+{$endc} {not MACOSALLINCLUDE}

+ 320 - 0
packages/univint/src/mach_error.pas

@@ -0,0 +1,320 @@
+{
+ * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
+ * 
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
+ }
+{       Pascal Translation Updated:  Jonas Maebe, <[email protected]>, September 2010 }
+{
+    Modified for use with Free Pascal
+    Version 308
+    Please report any bugs to <[email protected]>
+}
+
+{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
+{$mode macpas}
+{$packenum 1}
+{$macro on}
+{$inline on}
+{$calling mwpascal}
+
+unit mach_error;
+interface
+{$setc UNIVERSAL_INTERFACES_VERSION := $0400}
+{$setc GAP_INTERFACES_VERSION := $0308}
+
+{$ifc not defined USE_CFSTR_CONSTANT_MACROS}
+    {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
+{$endc}
+
+{$ifc defined CPUPOWERPC and defined CPUI386}
+	{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
+{$endc}
+{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
+	{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
+{$endc}
+
+{$ifc not defined __ppc__ and defined CPUPOWERPC32}
+	{$setc __ppc__ := 1}
+{$elsec}
+	{$setc __ppc__ := 0}
+{$endc}
+{$ifc not defined __ppc64__ and defined CPUPOWERPC64}
+	{$setc __ppc64__ := 1}
+{$elsec}
+	{$setc __ppc64__ := 0}
+{$endc}
+{$ifc not defined __i386__ and defined CPUI386}
+	{$setc __i386__ := 1}
+{$elsec}
+	{$setc __i386__ := 0}
+{$endc}
+{$ifc not defined __x86_64__ and defined CPUX86_64}
+	{$setc __x86_64__ := 1}
+{$elsec}
+	{$setc __x86_64__ := 0}
+{$endc}
+{$ifc not defined __arm__ and defined CPUARM}
+	{$setc __arm__ := 1}
+{$elsec}
+	{$setc __arm__ := 0}
+{$endc}
+
+{$ifc defined cpu64}
+  {$setc __LP64__ := 1}
+{$elsec}
+  {$setc __LP64__ := 0}
+{$endc}
+
+
+{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
+	{$error Conflicting definitions for __ppc__ and __i386__}
+{$endc}
+
+{$ifc defined __ppc__ and __ppc__}
+	{$setc TARGET_CPU_PPC := TRUE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$elifc defined __ppc64__ and __ppc64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := TRUE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$elifc defined __i386__ and __i386__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := TRUE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+{$ifc defined(iphonesim)}
+ 	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
+{$elsec}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$endc}
+{$elifc defined __x86_64__ and __x86_64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := TRUE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$elifc defined __arm__ and __arm__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := TRUE}
+	{ will require compiler define when/if other Apple devices with ARM cpus ship }
+	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$elsec}
+	{$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ is defined.}
+{$endc}
+
+{$ifc defined __LP64__ and __LP64__ }
+  {$setc TARGET_CPU_64 := TRUE}
+{$elsec}
+  {$setc TARGET_CPU_64 := FALSE}
+{$endc}
+
+{$ifc defined FPC_BIG_ENDIAN}
+	{$setc TARGET_RT_BIG_ENDIAN := TRUE}
+	{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
+{$elifc defined FPC_LITTLE_ENDIAN}
+	{$setc TARGET_RT_BIG_ENDIAN := FALSE}
+	{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
+{$elsec}
+	{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
+{$endc}
+{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
+{$setc CALL_NOT_IN_CARBON := FALSE}
+{$setc OLDROUTINENAMES := FALSE}
+{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
+{$setc OPAQUE_UPP_TYPES := TRUE}
+{$setc OTCARBONAPPLICATION := TRUE}
+{$setc OTKERNEL := FALSE}
+{$setc PM_USE_SESSION_APIS := TRUE}
+{$setc TARGET_API_MAC_CARBON := TRUE}
+{$setc TARGET_API_MAC_OS8 := FALSE}
+{$setc TARGET_API_MAC_OSX := TRUE}
+{$setc TARGET_CARBON := TRUE}
+{$setc TARGET_CPU_68K := FALSE}
+{$setc TARGET_CPU_MIPS := FALSE}
+{$setc TARGET_CPU_SPARC := FALSE}
+{$setc TARGET_OS_UNIX := FALSE}
+{$setc TARGET_OS_WIN32 := FALSE}
+{$setc TARGET_RT_MAC_68881 := FALSE}
+{$setc TARGET_RT_MAC_CFM := FALSE}
+{$setc TARGET_RT_MAC_MACHO := TRUE}
+{$setc TYPED_FUNCTION_POINTERS := TRUE}
+{$setc TYPE_BOOL := FALSE}
+{$setc TYPE_EXTENDED := FALSE}
+{$setc TYPE_LONGLONG := TRUE}
+uses MacTypes,kern_return;
+{$endc} {not MACOSALLINCLUDE}
+
+
+{
+ * @OSF_COPYRIGHT@
+ }
+{ 
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
+ * All Rights Reserved.
+ * 
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ * 
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ * 
+ * Carnegie Mellon requests users of this software to return to
+ * 
+ *  Software Distribution Coordinator  or  [email protected]
+ *  School of Computer Science
+ *  Carnegie Mellon University
+ *  Pittsburgh PA 15213-3890
+ * 
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ }
+{
+ * File:	mach/error.h
+ * Purpose:
+ *	error module definitions
+ *
+ }
+
+type
+	mach_error_t = kern_return_t;
+	mach_error_fn_t = function: mach_error_t;
+
+{
+ *	error number layout as follows:
+ *
+ *	hi		 		       lo
+ *	| system(6) | subsystem(12) | code(14) |
+ }
+
+
+const
+  err_none	=	mach_error_t(0);
+  ERR_SUCCESS	=	mach_error_t(0);
+  ERR_ROUTINE_NIL	= nil;
+
+  system_emask = (((($3f) and $3f) shl 26));
+  sub_emask = (((($fff) and $fff) shl 14));
+	code_emask = $3fff;
+
+
+{	major error systems	}
+  err_kern = ((($0) and $3f) shl 26);		{ kernel }
+  err_us = ((($1) and $3f) shl 26);		{ user space library }
+  err_server = ((($2) and $3f) shl 26);		{ user space servers }
+  err_ipc = ((($3) and $3f) shl 26);		{ old ipc errors }
+  err_mach_ipc = ((($4) and $3f) shl 26);		{ mach-ipc errors }
+  err_dipc = ((($7) and $3f) shl 26);		{ distributed ipc }
+  err_local = ((($3e) and $3f) shl 26);	{ user defined errors }
+  err_ipc_compat = ((($3f) and $3f) shl 26);	{ (compatibility) mach-ipc errors }
+
+const
+	err_max_system = $3f;
+
+
+
+
+function err_system(x: mach_error_t): mach_error_t; inline;
+function err_sub(x: mach_error_t): mach_error_t; inline;
+
+function err_get_system(err: mach_error_t): mach_error_t; inline;
+function err_get_sub(err: mach_error_t): mach_error_t; inline;
+function err_get_code(err: mach_error_t): mach_error_t; inline;
+
+  {	unix errors get lumped into one subsystem  }
+function unix_err(errno: SInt32): mach_error_t; inline;
+
+{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
+implementation
+
+
+{$push}
+{$R-,Q-}
+
+function err_system(x: mach_error_t): mach_error_t; inline;
+begin
+  err_system:=(((x) and $3f) shl 26)
+end;
+
+function err_sub(x: mach_error_t): mach_error_t; inline;
+begin
+  err_sub:=(((x) shr 14) and $fff)
+end;
+
+
+function err_get_system(err: mach_error_t): mach_error_t; inline;
+begin
+  err_get_system:=(((err) shr 26) and $3f)
+end;
+
+function err_get_sub(err: mach_error_t): mach_error_t; inline;
+begin
+  err_get_sub:=(((err) shr 14) and $fff)
+end;
+
+function err_get_code(err: mach_error_t): mach_error_t; inline;
+begin
+  err_get_code:=((err) and $3fff)
+end;
+
+
+function unix_err(errno: SInt32): mach_error_t; inline;
+begin
+  unix_err:=err_kern or (((3) and $fff) shl 14) or errno;
+end;
+
+{$pop}
+
+end.
+
+{$endc} {not MACOSALLINCLUDE}

部分文件因为文件数量过多而无法显示