diff --git a/CMakeLists.txt b/CMakeLists.txt index 065c16e2c..d1cca2fd1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,5 +2,8 @@ project(darling) set(DARLING_TOP_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") +enable_language(ASM_NASM) add_subdirectory(src) +install(FILES etc/dylib.conf DESTINATION /etc/darling) + diff --git a/include/darwin/_types.h b/include/darwin/_types.h deleted file mode 100644 index 16ce25bda..000000000 --- a/include/darwin/_types.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. - * - * @APPLE_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. 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_LICENSE_HEADER_END@ - */ - -#ifndef __TYPES_H_ -#define __TYPES_H_ - -#include -//#include - -#if __GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ >= 7 -#define __strfmonlike(fmtarg, firstvararg) \ - __attribute__((__format__ (__strfmon__, fmtarg, firstvararg))) -#define __strftimelike(fmtarg) \ - __attribute__((__format__ (__strftime__, fmtarg, 0))) -#else -#define __strfmonlike(fmtarg, firstvararg) -#define __strftimelike(fmtarg) -#endif - -typedef int __darwin_nl_item; -typedef int __darwin_wctrans_t; -#ifdef __LP64__ -typedef uint32_t __darwin_wctype_t; -#else /* !__LP64__ */ -typedef unsigned long __darwin_wctype_t; -#endif /* __LP64__ */ - -#ifdef __WCHAR_MAX__ -#define __DARWIN_WCHAR_MAX __WCHAR_MAX__ -#else /* ! __WCHAR_MAX__ */ -#define __DARWIN_WCHAR_MAX 0x7fffffff -#endif /* __WCHAR_MAX__ */ - -#if __DARWIN_WCHAR_MAX > 0xffffU -#define __DARWIN_WCHAR_MIN (-0x7fffffff - 1) -#else -#define __DARWIN_WCHAR_MIN 0 -#endif -#define __DARWIN_WEOF ((__darwin_wint_t)-1) - -#ifndef _FORTIFY_SOURCE -# if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) < 1050) -# define _FORTIFY_SOURCE 0 -# else -# define _FORTIFY_SOURCE 2 /* on by default */ -# endif -#endif - -#endif /* __TYPES_H_ */ diff --git a/include/darwin/mac-ctype.h b/include/darwin/mac-ctype.h deleted file mode 100644 index 0e9166a47..000000000 --- a/include/darwin/mac-ctype.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2000, 2005, 2008 Apple Inc. All rights reserved. - * - * @APPLE_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. 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_LICENSE_HEADER_END@ - */ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * (c) UNIX System Laboratories, Inc. - * All or some portions of this file are derived from material licensed - * to the University of California by American Telephone and Telegraph - * Co. or Unix System Laboratories, Inc. and are reproduced herein with - * the permission of UNIX System Laboratories, Inc. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)ctype.h 8.4 (Berkeley) 1/21/94 - */ - -#ifndef MAC_CTYPE_H_ -#define MAC_CTYPE_H_ - -#define _CTYPE_A 0x00000100L /* Alpha */ -#define _CTYPE_C 0x00000200L /* Control */ -#define _CTYPE_D 0x00000400L /* Digit */ -#define _CTYPE_G 0x00000800L /* Graph */ -#define _CTYPE_L 0x00001000L /* Lower */ -#define _CTYPE_P 0x00002000L /* Punct */ -#define _CTYPE_S 0x00004000L /* Space */ -#define _CTYPE_U 0x00008000L /* Upper */ -#define _CTYPE_X 0x00010000L /* X digit */ -#define _CTYPE_B 0x00020000L /* Blank */ -#define _CTYPE_R 0x00040000L /* Print */ -#define _CTYPE_I 0x00080000L /* Ideogram */ -#define _CTYPE_T 0x00100000L /* Special */ -#define _CTYPE_Q 0x00200000L /* Phonogram */ - -/* - * Backward compatibility - */ -#define _A _CTYPE_A /* Alpha */ -#define _C _CTYPE_C /* Control */ -#define _D _CTYPE_D /* Digit */ -#define _G _CTYPE_G /* Graph */ -#define _L _CTYPE_L /* Lower */ -#define _P _CTYPE_P /* Punct */ -#define _S _CTYPE_S /* Space */ -#define _U _CTYPE_U /* Upper */ -#define _X _CTYPE_X /* X digit */ -#define _B _CTYPE_B /* Blank */ -#define _R _CTYPE_R /* Print */ -#define _I _CTYPE_I /* Ideogram */ -#define _T _CTYPE_T /* Special */ -#define _Q _CTYPE_Q /* Phonogram */ - -#endif /* !MAC_CTYPE_H_ */ diff --git a/include/darwin/mach-o/arm/reloc.h b/include/darwin/mach-o/arm/reloc.h deleted file mode 100644 index 2447814fd..000000000 --- a/include/darwin/mach-o/arm/reloc.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. - * - * @APPLE_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. 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_LICENSE_HEADER_END@ - */ -/* - * Relocation types used in the arm implementation. Relocation entries for - * things other than instructions use the same generic relocation as discribed - * in and their r_type is ARM_RELOC_VANILLA, one of the - * *_SECTDIFF or the *_PB_LA_PTR types. The rest of the relocation types are - * for instructions. Since they are for instructions the r_address field - * indicates the 32 bit instruction that the relocation is to be preformed on. - */ -enum reloc_type_arm -{ - ARM_RELOC_VANILLA, /* generic relocation as discribed above */ - ARM_RELOC_PAIR, /* the second relocation entry of a pair */ - ARM_RELOC_SECTDIFF, /* a PAIR follows with subtract symbol value */ - ARM_RELOC_LOCAL_SECTDIFF, /* like ARM_RELOC_SECTDIFF, but the symbol - referenced was local. */ - ARM_RELOC_PB_LA_PTR,/* prebound lazy pointer */ - ARM_RELOC_BR24, /* 24 bit branch displacement (to a word address) */ - ARM_THUMB_RELOC_BR22, /* 22 bit branch displacement (to a half-word - address) */ - ARM_THUMB_32BIT_BRANCH, /* obsolete - a thumb 32-bit branch instruction - possibly needing page-spanning branch workaround */ - - /* - * For these two r_type relocations they always have a pair following them - * and the r_length bits are used differently. The encoding of the - * r_length is as follows: - * low bit of r_length: - * 0 - :lower16: for movw instructions - * 1 - :upper16: for movt instructions - * high bit of r_length: - * 0 - arm instructions - * 1 - thumb instructions - * the other half of the relocated expression is in the following pair - * relocation entry in the the low 16 bits of r_address field. - */ - ARM_RELOC_HALF, - ARM_RELOC_HALF_SECTDIFF -}; diff --git a/include/darwin/mach-o/fat.h b/include/darwin/mach-o/fat.h deleted file mode 100644 index 51e13c78d..000000000 --- a/include/darwin/mach-o/fat.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. - * - * @APPLE_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. 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_LICENSE_HEADER_END@ - */ -#ifndef _MACH_O_FAT_H_ -#define _MACH_O_FAT_H_ -/* - * This header file describes the structures of the file format for "fat" - * architecture specific file (wrapper design). At the begining of the file - * there is one fat_header structure followed by a number of fat_arch - * structures. For each architecture in the file, specified by a pair of - * cputype and cpusubtype, the fat_header describes the file offset, file - * size and alignment in the file of the architecture specific member. - * The padded bytes in the file to place each member on it's specific alignment - * are defined to be read as zeros and can be left as "holes" if the file system - * can support them as long as they read as zeros. - * - * All structures defined here are always written and read to/from disk - * in big-endian order. - */ - -/* - * is needed here for the cpu_type_t and cpu_subtype_t types - * and contains the constants for the possible values of these types. - */ -#include -#include -//#include - -#define FAT_MAGIC 0xcafebabe -#define FAT_CIGAM 0xbebafeca /* NXSwapLong(FAT_MAGIC) */ - -struct fat_header { - uint32_t magic; /* FAT_MAGIC */ - uint32_t nfat_arch; /* number of structs that follow */ -}; - -struct fat_arch { - cpu_type_t cputype; /* cpu specifier (int) */ - cpu_subtype_t cpusubtype; /* machine specifier (int) */ - uint32_t offset; /* file offset to this object file */ - uint32_t size; /* size of this object file */ - uint32_t align; /* alignment as a power of 2 */ -}; - -#endif /* _MACH_O_FAT_H_ */ diff --git a/include/darwin/mach-o/loader.h b/include/darwin/mach-o/loader.h deleted file mode 100644 index f6b52b971..000000000 --- a/include/darwin/mach-o/loader.h +++ /dev/null @@ -1,1458 +0,0 @@ -/* - * Copyright (c) 1999-2010 Apple Inc. All Rights Reserved. - * - * @APPLE_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. 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_LICENSE_HEADER_END@ - */ -#ifndef _MACHO_LOADER_H_ -#define _MACHO_LOADER_H_ - -/* - * This file describes the format of mach object files. - */ -#include - -/* - * is needed here for the cpu_type_t and cpu_subtype_t types - * and contains the constants for the possible values of these types. - */ -#include - -/* - * is needed here for the vm_prot_t type and contains the - * constants that are or'ed together for the possible values of this type. - */ -#include - -/* - * is expected to define the flavors of the thread - * states and the structures of those flavors for each machine. - */ -//#include -//#include - -/* - * The 32-bit mach header appears at the very beginning of the object file for - * 32-bit architectures. - */ -struct mach_header { - uint32_t magic; /* mach magic number identifier */ - cpu_type_t cputype; /* cpu specifier */ - cpu_subtype_t cpusubtype; /* machine specifier */ - uint32_t filetype; /* type of file */ - uint32_t ncmds; /* number of load commands */ - uint32_t sizeofcmds; /* the size of all the load commands */ - uint32_t flags; /* flags */ -}; - -/* Constant for the magic field of the mach_header (32-bit architectures) */ -#define MH_MAGIC 0xfeedface /* the mach magic number */ -#define MH_CIGAM 0xcefaedfe /* NXSwapInt(MH_MAGIC) */ - -/* - * The 64-bit mach header appears at the very beginning of object files for - * 64-bit architectures. - */ -struct mach_header_64 { - uint32_t magic; /* mach magic number identifier */ - cpu_type_t cputype; /* cpu specifier */ - cpu_subtype_t cpusubtype; /* machine specifier */ - uint32_t filetype; /* type of file */ - uint32_t ncmds; /* number of load commands */ - uint32_t sizeofcmds; /* the size of all the load commands */ - uint32_t flags; /* flags */ - uint32_t reserved; /* reserved */ -}; - -/* Constant for the magic field of the mach_header_64 (64-bit architectures) */ -#define MH_MAGIC_64 0xfeedfacf /* the 64-bit mach magic number */ -#define MH_CIGAM_64 0xcffaedfe /* NXSwapInt(MH_MAGIC_64) */ - -/* - * The layout of the file depends on the filetype. For all but the MH_OBJECT - * file type the segments are padded out and aligned on a segment alignment - * boundary for efficient demand pageing. The MH_EXECUTE, MH_FVMLIB, MH_DYLIB, - * MH_DYLINKER and MH_BUNDLE file types also have the headers included as part - * of their first segment. - * - * The file type MH_OBJECT is a compact format intended as output of the - * assembler and input (and possibly output) of the link editor (the .o - * format). All sections are in one unnamed segment with no segment padding. - * This format is used as an executable format when the file is so small the - * segment padding greatly increases its size. - * - * The file type MH_PRELOAD is an executable format intended for things that - * are not executed under the kernel (proms, stand alones, kernels, etc). The - * format can be executed under the kernel but may demand paged it and not - * preload it before execution. - * - * A core file is in MH_CORE format and can be any in an arbritray legal - * Mach-O file. - * - * Constants for the filetype field of the mach_header - */ -#define MH_OBJECT 0x1 /* relocatable object file */ -#define MH_EXECUTE 0x2 /* demand paged executable file */ -#define MH_FVMLIB 0x3 /* fixed VM shared library file */ -#define MH_CORE 0x4 /* core file */ -#define MH_PRELOAD 0x5 /* preloaded executable file */ -#define MH_DYLIB 0x6 /* dynamically bound shared library */ -#define MH_DYLINKER 0x7 /* dynamic link editor */ -#define MH_BUNDLE 0x8 /* dynamically bound bundle file */ -#define MH_DYLIB_STUB 0x9 /* shared library stub for static */ - /* linking only, no section contents */ -#define MH_DSYM 0xa /* companion file with only debug */ - /* sections */ -#define MH_KEXT_BUNDLE 0xb /* x86_64 kexts */ - -/* Constants for the flags field of the mach_header */ -#define MH_NOUNDEFS 0x1 /* the object file has no undefined - references */ -#define MH_INCRLINK 0x2 /* the object file is the output of an - incremental link against a base file - and can't be link edited again */ -#define MH_DYLDLINK 0x4 /* the object file is input for the - dynamic linker and can't be staticly - link edited again */ -#define MH_BINDATLOAD 0x8 /* the object file's undefined - references are bound by the dynamic - linker when loaded. */ -#define MH_PREBOUND 0x10 /* the file has its dynamic undefined - references prebound. */ -#define MH_SPLIT_SEGS 0x20 /* the file has its read-only and - read-write segments split */ -#define MH_LAZY_INIT 0x40 /* the shared library init routine is - to be run lazily via catching memory - faults to its writeable segments - (obsolete) */ -#define MH_TWOLEVEL 0x80 /* the image is using two-level name - space bindings */ -#define MH_FORCE_FLAT 0x100 /* the executable is forcing all images - to use flat name space bindings */ -#define MH_NOMULTIDEFS 0x200 /* this umbrella guarantees no multiple - defintions of symbols in its - sub-images so the two-level namespace - hints can always be used. */ -#define MH_NOFIXPREBINDING 0x400 /* do not have dyld notify the - prebinding agent about this - executable */ -#define MH_PREBINDABLE 0x800 /* the binary is not prebound but can - have its prebinding redone. only used - when MH_PREBOUND is not set. */ -#define MH_ALLMODSBOUND 0x1000 /* indicates that this binary binds to - all two-level namespace modules of - its dependent libraries. only used - when MH_PREBINDABLE and MH_TWOLEVEL - are both set. */ -#define MH_SUBSECTIONS_VIA_SYMBOLS 0x2000/* safe to divide up the sections into - sub-sections via symbols for dead - code stripping */ -#define MH_CANONICAL 0x4000 /* the binary has been canonicalized - via the unprebind operation */ -#define MH_WEAK_DEFINES 0x8000 /* the final linked image contains - external weak symbols */ -#define MH_BINDS_TO_WEAK 0x10000 /* the final linked image uses - weak symbols */ - -#define MH_ALLOW_STACK_EXECUTION 0x20000/* When this bit is set, all stacks - in the task will be given stack - execution privilege. Only used in - MH_EXECUTE filetypes. */ -#define MH_ROOT_SAFE 0x40000 /* When this bit is set, the binary - declares it is safe for use in - processes with uid zero */ - -#define MH_SETUID_SAFE 0x80000 /* When this bit is set, the binary - declares it is safe for use in - processes when issetugid() is true */ - -#define MH_NO_REEXPORTED_DYLIBS 0x100000 /* When this bit is set on a dylib, - the static linker does not need to - examine dependent dylibs to see - if any are re-exported */ -#define MH_PIE 0x200000 /* When this bit is set, the OS will - load the main executable at a - random address. Only used in - MH_EXECUTE filetypes. */ -#define MH_DEAD_STRIPPABLE_DYLIB 0x400000 /* Only for use on dylibs. When - linking against a dylib that - has this bit set, the static linker - will automatically not create a - LC_LOAD_DYLIB load command to the - dylib if no symbols are being - referenced from the dylib. */ -#define MH_HAS_TLV_DESCRIPTORS 0x800000 /* Contains a section of type - S_THREAD_LOCAL_VARIABLES */ - -#define MH_NO_HEAP_EXECUTION 0x1000000 /* When this bit is set, the OS will - run the main executable with - a non-executable heap even on - platforms (e.g. i386) that don't - require it. Only used in MH_EXECUTE - filetypes. */ - -/* - * The load commands directly follow the mach_header. The total size of all - * of the commands is given by the sizeofcmds field in the mach_header. All - * load commands must have as their first two fields cmd and cmdsize. The cmd - * field is filled in with a constant for that command type. Each command type - * has a structure specifically for it. The cmdsize field is the size in bytes - * of the particular load command structure plus anything that follows it that - * is a part of the load command (i.e. section structures, strings, etc.). To - * advance to the next load command the cmdsize can be added to the offset or - * pointer of the current load command. The cmdsize for 32-bit architectures - * MUST be a multiple of 4 bytes and for 64-bit architectures MUST be a multiple - * of 8 bytes (these are forever the maximum alignment of any load commands). - * The padded bytes must be zero. All tables in the object file must also - * follow these rules so the file can be memory mapped. Otherwise the pointers - * to these tables will not work well or at all on some machines. With all - * padding zeroed like objects will compare byte for byte. - */ -struct load_command { - uint32_t cmd; /* type of load command */ - uint32_t cmdsize; /* total size of command in bytes */ -}; - -/* - * After MacOS X 10.1 when a new load command is added that is required to be - * understood by the dynamic linker for the image to execute properly the - * LC_REQ_DYLD bit will be or'ed into the load command constant. If the dynamic - * linker sees such a load command it it does not understand will issue a - * "unknown load command required for execution" error and refuse to use the - * image. Other load commands without this bit that are not understood will - * simply be ignored. - */ -#define LC_REQ_DYLD 0x80000000 - -/* Constants for the cmd field of all load commands, the type */ -#define LC_SEGMENT 0x1 /* segment of this file to be mapped */ -#define LC_SYMTAB 0x2 /* link-edit stab symbol table info */ -#define LC_SYMSEG 0x3 /* link-edit gdb symbol table info (obsolete) */ -#define LC_THREAD 0x4 /* thread */ -#define LC_UNIXTHREAD 0x5 /* unix thread (includes a stack) */ -#define LC_LOADFVMLIB 0x6 /* load a specified fixed VM shared library */ -#define LC_IDFVMLIB 0x7 /* fixed VM shared library identification */ -#define LC_IDENT 0x8 /* object identification info (obsolete) */ -#define LC_FVMFILE 0x9 /* fixed VM file inclusion (internal use) */ -#define LC_PREPAGE 0xa /* prepage command (internal use) */ -#define LC_DYSYMTAB 0xb /* dynamic link-edit symbol table info */ -#define LC_LOAD_DYLIB 0xc /* load a dynamically linked shared library */ -#define LC_ID_DYLIB 0xd /* dynamically linked shared lib ident */ -#define LC_LOAD_DYLINKER 0xe /* load a dynamic linker */ -#define LC_ID_DYLINKER 0xf /* dynamic linker identification */ -#define LC_PREBOUND_DYLIB 0x10 /* modules prebound for a dynamically */ - /* linked shared library */ -#define LC_ROUTINES 0x11 /* image routines */ -#define LC_SUB_FRAMEWORK 0x12 /* sub framework */ -#define LC_SUB_UMBRELLA 0x13 /* sub umbrella */ -#define LC_SUB_CLIENT 0x14 /* sub client */ -#define LC_SUB_LIBRARY 0x15 /* sub library */ -#define LC_TWOLEVEL_HINTS 0x16 /* two-level namespace lookup hints */ -#define LC_PREBIND_CKSUM 0x17 /* prebind checksum */ - -/* - * load a dynamically linked shared library that is allowed to be missing - * (all symbols are weak imported). - */ -#define LC_LOAD_WEAK_DYLIB (0x18 | LC_REQ_DYLD) - -#define LC_SEGMENT_64 0x19 /* 64-bit segment of this file to be - mapped */ -#define LC_ROUTINES_64 0x1a /* 64-bit image routines */ -#define LC_UUID 0x1b /* the uuid */ -#define LC_RPATH (0x1c | LC_REQ_DYLD) /* runpath additions */ -#define LC_CODE_SIGNATURE 0x1d /* local of code signature */ -#define LC_SEGMENT_SPLIT_INFO 0x1e /* local of info to split segments */ -#define LC_REEXPORT_DYLIB (0x1f | LC_REQ_DYLD) /* load and re-export dylib */ -#define LC_LAZY_LOAD_DYLIB 0x20 /* delay load of dylib until first use */ -#define LC_ENCRYPTION_INFO 0x21 /* encrypted segment information */ -#define LC_DYLD_INFO 0x22 /* compressed dyld information */ -#define LC_DYLD_INFO_ONLY (0x22|LC_REQ_DYLD) /* compressed dyld information only */ -#define LC_LOAD_UPWARD_DYLIB (0x23 | LC_REQ_DYLD) /* load upward dylib */ -#define LC_VERSION_MIN_MACOSX 0x24 /* build for MacOSX min OS version */ -#define LC_VERSION_MIN_IPHONEOS 0x25 /* build for iPhoneOS min OS version */ -#define LC_FUNCTION_STARTS 0x26 /* compressed table of function start addresses */ -#define LC_DYLD_ENVIRONMENT 0x27 /* string for dyld to treat - like environment variable */ -#define LC_MAIN (0x28|LC_REQ_DYLD) /* replacement for LC_UNIXTHREAD */ -#define LC_DATA_IN_CODE 0x29 /* table of non-instructions in __text */ -#define LC_SOURCE_VERSION 0x2A /* source version used to build binary */ -#define LC_DYLIB_CODE_SIGN_DRS 0x2B /* Code signing DRs copied from linked dylibs */ - - -/* - * A variable length string in a load command is represented by an lc_str - * union. The strings are stored just after the load command structure and - * the offset is from the start of the load command structure. The size - * of the string is reflected in the cmdsize field of the load command. - * Once again any padded bytes to bring the cmdsize field to a multiple - * of 4 bytes must be zero. - */ -union lc_str { - uint32_t offset; /* offset to the string */ -#ifndef __LP64__ - char *ptr; /* pointer to the string */ -#endif -}; - -/* - * The segment load command indicates that a part of this file is to be - * mapped into the task's address space. The size of this segment in memory, - * vmsize, maybe equal to or larger than the amount to map from this file, - * filesize. The file is mapped starting at fileoff to the beginning of - * the segment in memory, vmaddr. The rest of the memory of the segment, - * if any, is allocated zero fill on demand. The segment's maximum virtual - * memory protection and initial virtual memory protection are specified - * by the maxprot and initprot fields. If the segment has sections then the - * section structures directly follow the segment command and their size is - * reflected in cmdsize. - */ -struct segment_command { /* for 32-bit architectures */ - uint32_t cmd; /* LC_SEGMENT */ - uint32_t cmdsize; /* includes sizeof section structs */ - char segname[16]; /* segment name */ - uint32_t vmaddr; /* memory address of this segment */ - uint32_t vmsize; /* memory size of this segment */ - uint32_t fileoff; /* file offset of this segment */ - uint32_t filesize; /* amount to map from the file */ - vm_prot_t maxprot; /* maximum VM protection */ - vm_prot_t initprot; /* initial VM protection */ - uint32_t nsects; /* number of sections in segment */ - uint32_t flags; /* flags */ -}; - -/* - * The 64-bit segment load command indicates that a part of this file is to be - * mapped into a 64-bit task's address space. If the 64-bit segment has - * sections then section_64 structures directly follow the 64-bit segment - * command and their size is reflected in cmdsize. - */ -struct segment_command_64 { /* for 64-bit architectures */ - uint32_t cmd; /* LC_SEGMENT_64 */ - uint32_t cmdsize; /* includes sizeof section_64 structs */ - char segname[16]; /* segment name */ - uint64_t vmaddr; /* memory address of this segment */ - uint64_t vmsize; /* memory size of this segment */ - uint64_t fileoff; /* file offset of this segment */ - uint64_t filesize; /* amount to map from the file */ - vm_prot_t maxprot; /* maximum VM protection */ - vm_prot_t initprot; /* initial VM protection */ - uint32_t nsects; /* number of sections in segment */ - uint32_t flags; /* flags */ -}; - -/* Constants for the flags field of the segment_command */ -#define SG_HIGHVM 0x1 /* the file contents for this segment is for - the high part of the VM space, the low part - is zero filled (for stacks in core files) */ -#define SG_FVMLIB 0x2 /* this segment is the VM that is allocated by - a fixed VM library, for overlap checking in - the link editor */ -#define SG_NORELOC 0x4 /* this segment has nothing that was relocated - in it and nothing relocated to it, that is - it maybe safely replaced without relocation*/ -#define SG_PROTECTED_VERSION_1 0x8 /* This segment is protected. If the - segment starts at file offset 0, the - first page of the segment is not - protected. All other pages of the - segment are protected. */ - -/* - * A segment is made up of zero or more sections. Non-MH_OBJECT files have - * all of their segments with the proper sections in each, and padded to the - * specified segment alignment when produced by the link editor. The first - * segment of a MH_EXECUTE and MH_FVMLIB format file contains the mach_header - * and load commands of the object file before its first section. The zero - * fill sections are always last in their segment (in all formats). This - * allows the zeroed segment padding to be mapped into memory where zero fill - * sections might be. The gigabyte zero fill sections, those with the section - * type S_GB_ZEROFILL, can only be in a segment with sections of this type. - * These segments are then placed after all other segments. - * - * The MH_OBJECT format has all of its sections in one segment for - * compactness. There is no padding to a specified segment boundary and the - * mach_header and load commands are not part of the segment. - * - * Sections with the same section name, sectname, going into the same segment, - * segname, are combined by the link editor. The resulting section is aligned - * to the maximum alignment of the combined sections and is the new section's - * alignment. The combined sections are aligned to their original alignment in - * the combined section. Any padded bytes to get the specified alignment are - * zeroed. - * - * The format of the relocation entries referenced by the reloff and nreloc - * fields of the section structure for mach object files is described in the - * header file . - */ -struct section { /* for 32-bit architectures */ - char sectname[16]; /* name of this section */ - char segname[16]; /* segment this section goes in */ - uint32_t addr; /* memory address of this section */ - uint32_t size; /* size in bytes of this section */ - uint32_t offset; /* file offset of this section */ - uint32_t align; /* section alignment (power of 2) */ - uint32_t reloff; /* file offset of relocation entries */ - uint32_t nreloc; /* number of relocation entries */ - uint32_t flags; /* flags (section type and attributes)*/ - uint32_t reserved1; /* reserved (for offset or index) */ - uint32_t reserved2; /* reserved (for count or sizeof) */ -}; - -struct section_64 { /* for 64-bit architectures */ - char sectname[16]; /* name of this section */ - char segname[16]; /* segment this section goes in */ - uint64_t addr; /* memory address of this section */ - uint64_t size; /* size in bytes of this section */ - uint32_t offset; /* file offset of this section */ - uint32_t align; /* section alignment (power of 2) */ - uint32_t reloff; /* file offset of relocation entries */ - uint32_t nreloc; /* number of relocation entries */ - uint32_t flags; /* flags (section type and attributes)*/ - uint32_t reserved1; /* reserved (for offset or index) */ - uint32_t reserved2; /* reserved (for count or sizeof) */ - uint32_t reserved3; /* reserved */ -}; - -/* - * The flags field of a section structure is separated into two parts a section - * type and section attributes. The section types are mutually exclusive (it - * can only have one type) but the section attributes are not (it may have more - * than one attribute). - */ -#define SECTION_TYPE 0x000000ff /* 256 section types */ -#define SECTION_ATTRIBUTES 0xffffff00 /* 24 section attributes */ - -/* Constants for the type of a section */ -#define S_REGULAR 0x0 /* regular section */ -#define S_ZEROFILL 0x1 /* zero fill on demand section */ -#define S_CSTRING_LITERALS 0x2 /* section with only literal C strings*/ -#define S_4BYTE_LITERALS 0x3 /* section with only 4 byte literals */ -#define S_8BYTE_LITERALS 0x4 /* section with only 8 byte literals */ -#define S_LITERAL_POINTERS 0x5 /* section with only pointers to */ - /* literals */ -/* - * For the two types of symbol pointers sections and the symbol stubs section - * they have indirect symbol table entries. For each of the entries in the - * section the indirect symbol table entries, in corresponding order in the - * indirect symbol table, start at the index stored in the reserved1 field - * of the section structure. Since the indirect symbol table entries - * correspond to the entries in the section the number of indirect symbol table - * entries is inferred from the size of the section divided by the size of the - * entries in the section. For symbol pointers sections the size of the entries - * in the section is 4 bytes and for symbol stubs sections the byte size of the - * stubs is stored in the reserved2 field of the section structure. - */ -#define S_NON_LAZY_SYMBOL_POINTERS 0x6 /* section with only non-lazy - symbol pointers */ -#define S_LAZY_SYMBOL_POINTERS 0x7 /* section with only lazy symbol - pointers */ -#define S_SYMBOL_STUBS 0x8 /* section with only symbol - stubs, byte size of stub in - the reserved2 field */ -#define S_MOD_INIT_FUNC_POINTERS 0x9 /* section with only function - pointers for initialization*/ -#define S_MOD_TERM_FUNC_POINTERS 0xa /* section with only function - pointers for termination */ -#define S_COALESCED 0xb /* section contains symbols that - are to be coalesced */ -#define S_GB_ZEROFILL 0xc /* zero fill on demand section - (that can be larger than 4 - gigabytes) */ -#define S_INTERPOSING 0xd /* section with only pairs of - function pointers for - interposing */ -#define S_16BYTE_LITERALS 0xe /* section with only 16 byte - literals */ -#define S_DTRACE_DOF 0xf /* section contains - DTrace Object Format */ -#define S_LAZY_DYLIB_SYMBOL_POINTERS 0x10 /* section with only lazy - symbol pointers to lazy - loaded dylibs */ -/* - * Section types to support thread local variables - */ -#define S_THREAD_LOCAL_REGULAR 0x11 /* template of initial - values for TLVs */ -#define S_THREAD_LOCAL_ZEROFILL 0x12 /* template of initial - values for TLVs */ -#define S_THREAD_LOCAL_VARIABLES 0x13 /* TLV descriptors */ -#define S_THREAD_LOCAL_VARIABLE_POINTERS 0x14 /* pointers to TLV - descriptors */ -#define S_THREAD_LOCAL_INIT_FUNCTION_POINTERS 0x15 /* functions to call - to initialize TLV - values */ - -/* - * Constants for the section attributes part of the flags field of a section - * structure. - */ -#define SECTION_ATTRIBUTES_USR 0xff000000 /* User setable attributes */ -#define S_ATTR_PURE_INSTRUCTIONS 0x80000000 /* section contains only true - machine instructions */ -#define S_ATTR_NO_TOC 0x40000000 /* section contains coalesced - symbols that are not to be - in a ranlib table of - contents */ -#define S_ATTR_STRIP_STATIC_SYMS 0x20000000 /* ok to strip static symbols - in this section in files - with the MH_DYLDLINK flag */ -#define S_ATTR_NO_DEAD_STRIP 0x10000000 /* no dead stripping */ -#define S_ATTR_LIVE_SUPPORT 0x08000000 /* blocks are live if they - reference live blocks */ -#define S_ATTR_SELF_MODIFYING_CODE 0x04000000 /* Used with i386 code stubs - written on by dyld */ -/* - * If a segment contains any sections marked with S_ATTR_DEBUG then all - * sections in that segment must have this attribute. No section other than - * a section marked with this attribute may reference the contents of this - * section. A section with this attribute may contain no symbols and must have - * a section type S_REGULAR. The static linker will not copy section contents - * from sections with this attribute into its output file. These sections - * generally contain DWARF debugging info. - */ -#define S_ATTR_DEBUG 0x02000000 /* a debug section */ -#define SECTION_ATTRIBUTES_SYS 0x00ffff00 /* system setable attributes */ -#define S_ATTR_SOME_INSTRUCTIONS 0x00000400 /* section contains some - machine instructions */ -#define S_ATTR_EXT_RELOC 0x00000200 /* section has external - relocation entries */ -#define S_ATTR_LOC_RELOC 0x00000100 /* section has local - relocation entries */ - - -/* - * The names of segments and sections in them are mostly meaningless to the - * link-editor. But there are few things to support traditional UNIX - * executables that require the link-editor and assembler to use some names - * agreed upon by convention. - * - * The initial protection of the "__TEXT" segment has write protection turned - * off (not writeable). - * - * The link-editor will allocate common symbols at the end of the "__common" - * section in the "__DATA" segment. It will create the section and segment - * if needed. - */ - -/* The currently known segment names and the section names in those segments */ - -#define SEG_PAGEZERO "__PAGEZERO" /* the pagezero segment which has no */ - /* protections and catches NULL */ - /* references for MH_EXECUTE files */ - - -#define SEG_TEXT "__TEXT" /* the tradition UNIX text segment */ -#define SECT_TEXT "__text" /* the real text part of the text */ - /* section no headers, and no padding */ -#define SECT_FVMLIB_INIT0 "__fvmlib_init0" /* the fvmlib initialization */ - /* section */ -#define SECT_FVMLIB_INIT1 "__fvmlib_init1" /* the section following the */ - /* fvmlib initialization */ - /* section */ - -#define SEG_DATA "__DATA" /* the tradition UNIX data segment */ -#define SECT_DATA "__data" /* the real initialized data section */ - /* no padding, no bss overlap */ -#define SECT_BSS "__bss" /* the real uninitialized data section*/ - /* no padding */ -#define SECT_COMMON "__common" /* the section common symbols are */ - /* allocated in by the link editor */ - -#define SEG_OBJC "__OBJC" /* objective-C runtime segment */ -#define SECT_OBJC_SYMBOLS "__symbol_table" /* symbol table */ -#define SECT_OBJC_MODULES "__module_info" /* module information */ -#define SECT_OBJC_STRINGS "__selector_strs" /* string table */ -#define SECT_OBJC_REFS "__selector_refs" /* string table */ - -#define SEG_ICON "__ICON" /* the icon segment */ -#define SECT_ICON_HEADER "__header" /* the icon headers */ -#define SECT_ICON_TIFF "__tiff" /* the icons in tiff format */ - -#define SEG_LINKEDIT "__LINKEDIT" /* the segment containing all structs */ - /* created and maintained by the link */ - /* editor. Created with -seglinkedit */ - /* option to ld(1) for MH_EXECUTE and */ - /* FVMLIB file types only */ - -#define SEG_UNIXSTACK "__UNIXSTACK" /* the unix stack segment */ - -#define SEG_IMPORT "__IMPORT" /* the segment for the self (dyld) */ - /* modifing code stubs that has read, */ - /* write and execute permissions */ - -/* - * Fixed virtual memory shared libraries are identified by two things. The - * target pathname (the name of the library as found for execution), and the - * minor version number. The address of where the headers are loaded is in - * header_addr. (THIS IS OBSOLETE and no longer supported). - */ -struct fvmlib { - union lc_str name; /* library's target pathname */ - uint32_t minor_version; /* library's minor version number */ - uint32_t header_addr; /* library's header address */ -}; - -/* - * A fixed virtual shared library (filetype == MH_FVMLIB in the mach header) - * contains a fvmlib_command (cmd == LC_IDFVMLIB) to identify the library. - * An object that uses a fixed virtual shared library also contains a - * fvmlib_command (cmd == LC_LOADFVMLIB) for each library it uses. - * (THIS IS OBSOLETE and no longer supported). - */ -struct fvmlib_command { - uint32_t cmd; /* LC_IDFVMLIB or LC_LOADFVMLIB */ - uint32_t cmdsize; /* includes pathname string */ - struct fvmlib fvmlib; /* the library identification */ -}; - -/* - * Dynamicly linked shared libraries are identified by two things. The - * pathname (the name of the library as found for execution), and the - * compatibility version number. The pathname must match and the compatibility - * number in the user of the library must be greater than or equal to the - * library being used. The time stamp is used to record the time a library was - * built and copied into user so it can be use to determined if the library used - * at runtime is exactly the same as used to built the program. - */ -struct dylib { - union lc_str name; /* library's path name */ - uint32_t timestamp; /* library's build time stamp */ - uint32_t current_version; /* library's current version number */ - uint32_t compatibility_version; /* library's compatibility vers number*/ -}; - -/* - * A dynamically linked shared library (filetype == MH_DYLIB in the mach header) - * contains a dylib_command (cmd == LC_ID_DYLIB) to identify the library. - * An object that uses a dynamically linked shared library also contains a - * dylib_command (cmd == LC_LOAD_DYLIB, LC_LOAD_WEAK_DYLIB, or - * LC_REEXPORT_DYLIB) for each library it uses. - */ -struct dylib_command { - uint32_t cmd; /* LC_ID_DYLIB, LC_LOAD_{,WEAK_}DYLIB, - LC_REEXPORT_DYLIB */ - uint32_t cmdsize; /* includes pathname string */ - struct dylib dylib; /* the library identification */ -}; - -/* - * A dynamically linked shared library may be a subframework of an umbrella - * framework. If so it will be linked with "-umbrella umbrella_name" where - * Where "umbrella_name" is the name of the umbrella framework. A subframework - * can only be linked against by its umbrella framework or other subframeworks - * that are part of the same umbrella framework. Otherwise the static link - * editor produces an error and states to link against the umbrella framework. - * The name of the umbrella framework for subframeworks is recorded in the - * following structure. - */ -struct sub_framework_command { - uint32_t cmd; /* LC_SUB_FRAMEWORK */ - uint32_t cmdsize; /* includes umbrella string */ - union lc_str umbrella; /* the umbrella framework name */ -}; - -/* - * For dynamically linked shared libraries that are subframework of an umbrella - * framework they can allow clients other than the umbrella framework or other - * subframeworks in the same umbrella framework. To do this the subframework - * is built with "-allowable_client client_name" and an LC_SUB_CLIENT load - * command is created for each -allowable_client flag. The client_name is - * usually a framework name. It can also be a name used for bundles clients - * where the bundle is built with "-client_name client_name". - */ -struct sub_client_command { - uint32_t cmd; /* LC_SUB_CLIENT */ - uint32_t cmdsize; /* includes client string */ - union lc_str client; /* the client name */ -}; - -/* - * A dynamically linked shared library may be a sub_umbrella of an umbrella - * framework. If so it will be linked with "-sub_umbrella umbrella_name" where - * Where "umbrella_name" is the name of the sub_umbrella framework. When - * staticly linking when -twolevel_namespace is in effect a twolevel namespace - * umbrella framework will only cause its subframeworks and those frameworks - * listed as sub_umbrella frameworks to be implicited linked in. Any other - * dependent dynamic libraries will not be linked it when -twolevel_namespace - * is in effect. The primary library recorded by the static linker when - * resolving a symbol in these libraries will be the umbrella framework. - * Zero or more sub_umbrella frameworks may be use by an umbrella framework. - * The name of a sub_umbrella framework is recorded in the following structure. - */ -struct sub_umbrella_command { - uint32_t cmd; /* LC_SUB_UMBRELLA */ - uint32_t cmdsize; /* includes sub_umbrella string */ - union lc_str sub_umbrella; /* the sub_umbrella framework name */ -}; - -/* - * A dynamically linked shared library may be a sub_library of another shared - * library. If so it will be linked with "-sub_library library_name" where - * Where "library_name" is the name of the sub_library shared library. When - * staticly linking when -twolevel_namespace is in effect a twolevel namespace - * shared library will only cause its subframeworks and those frameworks - * listed as sub_umbrella frameworks and libraries listed as sub_libraries to - * be implicited linked in. Any other dependent dynamic libraries will not be - * linked it when -twolevel_namespace is in effect. The primary library - * recorded by the static linker when resolving a symbol in these libraries - * will be the umbrella framework (or dynamic library). Zero or more sub_library - * shared libraries may be use by an umbrella framework or (or dynamic library). - * The name of a sub_library framework is recorded in the following structure. - * For example /usr/lib/libobjc_profile.A.dylib would be recorded as "libobjc". - */ -struct sub_library_command { - uint32_t cmd; /* LC_SUB_LIBRARY */ - uint32_t cmdsize; /* includes sub_library string */ - union lc_str sub_library; /* the sub_library name */ -}; - -/* - * A program (filetype == MH_EXECUTE) that is - * prebound to its dynamic libraries has one of these for each library that - * the static linker used in prebinding. It contains a bit vector for the - * modules in the library. The bits indicate which modules are bound (1) and - * which are not (0) from the library. The bit for module 0 is the low bit - * of the first byte. So the bit for the Nth module is: - * (linked_modules[N/8] >> N%8) & 1 - */ -struct prebound_dylib_command { - uint32_t cmd; /* LC_PREBOUND_DYLIB */ - uint32_t cmdsize; /* includes strings */ - union lc_str name; /* library's path name */ - uint32_t nmodules; /* number of modules in library */ - union lc_str linked_modules; /* bit vector of linked modules */ -}; - -/* - * A program that uses a dynamic linker contains a dylinker_command to identify - * the name of the dynamic linker (LC_LOAD_DYLINKER). And a dynamic linker - * contains a dylinker_command to identify the dynamic linker (LC_ID_DYLINKER). - * A file can have at most one of these. - * This struct is also used for the LC_DYLD_ENVIRONMENT load command and - * contains string for dyld to treat like environment variable. - */ -struct dylinker_command { - uint32_t cmd; /* LC_ID_DYLINKER, LC_LOAD_DYLINKER or - LC_DYLD_ENVIRONMENT */ - uint32_t cmdsize; /* includes pathname string */ - union lc_str name; /* dynamic linker's path name */ -}; - -/* - * Thread commands contain machine-specific data structures suitable for - * use in the thread state primitives. The machine specific data structures - * follow the struct thread_command as follows. - * Each flavor of machine specific data structure is preceded by an unsigned - * long constant for the flavor of that data structure, an uint32_t - * that is the count of longs of the size of the state data structure and then - * the state data structure follows. This triple may be repeated for many - * flavors. The constants for the flavors, counts and state data structure - * definitions are expected to be in the header file . - * These machine specific data structures sizes must be multiples of - * 4 bytes The cmdsize reflects the total size of the thread_command - * and all of the sizes of the constants for the flavors, counts and state - * data structures. - * - * For executable objects that are unix processes there will be one - * thread_command (cmd == LC_UNIXTHREAD) created for it by the link-editor. - * This is the same as a LC_THREAD, except that a stack is automatically - * created (based on the shell's limit for the stack size). Command arguments - * and environment variables are copied onto that stack. - */ -struct thread_command { - uint32_t cmd; /* LC_THREAD or LC_UNIXTHREAD */ - uint32_t cmdsize; /* total size of this command */ - /* uint32_t flavor flavor of thread state */ - /* uint32_t count count of longs in thread state */ - /* struct XXX_thread_state state thread state for this flavor */ - /* ... */ -}; - -/* - * The routines command contains the address of the dynamic shared library - * initialization routine and an index into the module table for the module - * that defines the routine. Before any modules are used from the library the - * dynamic linker fully binds the module that defines the initialization routine - * and then calls it. This gets called before any module initialization - * routines (used for C++ static constructors) in the library. - */ -struct routines_command { /* for 32-bit architectures */ - uint32_t cmd; /* LC_ROUTINES */ - uint32_t cmdsize; /* total size of this command */ - uint32_t init_address; /* address of initialization routine */ - uint32_t init_module; /* index into the module table that */ - /* the init routine is defined in */ - uint32_t reserved1; - uint32_t reserved2; - uint32_t reserved3; - uint32_t reserved4; - uint32_t reserved5; - uint32_t reserved6; -}; - -/* - * The 64-bit routines command. Same use as above. - */ -struct routines_command_64 { /* for 64-bit architectures */ - uint32_t cmd; /* LC_ROUTINES_64 */ - uint32_t cmdsize; /* total size of this command */ - uint64_t init_address; /* address of initialization routine */ - uint64_t init_module; /* index into the module table that */ - /* the init routine is defined in */ - uint64_t reserved1; - uint64_t reserved2; - uint64_t reserved3; - uint64_t reserved4; - uint64_t reserved5; - uint64_t reserved6; -}; - -/* - * The symtab_command contains the offsets and sizes of the link-edit 4.3BSD - * "stab" style symbol table information as described in the header files - * and . - */ -struct symtab_command { - uint32_t cmd; /* LC_SYMTAB */ - uint32_t cmdsize; /* sizeof(struct symtab_command) */ - uint32_t symoff; /* symbol table offset */ - uint32_t nsyms; /* number of symbol table entries */ - uint32_t stroff; /* string table offset */ - uint32_t strsize; /* string table size in bytes */ -}; - -/* - * This is the second set of the symbolic information which is used to support - * the data structures for the dynamically link editor. - * - * The original set of symbolic information in the symtab_command which contains - * the symbol and string tables must also be present when this load command is - * present. When this load command is present the symbol table is organized - * into three groups of symbols: - * local symbols (static and debugging symbols) - grouped by module - * defined external symbols - grouped by module (sorted by name if not lib) - * undefined external symbols (sorted by name if MH_BINDATLOAD is not set, - * and in order the were seen by the static - * linker if MH_BINDATLOAD is set) - * In this load command there are offsets and counts to each of the three groups - * of symbols. - * - * This load command contains a the offsets and sizes of the following new - * symbolic information tables: - * table of contents - * module table - * reference symbol table - * indirect symbol table - * The first three tables above (the table of contents, module table and - * reference symbol table) are only present if the file is a dynamically linked - * shared library. For executable and object modules, which are files - * containing only one module, the information that would be in these three - * tables is determined as follows: - * table of contents - the defined external symbols are sorted by name - * module table - the file contains only one module so everything in the - * file is part of the module. - * reference symbol table - is the defined and undefined external symbols - * - * For dynamically linked shared library files this load command also contains - * offsets and sizes to the pool of relocation entries for all sections - * separated into two groups: - * external relocation entries - * local relocation entries - * For executable and object modules the relocation entries continue to hang - * off the section structures. - */ -struct dysymtab_command { - uint32_t cmd; /* LC_DYSYMTAB */ - uint32_t cmdsize; /* sizeof(struct dysymtab_command) */ - - /* - * The symbols indicated by symoff and nsyms of the LC_SYMTAB load command - * are grouped into the following three groups: - * local symbols (further grouped by the module they are from) - * defined external symbols (further grouped by the module they are from) - * undefined symbols - * - * The local symbols are used only for debugging. The dynamic binding - * process may have to use them to indicate to the debugger the local - * symbols for a module that is being bound. - * - * The last two groups are used by the dynamic binding process to do the - * binding (indirectly through the module table and the reference symbol - * table when this is a dynamically linked shared library file). - */ - uint32_t ilocalsym; /* index to local symbols */ - uint32_t nlocalsym; /* number of local symbols */ - - uint32_t iextdefsym;/* index to externally defined symbols */ - uint32_t nextdefsym;/* number of externally defined symbols */ - - uint32_t iundefsym; /* index to undefined symbols */ - uint32_t nundefsym; /* number of undefined symbols */ - - /* - * For the for the dynamic binding process to find which module a symbol - * is defined in the table of contents is used (analogous to the ranlib - * structure in an archive) which maps defined external symbols to modules - * they are defined in. This exists only in a dynamically linked shared - * library file. For executable and object modules the defined external - * symbols are sorted by name and is use as the table of contents. - */ - uint32_t tocoff; /* file offset to table of contents */ - uint32_t ntoc; /* number of entries in table of contents */ - - /* - * To support dynamic binding of "modules" (whole object files) the symbol - * table must reflect the modules that the file was created from. This is - * done by having a module table that has indexes and counts into the merged - * tables for each module. The module structure that these two entries - * refer to is described below. This exists only in a dynamically linked - * shared library file. For executable and object modules the file only - * contains one module so everything in the file belongs to the module. - */ - uint32_t modtaboff; /* file offset to module table */ - uint32_t nmodtab; /* number of module table entries */ - - /* - * To support dynamic module binding the module structure for each module - * indicates the external references (defined and undefined) each module - * makes. For each module there is an offset and a count into the - * reference symbol table for the symbols that the module references. - * This exists only in a dynamically linked shared library file. For - * executable and object modules the defined external symbols and the - * undefined external symbols indicates the external references. - */ - uint32_t extrefsymoff; /* offset to referenced symbol table */ - uint32_t nextrefsyms; /* number of referenced symbol table entries */ - - /* - * The sections that contain "symbol pointers" and "routine stubs" have - * indexes and (implied counts based on the size of the section and fixed - * size of the entry) into the "indirect symbol" table for each pointer - * and stub. For every section of these two types the index into the - * indirect symbol table is stored in the section header in the field - * reserved1. An indirect symbol table entry is simply a 32bit index into - * the symbol table to the symbol that the pointer or stub is referring to. - * The indirect symbol table is ordered to match the entries in the section. - */ - uint32_t indirectsymoff; /* file offset to the indirect symbol table */ - uint32_t nindirectsyms; /* number of indirect symbol table entries */ - - /* - * To support relocating an individual module in a library file quickly the - * external relocation entries for each module in the library need to be - * accessed efficiently. Since the relocation entries can't be accessed - * through the section headers for a library file they are separated into - * groups of local and external entries further grouped by module. In this - * case the presents of this load command who's extreloff, nextrel, - * locreloff and nlocrel fields are non-zero indicates that the relocation - * entries of non-merged sections are not referenced through the section - * structures (and the reloff and nreloc fields in the section headers are - * set to zero). - * - * Since the relocation entries are not accessed through the section headers - * this requires the r_address field to be something other than a section - * offset to identify the item to be relocated. In this case r_address is - * set to the offset from the vmaddr of the first LC_SEGMENT command. - * For MH_SPLIT_SEGS images r_address is set to the the offset from the - * vmaddr of the first read-write LC_SEGMENT command. - * - * The relocation entries are grouped by module and the module table - * entries have indexes and counts into them for the group of external - * relocation entries for that the module. - * - * For sections that are merged across modules there must not be any - * remaining external relocation entries for them (for merged sections - * remaining relocation entries must be local). - */ - uint32_t extreloff; /* offset to external relocation entries */ - uint32_t nextrel; /* number of external relocation entries */ - - /* - * All the local relocation entries are grouped together (they are not - * grouped by their module since they are only used if the object is moved - * from it staticly link edited address). - */ - uint32_t locreloff; /* offset to local relocation entries */ - uint32_t nlocrel; /* number of local relocation entries */ - -}; - -/* - * An indirect symbol table entry is simply a 32bit index into the symbol table - * to the symbol that the pointer or stub is refering to. Unless it is for a - * non-lazy symbol pointer section for a defined symbol which strip(1) as - * removed. In which case it has the value INDIRECT_SYMBOL_LOCAL. If the - * symbol was also absolute INDIRECT_SYMBOL_ABS is or'ed with that. - */ -#define INDIRECT_SYMBOL_LOCAL 0x80000000 -#define INDIRECT_SYMBOL_ABS 0x40000000 - - -/* a table of contents entry */ -struct dylib_table_of_contents { - uint32_t symbol_index; /* the defined external symbol - (index into the symbol table) */ - uint32_t module_index; /* index into the module table this symbol - is defined in */ -}; - -/* a module table entry */ -struct dylib_module { - uint32_t module_name; /* the module name (index into string table) */ - - uint32_t iextdefsym; /* index into externally defined symbols */ - uint32_t nextdefsym; /* number of externally defined symbols */ - uint32_t irefsym; /* index into reference symbol table */ - uint32_t nrefsym; /* number of reference symbol table entries */ - uint32_t ilocalsym; /* index into symbols for local symbols */ - uint32_t nlocalsym; /* number of local symbols */ - - uint32_t iextrel; /* index into external relocation entries */ - uint32_t nextrel; /* number of external relocation entries */ - - uint32_t iinit_iterm; /* low 16 bits are the index into the init - section, high 16 bits are the index into - the term section */ - uint32_t ninit_nterm; /* low 16 bits are the number of init section - entries, high 16 bits are the number of - term section entries */ - - uint32_t /* for this module address of the start of */ - objc_module_info_addr; /* the (__OBJC,__module_info) section */ - uint32_t /* for this module size of */ - objc_module_info_size; /* the (__OBJC,__module_info) section */ -}; - -/* a 64-bit module table entry */ -struct dylib_module_64 { - uint32_t module_name; /* the module name (index into string table) */ - - uint32_t iextdefsym; /* index into externally defined symbols */ - uint32_t nextdefsym; /* number of externally defined symbols */ - uint32_t irefsym; /* index into reference symbol table */ - uint32_t nrefsym; /* number of reference symbol table entries */ - uint32_t ilocalsym; /* index into symbols for local symbols */ - uint32_t nlocalsym; /* number of local symbols */ - - uint32_t iextrel; /* index into external relocation entries */ - uint32_t nextrel; /* number of external relocation entries */ - - uint32_t iinit_iterm; /* low 16 bits are the index into the init - section, high 16 bits are the index into - the term section */ - uint32_t ninit_nterm; /* low 16 bits are the number of init section - entries, high 16 bits are the number of - term section entries */ - - uint32_t /* for this module size of */ - objc_module_info_size; /* the (__OBJC,__module_info) section */ - uint64_t /* for this module address of the start of */ - objc_module_info_addr; /* the (__OBJC,__module_info) section */ -}; - -/* - * The entries in the reference symbol table are used when loading the module - * (both by the static and dynamic link editors) and if the module is unloaded - * or replaced. Therefore all external symbols (defined and undefined) are - * listed in the module's reference table. The flags describe the type of - * reference that is being made. The constants for the flags are defined in - * as they are also used for symbol table entries. - */ -struct dylib_reference { - uint32_t isym:24, /* index into the symbol table */ - flags:8; /* flags to indicate the type of reference */ -}; - -/* - * The twolevel_hints_command contains the offset and number of hints in the - * two-level namespace lookup hints table. - */ -struct twolevel_hints_command { - uint32_t cmd; /* LC_TWOLEVEL_HINTS */ - uint32_t cmdsize; /* sizeof(struct twolevel_hints_command) */ - uint32_t offset; /* offset to the hint table */ - uint32_t nhints; /* number of hints in the hint table */ -}; - -/* - * The entries in the two-level namespace lookup hints table are twolevel_hint - * structs. These provide hints to the dynamic link editor where to start - * looking for an undefined symbol in a two-level namespace image. The - * isub_image field is an index into the sub-images (sub-frameworks and - * sub-umbrellas list) that made up the two-level image that the undefined - * symbol was found in when it was built by the static link editor. If - * isub-image is 0 the the symbol is expected to be defined in library and not - * in the sub-images. If isub-image is non-zero it is an index into the array - * of sub-images for the umbrella with the first index in the sub-images being - * 1. The array of sub-images is the ordered list of sub-images of the umbrella - * that would be searched for a symbol that has the umbrella recorded as its - * primary library. The table of contents index is an index into the - * library's table of contents. This is used as the starting point of the - * binary search or a directed linear search. - */ -struct twolevel_hint { - uint32_t - isub_image:8, /* index into the sub images */ - itoc:24; /* index into the table of contents */ -}; - -/* - * The prebind_cksum_command contains the value of the original check sum for - * prebound files or zero. When a prebound file is first created or modified - * for other than updating its prebinding information the value of the check sum - * is set to zero. When the file has it prebinding re-done and if the value of - * the check sum is zero the original check sum is calculated and stored in - * cksum field of this load command in the output file. If when the prebinding - * is re-done and the cksum field is non-zero it is left unchanged from the - * input file. - */ -struct prebind_cksum_command { - uint32_t cmd; /* LC_PREBIND_CKSUM */ - uint32_t cmdsize; /* sizeof(struct prebind_cksum_command) */ - uint32_t cksum; /* the check sum or zero */ -}; - -/* - * The uuid load command contains a single 128-bit unique random number that - * identifies an object produced by the static link editor. - */ -struct uuid_command { - uint32_t cmd; /* LC_UUID */ - uint32_t cmdsize; /* sizeof(struct uuid_command) */ - uint8_t uuid[16]; /* the 128-bit uuid */ -}; - -/* - * The rpath_command contains a path which at runtime should be added to - * the current run path used to find @rpath prefixed dylibs. - */ -struct rpath_command { - uint32_t cmd; /* LC_RPATH */ - uint32_t cmdsize; /* includes string */ - union lc_str path; /* path to add to run path */ -}; - -/* - * The linkedit_data_command contains the offsets and sizes of a blob - * of data in the __LINKEDIT segment. - */ -struct linkedit_data_command { - uint32_t cmd; /* LC_CODE_SIGNATURE, LC_SEGMENT_SPLIT_INFO, - LC_FUNCTION_STARTS, LC_DATA_IN_CODE, - or LC_DYLIB_CODE_SIGN_DRS */ - uint32_t cmdsize; /* sizeof(struct linkedit_data_command) */ - uint32_t dataoff; /* file offset of data in __LINKEDIT segment */ - uint32_t datasize; /* file size of data in __LINKEDIT segment */ -}; - -/* - * The encryption_info_command contains the file offset and size of an - * of an encrypted segment. - */ -struct encryption_info_command { - uint32_t cmd; /* LC_ENCRYPTION_INFO */ - uint32_t cmdsize; /* sizeof(struct encryption_info_command) */ - uint32_t cryptoff; /* file offset of encrypted range */ - uint32_t cryptsize; /* file size of encrypted range */ - uint32_t cryptid; /* which enryption system, - 0 means not-encrypted yet */ -}; - -/* - * The version_min_command contains the min OS version on which this - * binary was built to run. - */ -struct version_min_command { - uint32_t cmd; /* LC_VERSION_MIN_MACOSX or - LC_VERSION_MIN_IPHONEOS */ - uint32_t cmdsize; /* sizeof(struct min_version_command) */ - uint32_t version; /* X.Y.Z is encoded in nibbles xxxx.yy.zz */ - uint32_t sdk; /* X.Y.Z is encoded in nibbles xxxx.yy.zz */ -}; - -/* - * The dyld_info_command contains the file offsets and sizes of - * the new compressed form of the information dyld needs to - * load the image. This information is used by dyld on Mac OS X - * 10.6 and later. All information pointed to by this command - * is encoded using byte streams, so no endian swapping is needed - * to interpret it. - */ -struct dyld_info_command { - uint32_t cmd; /* LC_DYLD_INFO or LC_DYLD_INFO_ONLY */ - uint32_t cmdsize; /* sizeof(struct dyld_info_command) */ - - /* - * Dyld rebases an image whenever dyld loads it at an address different - * from its preferred address. The rebase information is a stream - * of byte sized opcodes whose symbolic names start with REBASE_OPCODE_. - * Conceptually the rebase information is a table of tuples: - * - * The opcodes are a compressed way to encode the table by only - * encoding when a column changes. In addition simple patterns - * like "every n'th offset for m times" can be encoded in a few - * bytes. - */ - uint32_t rebase_off; /* file offset to rebase info */ - uint32_t rebase_size; /* size of rebase info */ - - /* - * Dyld binds an image during the loading process, if the image - * requires any pointers to be initialized to symbols in other images. - * The bind information is a stream of byte sized - * opcodes whose symbolic names start with BIND_OPCODE_. - * Conceptually the bind information is a table of tuples: - * - * The opcodes are a compressed way to encode the table by only - * encoding when a column changes. In addition simple patterns - * like for runs of pointers initialzed to the same value can be - * encoded in a few bytes. - */ - uint32_t bind_off; /* file offset to binding info */ - uint32_t bind_size; /* size of binding info */ - - /* - * Some C++ programs require dyld to unique symbols so that all - * images in the process use the same copy of some code/data. - * This step is done after binding. The content of the weak_bind - * info is an opcode stream like the bind_info. But it is sorted - * alphabetically by symbol name. This enable dyld to walk - * all images with weak binding information in order and look - * for collisions. If there are no collisions, dyld does - * no updating. That means that some fixups are also encoded - * in the bind_info. For instance, all calls to "operator new" - * are first bound to libstdc++.dylib using the information - * in bind_info. Then if some image overrides operator new - * that is detected when the weak_bind information is processed - * and the call to operator new is then rebound. - */ - uint32_t weak_bind_off; /* file offset to weak binding info */ - uint32_t weak_bind_size; /* size of weak binding info */ - - /* - * Some uses of external symbols do not need to be bound immediately. - * Instead they can be lazily bound on first use. The lazy_bind - * are contains a stream of BIND opcodes to bind all lazy symbols. - * Normal use is that dyld ignores the lazy_bind section when - * loading an image. Instead the static linker arranged for the - * lazy pointer to initially point to a helper function which - * pushes the offset into the lazy_bind area for the symbol - * needing to be bound, then jumps to dyld which simply adds - * the offset to lazy_bind_off to get the information on what - * to bind. - */ - uint32_t lazy_bind_off; /* file offset to lazy binding info */ - uint32_t lazy_bind_size; /* size of lazy binding infs */ - - /* - * The symbols exported by a dylib are encoded in a trie. This - * is a compact representation that factors out common prefixes. - * It also reduces LINKEDIT pages in RAM because it encodes all - * information (name, address, flags) in one small, contiguous range. - * The export area is a stream of nodes. The first node sequentially - * is the start node for the trie. - * - * Nodes for a symbol start with a uleb128 that is the length of - * the exported symbol information for the string so far. - * If there is no exported symbol, the node starts with a zero byte. - * If there is exported info, it follows the length. - * - * First is a uleb128 containing flags. Normally, it is followed by - * a uleb128 encoded offset which is location of the content named - * by the symbol from the mach_header for the image. If the flags - * is EXPORT_SYMBOL_FLAGS_REEXPORT, then following the flags is - * a uleb128 encoded library ordinal, then a zero terminated - * UTF8 string. If the string is zero length, then the symbol - * is re-export from the specified dylib with the same name. - * If the flags is EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER, then following - * the flags is two uleb128s: the stub offset and the resolver offset. - * The stub is used by non-lazy pointers. The resolver is used - * by lazy pointers and must be called to get the actual address to use. - * - * After the optional exported symbol information is a byte of - * how many edges (0-255) that this node has leaving it, - * followed by each edge. - * Each edge is a zero terminated UTF8 of the addition chars - * in the symbol, followed by a uleb128 offset for the node that - * edge points to. - * - */ - uint32_t export_off; /* file offset to lazy binding info */ - uint32_t export_size; /* size of lazy binding infs */ -}; - -/* - * The following are used to encode rebasing information - */ -#define REBASE_TYPE_POINTER 1 -#define REBASE_TYPE_TEXT_ABSOLUTE32 2 -#define REBASE_TYPE_TEXT_PCREL32 3 - -#define REBASE_OPCODE_MASK 0xF0 -#define REBASE_IMMEDIATE_MASK 0x0F -#define REBASE_OPCODE_DONE 0x00 -#define REBASE_OPCODE_SET_TYPE_IMM 0x10 -#define REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB 0x20 -#define REBASE_OPCODE_ADD_ADDR_ULEB 0x30 -#define REBASE_OPCODE_ADD_ADDR_IMM_SCALED 0x40 -#define REBASE_OPCODE_DO_REBASE_IMM_TIMES 0x50 -#define REBASE_OPCODE_DO_REBASE_ULEB_TIMES 0x60 -#define REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB 0x70 -#define REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB 0x80 - - -/* - * The following are used to encode binding information - */ -#define BIND_TYPE_POINTER 1 -#define BIND_TYPE_TEXT_ABSOLUTE32 2 -#define BIND_TYPE_TEXT_PCREL32 3 - -#define BIND_SPECIAL_DYLIB_SELF 0 -#define BIND_SPECIAL_DYLIB_MAIN_EXECUTABLE -1 -#define BIND_SPECIAL_DYLIB_FLAT_LOOKUP -2 - -#define BIND_SYMBOL_FLAGS_WEAK_IMPORT 0x1 -#define BIND_SYMBOL_FLAGS_NON_WEAK_DEFINITION 0x8 - -#define BIND_OPCODE_MASK 0xF0 -#define BIND_IMMEDIATE_MASK 0x0F -#define BIND_OPCODE_DONE 0x00 -#define BIND_OPCODE_SET_DYLIB_ORDINAL_IMM 0x10 -#define BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB 0x20 -#define BIND_OPCODE_SET_DYLIB_SPECIAL_IMM 0x30 -#define BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM 0x40 -#define BIND_OPCODE_SET_TYPE_IMM 0x50 -#define BIND_OPCODE_SET_ADDEND_SLEB 0x60 -#define BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB 0x70 -#define BIND_OPCODE_ADD_ADDR_ULEB 0x80 -#define BIND_OPCODE_DO_BIND 0x90 -#define BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB 0xA0 -#define BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED 0xB0 -#define BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB 0xC0 - - -/* - * The following are used on the flags byte of a terminal node - * in the export information. - */ -#define EXPORT_SYMBOL_FLAGS_KIND_MASK 0x03 -#define EXPORT_SYMBOL_FLAGS_KIND_REGULAR 0x00 -#define EXPORT_SYMBOL_FLAGS_KIND_THREAD_LOCAL 0x01 -#define EXPORT_SYMBOL_FLAGS_WEAK_DEFINITION 0x04 -#define EXPORT_SYMBOL_FLAGS_REEXPORT 0x08 -#define EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER 0x10 - -/* - * The symseg_command contains the offset and size of the GNU style - * symbol table information as described in the header file . - * The symbol roots of the symbol segments must also be aligned properly - * in the file. So the requirement of keeping the offsets aligned to a - * multiple of a 4 bytes translates to the length field of the symbol - * roots also being a multiple of a long. Also the padding must again be - * zeroed. (THIS IS OBSOLETE and no longer supported). - */ -struct symseg_command { - uint32_t cmd; /* LC_SYMSEG */ - uint32_t cmdsize; /* sizeof(struct symseg_command) */ - uint32_t offset; /* symbol segment offset */ - uint32_t size; /* symbol segment size in bytes */ -}; - -/* - * The ident_command contains a free format string table following the - * ident_command structure. The strings are null terminated and the size of - * the command is padded out with zero bytes to a multiple of 4 bytes/ - * (THIS IS OBSOLETE and no longer supported). - */ -struct ident_command { - uint32_t cmd; /* LC_IDENT */ - uint32_t cmdsize; /* strings that follow this command */ -}; - -/* - * The fvmfile_command contains a reference to a file to be loaded at the - * specified virtual address. (Presently, this command is reserved for - * internal use. The kernel ignores this command when loading a program into - * memory). - */ -struct fvmfile_command { - uint32_t cmd; /* LC_FVMFILE */ - uint32_t cmdsize; /* includes pathname string */ - union lc_str name; /* files pathname */ - uint32_t header_addr; /* files virtual address */ -}; - - -/* - * The entry_point_command is a replacement for thread_command. - * It is used for main executables to specify the location (file offset) - * of main(). If -stack_size was used at link time, the stacksize - * field will contain the stack size need for the main thread. - */ -struct entry_point_command { - uint32_t cmd; /* LC_MAIN only used in MH_EXECUTE filetypes */ - uint32_t cmdsize; /* 24 */ - uint64_t entryoff; /* file (__TEXT) offset of main() */ - uint64_t stacksize;/* if not zero, initial stack size */ -}; - - -/* - * The source_version_command is an optional load command containing - * the version of the sources used to build the binary. - */ -struct source_version_command { - uint32_t cmd; /* LC_SOURCE_VERSION */ - uint32_t cmdsize; /* 16 */ - uint64_t version; /* A.B.C.D.E packed as a24.b10.c10.d10.e10 */ -}; - - -/* - * The LC_DATA_IN_CODE load commands uses a linkedit_data_command - * to point to an array of data_in_code_entry entries. Each entry - * describes a range of data in a code section. This load command - * is only used in final linked images. - */ -struct data_in_code_entry { - uint32_t offset; /* from mach_header to start of data range*/ - uint16_t length; /* number of bytes in data range */ - uint16_t kind; /* a DICE_KIND_* value */ -}; -#define DICE_KIND_DATA 0x0001 /* L$start$data$... label */ -#define DICE_KIND_JUMP_TABLE8 0x0002 /* L$start$jt8$... label */ -#define DICE_KIND_JUMP_TABLE16 0x0003 /* L$start$jt16$... label */ -#define DICE_KIND_JUMP_TABLE32 0x0004 /* L$start$jt32$... label */ -#define DICE_KIND_ABS_JUMP_TABLE32 0x0005 /* L$start$jta32$... label */ - - - -/* - * Sections of type S_THREAD_LOCAL_VARIABLES contain an array - * of tlv_descriptor structures. - */ -struct tlv_descriptor -{ - void* (*thunk)(struct tlv_descriptor*); - unsigned long key; - unsigned long offset; -}; - -#endif /* _MACHO_LOADER_H_ */ diff --git a/include/darwin/mach-o/nlist.h b/include/darwin/mach-o/nlist.h deleted file mode 100644 index dd1988846..000000000 --- a/include/darwin/mach-o/nlist.h +++ /dev/null @@ -1,312 +0,0 @@ -/* - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * @APPLE_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. 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_LICENSE_HEADER_END@ - */ -#ifndef _MACHO_NLIST_H_ -#define _MACHO_NLIST_H_ -/* $NetBSD: nlist.h,v 1.5 1994/10/26 00:56:11 cgd Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * (c) UNIX System Laboratories, Inc. - * All or some portions of this file are derived from material licensed - * to the University of California by American Telephone and Telegraph - * Co. or Unix System Laboratories, Inc. and are reproduced herein with - * the permission of UNIX System Laboratories, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)nlist.h 8.2 (Berkeley) 1/21/94 - */ -#include - -/* - * Format of a symbol table entry of a Mach-O file for 32-bit architectures. - * Modified from the BSD format. The modifications from the original format - * were changing n_other (an unused field) to n_sect and the addition of the - * N_SECT type. These modifications are required to support symbols in a larger - * number of sections not just the three sections (text, data and bss) in a BSD - * file. - */ -struct nlist { - union { -#ifndef __LP64__ - char *n_name; /* for use when in-core */ -#endif - uint32_t n_strx; /* index into the string table */ - } n_un; - uint8_t n_type; /* type flag, see below */ - uint8_t n_sect; /* section number or NO_SECT */ - int16_t n_desc; /* see */ - uint32_t n_value; /* value of this symbol (or stab offset) */ -}; - -/* - * This is the symbol table entry structure for 64-bit architectures. - */ -struct nlist_64 { - union { - uint32_t n_strx; /* index into the string table */ - } n_un; - uint8_t n_type; /* type flag, see below */ - uint8_t n_sect; /* section number or NO_SECT */ - uint16_t n_desc; /* see */ - uint64_t n_value; /* value of this symbol (or stab offset) */ -}; - -/* - * Symbols with a index into the string table of zero (n_un.n_strx == 0) are - * defined to have a null, "", name. Therefore all string indexes to non null - * names must not have a zero string index. This is bit historical information - * that has never been well documented. - */ - -/* - * The n_type field really contains four fields: - * unsigned char N_STAB:3, - * N_PEXT:1, - * N_TYPE:3, - * N_EXT:1; - * which are used via the following masks. - */ -#define N_STAB 0xe0 /* if any of these bits set, a symbolic debugging entry */ -#define N_PEXT 0x10 /* private external symbol bit */ -#define N_TYPE 0x0e /* mask for the type bits */ -#define N_EXT 0x01 /* external symbol bit, set for external symbols */ - -/* - * Only symbolic debugging entries have some of the N_STAB bits set and if any - * of these bits are set then it is a symbolic debugging entry (a stab). In - * which case then the values of the n_type field (the entire field) are given - * in - */ - -/* - * Values for N_TYPE bits of the n_type field. - */ -#define N_UNDF 0x0 /* undefined, n_sect == NO_SECT */ -#define N_ABS 0x2 /* absolute, n_sect == NO_SECT */ -#define N_SECT 0xe /* defined in section number n_sect */ -#define N_PBUD 0xc /* prebound undefined (defined in a dylib) */ -#define N_INDR 0xa /* indirect */ - -/* - * If the type is N_INDR then the symbol is defined to be the same as another - * symbol. In this case the n_value field is an index into the string table - * of the other symbol's name. When the other symbol is defined then they both - * take on the defined type and value. - */ - -/* - * If the type is N_SECT then the n_sect field contains an ordinal of the - * section the symbol is defined in. The sections are numbered from 1 and - * refer to sections in order they appear in the load commands for the file - * they are in. This means the same ordinal may very well refer to different - * sections in different files. - * - * The n_value field for all symbol table entries (including N_STAB's) gets - * updated by the link editor based on the value of it's n_sect field and where - * the section n_sect references gets relocated. If the value of the n_sect - * field is NO_SECT then it's n_value field is not changed by the link editor. - */ -#define NO_SECT 0 /* symbol is not in any section */ -#define MAX_SECT 255 /* 1 thru 255 inclusive */ - -/* - * Common symbols are represented by undefined (N_UNDF) external (N_EXT) types - * who's values (n_value) are non-zero. In which case the value of the n_value - * field is the size (in bytes) of the common symbol. The n_sect field is set - * to NO_SECT. The alignment of a common symbol may be set as a power of 2 - * between 2^1 and 2^15 as part of the n_desc field using the macros below. If - * the alignment is not set (a value of zero) then natural alignment based on - * the size is used. - */ -#define GET_COMM_ALIGN(n_desc) (((n_desc) >> 8) & 0x0f) -#define SET_COMM_ALIGN(n_desc,align) \ - (n_desc) = (((n_desc) & 0xf0ff) | (((align) & 0x0f) << 8)) - -/* - * To support the lazy binding of undefined symbols in the dynamic link-editor, - * the undefined symbols in the symbol table (the nlist structures) are marked - * with the indication if the undefined reference is a lazy reference or - * non-lazy reference. If both a non-lazy reference and a lazy reference is - * made to the same symbol the non-lazy reference takes precedence. A reference - * is lazy only when all references to that symbol are made through a symbol - * pointer in a lazy symbol pointer section. - * - * The implementation of marking nlist structures in the symbol table for - * undefined symbols will be to use some of the bits of the n_desc field as a - * reference type. The mask REFERENCE_TYPE will be applied to the n_desc field - * of an nlist structure for an undefined symbol to determine the type of - * undefined reference (lazy or non-lazy). - * - * The constants for the REFERENCE FLAGS are propagated to the reference table - * in a shared library file. In that case the constant for a defined symbol, - * REFERENCE_FLAG_DEFINED, is also used. - */ -/* Reference type bits of the n_desc field of undefined symbols */ -#define REFERENCE_TYPE 0x7 -/* types of references */ -#define REFERENCE_FLAG_UNDEFINED_NON_LAZY 0 -#define REFERENCE_FLAG_UNDEFINED_LAZY 1 -#define REFERENCE_FLAG_DEFINED 2 -#define REFERENCE_FLAG_PRIVATE_DEFINED 3 -#define REFERENCE_FLAG_PRIVATE_UNDEFINED_NON_LAZY 4 -#define REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY 5 - -/* - * To simplify stripping of objects that use are used with the dynamic link - * editor, the static link editor marks the symbols defined an object that are - * referenced by a dynamicly bound object (dynamic shared libraries, bundles). - * With this marking strip knows not to strip these symbols. - */ -#define REFERENCED_DYNAMICALLY 0x0010 - -/* - * For images created by the static link editor with the -twolevel_namespace - * option in effect the flags field of the mach header is marked with - * MH_TWOLEVEL. And the binding of the undefined references of the image are - * determined by the static link editor. Which library an undefined symbol is - * bound to is recorded by the static linker in the high 8 bits of the n_desc - * field using the SET_LIBRARY_ORDINAL macro below. The ordinal recorded - * references the libraries listed in the Mach-O's LC_LOAD_DYLIB, - * LC_LOAD_WEAK_DYLIB, LC_REEXPORT_DYLIB, LC_LOAD_UPWARD_DYLIB, and - * LC_LAZY_LOAD_DYLIB, etc. load commands in the order they appear in the - * headers. The library ordinals start from 1. - * For a dynamic library that is built as a two-level namespace image the - * undefined references from module defined in another use the same nlist struct - * an in that case SELF_LIBRARY_ORDINAL is used as the library ordinal. For - * defined symbols in all images they also must have the library ordinal set to - * SELF_LIBRARY_ORDINAL. The EXECUTABLE_ORDINAL refers to the executable - * image for references from plugins that refer to the executable that loads - * them. - * - * The DYNAMIC_LOOKUP_ORDINAL is for undefined symbols in a two-level namespace - * image that are looked up by the dynamic linker with flat namespace semantics. - * This ordinal was added as a feature in Mac OS X 10.3 by reducing the - * value of MAX_LIBRARY_ORDINAL by one. So it is legal for existing binaries - * or binaries built with older tools to have 0xfe (254) dynamic libraries. In - * this case the ordinal value 0xfe (254) must be treated as a library ordinal - * for compatibility. - */ -#define GET_LIBRARY_ORDINAL(n_desc) (((n_desc) >> 8) & 0xff) -#define SET_LIBRARY_ORDINAL(n_desc,ordinal) \ - (n_desc) = (((n_desc) & 0x00ff) | (((ordinal) & 0xff) << 8)) -#define SELF_LIBRARY_ORDINAL 0x0 -#define MAX_LIBRARY_ORDINAL 0xfd -#define DYNAMIC_LOOKUP_ORDINAL 0xfe -#define EXECUTABLE_ORDINAL 0xff - -/* - * The bit 0x0020 of the n_desc field is used for two non-overlapping purposes - * and has two different symbolic names, N_NO_DEAD_STRIP and N_DESC_DISCARDED. - */ - -/* - * The N_NO_DEAD_STRIP bit of the n_desc field only ever appears in a - * relocatable .o file (MH_OBJECT filetype). And is used to indicate to the - * static link editor it is never to dead strip the symbol. - */ -#define N_NO_DEAD_STRIP 0x0020 /* symbol is not to be dead stripped */ - -/* - * The N_DESC_DISCARDED bit of the n_desc field never appears in linked image. - * But is used in very rare cases by the dynamic link editor to mark an in - * memory symbol as discared and longer used for linking. - */ -#define N_DESC_DISCARDED 0x0020 /* symbol is discarded */ - -/* - * The N_WEAK_REF bit of the n_desc field indicates to the dynamic linker that - * the undefined symbol is allowed to be missing and is to have the address of - * zero when missing. - */ -#define N_WEAK_REF 0x0040 /* symbol is weak referenced */ - -/* - * The N_WEAK_DEF bit of the n_desc field indicates to the static and dynamic - * linkers that the symbol definition is weak, allowing a non-weak symbol to - * also be used which causes the weak definition to be discared. Currently this - * is only supported for symbols in coalesed sections. - */ -#define N_WEAK_DEF 0x0080 /* coalesed symbol is a weak definition */ - -/* - * The N_REF_TO_WEAK bit of the n_desc field indicates to the dynamic linker - * that the undefined symbol should be resolved using flat namespace searching. - */ -#define N_REF_TO_WEAK 0x0080 /* reference to a weak symbol */ - -/* - * The N_ARM_THUMB_DEF bit of the n_desc field indicates that the symbol is - * a defintion of a Thumb function. - */ -#define N_ARM_THUMB_DEF 0x0008 /* symbol is a Thumb function (ARM) */ - -/* - * The N_SYMBOL_RESOLVER bit of the n_desc field indicates that the - * that the function is actually a resolver function and should - * be called to get the address of the real function to use. - * This bit is only available in .o files (MH_OBJECT filetype) - */ -#define N_SYMBOL_RESOLVER 0x0100 - -#ifndef __STRICT_BSD__ -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -/* - * The function nlist(3) from the C library. - */ -extern int nlist (const char *filename, struct nlist *list); -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __STRICT_BSD__ */ - -#endif /* _MACHO_LIST_H_ */ diff --git a/include/darwin/mach-o/ppc/reloc.h b/include/darwin/mach-o/ppc/reloc.h deleted file mode 100644 index 7b564cc0a..000000000 --- a/include/darwin/mach-o/ppc/reloc.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. - * - * @APPLE_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. 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_LICENSE_HEADER_END@ - */ -/* - * Relocation types used in the ppc implementation. Relocation entries for - * things other than instructions use the same generic relocation as discribed - * above and their r_type is RELOC_VANILLA. The rest of the relocation types - * are for instructions. Since they are for instructions the r_address field - * indicates the 32 bit instruction that the relocation is to be preformed on. - * The fields r_pcrel and r_length are ignored for non-RELOC_VANILLA r_types - * except for PPC_RELOC_BR14. - * - * For PPC_RELOC_BR14 if the r_length is the unused value 3, then the branch was - * statically predicted setting or clearing the Y-bit based on the sign of the - * displacement or the opcode. If this is the case the static linker must flip - * the value of the Y-bit if the sign of the displacement changes for non-branch - * always conditions. - */ -enum reloc_type_ppc -{ - PPC_RELOC_VANILLA, /* generic relocation as discribed above */ - PPC_RELOC_PAIR, /* the second relocation entry of a pair */ - PPC_RELOC_BR14, /* 14 bit branch displacement (to a word address) */ - PPC_RELOC_BR24, /* 24 bit branch displacement (to a word address) */ - PPC_RELOC_HI16, /* a PAIR follows with the low half */ - PPC_RELOC_LO16, /* a PAIR follows with the high half */ - PPC_RELOC_HA16, /* Same as the RELOC_HI16 except the low 16 bits and the - * high 16 bits are added together with the low 16 bits - * sign extened first. This means if bit 15 of the low - * 16 bits is set the high 16 bits stored in the - * instruction will be adjusted. - */ - PPC_RELOC_LO14, /* Same as the LO16 except that the low 2 bits are not - * stored in the instruction and are always zero. This - * is used in double word load/store instructions. - */ - PPC_RELOC_SECTDIFF, /* a PAIR follows with subtract symbol value */ - PPC_RELOC_PB_LA_PTR,/* prebound lazy pointer */ - PPC_RELOC_HI16_SECTDIFF, /* section difference forms of above. a PAIR */ - PPC_RELOC_LO16_SECTDIFF, /* follows these with subtract symbol value */ - PPC_RELOC_HA16_SECTDIFF, - PPC_RELOC_JBSR, - PPC_RELOC_LO14_SECTDIFF, - PPC_RELOC_LOCAL_SECTDIFF /* like PPC_RELOC_SECTDIFF, but the symbol - referenced was local. */ -}; diff --git a/include/darwin/mach-o/reloc.h b/include/darwin/mach-o/reloc.h deleted file mode 100644 index d5741efa3..000000000 --- a/include/darwin/mach-o/reloc.h +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. - * - * @APPLE_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. 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_LICENSE_HEADER_END@ - */ -/* $NetBSD: exec.h,v 1.6 1994/10/27 04:16:05 cgd Exp $ */ - -/* - * Copyright (c) 1993 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _MACHO_RELOC_H_ -#define _MACHO_RELOC_H_ -#include - -/* - * Format of a relocation entry of a Mach-O file. Modified from the 4.3BSD - * format. The modifications from the original format were changing the value - * of the r_symbolnum field for "local" (r_extern == 0) relocation entries. - * This modification is required to support symbols in an arbitrary number of - * sections not just the three sections (text, data and bss) in a 4.3BSD file. - * Also the last 4 bits have had the r_type tag added to them. - */ -struct relocation_info { - int32_t r_address; /* offset in the section to what is being - relocated */ - uint32_t r_symbolnum:24, /* symbol index if r_extern == 1 or section - ordinal if r_extern == 0 */ - r_pcrel:1, /* was relocated pc relative already */ - r_length:2, /* 0=byte, 1=word, 2=long, 3=quad */ - r_extern:1, /* does not include value of sym referenced */ - r_type:4; /* if not 0, machine specific relocation type */ -}; -#define R_ABS 0 /* absolute relocation type for Mach-O files */ - -/* - * The r_address is not really the address as it's name indicates but an offset. - * In 4.3BSD a.out objects this offset is from the start of the "segment" for - * which relocation entry is for (text or data). For Mach-O object files it is - * also an offset but from the start of the "section" for which the relocation - * entry is for. See comments in about the r_address feild - * in images for used with the dynamic linker. - * - * In 4.3BSD a.out objects if r_extern is zero then r_symbolnum is an ordinal - * for the segment the symbol being relocated is in. These ordinals are the - * symbol types N_TEXT, N_DATA, N_BSS or N_ABS. In Mach-O object files these - * ordinals refer to the sections in the object file in the order their section - * structures appear in the headers of the object file they are in. The first - * section has the ordinal 1, the second 2, and so on. This means that the - * same ordinal in two different object files could refer to two different - * sections. And further could have still different ordinals when combined - * by the link-editor. The value R_ABS is used for relocation entries for - * absolute symbols which need no further relocation. - */ - -/* - * For RISC machines some of the references are split across two instructions - * and the instruction does not contain the complete value of the reference. - * In these cases a second, or paired relocation entry, follows each of these - * relocation entries, using a PAIR r_type, which contains the other part of the - * reference not contained in the instruction. This other part is stored in the - * pair's r_address field. The exact number of bits of the other part of the - * reference store in the r_address field is dependent on the particular - * relocation type for the particular architecture. - */ - -/* - * To make scattered loading by the link editor work correctly "local" - * relocation entries can't be used when the item to be relocated is the value - * of a symbol plus an offset (where the resulting expresion is outside the - * block the link editor is moving, a blocks are divided at symbol addresses). - * In this case. where the item is a symbol value plus offset, the link editor - * needs to know more than just the section the symbol was defined. What is - * needed is the actual value of the symbol without the offset so it can do the - * relocation correctly based on where the value of the symbol got relocated to - * not the value of the expression (with the offset added to the symbol value). - * So for the NeXT 2.0 release no "local" relocation entries are ever used when - * there is a non-zero offset added to a symbol. The "external" and "local" - * relocation entries remain unchanged. - * - * The implemention is quite messy given the compatibility with the existing - * relocation entry format. The ASSUMPTION is that a section will never be - * bigger than 2**24 - 1 (0x00ffffff or 16,777,215) bytes. This assumption - * allows the r_address (which is really an offset) to fit in 24 bits and high - * bit of the r_address field in the relocation_info structure to indicate - * it is really a scattered_relocation_info structure. Since these are only - * used in places where "local" relocation entries are used and not where - * "external" relocation entries are used the r_extern field has been removed. - * - * For scattered loading to work on a RISC machine where some of the references - * are split across two instructions the link editor needs to be assured that - * each reference has a unique 32 bit reference (that more than one reference is - * NOT sharing the same high 16 bits for example) so it move each referenced - * item independent of each other. Some compilers guarantees this but the - * compilers don't so scattered loading can be done on those that do guarantee - * this. - */ -#if defined(__BIG_ENDIAN__) || defined(__LITTLE_ENDIAN__) -/* - * The reason for the ifdef's of __BIG_ENDIAN__ and __LITTLE_ENDIAN__ are that - * when stattered relocation entries were added the mistake of using a mask - * against a structure that is made up of bit fields was used. To make this - * design work this structure must be laid out in memory the same way so the - * mask can be applied can check the same bit each time (r_scattered). - */ -#endif /* defined(__BIG_ENDIAN__) || defined(__LITTLE_ENDIAN__) */ -#define R_SCATTERED 0x80000000 /* mask to be applied to the r_address field - of a relocation_info structure to tell that - is is really a scattered_relocation_info - stucture */ -struct scattered_relocation_info { -#ifdef __BIG_ENDIAN__ - uint32_t r_scattered:1, /* 1=scattered, 0=non-scattered (see above) */ - r_pcrel:1, /* was relocated pc relative already */ - r_length:2, /* 0=byte, 1=word, 2=long, 3=quad */ - r_type:4, /* if not 0, machine specific relocation type */ - r_address:24; /* offset in the section to what is being - relocated */ - int32_t r_value; /* the value the item to be relocated is - refering to (without any offset added) */ -#endif /* __BIG_ENDIAN__ */ -#ifdef __LITTLE_ENDIAN__ - uint32_t - r_address:24, /* offset in the section to what is being - relocated */ - r_type:4, /* if not 0, machine specific relocation type */ - r_length:2, /* 0=byte, 1=word, 2=long, 3=quad */ - r_pcrel:1, /* was relocated pc relative already */ - r_scattered:1; /* 1=scattered, 0=non-scattered (see above) */ - int32_t r_value; /* the value the item to be relocated is - refering to (without any offset added) */ -#endif /* __LITTLE_ENDIAN__ */ -}; - -/* - * Relocation types used in a generic implementation. Relocation entries for - * normal things use the generic relocation as discribed above and their r_type - * is GENERIC_RELOC_VANILLA (a value of zero). - * - * Another type of generic relocation, GENERIC_RELOC_SECTDIFF, is to support - * the difference of two symbols defined in different sections. That is the - * expression "symbol1 - symbol2 + constant" is a relocatable expression when - * both symbols are defined in some section. For this type of relocation the - * both relocations entries are scattered relocation entries. The value of - * symbol1 is stored in the first relocation entry's r_value field and the - * value of symbol2 is stored in the pair's r_value field. - * - * A special case for a prebound lazy pointer is needed to beable to set the - * value of the lazy pointer back to its non-prebound state. This is done - * using the GENERIC_RELOC_PB_LA_PTR r_type. This is a scattered relocation - * entry where the r_value feild is the value of the lazy pointer not prebound. - */ -enum reloc_type_generic -{ - GENERIC_RELOC_VANILLA, /* generic relocation as discribed above */ - GENERIC_RELOC_PAIR, /* Only follows a GENERIC_RELOC_SECTDIFF */ - GENERIC_RELOC_SECTDIFF, - GENERIC_RELOC_PB_LA_PTR, /* prebound lazy pointer */ - GENERIC_RELOC_LOCAL_SECTDIFF, - GENERIC_RELOC_TLV /* thread local variables */ -}; - -#endif /* _MACHO_RELOC_H_ */ diff --git a/include/darwin/mach-o/x86_64/reloc.h b/include/darwin/mach-o/x86_64/reloc.h deleted file mode 100644 index d3466d8fe..000000000 --- a/include/darwin/mach-o/x86_64/reloc.h +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (c) 2006 Apple Computer, Inc. All rights reserved. - * - * @APPLE_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. 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_LICENSE_HEADER_END@ - */ -/* - * Relocations for x86_64 are a bit different than for other architectures in - * Mach-O: Scattered relocations are not used. Almost all relocations produced - * by the compiler are external relocations. An external relocation has the - * r_extern bit set to 1 and the r_symbolnum field contains the symbol table - * index of the target label. - * - * When the assembler is generating relocations, if the target label is a local - * label (begins with 'L'), then the previous non-local label in the same - * section is used as the target of the external relocation. An addend is used - * with the distance from that non-local label to the target label. Only when - * there is no previous non-local label in the section is an internal - * relocation used. - * - * The addend (i.e. the 4 in _foo+4) is encoded in the instruction (Mach-O does - * not have RELA relocations). For PC-relative relocations, the addend is - * stored directly in the instruction. This is different from other Mach-O - * architectures, which encode the addend minus the current section offset. - * - * The relocation types are: - * - * X86_64_RELOC_UNSIGNED // for absolute addresses - * X86_64_RELOC_SIGNED // for signed 32-bit displacement - * X86_64_RELOC_BRANCH // a CALL/JMP instruction with 32-bit displacement - * X86_64_RELOC_GOT_LOAD // a MOVQ load of a GOT entry - * X86_64_RELOC_GOT // other GOT references - * X86_64_RELOC_SUBTRACTOR // must be followed by a X86_64_RELOC_UNSIGNED - * - * The following are sample assembly instructions, followed by the relocation - * and section content they generate in an object file: - * - * call _foo - * r_type=X86_64_RELOC_BRANCH, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo - * E8 00 00 00 00 - * - * call _foo+4 - * r_type=X86_64_RELOC_BRANCH, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo - * E8 04 00 00 00 - * - * movq _foo@GOTPCREL(%rip), %rax - * r_type=X86_64_RELOC_GOT_LOAD, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo - * 48 8B 05 00 00 00 00 - * - * pushq _foo@GOTPCREL(%rip) - * r_type=X86_64_RELOC_GOT, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo - * FF 35 00 00 00 00 - * - * movl _foo(%rip), %eax - * r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo - * 8B 05 00 00 00 00 - * - * movl _foo+4(%rip), %eax - * r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo - * 8B 05 04 00 00 00 - * - * movb $0x12, _foo(%rip) - * r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo - * C6 05 FF FF FF FF 12 - * - * movl $0x12345678, _foo(%rip) - * r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo - * C7 05 FC FF FF FF 78 56 34 12 - * - * .quad _foo - * r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_foo - * 00 00 00 00 00 00 00 00 - * - * .quad _foo+4 - * r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_foo - * 04 00 00 00 00 00 00 00 - * - * .quad _foo - _bar - * r_type=X86_64_RELOC_SUBTRACTOR, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_bar - * r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_foo - * 00 00 00 00 00 00 00 00 - * - * .quad _foo - _bar + 4 - * r_type=X86_64_RELOC_SUBTRACTOR, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_bar - * r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_foo - * 04 00 00 00 00 00 00 00 - * - * .long _foo - _bar - * r_type=X86_64_RELOC_SUBTRACTOR, r_length=2, r_extern=1, r_pcrel=0, r_symbolnum=_bar - * r_type=X86_64_RELOC_UNSIGNED, r_length=2, r_extern=1, r_pcrel=0, r_symbolnum=_foo - * 00 00 00 00 - * - * lea L1(%rip), %rax - * r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_prev - * 48 8d 05 12 00 00 00 - * // assumes _prev is the first non-local label 0x12 bytes before L1 - * - * lea L0(%rip), %rax - * r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=0, r_pcrel=1, r_symbolnum=3 - * 48 8d 05 56 00 00 00 - * // assumes L0 is in third section and there is no previous non-local label. - * // The rip-relative-offset of 0x00000056 is L0-address_of_next_instruction. - * // address_of_next_instruction is the address of the relocation + 4. - * - * add $6,L0(%rip) - * r_type=X86_64_RELOC_SIGNED_1, r_length=2, r_extern=0, r_pcrel=1, r_symbolnum=3 - * 83 05 18 00 00 00 06 - * // assumes L0 is in third section and there is no previous non-local label. - * // The rip-relative-offset of 0x00000018 is L0-address_of_next_instruction. - * // address_of_next_instruction is the address of the relocation + 4 + 1. - * // The +1 comes from SIGNED_1. This is used because the relocation is not - * // at the end of the instruction. - * - * .quad L1 - * r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_prev - * 12 00 00 00 00 00 00 00 - * // assumes _prev is the first non-local label 0x12 bytes before L1 - * - * .quad L0 - * r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=0, r_pcrel=0, r_symbolnum=3 - * 56 00 00 00 00 00 00 00 - * // assumes L0 is in third section, has an address of 0x00000056 in .o - * // file, and there is no previous non-local label - * - * .quad _foo - . - * r_type=X86_64_RELOC_SUBTRACTOR, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_prev - * r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_foo - * EE FF FF FF FF FF FF FF - * // assumes _prev is the first non-local label 0x12 bytes before this - * // .quad - * - * .quad _foo - L1 - * r_type=X86_64_RELOC_SUBTRACTOR, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_prev - * r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_foo - * EE FF FF FF FF FF FF FF - * // assumes _prev is the first non-local label 0x12 bytes before L1 - * - * .quad L1 - _prev - * // No relocations. This is an assembly time constant. - * 12 00 00 00 00 00 00 00 - * // assumes _prev is the first non-local label 0x12 bytes before L1 - * - * - * - * In final linked images, there are only two valid relocation kinds: - * - * r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_pcrel=0, r_extern=1, r_symbolnum=sym_index - * This tells dyld to add the address of a symbol to a pointer sized (8-byte) - * piece of data (i.e on disk the 8-byte piece of data contains the addend). The - * r_symbolnum contains the index into the symbol table of the target symbol. - * - * r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_pcrel=0, r_extern=0, r_symbolnum=0 - * This tells dyld to adjust the pointer sized (8-byte) piece of data by the amount - * the containing image was loaded from its base address (e.g. slide). - * - */ -enum reloc_type_x86_64 -{ - X86_64_RELOC_UNSIGNED, // for absolute addresses - X86_64_RELOC_SIGNED, // for signed 32-bit displacement - X86_64_RELOC_BRANCH, // a CALL/JMP instruction with 32-bit displacement - X86_64_RELOC_GOT_LOAD, // a MOVQ load of a GOT entry - X86_64_RELOC_GOT, // other GOT references - X86_64_RELOC_SUBTRACTOR, // must be followed by a X86_64_RELOC_UNSIGNED - X86_64_RELOC_SIGNED_1, // for signed 32-bit displacement with a -1 addend - X86_64_RELOC_SIGNED_2, // for signed 32-bit displacement with a -2 addend - X86_64_RELOC_SIGNED_4, // for signed 32-bit displacement with a -4 addend - X86_64_RELOC_TLV, // for thread local variables -}; diff --git a/include/darwin/mach/machine.h b/include/darwin/mach/machine.h deleted file mode 100644 index e5edf4320..000000000 --- a/include/darwin/mach/machine.h +++ /dev/null @@ -1,343 +0,0 @@ -/* - * Copyright (c) 2000-2007 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@ - */ -/* - * 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 Software.Distribution@CS.CMU.EDU - * 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: machine.h - * Author: Avadis Tevanian, Jr. - * Date: 1986 - * - * Machine independent machine abstraction. - */ - -#ifndef _MACH_MACHINE_H_ -#define _MACH_MACHINE_H_ - -#include -//#include -//#include - -//typedef uint32_t integer_t; - -typedef integer_t cpu_type_t; -typedef integer_t cpu_subtype_t; -typedef integer_t cpu_threadtype_t; - -#define CPU_STATE_MAX 4 - -#define CPU_STATE_USER 0 -#define CPU_STATE_SYSTEM 1 -#define CPU_STATE_IDLE 2 -#define CPU_STATE_NICE 3 - - - -/* - * Capability bits used in the definition of cpu_type. - */ -#define CPU_ARCH_MASK 0xff000000 /* mask for architecture bits */ -#define CPU_ARCH_ABI64 0x01000000 /* 64 bit ABI */ - -/* - * Machine types known by all. - */ - -#define CPU_TYPE_ANY ((cpu_type_t) -1) - -#define CPU_TYPE_VAX ((cpu_type_t) 1) -/* skip ((cpu_type_t) 2) */ -/* skip ((cpu_type_t) 3) */ -/* skip ((cpu_type_t) 4) */ -/* skip ((cpu_type_t) 5) */ -#define CPU_TYPE_MC680x0 ((cpu_type_t) 6) -#define CPU_TYPE_X86 ((cpu_type_t) 7) -#define CPU_TYPE_I386 CPU_TYPE_X86 /* compatibility */ -#define CPU_TYPE_X86_64 (CPU_TYPE_X86 | CPU_ARCH_ABI64) - -/* skip CPU_TYPE_MIPS ((cpu_type_t) 8) */ -/* skip ((cpu_type_t) 9) */ -#define CPU_TYPE_MC98000 ((cpu_type_t) 10) -#define CPU_TYPE_HPPA ((cpu_type_t) 11) -#define CPU_TYPE_ARM ((cpu_type_t) 12) -#define CPU_TYPE_MC88000 ((cpu_type_t) 13) -#define CPU_TYPE_SPARC ((cpu_type_t) 14) -#define CPU_TYPE_I860 ((cpu_type_t) 15) -/* skip CPU_TYPE_ALPHA ((cpu_type_t) 16) */ -/* skip ((cpu_type_t) 17) */ -#define CPU_TYPE_POWERPC ((cpu_type_t) 18) -#define CPU_TYPE_POWERPC64 (CPU_TYPE_POWERPC | CPU_ARCH_ABI64) - -/* - * Machine subtypes (these are defined here, instead of in a machine - * dependent directory, so that any program can get all definitions - * regardless of where is it compiled). - */ - -/* - * Capability bits used in the definition of cpu_subtype. - */ -#define CPU_SUBTYPE_MASK 0xff000000 /* mask for feature flags */ -#define CPU_SUBTYPE_LIB64 0x80000000 /* 64 bit libraries */ - - -/* - * Object files that are hand-crafted to run on any - * implementation of an architecture are tagged with - * CPU_SUBTYPE_MULTIPLE. This functions essentially the same as - * the "ALL" subtype of an architecture except that it allows us - * to easily find object files that may need to be modified - * whenever a new implementation of an architecture comes out. - * - * It is the responsibility of the implementor to make sure the - * software handles unsupported implementations elegantly. - */ -#define CPU_SUBTYPE_MULTIPLE ((cpu_subtype_t) -1) -#define CPU_SUBTYPE_LITTLE_ENDIAN ((cpu_subtype_t) 0) -#define CPU_SUBTYPE_BIG_ENDIAN ((cpu_subtype_t) 1) - -/* - * Machine threadtypes. - * This is none - not defined - for most machine types/subtypes. - */ -#define CPU_THREADTYPE_NONE ((cpu_threadtype_t) 0) - -/* - * VAX subtypes (these do *not* necessary conform to the actual cpu - * ID assigned by DEC available via the SID register). - */ - -#define CPU_SUBTYPE_VAX_ALL ((cpu_subtype_t) 0) -#define CPU_SUBTYPE_VAX780 ((cpu_subtype_t) 1) -#define CPU_SUBTYPE_VAX785 ((cpu_subtype_t) 2) -#define CPU_SUBTYPE_VAX750 ((cpu_subtype_t) 3) -#define CPU_SUBTYPE_VAX730 ((cpu_subtype_t) 4) -#define CPU_SUBTYPE_UVAXI ((cpu_subtype_t) 5) -#define CPU_SUBTYPE_UVAXII ((cpu_subtype_t) 6) -#define CPU_SUBTYPE_VAX8200 ((cpu_subtype_t) 7) -#define CPU_SUBTYPE_VAX8500 ((cpu_subtype_t) 8) -#define CPU_SUBTYPE_VAX8600 ((cpu_subtype_t) 9) -#define CPU_SUBTYPE_VAX8650 ((cpu_subtype_t) 10) -#define CPU_SUBTYPE_VAX8800 ((cpu_subtype_t) 11) -#define CPU_SUBTYPE_UVAXIII ((cpu_subtype_t) 12) - -/* - * 680x0 subtypes - * - * The subtype definitions here are unusual for historical reasons. - * NeXT used to consider 68030 code as generic 68000 code. For - * backwards compatability: - * - * CPU_SUBTYPE_MC68030 symbol has been preserved for source code - * compatability. - * - * CPU_SUBTYPE_MC680x0_ALL has been defined to be the same - * subtype as CPU_SUBTYPE_MC68030 for binary comatability. - * - * CPU_SUBTYPE_MC68030_ONLY has been added to allow new object - * files to be tagged as containing 68030-specific instructions. - */ - -#define CPU_SUBTYPE_MC680x0_ALL ((cpu_subtype_t) 1) -#define CPU_SUBTYPE_MC68030 ((cpu_subtype_t) 1) /* compat */ -#define CPU_SUBTYPE_MC68040 ((cpu_subtype_t) 2) -#define CPU_SUBTYPE_MC68030_ONLY ((cpu_subtype_t) 3) - -/* - * I386 subtypes - */ - -#define CPU_SUBTYPE_INTEL(f, m) ((cpu_subtype_t) (f) + ((m) << 4)) - -#define CPU_SUBTYPE_I386_ALL CPU_SUBTYPE_INTEL(3, 0) -#define CPU_SUBTYPE_386 CPU_SUBTYPE_INTEL(3, 0) -#define CPU_SUBTYPE_486 CPU_SUBTYPE_INTEL(4, 0) -#define CPU_SUBTYPE_486SX CPU_SUBTYPE_INTEL(4, 8) // 8 << 4 = 128 -#define CPU_SUBTYPE_586 CPU_SUBTYPE_INTEL(5, 0) -#define CPU_SUBTYPE_PENT CPU_SUBTYPE_INTEL(5, 0) -#define CPU_SUBTYPE_PENTPRO CPU_SUBTYPE_INTEL(6, 1) -#define CPU_SUBTYPE_PENTII_M3 CPU_SUBTYPE_INTEL(6, 3) -#define CPU_SUBTYPE_PENTII_M5 CPU_SUBTYPE_INTEL(6, 5) -#define CPU_SUBTYPE_CELERON CPU_SUBTYPE_INTEL(7, 6) -#define CPU_SUBTYPE_CELERON_MOBILE CPU_SUBTYPE_INTEL(7, 7) -#define CPU_SUBTYPE_PENTIUM_3 CPU_SUBTYPE_INTEL(8, 0) -#define CPU_SUBTYPE_PENTIUM_3_M CPU_SUBTYPE_INTEL(8, 1) -#define CPU_SUBTYPE_PENTIUM_3_XEON CPU_SUBTYPE_INTEL(8, 2) -#define CPU_SUBTYPE_PENTIUM_M CPU_SUBTYPE_INTEL(9, 0) -#define CPU_SUBTYPE_PENTIUM_4 CPU_SUBTYPE_INTEL(10, 0) -#define CPU_SUBTYPE_PENTIUM_4_M CPU_SUBTYPE_INTEL(10, 1) -#define CPU_SUBTYPE_ITANIUM CPU_SUBTYPE_INTEL(11, 0) -#define CPU_SUBTYPE_ITANIUM_2 CPU_SUBTYPE_INTEL(11, 1) -#define CPU_SUBTYPE_XEON CPU_SUBTYPE_INTEL(12, 0) -#define CPU_SUBTYPE_XEON_MP CPU_SUBTYPE_INTEL(12, 1) - -#define CPU_SUBTYPE_INTEL_FAMILY(x) ((x) & 15) -#define CPU_SUBTYPE_INTEL_FAMILY_MAX 15 - -#define CPU_SUBTYPE_INTEL_MODEL(x) ((x) >> 4) -#define CPU_SUBTYPE_INTEL_MODEL_ALL 0 - -/* - * X86 subtypes. - */ - -#define CPU_SUBTYPE_X86_ALL ((cpu_subtype_t)3) -#define CPU_SUBTYPE_X86_64_ALL ((cpu_subtype_t)3) -#define CPU_SUBTYPE_X86_ARCH1 ((cpu_subtype_t)4) - - -#define CPU_THREADTYPE_INTEL_HTT ((cpu_threadtype_t) 1) - -/* - * Mips subtypes. - */ - -#define CPU_SUBTYPE_MIPS_ALL ((cpu_subtype_t) 0) -#define CPU_SUBTYPE_MIPS_R2300 ((cpu_subtype_t) 1) -#define CPU_SUBTYPE_MIPS_R2600 ((cpu_subtype_t) 2) -#define CPU_SUBTYPE_MIPS_R2800 ((cpu_subtype_t) 3) -#define CPU_SUBTYPE_MIPS_R2000a ((cpu_subtype_t) 4) /* pmax */ -#define CPU_SUBTYPE_MIPS_R2000 ((cpu_subtype_t) 5) -#define CPU_SUBTYPE_MIPS_R3000a ((cpu_subtype_t) 6) /* 3max */ -#define CPU_SUBTYPE_MIPS_R3000 ((cpu_subtype_t) 7) - -/* - * MC98000 (PowerPC) subtypes - */ -#define CPU_SUBTYPE_MC98000_ALL ((cpu_subtype_t) 0) -#define CPU_SUBTYPE_MC98601 ((cpu_subtype_t) 1) - -/* - * HPPA subtypes for Hewlett-Packard HP-PA family of - * risc processors. Port by NeXT to 700 series. - */ - -#define CPU_SUBTYPE_HPPA_ALL ((cpu_subtype_t) 0) -#define CPU_SUBTYPE_HPPA_7100 ((cpu_subtype_t) 0) /* compat */ -#define CPU_SUBTYPE_HPPA_7100LC ((cpu_subtype_t) 1) - -/* - * MC88000 subtypes. - */ -#define CPU_SUBTYPE_MC88000_ALL ((cpu_subtype_t) 0) -#define CPU_SUBTYPE_MC88100 ((cpu_subtype_t) 1) -#define CPU_SUBTYPE_MC88110 ((cpu_subtype_t) 2) - -/* - * SPARC subtypes - */ -#define CPU_SUBTYPE_SPARC_ALL ((cpu_subtype_t) 0) - -/* - * I860 subtypes - */ -#define CPU_SUBTYPE_I860_ALL ((cpu_subtype_t) 0) -#define CPU_SUBTYPE_I860_860 ((cpu_subtype_t) 1) - -/* - * PowerPC subtypes - */ -#define CPU_SUBTYPE_POWERPC_ALL ((cpu_subtype_t) 0) -#define CPU_SUBTYPE_POWERPC_601 ((cpu_subtype_t) 1) -#define CPU_SUBTYPE_POWERPC_602 ((cpu_subtype_t) 2) -#define CPU_SUBTYPE_POWERPC_603 ((cpu_subtype_t) 3) -#define CPU_SUBTYPE_POWERPC_603e ((cpu_subtype_t) 4) -#define CPU_SUBTYPE_POWERPC_603ev ((cpu_subtype_t) 5) -#define CPU_SUBTYPE_POWERPC_604 ((cpu_subtype_t) 6) -#define CPU_SUBTYPE_POWERPC_604e ((cpu_subtype_t) 7) -#define CPU_SUBTYPE_POWERPC_620 ((cpu_subtype_t) 8) -#define CPU_SUBTYPE_POWERPC_750 ((cpu_subtype_t) 9) -#define CPU_SUBTYPE_POWERPC_7400 ((cpu_subtype_t) 10) -#define CPU_SUBTYPE_POWERPC_7450 ((cpu_subtype_t) 11) -#define CPU_SUBTYPE_POWERPC_970 ((cpu_subtype_t) 100) - -/* - * ARM subtypes - */ -#define CPU_SUBTYPE_ARM_ALL ((cpu_subtype_t) 0) -#define CPU_SUBTYPE_ARM_V4T ((cpu_subtype_t) 5) -#define CPU_SUBTYPE_ARM_V6 ((cpu_subtype_t) 6) -#define CPU_SUBTYPE_ARM_V5TEJ ((cpu_subtype_t) 7) -#define CPU_SUBTYPE_ARM_XSCALE ((cpu_subtype_t) 8) -#define CPU_SUBTYPE_ARM_V7 ((cpu_subtype_t) 9) - -/* - * CPU families (sysctl hw.cpufamily) - * - * These are meant to identify the CPU's marketing name - an - * application can map these to (possibly) localized strings. - * NB: the encodings of the CPU families are intentionally arbitrary. - * There is no ordering, and you should never try to deduce whether - * or not some feature is available based on the family. - * Use feature flags (eg, hw.optional.altivec) to test for optional - * functionality. - */ -#define CPUFAMILY_UNKNOWN 0 -#define CPUFAMILY_POWERPC_G3 0xcee41549 -#define CPUFAMILY_POWERPC_G4 0x77c184ae -#define CPUFAMILY_POWERPC_G5 0xed76d8aa -#define CPUFAMILY_INTEL_6_13 0xaa33392b -#define CPUFAMILY_INTEL_6_14 0x73d67300 /* "Intel Core Solo" and "Intel Core Duo" (32-bit Pentium-M with SSE3) */ -#define CPUFAMILY_INTEL_6_15 0x426f69ef /* "Intel Core 2 Duo" */ -#define CPUFAMILY_INTEL_6_23 0x78ea4fbc /* Penryn */ -#define CPUFAMILY_INTEL_6_26 0x6b5a4cd2 /* Nehalem */ -#define CPUFAMILY_ARM_9 0xe73283ae -#define CPUFAMILY_ARM_11 0x8ff620d8 -#define CPUFAMILY_ARM_XSCALE 0x53b005f5 -#define CPUFAMILY_ARM_13 0x0cc90e64 - -#define CPUFAMILY_INTEL_YONAH CPUFAMILY_INTEL_6_14 -#define CPUFAMILY_INTEL_MEROM CPUFAMILY_INTEL_6_15 -#define CPUFAMILY_INTEL_PENRYN CPUFAMILY_INTEL_6_23 -#define CPUFAMILY_INTEL_NEHALEM CPUFAMILY_INTEL_6_26 - -#define CPUFAMILY_INTEL_CORE CPUFAMILY_INTEL_6_14 -#define CPUFAMILY_INTEL_CORE2 CPUFAMILY_INTEL_6_15 - -#endif /* _MACH_MACHINE_H_ */ diff --git a/include/darwin/mach/vm_prot.h b/include/darwin/mach/vm_prot.h deleted file mode 100644 index 2dcd4432d..000000000 --- a/include/darwin/mach/vm_prot.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2000-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@ - */ -/* - * @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 Software.Distribution@CS.CMU.EDU - * 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/vm_prot.h - * Author: Avadis Tevanian, Jr., Michael Wayne Young - * - * Virtual memory protection definitions. - * - */ - -#ifndef _MACH_VM_PROT_H_ -#define _MACH_VM_PROT_H_ - -/* - * Types defined: - * - * vm_prot_t VM protection values. - */ - -typedef int vm_prot_t; - -/* - * Protection values, defined as bits within the vm_prot_t type - */ - -#define VM_PROT_NONE ((vm_prot_t) 0x00) - -#define VM_PROT_READ ((vm_prot_t) 0x01) /* read permission */ -#define VM_PROT_WRITE ((vm_prot_t) 0x02) /* write permission */ -#define VM_PROT_EXECUTE ((vm_prot_t) 0x04) /* execute permission */ - -/* - * The default protection for newly-created virtual memory - */ - -#define VM_PROT_DEFAULT (VM_PROT_READ|VM_PROT_WRITE) - -/* - * The maximum privileges possible, for parameter checking. - */ - -#define VM_PROT_ALL (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE) - -/* - * An invalid protection value. - * Used only by memory_object_lock_request to indicate no change - * to page locks. Using -1 here is a bad idea because it - * looks like VM_PROT_ALL and then some. - */ - -#define VM_PROT_NO_CHANGE ((vm_prot_t) 0x08) - -/* - * When a caller finds that he cannot obtain write permission on a - * mapped entry, the following flag can be used. The entry will - * be made "needs copy" effectively copying the object (using COW), - * and write permission will be added to the maximum protections - * for the associated entry. - */ - -#define VM_PROT_COPY ((vm_prot_t) 0x10) - - -/* - * Another invalid protection value. - * Used only by memory_object_data_request upon an object - * which has specified a copy_call copy strategy. It is used - * when the kernel wants a page belonging to a copy of the - * object, and is only asking the object as a result of - * following a shadow chain. This solves the race between pages - * being pushed up by the memory manager and the kernel - * walking down the shadow chain. - */ - -#define VM_PROT_WANTS_COPY ((vm_prot_t) 0x10) - - -#endif /* _MACH_VM_PROT_H_ */ diff --git a/include/darwin/runetype.h b/include/darwin/runetype.h deleted file mode 100644 index 9458b0432..000000000 --- a/include/darwin/runetype.h +++ /dev/null @@ -1,140 +0,0 @@ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)runetype.h 8.1 (Berkeley) 6/2/93 - */ - -#ifndef _RUNETYPE_H_ -#define _RUNETYPE_H_ - -#include <_types.h> -#include - -typedef wchar_t __darwin_rune_t; -typedef size_t __darwin_size_t; - -#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) - -#ifndef _SIZE_T -#define _SIZE_T -typedef __darwin_size_t size_t; -#endif - -#ifndef _CT_RUNE_T -#define _CT_RUNE_T -typedef __darwin_ct_rune_t ct_rune_t; -#endif - -#ifndef _RUNE_T -#define _RUNE_T -typedef __darwin_rune_t rune_t; -#endif - -#ifndef __cplusplus -#ifndef _WCHAR_T -#define _WCHAR_T -typedef __darwin_wchar_t wchar_t; -#endif /* _WCHAR_T */ -#endif /* __cplusplus */ - -#ifndef _WINT_T -#define _WINT_T -typedef __darwin_wint_t wint_t; -#endif - -#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ - -#define _CACHED_RUNES (1 <<8 ) /* Must be a power of 2 */ -#define _CRMASK (~(_CACHED_RUNES - 1)) - -/* - * The lower 8 bits of runetype[] contain the digit value of the rune. - */ -typedef struct { - __darwin_rune_t __min; /* First rune of the range */ - __darwin_rune_t __max; /* Last rune (inclusive) of the range */ - __darwin_rune_t __map; /* What first maps to in maps */ - uint32_t *__types; /* Array of types in range */ -} _RuneEntry; - -typedef struct { - int __nranges; /* Number of ranges stored */ - _RuneEntry *__ranges; /* Pointer to the ranges */ -} _RuneRange; - -typedef struct { - char __name[14]; /* CHARCLASS_NAME_MAX = 14 */ - uint32_t __mask; /* charclass mask */ -} _RuneCharClass; - -typedef struct { - char __magic[8]; /* Magic saying what version we are */ - char __encoding[32]; /* ASCII name of this encoding */ - - __darwin_rune_t (*__sgetrune)(const char *, __darwin_size_t, char const **); - int (*__sputrune)(__darwin_rune_t, char *, __darwin_size_t, char **); - __darwin_rune_t __invalid_rune; - - uint32_t __runetype[_CACHED_RUNES]; - __darwin_rune_t __maplower[_CACHED_RUNES]; - __darwin_rune_t __mapupper[_CACHED_RUNES]; - - /* - * The following are to deal with Runes larger than _CACHED_RUNES - 1. - * Their data is actually contiguous with this structure so as to make - * it easier to read/write from/to disk. - */ - _RuneRange __runetype_ext; - _RuneRange __maplower_ext; - _RuneRange __mapupper_ext; - - void *__variable; /* Data which depends on the encoding */ - int __variable_len; /* how long that data is */ - - /* - * extra fields to deal with arbitrary character classes - */ - int __ncharclasses; - _RuneCharClass *__charclasses; -} _RuneLocale; - -#define _RUNE_MAGIC_A "RuneMagA" /* Indicates version A of RuneLocale */ - -__BEGIN_DECLS -extern _RuneLocale _DefaultRuneLocale; -extern _RuneLocale *_CurrentRuneLocale; -__END_DECLS - -#endif /* !_RUNETYPE_H_ */ diff --git a/include/xnu/bsd/i386/_types.h b/include/xnu/bsd/i386/_types.h deleted file mode 100644 index 2f385a900..000000000 --- a/include/xnu/bsd/i386/_types.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2000-2003 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@ - */ -#ifndef _BSD_I386__TYPES_H_ -#define _BSD_I386__TYPES_H_ - -/* - * This header file contains integer types. It's intended to also contain - * flotaing point and other arithmetic types, as needed, later. - */ - -/* Some of these are provided by standard Linux headers */ - -#ifdef __GNUC__ -typedef __signed char __int8_t; -#else -typedef char __int8_t; -#endif -typedef unsigned char __uint8_t; -typedef short __int16_t; -typedef unsigned short __uint16_t; -typedef int __int32_t; -typedef unsigned int __uint32_t; -/* -typedef long long __int64_t; -typedef unsigned long long __uint64_t; -*/ -typedef long __darwin_intptr_t; -typedef unsigned int __darwin_natural_t; - -/* - * The rune type below is declared to be an ``int'' instead of the more natural - * ``unsigned long'' or ``long''. Two things are happening here. It is not - * unsigned so that EOF (-1) can be naturally assigned to it and used. Also, - * it looks like 10646 will be a 31 bit standard. This means that if your - * ints cannot hold 32 bits, you will be in trouble. The reason an int was - * chosen over a long is that the is*() and to*() routines take ints (says - * ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it - * here, you lose a bit of ANSI conformance, but your programs will still - * work. - * - * NOTE: rune_t is not covered by ANSI nor other standards, and should not - * be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and - * rune_t must be the same type. Also wint_t must be no narrower than - * wchar_t, and should also be able to hold all members of the largest - * character set plus one extra value (WEOF). wint_t must be at least 16 bits. - */ - -typedef int __darwin_ct_rune_t; /* ct_rune_t */ - -/* - * mbstate_t is an opaque object to keep conversion state, during multibyte - * stream conversions. The content must not be referenced by user programs. - */ - -typedef union { - char __mbstate8[128]; - long long _mbstateL; /* for alignment */ -} __darwin_mbstate_t; - - -/*typedef __mbstate_t __darwin_mbstate_t;*/ - -#if defined(__GNUC__) && defined(__PTRDIFF_TYPE__) -typedef __PTRDIFF_TYPE__ __darwin_ptrdiff_t; /* ptr1 - ptr2 */ -#else -typedef int __darwin_ptrdiff_t; /* ptr1 - ptr2 */ -#endif /* __GNUC__ */ - -#if defined(__GNUC__) && defined(__SIZE_TYPE__) -typedef __SIZE_TYPE__ __darwin_size_t; /* sizeof() */ -#else -typedef unsigned long __darwin_size_t; /* sizeof() */ -#endif - -#if (__GNUC__ > 2) -typedef __builtin_va_list __darwin_va_list; /* va_list */ -#else -typedef void * __darwin_va_list; /* va_list */ -#endif - -#if defined(__GNUC__) && defined(__WCHAR_TYPE__) -typedef __WCHAR_TYPE__ __darwin_wchar_t; /* wchar_t */ -#else -typedef __darwin_ct_rune_t __darwin_wchar_t; /* wchar_t */ -#endif - -typedef __darwin_wchar_t __darwin_rune_t; /* rune_t */ - -#if defined(__GNUC__) && defined(__WINT_TYPE__) -typedef __WINT_TYPE__ __darwin_wint_t; /* wint_t */ -#else -typedef __darwin_ct_rune_t __darwin_wint_t; /* wint_t */ -#endif - -typedef unsigned long __darwin_clock_t; /* clock() */ -typedef __uint32_t __darwin_socklen_t; /* socklen_t (duh) */ -typedef long __darwin_ssize_t; /* byte count or error */ -typedef long __darwin_time_t; /* time() */ - -#endif /* _BSD_I386__TYPES_H_ */ diff --git a/include/xnu/bsd/sys/appleapiopts.h b/include/xnu/bsd/sys/appleapiopts.h deleted file mode 100644 index 20557019b..000000000 --- a/include/xnu/bsd/sys/appleapiopts.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 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@ - */ - -#ifndef __SYS_APPLEAPIOPTS_H__ -#define __SYS_APPLEAPIOPTS_H__ - - -#ifndef __APPLE_API_STANDARD -#define __APPLE_API_STANDARD -#endif /* __APPLE_API_STANDARD */ - -#ifndef __APPLE_API_STABLE -#define __APPLE_API_STABLE -#endif /* __APPLE_API_STABLE */ - -#ifndef __APPLE_API_STRICT_CONFORMANCE - -#ifndef __APPLE_API_EVOLVING -#define __APPLE_API_EVOLVING -#endif /* __APPLE_API_EVOLVING */ - -#ifndef __APPLE_API_UNSTABLE -#define __APPLE_API_UNSTABLE -#endif /* __APPLE_API_UNSTABLE */ - -#ifndef __APPLE_API_PRIVATE -#define __APPLE_API_PRIVATE -#endif /* __APPLE_API_PRIVATE */ - -#ifndef __APPLE_API_OBSOLETE -#define __APPLE_API_OBSOLETE -#endif /* __APPLE_API_OBSOLETE */ - -#endif /* __APPLE_API_STRICT_CONFORMANCE */ - -#endif /* __SYS_APPLEAPIOPTS_H__ */ - diff --git a/include/xnu/i386/eflags.h b/include/xnu/i386/eflags.h deleted file mode 100644 index 9dc64783e..000000000 --- a/include/xnu/i386/eflags.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2000-2005 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@ - */ -/* - * @OSF_COPYRIGHT@ - */ -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989 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 Software.Distribution@CS.CMU.EDU - * 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. - */ -/* - */ - -#ifndef _I386_EFLAGS_H_ -#define _I386_EFLAGS_H_ - -/* - * i386 flags register - */ - -#ifndef EFL_CF -#define EFL_CF 0x00000001 /* carry */ -#define EFL_PF 0x00000004 /* parity of low 8 bits */ -#define EFL_AF 0x00000010 /* carry out of bit 3 */ -#define EFL_ZF 0x00000040 /* zero */ -#define EFL_SF 0x00000080 /* sign */ -#define EFL_TF 0x00000100 /* trace trap */ -#define EFL_IF 0x00000200 /* interrupt enable */ -#define EFL_DF 0x00000400 /* direction */ -#define EFL_OF 0x00000800 /* overflow */ -#define EFL_IOPL 0x00003000 /* IO privilege level: */ -#define EFL_IOPL_KERNEL 0x00000000 /* kernel */ -#define EFL_IOPL_USER 0x00003000 /* user */ -#define EFL_NT 0x00004000 /* nested task */ -#define EFL_RF 0x00010000 /* resume without tracing */ -#define EFL_VM 0x00020000 /* virtual 8086 mode */ -#define EFL_AC 0x00040000 /* alignment check */ -#define EFL_VIF 0x00080000 /* virtual interrupt flag */ -#define EFL_VIP 0x00100000 /* virtual interrupt pending */ -#define EFL_ID 0x00200000 /* cpuID instruction */ -#endif - -#define EFL_CLR 0xfff88028 -#define EFL_SET 0x00000002 - -#define EFL_USER_SET (EFL_IF) -#define EFL_USER_CLEAR (EFL_IOPL|EFL_NT|EFL_RF) - -#endif /* _I386_EFLAGS_H_ */ diff --git a/include/xnu/mach/alert.h b/include/xnu/mach/alert.h deleted file mode 100644 index 4365af96a..000000000 --- a/include/xnu/mach/alert.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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@ - */ -/* - * @OSF_FREE_COPYRIGHT@ - */ -/* - * HISTORY - * - * Revision 1.1.1.1 1998/09/22 21:05:31 wsanchez - * Import of Mac OS X kernel (~semeria) - * - * Revision 1.1.1.1 1998/03/07 02:25:45 wsanchez - * Import of OSF Mach kernel (~mburg) - * - * Revision 1.1.5.2 1995/01/18 18:35:06 ezf - * updated Utah CR notice - * [1995/01/18 18:30:38 ezf] - * - * Revision 1.1.5.1 1994/09/23 02:33:53 ezf - * change marker to not FREE - * [1994/09/22 21:38:56 ezf] - * - * Revision 1.1.2.1 1994/01/12 17:56:03 dwm - * Coloc: initial restructuring to follow Utah model. - * Alert bit definitions - * [1994/01/12 17:30:19 dwm] - * - * $EndLog$ - */ -/* - * Copyright (c) 1993 The University of Utah and - * the Computer Systems Laboratory (CSL). 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. - * - * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS - * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF - * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * CSL requests users of this software to return to csl-dist@cs.utah.edu any - * improvements that they make and grant CSL redistribution rights. - * - */ - -#ifndef _MACH_ALERT_H_ -#define _MACH_ALERT_H_ - -#define ALERT_BITS 32 /* Minimum; more may actually be available */ - -/* Request to abort _all_ operations */ -#define ALERT_ABORT_STRONG 0x00000001 - -/* Request to abort restartable operations */ -#define ALERT_ABORT_SAFE 0x00000002 - -/* User-defined alert bits */ -#define ALERT_USER 0xffff0000 - -#endif /* _MACH_ALERT_H_ */ diff --git a/include/xnu/mach/boolean.h b/include/xnu/mach/boolean.h deleted file mode 100644 index 641c3962d..000000000 --- a/include/xnu/mach/boolean.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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@ - */ -/* - * @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 Software.Distribution@CS.CMU.EDU - * 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/boolean.h - * - * Boolean data type. - * - */ - -#ifndef _MACH_BOOLEAN_H_ -#define _MACH_BOOLEAN_H_ - -/* - * Pick up "boolean_t" type definition - */ - -#ifndef ASSEMBLER -#include -#endif /* ASSEMBLER */ - -/* - * Define TRUE and FALSE if not defined. - */ - -#ifndef TRUE -#define TRUE 1 -#endif /* TRUE */ - -#ifndef FALSE -#define FALSE 0 -#endif /* FALSE */ - -#endif /* _MACH_BOOLEAN_H_ */ diff --git a/include/xnu/mach/bootstrap.h b/include/xnu/mach/bootstrap.h deleted file mode 100644 index 67667c308..000000000 --- a/include/xnu/mach/bootstrap.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 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@ - */ -/* - * Mach bootstrap interfaces (obsolete: header included only for compatibility) - */ -#ifndef _MACH_BOOTSTRAP_H_ -#define _MACH_BOOTSTRAP_H_ - -#endif /* _MACH_BOOTSTRAP_H_ */ diff --git a/include/xnu/mach/branch_predicates.h b/include/xnu/mach/branch_predicates.h deleted file mode 100644 index 8d16db0fa..000000000 --- a/include/xnu/mach/branch_predicates.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2000-2009 Apple 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@ - */ - - -#ifndef _MACH_BRANCH_PREDICATES_H -#define _MACH_BRANCH_PREDICATES_H - -#define __probable(x) __builtin_expect((x), 1) -#define __improbable(x) __builtin_expect((x), 0) -#endif /* _MACH_BRANCH_PREDICATES_H */ diff --git a/include/xnu/mach/clock_types.h b/include/xnu/mach/clock_types.h deleted file mode 100644 index e020066d1..000000000 --- a/include/xnu/mach/clock_types.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * 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@ - */ -/* - * @OSF_COPYRIGHT@ - */ -/* - * File: clock_types.h - * Purpose: Clock facility header definitions. These - * definitons are needed by both kernel and - * user-level software. - */ - -/* - * All interfaces defined here are obsolete. - */ - -#ifndef _MACH_CLOCK_TYPES_H_ -#define _MACH_CLOCK_TYPES_H_ - -#include -#include - -/* - * Type definitions. - */ -typedef int alarm_type_t; /* alarm time type */ -typedef int sleep_type_t; /* sleep time type */ -typedef int clock_id_t; /* clock identification type */ -typedef int clock_flavor_t; /* clock flavor type */ -typedef int *clock_attr_t; /* clock attribute type */ -typedef int clock_res_t; /* clock resolution type */ - -/* - * Normal time specification used by the kernel clock facility. - */ -struct mach_timespec { - unsigned int tv_sec; /* seconds */ - clock_res_t tv_nsec; /* nanoseconds */ -}; -typedef struct mach_timespec mach_timespec_t; - -/* - * Reserved clock id values for default clocks. - */ -#define SYSTEM_CLOCK 0 -#define CALENDAR_CLOCK 1 - -#define REALTIME_CLOCK 0 - -/* - * Attribute names. - */ -#define CLOCK_GET_TIME_RES 1 /* get_time call resolution */ -/* 2 * was map_time call resolution */ -#define CLOCK_ALARM_CURRES 3 /* current alarm resolution */ -#define CLOCK_ALARM_MINRES 4 /* minimum alarm resolution */ -#define CLOCK_ALARM_MAXRES 5 /* maximum alarm resolution */ - -#define NSEC_PER_USEC 1000 /* nanoseconds per microsecond */ -#define USEC_PER_SEC 1000000 /* microseconds per second */ -#define NSEC_PER_SEC 1000000000 /* nanoseconds per second */ -#define NSEC_PER_MSEC 1000000ull /* nanoseconds per millisecond */ - -#define BAD_MACH_TIMESPEC(t) \ - ((t)->tv_nsec < 0 || (t)->tv_nsec >= NSEC_PER_SEC) - -/* t1 <=> t2, also (t1 - t2) in nsec with max of +- 1 sec */ -#define CMP_MACH_TIMESPEC(t1, t2) \ - ((t1)->tv_sec > (t2)->tv_sec ? +NSEC_PER_SEC : \ - ((t1)->tv_sec < (t2)->tv_sec ? -NSEC_PER_SEC : \ - (t1)->tv_nsec - (t2)->tv_nsec)) - -/* t1 += t2 */ -#define ADD_MACH_TIMESPEC(t1, t2) \ - do { \ - if (((t1)->tv_nsec += (t2)->tv_nsec) >= NSEC_PER_SEC) { \ - (t1)->tv_nsec -= NSEC_PER_SEC; \ - (t1)->tv_sec += 1; \ - } \ - (t1)->tv_sec += (t2)->tv_sec; \ - } while (0) - -/* t1 -= t2 */ -#define SUB_MACH_TIMESPEC(t1, t2) \ - do { \ - if (((t1)->tv_nsec -= (t2)->tv_nsec) < 0) { \ - (t1)->tv_nsec += NSEC_PER_SEC; \ - (t1)->tv_sec -= 1; \ - } \ - (t1)->tv_sec -= (t2)->tv_sec; \ - } while (0) - -/* - * Alarm parameter defines. - */ -#define ALRMTYPE 0xff /* type (8-bit field) */ -#define TIME_ABSOLUTE 0x00 /* absolute time */ -#define TIME_RELATIVE 0x01 /* relative time */ - -#define BAD_ALRMTYPE(t) (((t) &~ TIME_RELATIVE) != 0) - -#endif /* _MACH_CLOCK_TYPES_H_ */ diff --git a/include/xnu/mach/error.h b/include/xnu/mach/error.h deleted file mode 100644 index a32eaee53..000000000 --- a/include/xnu/mach/error.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * 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@ - */ -/* - * @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 Software.Distribution@CS.CMU.EDU - * 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 - * - */ - -#ifndef _MACH_ERROR_H_ -#define _MACH_ERROR_H_ - -#include - -/* - * error number layout as follows: - * - * hi lo - * | system(6) | subsystem(12) | code(14) | - */ - - -#define err_none (mach_error_t)0 -#define ERR_SUCCESS (mach_error_t)0 -#define ERR_ROUTINE_NIL (mach_error_fn_t)0 - - -#define err_system(x) (((x)&0x3f)<<26) -#define err_sub(x) (((x)&0xfff)<<14) - -#define err_get_system(err) (((err)>>26)&0x3f) -#define err_get_sub(err) (((err)>>14)&0xfff) -#define err_get_code(err) ((err)&0x3fff) - -#define system_emask (err_system(0x3f)) -#define sub_emask (err_sub(0xfff)) -#define code_emask (0x3fff) - - -/* major error systems */ -#define err_kern err_system(0x0) /* kernel */ -#define err_us err_system(0x1) /* user space library */ -#define err_server err_system(0x2) /* user space servers */ -#define err_ipc err_system(0x3) /* old ipc errors */ -#define err_mach_ipc err_system(0x4) /* mach-ipc errors */ -#define err_dipc err_system(0x7) /* distributed ipc */ -#define err_local err_system(0x3e) /* user defined errors */ -#define err_ipc_compat err_system(0x3f) /* (compatibility) mach-ipc errors */ - -#define err_max_system 0x3f - - -/* unix errors get lumped into one subsystem */ -#define unix_err(errno) (err_kern|err_sub(3)|errno) - -typedef kern_return_t mach_error_t; -typedef mach_error_t (* mach_error_fn_t)( void ); - -#endif /* _MACH_ERROR_H_ */ diff --git a/include/xnu/mach/events_info.h b/include/xnu/mach/events_info.h deleted file mode 100644 index c48772069..000000000 --- a/include/xnu/mach/events_info.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2000-2005 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@ - */ -/* - * @OSF_FREE_COPYRIGHT@ - */ -/* - * Machine-independent event information structures and definitions. - * - * The definitions in this file are exported to the user. The kernel - * will translate its internal data structures to these structures - * as appropriate. - * - * This data structure is used to track events that occur during - * thread execution, and to summarize this information for tasks. - */ - -#ifndef _MACH_EVENTS_INFO_H_ -#define _MACH_EVENTS_INFO_H_ - -#include - -struct events_info { - integer_t faults; /* number of page faults */ - integer_t zero_fills; /* number of zero fill pages */ - integer_t reactivations; /* number of reactivated pages */ - integer_t pageins; /* number of actual pageins */ - integer_t cow_faults; /* number of copy-on-write faults */ - integer_t messages_sent; /* number of messages sent */ - integer_t messages_received; /* number of messages received */ -}; -typedef struct events_info events_info_data_t; -typedef struct events_info *events_info_t; -#define EVENTS_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof(events_info_data_t) / sizeof(integer_t))) - -#endif /*_MACH_EVENTS_INFO_H_*/ diff --git a/include/xnu/mach/exception.h b/include/xnu/mach/exception.h deleted file mode 100644 index e7d5d236c..000000000 --- a/include/xnu/mach/exception.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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@ - */ -/* - * @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 Software.Distribution@CS.CMU.EDU - * 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. - */ - -#ifndef _MACH_EXCEPTION_H_ -#define _MACH_EXCEPTION_H_ - -#include - -#endif /* _MACH_EXCEPTION_H_ */ diff --git a/include/xnu/mach/exception_types.h b/include/xnu/mach/exception_types.h deleted file mode 100644 index 96de421d2..000000000 --- a/include/xnu/mach/exception_types.h +++ /dev/null @@ -1,193 +0,0 @@ -/* - * 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@ - */ -/* - * @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 Software.Distribution@CS.CMU.EDU - * 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. - */ -/* - */ - -#ifndef _MACH_EXCEPTION_TYPES_H_ -#define _MACH_EXCEPTION_TYPES_H_ - -#include - -/* - * Machine-independent exception definitions. - */ - -#define EXC_BAD_ACCESS 1 /* Could not access memory */ - /* Code contains kern_return_t describing error. */ - /* Subcode contains bad memory address. */ - -#define EXC_BAD_INSTRUCTION 2 /* Instruction failed */ - /* Illegal or undefined instruction or operand */ - -#define EXC_ARITHMETIC 3 /* Arithmetic exception */ - /* Exact nature of exception is in code field */ - -#define EXC_EMULATION 4 /* Emulation instruction */ - /* Emulation support instruction encountered */ - /* Details in code and subcode fields */ - -#define EXC_SOFTWARE 5 /* Software generated exception */ - /* Exact exception is in code field. */ - /* Codes 0 - 0xFFFF reserved to hardware */ - /* Codes 0x10000 - 0x1FFFF reserved for OS emulation (Unix) */ - -#define EXC_BREAKPOINT 6 /* Trace, breakpoint, etc. */ - /* Details in code field. */ - -#define EXC_SYSCALL 7 /* System calls. */ - -#define EXC_MACH_SYSCALL 8 /* Mach system calls. */ - -#define EXC_RPC_ALERT 9 /* RPC alert */ - -#define EXC_CRASH 10 /* Abnormal process exit */ - -#define EXC_RESOURCE 11 /* Hit resource consumption limit */ - /* Exact resource is in code field. */ - -/* - * Machine-independent exception behaviors - */ - -# define EXCEPTION_DEFAULT 1 -/* Send a catch_exception_raise message including the identity. - */ - -# define EXCEPTION_STATE 2 -/* Send a catch_exception_raise_state message including the - * thread state. - */ - -# define EXCEPTION_STATE_IDENTITY 3 -/* Send a catch_exception_raise_state_identity message including - * the thread identity and state. - */ - -#define MACH_EXCEPTION_CODES 0x80000000 -/* Send 64-bit code and subcode in the exception header */ - -/* - * Masks for exception definitions, above - * bit zero is unused, therefore 1 word = 31 exception types - */ - -#define EXC_MASK_BAD_ACCESS (1 << EXC_BAD_ACCESS) -#define EXC_MASK_BAD_INSTRUCTION (1 << EXC_BAD_INSTRUCTION) -#define EXC_MASK_ARITHMETIC (1 << EXC_ARITHMETIC) -#define EXC_MASK_EMULATION (1 << EXC_EMULATION) -#define EXC_MASK_SOFTWARE (1 << EXC_SOFTWARE) -#define EXC_MASK_BREAKPOINT (1 << EXC_BREAKPOINT) -#define EXC_MASK_SYSCALL (1 << EXC_SYSCALL) -#define EXC_MASK_MACH_SYSCALL (1 << EXC_MACH_SYSCALL) -#define EXC_MASK_RPC_ALERT (1 << EXC_RPC_ALERT) -#define EXC_MASK_CRASH (1 << EXC_CRASH) -#define EXC_MASK_RESOURCE (1 << EXC_RESOURCE) - -#define EXC_MASK_ALL (EXC_MASK_BAD_ACCESS | \ - EXC_MASK_BAD_INSTRUCTION | \ - EXC_MASK_ARITHMETIC | \ - EXC_MASK_EMULATION | \ - EXC_MASK_SOFTWARE | \ - EXC_MASK_BREAKPOINT | \ - EXC_MASK_SYSCALL | \ - EXC_MASK_MACH_SYSCALL | \ - EXC_MASK_RPC_ALERT | \ - EXC_MASK_RESOURCE | \ - EXC_MASK_MACHINE) - -#ifdef KERNEL_PRIVATE -#define EXC_MASK_VALID (EXC_MASK_ALL | EXC_MASK_CRASH) -#endif /* KERNEL_PRIVATE */ - -#define FIRST_EXCEPTION 1 /* ZERO is illegal */ - -/* - * Machine independent codes for EXC_SOFTWARE - * Codes 0x10000 - 0x1FFFF reserved for OS emulation (Unix) - * 0x10000 - 0x10002 in use for unix signals - * 0x20000 - 0x2FFFF reserved for MACF - */ -#define EXC_SOFT_SIGNAL 0x10003 /* Unix signal exceptions */ - -#define EXC_MACF_MIN 0x20000 /* MACF exceptions */ -#define EXC_MACF_MAX 0x2FFFF - -#ifndef ASSEMBLER - -#include -#include -#include -/* - * Exported types - */ - -typedef int exception_type_t; -typedef integer_t exception_data_type_t; -typedef int64_t mach_exception_data_type_t; -typedef int exception_behavior_t; -typedef exception_data_type_t *exception_data_t; -typedef mach_exception_data_type_t *mach_exception_data_t; -typedef unsigned int exception_mask_t; -typedef exception_mask_t *exception_mask_array_t; -typedef exception_behavior_t *exception_behavior_array_t; -typedef thread_state_flavor_t *exception_flavor_array_t; -typedef mach_port_t *exception_port_array_t; -typedef mach_exception_data_type_t mach_exception_code_t; -typedef mach_exception_data_type_t mach_exception_subcode_t; - -#endif /* ASSEMBLER */ - -#endif /* _MACH_EXCEPTION_TYPES_H_ */ diff --git a/include/xnu/mach/flipc_cb.h b/include/xnu/mach/flipc_cb.h deleted file mode 100644 index 4c7f969b9..000000000 --- a/include/xnu/mach/flipc_cb.h +++ /dev/null @@ -1,1220 +0,0 @@ -/* - * 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@ - */ -/* - * @OSF_COPYRIGHT@ - * - */ -/* - * HISTORY - * - * Revision 1.1.1.1 1998/09/22 21:05:29 wsanchez - * Import of Mac OS X kernel (~semeria) - * - * Revision 1.1.1.1 1998/03/07 02:25:45 wsanchez - * Import of OSF Mach kernel (~mburg) - * - * Revision 1.1.11.1 1996/09/17 16:34:42 bruel - * fixed types. - * [96/09/17 bruel] - * - * Revision 1.1.6.1 1995/06/13 18:20:10 sjs - * Merged from flipc_shared. - * [95/06/07 sjs] - * - * Revision 1.1.3.14 1995/05/19 00:58:14 sjs - * Added send_ready to shared area, used for fast check if there is something - * to do (and prevents the cache from getting stirred). - * [95/05/18 sjs] - * - * Revision 1.1.3.13 1995/05/16 20:46:28 randys - * Export performance valid information through performance - * structure rather than kernel configuration section. - * [95/05/16 randys] - * - * Added performance (FLIPC_PERF) config information to - * kernel_configuration section of comm buffer, so that user - * programs can find out if this information is being gathered. - * [95/05/16 randys] - * - * Revision 1.1.3.12 1995/05/15 14:26:54 randys - * Updated comments on use of acquire pointer (it's completely - * ignored if dpb is set) and added macros for testing !dpb and - * enabled at the same time. - * [95/05/11 randys] - * - * Change pme_process_ptr ==> sme_process_ptr (since it's being read - * by AIL now). - * [95/05/11 randys] - * - * Added private copied of release and process pointers. - * [95/05/11 randys] - * - * Rearrange endpoint structure to separate data with importantly - * different access patterns into different cache lines. This - * involved duplicating some (effectively constant) entries, and - * creating two versions of some macros. - * [95/05/11 randys] - * - * Revision 1.1.3.11 1995/05/08 16:06:33 randys - * Added comment explaining that an endpoint bufferlist must always - * have valid buffer pointers in all of its entries, to keep - * FLIPC_endpoint_buffer_available from going off the deep end. No - * code changes. - * [95/04/18 randys] - * - * Revision 1.1.3.10 1995/04/05 21:21:52 randys - * Added a field to the buffer control structure holding the - * scheduling policy chosen for the allocations lock. - * [95/04/05 randys] - * - * Revision 1.1.3.9 1995/03/23 20:35:19 randys - * Added comments indicating duplication of declarations of - * flipc_cb_base & flipc_cb_size in this file and in flipc_usermsg.h - * Modified declaration of flipc_cb_size to be unsigned long. - * [95/03/21 randys] - * - * Revision 1.1.3.8 1995/02/23 21:32:42 randys - * Added space for kernel configuration in communications buffer - * control structure. - * [95/02/22 randys] - * - * Revision 1.1.3.7 1995/02/21 17:22:58 randys - * Re-indented code to four space indentation - * [1995/02/21 16:25:32 randys] - * - * Revision 1.1.3.6 1995/02/13 22:57:29 randys - * Replaced all of NEXT_{ACQUIRE,RELEASE,PROCESS}_PTR macros with a - * single NEXT_BUFFERLIST_PTR macro. - * [95/02/03 randys] - * - * Revision 1.1.3.5 1995/01/26 21:01:44 randys - * Add performance structure into CB. - * [1995/01/24 21:14:31 randys] - * - * Added flag in epgroup structure to note that epgroup - * has a semaphore associated with it. - * [1995/01/19 23:02:13 randys] - * - * Add a space in the comm buffer header for the null_destination - * the ME sets up for the AIL. Get rid of - * FLIPC_ADDRESS_ENDPOINT_PTR (it isn't used) - * [1995/01/19 20:22:30 randys] - * - * Up the comm buffer size to 1 megabyte - * [1995/01/17 22:23:27 randys] - * - * Revision 1.1.3.4 1995/01/12 21:19:01 randys - * Minor commenting changes from dlb - * [1995/01/06 18:18:12 randys] - * - * Revision 1.1.3.3 1994/12/22 16:23:57 randys - * Fixed calculation of number of buffers on an endpoint - * to take size of buffer pointers into account. - * [1994/12/21 16:19:55 randys] - * - * Revision 1.1.3.2 1994/12/20 19:01:56 randys - * Moved definition of flipc_simple_lock to flipc_cb.h - * [1994/12/20 17:34:41 randys] - * - * Added a simple lock in the comm buffer to use for the - * allocations lock, along with directions as to how - * to use it (not like a normal simple lock). - * [1994/12/20 15:27:25 randys] - * - * Added error log into communications buffer control - * structure, and changed FLIPC_ADDRESS_ENDPOINT_PTR to - * correctly compute the endpoint pointer based on the - * new ctl structure layout. - * [1994/12/19 23:47:45 randys] - * - * Added filename in comment at top of each file - * [1994/12/19 20:28:20 randys] - * - * Add version field to epgroup to check races on buffer acquire - * from epgroup. - * [1994/12/19 18:05:04 randys] - * - * Revision 1.1.3.1 1994/12/12 17:46:12 randys - * Putting initial flipc implementation under flipc_shared - * [1994/12/12 16:27:46 randys] - * - * Revision 1.1.1.2 1994/12/11 23:11:18 randys - * Initial flipc code checkin - * - * $EndLog$ - */ - -/* - * mach/flipc_cb.h - * - * This file is intended to be the data structure layout for the flipc - * communcations buffer, both for the KKT implementation and - * for the eventual paragon implementation. This file should include - * all of the information necessary for either humans or machines to - * understand the data structure layout. - * - * The communications buffer is the wired section of memory used for - * communication between the flipc applications interface layer and - * the flipc message engine. No structure in it are visible to the - * user; the applications interface layer mediates all user access to - * the CB. - */ - -#ifndef _MACH_FLIPC_CB_H_ -#define _MACH_FLIPC_CB_H_ - -#include - -/* - * Flipc naming and argument ordering conventions (this applies mainly to - * user-interface.h, but seems inappropriate in a user-visible header file): - * - * All objects prefixed with "flipc"; uppercase for user-visible - * objects, lower case for internal ones. - * - * Types created with typedef will have _t suffixes. - * - * Words will be separated by '_'. - * - * Macro definitions will be all in caps. - * - * Enum members will have their initial letter (after Flipc) capitalized. - * - * - * For user-visible routines: - * - * The first word following the "flipc" will be the flipc object type that - * that routine operates on (specifically "domain", "epgroup", - * "endpoint", or "buffer"). - * - * The object named by the first word of the call will, if an argument - * to the call, be the first argument. - * - * Output variables passed as pointers in the arglist will come last. - */ - -/* - * The kinds of objects that exist in the communications buffer are: - * - * Endpoints -- Used for sending or receiving. - * Buffers -- Composed of a buffer header and buffer data. - * Endpoint groups -- Used for collecting multiple numbers of endpoints - * together for a select like operation. - */ - -/* - * We can't use general pointers inside the communications buffer, - * since the address space on either side of the interface is - * different. The places where we could use pointers are: - * - * *) From endpoint sets to endpoints. - * *) From endpoints to buffers. - * - * The kinds of pointers we could use are: - * *) Byte offset from the beginning of the comm buffer. This - * is simple, but has the disadvantage of allowing the user to - * play games with pointing endpoint buffer pointers into data - * space, & etc. - * *) Rigid arrays of each type of object, with the object - * "pointer" being an index into the array. This avoids the - * above problem, but complicates memory allocation (forces - * allocation to be contiguous, which may force pre-deciding - * how much space each of the above types will take). - * - * Though we appear to be going for the rigid allocation for each type - * of data structure, I'm still going to do the "simple offset" - * solution to maintain maximum flexibility into the future. - * The single exception to this is that FLIPC addresses will be composed of - * node number and endpoint number, where the endpoint number will be - * the index into the endpoint array. - */ - -typedef unsigned long flipc_cb_ptr; -/* Define a null value, which doesn't point anywhere into the CB. */ -#define FLIPC_CBPTR_NULL ((flipc_cb_ptr) -1) - -/* - * Synchronization between message engine and application. - * - * In general, it isn't reasonable to allow locking and unlocking of - * data structures between message engine and communications buffer, - * as this requires the message engine to trust arbitrary user - * threads. The solution is to arrange all data structures so that - * they may be accessed by both parties without locking. The way that - * this is usually done is that specific variables are considered to - * be owned by one of the ME or the AIL, and the other party is - * allowed to read the variable but not to modify it. With this - * arrangement, implementing things like producer/consumer circular - * queues is possible; each agent (ME or AIL) goes around the list - * doing its thing, and avoids passing the pointer showing where the - * other agent is working. - * - * Following the above, we may divide structure members into five - * classes, and define prefixes for these five classes. - * - * Description Prefix - * ------------------------------- - * Private to AIL pail_ - * Private to ME pme_ - * AIL owned, read by ME sail_ - * ME owned, read by AIL sme_ - * Shared in other way shrd_ - * - * Shared variables may change their ownership based on their own - * or someone elses value (these variables may be thought of as - * being handed back and forth between the two entities) or on a - * configuration option of the structure (not handed back and forth, - * but still based on another variables value). - * - * In addition, I am going to put variables that are set at endpoint - * allocation and cleared at deallocation (but read by both sides) in - * a separate class; they are "AIL owned, read by ME" but are - * effectively constant over the synchronization protocols we care - * about. - * - * Constant after allocation const_ - * - * Note that this ignores memory consistency issues (when the two - * agents are actually on two separate processors). These issues need - * to be explored in more detail; for now suffice it to say that the - * above methods work given a sequentially consistent memory model or - * a processor consistent memory model. - * - * Also note that an optimizing compiler may reorder our memory - * accesses, playing merry hell with the inter-node synchronization - * protocols (the compiler doesn't know about the other node, after - * all). To avoid this, all structure members used for - * synchronization will be marked volatile; this will force the - * compiler to keep the order and number of accesses intact. This - * will also force the compiler *not* to optimize way accesses to - * these variables, so it is wise to explicitly load the variable into - * a temporary once if you need to do multiple computations with it, - * and store it back afterwards when you are done. - */ - -/* - * Memory allocation: - * - * For maximum simplicity in the first implementation, we need to know - * at comm buffer allocation time how many endpoints, endpoint_sets, - * and buffers we will want total, until the end of time. This - * masively simplifies memory allocation; there will be a single array - * of each type of data and the communication buffer will be taken up - * by the concatenation of these arrays (with some fiddling to make - * sure that no data crosses a page boundary). - * - * For each data type there will be a free list to which pieces of - * data will be added to or removed from as needed. Each data type - * will have a pointer in it to allow it to be linked onto the free - * list. - */ - -/* - * Multiple thread access to data structures: - * - * There are several points in the communications buffer (notably - * endpoint accesses) when multiple application threads will be - * attempting operations on data structures at the same time. To - * multiplex these operations, we need a per-data structure lock. - * Lock attributes: - * *) This lock will not be kernel based, as such a lock would be - * too heavyweight to use for arbitrary sending and receiving - * operations). - * *) Because it is not kernel based, it may not be used to - * multiplex accesses from threads at different kernel - * priority levels. Deadlock would result if a low-priority - * thread gained the lock and then was prempted by a - * high-priority thread that wanted to acquire it. - * *) Architecture-dependent interfaces need to be designed to - * atomically lock and unlock this data structure. - * - * These are "simple locks" and are defined in flipc_dep.h. - */ - -/* - * Lock type. This placement (in flipc_cb.h) is a little bit of a - * hack, as it really should be defined with the machine dependent lock - * macros. But then the machine independent lock macros have problems - * because they have to include it both before and after the prototypes. - * So rather than split the machine dependent stuff into multiple - * files, I'll define it here and hope that this definition works for - * whatever architectures we're on. - */ -typedef unsigned long flipc_simple_lock; - -/* - * Ownership of data structures. - * - * Please note that this is a can of worms, and that I (Randys) - * consider this (and it's interactions with endpoint group membership) - * the likeliest place for design bugs in FLIPC. Any and all should - * take this as an open invitation and challenge to find bugs in what - * follows. - * - * Rules: - * - * *) If you've disabled a structure and synched with the - * appropriate side of the ME, the ME won't touch it. - * - * *) If you've taken a send endpoint off of the send endpoint - * list and sync'd with the ME, the ME won't touch it. - * - *[The rest of this applies to the AIL only; the above rules are the - * only ones the ME respects. ] - * - * *) Within the AIL, a disabled structure is owned by: - * *) The routine that disabled it, before it is put on - * the free list. - * *) The routine that dequeued it from the free list, - * before it is enabled. - * Taking of the simple lock is not required for ownership in - * these cases. Taking of the simple lock is not required for - * the act of *enabling* the structure (you have ownership and - * are giving it away), however it is required for the act of - * disabling the structure (since it is the only valid way to - * take ownership of an enabled structure, and you can't - * modify the enabled bit without having ownership). - * - * *) The simple lock in a structure always needs to be valid, as - * simple locks may be taken while the structure is in any - * state. Simiarly, the enabled bit must always be valid, - * both because it's what the ME checks, and because it may be - * checked by the AIL while the structure is free. - * - * *) Holding the simple lock on an enabled structure imparts - * ownership of that structure. You are allowed to take the - * simple lock of a disabled structure, but ownership is not - * gained by doing so. - * - * *) You are allowed to read the enabled/disabled bit without - * owning the structure (if the structure is disabled, there - * may be no way to gain the ownership). - * - * *) Owning a structure allows you to do what you want with it, - * except: - * *) As mentioned above, the simple lock and - * enabled/disabled bit must always be valid. - * *) The ownership of the endpoint group related members - * of an endpoint structure is special; see below. - * *) The allocations lock must be held to manipulate the - * next send endpoint field of any endpoint. - * - * *) If an endpoint is on an endpoint group, the ownership of - * the the endpoint group related members of the structure - * (sail_endpoint_group and pail_next_eg_endpoint) go with the - * owndership of the endpoint group, not the endpoint. For - * this purpose only, membership is defined atomically as the - * sail_endpoint_group pointer being set to an endpoint group. - * Thus one may remove an endpoint from an endpoint group - * without owning the endpoint (change the sail_endpoint_group - * pointer last). One requires both locks to add an endpoint - * to an endpoint group, however. - * - * (Part of the motivation for this is that removal and - * addition of endpoints to endpoint groups requires - * modifications of pointers in other endpoint structures). - * - * *) No structure may be put on the free list if marked with any - * association to any other structure. Specifically, endpoint - * groups may have no endpoints belonging to them, and - * endpoints may not belong to an endpoint group or have - * buffers belonging to them. - * - * *) One consequence of the above is that endpoint groups may - * not be marked as disabled while they have any endpoints on - * them, as freeing an endpoint requires it to be removed from - * its endpoint group, and if ownership of the endpoint group - * cannot be gained, that is impossible. - * - * *) In theory, endpoints *may* be marked disabled while they - * are still on endpoint groups. In practice, they are not. - * This is relied on by the code which frees endpoint groups, - * in a non-obvious way. Specifically, that code assumes that - * there is no way that a call to free endpoint will return - * with the endpoint still on the endpoint group. Since the - * only way for free endpoint to fail is if the endpoint is - * inactive, and since the endpoint is set inactive only after - * free endpoint (presumably a different one) confirms that it - * isn't on any endpoint group, this assumption is true. - * - * Got that? Take home lesson: don't allow endpoints to be - * marked disabled while still on endpoint groups until you - * *do* get that, and are willing to take the responsibility - * of changing it so that it works under your new scheme. - * - * *) Ownership of the freelist(s) are gained by holding the - * allocations lock for the buffer, and *only* in that way. - * No modification of freelist, send endpoint list, or send - * side ME sync bits is valid without holding the allocations - * lock. In other words, while you can read things in the - * main communications buffer control structure at will, you - * may not change them without owning the allocations lock. - * - * *) The state where a structure is disabled but off of the - * freelist may be valid as an intermediate (while an AIL - * routine is orchestrating a transition) but is not a valid - * static state. This state must not survive the return to - * application code of the thread that disabled the structure. - */ - -/* - * Flipc data buffer management. - * - * A buffer (whether being used for sending or receiving) may be in - * one of three states: - * - * READY -- Buffer held by application. - * PROCESSING -- Buffer held by endpoint, unprocessed. For receive endpoints, - * this means that the buffer is empty, waiting to be filled by - * an incoming message. For send endpoints, this means tht the - * buffer is full, waiting to be sent out. - * COMPLETED -- Buffer held by the endpoint, processed. For receive - * endpoints, this means that the buffer is full, with newly - * received data in it. For send endpoints, this means that the - * buffer is empty (*), with it's data having been sent out. - * - * (*) In point of fact the data hasn't been touched, though bits - * may have been fiddled with in the header data structure. But - * it's been sent. - * FREE -- The buffer is in the pool of free buffers, and may be - * allocated to any newly created endpoint. - * - * The transition diagram between these states is relatively simple: - * - * - * release - * /-----------------\| - * +----------+ -+----------+ - * | READY | |PROCESSING|<- - - - - - - * +----------+_ +----------+ \ - * ^ |\ - - - - - - - - / | | \endpoint allocate - * | (processed) \endpoint \ - * | | \ free | - * | acquire / ------\ - * | \ | - * | / (processed) >+----------+ - * +----------+ | FREE | - * |COMPLETED |< - - - - - - - - - - +----------+ - * +----------+ endpoint allocate / ^ - * | ^- - - - - - - - - - - - - - - - - - - - - - - | - * | / - * \ endpoint free / - * ------------------------------------------------------/ - * - * (If it doesn't look simple, imagine it without the FREE state; that - * state doesn't enter into almost any buffer manipulations) - * - * For send buffers, release==send, acquire==allocate, and - * processed==the sending done by the message engine. For receive buffers, - * release==release, acquire==receive, and process==the actual - * arrival of the message handled by the messaging engine. - * - * The choice of path from the PROCESSING state is an endpoint - * specific configuration option; a particular endpoint may leave a - * processed buffer on the endpoint, or it may release it back to the - * application by dropping it from the endpoint. - * - * Buffers are assigned the PROCESSING state on a newly allocated - * receive endpoint (to be ready to receive messages) and the - * COMPLETED state on a newly allocated send endpoint. - * - * The state (other than FREE) that a particular buffer is in is - * determined by its place on a circular queue of buffer pointers that - * is part of the endpoint structure. Buffers owned by the - * application (READY) are not pointed to by pointers on this queue. - * The buffer is released to the message engine by placement of a - * pointer to it on this queue. When the message engine is done - * processing the buffer, it sets a flag in the buffer header. If the - * endpoint is so configured, it then removes the buffer pointer from - * the queue; otherwise the AIL acquires the buffer (and removes the - * pointer from the queue) when it chooses. - * - * . . . . . . - * . . - * . . - * . . AIL releasing - * . . ^ - * . +-------+--/ - * . | | - * . |Buffers| - * . | to be | - * . |Sent or| - * . |Receivd| - * . | Into | ^ ME processing - * . +-------+ --/ - * . | | - * . AIL | Sent | (These buffers have a flag set to indicate - * .Acquiring| or | that they have been processed. This - * . |Filled | section is optional; the endpoint may be - * . |buffers| configured to drop buffers after processing) - * . ^ | | - * . \--+-------+ - * . . - * . . - * . . . . . . - * - * - * The AIL will refuse to acquire a buffer that has not yet been - * processed by the ME. Acquire will not work at all on endpoints - * that have been configured to drop buffers on completion. - * - * The buffer_available primitive is coded to avoid doing a - * (potentially costly) acquiring of the endpoint flipc lock. Since - * telling where there is a buffer available requires two operations - * (comparison of the acquire and release pointers to see if there are - * any buffers on the endpoint, and then indirection of the acquire - * pointer to see if that buffer has bee processed yet), there is a - * potential race that will admit the possibility of indirecting - * through an invalid pointer. For this reason, for the life of an - * endpoint, it is a requirement that all buffer pointers on the - * bufferlist point *somewhere* (ie. to some existing buffer), so that - * this indirection will not cause an access error. The - * buffer_available primitive may return the wrong result, but (as - * long as the incorrectness is transitory), this is acceptable. - */ - -/* Set up the states so that FLIPC_buffer_processed can just do an - & and a test. */ -typedef enum { - flipc_Free = 0x0, flipc_Processing = 0x1, - flipc_Completed = 0x2, flipc_Ready = 0x3 -} flipc_buffer_state_t; -#define FLIPC_BUFFER_PROCESSED_P(state) ((state) & 0x2) - -/* - * Data header/buffer layout. - * - * For this implementation, and probably for all time, the header - * immediately precedes the data in memory, and the mesaging engine - * will send both header and data. Our priority is message dispatch - * speed rather than raw bandwidth (this is the small message side of - * a transfer mechanism), so we don't mind that we are throwing away - * some bandwidth by taking up transferred space with header data. - * - * The data size will be the maximum size allowed by the underlying - * transport, minus the header size (available at run time). The user - * will be given a pointer to the data buffer, and will use this both - * for copying data in and out, and as an argument to the underlying - * flipc routines. The flipc routines will access appropriately. - * - * The header structure follows; the user data type will be offset and - * cast appropriately to access this. - */ - -typedef struct flipc_data_buffer { - union { - FLIPC_address_t destination; /* For sending. */ - flipc_cb_ptr free; /* Link for header free list. */ - } u; - - /* ME owned if flipc_Processing, AIL owned otherwise. May not ever - assume the state flipc_Ready in an optimized implementation. */ - volatile flipc_buffer_state_t shrd_state; -} *flipc_data_buffer_t; - -/* - * Endpoint structure. - * - * An endpoint is the data structure used for communicating buffers, - * either send or receive. Note that all actual circular lists of - * buffer pointers on the endpoints are in their own array that gets - * partitioned out to the various endpoints. This is because we want - * the endpoint structures themselves to be fixed size for easy - * indexing upon receit of a message. This large scale array will be - * of size (max_buffers_per_endpoint) * (number_of_endpoints). Both - * of these values are set during the domain initialization call. - * - * Note that the pointers contained in the buffer lists are pointers to - * buffer *headers*, not to the data. - */ - -/* - * This structure is divided into four cache lines, separated by their - * usage type: - * - * *) Private data that the AIL scribbles on. - * *) Data the AIL writes (regularly) that the ME reads - * (occaisionally). The canonical example is the release pointer. - * *) Private data that the ME scribbles on. - * *) Data the ME writes (regularly) that the AIL reads (occaisionally). - * The canonical example is the process pointer. - * - * There are a couple of other categories of stuff, that can be shoehorned - * into the above: - * *) Constant data that both sides read regularly. This can be - * duplicated in the two private areas (actually, it can be - * duplicated in any two areas that stay in the cache of the - * respective processors). - * *) Stuff that is not accessed on the critical path; it can go - * almost anywhere (probably in one of the two ping-ponging - * cache lines). - * *) Stuff that is read-only for a single processor goes in that - * processors private data section. - * - * Duplicate entries have a "p" or a "a" suffixed to the name to - * indicate that fact. Note that these will usually, but not always, - * be "const" variables--they may be "const" variables only from the - * critical path viewpoint. - * - * We take cache line length as being 8 * sizeof(int). - */ - -typedef struct flipc_endpoint { - - /* ===Private AIL data=== */ - /* Type of endpoint (send, recv, etc). Duplicated in private - ME section. */ - FLIPC_endpoint_type_t constda_type; - - /* This next value is two variables squeezed into a single word to - * save on memory accesses (since they are almost always read at - * the same time. The two variables are: - * - * const_drop_processed_buffers -- Should the message engine drop - * buffers after processing them (as opposed to leaving them on - * the endpoint)? - * - * sail_enabled (volatile) -- Is the endpoint enabled? This isn't - * marked constant because it is used for synchronization on - * endpoint deallocation. - * - * Note that to reduce test and branches, we these two variables - * are represented by two bits in the word (bit 0 and bit 16). It - * is illegal to have bits other than 0 and 16 set in this word. - * This assumption is used in ENABLED_AND_NOT_DPB_P, and is enforced - * in DOE_CONSTRUCT (assumed to not be performance critical) below. - * - * Duplicated in private ME section. - */ - - volatile unsigned long sailda_dpb_or_enabled; - -#define EXTRACT_DPB(dpb_or_enabled) ((dpb_or_enabled) >> 16) -#define EXTRACT_ENABLED(dpb_or_enabled) ((dpb_or_enabled) & 0xffff) -#define DISABLED_OR_DPB_P(dpb_or_enabled) ((dpb_or_enabled) ^ 0x1) -#define DOE_CONSTRUCT(dpb, enabled) \ - (((dpb) ? 0x10000 : 0) | ((enabled) ? 0x1 : 0)) - - flipc_simple_lock pail_lock; /* Simple lock for serializing - multiple thread access to - structure. AIL owned. */ - /* First element in buffer list array that is ours. Constant - from communications buffer initialization. */ - flipc_cb_ptr constda_my_buffer_list; - /* First element after my_buffer_list that is *not* in my buffer - list. Constant from communications buffer initialization. */ - flipc_cb_ptr constda_next_buffer_list; - - /* First location that has a valid buffer pointer in it. This may - contain a pointer to a buffer available for acquisition, or it - may contain a pointer to a buffer that is still being - processed; the buffer header or process_ptr needs to be checked - to be sure. This location is AIL owned. It is ignored by all - (including the ME and initialization code) if - drop_processed_buffers, above, is set. */ - volatile flipc_cb_ptr shrd_acquire_ptr; - - /* AIL private copy of process pointer. This hopefully means that - the AIL won't need to read the real process pointer (and fault - in a cache line) very often. */ - flipc_cb_ptr pail_process_ptr; - - unsigned int pad_pail_7; - - /* ===End of cache line===*/ - /* ===AIL writes, ME occaisionally reads=== */ - - /* Next location at which the AIL may insert a buffer pointer. */ - volatile flipc_cb_ptr sail_release_ptr; - unsigned int pad_sail_1; - unsigned int pad_sail_2; - unsigned int pad_sail_3; - unsigned int pad_sail_4; - unsigned int pad_sail_5; - unsigned int pad_sail_6; - unsigned int pad_sail_7; - - /* ===End of cache line===*/ - /* ===Private ME data=== */ - /* See above comments (in private ail section). */ - - FLIPC_endpoint_type_t constdm_type; - volatile unsigned long saildm_dpb_or_enabled; - - volatile unsigned long sme_overruns; /* For a receive endpoint, counter for - the number of messages that have - arrived when there hasn't been - space. ME owned. */ - unsigned long pail_overruns_seen; /* A count of the number of overruns - that the AIL has noted and doesn't - want to be bothered with again. - The user only sees the difference - between the previous count and this. */ - - /* - * For send endpoints; linked into a list that is used by the ME - * to find stuff to do. Also used for endpoint free list. - * Null if at end of list. Not "const" because it's used as a - * synchronization variable during setup and teardown - * of send endpoints. - */ - volatile flipc_cb_ptr sail_next_send_endpoint; - - /* Constant buffer lsit pointers for ME. See private ail comments. */ - flipc_cb_ptr constdm_my_buffer_list; - flipc_cb_ptr constdm_next_buffer_list; - - /* Private ME copy of release pointer. This hopefully means that - the ME won't have to read (and fault in a cache line) the - release pointer very often. */ - - flipc_cb_ptr pme_release_ptr; - /* ===End of cache line===*/ - - /* ===ME writes, AIL occaisionally reads=== */ - /* - * For endpoint group membership. - */ - flipc_cb_ptr pail_next_eg_endpoint; /* Next endpoint in endpoint group. - AIL owned. */ - flipc_cb_ptr sail_epgroup; /* Direct pointer to endpoint group that - we are part of. FLIPC_CBPTR_NULL - if none. AIL owned. */ - - /* First location that has a buffer pointer available for - processing. If this value is equal to the release_ptr there are no - buffers available for processing. */ - volatile flipc_cb_ptr sme_process_ptr; - unsigned int pad_sme_3; - unsigned int pad_sme_4; - unsigned int pad_sme_5; - unsigned int pad_sme_6; - unsigned int pad_sme_7; - - /* ===End of cache line===*/ - /* ===END=== */ - - /* The following macros may have possible performance loss in - multiple accesses (or indirection, but a good compiler will get - around that). We need to have versions for each processor so - that the constant reads are done from the right copy. */ - - /* General bufferlist pointer increment macro, with versions - for ME and AIL. */ - -#define NEXT_BUFFERLIST_PTR(bufferlist_ptr, endpoint, suf) \ - (((bufferlist_ptr) + sizeof(flipc_data_buffer_t) \ - == ((endpoint)->const ## suf ## _next_buffer_list)) ? \ - ((endpoint)->const ## suf ## _my_buffer_list) : \ - (bufferlist_ptr) + sizeof(flipc_data_buffer_t)) -#define NEXT_BUFFERLIST_PTR_ME(bufferlist_ptr, endpoint) \ - NEXT_BUFFERLIST_PTR(bufferlist_ptr, endpoint, dm) -#define NEXT_BUFFERLIST_PTR_AIL(bufferlist_ptr, endpoint) \ - NEXT_BUFFERLIST_PTR(bufferlist_ptr, endpoint, da) - - /* Macros for each of "can I release onto this buffer?" "Can I - acquire from this buffer?" and "Can I process an element on - this buffer?" The first two presume they are being executed on - the main procesor, the third on the co-processor. - All have three arguments: - *) A variable which will be set to the release, acquire, or - process pointer after the macro *if* the operation is ok. - *) A temporary variable used inside the function. - *) The endpoint. - - We presume the acquire macro won't be called if drop processed - buffers is enabled; the process and release macros deal - appropriately with that issue. */ - - /* In general these macros will: - *) Not read a volatile structure member more than once. - *) If a variables owner is the other processor, these macros - will check a local copy of the variable first before checking - the other processors. - *) Will only update the local copy if the remote copy really is - different from the local one. - */ - -/* This macro implements the synchronization check; local cbptr is - the pointer owned by the local processor which we want to compare - with a pointer on the remote processor which we have a copy - of locally. Reads the remote pointer zero or one times; other - reads are as necessary. - - The algorithm is: - *) If the local copy says our pointer and the remote value aren't equal, - we're done. - *) Otherwise, check the remote copy. If it says the values aren't - equal, update the local copy. */ - -#define ENDPOINT_SYNCNE_CHECK(local_cbptr, copy_rmt_cbptr, \ - rmt_cbptr, tmp_cbptr) \ - ((local_cbptr) != (copy_rmt_cbptr) \ - || ((((tmp_cbptr) = (rmt_cbptr)) != (local_cbptr)) \ - && (((copy_rmt_cbptr) = (tmp_cbptr)), 1))) - -#define ENDPOINT_ACQUIRE_OK(acquire_cbptr, tmp_cbptr, endpoint) \ - ((acquire_cbptr) = (endpoint)->shrd_acquire_ptr, \ - ENDPOINT_SYNCNE_CHECK(acquire_cbptr, (endpoint)->pail_process_ptr, \ - (endpoint)->sme_process_ptr, tmp_cbptr)) - -#define ENDPOINT_PROCESS_OK(process_cbptr, tmp_cbptr, endpoint) \ - ((process_cbptr) = (endpoint)->sme_process_ptr, \ - ENDPOINT_SYNCNE_CHECK(process_cbptr, (endpoint)->pme_release_ptr, \ - (endpoint)->sail_release_ptr, tmp_cbptr)) - -#define NODPB_ENDPOINT_RELEASE_OK(release_cbptr, tmp_cbptr, endpoint) \ - ((release_cbptr) = (endpoint)->sail_release_ptr, \ - (tmp_cbptr) = (endpoint)->shrd_acquire_ptr, \ - (NEXT_BUFFERLIST_PTR_AIL(release_cbptr, endpoint) \ - != (tmp_cbptr))) - -/* Don't use NEXT_BUFFERLIST_PTR here to save a temporary variable. */ -#define DPB_ENDPOINT_RELEASE_OK(release_cbptr, tmp_cbptr, endpoint) \ - (release_cbptr = (endpoint)->sail_release_ptr, \ - ((release_cbptr + sizeof(flipc_data_buffer_t) == \ - (endpoint)->constda_next_buffer_list) \ - ? ENDPOINT_SYNCNE_CHECK((endpoint)->constda_my_buffer_list, \ - (endpoint)->pail_process_ptr, \ - (endpoint)->sme_process_ptr, \ - tmp_cbptr) \ - : ENDPOINT_SYNCNE_CHECK(release_cbptr + sizeof(flipc_data_buffer_t), \ - (endpoint)->pail_process_ptr, \ - (endpoint)->sme_process_ptr, \ - tmp_cbptr))) - - /* This next is tricky; remember that acquire_ptr points - to an actual bufferptr on the list, whereas release_ptr does - not. This macro is only used in FLIPC_endpoint_query, and so - doesn't need to have an ME version. */ - -#define BUFFERS_ON_ENDPOINT_AIL(acquire_ptr, release_ptr, endpoint) \ - ((release_ptr) > (acquire_ptr) \ - ? ((release_ptr) - (acquire_ptr)) / sizeof(flipc_cb_ptr) \ - : ((((release_ptr) - (endpoint)->constda_my_buffer_list) \ - + ((endpoint)->constda_next_buffer_list - acquire_ptr)) \ - / sizeof(flipc_cb_ptr))) -} *flipc_endpoint_t; - - -/* - * Endpoint groups. - * - * Used to represent a group of endpoints, for linking sending/receiving - * with semaphores & etc. Note that there needs to be a private data - * structure kept by the kernel that associates with each epgroup - * a semaphore to be used for wakeups on that endpoint set. - */ - -typedef struct flipc_epgroup { - flipc_simple_lock pail_lock; /* Lock to synchronize threads (at the - same priority level) accessing this - structure. */ - volatile unsigned long sail_enabled; /* Set if structure is active. */ - unsigned long const_semaphore_associated; /* Flag to indicate whether or not - there is a semaphore associated - with this endpoint group in the - kernel flipc routines. */ - volatile unsigned long sail_wakeup_req; /* Incremented when a thread wants to - be woken. */ - volatile unsigned long pme_wakeup_del; /* Incremented when the ME delivers a - wakeup. */ - unsigned long pail_version; /* Incremented when epgroup membership - is changed; checked when retrieving - a buffer from an epgroup. */ - unsigned long sail_msgs_per_wakeup; /* How many messages need to arrive - before the ME delivers a wakeup. */ - unsigned long pme_msgs_since_wakeup; /* How many messages have arrived - since the last wakeup. ME - owned. */ - - flipc_cb_ptr pail_first_endpoint; /* First endpoint in the group. The - other endpoints are linked along - behind him. AIL owned. */ - flipc_cb_ptr pail_free; /* Used to link this endpoint onto - the freelist. */ -} *flipc_epgroup_t; - -/* - * Communication buffer control structure. - * - * This is in the communications buffer itself. Note that any changes - * in this structure require it to be locked with the allocation lock, - * as access to this structure is shared by all threads using the CB. - */ - -/* - * Individual data type layout. - * - * All we need here is a pointer to the start of each type of data - * struct, the number of those data structures in the communications - * buffer, and a pointer to the beginning of the freelist for that data - * structure. - * - * Note that the composite buffer list doesn't have a freelist associated - * with it, since each section of the buffer list is tightly bound to an - * endpoint, and is allocated and freed with that endpoint. We still - * need the start and number information, though. - */ -struct flipc_cb_type_ctl { - flipc_cb_ptr start; /* Where there array of this type of - data structure starts. */ - unsigned long number; /* How many of them we've got. */ - flipc_cb_ptr free; /* Where the beginning of the freelist - is. */ -}; - -/* - * Synchronization with message engine. - * - * At certain times (specifically during structure allocation/free or - * additions to the send list) you want to know that the messaging - * engine has picked up your changes. However, the message engine has - * (effectively) two threads, one for each of the send and receive - * sides. The mechanisms used for synchronizations with the two sides - * differ. In an eventual co-processor implementation (with a single - * thread), only the send side mechanism will be used. - * - * To request a cached state flush by the send side of the mesasging - * engine, you flip the request_sync bit and it responds by flipping - * the response_sync bit. The send ME checks this bit once every trip - * through the send endpoints. - * - * On the receive side, since receives take very little time and do - * not block (unlike sends) when we want to make sure the ME is - * holding no cached receive side state, we simply spin until we see - * that the ME receive side is no longer operating. It sets a - * variable whenever it is in the process of receiving a message. - */ - -/* - * Proper manipulation of the send endpoint list. - * - * Note that synchronizing with the message engine over access to the - * send endpoint list is especially tricky. There is no problem with - * writing new values in all of the locations required to take a send - * endpoint off of the list. However, we must be very sure before - * modifying the pointer *in* the send endpoint that the ME isn't - * currently working in that send endpoint (else it could be sent off - * into the void). Two options here: - * - * *) Synchronize (using the below variables) for each send - * endpoint removed, after the removal but before the - * modification of the data in the internal structure. - * *) If we can always be sure that the send endpoint link in the - * endpoint structure has a valid value, we can simply let the - * chips fall where they may. It will be null while free, and - * have a value that points back into the send buffer list - * when reallocated. I'm not going to do this; it's sleezy - * and will partially mess up fairness based on ME send - * endpoint round-robinning. - */ - -/* - * This entire structure is protected by an kernel level lock so there - * is no conflict between threads accessing it. See flipc_kfr.c for - * details on this lock; how it is implemented and used depends on what - * kernel base we are on. - */ - -/* - * Note that the last element of this structure is variable sized, so this - * structure itself is also variable sized. - */ -typedef struct flipc_comm_buffer_ctl { - /* Kernel flipc configuration that the user must match in order to - work with this kernel. Checked as soon as the comm buffer is - mapped. */ - struct { - unsigned int real_time_primitives:1; - unsigned int message_engine_in_kernel:1; - unsigned int no_bus_locking:1; /* One way check -- if the kernel doesn't - have this and the user does, that's - an error. */ - } kernel_configuration; - volatile unsigned long send_ready; /* A send(s) is ready to go */ - - /* These first three structures are constant after communications buffer - initialization. */ - unsigned long data_buffer_size; /* Size of the data buffers. */ - unsigned long local_node_address; /* Local node number. */ - FLIPC_address_t null_destination; /* Local null destination value. */ - -#if REAL_TIME_PRIMITIVES - /* The scheduling policy used by the task initializing flipc for - the allocations lock. */ - int allocations_lock_policy; -#else - /* A poor substitute for a kernel level allocations lock. - Note that this *cannot* be used as a regular simple lock; - instead, try to acquire it, call sleep(1), try again, etc. - Spinning on this lock will probably waste lots of cycles. */ - flipc_simple_lock pail_alloc_lock; -#endif - - /* All of the members of these structures except for the free pointer - are constant after initialization. The free pointer is ail owned - and private. */ - struct flipc_cb_type_ctl endpoint; - struct flipc_cb_type_ctl epgroup; - struct flipc_cb_type_ctl bufferlist; - struct flipc_cb_type_ctl data_buffer; - - /* Global synchronization with the message engine. On the KKT - implementation we need one synchronizer for each thread. */ - - /* Send side: */ - volatile unsigned long sail_request_sync; /* request_sync = !request_sync when the - AIL wants to synchronize with the - CB. */ - volatile unsigned long sme_respond_sync; /* respond_sync = !respond_sync when - the ME has noticed the sync - request. By responding to the - sync, the ME is stating that it has - no communications buffer state that - was cached previous to it noticing - the sync. */ - - /* Receive side. */ - volatile unsigned long sme_receive_in_progress; /* Set by the ME before it looks at - any data structures; cleared - afterwards. A simple spin in - the user space on this - variable will suffice, as the - time that the message - engine could be receiving - is low. */ - - /* Send endpoint list starts here. */ - volatile flipc_cb_ptr sail_send_endpoint_list; /* Null if no send endpoints. - */ - - /* Keep track of whatever performance information we choose. */ - struct FLIPC_domain_performance_info performance; - - /* Keep track of various kinds of error information here. */ - struct FLIPC_domain_errors sme_error_log; - -} *flipc_comm_buffer_ctl_t; - - -/* - * The communications buffer. - * - * The only restriction on the layout of the communications buffer is - * that the buffers themselves may not cross page boundaries. So we - * will place the data buffers at the end of the communications - * buffer, and the other objects at the beginning, and there may be a - * little bit of extra space in the middle. - * - * Note that this layout may change in future versions of FLIPC. - * - * +---------------------------+ - * | flipc_comm_buffer_ctl | - * +---------------------------+ - * | | - * | Endpoints | - * | | - * +---------------------------+ - * | | - * | Endpoint Groups | - * | | - * +---------------------------+ - * | | - * | Combined Buffer Lists | - * | | - * +---------------------------+ - * | | - * | (Possible empty space) | - * | | - * +---------------------------+ - * | | - * | Data Buffers | - * | | - * +---------------------------+ - */ - -/* The number of pages that the kernel will reserve for the comm - buffer. The AIL needs to know this to know how much to map. */ -#define COMM_BUFFER_SIZE 0x100000 - -/* - * These variables are set, in a per-address space context, to the base - * and length of the communications buffer. The ME needs to do bounds - * checking to make sure it isn't overrunning anything. Note that the - * existence of these variables implies that an application will only - * open a single domain. - * - * These declarations are duplicated in flipc/flipc_usermsg.h, and - * should be kept in sync with that file. - */ -unsigned char *flipc_cb_base; -unsigned long flipc_cb_length; /* In bytes. */ - -/* - * Following is a set of macros to convert back and forth between - * real address pointers and flipc_cb_ptr's for each data type. They - * rely on the flipc_cb_base being set correctly. - * - * A possible future improvement might be to have bounds checking occur - * inside these macros, but I'm not sure what I'd do if it failed. - */ - -/* Easy going one way. */ -#define FLIPC_CBPTR(ptr) \ -(((unsigned char *) (ptr)) - flipc_cb_base) - -/* Need to get the right types going the other way. */ -#define FLIPC_ENDPOINT_PTR(cb_ptr) \ -((flipc_endpoint_t) ((cb_ptr) + flipc_cb_base)) -#define FLIPC_EPGROUP_PTR(cb_ptr) \ -((flipc_epgroup_t) ((cb_ptr) + flipc_cb_base)) -#define FLIPC_DATA_BUFFER_PTR(cb_ptr) \ -((flipc_data_buffer_t) ((cb_ptr) + flipc_cb_base)) -#define FLIPC_BUFFERLIST_PTR(cb_ptr) \ -((flipc_cb_ptr *) ((cb_ptr) + flipc_cb_base)) - - -/* - * Flipc addresses. - * - * The addresses used by flipc for communication are defined in the - * user visible header file as unsigned longs. These macros pull that - * information apart for use of the FLIPC internal routines. - * - * I assume in the following that endpoints immediately follow the - * comm buffer control structure, because that makes indexing into - * them much easier. - */ - -#define FLIPC_CREATE_ADDRESS(node, endpoint_idx) \ -((node << 16) | (endpoint_idx)) -#define FLIPC_ADDRESS_NODE(addr) (((unsigned long) (addr)) >> 16) -#define FLIPC_ADDRESS_ENDPOINT(addr) (((unsigned long) (addr)) & 0xffff) - -#endif /* _MACH_FLIPC_CB_H_ */ diff --git a/include/xnu/mach/flipc_debug.h b/include/xnu/mach/flipc_debug.h deleted file mode 100644 index 969deda3a..000000000 --- a/include/xnu/mach/flipc_debug.h +++ /dev/null @@ -1,248 +0,0 @@ -/* - * 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@ - */ -/* - * @OSF_COPYRIGHT@ - * - */ - -/* - * Really a C file, but I'd like to have this code available in both - * the kernel and the application, so I'll put it in a .h file. This - * file needs to be included only once in the AIL or ME, into a .c file - * where it will be compiled. - */ - -/* - * Since these are debug functions, it doesn't matter which processor macro - * version I use; I don't mind spoiling cache while I'm debugging. - */ - -#include -/* - * Print (using printf) all buffers in the communications buffer that - * are not on any endpoint or on the buffer freelist. Only active - * endpoints are checked. - * - * Note that no locking is done; this function implicitly assumes the - * communications buffer is in a quiescent state. It is expected that - * this function will normally be called from a debugger. - * - * As long as it is at it, this function prints buffers that are - * doubly owned (valid pointers to them from two places). - */ - -/* - * Given that these functions will normally be called from the debugger, - * there isn't any need to globally visible prototypes for them. To - * eliminate compilation warnings, we include prototypes for the functions - * here in the file. - */ -static void flipcdbg_update_bufferset_bitvec(flipc_comm_buffer_ctl_t, - flipc_data_buffer_t); -void flipcdbg_print_unowned_buffers(void); -void flipcdbg_buffer_find_refs(flipc_cb_ptr buffer_cbptr); - -#ifdef __GNUC__ -__inline__ -#endif -static void -flipcdbg_update_bufferset_bitvec(flipc_comm_buffer_ctl_t cb_ctl, - flipc_data_buffer_t buffer) -{ - unsigned char *buffer_base = flipc_cb_base + cb_ctl->data_buffer.start; - int bitpos = ((((unsigned char *) buffer) - buffer_base) - / cb_ctl->data_buffer_size); - int element = bitpos / (sizeof(unsigned long) * 8); - int subbitpos = bitpos - element * sizeof(unsigned long) * 8; - - /* Is that position set already? */ - if (flipc_debug_buffer_bitvec[element] & (1 << subbitpos)) - printf("Buffer 0x%x (idx: %d, cbptr: 0x%x) is multiply referenced.\n", - buffer, bitpos, FLIPC_CBPTR(buffer)); - - /* Set it. */ - flipc_debug_buffer_bitvec[element] |= (1 << subbitpos); -} - -void -flipcdbg_print_unowned_buffers(void) -{ - flipc_comm_buffer_ctl_t cb_ctl = - (flipc_comm_buffer_ctl_t) flipc_cb_base; - int i; - unsigned long bitvec_length = ((cb_ctl->data_buffer.number + sizeof(unsigned long) * 8) - / (sizeof(unsigned int) * 8)); - flipc_data_buffer_t current_buffer; - flipc_endpoint_t current_endpoint; - flipc_cb_ptr current_cbptr; - int header_printed = 0; - - /* Clean out the bitvec. */ - for (i = 0; i < bitvec_length; i++) - flipc_debug_buffer_bitvec[i] = 0; - - /* Go through the freelist, setting bits for each buffer. */ - for (current_cbptr = cb_ctl->data_buffer.free; - current_cbptr != FLIPC_CBPTR_NULL; - current_cbptr = current_buffer->u.free) { - int bitpos; - int element, subbitpos; - - current_buffer = FLIPC_DATA_BUFFER_PTR(current_cbptr); - flipcdbg_update_bufferset_bitvec(cb_ctl, current_buffer); - } - - /* Go through all the endpoints, again setting bits for each buffer. */ - for (current_endpoint = FLIPC_ENDPOINT_PTR(cb_ctl->endpoint.start); - (current_endpoint - < (FLIPC_ENDPOINT_PTR(cb_ctl->endpoint.start) - + cb_ctl->endpoint.number)); - current_endpoint++) { - if (EXTRACT_ENABLED(current_endpoint->saildm_dpb_or_enabled)) { - flipc_cb_ptr current_ptr = - (EXTRACT_DPB(current_endpoint->saildm_dpb_or_enabled) - ? current_endpoint->sme_process_ptr - : current_endpoint->shrd_acquire_ptr); - flipc_cb_ptr limit_ptr = current_endpoint->sail_release_ptr; - - while (current_ptr != limit_ptr) { - flipc_cb_ptr current_buffer_cbptr = - *FLIPC_BUFFERLIST_PTR(current_ptr); - flipc_data_buffer_t current_buffer = - FLIPC_DATA_BUFFER_PTR(current_buffer_cbptr); - - /* Mark this as set. */ - flipcdbg_update_bufferset_bitvec(cb_ctl, current_buffer); - - /* Increment the current pointer. */ - current_ptr = NEXT_BUFFERLIST_PTR_ME(current_ptr, - current_endpoint); - } - } - } - - /* Ok, we should have marked every buffer that has a reference. - Print out all the ones that done have references. */ - for (i = 0; i < bitvec_length; i++) { - int this_limit = - ((i == bitvec_length - 1) - ? cb_ctl->data_buffer.number % (sizeof(unsigned long)*8) - : sizeof(unsigned long)*8); - if (flipc_debug_buffer_bitvec[i] != (unsigned long) -1) { - int j; - for (j = 0; j < this_limit; j++) { - if (!(flipc_debug_buffer_bitvec[i] & (1 << j))) { - int buffer_bitpos = i * sizeof(unsigned long) * 8 + j; - flipc_cb_ptr buffer_cbptr = - (buffer_bitpos * cb_ctl->data_buffer_size - + cb_ctl->data_buffer.start); - flipc_data_buffer_t buffer_ptr = - FLIPC_DATA_BUFFER_PTR(buffer_cbptr); - - /* Print header if necessary. */ - if (!header_printed) { - header_printed = 1; - printf("Unreferenced buffers (ptr,idx,cbptr):"); - } - - /* Print buffer. */ - printf(" (0x%x,%d,0x%x)", buffer_ptr, buffer_bitpos, - buffer_cbptr); - } - } - } - } - if (header_printed) - printf("\n"); -} - -void -flipcdbg_buffer_find_refs(flipc_cb_ptr buffer_cbptr) -{ - flipc_comm_buffer_ctl_t cb_ctl = - (flipc_comm_buffer_ctl_t) flipc_cb_base; - int found_on_freelist = 0; - int found_on_endpoints = 0; - int i; - flipc_endpoint_t current_endpoint; - - flipc_cb_ptr current_cbptr; - flipc_data_buffer_t current_buffer; - - /* Go through the freelist, looking for buffer. */ - for (i = 0, current_cbptr = cb_ctl->data_buffer.free; - current_cbptr != FLIPC_CBPTR_NULL; - i++, current_cbptr = current_buffer->u.free) { - if (current_cbptr == buffer_cbptr) { - printf("Buffer found on freelist in position %d\n", i); - found_on_freelist = 1; - } - current_buffer = FLIPC_DATA_BUFFER_PTR(current_cbptr); - if (i > cb_ctl->data_buffer.number) { - printf ("**Some form of corruption following freelist.**"); - return; - } - } - if (found_on_freelist) - printf("(Total buffers on freelist: %d/%d)\n", i, - cb_ctl->data_buffer.number); - - /* Go through all the endpoints, again looking for the buffer. */ - for (current_endpoint = FLIPC_ENDPOINT_PTR(cb_ctl->endpoint.start); - (current_endpoint - < (FLIPC_ENDPOINT_PTR(cb_ctl->endpoint.start) - + cb_ctl->endpoint.number)); - current_endpoint++) { - if (EXTRACT_ENABLED(current_endpoint->saildm_dpb_or_enabled)) { - flipc_cb_ptr current_ptr = - (EXTRACT_DPB(current_endpoint->saildm_dpb_or_enabled) - ? current_endpoint->sme_process_ptr - : current_endpoint->shrd_acquire_ptr); - flipc_cb_ptr limit_ptr = current_endpoint->sail_release_ptr; - - while (current_ptr != limit_ptr) { - current_cbptr = *FLIPC_BUFFERLIST_PTR(current_ptr); - - if (current_cbptr == buffer_cbptr) { - printf("Buffer found on endpoint 0x%x (idx: %d)\n", - current_endpoint, - (current_endpoint - - FLIPC_ENDPOINT_PTR(cb_ctl->endpoint.start))); - found_on_endpoints = 1; - } - - /* Increment the current pointer. */ - current_ptr = NEXT_BUFFERLIST_PTR_ME(current_ptr, - current_endpoint); - } - } - } -} - - - diff --git a/include/xnu/mach/flipc_device.h b/include/xnu/mach/flipc_device.h deleted file mode 100644 index e76e52047..000000000 --- a/include/xnu/mach/flipc_device.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * 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@ - */ -/* - * @OSF_COPYRIGHT@ - * - */ -/* - * HISTORY - * - * Revision 1.1.1.1 1998/09/22 21:05:29 wsanchez - * Import of Mac OS X kernel (~semeria) - * - * Revision 1.1.1.1 1998/03/07 02:25:45 wsanchez - * Import of OSF Mach kernel (~mburg) - * - * Revision 1.1.5.1 1995/06/13 18:20:16 sjs - * Merged from flipc_shared. - * [95/06/07 sjs] - * - * Revision 1.1.3.4 1995/04/05 21:21:58 randys - * Added allocations_lock_policy argument to usermsg_Init_Buffer set - * status call. - * [95/04/05 randys] - * - * Revision 1.1.3.3 1995/02/21 17:23:08 randys - * Re-indented code to four space indentation - * [1995/02/21 16:25:35 randys] - * - * Revision 1.1.3.2 1994/12/20 19:02:03 randys - * Added filename in comment at top of each file - * [1994/12/19 20:28:25 randys] - * - * Revision 1.1.3.1 1994/12/12 17:46:17 randys - * Putting initial flipc implementation under flipc_shared - * [1994/12/12 16:27:48 randys] - * - * Revision 1.1.1.2 1994/12/11 23:11:21 randys - * Initial flipc code checkin - * - * $EndLog$ - */ - -/* - * mach/flipc_device.h - * - * Declarations related to the device driver interface to FLIPC. - */ - -#ifndef _MACH_FLIPC_DEVICE_H_ -#define _MACH_FLIPC_DEVICE_H_ - -/* - * Definitions of constants both the ME and AIL need to know for - * communications through the device driver interface. These are the - * possible values for the top 16 bits of the flavor parameter; the - * bottom 16 bits are extra information that may be needed (eg. to - * parameterize a request for semaphore in the get status routine). - */ -typedef enum { /* Arguments. */ - /* Get status flavors. */ - usermsg_Get_Initialized_Status = 1, /* (int *init_p) */ - usermsg_Get_Epgroup_Semaphore, /* (mach_port_t *semaphore) */ - usermsg_Return_Allocations_Lock, /* (void) */ - - /* Set status flavors. */ - usermsg_Init_Buffer, /* (int max_endpoints, - int max_epgroups, - int max_buffers, - int max_buffers_per_endpoint, - int allocations_lock_policy) */ - usermsg_Process_Work, /* (void) */ - usermsg_Acquire_Allocations_Lock, /* (void) */ - usermsg_Release_Allocations_Lock, /* (void) */ - usermsg_Epgroup_Associate_Semaphore /* (int epgroup_idx, mach_port_t port) */ -} usermsg_devop_t; - -#define FLIPC_DEVICE_FLAVOR(devop, param) (((devop)<<16)|(param)) - -#endif /* _MACH_FLIPC_DEVICE_H_ */ diff --git a/include/xnu/mach/flipc_locks.h b/include/xnu/mach/flipc_locks.h deleted file mode 100644 index 94d9a6ee5..000000000 --- a/include/xnu/mach/flipc_locks.h +++ /dev/null @@ -1,180 +0,0 @@ -/* - * 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@ - */ -/* - * @OSF_COPYRIGHT@ - * - */ -/* - * HISTORY - * - * Revision 1.1.1.1 1998/09/22 21:05:30 wsanchez - * Import of Mac OS X kernel (~semeria) - * - * Revision 1.1.1.1 1998/03/07 02:25:45 wsanchez - * Import of OSF Mach kernel (~mburg) - * - * Revision 1.1.4.1 1995/06/13 18:20:29 sjs - * Merged from flipc_shared. - * [95/06/07 sjs] - * - * Revision 1.1.2.3 1995/03/09 19:42:30 rwd - * Move yield function out of macro and prototype. - * [1995/03/09 19:36:25 rwd] - * - * Revision 1.1.2.2 1995/02/21 17:23:11 randys - * Re-indented code to four space indentation - * [1995/02/21 16:25:39 randys] - * - * Revision 1.1.2.1 1994/12/20 19:02:06 randys - * Moved definition of flipc_simple_lock to flipc_cb.h - * [1994/12/20 17:34:44 randys] - * - * Separated the lock macros out into machine dependent and independent files; - * this is the machine independent file. - * [1994/12/20 16:43:38 randys] - * - * $EndLog$ - */ - -/* - * mach/flipc_locks.h - * - * The machine independent part of the flipc_simple_locks definitions. - * Most of the locks definitions is in flipc_dep.h, but what isn't - * dependent on the platform being used is here. - */ - -/* - * Note that the locks defined in this file and in flipc_dep.h are only - * for use by user level code. The reason why this file is visible to - * the kernel is that the kernel section of flipc needs to initialize - * these locks. - */ - -#ifndef _MACH_FLIPC_LOCKS_H_ -#define _MACH_FLIPC_LOCKS_H_ - -/* Get the simple lock type. */ -#include - -/* - * Lock function prototypes. This needs to be before any lock definitions - * that happen to be macros. - */ - -/* Initializes lock. Always a macro (so that kernel code can use it without - library assistance). */ -void flipc_simple_lock_init(flipc_simple_lock *lock); - -/* Returns 1 if lock gained, 0 otherwise. */ -int flipc_simple_lock_try(flipc_simple_lock *lock); - -/* Returns 1 if lock is locked, 0 otherwise. */ -int flipc_simple_lock_locked(flipc_simple_lock *lock); - -/* Releases the lock. */ -void flipc_simple_lock_release(flipc_simple_lock *lock); - -/* Take the lock. */ -void flipc_simple_lock_acquire(flipc_simple_lock *lock); - -/* Take two locks. Does not hold one while spinning on the - other. */ -void flipc_simple_lock_acquire_2(flipc_simple_lock *lock1, - flipc_simple_lock *lock2); - -/* Get the machine dependent stuff. The things that need to be - * defined in a machine dependent fashion are: - * - * flipc_simple_lock_init (must be a macro) - * flipc_simple_lock_try - * flipc_simple_lock_locked - * flipc_simple_lock_release - * - * These last three don't necessarily have to be macros, but if they - * aren't definitions must be included in the machine dependent - * part of the user level library code. - */ -#include - -/* - * Set at flipc initialization time to thread_yield argument to - * FLIPC_domain_init - */ - -extern void (*flipc_simple_lock_yield_fn)(void); - -/* - * Machine independent definitions; defined in terms of above routines. - */ - -/* Take the lock. Assumes an external define saying how long to - spin, and an external function to call when we've spun too long. */ -#define flipc_simple_lock_acquire(lock) \ -do { \ - int __spin_count = 0; \ - \ - while (flipc_simple_lock_locked(lock) \ - || !flipc_simple_lock_try(lock)) \ - if (++__spin_count > LOCK_SPIN_LIMIT) { \ - (*flipc_simple_lock_yield_fn)(); \ - __spin_count = 0; \ - } \ -} while (0) - -/* Take two locks. Hold neither while spinning on the other. */ -#define flipc_simple_lock_acquire_2(lock1, lock2) \ -do { \ - int __spin_count = 0; \ - \ - while (1) { \ - while (flipc_simple_lock_locked(lock1) \ - || !flipc_simple_lock_try(lock1)) \ - if (++__spin_count > LOCK_SPIN_LIMIT) { \ - (*flipc_simple_lock_yield_fn)(); \ - __spin_count = 0; \ - } \ - \ - if (flipc_simple_lock_try(lock2)) \ - break; \ - flipc_simple_lock_release(lock1); \ - \ - while (flipc_simple_lock_locked(lock2) \ - || !flipc_simple_lock_try(lock2)) \ - if (++__spin_count > LOCK_SPIN_LIMIT) { \ - (*flipc_simple_lock_yield_fn)(); \ - __spin_count = 0; \ - } \ - \ - if (flipc_simple_lock_try(lock1)) \ - break; \ - flipc_simple_lock_release(lock2); \ - } \ -} while (0) - -#endif /* _MACH_FLIPC_LOCKS_H_ */ diff --git a/include/xnu/mach/flipc_types.h b/include/xnu/mach/flipc_types.h deleted file mode 100644 index 1f7f9782b..000000000 --- a/include/xnu/mach/flipc_types.h +++ /dev/null @@ -1,260 +0,0 @@ -/* - * 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@ - */ -/* - * @OSF_COPYRIGHT@ - * - */ -/* - * HISTORY - * - * Revision 1.1.1.1 1998/09/22 21:05:30 wsanchez - * Import of Mac OS X kernel (~semeria) - * - * Revision 1.1.1.1 1998/03/07 02:25:45 wsanchez - * Import of OSF Mach kernel (~mburg) - * - * Revision 1.1.7.1 1996/09/17 16:34:35 bruel - * fixed types. - * [96/09/17 bruel] - * - * Revision 1.1.5.1 1995/06/13 18:20:20 sjs - * Merged from flipc_shared. - * [95/06/07 sjs] - * - * Revision 1.1.3.11 1995/05/23 19:55:36 randys - * Don't keep track of messages sent to a bad destination--that's - * purely a transport function now. - * [95/05/23 randys] - * - * Revision 1.1.3.10 1995/05/23 15:40:20 randys - * Added field to FLIPC_domain_errors to indicate validity of other - * fields. - * [95/05/22 randys] - * - * Revision 1.1.3.9 1995/05/16 20:46:35 randys - * Added a "performance_valid" field to the flipc performance - * structure. - * [95/05/16 randys] - * - * Revision 1.1.3.8 1995/04/05 21:22:01 randys - * Added field to domain_info struct to include allocations lock - * sched policy. - * [95/04/05 randys] - * - * Revision 1.1.3.7 1995/03/09 19:42:33 rwd - * Define SEMAPHORE_NULL (for now) and include mach_types.h instead - * of sema_types.h. - * [95/03/08 rwd] - * - * Revision 1.1.3.6 1995/02/23 21:32:52 randys - * Removed placeholder definition for locks--I don't believe that I - * use locks unless I'm on top of a real time base, in which case - * that base will define the type. - * [95/02/22 randys] - * - * Revision 1.1.3.5 1995/02/21 17:23:13 randys - * Re-indented code to four space indentation - * [1995/02/21 16:25:36 randys] - * - * Revision 1.1.3.4 1995/02/16 23:20:14 randys - * ANSIfy FLIPC_thread_yield_function. - * [95/02/14 randys] - * - * Add FLIPC_thread_yield_function type. - * [95/02/14 randys] - * - * Revision 1.1.3.3 1995/01/26 21:01:51 randys - * Added performance structure. - * [1995/01/24 21:14:12 randys] - * - * Added FLIPC_epgroup_info struct - * [1995/01/24 18:30:02 randys] - * - * Create a new structure (FLIPC_endpoint_info) to return - * information about an endpoint. - * [1995/01/20 19:26:35 randys] - * - * Get rid of FLIPC_DESTINATION_NULL and add in - * FLIPC_ADDRESS_ERROR (return code from FLIPC_buffer_destination) - * [1995/01/19 20:23:24 randys] - * - * Added domain index type for specifying domain in - * init and attach calls - * [1995/01/18 16:47:25 randys] - * - * Revision 1.1.3.2 1994/12/20 19:02:09 randys - * Added error reporting structure type, and added - * room in the standard domain query for error log size. - * [1994/12/19 23:46:09 randys] - * - * Added filename in comment at top of each file - * [1994/12/19 20:28:26 randys] - * - * Support and doc for minor user interface changes for error conditions - * [1994/12/18 23:24:30 randys] - * - * Yank the semaphore type definitions back out, and include the file - * that defines those types. - * [1994/12/13 17:50:03 randys] - * - * Revision 1.1.3.1 1994/12/12 17:46:20 randys - * Put definitions of semaphore_t and SEMAPHORE_NULL back in; they aren't - * defined in user space yet. - * [1994/12/12 17:21:56 randys] - * - * Revision 1.1.1.2 1994/12/11 23:11:23 randys - * Initial flipc code checkin - * - * $EndLog$ - */ - -/* - * mach/flipc_types.h - * - * Definitions of those flipc types that need to be visible to both the AIL - * and kernel sides of flipc (which is just about everything). - */ - -#ifndef _MACH_FLIPC_TYPES_H_ -#define _MACH_FLIPC_TYPES_H_ - -#include - -/* - * Define a couple of generally useful types. - */ -#include - -#ifndef MACH_KERNEL -#define SEMAPHORE_NULL (semaphore_port_t)0 -#endif /* !defined(MACH_KERNEL) */ - -/* - * Basic flipc types; visible to both user and kernel segments of the - * flipc implementation. - */ -/* Flipc addresses. These name a node-endpoint combination for - sending. */ -typedef unsigned int FLIPC_address_t; -#define FLIPC_ADDRESS_ERROR ((FLIPC_address_t) -1) - -/* Flipc endpoints. */ -typedef void *FLIPC_endpoint_t; -#define FLIPC_ENDPOINT_NULL ((FLIPC_endpoint_t) 0) - -/* Buffer pointers (returned by query functions). Users are allowed to - copy directly to/from this pointer; it points at their data. */ -typedef void *FLIPC_buffer_t; -#define FLIPC_BUFFER_NULL ((FLIPC_buffer_t) 0) - -/* Endpoint group identifiers. */ -typedef void *FLIPC_epgroup_t; -#define FLIPC_EPGROUP_NULL ((FLIPC_epgroup_t) 0) -#define FLIPC_EPGROUP_ERROR ((FLIPC_epgroup_t) -1) - -/* Domain index; argument to initialization and attach routines. */ -typedef unsigned int FLIPC_domain_index_t; - -/* Domain handle (mach port). */ -typedef mach_port_t FLIPC_domain_t; - -/* The different types an endpoint can be. FLIPC_Inactive is used when - the endpoint has not been configured and hence is on the freelist. */ -typedef enum { - FLIPC_Inactive = -1, - FLIPC_Send, - FLIPC_Receive -} FLIPC_endpoint_type_t; - -/* Structure for returning performance information about the flipc - domain; a placeholder for future entries as needed. - This information will only be valid if the kernel is configured to - keep flipc performance information. */ -typedef struct FLIPC_domain_performance_info { - unsigned long performance_valid; /* Non zero if the other information - in this structure is valid. */ - unsigned long messages_sent; /* Since last init. */ - unsigned long messages_received; /* Since last init. Includes overruns - (because they are marked in the - endpoint data structure). Doesn't - include other drops (they are - marked in other places) */ -} *FLIPC_domain_performance_info_t; - -/* Flipc yield function. */ -typedef void (*FLIPC_thread_yield_function)(void); - -/* Structure for returning information about the flipc domain. */ -typedef struct FLIPC_domain_info { - int max_endpoints; - int max_epgroups; - int max_buffers; - int max_buffers_per_endpoint; - int msg_buffer_size; - FLIPC_thread_yield_function yield_fn; - int policy; /* Allocations lock sched policy. - Unused if REAL_TIME_PRIMITIVES are - not being used. */ - struct FLIPC_domain_performance_info performance; - int error_log_size; /* In bytes. */ -} *FLIPC_domain_info_t; - -/* Structure for returning information about the error state of - the flipc domain. Note that this is variable sized; the size - of the transport specific information is not known at compile - time. */ -typedef struct FLIPC_domain_errors { - int error_full_config_p; /* 1 if disabled and badtype below are - valid; 0 if only msgdrop_inactive - is valid. */ - int msgdrop_inactive; /* Messages dropped because - of the domain being locally - inactive. */ - int msgdrop_disabled; /* Messages dropped because of a - disabled endpoint. */ - int msgdrop_badtype; /* Messages dropped because they - were sent to a send endpoint. */ - - int transport_error_size; /* Size of the following array of - ints, in bytes. */ - int transport_error_info[1]; /* Really of transport_error_size. */ -} *FLIPC_domain_errors_t; - -/* Structure for returning information about endpoints. */ -typedef struct FLIPC_endpoint_info { - FLIPC_endpoint_type_t type; - unsigned int processed_buffers_dropped_p; - unsigned long number_buffers; - FLIPC_epgroup_t epgroup; -} *FLIPC_endpoint_info_t; - -typedef struct FLIPC_epgroup_info { - unsigned long msgs_per_wakeup; -} *FLIPC_epgroup_info_t; - -#endif /* _MACH_FLIPC_TYPES_H_ */ diff --git a/include/xnu/mach/host_info.h b/include/xnu/mach/host_info.h deleted file mode 100644 index d90f3be37..000000000 --- a/include/xnu/mach/host_info.h +++ /dev/null @@ -1,277 +0,0 @@ -/* - * Copyright (c) 2000-2009 Apple 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@ - */ -/* - * @OSF_COPYRIGHT@ - */ -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989,1988 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 Software.Distribution@CS.CMU.EDU - * 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/host_info.h - * - * Definitions for host_info call. - */ - -#ifndef _MACH_HOST_INFO_H_ -#define _MACH_HOST_INFO_H_ - -#include -#include -#include -#include -#include - -#include - -/* - * Generic information structure to allow for expansion. - */ -typedef integer_t *host_info_t; /* varying array of int. */ -typedef integer_t *host_info64_t; /* varying array of int. */ - -#define HOST_INFO_MAX (1024) /* max array size */ -typedef integer_t host_info_data_t[HOST_INFO_MAX]; - -#define KERNEL_VERSION_MAX (512) -typedef char kernel_version_t[KERNEL_VERSION_MAX]; - -#define KERNEL_BOOT_INFO_MAX (4096) -typedef char kernel_boot_info_t[KERNEL_BOOT_INFO_MAX]; - -/* - * Currently defined information. - */ -/* host_info() */ -typedef integer_t host_flavor_t; -#define HOST_BASIC_INFO 1 /* basic info */ -#define HOST_SCHED_INFO 3 /* scheduling info */ -#define HOST_RESOURCE_SIZES 4 /* kernel struct sizes */ -#define HOST_PRIORITY_INFO 5 /* priority information */ -#define HOST_SEMAPHORE_TRAPS 7 /* Has semaphore traps */ -#define HOST_MACH_MSG_TRAP 8 /* Has mach_msg_trap */ - -#ifdef MACH_KERNEL_PRIVATE -struct host_basic_info_old { - integer_t max_cpus; /* max number of cpus possible */ - uint32_t avail_cpus; /* number of cpus now available */ - natural_t memory_size; /* size of memory in bytes */ - cpu_type_t cpu_type; /* cpu type */ - cpu_subtype_t cpu_subtype; /* cpu subtype */ -}; - -typedef struct host_basic_info_old host_basic_info_data_old_t; -typedef struct host_basic_info_old *host_basic_info_old_t; -#define HOST_BASIC_INFO_OLD_COUNT ((mach_msg_type_number_t) \ - (sizeof(host_basic_info_data_old_t)/sizeof(integer_t))) -#endif - -#pragma pack(4) - -struct host_basic_info { - integer_t max_cpus; /* max number of CPUs possible */ - integer_t avail_cpus; /* number of CPUs now available */ - natural_t memory_size; /* size of memory in bytes, capped at 2 GB */ - cpu_type_t cpu_type; /* cpu type */ - cpu_subtype_t cpu_subtype; /* cpu subtype */ - cpu_threadtype_t cpu_threadtype; /* cpu threadtype */ - integer_t physical_cpu; /* number of physical CPUs now available */ - integer_t physical_cpu_max; /* max number of physical CPUs possible */ - integer_t logical_cpu; /* number of logical cpu now available */ - integer_t logical_cpu_max; /* max number of physical CPUs possible */ - uint64_t max_mem; /* actual size of physical memory */ -}; - -#pragma pack() - -typedef struct host_basic_info host_basic_info_data_t; -typedef struct host_basic_info *host_basic_info_t; -#define HOST_BASIC_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof(host_basic_info_data_t)/sizeof(integer_t))) - -struct host_sched_info { - integer_t min_timeout; /* minimum timeout in milliseconds */ - integer_t min_quantum; /* minimum quantum in milliseconds */ -}; - -typedef struct host_sched_info host_sched_info_data_t; -typedef struct host_sched_info *host_sched_info_t; -#define HOST_SCHED_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof(host_sched_info_data_t)/sizeof(integer_t))) - -struct kernel_resource_sizes { - natural_t task; - natural_t thread; - natural_t port; - natural_t memory_region; - natural_t memory_object; -}; - -typedef struct kernel_resource_sizes kernel_resource_sizes_data_t; -typedef struct kernel_resource_sizes *kernel_resource_sizes_t; -#define HOST_RESOURCE_SIZES_COUNT ((mach_msg_type_number_t) \ - (sizeof(kernel_resource_sizes_data_t)/sizeof(integer_t))) - -struct host_priority_info { - integer_t kernel_priority; - integer_t system_priority; - integer_t server_priority; - integer_t user_priority; - integer_t depress_priority; - integer_t idle_priority; - integer_t minimum_priority; - integer_t maximum_priority; -}; - -typedef struct host_priority_info host_priority_info_data_t; -typedef struct host_priority_info *host_priority_info_t; -#define HOST_PRIORITY_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof(host_priority_info_data_t)/sizeof(integer_t))) - -/* host_statistics() */ -#define HOST_LOAD_INFO 1 /* System loading stats */ -#define HOST_VM_INFO 2 /* Virtual memory stats */ -#define HOST_CPU_LOAD_INFO 3 /* CPU load stats */ - -/* host_statistics64() */ -#define HOST_VM_INFO64 4 /* 64-bit virtual memory stats */ -#define HOST_EXTMOD_INFO64 5 /* External modification stats */ - - -struct host_load_info { - integer_t avenrun[3]; /* scaled by LOAD_SCALE */ - integer_t mach_factor[3]; /* scaled by LOAD_SCALE */ -}; - -typedef struct host_load_info host_load_info_data_t; -typedef struct host_load_info *host_load_info_t; -#define HOST_LOAD_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof(host_load_info_data_t)/sizeof(integer_t))) - -/* in */ -/* vm_statistics64 */ -#define HOST_VM_INFO64_COUNT ((mach_msg_type_number_t) \ - (sizeof(vm_statistics64_data_t)/sizeof(integer_t))) - -/* size of the latest version of the structure */ -#define HOST_VM_INFO64_LATEST_COUNT HOST_VM_INFO64_COUNT - -/* in */ -/* vm_extmod_statistics */ -#define HOST_EXTMOD_INFO64_COUNT ((mach_msg_type_number_t) \ - (sizeof(vm_extmod_statistics_data_t)/sizeof(integer_t))) - -/* size of the latest version of the structure */ -#define HOST_EXTMOD_INFO64_LATEST_COUNT HOST_EXTMOD_INFO64_COUNT - -/* vm_statistics */ -#define HOST_VM_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof(vm_statistics_data_t)/sizeof(integer_t))) - -/* size of the latest version of the structure */ -#define HOST_VM_INFO_LATEST_COUNT HOST_VM_INFO_COUNT -#define HOST_VM_INFO_REV2_COUNT HOST_VM_INFO_LATEST_COUNT -/* previous versions: adjust the size according to what was added each time */ -#define HOST_VM_INFO_REV1_COUNT /* added "speculative_count" (1 int) */ \ - ((mach_msg_type_number_t) \ - (HOST_VM_INFO_REV2_COUNT - 1)) -#define HOST_VM_INFO_REV0_COUNT /* added "purgable" info (2 ints) */ \ - ((mach_msg_type_number_t) \ - (HOST_VM_INFO_REV1_COUNT - 2)) - -struct host_cpu_load_info { /* number of ticks while running... */ - natural_t cpu_ticks[CPU_STATE_MAX]; /* ... in the given mode */ -}; - -typedef struct host_cpu_load_info host_cpu_load_info_data_t; -typedef struct host_cpu_load_info *host_cpu_load_info_t; -#define HOST_CPU_LOAD_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof (host_cpu_load_info_data_t) / sizeof (integer_t))) - -#ifdef PRIVATE -/* - * CPU Statistics information - */ -struct _processor_statistics_np { - int32_t ps_cpuid; - - uint32_t ps_csw_count; - uint32_t ps_preempt_count; - uint32_t ps_preempted_rt_count; - uint32_t ps_preempted_by_rt_count; - - uint32_t ps_rt_sched_count; - - uint32_t ps_interrupt_count; - uint32_t ps_ipi_count; - uint32_t ps_timer_pop_count; - - uint64_t ps_runq_count_sum __attribute((aligned(8))); - - uint32_t ps_idle_transitions; - uint32_t ps_quantum_timer_expirations; -}; - -#endif /* PRIVATE */ - -#ifdef KERNEL_PRIVATE - -extern kern_return_t set_sched_stats_active( - boolean_t active); - -extern kern_return_t get_sched_statistics( - struct _processor_statistics_np *out, - uint32_t *count); -#endif /* KERNEL_PRIVATE */ - - -#endif /* _MACH_HOST_INFO_H_ */ diff --git a/include/xnu/mach/host_notify.h b/include/xnu/mach/host_notify.h deleted file mode 100644 index 6c0ca74b9..000000000 --- a/include/xnu/mach/host_notify.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2003 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@ - */ - -#ifndef _MACH_HOST_NOTIFY_H_ -#define _MACH_HOST_NOTIFY_H_ - -#define HOST_NOTIFY_CALENDAR_CHANGE 0 -#define HOST_NOTIFY_TYPE_MAX 0 - -#define HOST_CALENDAR_CHANGED_REPLYID 950 - -#endif /* _MACH_HOST_NOTIFY_H_ */ diff --git a/include/xnu/mach/host_reboot.h b/include/xnu/mach/host_reboot.h deleted file mode 100644 index 65609dd7f..000000000 --- a/include/xnu/mach/host_reboot.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2000-2004 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@ - */ -/* - * @OSF_COPYRIGHT@ - */ - -#ifndef _MACH_HOST_REBOOT_ -#define _MACH_HOST_REBOOT_ - -#define HOST_REBOOT_HALT 0x0008 -#define HOST_REBOOT_UPSDELAY 0x0100 -#define HOST_REBOOT_DEBUGGER 0x1000 - -#endif /* _MACH_HOST_REBOOT_ */ diff --git a/include/xnu/mach/host_special_ports.h b/include/xnu/mach/host_special_ports.h deleted file mode 100644 index 4b2037256..000000000 --- a/include/xnu/mach/host_special_ports.h +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 2003 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@ - */ -/* - * @OSF_COPYRIGHT@ - */ -/* - * Mach Operating System - * Copyright (c) 1991 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 Software.Distribution@CS.CMU.EDU - * 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/host_special_ports.h - * - * Defines codes for access to host-wide special ports. - */ - -#ifndef _MACH_HOST_SPECIAL_PORTS_H_ -#define _MACH_HOST_SPECIAL_PORTS_H_ - -/* - * Cannot be set or gotten from user space - */ -#define HOST_SECURITY_PORT 0 - -/* - * Always provided by kernel (cannot be set from user-space). - */ -#define HOST_PORT 1 -#define HOST_PRIV_PORT 2 -#define HOST_IO_MASTER_PORT 3 -#define HOST_MAX_SPECIAL_KERNEL_PORT 7 /* room to grow */ - -/* - * Not provided by kernel - */ -#define HOST_DYNAMIC_PAGER_PORT (1 + HOST_MAX_SPECIAL_KERNEL_PORT) -#define HOST_AUDIT_CONTROL_PORT (2 + HOST_MAX_SPECIAL_KERNEL_PORT) -#define HOST_USER_NOTIFICATION_PORT (3 + HOST_MAX_SPECIAL_KERNEL_PORT) -#define HOST_AUTOMOUNTD_PORT (4 + HOST_MAX_SPECIAL_KERNEL_PORT) -#define HOST_LOCKD_PORT (5 + HOST_MAX_SPECIAL_KERNEL_PORT) -#define HOST_SEATBELT_PORT (7 + HOST_MAX_SPECIAL_KERNEL_PORT) -#define HOST_KEXTD_PORT (8 + HOST_MAX_SPECIAL_KERNEL_PORT) -#define HOST_CHUD_PORT (9 + HOST_MAX_SPECIAL_KERNEL_PORT) -#define HOST_UNFREED_PORT (10 + HOST_MAX_SPECIAL_KERNEL_PORT) -#define HOST_AMFID_PORT (11 + HOST_MAX_SPECIAL_KERNEL_PORT) -#define HOST_GSSD_PORT (12 + HOST_MAX_SPECIAL_KERNEL_PORT) -#define HOST_MAX_SPECIAL_PORT (13 + HOST_MAX_SPECIAL_KERNEL_PORT) - /* room to grow here as well */ - -/* - * Special node identifier to always represent the local node. - */ -#define HOST_LOCAL_NODE -1 - -/* - * Definitions for ease of use. - * - * In the get call, the host parameter can be any host, but will generally - * be the local node host port. In the set call, the host must the per-node - * host port for the node being affected. - */ -#define host_get_host_port(host, port) \ - (host_get_special_port((host), \ - HOST_LOCAL_NODE, HOST_PORT, (port))) -#define host_set_host_port(host, port) (KERN_INVALID_ARGUMENT) - -#define host_get_host_priv_port(host, port) \ - (host_get_special_port((host), \ - HOST_LOCAL_NODE, HOST_PRIV_PORT, (port))) -#define host_set_host_priv_port(host, port) (KERN_INVALID_ARGUMENT) - -#define host_get_io_master_port(host, port) \ - (host_get_special_port((host), \ - HOST_LOCAL_NODE, HOST_IO_MASTER_PORT, (port))) -#define host_set_io_master_port(host, port) (KERN_INVALID_ARGUMENT) - -/* - * User-settable special ports. - */ -#define host_get_dynamic_pager_port(host, port) \ - (host_get_special_port((host), \ - HOST_LOCAL_NODE, HOST_DYNAMIC_PAGER_PORT, (port))) -#define host_set_dynamic_pager_port(host, port) \ - (host_set_special_port((host), HOST_DYNAMIC_PAGER_PORT, (port))) - -#define host_get_audit_control_port(host, port) \ - (host_get_special_port((host), \ - HOST_LOCAL_NODE, HOST_AUDIT_CONTROL_PORT, (port))) -#define host_set_audit_control_port(host, port) \ - (host_set_special_port((host), HOST_AUDIT_CONTROL_PORT, (port))) - -#define host_get_user_notification_port(host, port) \ - (host_get_special_port((host), \ - HOST_LOCAL_NODE, HOST_USER_NOTIFICATION_PORT, (port))) -#define host_set_user_notification_port(host, port) \ - (host_set_special_port((host), HOST_USER_NOTIFICATION_PORT, (port))) - -#define host_get_automountd_port(host, port) \ - (host_get_special_port((host), \ - HOST_LOCAL_NODE, HOST_AUTOMOUNTD_PORT, (port))) -#define host_set_automountd_port(host, port) \ - (host_set_special_port((host), HOST_AUTOMOUNTD_PORT, (port))) - -#define host_get_lockd_port(host, port) \ - (host_get_special_port((host), \ - HOST_LOCAL_NODE, HOST_LOCKD_PORT, (port))) -#define host_set_lockd_port(host, port) \ - (host_set_special_port((host), HOST_LOCKD_PORT, (port))) - -#define host_get_kextd_port(host, port) \ - (host_get_special_port((host), \ - HOST_LOCAL_NODE, HOST_KEXTD_PORT, (port))) -#define host_set_kextd_port(host, port) \ - (host_set_special_port((host), HOST_KEXTD_PORT, (port))) - -#define host_get_chud_port(host, port) \ - (host_get_special_port((host), \ - HOST_LOCAL_NODE, HOST_CHUD_PORT, (port))) -#define host_set_chud_port(host, port) \ - (host_set_special_port((host), HOST_CHUD_PORT, (port))) - -#define host_get_unfreed_port(host, port) \ - (host_get_special_port((host), \ - HOST_LOCAL_NODE, HOST_UNFREED_PORT, (port))) -#define host_set_unfreed_port(host, port) \ - (host_set_special_port((host), HOST_UNFREED_PORT, (port))) - -#define host_get_amfid_port(host, port) \ - (host_get_special_port((host), \ - HOST_LOCAL_NODE, HOST_AMFID_PORT, (port))) -#define host_set_amfid_port(host, port) \ - (host_set_special_port((host), HOST_AMFID_PORT, (port))) - -#define host_get_gssd_port(host, port) \ - (host_get_special_port((host), \ - HOST_LOCAL_NODE, HOST_GSSD_PORT, (port))) - -#define host_set_gssd_port(host, port) \ - (host_set_special_port((host), HOST_GSSD_PORT, (port))) - -#endif /* _MACH_HOST_SPECIAL_PORTS_H_ */ diff --git a/include/xnu/mach/i386/_structs.h b/include/xnu/mach/i386/_structs.h deleted file mode 100644 index 9dd3f4416..000000000 --- a/include/xnu/mach/i386/_structs.h +++ /dev/null @@ -1,797 +0,0 @@ -/* - * Copyright (c) 2004-2006 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@ - */ -/* - * @OSF_COPYRIGHT@ - */ - -#ifndef _MACH_I386__STRUCTS_H_ -#define _MACH_I386__STRUCTS_H_ - -/* - * i386 is the structure that is exported to user threads for - * use in status/mutate calls. This structure should never change. - * - */ - -#if __DARWIN_UNIX03 -#define _STRUCT_X86_THREAD_STATE32 struct __darwin_i386_thread_state -_STRUCT_X86_THREAD_STATE32 -{ - unsigned int __eax; - unsigned int __ebx; - unsigned int __ecx; - unsigned int __edx; - unsigned int __edi; - unsigned int __esi; - unsigned int __ebp; - unsigned int __esp; - unsigned int __ss; - unsigned int __eflags; - unsigned int __eip; - unsigned int __cs; - unsigned int __ds; - unsigned int __es; - unsigned int __fs; - unsigned int __gs; -}; -#else /* !__DARWIN_UNIX03 */ -#define _STRUCT_X86_THREAD_STATE32 struct i386_thread_state -_STRUCT_X86_THREAD_STATE32 -{ - unsigned int eax; - unsigned int ebx; - unsigned int ecx; - unsigned int edx; - unsigned int edi; - unsigned int esi; - unsigned int ebp; - unsigned int esp; - unsigned int ss; - unsigned int eflags; - unsigned int eip; - unsigned int cs; - unsigned int ds; - unsigned int es; - unsigned int fs; - unsigned int gs; -}; -#endif /* !__DARWIN_UNIX03 */ - -/* This structure should be double-word aligned for performance */ - -#if __DARWIN_UNIX03 -#define _STRUCT_FP_CONTROL struct __darwin_fp_control -_STRUCT_FP_CONTROL -{ - unsigned short __invalid :1, - __denorm :1, - __zdiv :1, - __ovrfl :1, - __undfl :1, - __precis :1, - :2, - __pc :2, -#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) -#define FP_PREC_24B 0 -#define FP_PREC_53B 2 -#define FP_PREC_64B 3 -#endif /* !_POSIX_C_SOURCE || _DARWIN_C_SOURCE */ - __rc :2, -#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) -#define FP_RND_NEAR 0 -#define FP_RND_DOWN 1 -#define FP_RND_UP 2 -#define FP_CHOP 3 -#endif /* !_POSIX_C_SOURCE || _DARWIN_C_SOURCE */ - /*inf*/ :1, - :3; -}; -typedef _STRUCT_FP_CONTROL __darwin_fp_control_t; -#else /* !__DARWIN_UNIX03 */ -#define _STRUCT_FP_CONTROL struct fp_control -_STRUCT_FP_CONTROL -{ - unsigned short invalid :1, - denorm :1, - zdiv :1, - ovrfl :1, - undfl :1, - precis :1, - :2, - pc :2, -#define FP_PREC_24B 0 -#define FP_PREC_53B 2 -#define FP_PREC_64B 3 - rc :2, -#define FP_RND_NEAR 0 -#define FP_RND_DOWN 1 -#define FP_RND_UP 2 -#define FP_CHOP 3 - /*inf*/ :1, - :3; -}; -typedef _STRUCT_FP_CONTROL fp_control_t; -#endif /* !__DARWIN_UNIX03 */ - -/* - * Status word. - */ - -#if __DARWIN_UNIX03 -#define _STRUCT_FP_STATUS struct __darwin_fp_status -_STRUCT_FP_STATUS -{ - unsigned short __invalid :1, - __denorm :1, - __zdiv :1, - __ovrfl :1, - __undfl :1, - __precis :1, - __stkflt :1, - __errsumm :1, - __c0 :1, - __c1 :1, - __c2 :1, - __tos :3, - __c3 :1, - __busy :1; -}; -typedef _STRUCT_FP_STATUS __darwin_fp_status_t; -#else /* !__DARWIN_UNIX03 */ -#define _STRUCT_FP_STATUS struct fp_status -_STRUCT_FP_STATUS -{ - unsigned short invalid :1, - denorm :1, - zdiv :1, - ovrfl :1, - undfl :1, - precis :1, - stkflt :1, - errsumm :1, - c0 :1, - c1 :1, - c2 :1, - tos :3, - c3 :1, - busy :1; -}; -typedef _STRUCT_FP_STATUS fp_status_t; -#endif /* !__DARWIN_UNIX03 */ - -/* defn of 80bit x87 FPU or MMX register */ - -#if __DARWIN_UNIX03 -#define _STRUCT_MMST_REG struct __darwin_mmst_reg -_STRUCT_MMST_REG -{ - char __mmst_reg[10]; - char __mmst_rsrv[6]; -}; -#else /* !__DARWIN_UNIX03 */ -#define _STRUCT_MMST_REG struct mmst_reg -_STRUCT_MMST_REG -{ - char mmst_reg[10]; - char mmst_rsrv[6]; -}; -#endif /* !__DARWIN_UNIX03 */ - - -/* defn of 128 bit XMM regs */ - -#if __DARWIN_UNIX03 -#define _STRUCT_XMM_REG struct __darwin_xmm_reg -_STRUCT_XMM_REG -{ - char __xmm_reg[16]; -}; -#else /* !__DARWIN_UNIX03 */ -#define _STRUCT_XMM_REG struct xmm_reg -_STRUCT_XMM_REG -{ - char xmm_reg[16]; -}; -#endif /* !__DARWIN_UNIX03 */ - -/* - * Floating point state. - */ - -#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) -#define FP_STATE_BYTES 512 /* number of chars worth of data from fpu_fcw */ -#endif /* !_POSIX_C_SOURCE || _DARWIN_C_SOURCE */ - -#if __DARWIN_UNIX03 -#define _STRUCT_X86_FLOAT_STATE32 struct __darwin_i386_float_state -_STRUCT_X86_FLOAT_STATE32 -{ - int __fpu_reserved[2]; - _STRUCT_FP_CONTROL __fpu_fcw; /* x87 FPU control word */ - _STRUCT_FP_STATUS __fpu_fsw; /* x87 FPU status word */ - __uint8_t __fpu_ftw; /* x87 FPU tag word */ - __uint8_t __fpu_rsrv1; /* reserved */ - __uint16_t __fpu_fop; /* x87 FPU Opcode */ - __uint32_t __fpu_ip; /* x87 FPU Instruction Pointer offset */ - __uint16_t __fpu_cs; /* x87 FPU Instruction Pointer Selector */ - __uint16_t __fpu_rsrv2; /* reserved */ - __uint32_t __fpu_dp; /* x87 FPU Instruction Operand(Data) Pointer offset */ - __uint16_t __fpu_ds; /* x87 FPU Instruction Operand(Data) Pointer Selector */ - __uint16_t __fpu_rsrv3; /* reserved */ - __uint32_t __fpu_mxcsr; /* MXCSR Register state */ - __uint32_t __fpu_mxcsrmask; /* MXCSR mask */ - _STRUCT_MMST_REG __fpu_stmm0; /* ST0/MM0 */ - _STRUCT_MMST_REG __fpu_stmm1; /* ST1/MM1 */ - _STRUCT_MMST_REG __fpu_stmm2; /* ST2/MM2 */ - _STRUCT_MMST_REG __fpu_stmm3; /* ST3/MM3 */ - _STRUCT_MMST_REG __fpu_stmm4; /* ST4/MM4 */ - _STRUCT_MMST_REG __fpu_stmm5; /* ST5/MM5 */ - _STRUCT_MMST_REG __fpu_stmm6; /* ST6/MM6 */ - _STRUCT_MMST_REG __fpu_stmm7; /* ST7/MM7 */ - _STRUCT_XMM_REG __fpu_xmm0; /* XMM 0 */ - _STRUCT_XMM_REG __fpu_xmm1; /* XMM 1 */ - _STRUCT_XMM_REG __fpu_xmm2; /* XMM 2 */ - _STRUCT_XMM_REG __fpu_xmm3; /* XMM 3 */ - _STRUCT_XMM_REG __fpu_xmm4; /* XMM 4 */ - _STRUCT_XMM_REG __fpu_xmm5; /* XMM 5 */ - _STRUCT_XMM_REG __fpu_xmm6; /* XMM 6 */ - _STRUCT_XMM_REG __fpu_xmm7; /* XMM 7 */ - char __fpu_rsrv4[14*16]; /* reserved */ - int __fpu_reserved1; -}; - -#define _STRUCT_X86_AVX_STATE32 struct __darwin_i386_avx_state -_STRUCT_X86_AVX_STATE32 -{ - int __fpu_reserved[2]; - _STRUCT_FP_CONTROL __fpu_fcw; /* x87 FPU control word */ - _STRUCT_FP_STATUS __fpu_fsw; /* x87 FPU status word */ - __uint8_t __fpu_ftw; /* x87 FPU tag word */ - __uint8_t __fpu_rsrv1; /* reserved */ - __uint16_t __fpu_fop; /* x87 FPU Opcode */ - __uint32_t __fpu_ip; /* x87 FPU Instruction Pointer offset */ - __uint16_t __fpu_cs; /* x87 FPU Instruction Pointer Selector */ - __uint16_t __fpu_rsrv2; /* reserved */ - __uint32_t __fpu_dp; /* x87 FPU Instruction Operand(Data) Pointer offset */ - __uint16_t __fpu_ds; /* x87 FPU Instruction Operand(Data) Pointer Selector */ - __uint16_t __fpu_rsrv3; /* reserved */ - __uint32_t __fpu_mxcsr; /* MXCSR Register state */ - __uint32_t __fpu_mxcsrmask; /* MXCSR mask */ - _STRUCT_MMST_REG __fpu_stmm0; /* ST0/MM0 */ - _STRUCT_MMST_REG __fpu_stmm1; /* ST1/MM1 */ - _STRUCT_MMST_REG __fpu_stmm2; /* ST2/MM2 */ - _STRUCT_MMST_REG __fpu_stmm3; /* ST3/MM3 */ - _STRUCT_MMST_REG __fpu_stmm4; /* ST4/MM4 */ - _STRUCT_MMST_REG __fpu_stmm5; /* ST5/MM5 */ - _STRUCT_MMST_REG __fpu_stmm6; /* ST6/MM6 */ - _STRUCT_MMST_REG __fpu_stmm7; /* ST7/MM7 */ - _STRUCT_XMM_REG __fpu_xmm0; /* XMM 0 */ - _STRUCT_XMM_REG __fpu_xmm1; /* XMM 1 */ - _STRUCT_XMM_REG __fpu_xmm2; /* XMM 2 */ - _STRUCT_XMM_REG __fpu_xmm3; /* XMM 3 */ - _STRUCT_XMM_REG __fpu_xmm4; /* XMM 4 */ - _STRUCT_XMM_REG __fpu_xmm5; /* XMM 5 */ - _STRUCT_XMM_REG __fpu_xmm6; /* XMM 6 */ - _STRUCT_XMM_REG __fpu_xmm7; /* XMM 7 */ - char __fpu_rsrv4[14*16]; /* reserved */ - int __fpu_reserved1; - char __avx_reserved1[64]; - _STRUCT_XMM_REG __fpu_ymmh0; /* YMMH 0 */ - _STRUCT_XMM_REG __fpu_ymmh1; /* YMMH 1 */ - _STRUCT_XMM_REG __fpu_ymmh2; /* YMMH 2 */ - _STRUCT_XMM_REG __fpu_ymmh3; /* YMMH 3 */ - _STRUCT_XMM_REG __fpu_ymmh4; /* YMMH 4 */ - _STRUCT_XMM_REG __fpu_ymmh5; /* YMMH 5 */ - _STRUCT_XMM_REG __fpu_ymmh6; /* YMMH 6 */ - _STRUCT_XMM_REG __fpu_ymmh7; /* YMMH 7 */ -}; - -#else /* !__DARWIN_UNIX03 */ -#define _STRUCT_X86_FLOAT_STATE32 struct i386_float_state -_STRUCT_X86_FLOAT_STATE32 -{ - int fpu_reserved[2]; - _STRUCT_FP_CONTROL fpu_fcw; /* x87 FPU control word */ - _STRUCT_FP_STATUS fpu_fsw; /* x87 FPU status word */ - __uint8_t fpu_ftw; /* x87 FPU tag word */ - __uint8_t fpu_rsrv1; /* reserved */ - __uint16_t fpu_fop; /* x87 FPU Opcode */ - __uint32_t fpu_ip; /* x87 FPU Instruction Pointer offset */ - __uint16_t fpu_cs; /* x87 FPU Instruction Pointer Selector */ - __uint16_t fpu_rsrv2; /* reserved */ - __uint32_t fpu_dp; /* x87 FPU Instruction Operand(Data) Pointer offset */ - __uint16_t fpu_ds; /* x87 FPU Instruction Operand(Data) Pointer Selector */ - __uint16_t fpu_rsrv3; /* reserved */ - __uint32_t fpu_mxcsr; /* MXCSR Register state */ - __uint32_t fpu_mxcsrmask; /* MXCSR mask */ - _STRUCT_MMST_REG fpu_stmm0; /* ST0/MM0 */ - _STRUCT_MMST_REG fpu_stmm1; /* ST1/MM1 */ - _STRUCT_MMST_REG fpu_stmm2; /* ST2/MM2 */ - _STRUCT_MMST_REG fpu_stmm3; /* ST3/MM3 */ - _STRUCT_MMST_REG fpu_stmm4; /* ST4/MM4 */ - _STRUCT_MMST_REG fpu_stmm5; /* ST5/MM5 */ - _STRUCT_MMST_REG fpu_stmm6; /* ST6/MM6 */ - _STRUCT_MMST_REG fpu_stmm7; /* ST7/MM7 */ - _STRUCT_XMM_REG fpu_xmm0; /* XMM 0 */ - _STRUCT_XMM_REG fpu_xmm1; /* XMM 1 */ - _STRUCT_XMM_REG fpu_xmm2; /* XMM 2 */ - _STRUCT_XMM_REG fpu_xmm3; /* XMM 3 */ - _STRUCT_XMM_REG fpu_xmm4; /* XMM 4 */ - _STRUCT_XMM_REG fpu_xmm5; /* XMM 5 */ - _STRUCT_XMM_REG fpu_xmm6; /* XMM 6 */ - _STRUCT_XMM_REG fpu_xmm7; /* XMM 7 */ - char fpu_rsrv4[14*16]; /* reserved */ - int fpu_reserved1; -}; - -#define _STRUCT_X86_AVX_STATE32 struct i386_avx_state -_STRUCT_X86_AVX_STATE32 -{ - int fpu_reserved[2]; - _STRUCT_FP_CONTROL fpu_fcw; /* x87 FPU control word */ - _STRUCT_FP_STATUS fpu_fsw; /* x87 FPU status word */ - __uint8_t fpu_ftw; /* x87 FPU tag word */ - __uint8_t fpu_rsrv1; /* reserved */ - __uint16_t fpu_fop; /* x87 FPU Opcode */ - __uint32_t fpu_ip; /* x87 FPU Instruction Pointer offset */ - __uint16_t fpu_cs; /* x87 FPU Instruction Pointer Selector */ - __uint16_t fpu_rsrv2; /* reserved */ - __uint32_t fpu_dp; /* x87 FPU Instruction Operand(Data) Pointer offset */ - __uint16_t fpu_ds; /* x87 FPU Instruction Operand(Data) Pointer Selector */ - __uint16_t fpu_rsrv3; /* reserved */ - __uint32_t fpu_mxcsr; /* MXCSR Register state */ - __uint32_t fpu_mxcsrmask; /* MXCSR mask */ - _STRUCT_MMST_REG fpu_stmm0; /* ST0/MM0 */ - _STRUCT_MMST_REG fpu_stmm1; /* ST1/MM1 */ - _STRUCT_MMST_REG fpu_stmm2; /* ST2/MM2 */ - _STRUCT_MMST_REG fpu_stmm3; /* ST3/MM3 */ - _STRUCT_MMST_REG fpu_stmm4; /* ST4/MM4 */ - _STRUCT_MMST_REG fpu_stmm5; /* ST5/MM5 */ - _STRUCT_MMST_REG fpu_stmm6; /* ST6/MM6 */ - _STRUCT_MMST_REG fpu_stmm7; /* ST7/MM7 */ - _STRUCT_XMM_REG fpu_xmm0; /* XMM 0 */ - _STRUCT_XMM_REG fpu_xmm1; /* XMM 1 */ - _STRUCT_XMM_REG fpu_xmm2; /* XMM 2 */ - _STRUCT_XMM_REG fpu_xmm3; /* XMM 3 */ - _STRUCT_XMM_REG fpu_xmm4; /* XMM 4 */ - _STRUCT_XMM_REG fpu_xmm5; /* XMM 5 */ - _STRUCT_XMM_REG fpu_xmm6; /* XMM 6 */ - _STRUCT_XMM_REG fpu_xmm7; /* XMM 7 */ - char fpu_rsrv4[14*16]; /* reserved */ - int fpu_reserved1; - char __avx_reserved1[64]; - _STRUCT_XMM_REG __fpu_ymmh0; /* YMMH 0 */ - _STRUCT_XMM_REG __fpu_ymmh1; /* YMMH 1 */ - _STRUCT_XMM_REG __fpu_ymmh2; /* YMMH 2 */ - _STRUCT_XMM_REG __fpu_ymmh3; /* YMMH 3 */ - _STRUCT_XMM_REG __fpu_ymmh4; /* YMMH 4 */ - _STRUCT_XMM_REG __fpu_ymmh5; /* YMMH 5 */ - _STRUCT_XMM_REG __fpu_ymmh6; /* YMMH 6 */ - _STRUCT_XMM_REG __fpu_ymmh7; /* YMMH 7 */ -}; - -#endif /* !__DARWIN_UNIX03 */ - -#if __DARWIN_UNIX03 -#define _STRUCT_X86_EXCEPTION_STATE32 struct __darwin_i386_exception_state -_STRUCT_X86_EXCEPTION_STATE32 -{ - __uint16_t __trapno; - __uint16_t __cpu; - __uint32_t __err; - __uint32_t __faultvaddr; -}; -#else /* !__DARWIN_UNIX03 */ -#define _STRUCT_X86_EXCEPTION_STATE32 struct i386_exception_state -_STRUCT_X86_EXCEPTION_STATE32 -{ - __uint16_t trapno; - __uint16_t cpu; - __uint32_t err; - __uint32_t faultvaddr; -}; -#endif /* !__DARWIN_UNIX03 */ - -#if __DARWIN_UNIX03 -#define _STRUCT_X86_DEBUG_STATE32 struct __darwin_x86_debug_state32 -_STRUCT_X86_DEBUG_STATE32 -{ - unsigned int __dr0; - unsigned int __dr1; - unsigned int __dr2; - unsigned int __dr3; - unsigned int __dr4; - unsigned int __dr5; - unsigned int __dr6; - unsigned int __dr7; -}; -#else /* !__DARWIN_UNIX03 */ -#define _STRUCT_X86_DEBUG_STATE32 struct x86_debug_state32 -_STRUCT_X86_DEBUG_STATE32 -{ - unsigned int dr0; - unsigned int dr1; - unsigned int dr2; - unsigned int dr3; - unsigned int dr4; - unsigned int dr5; - unsigned int dr6; - unsigned int dr7; -}; -#endif /* !__DARWIN_UNIX03 */ - -/* - * 64 bit versions of the above - */ - -#if __DARWIN_UNIX03 -#define _STRUCT_X86_THREAD_STATE64 struct __darwin_x86_thread_state64 -_STRUCT_X86_THREAD_STATE64 -{ - __uint64_t __rax; - __uint64_t __rbx; - __uint64_t __rcx; - __uint64_t __rdx; - __uint64_t __rdi; - __uint64_t __rsi; - __uint64_t __rbp; - __uint64_t __rsp; - __uint64_t __r8; - __uint64_t __r9; - __uint64_t __r10; - __uint64_t __r11; - __uint64_t __r12; - __uint64_t __r13; - __uint64_t __r14; - __uint64_t __r15; - __uint64_t __rip; - __uint64_t __rflags; - __uint64_t __cs; - __uint64_t __fs; - __uint64_t __gs; -}; -#else /* !__DARWIN_UNIX03 */ -#define _STRUCT_X86_THREAD_STATE64 struct x86_thread_state64 -_STRUCT_X86_THREAD_STATE64 -{ - __uint64_t rax; - __uint64_t rbx; - __uint64_t rcx; - __uint64_t rdx; - __uint64_t rdi; - __uint64_t rsi; - __uint64_t rbp; - __uint64_t rsp; - __uint64_t r8; - __uint64_t r9; - __uint64_t r10; - __uint64_t r11; - __uint64_t r12; - __uint64_t r13; - __uint64_t r14; - __uint64_t r15; - __uint64_t rip; - __uint64_t rflags; - __uint64_t cs; - __uint64_t fs; - __uint64_t gs; -}; -#endif /* !__DARWIN_UNIX03 */ - - -#if __DARWIN_UNIX03 -#define _STRUCT_X86_FLOAT_STATE64 struct __darwin_x86_float_state64 -_STRUCT_X86_FLOAT_STATE64 -{ - int __fpu_reserved[2]; - _STRUCT_FP_CONTROL __fpu_fcw; /* x87 FPU control word */ - _STRUCT_FP_STATUS __fpu_fsw; /* x87 FPU status word */ - __uint8_t __fpu_ftw; /* x87 FPU tag word */ - __uint8_t __fpu_rsrv1; /* reserved */ - __uint16_t __fpu_fop; /* x87 FPU Opcode */ - - /* x87 FPU Instruction Pointer */ - __uint32_t __fpu_ip; /* offset */ - __uint16_t __fpu_cs; /* Selector */ - - __uint16_t __fpu_rsrv2; /* reserved */ - - /* x87 FPU Instruction Operand(Data) Pointer */ - __uint32_t __fpu_dp; /* offset */ - __uint16_t __fpu_ds; /* Selector */ - - __uint16_t __fpu_rsrv3; /* reserved */ - __uint32_t __fpu_mxcsr; /* MXCSR Register state */ - __uint32_t __fpu_mxcsrmask; /* MXCSR mask */ - _STRUCT_MMST_REG __fpu_stmm0; /* ST0/MM0 */ - _STRUCT_MMST_REG __fpu_stmm1; /* ST1/MM1 */ - _STRUCT_MMST_REG __fpu_stmm2; /* ST2/MM2 */ - _STRUCT_MMST_REG __fpu_stmm3; /* ST3/MM3 */ - _STRUCT_MMST_REG __fpu_stmm4; /* ST4/MM4 */ - _STRUCT_MMST_REG __fpu_stmm5; /* ST5/MM5 */ - _STRUCT_MMST_REG __fpu_stmm6; /* ST6/MM6 */ - _STRUCT_MMST_REG __fpu_stmm7; /* ST7/MM7 */ - _STRUCT_XMM_REG __fpu_xmm0; /* XMM 0 */ - _STRUCT_XMM_REG __fpu_xmm1; /* XMM 1 */ - _STRUCT_XMM_REG __fpu_xmm2; /* XMM 2 */ - _STRUCT_XMM_REG __fpu_xmm3; /* XMM 3 */ - _STRUCT_XMM_REG __fpu_xmm4; /* XMM 4 */ - _STRUCT_XMM_REG __fpu_xmm5; /* XMM 5 */ - _STRUCT_XMM_REG __fpu_xmm6; /* XMM 6 */ - _STRUCT_XMM_REG __fpu_xmm7; /* XMM 7 */ - _STRUCT_XMM_REG __fpu_xmm8; /* XMM 8 */ - _STRUCT_XMM_REG __fpu_xmm9; /* XMM 9 */ - _STRUCT_XMM_REG __fpu_xmm10; /* XMM 10 */ - _STRUCT_XMM_REG __fpu_xmm11; /* XMM 11 */ - _STRUCT_XMM_REG __fpu_xmm12; /* XMM 12 */ - _STRUCT_XMM_REG __fpu_xmm13; /* XMM 13 */ - _STRUCT_XMM_REG __fpu_xmm14; /* XMM 14 */ - _STRUCT_XMM_REG __fpu_xmm15; /* XMM 15 */ - char __fpu_rsrv4[6*16]; /* reserved */ - int __fpu_reserved1; -}; - -#define _STRUCT_X86_AVX_STATE64 struct __darwin_x86_avx_state64 -_STRUCT_X86_AVX_STATE64 -{ - int __fpu_reserved[2]; - _STRUCT_FP_CONTROL __fpu_fcw; /* x87 FPU control word */ - _STRUCT_FP_STATUS __fpu_fsw; /* x87 FPU status word */ - __uint8_t __fpu_ftw; /* x87 FPU tag word */ - __uint8_t __fpu_rsrv1; /* reserved */ - __uint16_t __fpu_fop; /* x87 FPU Opcode */ - - /* x87 FPU Instruction Pointer */ - __uint32_t __fpu_ip; /* offset */ - __uint16_t __fpu_cs; /* Selector */ - - __uint16_t __fpu_rsrv2; /* reserved */ - - /* x87 FPU Instruction Operand(Data) Pointer */ - __uint32_t __fpu_dp; /* offset */ - __uint16_t __fpu_ds; /* Selector */ - - __uint16_t __fpu_rsrv3; /* reserved */ - __uint32_t __fpu_mxcsr; /* MXCSR Register state */ - __uint32_t __fpu_mxcsrmask; /* MXCSR mask */ - _STRUCT_MMST_REG __fpu_stmm0; /* ST0/MM0 */ - _STRUCT_MMST_REG __fpu_stmm1; /* ST1/MM1 */ - _STRUCT_MMST_REG __fpu_stmm2; /* ST2/MM2 */ - _STRUCT_MMST_REG __fpu_stmm3; /* ST3/MM3 */ - _STRUCT_MMST_REG __fpu_stmm4; /* ST4/MM4 */ - _STRUCT_MMST_REG __fpu_stmm5; /* ST5/MM5 */ - _STRUCT_MMST_REG __fpu_stmm6; /* ST6/MM6 */ - _STRUCT_MMST_REG __fpu_stmm7; /* ST7/MM7 */ - _STRUCT_XMM_REG __fpu_xmm0; /* XMM 0 */ - _STRUCT_XMM_REG __fpu_xmm1; /* XMM 1 */ - _STRUCT_XMM_REG __fpu_xmm2; /* XMM 2 */ - _STRUCT_XMM_REG __fpu_xmm3; /* XMM 3 */ - _STRUCT_XMM_REG __fpu_xmm4; /* XMM 4 */ - _STRUCT_XMM_REG __fpu_xmm5; /* XMM 5 */ - _STRUCT_XMM_REG __fpu_xmm6; /* XMM 6 */ - _STRUCT_XMM_REG __fpu_xmm7; /* XMM 7 */ - _STRUCT_XMM_REG __fpu_xmm8; /* XMM 8 */ - _STRUCT_XMM_REG __fpu_xmm9; /* XMM 9 */ - _STRUCT_XMM_REG __fpu_xmm10; /* XMM 10 */ - _STRUCT_XMM_REG __fpu_xmm11; /* XMM 11 */ - _STRUCT_XMM_REG __fpu_xmm12; /* XMM 12 */ - _STRUCT_XMM_REG __fpu_xmm13; /* XMM 13 */ - _STRUCT_XMM_REG __fpu_xmm14; /* XMM 14 */ - _STRUCT_XMM_REG __fpu_xmm15; /* XMM 15 */ - char __fpu_rsrv4[6*16]; /* reserved */ - int __fpu_reserved1; - char __avx_reserved1[64]; - _STRUCT_XMM_REG __fpu_ymmh0; /* YMMH 0 */ - _STRUCT_XMM_REG __fpu_ymmh1; /* YMMH 1 */ - _STRUCT_XMM_REG __fpu_ymmh2; /* YMMH 2 */ - _STRUCT_XMM_REG __fpu_ymmh3; /* YMMH 3 */ - _STRUCT_XMM_REG __fpu_ymmh4; /* YMMH 4 */ - _STRUCT_XMM_REG __fpu_ymmh5; /* YMMH 5 */ - _STRUCT_XMM_REG __fpu_ymmh6; /* YMMH 6 */ - _STRUCT_XMM_REG __fpu_ymmh7; /* YMMH 7 */ - _STRUCT_XMM_REG __fpu_ymmh8; /* YMMH 8 */ - _STRUCT_XMM_REG __fpu_ymmh9; /* YMMH 9 */ - _STRUCT_XMM_REG __fpu_ymmh10; /* YMMH 10 */ - _STRUCT_XMM_REG __fpu_ymmh11; /* YMMH 11 */ - _STRUCT_XMM_REG __fpu_ymmh12; /* YMMH 12 */ - _STRUCT_XMM_REG __fpu_ymmh13; /* YMMH 13 */ - _STRUCT_XMM_REG __fpu_ymmh14; /* YMMH 14 */ - _STRUCT_XMM_REG __fpu_ymmh15; /* YMMH 15 */ -}; - -#else /* !__DARWIN_UNIX03 */ -#define _STRUCT_X86_FLOAT_STATE64 struct x86_float_state64 -_STRUCT_X86_FLOAT_STATE64 -{ - int fpu_reserved[2]; - _STRUCT_FP_CONTROL fpu_fcw; /* x87 FPU control word */ - _STRUCT_FP_STATUS fpu_fsw; /* x87 FPU status word */ - __uint8_t fpu_ftw; /* x87 FPU tag word */ - __uint8_t fpu_rsrv1; /* reserved */ - __uint16_t fpu_fop; /* x87 FPU Opcode */ - - /* x87 FPU Instruction Pointer */ - __uint32_t fpu_ip; /* offset */ - __uint16_t fpu_cs; /* Selector */ - - __uint16_t fpu_rsrv2; /* reserved */ - - /* x87 FPU Instruction Operand(Data) Pointer */ - __uint32_t fpu_dp; /* offset */ - __uint16_t fpu_ds; /* Selector */ - - __uint16_t fpu_rsrv3; /* reserved */ - __uint32_t fpu_mxcsr; /* MXCSR Register state */ - __uint32_t fpu_mxcsrmask; /* MXCSR mask */ - _STRUCT_MMST_REG fpu_stmm0; /* ST0/MM0 */ - _STRUCT_MMST_REG fpu_stmm1; /* ST1/MM1 */ - _STRUCT_MMST_REG fpu_stmm2; /* ST2/MM2 */ - _STRUCT_MMST_REG fpu_stmm3; /* ST3/MM3 */ - _STRUCT_MMST_REG fpu_stmm4; /* ST4/MM4 */ - _STRUCT_MMST_REG fpu_stmm5; /* ST5/MM5 */ - _STRUCT_MMST_REG fpu_stmm6; /* ST6/MM6 */ - _STRUCT_MMST_REG fpu_stmm7; /* ST7/MM7 */ - _STRUCT_XMM_REG fpu_xmm0; /* XMM 0 */ - _STRUCT_XMM_REG fpu_xmm1; /* XMM 1 */ - _STRUCT_XMM_REG fpu_xmm2; /* XMM 2 */ - _STRUCT_XMM_REG fpu_xmm3; /* XMM 3 */ - _STRUCT_XMM_REG fpu_xmm4; /* XMM 4 */ - _STRUCT_XMM_REG fpu_xmm5; /* XMM 5 */ - _STRUCT_XMM_REG fpu_xmm6; /* XMM 6 */ - _STRUCT_XMM_REG fpu_xmm7; /* XMM 7 */ - _STRUCT_XMM_REG fpu_xmm8; /* XMM 8 */ - _STRUCT_XMM_REG fpu_xmm9; /* XMM 9 */ - _STRUCT_XMM_REG fpu_xmm10; /* XMM 10 */ - _STRUCT_XMM_REG fpu_xmm11; /* XMM 11 */ - _STRUCT_XMM_REG fpu_xmm12; /* XMM 12 */ - _STRUCT_XMM_REG fpu_xmm13; /* XMM 13 */ - _STRUCT_XMM_REG fpu_xmm14; /* XMM 14 */ - _STRUCT_XMM_REG fpu_xmm15; /* XMM 15 */ - char fpu_rsrv4[6*16]; /* reserved */ - int fpu_reserved1; -}; - -#define _STRUCT_X86_AVX_STATE64 struct x86_avx_state64 -_STRUCT_X86_AVX_STATE64 -{ - int fpu_reserved[2]; - _STRUCT_FP_CONTROL fpu_fcw; /* x87 FPU control word */ - _STRUCT_FP_STATUS fpu_fsw; /* x87 FPU status word */ - __uint8_t fpu_ftw; /* x87 FPU tag word */ - __uint8_t fpu_rsrv1; /* reserved */ - __uint16_t fpu_fop; /* x87 FPU Opcode */ - - /* x87 FPU Instruction Pointer */ - __uint32_t fpu_ip; /* offset */ - __uint16_t fpu_cs; /* Selector */ - - __uint16_t fpu_rsrv2; /* reserved */ - - /* x87 FPU Instruction Operand(Data) Pointer */ - __uint32_t fpu_dp; /* offset */ - __uint16_t fpu_ds; /* Selector */ - - __uint16_t fpu_rsrv3; /* reserved */ - __uint32_t fpu_mxcsr; /* MXCSR Register state */ - __uint32_t fpu_mxcsrmask; /* MXCSR mask */ - _STRUCT_MMST_REG fpu_stmm0; /* ST0/MM0 */ - _STRUCT_MMST_REG fpu_stmm1; /* ST1/MM1 */ - _STRUCT_MMST_REG fpu_stmm2; /* ST2/MM2 */ - _STRUCT_MMST_REG fpu_stmm3; /* ST3/MM3 */ - _STRUCT_MMST_REG fpu_stmm4; /* ST4/MM4 */ - _STRUCT_MMST_REG fpu_stmm5; /* ST5/MM5 */ - _STRUCT_MMST_REG fpu_stmm6; /* ST6/MM6 */ - _STRUCT_MMST_REG fpu_stmm7; /* ST7/MM7 */ - _STRUCT_XMM_REG fpu_xmm0; /* XMM 0 */ - _STRUCT_XMM_REG fpu_xmm1; /* XMM 1 */ - _STRUCT_XMM_REG fpu_xmm2; /* XMM 2 */ - _STRUCT_XMM_REG fpu_xmm3; /* XMM 3 */ - _STRUCT_XMM_REG fpu_xmm4; /* XMM 4 */ - _STRUCT_XMM_REG fpu_xmm5; /* XMM 5 */ - _STRUCT_XMM_REG fpu_xmm6; /* XMM 6 */ - _STRUCT_XMM_REG fpu_xmm7; /* XMM 7 */ - _STRUCT_XMM_REG fpu_xmm8; /* XMM 8 */ - _STRUCT_XMM_REG fpu_xmm9; /* XMM 9 */ - _STRUCT_XMM_REG fpu_xmm10; /* XMM 10 */ - _STRUCT_XMM_REG fpu_xmm11; /* XMM 11 */ - _STRUCT_XMM_REG fpu_xmm12; /* XMM 12 */ - _STRUCT_XMM_REG fpu_xmm13; /* XMM 13 */ - _STRUCT_XMM_REG fpu_xmm14; /* XMM 14 */ - _STRUCT_XMM_REG fpu_xmm15; /* XMM 15 */ - char fpu_rsrv4[6*16]; /* reserved */ - int fpu_reserved1; - char __avx_reserved1[64]; - _STRUCT_XMM_REG __fpu_ymmh0; /* YMMH 0 */ - _STRUCT_XMM_REG __fpu_ymmh1; /* YMMH 1 */ - _STRUCT_XMM_REG __fpu_ymmh2; /* YMMH 2 */ - _STRUCT_XMM_REG __fpu_ymmh3; /* YMMH 3 */ - _STRUCT_XMM_REG __fpu_ymmh4; /* YMMH 4 */ - _STRUCT_XMM_REG __fpu_ymmh5; /* YMMH 5 */ - _STRUCT_XMM_REG __fpu_ymmh6; /* YMMH 6 */ - _STRUCT_XMM_REG __fpu_ymmh7; /* YMMH 7 */ - _STRUCT_XMM_REG __fpu_ymmh8; /* YMMH 8 */ - _STRUCT_XMM_REG __fpu_ymmh9; /* YMMH 9 */ - _STRUCT_XMM_REG __fpu_ymmh10; /* YMMH 10 */ - _STRUCT_XMM_REG __fpu_ymmh11; /* YMMH 11 */ - _STRUCT_XMM_REG __fpu_ymmh12; /* YMMH 12 */ - _STRUCT_XMM_REG __fpu_ymmh13; /* YMMH 13 */ - _STRUCT_XMM_REG __fpu_ymmh14; /* YMMH 14 */ - _STRUCT_XMM_REG __fpu_ymmh15; /* YMMH 15 */ -}; - -#endif /* !__DARWIN_UNIX03 */ - -#if __DARWIN_UNIX03 -#define _STRUCT_X86_EXCEPTION_STATE64 struct __darwin_x86_exception_state64 -_STRUCT_X86_EXCEPTION_STATE64 -{ - __uint16_t __trapno; - __uint16_t __cpu; - __uint32_t __err; - __uint64_t __faultvaddr; -}; -#else /* !__DARWIN_UNIX03 */ -#define _STRUCT_X86_EXCEPTION_STATE64 struct x86_exception_state64 -_STRUCT_X86_EXCEPTION_STATE64 -{ - __uint16_t trapno; - __uint16_t cpu; - __uint32_t err; - __uint64_t faultvaddr; -}; -#endif /* !__DARWIN_UNIX03 */ - -#if __DARWIN_UNIX03 -#define _STRUCT_X86_DEBUG_STATE64 struct __darwin_x86_debug_state64 -_STRUCT_X86_DEBUG_STATE64 -{ - __uint64_t __dr0; - __uint64_t __dr1; - __uint64_t __dr2; - __uint64_t __dr3; - __uint64_t __dr4; - __uint64_t __dr5; - __uint64_t __dr6; - __uint64_t __dr7; -}; -#else /* !__DARWIN_UNIX03 */ -#define _STRUCT_X86_DEBUG_STATE64 struct x86_debug_state64 -_STRUCT_X86_DEBUG_STATE64 -{ - __uint64_t dr0; - __uint64_t dr1; - __uint64_t dr2; - __uint64_t dr3; - __uint64_t dr4; - __uint64_t dr5; - __uint64_t dr6; - __uint64_t dr7; -}; -#endif /* !__DARWIN_UNIX03 */ - -#endif /* _MACH_I386__STRUCTS_H_ */ diff --git a/include/xnu/mach/i386/boolean.h b/include/xnu/mach/i386/boolean.h deleted file mode 100644 index 100f7e7b5..000000000 --- a/include/xnu/mach/i386/boolean.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2000-2006 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@ - */ -/* - * @OSF_COPYRIGHT@ - */ -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989 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 Software.Distribution@CS.CMU.EDU - * 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: boolean.h - * - * Boolean type, for I386. - */ - -#ifndef _MACH_I386_BOOLEAN_H_ -#define _MACH_I386_BOOLEAN_H_ - -#if defined(__x86_64__) && !defined(KERNEL) -typedef unsigned int boolean_t; -#else -typedef int boolean_t; -#endif - -#endif /* _MACH_I386_BOOLEAN_H_ */ diff --git a/include/xnu/mach/i386/exception.h b/include/xnu/mach/i386/exception.h deleted file mode 100644 index a9b4fbf04..000000000 --- a/include/xnu/mach/i386/exception.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * 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@ - */ -/* - * @OSF_COPYRIGHT@ - */ -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989,1988 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 Software.Distribution@CS.CMU.EDU - * 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. - */ -/* - */ - -#ifndef _MACH_I386_EXCEPTION_H_ -#define _MACH_I386_EXCEPTION_H_ - -/* - * No machine dependent types for the 80386 - */ - -#define EXC_TYPES_COUNT 12 /* incl. illegal exception 0 */ - -/* - * Codes and subcodes for 80386 exceptions. - */ - -#define EXCEPTION_CODE_MAX 2 /* currently code and subcode */ - -/* - * EXC_BAD_INSTRUCTION - */ - -#define EXC_I386_INVOP 1 - -/* - * EXC_ARITHMETIC - */ - -#define EXC_I386_DIV 1 -#define EXC_I386_INTO 2 -#define EXC_I386_NOEXT 3 -#define EXC_I386_EXTOVR 4 -#define EXC_I386_EXTERR 5 -#define EXC_I386_EMERR 6 -#define EXC_I386_BOUND 7 -#define EXC_I386_SSEEXTERR 8 - -/* - * EXC_SOFTWARE - * Note: 0x10000-0x10003 in use for unix signal - */ - -/* - * EXC_BAD_ACCESS - */ - -/* - * EXC_BREAKPOINT - */ - -#define EXC_I386_SGL 1 -#define EXC_I386_BPT 2 - -#define EXC_I386_DIVERR 0 /* divide by 0 eprror */ -#define EXC_I386_SGLSTP 1 /* single step */ -#define EXC_I386_NMIFLT 2 /* NMI */ -#define EXC_I386_BPTFLT 3 /* breakpoint fault */ -#define EXC_I386_INTOFLT 4 /* INTO overflow fault */ -#define EXC_I386_BOUNDFLT 5 /* BOUND instruction fault */ -#define EXC_I386_INVOPFLT 6 /* invalid opcode fault */ -#define EXC_I386_NOEXTFLT 7 /* extension not available fault*/ -#define EXC_I386_DBLFLT 8 /* double fault */ -#define EXC_I386_EXTOVRFLT 9 /* extension overrun fault */ -#define EXC_I386_INVTSSFLT 10 /* invalid TSS fault */ -#define EXC_I386_SEGNPFLT 11 /* segment not present fault */ -#define EXC_I386_STKFLT 12 /* stack fault */ -#define EXC_I386_GPFLT 13 /* general protection fault */ -#define EXC_I386_PGFLT 14 /* page fault */ -#define EXC_I386_EXTERRFLT 16 /* extension error fault */ -#define EXC_I386_ALIGNFLT 17 /* Alignment fault */ -#define EXC_I386_ENDPERR 33 /* emulated extension error flt */ -#define EXC_I386_ENOEXTFLT 32 /* emulated ext not present */ - - -/* - * machine dependent exception masks - */ -#define EXC_MASK_MACHINE 0 - -#endif /* _MACH_I386_EXCEPTION_H_ */ diff --git a/include/xnu/mach/i386/flipc_dep.h b/include/xnu/mach/i386/flipc_dep.h deleted file mode 100644 index e04a83aaa..000000000 --- a/include/xnu/mach/i386/flipc_dep.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * 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@ - */ -/* - * @OSF_COPYRIGHT@ - * - */ - -/* - * mach/i386/flipc_dep.h - * - * This file will have all of the FLIPC implementation machine dependent - * defines that need to be visible to both kernel and AIL (eg. bus locks - * and bus synchronization primitives). - */ - -#ifndef _MACH_FLIPC_DEP_H_ -#define _MACH_FLIPC_DEP_H_ - -/* For the 386, we don't need to wrap synchronization variable writes - at all. */ -#define SYNCVAR_WRITE(statement) statement - -/* And similarly (I believe; check on this), for the 386 there isn't any - requirement for write fences. */ -#define WRITE_FENCE() - -/* - * Flipc simple lock defines. These are almost completely for the use - * of the AIL; the reason they are in this file is that they need to - * be initialized properly in the communications buffer initialization - * routine. Sigh. Note in particular that the kernel has no defined - * "simple_lock_yield_function", so it had better never expand the - * macro simple_lock_acquire. - * - * These locks may be declared by "flipc_simple_lock lock;". If they - * are instead declared by FLIPC_DECL_SIMPLE_LOCK(class,lockname) they - * may be used without initialization. - */ - -#define SIMPLE_LOCK_INITIALIZER 0 -#define FLIPC_DECL_SIMPLE_LOCK(class,lockname) \ -class flipc_simple_lock (lockname) = SIMPLE_LOCK_INITIALIZER - -/* - * Lower case because they may be macros or functions. - * I'll include the function prototypes just for examples here. - */ - -#define flipc_simple_lock_init(lock) \ -do { \ - *(lock) = SIMPLE_LOCK_INITIALIZER; \ -} while (0) - -/* - * Defines of the actual routines, for gcc. - */ - -#define flipc_simple_lock_locked(lock) ((*lock) != SIMPLE_LOCK_INITIALIZER) - -#ifdef __GNUC__ - extern __inline__ int flipc_simple_lock_try(flipc_simple_lock *lock) -{ - int r; - __asm__ volatile("movl $1, %0; xchgl %0, %1" : "=&r" (r), "=m" (*lock)); - return !r; -} - -/* I don't know why this requires an ASM, but I'll follow the leader. */ -extern __inline__ void flipc_simple_lock_release(flipc_simple_lock *lock) -{ - register int t; - - __asm__ volatile("xorl %0, %0; xchgl %0, %1" : "=&r" (t), "=m" (*lock)); -} -#else /* __GNUC__ */ -/* If we aren't compiling with gcc, the above need to be functions. */ -#endif /* __GNUC__ */ - -#endif /* _MACH_FLIPC_DEP_H_ */ diff --git a/include/xnu/mach/i386/fp_reg.h b/include/xnu/mach/i386/fp_reg.h deleted file mode 100644 index 92d504f3f..000000000 --- a/include/xnu/mach/i386/fp_reg.h +++ /dev/null @@ -1,177 +0,0 @@ -/* - * 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@ - */ -/* - * @OSF_COPYRIGHT@ - */ -/* - * Mach Operating System - * Copyright (c) 1992-1989 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 Software.Distribution@CS.CMU.EDU - * 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. - */ -/* - */ - -#ifndef _I386_FP_SAVE_H_ -#define _I386_FP_SAVE_H_ - -#ifdef MACH_KERNEL_PRIVATE - - -struct x86_fx_thread_state { - unsigned short fx_control; /* control */ - unsigned short fx_status; /* status */ - unsigned char fx_tag; /* register tags */ - unsigned char fx_bbz1; /* better be zero when calling fxrtstor */ - unsigned short fx_opcode; - unsigned int fx_eip; /* eip instruction */ - unsigned short fx_cs; /* cs instruction */ - unsigned short fx_bbz2; /* better be zero when calling fxrtstor */ - unsigned int fx_dp; /* data address */ - unsigned short fx_ds; /* data segment */ - unsigned short fx_bbz3; /* better be zero when calling fxrtstor */ - unsigned int fx_MXCSR; - unsigned int fx_MXCSR_MASK; - unsigned short fx_reg_word[8][8]; /* STx/MMx registers */ - unsigned short fx_XMM_reg[8][16]; /* XMM0-XMM15 on 64 bit processors */ - /* XMM0-XMM7 on 32 bit processors... unused storage reserved */ - - unsigned char fx_reserved[16*5]; /* reserved by intel for future - * expansion */ - unsigned int fp_valid; - unsigned int fp_save_layout; - unsigned char fx_pad[8]; -}__attribute__ ((packed)); - -struct x86_avx_thread_state { - unsigned short fx_control; /* control */ - unsigned short fx_status; /* status */ - unsigned char fx_tag; /* register tags */ - unsigned char fx_bbz1; /* reserved zero */ - unsigned short fx_opcode; - unsigned int fx_eip; /* eip instruction */ - unsigned short fx_cs; /* cs instruction */ - unsigned short fx_bbz2; /* reserved zero */ - unsigned int fx_dp; /* data address */ - unsigned short fx_ds; /* data segment */ - unsigned short fx_bbz3; /* reserved zero */ - unsigned int fx_MXCSR; - unsigned int fx_MXCSR_MASK; - unsigned short fx_reg_word[8][8]; /* STx/MMx registers */ - unsigned short fx_XMM_reg[8][16]; /* XMM0-XMM15 on 64 bit processors */ - /* XMM0-XMM7 on 32 bit processors... unused storage reserved */ - unsigned char fx_reserved[16*5]; /* reserved */ - unsigned int fp_valid; - unsigned int fp_save_layout; - unsigned char fx_pad[8]; - - struct xsave_header { /* Offset 512, xsave header */ - uint64_t xsbv; - char xhrsvd[56]; - }_xh; - - unsigned int x_YMMH_reg[4][16]; /* Offset 576, high YMMs*/ -}__attribute__ ((packed)); - -#endif /* MACH_KERNEL_PRIVATE */ -/* - * Control register - */ -#define FPC_IE 0x0001 /* enable invalid operation - exception */ -#define FPC_IM FPC_IE -#define FPC_DE 0x0002 /* enable denormalized operation - exception */ -#define FPC_DM FPC_DE -#define FPC_ZE 0x0004 /* enable zero-divide exception */ -#define FPC_ZM FPC_ZE -#define FPC_OE 0x0008 /* enable overflow exception */ -#define FPC_OM FPC_OE -#define FPC_UE 0x0010 /* enable underflow exception */ -#define FPC_PE 0x0020 /* enable precision exception */ -#define FPC_PC 0x0300 /* precision control: */ -#define FPC_PC_24 0x0000 /* 24 bits */ -#define FPC_PC_53 0x0200 /* 53 bits */ -#define FPC_PC_64 0x0300 /* 64 bits */ -#define FPC_RC 0x0c00 /* rounding control: */ -#define FPC_RC_RN 0x0000 /* round to nearest or even */ -#define FPC_RC_RD 0x0400 /* round down */ -#define FPC_RC_RU 0x0800 /* round up */ -#define FPC_RC_CHOP 0x0c00 /* chop */ -#define FPC_IC 0x1000 /* infinity control (obsolete) */ -#define FPC_IC_PROJ 0x0000 /* projective infinity */ -#define FPC_IC_AFF 0x1000 /* affine infinity (std) */ - -/* - * Status register - */ -#define FPS_IE 0x0001 /* invalid operation */ -#define FPS_DE 0x0002 /* denormalized operand */ -#define FPS_ZE 0x0004 /* divide by zero */ -#define FPS_OE 0x0008 /* overflow */ -#define FPS_UE 0x0010 /* underflow */ -#define FPS_PE 0x0020 /* precision */ -#define FPS_SF 0x0040 /* stack flag */ -#define FPS_ES 0x0080 /* error summary */ -#define FPS_C0 0x0100 /* condition code bit 0 */ -#define FPS_C1 0x0200 /* condition code bit 1 */ -#define FPS_C2 0x0400 /* condition code bit 2 */ -#define FPS_TOS 0x3800 /* top-of-stack pointer */ -#define FPS_TOS_SHIFT 11 -#define FPS_C3 0x4000 /* condition code bit 3 */ -#define FPS_BUSY 0x8000 /* FPU busy */ - -/* - * Kind of floating-point support provided by kernel. - */ -#define FP_NO 0 /* no floating point */ -#define FP_SOFT 1 /* software FP emulator */ -#define FP_287 2 /* 80287 */ -#define FP_387 3 /* 80387 or 80486 */ -#define FP_FXSR 4 /* Fast save/restore SIMD Extension */ - -#endif /* _I386_FP_SAVE_H_ */ diff --git a/include/xnu/mach/i386/kern_return.h b/include/xnu/mach/i386/kern_return.h deleted file mode 100644 index a9df708de..000000000 --- a/include/xnu/mach/i386/kern_return.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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@ - */ -/* - * @OSF_COPYRIGHT@ - */ -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989 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 Software.Distribution@CS.CMU.EDU - * 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: kern_return.h - * Author: Avadis Tevanian, Jr., Michael Wayne Young - * Date: 1985 - * - * Machine-dependent kernel return definitions. - */ - -#ifndef _MACH_I386_KERN_RETURN_H_ -#define _MACH_I386_KERN_RETURN_H_ - -#ifndef ASSEMBLER -typedef int kern_return_t; -#endif /* ASSEMBLER */ - -#endif /* _MACH_I386_KERN_RETURN_H_ */ diff --git a/include/xnu/mach/i386/ndr_def.h b/include/xnu/mach/i386/ndr_def.h deleted file mode 100644 index 5163f639c..000000000 --- a/include/xnu/mach/i386/ndr_def.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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@ - */ -/* - * @OSF_COPYRIGHT@ - */ - -/* NDR record for Intel x86s */ - -#include - -NDR_record_t NDR_record = { - 0, /* mig_reserved */ - 0, /* mig_reserved */ - 0, /* mig_reserved */ - NDR_PROTOCOL_2_0, - NDR_INT_LITTLE_ENDIAN, - NDR_CHAR_ASCII, - NDR_FLOAT_IEEE, - 0, -}; diff --git a/include/xnu/mach/i386/processor_info.h b/include/xnu/mach/i386/processor_info.h deleted file mode 100644 index 8272c6d82..000000000 --- a/include/xnu/mach/i386/processor_info.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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@ - */ -/* - * File: mach/i386/processor_info.h - * - * Data structure definitions for i386 specific processor control - */ - -#ifndef _MACH_I386_PROCESSOR_INFO_H_ -#define _MACH_I386_PROCESSOR_INFO_H_ - -#endif /* _MACH_I386_PROCESSOR_INFO_H_ */ diff --git a/include/xnu/mach/i386/rpc.h b/include/xnu/mach/i386/rpc.h deleted file mode 100644 index 55561f9eb..000000000 --- a/include/xnu/mach/i386/rpc.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2002,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@ - */ -/* - * @OSF_COPYRIGHT@ - */ - -#ifndef _MACH_I386_RPC_H_ -#define _MACH_I386_RPC_H_ - -#endif /* _MACH_I386_RPC_H_ */ - diff --git a/include/xnu/mach/i386/sdt_isa.h b/include/xnu/mach/i386/sdt_isa.h deleted file mode 100644 index 14549e810..000000000 --- a/include/xnu/mach/i386/sdt_isa.h +++ /dev/null @@ -1,441 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _MACH_I386_SDT_ISA_H -#define _MACH_I386_SDT_ISA_H - -/* - * Only define when testing. This makes the calls into actual calls to - * test functions. - */ -/* #define DTRACE_CALL_TEST */ - -#define DTRACE_STRINGIFY(s) #s -#define DTRACE_TOSTRING(s) DTRACE_STRINGIFY(s) -#if defined(KERNEL) -/* - * For the kernel, set an explicit global label so the symbol can be located - */ -#ifdef __x86_64__ -#define DTRACE_LAB(p, n) \ - "__dtrace_probe$" DTRACE_TOSTRING(%=__LINE__) DTRACE_STRINGIFY(_##p##___##n) - -#define DTRACE_LABEL(p, n) \ - ".section __DATA, __data\n\t" \ - ".globl " DTRACE_LAB(p, n) "\n\t" \ - DTRACE_LAB(p, n) ":" ".quad 1f""\n\t" \ - ".text" "\n\t" \ - "1:" -#else -#define DTRACE_LAB(p, n) \ - "__dtrace_probe$" DTRACE_TOSTRING(%=__LINE__) DTRACE_STRINGIFY(_##p##___##n) - -#define DTRACE_LABEL(p, n) \ - ".section __DATA, __data\n\t" \ - ".globl " DTRACE_LAB(p, n) "\n\t" \ - DTRACE_LAB(p, n) ":" ".long 1f""\n\t" \ - ".text" "\n\t" \ - "1:" -#endif -#else /* !KERNEL */ -#define DTRACE_LABEL(p, n) \ - "__dtrace_probe$" DTRACE_TOSTRING(%=__LINE__) DTRACE_STRINGIFY(_##p##___##n) ":" "\n\t" -#endif /* !KERNEL */ - -#ifdef DTRACE_CALL_TEST - -#define DTRACE_CALL(p,n) \ - DTRACE_LABEL(p,n) \ - DTRACE_CALL_INSN(p,n) - -#else - -#define DTRACE_CALL(p,n) \ - DTRACE_LABEL(p,n) \ - DTRACE_NOPS - -#endif - -#ifdef __x86_64__ - -#define DTRACE_NOPS \ - "nop" "\n\t" \ - "nop" "\n\t" \ - "nop" "\n\t" - -#define DTRACE_CALL_INSN(p,n) \ - "call _dtracetest" DTRACE_STRINGIFY(_##p##_##n) "\n\t" - -#define ARG1_EXTENT 1 -#define ARGS2_EXTENT 2 -#define ARGS3_EXTENT 3 -#define ARGS4_EXTENT 4 -#define ARGS5_EXTENT 5 -#define ARGS6_EXTENT 6 -#define ARGS7_EXTENT 7 -#define ARGS8_EXTENT 8 -#define ARGS9_EXTENT 10 -#define ARGS10_EXTENT 10 - -#define DTRACE_CALL0ARGS(provider, name) \ - asm volatile ( \ - DTRACE_CALL(provider, name) \ - : \ - : \ - ); - -#define DTRACE_CALL1ARG(provider, name) \ - asm volatile ("movq\t0x0(%0),%%rdi" "\n\t" \ - DTRACE_CALL(provider, name) \ - : \ - : "r" (__dtrace_args) \ - : "memory", "rdi" \ - ); - -#define DTRACE_CALL2ARGS(provider, name) \ - asm volatile ("movq\t0x0(%0),%%rdi" "\n\t" \ - "movq\t0x8(%0),%%rsi" "\n\t" \ - DTRACE_CALL(provider, name) \ - : \ - : "r" (__dtrace_args) \ - : "memory", "rdi", "rsi" \ - ); - -#define DTRACE_CALL3ARGS(provider, name) \ - asm volatile ("movq\t0x0(%0),%%rdi" "\n\t" \ - "movq\t0x8(%0),%%rsi" "\n\t" \ - "movq\t0x10(%0),%%rdx" "\n\t" \ - DTRACE_CALL(provider, name) \ - : \ - : "r" (__dtrace_args) \ - : "memory", "rdi", "rsi", "rdx" \ - ); - -#define DTRACE_CALL4ARGS(provider, name) \ - asm volatile ("movq\t0x0(%0),%%rdi" "\n\t" \ - "movq\t0x8(%0),%%rsi" "\n\t" \ - "movq\t0x10(%0),%%rdx" "\n\t" \ - "movq\t0x18(%0),%%rcx" "\n\t" \ - DTRACE_CALL(provider, name) \ - : \ - : "r" (__dtrace_args) \ - : "memory", "rdi", "rsi", "rdx", "rcx" \ - ); - -#define DTRACE_CALL5ARGS(provider, name) \ - asm volatile ("movq\t0x0(%0),%%rdi" "\n\t" \ - "movq\t0x8(%0),%%rsi" "\n\t" \ - "movq\t0x10(%0),%%rdx" "\n\t" \ - "movq\t0x18(%0),%%rcx" "\n\t" \ - "movq\t0x20(%0),%%r8" "\n\t" \ - DTRACE_CALL(provider, name) \ - : \ - : "r" (__dtrace_args) \ - : "memory", "rdi", "rsi", "rdx", "rcx", "r8" \ - ); - -#define DTRACE_CALL6ARGS(provider, name) \ - asm volatile ("movq\t0x0(%0),%%rdi" "\n\t" \ - "movq\t0x8(%0),%%rsi" "\n\t" \ - "movq\t0x10(%0),%%rdx" "\n\t" \ - "movq\t0x18(%0),%%rcx" "\n\t" \ - "movq\t0x20(%0),%%r8" "\n\t" \ - "movq\t0x28(%0),%%r9" "\n\t" \ - DTRACE_CALL(provider, name) \ - : \ - : "r" (__dtrace_args) \ - : "memory", "rdi", "rsi", "rdx", "rcx", "r8", "r9" \ - ); - -#define DTRACE_CALL7ARGS(provider, name) \ - asm volatile ("subq\t$0x8,%%rsp" "\n\t" \ - "movq\t0x0(%0),%%rdi" "\n\t" \ - "movq\t0x8(%0),%%rsi" "\n\t" \ - "movq\t0x10(%0),%%rdx" "\n\t" \ - "movq\t0x18(%0),%%rcx" "\n\t" \ - "movq\t0x20(%0),%%r8" "\n\t" \ - "movq\t0x28(%0),%%r9" "\n\t" \ - "movq\t0x30(%0),%%rax" "\n\t" \ - "movq\t%%rax,0x0(%%rsp)" "\n\t" \ - DTRACE_CALL(provider, name) \ - "addq\t$0x8,%%rsp" "\n\t" \ - : \ - : "r" (__dtrace_args) \ - : "memory", "rdi", "rsi", "rdx", "rcx", "r8", "r9", "rax" \ - ); - -#endif // __x86_64__ - -#ifdef __i386__ - -#define DTRACE_NOPS \ - "nop" "\n\t" \ - "leal 0(%%esi), %%esi" "\n\t" - -#define DTRACE_CALL_INSN(p,n) \ - "call _dtracetest" DTRACE_STRINGIFY(_##p##_##n) "\n\t" - -#define ARG1_EXTENT 1 -#define ARGS2_EXTENT 2 -#define ARGS3_EXTENT 4 -#define ARGS4_EXTENT 4 -#define ARGS5_EXTENT 8 -#define ARGS6_EXTENT 8 -#define ARGS7_EXTENT 8 -#define ARGS8_EXTENT 8 -#define ARGS9_EXTENT 12 -#define ARGS10_EXTENT 12 - -/* - * Because this code is used in the kernel, we must not touch any floating point - * or specialized registers. This leaves the following registers: - * - * eax ; volatile, safe to use - * ebx ; PIC register, gcc error when used - * ecx ; volatile, safe to use - * edx ; volatile, safe to use - * esi ; non-volatile, otherwise safe to use - * edi ; non-volatile, otherwise safe to use - * - * Using any of the non volatile register causes a spill to stack which is almost - * certainly a net performance loss. Also, note that the array ref (__dtrace_args) - * consumes one free register. If all three of the volatile regs are used for load/store, - * the compiler will spill a register to hold the array ref. - * - * The end result is that we only pipeline two loads/stores at a time. Blech. - */ - -#define DTRACE_CALL0ARGS(provider, name) \ - asm volatile ( \ - DTRACE_CALL(provider, name) \ - "# eat trailing nl +tabfrom DTRACE_CALL" \ - : \ - : \ - ); - -#define DTRACE_CALL1ARG(provider, name) \ - asm volatile ("subl\t$0x10,%%esp" "\n\t" \ - "movl\t0x0(%0),%%eax" "\n\t" \ - "movl\t%%eax,0x0(%%esp)" "\n\t" \ - DTRACE_CALL(provider, name) \ - "addl\t$0x10,%%esp" \ - : \ - : "r" (__dtrace_args) \ - : "memory", "eax" \ - ); - -#define DTRACE_CALL2ARGS(provider, name) \ - asm volatile ("subl\t$0x10,%%esp" "\n\t" \ - "movl\t0x0(%0),%%eax" "\n\t" \ - "movl\t0x4(%0),%%edx" "\n\t" \ - "movl\t%%eax,0x0(%%esp)" "\n\t" \ - "movl\t%%edx,0x4(%%esp)" "\n\t" \ - DTRACE_CALL(provider, name) \ - "addl\t$0x10,%%esp" \ - : \ - : "r" (__dtrace_args) \ - : "memory", "eax", "edx" \ - ); - -#define DTRACE_CALL3ARGS(provider, name) \ - asm volatile ("subl\t$0x10,%%esp" "\n\t" \ - "movl\t0x0(%0),%%eax" "\n\t" \ - "movl\t0x4(%0),%%edx" "\n\t" \ - "movl\t%%eax,0x0(%%esp)" "\n\t" \ - "movl\t%%edx,0x4(%%esp)" "\n\t" \ - "movl\t0x8(%0),%%eax" "\n\t" \ - "movl\t%%eax,0x8(%%esp)" "\n\t" \ - DTRACE_CALL(provider, name) \ - "addl\t$0x10,%%esp" \ - : \ - : "r" (__dtrace_args) \ - : "memory", "eax", "edx" \ - ); - -#define DTRACE_CALL4ARGS(provider, name) \ - asm volatile ("subl\t$0x10,%%esp" "\n\t" \ - "movl\t0x0(%0),%%eax" "\n\t" \ - "movl\t0x4(%0),%%edx" "\n\t" \ - "movl\t%%eax,0x0(%%esp)" "\n\t" \ - "movl\t%%edx,0x4(%%esp)" "\n\t" \ - "movl\t0x8(%0),%%eax" "\n\t" \ - "movl\t0xC(%0),%%edx" "\n\t" \ - "movl\t%%eax,0x8(%%esp)" "\n\t" \ - "movl\t%%edx,0xC(%%esp)" "\n\t" \ - DTRACE_CALL(provider, name) \ - "addl\t$0x10,%%esp" \ - : \ - : "r" (__dtrace_args) \ - : "memory", "eax", "edx" \ - ); - -#define DTRACE_CALL5ARGS(provider, name) \ - asm volatile ("subl\t$0x20,%%esp" "\n\t" \ - "movl\t0x0(%0),%%eax" "\n\t" \ - "movl\t0x4(%0),%%edx" "\n\t" \ - "movl\t%%eax,0x0(%%esp)" "\n\t" \ - "movl\t%%edx,0x4(%%esp)" "\n\t" \ - "movl\t0x8(%0),%%eax" "\n\t" \ - "movl\t0xC(%0),%%edx" "\n\t" \ - "movl\t%%eax,0x8(%%esp)" "\n\t" \ - "movl\t%%edx,0xC(%%esp)" "\n\t" \ - "movl\t0x10(%0),%%eax" "\n\t" \ - "movl\t%%eax,0x10(%%esp)" "\n\t" \ - DTRACE_CALL(provider, name) \ - "addl\t$0x20,%%esp" \ - : \ - : "r" (__dtrace_args) \ - : "memory", "eax", "edx" \ - ); - -#define DTRACE_CALL6ARGS(provider, name) \ - asm volatile ("subl\t$0x20,%%esp" "\n\t" \ - "movl\t0x0(%0),%%eax" "\n\t" \ - "movl\t0x4(%0),%%edx" "\n\t" \ - "movl\t%%eax,0x0(%%esp)" "\n\t" \ - "movl\t%%edx,0x4(%%esp)" "\n\t" \ - "movl\t0x8(%0),%%eax" "\n\t" \ - "movl\t0xC(%0),%%edx" "\n\t" \ - "movl\t%%eax,0x8(%%esp)" "\n\t" \ - "movl\t%%edx,0xC(%%esp)" "\n\t" \ - "movl\t0x10(%0),%%eax" "\n\t" \ - "movl\t0x14(%0),%%edx" "\n\t" \ - "movl\t%%eax,0x10(%%esp)" "\n\t" \ - "movl\t%%edx,0x14(%%esp)" "\n\t" \ - DTRACE_CALL(provider, name) \ - "addl\t$0x20,%%esp" \ - : \ - : "r" (__dtrace_args) \ - : "memory", "eax", "edx" \ - ); - -#define DTRACE_CALL7ARGS(provider, name) \ - asm volatile ("subl\t$0x20,%%esp" "\n\t" \ - "movl\t0x0(%0),%%eax" "\n\t" \ - "movl\t0x4(%0),%%edx" "\n\t" \ - "movl\t%%eax,0x0(%%esp)" "\n\t" \ - "movl\t%%edx,0x4(%%esp)" "\n\t" \ - "movl\t0x8(%0),%%eax" "\n\t" \ - "movl\t0xC(%0),%%edx" "\n\t" \ - "movl\t%%eax,0x8(%%esp)" "\n\t" \ - "movl\t%%edx,0xC(%%esp)" "\n\t" \ - "movl\t0x10(%0),%%eax" "\n\t" \ - "movl\t0x14(%0),%%edx" "\n\t" \ - "movl\t%%eax,0x10(%%esp)" "\n\t" \ - "movl\t%%edx,0x14(%%esp)" "\n\t" \ - "movl\t0x18(%0),%%eax" "\n\t" \ - "movl\t%%eax,0x18(%%esp)" "\n\t" \ - DTRACE_CALL(provider, name) \ - "addl\t$0x20,%%esp" \ - : \ - : "r" (__dtrace_args) \ - : "memory", "eax", "edx" \ - ); - -#define DTRACE_CALL8ARGS(provider, name) \ - asm volatile ("subl\t$0x20,%%esp" "\n\t" \ - "movl\t0x0(%0),%%eax" "\n\t" \ - "movl\t0x4(%0),%%edx" "\n\t" \ - "movl\t%%eax,0x0(%%esp)" "\n\t" \ - "movl\t%%edx,0x4(%%esp)" "\n\t" \ - "movl\t0x8(%0),%%eax" "\n\t" \ - "movl\t0xC(%0),%%edx" "\n\t" \ - "movl\t%%eax,0x8(%%esp)" "\n\t" \ - "movl\t%%edx,0xC(%%esp)" "\n\t" \ - "movl\t0x10(%0),%%eax" "\n\t" \ - "movl\t0x14(%0),%%edx" "\n\t" \ - "movl\t%%eax,0x10(%%esp)" "\n\t" \ - "movl\t%%edx,0x14(%%esp)" "\n\t" \ - "movl\t0x18(%0),%%eax" "\n\t" \ - "movl\t0x1C(%0),%%edx" "\n\t" \ - "movl\t%%eax,0x18(%%esp)" "\n\t" \ - "movl\t%%edx,0x1C(%%esp)" "\n\t" \ - DTRACE_CALL(provider, name) \ - "addl\t$0x20,%%esp" \ - : \ - : "r" (__dtrace_args) \ - : "memory", "eax", "edx" \ - ); - -#define DTRACE_CALL9ARGS(provider, name) \ - asm volatile ("subl\t$0x30,%%esp" "\n\t" \ - "movl\t0x0(%0),%%eax" "\n\t" \ - "movl\t0x4(%0),%%edx" "\n\t" \ - "movl\t%%eax,0x0(%%esp)" "\n\t" \ - "movl\t%%edx,0x4(%%esp)" "\n\t" \ - "movl\t0x8(%0),%%eax" "\n\t" \ - "movl\t0xC(%0),%%edx" "\n\t" \ - "movl\t%%eax,0x8(%%esp)" "\n\t" \ - "movl\t%%edx,0xC(%%esp)" "\n\t" \ - "movl\t0x10(%0),%%eax" "\n\t" \ - "movl\t0x14(%0),%%edx" "\n\t" \ - "movl\t%%eax,0x10(%%esp)" "\n\t" \ - "movl\t%%edx,0x14(%%esp)" "\n\t" \ - "movl\t0x18(%0),%%eax" "\n\t" \ - "movl\t0x1C(%0),%%edx" "\n\t" \ - "movl\t%%eax,0x18(%%esp)" "\n\t" \ - "movl\t%%edx,0x1C(%%esp)" "\n\t" \ - "movl\t0x20(%0),%%eax" "\n\t" \ - "movl\t%%eax,0x20(%%esp)" "\n\t" \ - DTRACE_CALL(provider, name) \ - "addl\t$0x30,%%esp" \ - : \ - : "r" (__dtrace_args) \ - : "memory", "eax", "edx" \ - ); - -#define DTRACE_CALL10ARGS(provider, name) \ - asm volatile ("subl\t$0x30,%%esp" "\n\t" \ - "movl\t0x0(%0),%%eax" "\n\t" \ - "movl\t0x4(%0),%%edx" "\n\t" \ - "movl\t%%eax,0x0(%%esp)" "\n\t" \ - "movl\t%%edx,0x4(%%esp)" "\n\t" \ - "movl\t0x8(%0),%%eax" "\n\t" \ - "movl\t0xC(%0),%%edx" "\n\t" \ - "movl\t%%eax,0x8(%%esp)" "\n\t" \ - "movl\t%%edx,0xC(%%esp)" "\n\t" \ - "movl\t0x10(%0),%%eax" "\n\t" \ - "movl\t0x14(%0),%%edx" "\n\t" \ - "movl\t%%eax,0x10(%%esp)" "\n\t" \ - "movl\t%%edx,0x14(%%esp)" "\n\t" \ - "movl\t0x18(%0),%%eax" "\n\t" \ - "movl\t0x1C(%0),%%edx" "\n\t" \ - "movl\t%%eax,0x18(%%esp)" "\n\t" \ - "movl\t%%edx,0x1C(%%esp)" "\n\t" \ - "movl\t0x20(%0),%%eax" "\n\t" \ - "movl\t0x24(%0),%%edx" "\n\t" \ - "movl\t%%eax,0x20(%%esp)" "\n\t" \ - "movl\t%%edx,0x24(%%esp)" "\n\t" \ - DTRACE_CALL(provider, name) \ - "addl\t$0x30,%%esp" \ - : \ - : "r" (__dtrace_args) \ - : "memory", "eax", "edx" \ - ); - -#endif // __i386__ - -#endif /* _MACH_I386_SDT_ISA_H */ diff --git a/include/xnu/mach/i386/syscall_sw.h b/include/xnu/mach/i386/syscall_sw.h deleted file mode 100644 index abef968a7..000000000 --- a/include/xnu/mach/i386/syscall_sw.h +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (c) 2000-2006 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@ - */ -/* - * @OSF_COPYRIGHT@ - */ -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989,1988 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 Software.Distribution@CS.CMU.EDU - * 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. - */ -#ifdef PRIVATE - -#ifndef _MACH_I386_SYSCALL_SW_H_ -#define _MACH_I386_SYSCALL_SW_H_ - -#include - -/* - * Software interrupt codes for 32-bit system call entry: - */ -#define UNIX_INT 0x80 -#define MACH_INT 0x81 -#define MACHDEP_INT 0x82 -#define DIAG_INT 0x83 - -#if defined(__i386__) - -#ifndef KERNEL -/* - * Syscall entry macros for use in libc: - */ -#define UNIX_SYSCALL_TRAP \ - int $(UNIX_INT) -#define MACHDEP_SYSCALL_TRAP \ - int $(MACHDEP_INT) - -/* - * Macro to generate Mach call stubs in libc: - */ - -#define kernel_trap(trap_name,trap_number,number_args) \ -LEAF(_##trap_name,0) ;\ - movl $##trap_number, %eax ;\ - call __sysenter_trap ;\ -END(_##trap_name) - -#endif /* !KERNEL */ - -#endif /* defined(__i386__) */ - -#if defined(__x86_64__) - -#ifndef KERNEL - -#define UNIX_SYSCALL_TRAP \ - syscall -#define MACHDEP_SYSCALL_TRAP \ - syscall - -/* - * Macro to generate Mach call stubs in Libc. - * Existing calls use negative numbers for Mach traps, so - * until we change those and change the 32-bit kernel_trap - * macro above, we negate those numbers here for the 64-bit - * code path. - */ -#define kernel_trap(trap_name,trap_number,number_args) \ -LEAF(_##trap_name,0) ;\ - movq %rcx, %r10 ;\ - movl $ SYSCALL_CONSTRUCT_MACH(-##trap_number), %eax ;\ - syscall ;\ -END(_##trap_name) - -#endif /* !KERNEL */ - -#endif /* defined(__x86_64__) */ - -/* - * Syscall classes for 64-bit system call entry. - * For 64-bit users, the 32-bit syscall number is partitioned - * with the high-order bits representing the class and low-order - * bits being the syscall number within that class. - * The high-order 32-bits of the 64-bit syscall number are unused. - * All system classes enter the kernel via the syscall instruction. - * - * These are not #ifdef'd for x86-64 because they might be used for - * 32-bit someday and so the 64-bit comm page in a 32-bit kernel - * can use them. - */ -#define SYSCALL_CLASS_SHIFT 24 -#define SYSCALL_CLASS_MASK (0xFF << SYSCALL_CLASS_SHIFT) -#define SYSCALL_NUMBER_MASK (~SYSCALL_CLASS_MASK) - -#define I386_SYSCALL_CLASS_MASK SYSCALL_CLASS_MASK -#define I386_SYSCALL_ARG_BYTES_SHIFT (16) -#define I386_SYSCALL_ARG_DWORDS_SHIFT (I386_SYSCALL_ARG_BYTES_SHIFT + 2) -#define I386_SYSCALL_ARG_BYTES_NUM (64) /* Must be <= sizeof(uu_arg) */ -#define I386_SYSCALL_ARG_DWORDS_MASK ((I386_SYSCALL_ARG_BYTES_NUM >> 2) -1) -#define I386_SYSCALL_ARG_BYTES_MASK (((I386_SYSCALL_ARG_BYTES_NUM -1)&~0x3) << I386_SYSCALL_ARG_BYTES_SHIFT) -#define I386_SYSCALL_NUMBER_MASK (0xFFFF) - -#define SYSCALL_CLASS_NONE 0 /* Invalid */ -#define SYSCALL_CLASS_MACH 1 /* Mach */ -#define SYSCALL_CLASS_UNIX 2 /* Unix/BSD */ -#define SYSCALL_CLASS_MDEP 3 /* Machine-dependent */ -#define SYSCALL_CLASS_DIAG 4 /* Diagnostics */ -#define SYSCALL_CLASS_IPC 5 /* Mach IPC */ - -/* Macros to simpllfy constructing syscall numbers. */ -#define SYSCALL_CONSTRUCT_MACH(syscall_number) \ - ((SYSCALL_CLASS_MACH << SYSCALL_CLASS_SHIFT) | \ - (SYSCALL_NUMBER_MASK & (syscall_number))) -#define SYSCALL_CONSTRUCT_UNIX(syscall_number) \ - ((SYSCALL_CLASS_UNIX << SYSCALL_CLASS_SHIFT) | \ - (SYSCALL_NUMBER_MASK & (syscall_number))) -#define SYSCALL_CONSTRUCT_MDEP(syscall_number) \ - ((SYSCALL_CLASS_MDEP << SYSCALL_CLASS_SHIFT) | \ - (SYSCALL_NUMBER_MASK & (syscall_number))) -#define SYSCALL_CONSTRUCT_DIAG(syscall_number) \ - ((SYSCALL_CLASS_DIAG << SYSCALL_CLASS_SHIFT) | \ - (SYSCALL_NUMBER_MASK & (syscall_number))) - -#endif /* _MACH_I386_SYSCALL_SW_H_ */ - -#endif /* PRIVATE */ diff --git a/include/xnu/mach/i386/thread_state.h b/include/xnu/mach/i386/thread_state.h deleted file mode 100644 index b2d5b9787..000000000 --- a/include/xnu/mach/i386/thread_state.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2000-2006 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@ - */ -/* - * @OSF_COPYRIGHT@ - */ - -#ifndef _MACH_I386_THREAD_STATE_H_ -#define _MACH_I386_THREAD_STATE_H_ - -/* Size of maximum exported thread state in words */ -#define I386_THREAD_STATE_MAX (224) /* Size of biggest state possible */ - -#if defined (__i386__) || defined(__x86_64__) || defined(__arm__) /* probably not correct for ARM, but we don't care atm */ -#define THREAD_STATE_MAX I386_THREAD_STATE_MAX -#endif - -#endif /* _MACH_I386_THREAD_STATE_H_ */ diff --git a/include/xnu/mach/i386/thread_status.h b/include/xnu/mach/i386/thread_status.h deleted file mode 100644 index 715422ac8..000000000 --- a/include/xnu/mach/i386/thread_status.h +++ /dev/null @@ -1,544 +0,0 @@ -/* - * Copyright (c) 2000-2006 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@ - */ -/* - * @OSF_COPYRIGHT@ - */ -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989 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 Software.Distribution@CS.CMU.EDU - * 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: thread_status.h - * Author: Avadis Tevanian, Jr. - * Date: 1985 - * - * This file contains the structure definitions for the thread - * state as applied to I386 processors. - */ - -#ifndef _MACH_I386_THREAD_STATUS_H_ -#define _MACH_I386_THREAD_STATUS_H_ - -#include -#include -#include -#include -#include - -/* - * the i386_xxxx form is kept for legacy purposes since these types - * are externally known... eventually they should be deprecated. - * our internal implementation has moved to the following naming convention - * - * x86_xxxx32 names are used to deal with 32 bit states - * x86_xxxx64 names are used to deal with 64 bit states - * x86_xxxx names are used to deal with either 32 or 64 bit states - * via a self-describing mechanism - */ - -/* - * these are the legacy names which should be deprecated in the future - * they are externally known which is the only reason we don't just get - * rid of them - */ -#define i386_THREAD_STATE 1 -#define i386_FLOAT_STATE 2 -#define i386_EXCEPTION_STATE 3 - -/* - * THREAD_STATE_FLAVOR_LIST 0 - * these are the supported flavors - */ -#define x86_THREAD_STATE32 1 -#define x86_FLOAT_STATE32 2 -#define x86_EXCEPTION_STATE32 3 -#define x86_THREAD_STATE64 4 -#define x86_FLOAT_STATE64 5 -#define x86_EXCEPTION_STATE64 6 -#define x86_THREAD_STATE 7 -#define x86_FLOAT_STATE 8 -#define x86_EXCEPTION_STATE 9 -#define x86_DEBUG_STATE32 10 -#define x86_DEBUG_STATE64 11 -#define x86_DEBUG_STATE 12 -#define THREAD_STATE_NONE 13 -/* 15 and 16 are used for the internal x86_SAVED_STATE flavours */ -#define x86_AVX_STATE32 16 -#define x86_AVX_STATE64 17 - - -/* - * Largest state on this machine: - * (be sure mach/machine/thread_state.h matches!) - */ -#define THREAD_MACHINE_STATE_MAX THREAD_STATE_MAX - -/* - * VALID_THREAD_STATE_FLAVOR is a platform specific macro that when passed - * an exception flavor will return if that is a defined flavor for that - * platform. The macro must be manually updated to include all of the valid - * exception flavors as defined above. - */ -#define VALID_THREAD_STATE_FLAVOR(x) \ - ((x == x86_THREAD_STATE32) || \ - (x == x86_FLOAT_STATE32) || \ - (x == x86_EXCEPTION_STATE32) || \ - (x == x86_DEBUG_STATE32) || \ - (x == x86_THREAD_STATE64) || \ - (x == x86_FLOAT_STATE64) || \ - (x == x86_EXCEPTION_STATE64) || \ - (x == x86_DEBUG_STATE64) || \ - (x == x86_THREAD_STATE) || \ - (x == x86_FLOAT_STATE) || \ - (x == x86_EXCEPTION_STATE) || \ - (x == x86_DEBUG_STATE) || \ - (x == x86_AVX_STATE32) || \ - (x == x86_AVX_STATE64) || \ - (x == THREAD_STATE_NONE)) - -struct x86_state_hdr { - int flavor; - int count; -}; -typedef struct x86_state_hdr x86_state_hdr_t; - -/* - * Default segment register values. - */ - -#define USER_CODE_SELECTOR 0x0017 -#define USER_DATA_SELECTOR 0x001f -#define KERN_CODE_SELECTOR 0x0008 -#define KERN_DATA_SELECTOR 0x0010 - -/* - * to be deprecated in the future - */ -typedef _STRUCT_X86_THREAD_STATE32 i386_thread_state_t; -#define i386_THREAD_STATE_COUNT ((mach_msg_type_number_t) \ - ( sizeof (i386_thread_state_t) / sizeof (int) )) - -typedef _STRUCT_X86_THREAD_STATE32 x86_thread_state32_t; -#define x86_THREAD_STATE32_COUNT ((mach_msg_type_number_t) \ - ( sizeof (x86_thread_state32_t) / sizeof (int) )) - -/* - * to be deprecated in the future - */ -typedef _STRUCT_X86_FLOAT_STATE32 i386_float_state_t; -#define i386_FLOAT_STATE_COUNT ((mach_msg_type_number_t) \ - (sizeof(i386_float_state_t)/sizeof(unsigned int))) - -typedef _STRUCT_X86_FLOAT_STATE32 x86_float_state32_t; -#define x86_FLOAT_STATE32_COUNT ((mach_msg_type_number_t) \ - (sizeof(x86_float_state32_t)/sizeof(unsigned int))) - -typedef _STRUCT_X86_AVX_STATE32 x86_avx_state32_t; -#define x86_AVX_STATE32_COUNT ((mach_msg_type_number_t) \ - (sizeof(x86_avx_state32_t)/sizeof(unsigned int))) - -/* - * to be deprecated in the future - */ -typedef _STRUCT_X86_EXCEPTION_STATE32 i386_exception_state_t; -#define i386_EXCEPTION_STATE_COUNT ((mach_msg_type_number_t) \ - ( sizeof (i386_exception_state_t) / sizeof (int) )) - -typedef _STRUCT_X86_EXCEPTION_STATE32 x86_exception_state32_t; -#define x86_EXCEPTION_STATE32_COUNT ((mach_msg_type_number_t) \ - ( sizeof (x86_exception_state32_t) / sizeof (int) )) - -#define I386_EXCEPTION_STATE_COUNT i386_EXCEPTION_STATE_COUNT - -typedef _STRUCT_X86_DEBUG_STATE32 x86_debug_state32_t; -#define x86_DEBUG_STATE32_COUNT ((mach_msg_type_number_t) \ - ( sizeof (x86_debug_state32_t) / sizeof (int) )) - -#define X86_DEBUG_STATE32_COUNT x86_DEBUG_STATE32_COUNT - -typedef _STRUCT_X86_THREAD_STATE64 x86_thread_state64_t; -#define x86_THREAD_STATE64_COUNT ((mach_msg_type_number_t) \ - ( sizeof (x86_thread_state64_t) / sizeof (int) )) - -typedef _STRUCT_X86_FLOAT_STATE64 x86_float_state64_t; -#define x86_FLOAT_STATE64_COUNT ((mach_msg_type_number_t) \ - (sizeof(x86_float_state64_t)/sizeof(unsigned int))) - -typedef _STRUCT_X86_AVX_STATE64 x86_avx_state64_t; -#define x86_AVX_STATE64_COUNT ((mach_msg_type_number_t) \ - (sizeof(x86_avx_state64_t)/sizeof(unsigned int))) - -typedef _STRUCT_X86_EXCEPTION_STATE64 x86_exception_state64_t; -#define x86_EXCEPTION_STATE64_COUNT ((mach_msg_type_number_t) \ - ( sizeof (x86_exception_state64_t) / sizeof (int) )) - -#define X86_EXCEPTION_STATE64_COUNT x86_EXCEPTION_STATE64_COUNT - -typedef _STRUCT_X86_DEBUG_STATE64 x86_debug_state64_t; -#define x86_DEBUG_STATE64_COUNT ((mach_msg_type_number_t) \ - ( sizeof (x86_debug_state64_t) / sizeof (int) )) - -#define X86_DEBUG_STATE64_COUNT x86_DEBUG_STATE64_COUNT - -/* - * Combined thread, float and exception states - */ -struct x86_thread_state { - x86_state_hdr_t tsh; - union { - x86_thread_state32_t ts32; - x86_thread_state64_t ts64; - } uts; -}; - -struct x86_float_state { - x86_state_hdr_t fsh; - union { - x86_float_state32_t fs32; - x86_float_state64_t fs64; - } ufs; -}; - -struct x86_exception_state { - x86_state_hdr_t esh; - union { - x86_exception_state32_t es32; - x86_exception_state64_t es64; - } ues; -}; - -struct x86_debug_state { - x86_state_hdr_t dsh; - union { - x86_debug_state32_t ds32; - x86_debug_state64_t ds64; - } uds; -}; - -typedef struct x86_thread_state x86_thread_state_t; -#define x86_THREAD_STATE_COUNT ((mach_msg_type_number_t) \ - ( sizeof (x86_thread_state_t) / sizeof (int) )) - -typedef struct x86_float_state x86_float_state_t; -#define x86_FLOAT_STATE_COUNT ((mach_msg_type_number_t) \ - (sizeof(x86_float_state_t)/sizeof(unsigned int))) - -typedef struct x86_exception_state x86_exception_state_t; -#define x86_EXCEPTION_STATE_COUNT ((mach_msg_type_number_t) \ - (sizeof(x86_exception_state_t)/sizeof(unsigned int))) - -typedef struct x86_debug_state x86_debug_state_t; -#define x86_DEBUG_STATE_COUNT ((mach_msg_type_number_t) \ - (sizeof(x86_debug_state_t)/sizeof(unsigned int))) - -/* - * Machine-independent way for servers and Mach's exception mechanism to - * choose the most efficient state flavor for exception RPC's: - */ -#define MACHINE_THREAD_STATE x86_THREAD_STATE -#define MACHINE_THREAD_STATE_COUNT x86_THREAD_STATE_COUNT - -/* - * when reloading the segment registers on - * a return out of the kernel, we may take - * a GeneralProtection or SegmentNotPresent - * fault if one or more of the segment - * registers in the saved state was improperly - * specified via an x86_THREAD_STATE32 call - * the frame we push on top of the existing - * save area looks like this... we need to - * carry this as part of the save area - * in case we get hit so that we have a big - * enough stack - */ -struct x86_seg_load_fault32 { - uint16_t trapno; - uint16_t cpu; - uint32_t err; - uint32_t eip; - uint32_t cs; - uint32_t efl; -}; - -#ifdef XNU_KERNEL_PRIVATE - -#define x86_SAVED_STATE32 THREAD_STATE_NONE + 1 -#define x86_SAVED_STATE64 THREAD_STATE_NONE + 2 - -/* - * Subset of saved state stored by processor on kernel-to-kernel - * trap. (Used by ddb to examine state guaranteed to be present - * on all traps into debugger.) - */ -struct x86_saved_state32_from_kernel { - uint32_t gs; - uint32_t fs; - uint32_t es; - uint32_t ds; - uint32_t edi; - uint32_t esi; - uint32_t ebp; - uint32_t cr2; /* kernel esp stored by pusha - we save cr2 here later */ - uint32_t ebx; - uint32_t edx; - uint32_t ecx; - uint32_t eax; - uint16_t trapno; - uint16_t cpu; - uint32_t err; - uint32_t eip; - uint32_t cs; - uint32_t efl; -}; - -/* - * The format in which thread state is saved by Mach on this machine. This - * state flavor is most efficient for exception RPC's to kernel-loaded - * servers, because copying can be avoided: - */ -struct x86_saved_state32 { - uint32_t gs; - uint32_t fs; - uint32_t es; - uint32_t ds; - uint32_t edi; - uint32_t esi; - uint32_t ebp; - uint32_t cr2; /* kernel esp stored by pusha - we save cr2 here later */ - uint32_t ebx; - uint32_t edx; - uint32_t ecx; - uint32_t eax; - uint16_t trapno; - uint16_t cpu; - uint32_t err; - uint32_t eip; - uint32_t cs; - uint32_t efl; - uint32_t uesp; - uint32_t ss; -}; -typedef struct x86_saved_state32 x86_saved_state32_t; - -#define x86_SAVED_STATE32_COUNT ((mach_msg_type_number_t) \ - (sizeof (x86_saved_state32_t)/sizeof(unsigned int))) - -#pragma pack(4) -struct x86_saved_state32_tagged { - uint32_t tag; - struct x86_saved_state32 state; -}; -typedef struct x86_saved_state32_tagged x86_saved_state32_tagged_t; -/* Note: sizeof(x86_saved_state32_tagged_t) is a multiple of 16 bytes */ - -struct x86_sframe32 { - /* - * in case we throw a fault reloading - * segment registers on a return out of - * the kernel... the 'slf' state is only kept - * long enough to rejigger (i.e. restore - * the save area to its original state) - * the save area and throw the appropriate - * kernel trap pointing to the 'ssf' state - */ - struct x86_seg_load_fault32 slf; - struct x86_saved_state32_tagged ssf; -}; -typedef struct x86_sframe32 x86_sframe32_t; - -/* - * This is the state pushed onto the 64-bit interrupt stack - * on any exception/trap/interrupt. - */ -struct x86_64_intr_stack_frame { - uint16_t trapno; - uint16_t cpu; - uint32_t _pad; - uint64_t trapfn; - uint64_t err; - uint64_t rip; - uint64_t cs; - uint64_t rflags; - uint64_t rsp; - uint64_t ss; -}; -typedef struct x86_64_intr_stack_frame x86_64_intr_stack_frame_t; -/* Note: sizeof(x86_64_intr_stack_frame_t) must be a multiple of 16 bytes */ - -/* - * This defines the state saved before entry into compatibility mode. - * The machine state is pushed automatically and the compat state is - * synthethized in the exception handling code. - */ -struct x86_saved_state_compat32 { - struct x86_saved_state32_tagged iss32; - struct x86_64_intr_stack_frame isf64; -}; -typedef struct x86_saved_state_compat32 x86_saved_state_compat32_t; - -struct x86_sframe_compat32 { - uint32_t pad_for_16byte_alignment[2]; - uint64_t _register_save_slot; - struct x86_64_intr_stack_frame slf; - struct x86_saved_state_compat32 ssf; -}; -typedef struct x86_sframe_compat32 x86_sframe_compat32_t; -/* Note: sizeof(x86_sframe_compat32_t) must be a multiple of 16 bytes */ - -/* - * thread state format for task running in 64bit long mode - * in long mode, the same hardware frame is always pushed regardless - * of whether there was a change in privlege level... therefore, there - * is no need for an x86_saved_state64_from_kernel variant - */ -struct x86_saved_state64 { - /* - * saved state organized to reflect the - * system call ABI register convention - * so that we can just pass a pointer - * to the saved state when calling through - * to the actual system call functions - * the ABI limits us to 6 args passed in - * registers... I've add v_arg6 - v_arg8 - * to accomodate our most 'greedy' system - * calls (both BSD and MACH)... the individual - * system call handlers will fill these in - * via copyin if needed... - */ - uint64_t rdi; /* arg0 for system call */ - uint64_t rsi; - uint64_t rdx; - uint64_t r10; - uint64_t r8; - uint64_t r9; /* arg5 for system call */ - uint64_t v_arg6; - uint64_t v_arg7; - uint64_t v_arg8; - - uint64_t cr2; - uint64_t r15; - uint64_t r14; - uint64_t r13; - uint64_t r12; - uint64_t r11; - uint64_t rbp; - uint64_t rbx; - uint64_t rcx; - uint64_t rax; - - uint32_t gs; - uint32_t fs; - - uint32_t _pad_for_tagged_alignment[3]; - - struct x86_64_intr_stack_frame isf; -}; -typedef struct x86_saved_state64 x86_saved_state64_t; -#define x86_SAVED_STATE64_COUNT ((mach_msg_type_number_t) \ - (sizeof (struct x86_saved_state64)/sizeof(unsigned int))) - -struct x86_saved_state64_tagged { - uint32_t tag; - x86_saved_state64_t state; -}; -typedef struct x86_saved_state64_tagged x86_saved_state64_tagged_t; - -struct x86_sframe64 { - uint64_t _register_save_slot[2]; - struct x86_64_intr_stack_frame slf; - x86_saved_state64_tagged_t ssf; -}; -typedef struct x86_sframe64 x86_sframe64_t; -/* Note: sizeof(x86_sframe64_t) is a multiple of 16 bytes */ - -extern uint32_t get_eflags_exportmask(void); - -/* - * Unified, tagged saved state: - */ -typedef struct { - uint32_t flavor; - union { - x86_saved_state32_t ss_32; - x86_saved_state64_t ss_64; - } uss; -} x86_saved_state_t; -#define ss_32 uss.ss_32 -#define ss_64 uss.ss_64 -#pragma pack() - -static inline boolean_t -is_saved_state64(x86_saved_state_t *iss) -{ - return (iss->flavor == x86_SAVED_STATE64); -} - -static inline boolean_t -is_saved_state32(x86_saved_state_t *iss) -{ - return (iss->flavor == x86_SAVED_STATE32); -} - -static inline x86_saved_state32_t * -saved_state32(x86_saved_state_t *iss) -{ - return &iss->ss_32; -} - -static inline x86_saved_state64_t * -saved_state64(x86_saved_state_t *iss) -{ - return &iss->ss_64; -} - -#endif /* XNU_KERNEL_PRIVATE */ - -#endif /* _MACH_I386_THREAD_STATUS_H_ */ diff --git a/include/xnu/mach/i386/vm_param.h b/include/xnu/mach/i386/vm_param.h deleted file mode 100644 index 12eb226e2..000000000 --- a/include/xnu/mach/i386/vm_param.h +++ /dev/null @@ -1,298 +0,0 @@ -/* - * Copyright (c) 2000-2006 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@ - */ -/* - * @OSF_COPYRIGHT@ - */ -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989,1988 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 Software.Distribution@CS.CMU.EDU - * 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. - */ - -/* - * Copyright (c) 1994 The University of Utah and - * the Computer Systems Laboratory at the University of Utah (CSL). - * All rights reserved. - * - * Permission to use, copy, modify and distribute this software is hereby - * granted provided that (1) source code retains these copyright, permission, - * and disclaimer notices, and (2) redistributions including binaries - * reproduce the notices in supporting documentation, and (3) all advertising - * materials mentioning features or use of this software display the following - * acknowledgement: ``This product includes software developed by the - * Computer Systems Laboratory at the University of Utah.'' - * - * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS - * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF - * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * CSL requests users of this software to return to csl-dist@cs.utah.edu any - * improvements that they make and grant CSL redistribution rights. - * - */ - -/* - * File: vm_param.h - * Author: Avadis Tevanian, Jr. - * Date: 1985 - * - * I386 machine dependent virtual memory parameters. - * Most of the declarations are preceeded by I386_ (or i386_) - * which is OK because only I386 specific code will be using - * them. - */ - -#ifndef _MACH_I386_VM_PARAM_H_ -#define _MACH_I386_VM_PARAM_H_ - -#define BYTE_SIZE 8 /* byte size in bits */ - -#define I386_PGBYTES 4096 /* bytes per 80386 page */ -#define I386_PGSHIFT 12 /* bitshift for pages */ - -#define PAGE_SIZE I386_PGBYTES -#define PAGE_SHIFT I386_PGSHIFT -#define PAGE_MASK (PAGE_SIZE - 1) - -#define I386_LPGBYTES 2*1024*1024 /* bytes per large page */ -#define I386_LPGSHIFT 21 /* bitshift for large pages */ -#define I386_LPGMASK (I386_LPGBYTES-1) - -/* - * Convert bytes to pages and convert pages to bytes. - * No rounding is used. - */ - -#define i386_btop(x) ((ppnum_t)((x) >> I386_PGSHIFT)) -#define machine_btop(x) i386_btop(x) -#define i386_ptob(x) (((pmap_paddr_t)(x)) << I386_PGSHIFT) -#define machine_ptob(x) i386_ptob(x) - -/* - * Round off or truncate to the nearest page. These will work - * for either addresses or counts. (i.e. 1 byte rounds to 1 page - * bytes. - */ - -#define i386_round_page(x) ((((pmap_paddr_t)(x)) + I386_PGBYTES - 1) & \ - ~(I386_PGBYTES-1)) -#define i386_trunc_page(x) (((pmap_paddr_t)(x)) & ~(I386_PGBYTES-1)) - - - -#define VM_MIN_ADDRESS64 ((user_addr_t) 0x0000000000000000ULL) -/* - * default top of user stack... it grows down from here - */ -#define VM_USRSTACK64 ((user_addr_t) 0x00007FFF5FC00000ULL) -#define VM_DYLD64 ((user_addr_t) 0x00007FFF5FC00000ULL) -#define VM_LIB64_SHR_DATA ((user_addr_t) 0x00007FFF60000000ULL) -#define VM_LIB64_SHR_TEXT ((user_addr_t) 0x00007FFF80000000ULL) -/* - * the end of the usable user address space , for now about 47 bits. - * the 64 bit commpage is past the end of this - */ -#define VM_MAX_PAGE_ADDRESS ((user_addr_t) 0x00007FFFFFE00000ULL) -/* - * canonical end of user address space for limits checking - */ -#define VM_MAX_USER_PAGE_ADDRESS ((user_addr_t)0x00007FFFFFFFF000ULL) - - -/* system-wide values */ -#define MACH_VM_MIN_ADDRESS ((mach_vm_offset_t) 0) -#define MACH_VM_MAX_ADDRESS ((mach_vm_offset_t) VM_MAX_PAGE_ADDRESS) - -/* process-relative values (all 32-bit legacy only for now) */ -#define VM_MIN_ADDRESS ((vm_offset_t) 0) -#define VM_USRSTACK32 ((vm_offset_t) 0xC0000000) /* ASLR slides stack down by up to 1 MB */ -#define VM_MAX_ADDRESS ((vm_offset_t) 0xFFE00000) - - -#ifdef KERNEL_PRIVATE - -/* Kernel-wide values */ - -#define KB (1024ULL) -#define MB (1024*KB) -#define GB (1024*MB) - -/* - * Maximum physical memory supported. - */ -#define K32_MAXMEM (32*GB) -#define K64_MAXMEM (96*GB) -#if defined(__i386__) -#define KERNEL_MAXMEM K32_MAXMEM -#else -#define KERNEL_MAXMEM K64_MAXMEM -#endif - -/* - * XXX - * The kernel max VM address is limited to 0xFF3FFFFF for now because - * some data structures are explicitly allocated at 0xFF400000 without - * VM's knowledge (see osfmk/i386/locore.s for the allocation of PTmap and co.). - * We can't let VM allocate memory from there. - */ - -#if defined(__i386__) - -#define KERNEL_IMAGE_TO_PHYS(x) (x) -#define VM_MIN_KERNEL_ADDRESS ((vm_offset_t) 0x00001000U) -#define VM_MIN_KERNEL_AND_KEXT_ADDRESS VM_MIN_KERNEL_ADDRESS -#define VM_MAX_KERNEL_ADDRESS ((vm_offset_t) 0xFE7FFFFFU) - -#elif defined(__x86_64__) - -#define KERNEL_IMAGE_TO_PHYS(x) (x) -#define VM_MIN_KERNEL_ADDRESS ((vm_offset_t) 0xFFFFFF8000000000UL) -#define VM_MIN_KERNEL_PAGE ((ppnum_t)0) -#define VM_MIN_KERNEL_AND_KEXT_ADDRESS (VM_MIN_KERNEL_ADDRESS - 0x80000000ULL) -#define VM_MAX_KERNEL_ADDRESS ((vm_offset_t) 0xFFFFFFFFFFFFEFFFUL) -#define VM_MAX_KERNEL_ADDRESS_EFI32 ((vm_offset_t) 0xFFFFFF80FFFFEFFFUL) -#define KEXT_ALLOC_MAX_OFFSET (2 * 1024 * 1024 * 1024UL) -#define KEXT_ALLOC_BASE(x) ((x) - KEXT_ALLOC_MAX_OFFSET) -#define KEXT_ALLOC_SIZE(x) (KEXT_ALLOC_MAX_OFFSET - (x)) - -#define VM_KERNEL_IS_KEXT(_o) \ - (((vm_offset_t)(_o) >= VM_MIN_KERNEL_AND_KEXT_ADDRESS) && \ - ((vm_offset_t)(_o) < VM_MIN_KERNEL_ADDRESS)) - -#else -#error unsupported architecture -#endif - -#define KERNEL_STACK_SIZE (I386_PGBYTES*4) - -#define VM_MAP_MIN_ADDRESS MACH_VM_MIN_ADDRESS -#define VM_MAP_MAX_ADDRESS MACH_VM_MAX_ADDRESS - -/* FIXME - always leave like this? */ -#define INTSTACK_SIZE (I386_PGBYTES*4) - -#ifdef MACH_KERNEL_PRIVATE - -/* For implementing legacy 32-bit interfaces */ -#define VM32_SUPPORT 1 -#define VM32_MIN_ADDRESS ((vm32_offset_t) 0) -#define VM32_MAX_ADDRESS ((vm32_offset_t) (VM_MAX_PAGE_ADDRESS & 0xFFFFFFFF)) - -/* - * kalloc() parameters: - * - * Historically kalloc's underlying zones were power-of-2 sizes, with a - * KALLOC_MINSIZE of 16 bytes. The allocator ensured that - * (sizeof == alignof) >= 16 for all kalloc allocations. - * - * Today kalloc may use zones with intermediate sizes, constrained by - * KALLOC_MINSIZE and a minimum alignment, expressed by KALLOC_LOG2_MINALIGN. - * - * The common alignment for LP64 is for longs and pointers i.e. 8 bytes. - */ - -#if defined(__i386__) - -#define KALLOC_MINSIZE 16 /* minimum allocation size */ -#define KALLOC_LOG2_MINALIGN 4 /* log2 minimum alignment */ - -#define LINEAR_KERNEL_ADDRESS ((vm_offset_t) 0x00000000) - -#define VM_MIN_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0x00000000U) -#define VM_MAX_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0x1FFFFFFFU) - -#define NCOPY_WINDOWS 4 - -#elif defined(__x86_64__) - -#define KALLOC_MINSIZE 16 /* minimum allocation size */ -#define KALLOC_LOG2_MINALIGN 4 /* log2 minimum alignment */ - -#define LINEAR_KERNEL_ADDRESS ((vm_offset_t) 0x00000000) - -#define VM_MIN_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0xFFFFFF8000000000UL) -#define VM_MAX_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0xFFFFFF801FFFFFFFUL) - -#define NCOPY_WINDOWS 0 - - -#else -#error unsupported architecture -#endif - -/* - * Conversion between 80386 pages and VM pages - */ - -#define trunc_i386_to_vm(p) (atop(trunc_page(i386_ptob(p)))) -#define round_i386_to_vm(p) (atop(round_page(i386_ptob(p)))) -#define vm_to_i386(p) (i386_btop(ptoa(p))) - - -#define PMAP_SET_CACHE_ATTR(mem, object, cache_attr, batch_pmap_op) \ - MACRO_BEGIN \ - pmap_set_cache_attributes((mem)->phys_page, (cache_attr)); \ - (object)->set_cache_attr = TRUE; \ - (void) batch_pmap_op; \ - MACRO_END - -#define PMAP_BATCH_SET_CACHE_ATTR(object, user_page_list, cache_attr, num_pages, batch_pmap_op)\ - MACRO_BEGIN \ - (void) user_page_list; \ - (void) num_pages; \ - (void) batch_pmap_op; \ - MACRO_END - -#define IS_USERADDR64_CANONICAL(addr) \ - ((addr) < (VM_MAX_USER_PAGE_ADDRESS + PAGE_SIZE)) - -#endif /* MACH_KERNEL_PRIVATE */ - -#endif /* KERNEL_PRIVATE */ - -#endif /* _MACH_I386_VM_PARAM_H_ */ diff --git a/include/xnu/mach/i386/vm_types.h b/include/xnu/mach/i386/vm_types.h deleted file mode 100644 index ecdc42070..000000000 --- a/include/xnu/mach/i386/vm_types.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (c) 2000-2006 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@ - */ -/* - * @OSF_COPYRIGHT@ - */ -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989,1988 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 Software.Distribution@CS.CMU.EDU - * 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: vm_types.h - * Author: Avadis Tevanian, Jr. - * Date: 1985 - * - * Header file for VM data types. I386 version. - */ - -#ifndef _MACH_I386_VM_TYPES_H_ -#define _MACH_I386_VM_TYPES_H_ - -#ifndef ASSEMBLER - -#include -#include -#include - -/* - * natural_t and integer_t are Mach's legacy types for machine- - * independent integer types (unsigned, and signed, respectively). - * Their original purpose was to define other types in a machine/ - * compiler independent way. - * - * They also had an implicit "same size as pointer" characteristic - * to them (i.e. Mach's traditional types are very ILP32 or ILP64 - * centric). We support x86 ABIs that do not follow either of - * these models (specifically LP64). Therefore, we had to make a - * choice between making these types scale with pointers or stay - * tied to integers. Because their use is predominantly tied to - * to the size of an integer, we are keeping that association and - * breaking free from pointer size guarantees. - * - * New use of these types is discouraged. - */ -typedef __darwin_natural_t natural_t; -typedef int integer_t; - -/* - * A vm_offset_t is a type-neutral pointer, - * e.g. an offset into a virtual memory space. - */ -#ifdef __LP64__ -typedef uintptr_t vm_offset_t; -#else /* __LP64__ */ -typedef natural_t vm_offset_t; -#endif /* __LP64__ */ - -/* - * A vm_size_t is the proper type for e.g. - * expressing the difference between two - * vm_offset_t entities. - */ -#ifdef __LP64__ -typedef uintptr_t vm_size_t; -#else /* __LP64__ */ -typedef natural_t vm_size_t; -#endif /* __LP64__ */ - -/* - * This new type is independent of a particular vm map's - * implementation size - and represents appropriate types - * for all possible maps. This is used for interfaces - * where the size of the map is not known - or we don't - * want to have to distinguish. - */ -typedef uint64_t mach_vm_address_t; -typedef uint64_t mach_vm_offset_t; -typedef uint64_t mach_vm_size_t; - -typedef uint64_t vm_map_offset_t; -typedef uint64_t vm_map_address_t; -typedef uint64_t vm_map_size_t; - -typedef mach_vm_address_t mach_port_context_t; - -#ifdef MACH_KERNEL_PRIVATE - -#if VM32_SUPPORT - -/* - * These are types used internal to Mach to implement the - * legacy 32-bit VM APIs published by the kernel. - */ -typedef uint32_t vm32_address_t; -typedef uint32_t vm32_offset_t; -typedef uint32_t vm32_size_t; - -#endif /* VM32_SUPPORT */ - -#endif /* MACH_KERNEL_PRIVATE */ - -#endif /* ASSEMBLER */ - -/* - * If composing messages by hand (please do not) - */ -#define MACH_MSG_TYPE_INTEGER_T MACH_MSG_TYPE_INTEGER_32 - -#endif /* _MACH_I386_VM_TYPES_H_ */ diff --git a/include/xnu/mach/kern_return.h b/include/xnu/mach/kern_return.h deleted file mode 100644 index da73236e3..000000000 --- a/include/xnu/mach/kern_return.h +++ /dev/null @@ -1,322 +0,0 @@ -/* - * 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@ - */ -/* - * @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 Software.Distribution@CS.CMU.EDU - * 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. - * - */ - -#ifndef _MACH_KERN_RETURN_H_ -#define _MACH_KERN_RETURN_H_ - -#include - -#define KERN_SUCCESS 0 - -#define KERN_INVALID_ADDRESS 1 - /* Specified address is not currently valid. - */ - -#define KERN_PROTECTION_FAILURE 2 - /* Specified memory is valid, but does not permit the - * required forms of access. - */ - -#define KERN_NO_SPACE 3 - /* The address range specified is already in use, or - * no address range of the size specified could be - * found. - */ - -#define KERN_INVALID_ARGUMENT 4 - /* The function requested was not applicable to this - * type of argument, or an argument is invalid - */ - -#define KERN_FAILURE 5 - /* The function could not be performed. A catch-all. - */ - -#define KERN_RESOURCE_SHORTAGE 6 - /* A system resource could not be allocated to fulfill - * this request. This failure may not be permanent. - */ - -#define KERN_NOT_RECEIVER 7 - /* The task in question does not hold receive rights - * for the port argument. - */ - -#define KERN_NO_ACCESS 8 - /* Bogus access restriction. - */ - -#define KERN_MEMORY_FAILURE 9 - /* During a page fault, the target address refers to a - * memory object that has been destroyed. This - * failure is permanent. - */ - -#define 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. - */ - -#define KERN_ALREADY_IN_SET 11 - /* The receive right is already a member of the portset. - */ - -#define KERN_NOT_IN_SET 12 - /* The receive right is not a member of a port set. - */ - -#define KERN_NAME_EXISTS 13 - /* The name already denotes a right in the task. - */ - -#define KERN_ABORTED 14 - /* The operation was aborted. Ipc code will - * catch this and reflect it as a message error. - */ - -#define KERN_INVALID_NAME 15 - /* The name doesn't denote a right in the task. - */ - -#define KERN_INVALID_TASK 16 - /* Target task isn't an active task. - */ - -#define KERN_INVALID_RIGHT 17 - /* The name denotes a right, but not an appropriate right. - */ - -#define KERN_INVALID_VALUE 18 - /* A blatant range error. - */ - -#define KERN_UREFS_OVERFLOW 19 - /* Operation would overflow limit on user-references. - */ - -#define KERN_INVALID_CAPABILITY 20 - /* The supplied (port) capability is improper. - */ - -#define KERN_RIGHT_EXISTS 21 - /* The task already has send or receive rights - * for the port under another name. - */ - -#define KERN_INVALID_HOST 22 - /* Target host isn't actually a host. - */ - -#define KERN_MEMORY_PRESENT 23 - /* An attempt was made to supply "precious" data - * for memory that is already present in a - * memory object. - */ - -#define 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. - */ - -#define 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. - */ - -#define KERN_INVALID_PROCESSOR_SET 26 - /* An argument applied to assert processor set privilege - * was not a processor set control port. - */ - -#define KERN_POLICY_LIMIT 27 - /* The specified scheduling attributes exceed the thread's - * limits. - */ - -#define KERN_INVALID_POLICY 28 - /* The specified scheduling policy is not currently - * enabled for the processor set. - */ - -#define KERN_INVALID_OBJECT 29 - /* The external memory manager failed to initialize the - * memory object. - */ - -#define KERN_ALREADY_WAITING 30 - /* A thread is attempting to wait for an event for which - * there is already a waiting thread. - */ - -#define KERN_DEFAULT_SET 31 - /* An attempt was made to destroy the default processor - * set. - */ - -#define 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. - */ - -#define KERN_INVALID_LEDGER 33 - /* A ledger was required but not supplied. - */ - -#define KERN_INVALID_MEMORY_CONTROL 34 - /* The port was not a memory cache control port. - */ - -#define KERN_INVALID_SECURITY 35 - /* An argument supplied to assert security privilege - * was not a host security port. - */ - -#define KERN_NOT_DEPRESSED 36 - /* thread_depress_abort was called on a thread which - * was not currently depressed. - */ - -#define KERN_TERMINATED 37 - /* Object has been terminated and is no longer available - */ - -#define KERN_LOCK_SET_DESTROYED 38 - /* Lock set has been destroyed and is no longer available. - */ - -#define KERN_LOCK_UNSTABLE 39 - /* The thread holding the lock terminated before releasing - * the lock - */ - -#define KERN_LOCK_OWNED 40 - /* The lock is already owned by another thread - */ - -#define KERN_LOCK_OWNED_SELF 41 - /* The lock is already owned by the calling thread - */ - -#define KERN_SEMAPHORE_DESTROYED 42 - /* Semaphore has been destroyed and is no longer available. - */ - -#define KERN_RPC_SERVER_TERMINATED 43 - /* Return from RPC indicating the target server was - * terminated before it successfully replied - */ - -#define KERN_RPC_TERMINATE_ORPHAN 44 - /* Terminate an orphaned activation. - */ - -#define KERN_RPC_CONTINUE_ORPHAN 45 - /* Allow an orphaned activation to continue executing. - */ - -#define KERN_NOT_SUPPORTED 46 - /* Empty thread activation (No thread linked to it) - */ - -#define KERN_NODE_DOWN 47 - /* Remote node down or inaccessible. - */ - -#define KERN_NOT_WAITING 48 - /* A signalled thread was not actually waiting. */ - -#define KERN_OPERATION_TIMED_OUT 49 - /* Some thread-oriented operation (semaphore_wait) timed out - */ - -#define KERN_CODESIGN_ERROR 50 - /* During a page fault, indicates that the page was rejected - * as a result of a signature check. - */ - -#define KERN_RETURN_MAX 0x100 - /* Maximum return value allowable - */ - -#endif /* _MACH_KERN_RETURN_H_ */ diff --git a/include/xnu/mach/kmod.h b/include/xnu/mach/kmod.h deleted file mode 100644 index 99449b7bf..000000000 --- a/include/xnu/mach/kmod.h +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (c) 2000-2007 Apple 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@ - */ -/* - * NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce - * support for mandatory and extensible security protections. This notice - * is included in support of clause 2.2 (b) of the Apple Public License, - * Version 2.0. - */ - -#ifndef _MACH_KMOD_H_ -#define _MACH_KMOD_H_ - -#include -#include - -#include - -__BEGIN_DECLS - -#if PRAGMA_MARK -#pragma mark Basic macros & typedefs -#endif -/*********************************************************************** -* Basic macros & typedefs -***********************************************************************/ -#define KMOD_MAX_NAME 64 - -#define KMOD_RETURN_SUCCESS KERN_SUCCESS -#define KMOD_RETURN_FAILURE KERN_FAILURE - -typedef int kmod_t; - -struct kmod_info; -typedef kern_return_t kmod_start_func_t(struct kmod_info * ki, void * data); -typedef kern_return_t kmod_stop_func_t(struct kmod_info * ki, void * data); - -#if PRAGMA_MARK -#pragma mark Structure definitions -#endif -/*********************************************************************** -* Structure definitions -* -* All structures must be #pragma pack(4). -***********************************************************************/ -#pragma pack(4) - -/* Run-time struct only; never saved to a file */ -typedef struct kmod_reference { - struct kmod_reference * next; - struct kmod_info * info; -} kmod_reference_t; - -/*********************************************************************** -* Warning: Any changes to the kmod_info structure affect the -* KMOD_..._DECL macros below. -***********************************************************************/ - -/* The kmod_info_t structure is only safe to use inside the running - * kernel. If you need to work with a kmod_info_t structure outside - * the kernel, please use the compatibility definitions below. - */ -typedef struct kmod_info { - struct kmod_info * next; - int32_t info_version; // version of this structure - uint32_t id; - char name[KMOD_MAX_NAME]; - char version[KMOD_MAX_NAME]; - int32_t reference_count; // # linkage refs to this - kmod_reference_t * reference_list; // who this refs (links on) - vm_address_t address; // starting address - vm_size_t size; // total size - vm_size_t hdr_size; // unwired hdr size - kmod_start_func_t * start; - kmod_stop_func_t * stop; -} kmod_info_t; - -/* A compatibility definition of kmod_info_t for 32-bit kexts. - */ -typedef struct kmod_info_32_v1 { - uint32_t next_addr; - int32_t info_version; - uint32_t id; - uint8_t name[KMOD_MAX_NAME]; - uint8_t version[KMOD_MAX_NAME]; - int32_t reference_count; - uint32_t reference_list_addr; - uint32_t address; - uint32_t size; - uint32_t hdr_size; - uint32_t start_addr; - uint32_t stop_addr; -} kmod_info_32_v1_t; - -/* A compatibility definition of kmod_info_t for 64-bit kexts. - */ -typedef struct kmod_info_64_v1 { - uint64_t next_addr; - int32_t info_version; - uint32_t id; - uint8_t name[KMOD_MAX_NAME]; - uint8_t version[KMOD_MAX_NAME]; - int32_t reference_count; - uint64_t reference_list_addr; - uint64_t address; - uint64_t size; - uint64_t hdr_size; - uint64_t start_addr; - uint64_t stop_addr; -} kmod_info_64_v1_t; - -#pragma pack() - -#if PRAGMA_MARK -#pragma mark Kmod structure declaration macros -#endif -/*********************************************************************** -* Kmod structure declaration macros -***********************************************************************/ -#define KMOD_INFO_NAME kmod_info -#define KMOD_INFO_VERSION 1 - -#define KMOD_DECL(name, version) \ - static kmod_start_func_t name ## _module_start; \ - static kmod_stop_func_t name ## _module_stop; \ - kmod_info_t KMOD_INFO_NAME = { 0, KMOD_INFO_VERSION, -1U, \ - { #name }, { version }, -1, 0, 0, 0, 0, \ - name ## _module_start, \ - name ## _module_stop }; - -#define KMOD_EXPLICIT_DECL(name, version, start, stop) \ - kmod_info_t KMOD_INFO_NAME = { 0, KMOD_INFO_VERSION, -1U, \ - { #name }, { version }, -1, 0, 0, 0, 0, \ - start, stop }; - -#if PRAGMA_MARK -#pragma mark Kernel private declarations -#endif -/*********************************************************************** -* Kernel private declarations. -***********************************************************************/ -#ifdef KERNEL_PRIVATE - -/* Implementation now in libkern/OSKextLib.cpp. */ -extern void kmod_panic_dump(vm_offset_t * addr, unsigned int dump_cnt); - -#if CONFIG_DTRACE -/* - * DTrace can take a flag indicating whether it should instrument - * probes immediately based on kernel symbols. This per kext - * flag overrides system mode in dtrace_modload(). - */ -#define KMOD_DTRACE_FORCE_INIT 0x01 -#endif /* CONFIG_DTRACE */ - -#endif /* KERNEL_PRIVATE */ - - -#if PRAGMA_MARK -#pragma mark Obsolete kmod stuff -#endif -/*********************************************************************** -* These 3 should be dropped but they're referenced by MIG declarations. -***********************************************************************/ -typedef void * kmod_args_t; -typedef int kmod_control_flavor_t; -typedef kmod_info_t * kmod_info_array_t; - -__END_DECLS - -#endif /* _MACH_KMOD_H_ */ diff --git a/include/xnu/mach/mach.h b/include/xnu/mach/mach.h deleted file mode 100644 index df61ab89a..000000000 --- a/include/xnu/mach/mach.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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@ - */ -/* - * Mach Operating System - * Copyright (c) 1989 Carnegie-Mellon University - * All rights reserved. The CMU software License Agreement specifies - * the terms and conditions for use and redistribution. - */ -/* - * Includes all the types that a normal user - * of Mach programs should need - */ - -#ifndef _MACH_H_ -#define _MACH_H_ - -#include -#include -#include -#include - -#endif /* _MACH_H_ */ diff --git a/include/xnu/mach/mach_interface.h b/include/xnu/mach/mach_interface.h deleted file mode 100644 index 12218bd01..000000000 --- a/include/xnu/mach/mach_interface.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2000-2010 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@ - */ - -#ifndef _MACH_INTERFACE_H_ -#define _MACH_INTERFACE_H_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef XNU_KERNEL_PRIVATE -/* - * Raw EMMI interfaces are private to xnu - * and subject to change. - */ -#include -#include -#include -#include -#endif - -#endif /* _MACH_INTERFACE_H_ */ diff --git a/include/xnu/mach/mach_param.h b/include/xnu/mach/mach_param.h deleted file mode 100644 index e4ead673e..000000000 --- a/include/xnu/mach/mach_param.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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@ - */ -/* - * @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 Software.Distribution@CS.CMU.EDU - * 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/mach_param.h - * Author: Avadis Tevanian, Jr., Michael Wayne Young - * Date: 1986 - * - * Mach system sizing parameters - */ - -#ifndef _MACH_MACH_PARAM_H_ -#define _MACH_MACH_PARAM_H_ - -/* Number of "registered" ports */ - -#define TASK_PORT_REGISTER_MAX 3 - -#endif /* _MACH_MACH_PARAM_H_ */ diff --git a/include/xnu/mach/mach_semaphore.h b/include/xnu/mach/mach_semaphore.h deleted file mode 100644 index 064e977d3..000000000 --- a/include/xnu/mach/mach_semaphore.h +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) 2000-2008 Apple 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@ - */ - -#ifndef _MACH_SEMAPHORE_H_ -#define _MACH_SEMAPHORE_H_ - -#include -#include -#include -#include - -/* - * Forward Declarations - * - * The semaphore creation and deallocation routines are - * defined with the Mach task APIs in . - * - * kern_return_t semaphore_create(task_t task, - * semaphore_t *new_semaphore, - * sync_policy_t policy, - * int value); - * - * kern_return_t semaphore_destroy(task_t task, - * semaphore_t semaphore); - */ - -#include -__BEGIN_DECLS - -extern kern_return_t semaphore_signal (semaphore_t semaphore); -extern kern_return_t semaphore_signal_all (semaphore_t semaphore); - -extern kern_return_t semaphore_wait (semaphore_t semaphore); - -#ifdef KERNEL - -#ifdef __LP64__ - -#ifdef KERNEL_PRIVATE - -extern kern_return_t semaphore_timedwait (semaphore_t semaphore, - mach_timespec_t wait_time); - -#endif /* KERNEL_PRIVATE */ - -#else /* __LP64__ */ - -extern kern_return_t semaphore_timedwait (semaphore_t semaphore, - mach_timespec_t wait_time); - -#endif /* __LP64__ */ - -extern kern_return_t semaphore_wait_deadline (semaphore_t semaphore, - uint64_t deadline); -extern kern_return_t semaphore_wait_noblock (semaphore_t semaphore); - -#ifdef XNU_KERNEL_PRIVATE - -extern kern_return_t semaphore_wait_signal (semaphore_t wait_semaphore, - semaphore_t signal_semaphore); - -extern kern_return_t semaphore_timedwait_signal(semaphore_t wait_semaphore, - semaphore_t signal_semaphore, - mach_timespec_t wait_time); - -extern kern_return_t semaphore_signal_thread (semaphore_t semaphore, - thread_t thread); - -#endif /* XNU_KERNEL_PRIVATE */ - -#else /* KERNEL */ - -extern kern_return_t semaphore_timedwait (semaphore_t semaphore, - mach_timespec_t wait_time); - -extern kern_return_t semaphore_timedwait_signal(semaphore_t wait_semaphore, - semaphore_t signal_semaphore, - mach_timespec_t wait_time); - -extern kern_return_t semaphore_wait_signal (semaphore_t wait_semaphore, - semaphore_t signal_semaphore); - -extern kern_return_t semaphore_signal_thread (semaphore_t semaphore, - thread_t thread); - -#endif /* KERNEL */ - -__END_DECLS - -#ifdef PRIVATE - -#define SEMAPHORE_OPTION_NONE 0x00000000 - -#define SEMAPHORE_SIGNAL 0x00000001 -#define SEMAPHORE_WAIT 0x00000002 -#define SEMAPHORE_WAIT_ON_SIGNAL 0x00000008 - -#define SEMAPHORE_SIGNAL_TIMEOUT 0x00000010 -#define SEMAPHORE_SIGNAL_ALL 0x00000020 -#define SEMAPHORE_SIGNAL_INTERRUPT 0x00000040 /* libmach implements */ -#define SEMAPHORE_SIGNAL_PREPOST 0x00000080 - -#define SEMAPHORE_WAIT_TIMEOUT 0x00000100 -#define SEMAPHORE_WAIT_INTERRUPT 0x00000400 /* libmach implements */ - -#define SEMAPHORE_TIMEOUT_NOBLOCK 0x00100000 -#define SEMAPHORE_TIMEOUT_RELATIVE 0x00200000 - -#define SEMAPHORE_USE_SAVED_RESULT 0x01000000 /* internal use only */ -#define SEMAPHORE_SIGNAL_RELEASE 0x02000000 /* internal use only */ - -#endif /* PRIVATE */ - -#endif /* _MACH_SEMAPHORE_H_ */ - diff --git a/include/xnu/mach/mach_syscalls.h b/include/xnu/mach/mach_syscalls.h deleted file mode 100644 index 0e04e4f31..000000000 --- a/include/xnu/mach/mach_syscalls.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2000-2004 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@ - */ -/* - * @OSF_COPYRIGHT@ - */ - -#ifndef _MACH_MACH_SYSCALLS_H_ -#define _MACH_MACH_SYSCALLS_H_ - -#include - -#endif /* _MACH_MACH_SYSCALLS_H_ */ diff --git a/include/xnu/mach/mach_time.h b/include/xnu/mach/mach_time.h deleted file mode 100644 index de93d518d..000000000 --- a/include/xnu/mach/mach_time.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2001-2005 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@ - */ - -#ifndef _MACH_MACH_TIME_H_ -#define _MACH_MACH_TIME_H_ - -#include - -#include - -struct mach_timebase_info { - uint32_t numer; - uint32_t denom; -}; - -typedef struct mach_timebase_info *mach_timebase_info_t; -typedef struct mach_timebase_info mach_timebase_info_data_t; - -__BEGIN_DECLS -#ifndef KERNEL - -kern_return_t mach_timebase_info( - mach_timebase_info_t info); - -kern_return_t mach_wait_until( - uint64_t deadline); - -#endif /* KERNEL */ - -uint64_t mach_absolute_time(void); -__END_DECLS - -#endif /* _MACH_MACH_TIME_H_ */ diff --git a/include/xnu/mach/mach_traps.h b/include/xnu/mach/mach_traps.h deleted file mode 100644 index 915bf9381..000000000 --- a/include/xnu/mach/mach_traps.h +++ /dev/null @@ -1,702 +0,0 @@ -/* - * Copyright (c) 2000-2007 Apple 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@ - */ -/* - * @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 Software.Distribution@CS.CMU.EDU - * 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. - */ -/* - */ -/* - * Definitions of general Mach system traps. - * - * These are the definitions as seen from user-space. - * The kernel definitions are in . - * Kernel RPC functions are defined in . - */ - -#ifndef _MACH_MACH_TRAPS_H_ -#define _MACH_MACH_TRAPS_H_ - -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include - -__BEGIN_DECLS - -#ifndef KERNEL - -#ifdef PRIVATE - -extern mach_port_name_t mach_reply_port(void); - -extern mach_port_name_t thread_self_trap(void); - -extern mach_port_name_t host_self_trap(void); - -extern mach_msg_return_t mach_msg_trap( - mach_msg_header_t *msg, - mach_msg_option_t option, - mach_msg_size_t send_size, - mach_msg_size_t rcv_size, - mach_port_name_t rcv_name, - mach_msg_timeout_t timeout, - mach_port_name_t notify); - -extern mach_msg_return_t mach_msg_overwrite_trap( - mach_msg_header_t *msg, - mach_msg_option_t option, - mach_msg_size_t send_size, - mach_msg_size_t rcv_size, - mach_port_name_t rcv_name, - mach_msg_timeout_t timeout, - mach_port_name_t notify, - mach_msg_header_t *rcv_msg, - mach_msg_size_t rcv_limit); - -extern kern_return_t semaphore_signal_trap( - mach_port_name_t signal_name); - -extern kern_return_t semaphore_signal_all_trap( - mach_port_name_t signal_name); - -extern kern_return_t semaphore_signal_thread_trap( - mach_port_name_t signal_name, - mach_port_name_t thread_name); - -extern kern_return_t semaphore_wait_trap( - mach_port_name_t wait_name); - -extern kern_return_t semaphore_wait_signal_trap( - mach_port_name_t wait_name, - mach_port_name_t signal_name); - -extern kern_return_t semaphore_timedwait_trap( - mach_port_name_t wait_name, - unsigned int sec, - clock_res_t nsec); - -extern kern_return_t semaphore_timedwait_signal_trap( - mach_port_name_t wait_name, - mach_port_name_t signal_name, - unsigned int sec, - clock_res_t nsec); - -#endif /* PRIVATE */ - -extern kern_return_t clock_sleep_trap( - mach_port_name_t clock_name, - sleep_type_t sleep_type, - int sleep_sec, - int sleep_nsec, - mach_timespec_t *wakeup_time); - -extern kern_return_t _kernelrpc_mach_vm_allocate_trap( - mach_port_name_t target, - mach_vm_offset_t *addr, - mach_vm_size_t size, - int flags); - -extern kern_return_t _kernelrpc_mach_vm_deallocate_trap( - mach_port_name_t target, - mach_vm_address_t address, - mach_vm_size_t size -); - -extern kern_return_t _kernelrpc_mach_vm_protect_trap( - mach_port_name_t target, - mach_vm_address_t address, - mach_vm_size_t size, - boolean_t set_maximum, - vm_prot_t new_protection -); - -extern kern_return_t _kernelrpc_mach_port_allocate_trap( - mach_port_name_t target, - mach_port_right_t right, - mach_port_name_t *name -); - - -extern kern_return_t _kernelrpc_mach_port_destroy_trap( - mach_port_name_t target, - mach_port_name_t name -); - -extern kern_return_t _kernelrpc_mach_port_deallocate_trap( - mach_port_name_t target, - mach_port_name_t name -); - -extern kern_return_t _kernelrpc_mach_port_mod_refs_trap( - mach_port_name_t target, - mach_port_name_t name, - mach_port_right_t right, - mach_port_delta_t delta -); - -extern kern_return_t _kernelrpc_mach_port_move_member_trap( - mach_port_name_t target, - mach_port_name_t member, - mach_port_name_t after -); - -extern kern_return_t _kernelrpc_mach_port_insert_right_trap( - mach_port_name_t target, - mach_port_name_t name, - mach_port_name_t poly, - mach_msg_type_name_t polyPoly -); - -extern kern_return_t _kernelrpc_mach_port_insert_member_trap( - mach_port_name_t target, - mach_port_name_t name, - mach_port_name_t pset -); - -extern kern_return_t _kernelrpc_mach_port_extract_member_trap( - mach_port_name_t target, - mach_port_name_t name, - mach_port_name_t pset -); - -extern kern_return_t macx_swapon( - uint64_t filename, - int flags, - int size, - int priority); - -extern kern_return_t macx_swapoff( - uint64_t filename, - int flags); - -extern kern_return_t macx_triggers( - int hi_water, - int low_water, - int flags, - mach_port_t alert_port); - -extern kern_return_t macx_backing_store_suspend( - boolean_t suspend); - -extern kern_return_t macx_backing_store_recovery( - int pid); - -extern boolean_t swtch_pri(int pri); - -extern boolean_t swtch(void); - -extern kern_return_t thread_switch( - mach_port_name_t thread_name, - int option, - mach_msg_timeout_t option_time); - -extern mach_port_name_t task_self_trap(void); - -/* - * Obsolete interfaces. - */ - -extern kern_return_t task_for_pid( - mach_port_name_t target_tport, - int pid, - mach_port_name_t *t); - -extern kern_return_t task_name_for_pid( - mach_port_name_t target_tport, - int pid, - mach_port_name_t *tn); - -extern kern_return_t pid_for_task( - mach_port_name_t t, - int *x); - -#if !defined(__LP64__) && !defined(__arm__) -/* these should go away altogether - so no 64 legacy please */ - -extern kern_return_t map_fd( - int fd, - vm_offset_t offset, - vm_offset_t *va, - boolean_t findspace, - vm_size_t size); - -#endif /* !defined(__LP64__) && !defined(__arm__) */ - -#else /* KERNEL */ - -#ifdef XNU_KERNEL_PRIVATE - -/* Syscall data translations routines - * - * The kernel may support multiple userspace ABIs, and must use - * argument structures with elements large enough for any of them. - */ -#define PAD_(t) (sizeof(uint64_t) <= sizeof(t) \ - ? 0 : sizeof(uint64_t) - sizeof(t)) -#define PAD_ARG_8 - -#if BYTE_ORDER == LITTLE_ENDIAN -#define PADL_(t) 0 -#define PADR_(t) PAD_(t) -#else -#define PADL_(t) PAD_(t) -#define PADR_(t) 0 -#endif - -#define PAD_ARG_(arg_type, arg_name) \ - char arg_name##_l_[PADL_(arg_type)]; arg_type arg_name; char arg_name##_r_[PADR_(arg_type)]; - -/* - * To support 32-bit clients as well as 64-bit clients, argument - * structures may need to be munged to repack the arguments. All - * active architectures do this inline in the code to dispatch Mach - * traps, without calling out to the BSD system call mungers. - */ - -#if 0 /* no active architectures use this */ -void munge_w(const void *, void *); -void munge_ww(const void *, void *); -void munge_www(const void *, void *); -void munge_wwww(const void *, void *); -void munge_wwwww(const void *, void *); -void munge_wwwwww(const void *, void *); -void munge_wwwwwww(const void *, void *); -void munge_wwwwwwww(const void *, void *); -void munge_d(const void *, void *); -void munge_dd(const void *, void *); -void munge_ddd(const void *, void *); -void munge_dddd(const void *, void *); -void munge_ddddd(const void *, void *); -void munge_dddddd(const void *, void *); -void munge_ddddddd(const void *, void *); -void munge_dddddddd(const void *, void *); -void munge_l(const void *, void *); -void munge_lw(const void *, void *); -void munge_lwww(const void *, void *); -void munge_wl(const void *, void *); -void munge_wlw(const void *, void *); -void munge_wwwl(const void *, void *); -void munge_wwwwl(const void *, void *); -void munge_wwwwwl(const void *, void *); -#endif /* 0 */ - -struct kern_invalid_args { - int32_t dummy; -}; -extern kern_return_t kern_invalid( - struct kern_invalid_args *args); - -struct mach_reply_port_args { - int32_t dummy; -}; -extern mach_port_name_t mach_reply_port( - struct mach_reply_port_args *args); - -struct thread_self_trap_args { - int32_t dummy; -}; -extern mach_port_name_t thread_self_trap( - struct thread_self_trap_args *args); - -struct task_self_trap_args { - int32_t dummy; -}; -extern mach_port_name_t task_self_trap( - struct task_self_trap_args *args); - -struct host_self_trap_args { - int32_t dummy; -}; -extern mach_port_name_t host_self_trap( - struct host_self_trap_args *args); - -struct mach_msg_overwrite_trap_args { - PAD_ARG_(user_addr_t, msg); - PAD_ARG_(mach_msg_option_t, option); - PAD_ARG_(mach_msg_size_t, send_size); - PAD_ARG_(mach_msg_size_t, rcv_size); - PAD_ARG_(mach_port_name_t, rcv_name); - PAD_ARG_(mach_msg_timeout_t, timeout); - PAD_ARG_(mach_port_name_t, notify); - PAD_ARG_8 - PAD_ARG_(user_addr_t, rcv_msg); /* Unused on mach_msg_trap */ -}; -extern mach_msg_return_t mach_msg_trap( - struct mach_msg_overwrite_trap_args *args); -extern mach_msg_return_t mach_msg_overwrite_trap( - struct mach_msg_overwrite_trap_args *args); - -struct semaphore_signal_trap_args { - PAD_ARG_(mach_port_name_t, signal_name); -}; -extern kern_return_t semaphore_signal_trap( - struct semaphore_signal_trap_args *args); - -struct semaphore_signal_all_trap_args { - PAD_ARG_(mach_port_name_t, signal_name); -}; -extern kern_return_t semaphore_signal_all_trap( - struct semaphore_signal_all_trap_args *args); - -struct semaphore_signal_thread_trap_args { - PAD_ARG_(mach_port_name_t, signal_name); - PAD_ARG_(mach_port_name_t, thread_name); -}; -extern kern_return_t semaphore_signal_thread_trap( - struct semaphore_signal_thread_trap_args *args); - -struct semaphore_wait_trap_args { - PAD_ARG_(mach_port_name_t, wait_name); -}; -extern kern_return_t semaphore_wait_trap( - struct semaphore_wait_trap_args *args); - -struct semaphore_wait_signal_trap_args { - PAD_ARG_(mach_port_name_t, wait_name); - PAD_ARG_(mach_port_name_t, signal_name); -}; -extern kern_return_t semaphore_wait_signal_trap( - struct semaphore_wait_signal_trap_args *args); - -struct semaphore_timedwait_trap_args { - PAD_ARG_(mach_port_name_t, wait_name); - PAD_ARG_(unsigned int, sec); - PAD_ARG_(clock_res_t, nsec); -}; -extern kern_return_t semaphore_timedwait_trap( - struct semaphore_timedwait_trap_args *args); - -struct semaphore_timedwait_signal_trap_args { - PAD_ARG_(mach_port_name_t, wait_name); - PAD_ARG_(mach_port_name_t, signal_name); - PAD_ARG_(unsigned int, sec); - PAD_ARG_(clock_res_t, nsec); -}; -extern kern_return_t semaphore_timedwait_signal_trap( - struct semaphore_timedwait_signal_trap_args *args); - -#if !defined(CONFIG_EMBEDDED) -struct map_fd_args { - PAD_ARG_(int, fd); - PAD_ARG_(vm_offset_t, offset); - PAD_ARG_(vm_offset_t *, va); - PAD_ARG_(boolean_t, findspace); - PAD_ARG_(vm_size_t, size); -}; -extern kern_return_t map_fd( - struct map_fd_args *args); -#endif /* !defined(CONFIG_EMBEDDED) */ - -struct task_for_pid_args { - PAD_ARG_(mach_port_name_t, target_tport); - PAD_ARG_(int, pid); - PAD_ARG_(user_addr_t, t); -}; -extern kern_return_t task_for_pid( - struct task_for_pid_args *args); - -struct task_name_for_pid_args { - PAD_ARG_(mach_port_name_t, target_tport); - PAD_ARG_(int, pid); - PAD_ARG_(user_addr_t, t); -}; -extern kern_return_t task_name_for_pid( - struct task_name_for_pid_args *args); - -struct pid_for_task_args { - PAD_ARG_(mach_port_name_t, t); - PAD_ARG_(user_addr_t, pid); -}; -extern kern_return_t pid_for_task( - struct pid_for_task_args *args); - -struct macx_swapon_args { - PAD_ARG_(uint64_t, filename); - PAD_ARG_(int, flags); - PAD_ARG_(int, size); - PAD_ARG_(int, priority); -}; -extern kern_return_t macx_swapon( - struct macx_swapon_args *args); - -struct macx_swapoff_args { - PAD_ARG_(uint64_t, filename); - PAD_ARG_(int, flags); -}; -extern kern_return_t macx_swapoff( - struct macx_swapoff_args *args); - -struct macx_triggers_args { - PAD_ARG_(int, hi_water); - PAD_ARG_(int, low_water); - PAD_ARG_(int, flags); - PAD_ARG_(mach_port_t, alert_port); -}; -extern kern_return_t macx_triggers( - struct macx_triggers_args *args); - -struct macx_backing_store_suspend_args { - PAD_ARG_(boolean_t, suspend); -}; -extern kern_return_t macx_backing_store_suspend( - struct macx_backing_store_suspend_args *args); - -struct macx_backing_store_recovery_args { - PAD_ARG_(int, pid); -}; -extern kern_return_t macx_backing_store_recovery( - struct macx_backing_store_recovery_args *args); - -struct swtch_pri_args { - PAD_ARG_(int, pri); -}; -extern boolean_t swtch_pri( - struct swtch_pri_args *args); - -struct pfz_exit_args { - int32_t dummy; -}; -extern kern_return_t pfz_exit( - struct pfz_exit_args *args); - -struct swtch_args { - int32_t dummy; -}; -extern boolean_t swtch( - struct swtch_args *args); - -struct clock_sleep_trap_args{ - PAD_ARG_(mach_port_name_t, clock_name); - PAD_ARG_(sleep_type_t, sleep_type); - PAD_ARG_(int, sleep_sec); - PAD_ARG_(int, sleep_nsec); - PAD_ARG_(user_addr_t, wakeup_time); -}; -extern kern_return_t clock_sleep_trap( - struct clock_sleep_trap_args *args); - -struct thread_switch_args { - PAD_ARG_(mach_port_name_t, thread_name); - PAD_ARG_(int, option); - PAD_ARG_(mach_msg_timeout_t, option_time); -}; -extern kern_return_t thread_switch( - struct thread_switch_args *args); - -struct mach_timebase_info_trap_args { - PAD_ARG_(user_addr_t, info); -}; -extern kern_return_t mach_timebase_info_trap( - struct mach_timebase_info_trap_args *args); - -struct mach_wait_until_trap_args { - PAD_ARG_(uint64_t, deadline); -}; -extern kern_return_t mach_wait_until_trap( - struct mach_wait_until_trap_args *args); - -struct mk_timer_create_trap_args { - int32_t dummy; -}; -extern mach_port_name_t mk_timer_create_trap( - struct mk_timer_create_trap_args *args); - -struct mk_timer_destroy_trap_args { - PAD_ARG_(mach_port_name_t, name); -}; -extern kern_return_t mk_timer_destroy_trap( - struct mk_timer_destroy_trap_args *args); - -struct mk_timer_arm_trap_args { - PAD_ARG_(mach_port_name_t, name); - PAD_ARG_(uint64_t, expire_time); -}; -extern kern_return_t mk_timer_arm_trap( - struct mk_timer_arm_trap_args *args); - -struct mk_timer_cancel_trap_args { - PAD_ARG_(mach_port_name_t, name); - PAD_ARG_(user_addr_t, result_time); -}; -extern kern_return_t mk_timer_cancel_trap( - struct mk_timer_cancel_trap_args *args); - -struct _kernelrpc_mach_vm_allocate_trap_args { - PAD_ARG_(mach_port_name_t, target); /* 1 word */ - PAD_ARG_(user_addr_t, addr); /* 1 word */ - PAD_ARG_(mach_vm_size_t, size); /* 2 words */ - PAD_ARG_(int, flags); /* 1 word */ -}; /* Total: 5 */ - -extern kern_return_t _kernelrpc_mach_vm_allocate_trap( - struct _kernelrpc_mach_vm_allocate_trap_args *args); - -struct _kernelrpc_mach_vm_deallocate_args { - PAD_ARG_(mach_port_name_t, target); /* 1 word */ - PAD_ARG_(mach_vm_address_t, address); /* 2 words */ - PAD_ARG_(mach_vm_size_t, size); /* 2 words */ -}; /* Total: 5 */ -extern kern_return_t _kernelrpc_mach_vm_deallocate_trap( - struct _kernelrpc_mach_vm_deallocate_args *args); - -struct _kernelrpc_mach_vm_protect_args { - PAD_ARG_(mach_port_name_t, target); /* 1 word */ - PAD_ARG_(mach_vm_address_t, address); /* 2 words */ - PAD_ARG_(mach_vm_size_t, size); /* 2 words */ - PAD_ARG_(boolean_t, set_maximum); /* 1 word */ - PAD_ARG_(vm_prot_t, new_protection); /* 1 word */ -}; /* Total: 7 */ -extern kern_return_t _kernelrpc_mach_vm_protect_trap( - struct _kernelrpc_mach_vm_protect_args *args); - -struct _kernelrpc_mach_port_allocate_args { - PAD_ARG_(mach_port_name_t, target); - PAD_ARG_(mach_port_right_t, right); - PAD_ARG_(user_addr_t, name); -}; -extern kern_return_t _kernelrpc_mach_port_allocate_trap( - struct _kernelrpc_mach_port_allocate_args *args); - - -struct _kernelrpc_mach_port_destroy_args { - PAD_ARG_(mach_port_name_t, target); - PAD_ARG_(mach_port_name_t, name); -}; -extern kern_return_t _kernelrpc_mach_port_destroy_trap( - struct _kernelrpc_mach_port_destroy_args *args); - -struct _kernelrpc_mach_port_deallocate_args { - PAD_ARG_(mach_port_name_t, target); - PAD_ARG_(mach_port_name_t, name); -}; -extern kern_return_t _kernelrpc_mach_port_deallocate_trap( - struct _kernelrpc_mach_port_deallocate_args *args); - -struct _kernelrpc_mach_port_mod_refs_args { - PAD_ARG_(mach_port_name_t, target); - PAD_ARG_(mach_port_name_t, name); - PAD_ARG_(mach_port_right_t, right); - PAD_ARG_(mach_port_delta_t, delta); -}; -extern kern_return_t _kernelrpc_mach_port_mod_refs_trap( - struct _kernelrpc_mach_port_mod_refs_args *args); - -struct _kernelrpc_mach_port_move_member_args { - PAD_ARG_(mach_port_name_t, target); - PAD_ARG_(mach_port_name_t, member); - PAD_ARG_(mach_port_name_t, after); -}; -extern kern_return_t _kernelrpc_mach_port_move_member_trap( - struct _kernelrpc_mach_port_move_member_args *args); - -struct _kernelrpc_mach_port_insert_right_args { - PAD_ARG_(mach_port_name_t, target); - PAD_ARG_(mach_port_name_t, name); - PAD_ARG_(mach_port_name_t, poly); - PAD_ARG_(mach_msg_type_name_t, polyPoly); -}; -extern kern_return_t _kernelrpc_mach_port_insert_right_trap( - struct _kernelrpc_mach_port_insert_right_args *args); - -struct _kernelrpc_mach_port_insert_member_args { - PAD_ARG_(mach_port_name_t, target); - PAD_ARG_(mach_port_name_t, name); - PAD_ARG_(mach_port_name_t, pset); -}; -extern kern_return_t _kernelrpc_mach_port_insert_member_trap( - struct _kernelrpc_mach_port_insert_member_args *args); - -struct _kernelrpc_mach_port_extract_member_args { - PAD_ARG_(mach_port_name_t, target); - PAD_ARG_(mach_port_name_t, name); - PAD_ARG_(mach_port_name_t, pset); -}; -extern kern_return_t _kernelrpc_mach_port_extract_member_trap( - struct _kernelrpc_mach_port_extract_member_args *args); - -/* not published to LP64 clients yet */ -struct iokit_user_client_trap_args { - PAD_ARG_(void *, userClientRef); - PAD_ARG_(uint32_t, index); - PAD_ARG_(void *, p1); - PAD_ARG_(void *, p2); - PAD_ARG_(void *, p3); - PAD_ARG_(void *, p4); - PAD_ARG_(void *, p5); - PAD_ARG_8 - PAD_ARG_(void *, p6); -}; -kern_return_t iokit_user_client_trap( - struct iokit_user_client_trap_args *args); - -#undef PAD_ -#undef PADL_ -#undef PADR_ -#undef PAD_ARG_ -#undef PAD_ARG_8 - -#endif /* XNU_KERNEL_PRIVATE */ - -#endif /* KERNEL */ - -__END_DECLS - -#endif /* _MACH_MACH_TRAPS_H_ */ diff --git a/include/xnu/mach/mach_types.h b/include/xnu/mach/mach_types.h deleted file mode 100644 index 9c9a1afbb..000000000 --- a/include/xnu/mach/mach_types.h +++ /dev/null @@ -1,280 +0,0 @@ -/* - * Copyright (c) 2000-2010 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@ - */ -/* - * @OSF_COPYRIGHT@ - */ -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989,1988 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 Software.Distribution@CS.CMU.EDU - * 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. - */ -/* - */ -/* - * NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce - * support for mandatory and extensible security protections. This notice - * is included in support of clause 2.2 (b) of the Apple Public License, - * Version 2.0. - */ -/* - * File: mach/mach_types.h - * Author: Avadis Tevanian, Jr., Michael Wayne Young - * Date: 1986 - * - * Mach external interface definitions. - * - */ - -#ifndef _MACH_MACH_TYPES_H_ -#define _MACH_MACH_TYPES_H_ - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef KERNEL - -#include - -/* - * If we are in the kernel, then pick up the kernel definitions for - * the basic mach types. - */ -typedef struct task *task_t, *task_name_t; -typedef struct thread *thread_t, *thread_act_t; -typedef struct ipc_space *ipc_space_t; -typedef struct host *host_t; -typedef struct host *host_priv_t; -typedef struct host *host_security_t; -typedef struct processor *processor_t; -typedef struct processor_set *processor_set_t; -typedef struct processor_set *processor_set_control_t; -typedef struct semaphore *semaphore_t; -typedef struct lock_set *lock_set_t; -typedef struct ledger *ledger_t; -typedef struct alarm *alarm_t; -typedef struct clock *clock_serv_t; -typedef struct clock *clock_ctrl_t; - -#ifndef MACH_KERNEL_PRIVATE - -__BEGIN_DECLS - -struct task ; -struct thread ; -struct host ; -struct processor ; -struct processor_set ; -struct semaphore ; -struct lock_set ; -struct ledger ; -struct alarm ; -struct clock ; - -__END_DECLS - -#endif /* MACH_KERNEL_PRIVATE */ - -#else /* KERNEL */ - -/* - * If we are not in the kernel, then these will all be represented by - * ports at user-space. - */ -typedef mach_port_t task_t; -typedef mach_port_t task_name_t; -typedef mach_port_t thread_t; -typedef mach_port_t thread_act_t; -typedef mach_port_t ipc_space_t; -typedef mach_port_t host_t; -typedef mach_port_t host_priv_t; -typedef mach_port_t host_security_t; -typedef mach_port_t processor_t; -typedef mach_port_t processor_set_t; -typedef mach_port_t processor_set_control_t; -typedef mach_port_t semaphore_t; -typedef mach_port_t lock_set_t; -typedef mach_port_t ledger_t; -typedef mach_port_t alarm_t; -typedef mach_port_t clock_serv_t; -typedef mach_port_t clock_ctrl_t; - -#endif /* KERNEL */ - -/* - * These aren't really unique types. They are just called - * out as unique types at one point in history. So we list - * them here for compatibility. - */ -typedef processor_set_t processor_set_name_t; - -/* - * These types are just hard-coded as ports - */ -typedef mach_port_t clock_reply_t; -typedef mach_port_t bootstrap_t; -typedef mach_port_t mem_entry_name_port_t; -typedef mach_port_t exception_handler_t; -typedef exception_handler_t *exception_handler_array_t; -typedef mach_port_t vm_task_entry_t; -typedef mach_port_t io_master_t; -typedef mach_port_t UNDServerRef; - -/* - * Mig doesn't translate the components of an array. - * For example, Mig won't use the thread_t translations - * to translate a thread_array_t argument. So, these definitions - * are not completely accurate at the moment for other kernel - * components. - */ -typedef task_t *task_array_t; -typedef thread_t *thread_array_t; -typedef processor_set_t *processor_set_array_t; -typedef processor_set_t *processor_set_name_array_t; -typedef processor_t *processor_array_t; -typedef thread_act_t *thread_act_array_t; -typedef ledger_t *ledger_array_t; - -/* - * However the real mach_types got declared, we also have to declare - * types with "port" in the name for compatability with the way OSF - * had declared the user interfaces at one point. Someday these should - * go away. - */ -typedef task_t task_port_t; -typedef task_array_t task_port_array_t; -typedef thread_t thread_port_t; -typedef thread_array_t thread_port_array_t; -typedef ipc_space_t ipc_space_port_t; -typedef host_t host_name_t; -typedef host_t host_name_port_t; -typedef processor_set_t processor_set_port_t; -typedef processor_set_t processor_set_name_port_t; -typedef processor_set_array_t processor_set_name_port_array_t; -typedef processor_set_t processor_set_control_port_t; -typedef processor_t processor_port_t; -typedef processor_array_t processor_port_array_t; -typedef thread_act_t thread_act_port_t; -typedef thread_act_array_t thread_act_port_array_t; -typedef semaphore_t semaphore_port_t; -typedef lock_set_t lock_set_port_t; -typedef ledger_t ledger_port_t; -typedef ledger_array_t ledger_port_array_t; -typedef alarm_t alarm_port_t; -typedef clock_serv_t clock_serv_port_t; -typedef clock_ctrl_t clock_ctrl_port_t; -typedef exception_handler_t exception_port_t; -typedef exception_handler_array_t exception_port_arrary_t; - - -#define TASK_NULL ((task_t) 0) -#define TASK_NAME_NULL ((task_name_t) 0) -#define THREAD_NULL ((thread_t) 0) -#define TID_NULL ((uint64_t) 0) -#define THR_ACT_NULL ((thread_act_t) 0) -#define IPC_SPACE_NULL ((ipc_space_t) 0) -#define HOST_NULL ((host_t) 0) -#define HOST_PRIV_NULL ((host_priv_t)0) -#define HOST_SECURITY_NULL ((host_security_t)0) -#define PROCESSOR_SET_NULL ((processor_set_t) 0) -#define PROCESSOR_NULL ((processor_t) 0) -#define SEMAPHORE_NULL ((semaphore_t) 0) -#define LOCK_SET_NULL ((lock_set_t) 0) -#define LEDGER_NULL ((ledger_t) 0) -#define ALARM_NULL ((alarm_t) 0) -#define CLOCK_NULL ((clock_t) 0) -#define UND_SERVER_NULL ((UNDServerRef) 0) - -/* DEPRECATED */ -typedef natural_t ledger_item_t; -#define LEDGER_ITEM_INFINITY ((ledger_item_t) (~0)) - -typedef int64_t ledger_amount_t; -#define LEDGER_LIMIT_INFINITY ((ledger_amount_t)(((uint64_t)1 << 63) - 1)) - -typedef mach_vm_offset_t *emulation_vector_t; -typedef char *user_subsystem_t; - -typedef char *labelstr_t; -/* - * Backwards compatibility, for those programs written - * before mach/{std,mach}_types.{defs,h} were set up. - */ -#include - -#endif /* _MACH_MACH_TYPES_H_ */ diff --git a/include/xnu/mach/machine.h b/include/xnu/mach/machine.h deleted file mode 100644 index 57a0c28e6..000000000 --- a/include/xnu/mach/machine.h +++ /dev/null @@ -1,397 +0,0 @@ -/* - * Copyright (c) 2000-2007 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@ - */ -/* - * 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 Software.Distribution@CS.CMU.EDU - * 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: machine.h - * Author: Avadis Tevanian, Jr. - * Date: 1986 - * - * Machine independent machine abstraction. - */ - -#ifndef _MACH_MACHINE_H_ -#define _MACH_MACHINE_H_ - -#ifndef __ASSEMBLER__ - -#include -#include -#include - -typedef integer_t cpu_type_t; -typedef integer_t cpu_subtype_t; -typedef integer_t cpu_threadtype_t; - -#define CPU_STATE_MAX 4 - -#define CPU_STATE_USER 0 -#define CPU_STATE_SYSTEM 1 -#define CPU_STATE_IDLE 2 -#define CPU_STATE_NICE 3 - -#ifdef KERNEL_PRIVATE - -#include - -__BEGIN_DECLS -cpu_type_t cpu_type(void); - -cpu_subtype_t cpu_subtype(void); - -cpu_threadtype_t cpu_threadtype(void); -__END_DECLS - -#ifdef MACH_KERNEL_PRIVATE - -struct machine_info { - integer_t major_version; /* kernel major version id */ - integer_t minor_version; /* kernel minor version id */ - integer_t max_cpus; /* max number of CPUs possible */ - uint32_t memory_size; /* size of memory in bytes, capped at 2 GB */ - uint64_t max_mem; /* actual size of physical memory */ - uint32_t physical_cpu; /* number of physical CPUs now available */ - integer_t physical_cpu_max; /* max number of physical CPUs possible */ - uint32_t logical_cpu; /* number of logical cpu now available */ - integer_t logical_cpu_max; /* max number of physical CPUs possible */ -}; - -typedef struct machine_info *machine_info_t; -typedef struct machine_info machine_info_data_t; - -extern struct machine_info machine_info; - -__BEGIN_DECLS -cpu_type_t slot_type( - int slot_num); - -cpu_subtype_t slot_subtype( - int slot_num); - -cpu_threadtype_t slot_threadtype( - int slot_num); -__END_DECLS - -#endif /* MACH_KERNEL_PRIVATE */ -#endif /* KERNEL_PRIVATE */ - - -/* - * Capability bits used in the definition of cpu_type. - */ -#define CPU_ARCH_MASK 0xff000000 /* mask for architecture bits */ -#define CPU_ARCH_ABI64 0x01000000 /* 64 bit ABI */ - -/* - * Machine types known by all. - */ - -#define CPU_TYPE_ANY ((cpu_type_t) -1) - -#define CPU_TYPE_VAX ((cpu_type_t) 1) -/* skip ((cpu_type_t) 2) */ -/* skip ((cpu_type_t) 3) */ -/* skip ((cpu_type_t) 4) */ -/* skip ((cpu_type_t) 5) */ -#define CPU_TYPE_MC680x0 ((cpu_type_t) 6) -#define CPU_TYPE_X86 ((cpu_type_t) 7) -#define CPU_TYPE_I386 CPU_TYPE_X86 /* compatibility */ -#define CPU_TYPE_X86_64 (CPU_TYPE_X86 | CPU_ARCH_ABI64) - -/* skip CPU_TYPE_MIPS ((cpu_type_t) 8) */ -/* skip ((cpu_type_t) 9) */ -#define CPU_TYPE_MC98000 ((cpu_type_t) 10) -#define CPU_TYPE_HPPA ((cpu_type_t) 11) -#define CPU_TYPE_ARM ((cpu_type_t) 12) -#define CPU_TYPE_MC88000 ((cpu_type_t) 13) -#define CPU_TYPE_SPARC ((cpu_type_t) 14) -#define CPU_TYPE_I860 ((cpu_type_t) 15) -/* skip CPU_TYPE_ALPHA ((cpu_type_t) 16) */ -/* skip ((cpu_type_t) 17) */ -#define CPU_TYPE_POWERPC ((cpu_type_t) 18) -#define CPU_TYPE_POWERPC64 (CPU_TYPE_POWERPC | CPU_ARCH_ABI64) - -/* - * Machine subtypes (these are defined here, instead of in a machine - * dependent directory, so that any program can get all definitions - * regardless of where is it compiled). - */ - -/* - * Capability bits used in the definition of cpu_subtype. - */ -#define CPU_SUBTYPE_MASK 0xff000000 /* mask for feature flags */ -#define CPU_SUBTYPE_LIB64 0x80000000 /* 64 bit libraries */ - - -/* - * Object files that are hand-crafted to run on any - * implementation of an architecture are tagged with - * CPU_SUBTYPE_MULTIPLE. This functions essentially the same as - * the "ALL" subtype of an architecture except that it allows us - * to easily find object files that may need to be modified - * whenever a new implementation of an architecture comes out. - * - * It is the responsibility of the implementor to make sure the - * software handles unsupported implementations elegantly. - */ -#define CPU_SUBTYPE_MULTIPLE ((cpu_subtype_t) -1) -#define CPU_SUBTYPE_LITTLE_ENDIAN ((cpu_subtype_t) 0) -#define CPU_SUBTYPE_BIG_ENDIAN ((cpu_subtype_t) 1) - -/* - * Machine threadtypes. - * This is none - not defined - for most machine types/subtypes. - */ -#define CPU_THREADTYPE_NONE ((cpu_threadtype_t) 0) - -/* - * VAX subtypes (these do *not* necessary conform to the actual cpu - * ID assigned by DEC available via the SID register). - */ - -#define CPU_SUBTYPE_VAX_ALL ((cpu_subtype_t) 0) -#define CPU_SUBTYPE_VAX780 ((cpu_subtype_t) 1) -#define CPU_SUBTYPE_VAX785 ((cpu_subtype_t) 2) -#define CPU_SUBTYPE_VAX750 ((cpu_subtype_t) 3) -#define CPU_SUBTYPE_VAX730 ((cpu_subtype_t) 4) -#define CPU_SUBTYPE_UVAXI ((cpu_subtype_t) 5) -#define CPU_SUBTYPE_UVAXII ((cpu_subtype_t) 6) -#define CPU_SUBTYPE_VAX8200 ((cpu_subtype_t) 7) -#define CPU_SUBTYPE_VAX8500 ((cpu_subtype_t) 8) -#define CPU_SUBTYPE_VAX8600 ((cpu_subtype_t) 9) -#define CPU_SUBTYPE_VAX8650 ((cpu_subtype_t) 10) -#define CPU_SUBTYPE_VAX8800 ((cpu_subtype_t) 11) -#define CPU_SUBTYPE_UVAXIII ((cpu_subtype_t) 12) - -/* - * 680x0 subtypes - * - * The subtype definitions here are unusual for historical reasons. - * NeXT used to consider 68030 code as generic 68000 code. For - * backwards compatability: - * - * CPU_SUBTYPE_MC68030 symbol has been preserved for source code - * compatability. - * - * CPU_SUBTYPE_MC680x0_ALL has been defined to be the same - * subtype as CPU_SUBTYPE_MC68030 for binary comatability. - * - * CPU_SUBTYPE_MC68030_ONLY has been added to allow new object - * files to be tagged as containing 68030-specific instructions. - */ - -#define CPU_SUBTYPE_MC680x0_ALL ((cpu_subtype_t) 1) -#define CPU_SUBTYPE_MC68030 ((cpu_subtype_t) 1) /* compat */ -#define CPU_SUBTYPE_MC68040 ((cpu_subtype_t) 2) -#define CPU_SUBTYPE_MC68030_ONLY ((cpu_subtype_t) 3) - -/* - * I386 subtypes - */ - -#define CPU_SUBTYPE_INTEL(f, m) ((cpu_subtype_t) (f) + ((m) << 4)) - -#define CPU_SUBTYPE_I386_ALL CPU_SUBTYPE_INTEL(3, 0) -#define CPU_SUBTYPE_386 CPU_SUBTYPE_INTEL(3, 0) -#define CPU_SUBTYPE_486 CPU_SUBTYPE_INTEL(4, 0) -#define CPU_SUBTYPE_486SX CPU_SUBTYPE_INTEL(4, 8) // 8 << 4 = 128 -#define CPU_SUBTYPE_586 CPU_SUBTYPE_INTEL(5, 0) -#define CPU_SUBTYPE_PENT CPU_SUBTYPE_INTEL(5, 0) -#define CPU_SUBTYPE_PENTPRO CPU_SUBTYPE_INTEL(6, 1) -#define CPU_SUBTYPE_PENTII_M3 CPU_SUBTYPE_INTEL(6, 3) -#define CPU_SUBTYPE_PENTII_M5 CPU_SUBTYPE_INTEL(6, 5) -#define CPU_SUBTYPE_CELERON CPU_SUBTYPE_INTEL(7, 6) -#define CPU_SUBTYPE_CELERON_MOBILE CPU_SUBTYPE_INTEL(7, 7) -#define CPU_SUBTYPE_PENTIUM_3 CPU_SUBTYPE_INTEL(8, 0) -#define CPU_SUBTYPE_PENTIUM_3_M CPU_SUBTYPE_INTEL(8, 1) -#define CPU_SUBTYPE_PENTIUM_3_XEON CPU_SUBTYPE_INTEL(8, 2) -#define CPU_SUBTYPE_PENTIUM_M CPU_SUBTYPE_INTEL(9, 0) -#define CPU_SUBTYPE_PENTIUM_4 CPU_SUBTYPE_INTEL(10, 0) -#define CPU_SUBTYPE_PENTIUM_4_M CPU_SUBTYPE_INTEL(10, 1) -#define CPU_SUBTYPE_ITANIUM CPU_SUBTYPE_INTEL(11, 0) -#define CPU_SUBTYPE_ITANIUM_2 CPU_SUBTYPE_INTEL(11, 1) -#define CPU_SUBTYPE_XEON CPU_SUBTYPE_INTEL(12, 0) -#define CPU_SUBTYPE_XEON_MP CPU_SUBTYPE_INTEL(12, 1) - -#define CPU_SUBTYPE_INTEL_FAMILY(x) ((x) & 15) -#define CPU_SUBTYPE_INTEL_FAMILY_MAX 15 - -#define CPU_SUBTYPE_INTEL_MODEL(x) ((x) >> 4) -#define CPU_SUBTYPE_INTEL_MODEL_ALL 0 - -/* - * X86 subtypes. - */ - -#define CPU_SUBTYPE_X86_ALL ((cpu_subtype_t)3) -#define CPU_SUBTYPE_X86_64_ALL ((cpu_subtype_t)3) -#define CPU_SUBTYPE_X86_ARCH1 ((cpu_subtype_t)4) - - -#define CPU_THREADTYPE_INTEL_HTT ((cpu_threadtype_t) 1) - -/* - * Mips subtypes. - */ - -#define CPU_SUBTYPE_MIPS_ALL ((cpu_subtype_t) 0) -#define CPU_SUBTYPE_MIPS_R2300 ((cpu_subtype_t) 1) -#define CPU_SUBTYPE_MIPS_R2600 ((cpu_subtype_t) 2) -#define CPU_SUBTYPE_MIPS_R2800 ((cpu_subtype_t) 3) -#define CPU_SUBTYPE_MIPS_R2000a ((cpu_subtype_t) 4) /* pmax */ -#define CPU_SUBTYPE_MIPS_R2000 ((cpu_subtype_t) 5) -#define CPU_SUBTYPE_MIPS_R3000a ((cpu_subtype_t) 6) /* 3max */ -#define CPU_SUBTYPE_MIPS_R3000 ((cpu_subtype_t) 7) - -/* - * MC98000 (PowerPC) subtypes - */ -#define CPU_SUBTYPE_MC98000_ALL ((cpu_subtype_t) 0) -#define CPU_SUBTYPE_MC98601 ((cpu_subtype_t) 1) - -/* - * HPPA subtypes for Hewlett-Packard HP-PA family of - * risc processors. Port by NeXT to 700 series. - */ - -#define CPU_SUBTYPE_HPPA_ALL ((cpu_subtype_t) 0) -#define CPU_SUBTYPE_HPPA_7100 ((cpu_subtype_t) 0) /* compat */ -#define CPU_SUBTYPE_HPPA_7100LC ((cpu_subtype_t) 1) - -/* - * MC88000 subtypes. - */ -#define CPU_SUBTYPE_MC88000_ALL ((cpu_subtype_t) 0) -#define CPU_SUBTYPE_MC88100 ((cpu_subtype_t) 1) -#define CPU_SUBTYPE_MC88110 ((cpu_subtype_t) 2) - -/* - * SPARC subtypes - */ -#define CPU_SUBTYPE_SPARC_ALL ((cpu_subtype_t) 0) - -/* - * I860 subtypes - */ -#define CPU_SUBTYPE_I860_ALL ((cpu_subtype_t) 0) -#define CPU_SUBTYPE_I860_860 ((cpu_subtype_t) 1) - -/* - * PowerPC subtypes - */ -#define CPU_SUBTYPE_POWERPC_ALL ((cpu_subtype_t) 0) -#define CPU_SUBTYPE_POWERPC_601 ((cpu_subtype_t) 1) -#define CPU_SUBTYPE_POWERPC_602 ((cpu_subtype_t) 2) -#define CPU_SUBTYPE_POWERPC_603 ((cpu_subtype_t) 3) -#define CPU_SUBTYPE_POWERPC_603e ((cpu_subtype_t) 4) -#define CPU_SUBTYPE_POWERPC_603ev ((cpu_subtype_t) 5) -#define CPU_SUBTYPE_POWERPC_604 ((cpu_subtype_t) 6) -#define CPU_SUBTYPE_POWERPC_604e ((cpu_subtype_t) 7) -#define CPU_SUBTYPE_POWERPC_620 ((cpu_subtype_t) 8) -#define CPU_SUBTYPE_POWERPC_750 ((cpu_subtype_t) 9) -#define CPU_SUBTYPE_POWERPC_7400 ((cpu_subtype_t) 10) -#define CPU_SUBTYPE_POWERPC_7450 ((cpu_subtype_t) 11) -#define CPU_SUBTYPE_POWERPC_970 ((cpu_subtype_t) 100) - -/* - * ARM subtypes - */ -#define CPU_SUBTYPE_ARM_ALL ((cpu_subtype_t) 0) -#define CPU_SUBTYPE_ARM_V4T ((cpu_subtype_t) 5) -#define CPU_SUBTYPE_ARM_V6 ((cpu_subtype_t) 6) -#define CPU_SUBTYPE_ARM_V5TEJ ((cpu_subtype_t) 7) -#define CPU_SUBTYPE_ARM_XSCALE ((cpu_subtype_t) 8) -#define CPU_SUBTYPE_ARM_V7 ((cpu_subtype_t) 9) -#define CPU_SUBTYPE_ARM_V7F ((cpu_subtype_t) 10) /* Cortex A9 */ -#define CPU_SUBTYPE_ARM_V7K ((cpu_subtype_t) 12) /* Kirkwood40 */ - -#endif /* !__ASSEMBLER__ */ - -/* - * CPU families (sysctl hw.cpufamily) - * - * These are meant to identify the CPU's marketing name - an - * application can map these to (possibly) localized strings. - * NB: the encodings of the CPU families are intentionally arbitrary. - * There is no ordering, and you should never try to deduce whether - * or not some feature is available based on the family. - * Use feature flags (eg, hw.optional.altivec) to test for optional - * functionality. - */ -#define CPUFAMILY_UNKNOWN 0 -#define CPUFAMILY_POWERPC_G3 0xcee41549 -#define CPUFAMILY_POWERPC_G4 0x77c184ae -#define CPUFAMILY_POWERPC_G5 0xed76d8aa -#define CPUFAMILY_INTEL_6_13 0xaa33392b -#define CPUFAMILY_INTEL_YONAH 0x73d67300 -#define CPUFAMILY_INTEL_MEROM 0x426f69ef -#define CPUFAMILY_INTEL_PENRYN 0x78ea4fbc -#define CPUFAMILY_INTEL_NEHALEM 0x6b5a4cd2 -#define CPUFAMILY_INTEL_WESTMERE 0x573b5eec -#define CPUFAMILY_INTEL_SANDYBRIDGE 0x5490b78c -#define CPUFAMILY_INTEL_IVYBRIDGE 0x1f65e835 -#define CPUFAMILY_ARM_9 0xe73283ae -#define CPUFAMILY_ARM_11 0x8ff620d8 -#define CPUFAMILY_ARM_XSCALE 0x53b005f5 -#define CPUFAMILY_ARM_13 0x0cc90e64 -#define CPUFAMILY_ARM_14 0x96077ef1 - -/* The following synonyms are deprecated: */ -#define CPUFAMILY_INTEL_6_14 CPUFAMILY_INTEL_YONAH -#define CPUFAMILY_INTEL_6_15 CPUFAMILY_INTEL_MEROM -#define CPUFAMILY_INTEL_6_23 CPUFAMILY_INTEL_PENRYN -#define CPUFAMILY_INTEL_6_26 CPUFAMILY_INTEL_NEHALEM - -#define CPUFAMILY_INTEL_CORE CPUFAMILY_INTEL_YONAH -#define CPUFAMILY_INTEL_CORE2 CPUFAMILY_INTEL_MEROM - - -#endif /* _MACH_MACHINE_H_ */ diff --git a/include/xnu/mach/machine/asm.h b/include/xnu/mach/machine/asm.h deleted file mode 100644 index 1cdbb8109..000000000 --- a/include/xnu/mach/machine/asm.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2000-2007 Apple 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@ - */ - -#ifndef _MACH_MACHINE_ASM_H -#define _MACH_MACHINE_ASM_H - -#if defined (__i386__) || defined(__x86_64__) -#include "mach/i386/asm.h" -#else -#error architecture not supported -#endif - -#endif /* _MACH_MACHINE_ASM_H */ diff --git a/include/xnu/mach/machine/boolean.h b/include/xnu/mach/machine/boolean.h deleted file mode 100644 index 63bdb52e5..000000000 --- a/include/xnu/mach/machine/boolean.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2000-2007 Apple 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@ - */ - -#ifndef _MACH_MACHINE_BOOLEAN_H_ -#define _MACH_MACHINE_BOOLEAN_H_ - -#if defined (__i386__) || defined(__x86_64__) || defined(__arm__) -#include "mach/i386/boolean.h" -#else -#error architecture not supported -#endif - -#endif /* _MACH_MACHINE_BOOLEAN_H_ */ diff --git a/include/xnu/mach/machine/exception.h b/include/xnu/mach/machine/exception.h deleted file mode 100644 index 70cfcfa74..000000000 --- a/include/xnu/mach/machine/exception.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2000-2007 Apple 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@ - */ - -#ifndef _MACH_MACHINE_EXCEPTION_H_ -#define _MACH_MACHINE_EXCEPTION_H_ - -#if defined (__i386__) || defined(__x86_64__) || defined(__arm__) -#include "mach/i386/exception.h" -#else -#error architecture not supported -#endif - -#endif /* _MACH_MACHINE_EXCEPTION_H_ */ diff --git a/include/xnu/mach/machine/kern_return.h b/include/xnu/mach/machine/kern_return.h deleted file mode 100644 index 37ec65fe0..000000000 --- a/include/xnu/mach/machine/kern_return.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2000-2007 Apple 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@ - */ - -#ifndef _MACH_MACHINE_KERN_RETURN_H_ -#define _MACH_MACHINE_KERN_RETURN_H_ - -#if defined (__i386__) || defined(__x86_64__) || defined(__arm__) -#include "mach/i386/kern_return.h" -#else -#error architecture not supported -#endif - -#endif /* _MACH_MACHINE_KERN_RETURN_H_ */ diff --git a/include/xnu/mach/machine/ndr_def.h b/include/xnu/mach/machine/ndr_def.h deleted file mode 100644 index 2d3451472..000000000 --- a/include/xnu/mach/machine/ndr_def.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2000-2007 Apple 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@ - */ - -#ifndef _MACH_MACHINE_NDR_DEF_H -#define _MACH_MACHINE_NDR_DEF_H - -#if defined (__i386__) || defined(__x86_64__) -#include "mach/i386/ndr_def.h" -#else -#error architecture not supported -#endif - -#endif /* _MACH_MACHINE_NDR_DEF_H */ diff --git a/include/xnu/mach/machine/processor_info.h b/include/xnu/mach/machine/processor_info.h deleted file mode 100644 index 46d42a3d5..000000000 --- a/include/xnu/mach/machine/processor_info.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2000-2007 Apple 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@ - */ - -#ifndef _MACH_MACHINE_PROCESSOR_INFO_H_ -#define _MACH_MACHINE_PROCESSOR_INFO_H_ - -#if defined (__i386__) || defined(__x86_64__) || defined(__arm__) -#include "mach/i386/processor_info.h" -#else -#error architecture not supported -#endif - -#endif /* _MACH_MACHINE_PROCESSOR_INFO_H_ */ diff --git a/include/xnu/mach/machine/rpc.h b/include/xnu/mach/machine/rpc.h deleted file mode 100644 index 3e543a88f..000000000 --- a/include/xnu/mach/machine/rpc.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2000-2007 Apple 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@ - */ - -#ifndef _MACH_MACHINE_RPC_H_ -#define _MACH_MACHINE_RPC_H_ - -#if defined (__i386__) || defined(__x86_64__) -#include "mach/i386/rpc.h" -#else -#error architecture not supported -#endif - -#endif /* _MACH_MACHINE_RPC_H_ */ diff --git a/include/xnu/mach/machine/sdt.h b/include/xnu/mach/machine/sdt.h deleted file mode 100644 index 551f2b0fc..000000000 --- a/include/xnu/mach/machine/sdt.h +++ /dev/null @@ -1,322 +0,0 @@ -/* - * Copyright (c) 2007 Apple Inc. All rights reserved. - */ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _MACH_MACHINE_SYS_SDT_H -#define _MACH_MACHINE_SYS_SDT_H - -#include - -#ifdef KERNEL - -#if CONFIG_DTRACE - -/* - * The following macros are used to create static probes. The argument types - * should be no greater than uintptr_t in size each. The behavior of larger - * types is undefined. - */ - -#define DTRACE_PROBE(provider, name) { \ - DTRACE_CALL0ARGS(provider, name) \ -} - -#define DTRACE_PROBE1(provider, name, arg0) { \ - uintptr_t __dtrace_args[ARG1_EXTENT] __attribute__ ((aligned (16))); \ - __dtrace_args[0] = (uintptr_t)arg0; \ - DTRACE_CALL1ARG(provider, name) \ -} - -#define DTRACE_PROBE2(provider, name, arg0, arg1) { \ - uintptr_t __dtrace_args[ARGS2_EXTENT] __attribute__ ((aligned (16))); \ - __dtrace_args[0] = (uintptr_t)arg0; \ - __dtrace_args[1] = (uintptr_t)arg1; \ - DTRACE_CALL2ARGS(provider, name) \ -} - -#define DTRACE_PROBE3(provider, name, arg0, arg1, arg2) { \ - uintptr_t __dtrace_args[ARGS3_EXTENT] __attribute__ ((aligned (16))); \ - __dtrace_args[0] = (uintptr_t)arg0; \ - __dtrace_args[1] = (uintptr_t)arg1; \ - __dtrace_args[2] = (uintptr_t)arg2; \ - DTRACE_CALL3ARGS(provider, name) \ -} - -#define DTRACE_PROBE4(provider, name, arg0, arg1, arg2, arg3) { \ - uintptr_t __dtrace_args[ARGS4_EXTENT] __attribute__ ((aligned (16))); \ - __dtrace_args[0] = (uintptr_t)arg0; \ - __dtrace_args[1] = (uintptr_t)arg1; \ - __dtrace_args[2] = (uintptr_t)arg2; \ - __dtrace_args[3] = (uintptr_t)arg3; \ - DTRACE_CALL4ARGS(provider, name) \ -} - -#define DTRACE_PROBE5(provider, name, arg0, arg1, arg2, arg3, arg4) { \ - uintptr_t __dtrace_args[ARGS5_EXTENT] __attribute__ ((aligned (16))); \ - __dtrace_args[0] = (uintptr_t)arg0; \ - __dtrace_args[1] = (uintptr_t)arg1; \ - __dtrace_args[2] = (uintptr_t)arg2; \ - __dtrace_args[3] = (uintptr_t)arg3; \ - __dtrace_args[4] = (uintptr_t)arg4; \ - DTRACE_CALL5ARGS(provider, name) \ -} - -#define DTRACE_PROBE6(provider, name, arg0, arg1, arg2, arg3, arg4, arg5) { \ - uintptr_t __dtrace_args[ARGS6_EXTENT] __attribute__ ((aligned (16))); \ - __dtrace_args[0] = (uintptr_t)arg0; \ - __dtrace_args[1] = (uintptr_t)arg1; \ - __dtrace_args[2] = (uintptr_t)arg2; \ - __dtrace_args[3] = (uintptr_t)arg3; \ - __dtrace_args[4] = (uintptr_t)arg4; \ - __dtrace_args[5] = (uintptr_t)arg5; \ - DTRACE_CALL6ARGS(provider, name) \ -} - -#define DTRACE_PROBE7(provider, name, arg0, arg1, arg2, arg3, arg4, arg5, arg6) { \ - uintptr_t __dtrace_args[ARGS7_EXTENT] __attribute__ ((aligned (16))); \ - __dtrace_args[0] = (uintptr_t)arg0; \ - __dtrace_args[1] = (uintptr_t)arg1; \ - __dtrace_args[2] = (uintptr_t)arg2; \ - __dtrace_args[3] = (uintptr_t)arg3; \ - __dtrace_args[4] = (uintptr_t)arg4; \ - __dtrace_args[5] = (uintptr_t)arg5; \ - __dtrace_args[6] = (uintptr_t)arg6; \ - DTRACE_CALL7ARGS(provider, name) \ -} - -#define DTRACE_PROBE8(provider, name, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) { \ - uintptr_t __dtrace_args[ARGS8_EXTENT] __attribute__ ((aligned (16))); \ - __dtrace_args[0] = (uintptr_t)arg0; \ - __dtrace_args[1] = (uintptr_t)arg1; \ - __dtrace_args[2] = (uintptr_t)arg2; \ - __dtrace_args[3] = (uintptr_t)arg3; \ - __dtrace_args[4] = (uintptr_t)arg4; \ - __dtrace_args[5] = (uintptr_t)arg5; \ - __dtrace_args[6] = (uintptr_t)arg6; \ - __dtrace_args[7] = (uintptr_t)arg7; \ - DTRACE_CALL8ARGS(provider, name) \ -} - -#define DTRACE_PROBE9(provider, name, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) { \ - uintptr_t __dtrace_args[ARGS9_EXTENT] __attribute__ ((aligned (16))); \ - __dtrace_args[0] = (uintptr_t)arg0; \ - __dtrace_args[1] = (uintptr_t)arg1; \ - __dtrace_args[2] = (uintptr_t)arg2; \ - __dtrace_args[3] = (uintptr_t)arg3; \ - __dtrace_args[4] = (uintptr_t)arg4; \ - __dtrace_args[5] = (uintptr_t)arg5; \ - __dtrace_args[6] = (uintptr_t)arg6; \ - __dtrace_args[7] = (uintptr_t)arg7; \ - __dtrace_args[8] = (uintptr_t)arg8; \ - DTRACE_CALL9ARGS(provider, name) \ -} - -#define DTRACE_PROBE10(provider, name, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) { \ - uintptr_t __dtrace_args[ARGS10_EXTENT] __attribute__ ((aligned (16))); \ - __dtrace_args[0] = (uintptr_t)arg0; \ - __dtrace_args[1] = (uintptr_t)arg1; \ - __dtrace_args[2] = (uintptr_t)arg2; \ - __dtrace_args[3] = (uintptr_t)arg3; \ - __dtrace_args[4] = (uintptr_t)arg4; \ - __dtrace_args[5] = (uintptr_t)arg5; \ - __dtrace_args[6] = (uintptr_t)arg6; \ - __dtrace_args[7] = (uintptr_t)arg7; \ - __dtrace_args[8] = (uintptr_t)arg8; \ - __dtrace_args[9] = (uintptr_t)arg9; \ - DTRACE_CALL10ARGS(provider, name) \ -} - - - -#define DTRACE_SCHED(name) \ - DTRACE_PROBE(__sched_, name); - -#define DTRACE_SCHED1(name, type1, arg1) \ - DTRACE_PROBE1(__sched_, name, arg1); - -#define DTRACE_SCHED2(name, type1, arg1, type2, arg2) \ - DTRACE_PROBE2(__sched_, name, arg1, arg2); - -#define DTRACE_SCHED3(name, type1, arg1, type2, arg2, type3, arg3) \ - DTRACE_PROBE3(__sched_, name, arg1, arg2, arg3); - -#define DTRACE_SCHED4(name, type1, arg1, type2, arg2, \ - type3, arg3, type4, arg4) \ - DTRACE_PROBE4(__sched_, name, arg1, arg2, arg3, arg4); - -#define DTRACE_PROC(name) \ - DTRACE_PROBE(__proc_, name); - -#define DTRACE_PROC1(name, type1, arg1) \ - DTRACE_PROBE1(__proc_, name, arg1); - -#define DTRACE_PROC2(name, type1, arg1, type2, arg2) \ - DTRACE_PROBE2(__proc_, name, arg1, arg2); - -#define DTRACE_PROC3(name, type1, arg1, type2, arg2, type3, arg3) \ - DTRACE_PROBE3(__proc_, name, arg1, arg2, arg3); - -#define DTRACE_PROC4(name, type1, arg1, type2, arg2, \ - type3, arg3, type4, arg4) \ - DTRACE_PROBE4(__proc_, name, arg1, arg2, arg3, arg4); - -#define DTRACE_IO(name) \ - DTRACE_PROBE(__io_, name); - -#define DTRACE_IO1(name, type1, arg1) \ - DTRACE_PROBE1(__io_, name, arg1); - -#define DTRACE_IO2(name, type1, arg1, type2, arg2) \ - DTRACE_PROBE2(__io_, name, type1, arg1, type2, arg2); - -#define DTRACE_IO3(name, type1, arg1, type2, arg2, type3, arg3) \ - DTRACE_PROBE3(__io_, name, arg1, arg2, arg3); - -#define DTRACE_IO4(name, type1, arg1, type2, arg2, \ - type3, arg3, type4, arg4) \ - DTRACE_PROBE4(__io_, name, arg1, arg2, arg3, arg4); - -#define DTRACE_INT5(name, type1, arg1, type2, arg2, \ - type3, arg3, type4, arg4, type5, arg5) \ - DTRACE_PROBE5(__sdt_, name, arg1, arg2, arg3, arg4, arg5); - -#define DTRACE_TMR3(name, type1, arg1, type2, arg2, type3, arg3) \ - DTRACE_PROBE3(__sdt_, name, arg1, arg2, arg3); - -#define DTRACE_VM(name) \ - DTRACE_PROBE(__vminfo_, name) - -#define DTRACE_VM1(name, type1, arg1) \ - DTRACE_PROBE1(__vminfo_, name, arg1) - -#define DTRACE_VM2(name, type1, arg1, type2, arg2) \ - DTRACE_PROBE2(__vminfo_, name, arg1, arg2) - -#define DTRACE_VM3(name, type1, arg1, type2, arg2, type3, arg3) \ - DTRACE_PROBE3(__vminfo_, name, arg1, arg2, arg3) - -#define DTRACE_VM4(name, type1, arg1, type2, arg2, \ - type3, arg3, type4, arg4) \ - DTRACE_PROBE4(__vminfo_, name, arg1, arg2, arg3, arg4) - -#define DTRACE_IP(name) \ - DTRACE_PROBE(__ip_, name) - -#define DTRACE_IP1(name, type1, arg1) \ - DTRACE_PROBE1(__ip_, name, arg1) - -#define DTRACE_IP2(name, type1, arg1, type2, arg2) \ - DTRACE_PROBE2(__ip_, name, arg1, arg2) - -#define DTRACE_IP3(name, type1, arg1, type2, arg2, type3, arg3) \ - DTRACE_PROBE3(__ip_, name, arg1, arg2, arg3) - -#define DTRACE_IP4(name, type1, arg1, type2, arg2, \ - type3, arg3, type4, arg4) \ - DTRACE_PROBE4(__ip_, name, arg1, arg2, arg3, arg4) - -#define DTRACE_IP5(name, typ1, arg1, type2, arg2, type3, arg3, \ - type4, arg4, type5, arg5) \ - DTRACE_PROBE5(__ip_, name, arg1, arg2, arg3, arg4, arg5) - -#define DTRACE_IP6(name, type1, arg1, type2, arg2, type3, arg3, \ - type4,arg4, type5, arg5, type6, arg6) \ - DTRACE_PROBE6(__ip_, name, arg1, arg2, arg3, arg4, arg5, arg6) - -#define DTRACE_IP7(name, type1, arg1, type2, arg2, type3, arg3, \ - type4, arg4, type5, arg5, type6, arg6, type7, arg7) \ - DTRACE_PROBE7(__ip_, name, arg1, arg2, arg3, arg4, arg5, arg6, arg7) - -#define DTRACE_TCP(name) \ - DTRACE_PROBE(__tcp_, name) - -#define DTRACE_TCP1(name, type1, arg1) \ - DTRACE_PROBE1(__tcp_, name, arg1) - -#define DTRACE_TCP2(name, type1, arg1, type2, arg2) \ - DTRACE_PROBE2(__tcp_, name, arg1, arg2) - -#define DTRACE_TCP3(name, type1, arg1, type2, arg2, type3, arg3) \ - DTRACE_PROBE3(__tcp_, name, arg1, arg2, arg3) - -#define DTRACE_TCP4(name, type1, arg1, type2, arg2, \ - type3, arg3, type4, arg4) \ - DTRACE_PROBE4(__tcp_, name, arg1, arg2, arg3, arg4) - -#define DTRACE_TCP5(name, typ1, arg1, type2, arg2, type3, arg3, \ - type4, arg4, type5, arg5) \ - DTRACE_PROBE5(__tcp_, name, arg1, arg2, arg3, arg4, arg5) - -#else /* CONFIG_DTRACE */ - -#define DTRACE_SCHED(name) do {} while (0) -#define DTRACE_SCHED1(name, type1, arg1) do {} while (0) -#define DTRACE_SCHED2(name, type1, arg1, type2, arg2) do {} while (0) -#define DTRACE_SCHED3(name, type1, arg1, type2, arg2, type3, arg3) do {} while (0) -#define DTRACE_SCHED4(name, type1, arg1, type2, arg2, type3, arg3, type4, arg4) do {} while (0) - -#define DTRACE_PROC(name) do {} while(0) -#define DTRACE_PROC1(name, type1, arg1) do {} while(0) -#define DTRACE_PROC2(name, type1, arg1, type2, arg2) do {} while (0) -#define DTRACE_PROC3(name, type1, arg1, type2, arg2, type3, arg3) do {} while (0) -#define DTRACE_PROC4(name, type1, arg1, type2, arg2, type3, arg3, type4, arg4) do {} while(0) -#define DTRACE_IO(name) do {} while(0) -#define DTRACE_IO1(name, type1, arg1) do {} while(0) -#define DTRACE_IO2(name, type1, arg1, type2, arg2) do {} while(0) -#define DTRACE_IO3(name, type1, arg1, type2, arg2, type3, arg3) do {} while(0) -#define DTRACE_IO4(name, type1, arg1, type2, arg2, type3, arg3, type4, arg4) do {} while(0) -#define DTRACE_INT5(name, type1, arg1, type2, arg2, type3, arg3, type4, arg4, type5, arg5) do {} while(0) -#define DTRACE_TMR3(name, type1, arg1, type2, arg2, type3, arg3) do {} while(0) - -#define DTRACE_VM(name) do {} while(0) -#define DTRACE_VM1(name, type1, arg1) do {} while(0) -#define DTRACE_VM2(name, type1, arg1, type2, arg2) do {} while(0) -#define DTRACE_VM3(name, type1, arg1, type2, arg2, type3, arg3) do {} while(0) -#define DTRACE_VM4(name, type1, arg1, type2, arg2, type3, arg3, type4, arg4) do {} while(0) -#define DTRACE_IP(name) do {} while(0) -#define DTRACE_IP1(name, type1, arg1) do {} while(0) -#define DTRACE_IP2(name, type1, arg1, type2, arg2) do {} while(0) -#define DTRACE_IP3(name, type1, arg1, type2, arg2, type3, arg3) do {} while(0) -#define DTRACE_IP4(name, type1, arg1, type2, arg2, type3, arg3, type4, arg4) do {} while(0) -#define DTRACE_IP5(name, type1, arg1, type2, arg2, type3, arg3, type4, arg4, type5, arg5) do {} while(0) -#define DTRACE_IP6(name, type1, arg1, type2, arg2, type3, arg3, type4, arg4, type5, arg5, type6, arg6) do {} while(0) -#define DTRACE_IP7(name, type1, arg1, type2, arg2, type3, arg3, type4, arg4, type5, arg5, \ - type6, arg6, type7, arg7) do {} while(0) - -#define DTRACE_TCP(name) do {} while(0) -#define DTRACE_TCP1(name, type1, arg1) do {} while(0) -#define DTRACE_TCP2(name, type1, arg1, type2, arg2) do {} while(0) -#define DTRACE_TCP3(name, type1, arg1, type2, arg2, type3, arg3) do {} while(0) -#define DTRACE_TCP4(name, type1, arg1, type2, arg2, type3, arg3, type4, arg4) do {} while(0) -#define DTRACE_TCP5(name, type1, arg1, type2, arg2, type3, arg3, type4, arg4, type5, arg5) do {} while(0) - -#endif /* CONFIG_DTRACE */ - -#endif /* KERNEL */ - -#endif /* _MACH_MACHINE_SYS_SDT_H */ diff --git a/include/xnu/mach/machine/sdt_isa.h b/include/xnu/mach/machine/sdt_isa.h deleted file mode 100644 index edd26dcc2..000000000 --- a/include/xnu/mach/machine/sdt_isa.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2000-2007 Apple 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@ - */ -#ifndef _MACH_MACHINE_SDT_ISA_H_ -#define _MACH_MACHINE_SDT_ISA_H_ - -#if defined (__i386__) || defined(__x86_64__) -#include -#else -#error architecture not supported -#endif - -#endif /* _BSD_MACHINE_SDT_ISA_H_ */ diff --git a/include/xnu/mach/machine/syscall_sw.h b/include/xnu/mach/machine/syscall_sw.h deleted file mode 100644 index 902b6815e..000000000 --- a/include/xnu/mach/machine/syscall_sw.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2000-2007 Apple 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@ - */ - -#ifdef PRIVATE - -#ifndef _MACH_MACHINE_SYSCALL_SW_H_ -#define _MACH_MACHINE_SYSCALL_SW_H_ - -#if defined (__i386__) || defined(__x86_64__) -#include "mach/i386/syscall_sw.h" -#else -#error architecture not supported -#endif - -#endif /* _MACH_MACHINE_SYSCALL_SW_H_ */ - -#endif /* PRIVATE */ diff --git a/include/xnu/mach/machine/thread_state.h b/include/xnu/mach/machine/thread_state.h deleted file mode 100644 index cbcd81ab7..000000000 --- a/include/xnu/mach/machine/thread_state.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2000-2007 Apple 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@ - */ - -#ifndef _MACH_MACHINE_THREAD_STATE_H_ -#define _MACH_MACHINE_THREAD_STATE_H_ - -#if defined (__i386__) || defined(__x86_64__) || defined(__arm__) -#include "mach/i386/thread_state.h" -#else -#error architecture not supported -#endif - -#endif /* _MACH_MACHINE_THREAD_STATE_H_ */ diff --git a/include/xnu/mach/machine/thread_status.h b/include/xnu/mach/machine/thread_status.h deleted file mode 100644 index 295c60e07..000000000 --- a/include/xnu/mach/machine/thread_status.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2000-2007 Apple 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@ - */ - -#ifndef _MACH_MACHINE_THREAD_STATUS_H_ -#define _MACH_MACHINE_THREAD_STATUS_H_ - -#if defined (__i386__) || defined(__x86_64__) || defined(__arm__) -#include "mach/i386/thread_status.h" -#else -#error architecture not supported -#endif - -#endif /* _MACH_MACHINE_THREAD_STATUS_H_ */ diff --git a/include/xnu/mach/machine/vm_param.h b/include/xnu/mach/machine/vm_param.h deleted file mode 100644 index 9821820ff..000000000 --- a/include/xnu/mach/machine/vm_param.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2000-2007 Apple 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@ - */ - -#ifndef _MACH_MACHINE_VM_PARAM_H_ -#define _MACH_MACHINE_VM_PARAM_H_ - -#if defined (__i386__) || defined(__x86_64__) || defined(__arm__) -#include "mach/i386/vm_param.h" -#else -#error architecture not supported -#endif - -#endif /* _MACH_MACHINE_VM_PARAM_H_ */ diff --git a/include/xnu/mach/machine/vm_types.h b/include/xnu/mach/machine/vm_types.h deleted file mode 100644 index a174ab732..000000000 --- a/include/xnu/mach/machine/vm_types.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2000-2007 Apple 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@ - */ - -#ifndef _MACH_MACHINE_VM_TYPES_H_ -#define _MACH_MACHINE_VM_TYPES_H_ - -#if defined (__i386__) || defined(__x86_64__) || defined(__arm__) -#include "mach/i386/vm_types.h" -#else -#error architecture not supported -#endif - -#endif /* _MACH_MACHINE_VM_TYPES_H_ */ diff --git a/include/xnu/mach/memory_object.h b/include/xnu/mach/memory_object.h deleted file mode 100644 index 68223b8fa..000000000 --- a/include/xnu/mach/memory_object.h +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright (c) 2000-2005 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@ - */ -/* - * @OSF_COPYRIGHT@ - */ -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989,1988 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 Software.Distribution@CS.CMU.EDU - * 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: memory_object.h - * Author: Michael Wayne Young - * - * External memory management interface definition. - */ - -#ifndef _MACH_MEMORY_OBJECT_H_ -#define _MACH_MEMORY_OBJECT_H_ - -/* - * User-visible types used in the external memory - * management interface: - */ - -#include -#include -#include - -typedef mach_port_t memory_object_t; - /* A memory object ... */ - /* Used by the kernel to retrieve */ - /* or store data */ - -typedef mach_port_t memory_object_control_t; - /* Provided to a memory manager; ... */ - /* used to control a memory object */ - -typedef mach_port_t memory_object_name_t; - /* Used to describe the memory ... */ - /* object in vm_regions() calls */ - -typedef mach_port_t memory_object_rep_t; - /* Per-client handle for mem object */ - /* Used by user programs to specify */ - /* the object to map */ - -typedef int memory_object_copy_strategy_t; - /* How memory manager handles copy: */ -#define MEMORY_OBJECT_COPY_NONE 0 - /* ... No special support */ -#define MEMORY_OBJECT_COPY_CALL 1 - /* ... Make call on memory manager */ -#define MEMORY_OBJECT_COPY_DELAY 2 - /* ... Memory manager doesn't - * change data externally. - */ -#define MEMORY_OBJECT_COPY_TEMPORARY 3 - /* ... Memory manager doesn't - * change data externally, and - * doesn't need to see changes. - */ -#define MEMORY_OBJECT_COPY_SYMMETRIC 4 - /* ... Memory manager doesn't - * change data externally, - * doesn't need to see changes, - * and object will not be - * multiply mapped. - * - * XXX - * Not yet safe for non-kernel use. - */ - -#define MEMORY_OBJECT_COPY_INVALID 5 - /* ... An invalid copy strategy, - * for external objects which - * have not been initialized. - * Allows copy_strategy to be - * examined without also - * examining pager_ready and - * internal. - */ - -typedef int memory_object_return_t; - /* Which pages to return to manager - this time (lock_request) */ -#define MEMORY_OBJECT_RETURN_NONE 0 - /* ... don't return any. */ -#define MEMORY_OBJECT_RETURN_DIRTY 1 - /* ... only dirty pages. */ -#define MEMORY_OBJECT_RETURN_ALL 2 - /* ... dirty and precious pages. */ -#define MEMORY_OBJECT_RETURN_ANYTHING 3 - /* ... any resident page. */ - -#define MEMORY_OBJECT_NULL MACH_PORT_NULL - - -/* - * Types for the memory object flavor interfaces - */ - -#define MEMORY_OBJECT_INFO_MAX (1024) -typedef int *memory_object_info_t; -typedef int memory_object_flavor_t; -typedef int memory_object_info_data_t[MEMORY_OBJECT_INFO_MAX]; - - -#define OLD_MEMORY_OBJECT_BEHAVIOR_INFO 10 -#define MEMORY_OBJECT_PERFORMANCE_INFO 11 -#define OLD_MEMORY_OBJECT_ATTRIBUTE_INFO 12 -#define MEMORY_OBJECT_ATTRIBUTE_INFO 14 -#define MEMORY_OBJECT_BEHAVIOR_INFO 15 - - -struct old_memory_object_behave_info { - memory_object_copy_strategy_t copy_strategy; - boolean_t temporary; - boolean_t invalidate; -}; - -struct memory_object_perf_info { - memory_object_cluster_size_t cluster_size; - boolean_t may_cache; -}; - -struct old_memory_object_attr_info { /* old attr list */ - boolean_t object_ready; - boolean_t may_cache; - memory_object_copy_strategy_t copy_strategy; -}; - -struct memory_object_attr_info { - memory_object_copy_strategy_t copy_strategy; - memory_object_cluster_size_t cluster_size; - boolean_t may_cache_object; - boolean_t temporary; -}; - -struct memory_object_behave_info { - memory_object_copy_strategy_t copy_strategy; - boolean_t temporary; - boolean_t invalidate; - boolean_t silent_overwrite; - boolean_t advisory_pageout; -}; - -typedef struct old_memory_object_behave_info *old_memory_object_behave_info_t; -typedef struct old_memory_object_behave_info old_memory_object_behave_info_data_t; - -typedef struct memory_object_behave_info *memory_object_behave_info_t; -typedef struct memory_object_behave_info memory_object_behave_info_data_t; - -typedef struct memory_object_perf_info *memory_object_perf_info_t; -typedef struct memory_object_perf_info memory_object_perf_info_data_t; - -typedef struct old_memory_object_attr_info *old_memory_object_attr_info_t; -typedef struct old_memory_object_attr_info old_memory_object_attr_info_data_t; - -typedef struct memory_object_attr_info *memory_object_attr_info_t; -typedef struct memory_object_attr_info memory_object_attr_info_data_t; - -#define OLD_MEMORY_OBJECT_BEHAVE_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof(old_memory_object_behave_info_data_t)/sizeof(int))) -#define MEMORY_OBJECT_BEHAVE_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof(memory_object_behave_info_data_t)/sizeof(int))) -#define MEMORY_OBJECT_PERF_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof(memory_object_perf_info_data_t)/sizeof(int))) -#define OLD_MEMORY_OBJECT_ATTR_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof(old_memory_object_attr_info_data_t)/sizeof(int))) -#define MEMORY_OBJECT_ATTR_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof(memory_object_attr_info_data_t)/sizeof(int))) - -#define invalid_memory_object_flavor(f) \ - (f != MEMORY_OBJECT_ATTRIBUTE_INFO && \ - f != MEMORY_OBJECT_PERFORMANCE_INFO && \ - f != OLD_MEMORY_OBJECT_BEHAVIOR_INFO && \ - f != MEMORY_OBJECT_BEHAVIOR_INFO && \ - f != OLD_MEMORY_OBJECT_ATTRIBUTE_INFO) - -#endif /* _MACH_MEMORY_OBJECT_H_ */ diff --git a/include/xnu/mach/memory_object_types.h b/include/xnu/mach/memory_object_types.h deleted file mode 100644 index 281ff1c9f..000000000 --- a/include/xnu/mach/memory_object_types.h +++ /dev/null @@ -1,707 +0,0 @@ -/* - * Copyright (c) 2000-2006 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@ - */ -/* - * @OSF_COPYRIGHT@ - */ -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989,1988 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 Software.Distribution@CS.CMU.EDU - * 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: memory_object.h - * Author: Michael Wayne Young - * - * External memory management interface definition. - */ - -#ifndef _MACH_MEMORY_OBJECT_TYPES_H_ -#define _MACH_MEMORY_OBJECT_TYPES_H_ - -/* - * User-visible types used in the external memory - * management interface: - */ - -#include -#include -#include -#include -#include -#include - -#include - -#define VM_64_BIT_DATA_OBJECTS - -typedef unsigned long long memory_object_offset_t; -typedef unsigned long long memory_object_size_t; -typedef natural_t memory_object_cluster_size_t; -typedef natural_t * memory_object_fault_info_t; - -typedef unsigned long long vm_object_id_t; - - -/* - * Temporary until real EMMI version gets re-implemented - */ - -#ifdef KERNEL_PRIVATE - -struct memory_object_pager_ops; /* forward declaration */ - -typedef struct memory_object { - unsigned int _pad1; /* struct ipc_object_header */ -#ifdef __LP64__ - unsigned int _pad2; /* pad to natural boundary */ -#endif - const struct memory_object_pager_ops *mo_pager_ops; -} *memory_object_t; - -typedef struct memory_object_control { - unsigned int moc_ikot; /* struct ipc_object_header */ -#ifdef __LP64__ - unsigned int _pad; /* pad to natural boundary */ -#endif - struct vm_object *moc_object; -} *memory_object_control_t; - -typedef const struct memory_object_pager_ops { - void (*memory_object_reference)( - memory_object_t mem_obj); - void (*memory_object_deallocate)( - memory_object_t mem_obj); - kern_return_t (*memory_object_init)( - memory_object_t mem_obj, - memory_object_control_t mem_control, - memory_object_cluster_size_t size); - kern_return_t (*memory_object_terminate)( - memory_object_t mem_obj); - kern_return_t (*memory_object_data_request)( - memory_object_t mem_obj, - memory_object_offset_t offset, - memory_object_cluster_size_t length, - vm_prot_t desired_access, - memory_object_fault_info_t fault_info); - kern_return_t (*memory_object_data_return)( - memory_object_t mem_obj, - memory_object_offset_t offset, - memory_object_cluster_size_t size, - memory_object_offset_t *resid_offset, - int *io_error, - boolean_t dirty, - boolean_t kernel_copy, - int upl_flags); - kern_return_t (*memory_object_data_initialize)( - memory_object_t mem_obj, - memory_object_offset_t offset, - memory_object_cluster_size_t size); - kern_return_t (*memory_object_data_unlock)( - memory_object_t mem_obj, - memory_object_offset_t offset, - memory_object_size_t size, - vm_prot_t desired_access); - kern_return_t (*memory_object_synchronize)( - memory_object_t mem_obj, - memory_object_offset_t offset, - memory_object_size_t size, - vm_sync_t sync_flags); - kern_return_t (*memory_object_map)( - memory_object_t mem_obj, - vm_prot_t prot); - kern_return_t (*memory_object_last_unmap)( - memory_object_t mem_obj); - kern_return_t (*memory_object_data_reclaim)( - memory_object_t mem_obj, - boolean_t reclaim_backing_store); - const char *memory_object_pager_name; -} * memory_object_pager_ops_t; - -#else /* KERNEL_PRIVATE */ - -typedef mach_port_t memory_object_t; -typedef mach_port_t memory_object_control_t; - -#endif /* KERNEL_PRIVATE */ - -typedef memory_object_t *memory_object_array_t; - /* A memory object ... */ - /* Used by the kernel to retrieve */ - /* or store data */ - -typedef mach_port_t memory_object_name_t; - /* Used to describe the memory ... */ - /* object in vm_regions() calls */ - -typedef mach_port_t memory_object_default_t; - /* Registered with the host ... */ - /* for creating new internal objects */ - -#define MEMORY_OBJECT_NULL ((memory_object_t) 0) -#define MEMORY_OBJECT_CONTROL_NULL ((memory_object_control_t) 0) -#define MEMORY_OBJECT_NAME_NULL ((memory_object_name_t) 0) -#define MEMORY_OBJECT_DEFAULT_NULL ((memory_object_default_t) 0) - - -typedef int memory_object_copy_strategy_t; - /* How memory manager handles copy: */ -#define MEMORY_OBJECT_COPY_NONE 0 - /* ... No special support */ -#define MEMORY_OBJECT_COPY_CALL 1 - /* ... Make call on memory manager */ -#define MEMORY_OBJECT_COPY_DELAY 2 - /* ... Memory manager doesn't - * change data externally. - */ -#define MEMORY_OBJECT_COPY_TEMPORARY 3 - /* ... Memory manager doesn't - * change data externally, and - * doesn't need to see changes. - */ -#define MEMORY_OBJECT_COPY_SYMMETRIC 4 - /* ... Memory manager doesn't - * change data externally, - * doesn't need to see changes, - * and object will not be - * multiply mapped. - * - * XXX - * Not yet safe for non-kernel use. - */ - -#define MEMORY_OBJECT_COPY_INVALID 5 - /* ... An invalid copy strategy, - * for external objects which - * have not been initialized. - * Allows copy_strategy to be - * examined without also - * examining pager_ready and - * internal. - */ - -typedef int memory_object_return_t; - /* Which pages to return to manager - this time (lock_request) */ -#define MEMORY_OBJECT_RETURN_NONE 0 - /* ... don't return any. */ -#define MEMORY_OBJECT_RETURN_DIRTY 1 - /* ... only dirty pages. */ -#define MEMORY_OBJECT_RETURN_ALL 2 - /* ... dirty and precious pages. */ -#define MEMORY_OBJECT_RETURN_ANYTHING 3 - /* ... any resident page. */ - -/* - * Data lock request flags - */ - -#define MEMORY_OBJECT_DATA_FLUSH 0x1 -#define MEMORY_OBJECT_DATA_NO_CHANGE 0x2 -#define MEMORY_OBJECT_DATA_PURGE 0x4 -#define MEMORY_OBJECT_COPY_SYNC 0x8 -#define MEMORY_OBJECT_DATA_SYNC 0x10 -#define MEMORY_OBJECT_IO_SYNC 0x20 -#define MEMORY_OBJECT_DATA_FLUSH_ALL 0x40 - -/* - * Types for the memory object flavor interfaces - */ - -#define MEMORY_OBJECT_INFO_MAX (1024) -typedef int *memory_object_info_t; -typedef int memory_object_flavor_t; -typedef int memory_object_info_data_t[MEMORY_OBJECT_INFO_MAX]; - - -#define MEMORY_OBJECT_PERFORMANCE_INFO 11 -#define MEMORY_OBJECT_ATTRIBUTE_INFO 14 -#define MEMORY_OBJECT_BEHAVIOR_INFO 15 - -#ifdef PRIVATE - -#define OLD_MEMORY_OBJECT_BEHAVIOR_INFO 10 -#define OLD_MEMORY_OBJECT_ATTRIBUTE_INFO 12 - -struct old_memory_object_behave_info { - memory_object_copy_strategy_t copy_strategy; - boolean_t temporary; - boolean_t invalidate; -}; - -struct old_memory_object_attr_info { /* old attr list */ - boolean_t object_ready; - boolean_t may_cache; - memory_object_copy_strategy_t copy_strategy; -}; - -typedef struct old_memory_object_behave_info *old_memory_object_behave_info_t; -typedef struct old_memory_object_behave_info old_memory_object_behave_info_data_t; -typedef struct old_memory_object_attr_info *old_memory_object_attr_info_t; -typedef struct old_memory_object_attr_info old_memory_object_attr_info_data_t; - -#define OLD_MEMORY_OBJECT_BEHAVE_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof(old_memory_object_behave_info_data_t)/sizeof(int))) -#define OLD_MEMORY_OBJECT_ATTR_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof(old_memory_object_attr_info_data_t)/sizeof(int))) - -#ifdef KERNEL - -__BEGIN_DECLS -extern void memory_object_reference(memory_object_t object); -extern void memory_object_deallocate(memory_object_t object); - -extern void memory_object_default_reference(memory_object_default_t); -extern void memory_object_default_deallocate(memory_object_default_t); - -extern void memory_object_control_reference(memory_object_control_t control); -extern void memory_object_control_deallocate(memory_object_control_t control); -extern int memory_object_control_uiomove(memory_object_control_t, memory_object_offset_t, void *, int, int, int, int); -__END_DECLS - -#endif /* KERNEL */ - -#endif /* PRIVATE */ - -struct memory_object_perf_info { - memory_object_cluster_size_t cluster_size; - boolean_t may_cache; -}; - -struct memory_object_attr_info { - memory_object_copy_strategy_t copy_strategy; - memory_object_cluster_size_t cluster_size; - boolean_t may_cache_object; - boolean_t temporary; -}; - -struct memory_object_behave_info { - memory_object_copy_strategy_t copy_strategy; - boolean_t temporary; - boolean_t invalidate; - boolean_t silent_overwrite; - boolean_t advisory_pageout; -}; - - -typedef struct memory_object_behave_info *memory_object_behave_info_t; -typedef struct memory_object_behave_info memory_object_behave_info_data_t; - -typedef struct memory_object_perf_info *memory_object_perf_info_t; -typedef struct memory_object_perf_info memory_object_perf_info_data_t; - -typedef struct memory_object_attr_info *memory_object_attr_info_t; -typedef struct memory_object_attr_info memory_object_attr_info_data_t; - -#define MEMORY_OBJECT_BEHAVE_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof(memory_object_behave_info_data_t)/sizeof(int))) -#define MEMORY_OBJECT_PERF_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof(memory_object_perf_info_data_t)/sizeof(int))) -#define MEMORY_OBJECT_ATTR_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof(memory_object_attr_info_data_t)/sizeof(int))) - -#define invalid_memory_object_flavor(f) \ - (f != MEMORY_OBJECT_ATTRIBUTE_INFO && \ - f != MEMORY_OBJECT_PERFORMANCE_INFO && \ - f != OLD_MEMORY_OBJECT_BEHAVIOR_INFO && \ - f != MEMORY_OBJECT_BEHAVIOR_INFO && \ - f != OLD_MEMORY_OBJECT_ATTRIBUTE_INFO) - - -/* - * Used to support options on memory_object_release_name call - */ -#define MEMORY_OBJECT_TERMINATE_IDLE 0x1 -#define MEMORY_OBJECT_RESPECT_CACHE 0x2 -#define MEMORY_OBJECT_RELEASE_NO_OP 0x4 - - -/* named entry processor mapping options */ -/* enumerated */ -#define MAP_MEM_NOOP 0 -#define MAP_MEM_COPYBACK 1 -#define MAP_MEM_IO 2 -#define MAP_MEM_WTHRU 3 -#define MAP_MEM_WCOMB 4 /* Write combining mode */ - /* aka store gather */ -#define MAP_MEM_INNERWBACK 5 - -#define GET_MAP_MEM(flags) \ - ((((unsigned int)(flags)) >> 24) & 0xFF) - -#define SET_MAP_MEM(caching, flags) \ - ((flags) = ((((unsigned int)(caching)) << 24) \ - & 0xFF000000) | ((flags) & 0xFFFFFF)); - -/* leave room for vm_prot bits */ -#define MAP_MEM_ONLY 0x010000 /* change processor caching */ -#define MAP_MEM_NAMED_CREATE 0x020000 /* create extant object */ -#define MAP_MEM_PURGABLE 0x040000 /* create a purgable VM object */ -#define MAP_MEM_NAMED_REUSE 0x080000 /* reuse provided entry if identical */ - -#ifdef KERNEL - -/* - * Universal Page List data structures - * - * A UPL describes a bounded set of physical pages - * associated with some range of an object or map - * and a snapshot of the attributes associated with - * each of those pages. - */ -#ifdef PRIVATE -#define MAX_UPL_TRANSFER 256 -#define MAX_UPL_SIZE 8192 - -struct upl_page_info { - ppnum_t phys_addr; /* physical page index number */ - unsigned int -#ifdef XNU_KERNEL_PRIVATE - pageout:1, /* page is to be removed on commit */ - absent:1, /* No valid data in this page */ - dirty:1, /* Page must be cleaned (O) */ - precious:1, /* must be cleaned, we have only copy */ - device:1, /* no page data, mapped dev memory */ - speculative:1, /* page is valid, but not yet accessed */ - cs_validated:1, /* CODE SIGNING: page was validated */ - cs_tainted:1, /* CODE SIGNING: page is tainted */ - needed:1, /* page should be left in cache on abort */ - :0; /* force to long boundary */ -#else - opaque; /* use upl_page_xxx() accessor funcs */ -#endif /* XNU_KERNEL_PRIVATE */ -}; - -#else - -struct upl_page_info { - unsigned int opaque[2]; /* use upl_page_xxx() accessor funcs */ -}; - -#endif /* PRIVATE */ - -typedef struct upl_page_info upl_page_info_t; -typedef upl_page_info_t *upl_page_info_array_t; -typedef upl_page_info_array_t upl_page_list_ptr_t; - -typedef uint32_t upl_offset_t; /* page-aligned byte offset */ -typedef uint32_t upl_size_t; /* page-aligned byte size */ - -/* upl invocation flags */ -/* top nibble is used by super upl */ - -#define UPL_FLAGS_NONE 0x00000000 -#define UPL_COPYOUT_FROM 0x00000001 -#define UPL_PRECIOUS 0x00000002 -#define UPL_NO_SYNC 0x00000004 -#define UPL_CLEAN_IN_PLACE 0x00000008 -#define UPL_NOBLOCK 0x00000010 -#define UPL_RET_ONLY_DIRTY 0x00000020 -#define UPL_SET_INTERNAL 0x00000040 -#define UPL_QUERY_OBJECT_TYPE 0x00000080 -#define UPL_RET_ONLY_ABSENT 0x00000100 /* used only for COPY_FROM = FALSE */ -#define UPL_FILE_IO 0x00000200 -#define UPL_SET_LITE 0x00000400 -#define UPL_SET_INTERRUPTIBLE 0x00000800 -#define UPL_SET_IO_WIRE 0x00001000 -#define UPL_FOR_PAGEOUT 0x00002000 -#define UPL_WILL_BE_DUMPED 0x00004000 -#define UPL_FORCE_DATA_SYNC 0x00008000 -/* continued after the ticket bits... */ - -#define UPL_PAGE_TICKET_MASK 0x000F0000 -#define UPL_PAGE_TICKET_SHIFT 16 - -/* ... flags resume here */ -#define UPL_BLOCK_ACCESS 0x00100000 -#define UPL_ENCRYPT 0x00200000 -#define UPL_NOZEROFILL 0x00400000 -#define UPL_WILL_MODIFY 0x00800000 /* caller will modify the pages */ - -#define UPL_NEED_32BIT_ADDR 0x01000000 -#define UPL_UBC_MSYNC 0x02000000 -#define UPL_UBC_PAGEOUT 0x04000000 -#define UPL_UBC_PAGEIN 0x08000000 -#define UPL_REQUEST_SET_DIRTY 0x10000000 - -/* UPL flags known by this kernel */ -#define UPL_VALID_FLAGS 0x1FFFFFFF - - -/* upl abort error flags */ -#define UPL_ABORT_RESTART 0x1 -#define UPL_ABORT_UNAVAILABLE 0x2 -#define UPL_ABORT_ERROR 0x4 -#define UPL_ABORT_FREE_ON_EMPTY 0x8 /* only implemented in wrappers */ -#define UPL_ABORT_DUMP_PAGES 0x10 -#define UPL_ABORT_NOTIFY_EMPTY 0x20 -/* deprecated: #define UPL_ABORT_ALLOW_ACCESS 0x40 */ -#define UPL_ABORT_REFERENCE 0x80 - -/* upl pages check flags */ -#define UPL_CHECK_DIRTY 0x1 - - -/* - * upl pagein/pageout flags - * - * - * when I/O is issued from this UPL it should be done synchronously - */ -#define UPL_IOSYNC 0x1 - -/* - * the passed in UPL should not have either a commit or abort - * applied to it by the underlying layers... the site that - * created the UPL is responsible for cleaning it up. - */ -#define UPL_NOCOMMIT 0x2 - -/* - * turn off any speculative read-ahead applied at the I/O layer - */ -#define UPL_NORDAHEAD 0x4 - -/* - * pageout request is targeting a real file - * as opposed to a swap file. - */ - -#define UPL_VNODE_PAGER 0x8 -/* - * this pageout is being originated as part of an explicit - * memory synchronization operation... no speculative clustering - * should be applied, only the range specified should be pushed. - */ -#define UPL_MSYNC 0x10 - -/* - * - */ -#define UPL_PAGING_ENCRYPTED 0x20 - -/* - * this pageout is being originated as part of an explicit - * memory synchronization operation that is checking for I/O - * errors and taking it's own action... if an error occurs, - * just abort the pages back into the cache unchanged - */ -#define UPL_KEEPCACHED 0x40 - -/* - * this pageout originated from within cluster_io to deal - * with a dirty page that hasn't yet been seen by the FS - * that backs it... tag it so that the FS can take the - * appropriate action w/r to its locking model since the - * pageout will reenter the FS for the same file currently - * being handled in this context. - */ -#define UPL_NESTED_PAGEOUT 0x80 - -/* - * we've detected a sequential access pattern and - * we are speculatively and aggressively pulling - * pages in... do not count these as real PAGEINs - * w/r to our hard throttle maintenance - */ -#define UPL_IOSTREAMING 0x100 - - - - -/* upl commit flags */ -#define UPL_COMMIT_FREE_ON_EMPTY 0x1 /* only implemented in wrappers */ -#define UPL_COMMIT_CLEAR_DIRTY 0x2 -#define UPL_COMMIT_SET_DIRTY 0x4 -#define UPL_COMMIT_INACTIVATE 0x8 -#define UPL_COMMIT_NOTIFY_EMPTY 0x10 -/* deprecated: #define UPL_COMMIT_ALLOW_ACCESS 0x20 */ -#define UPL_COMMIT_CS_VALIDATED 0x40 -#define UPL_COMMIT_CLEAR_PRECIOUS 0x80 -#define UPL_COMMIT_SPECULATE 0x100 -#define UPL_COMMIT_FREE_ABSENT 0x200 - -#define UPL_COMMIT_KERNEL_ONLY_FLAGS (UPL_COMMIT_CS_VALIDATED | UPL_COMMIT_FREE_ABSENT) - -/* flags for return of state from vm_map_get_upl, vm_upl address space */ -/* based call */ -#define UPL_DEV_MEMORY 0x1 -#define UPL_PHYS_CONTIG 0x2 - - -/* - * Flags for the UPL page ops routine. This routine is not exported - * out of the kernel at the moment and so the defs live here. - */ -#define UPL_POP_DIRTY 0x1 -#define UPL_POP_PAGEOUT 0x2 -#define UPL_POP_PRECIOUS 0x4 -#define UPL_POP_ABSENT 0x8 -#define UPL_POP_BUSY 0x10 - -#define UPL_POP_PHYSICAL 0x10000000 -#define UPL_POP_DUMP 0x20000000 -#define UPL_POP_SET 0x40000000 -#define UPL_POP_CLR 0x80000000 - -/* - * Flags for the UPL range op routine. This routine is not exported - * out of the kernel at the moemet and so the defs live here. - */ -/* - * UPL_ROP_ABSENT: Returns the extent of the range presented which - * is absent, starting with the start address presented - */ -#define UPL_ROP_ABSENT 0x01 -/* - * UPL_ROP_PRESENT: Returns the extent of the range presented which - * is present (i.e. resident), starting with the start address presented - */ -#define UPL_ROP_PRESENT 0x02 -/* - * UPL_ROP_DUMP: Dump the pages which are found in the target object - * for the target range. - */ -#define UPL_ROP_DUMP 0x04 - -#ifdef PRIVATE - -/* access macros for upl_t */ - -#define UPL_DEVICE_PAGE(upl) \ - (((upl)[0].phys_addr != 0) ? ((upl)[0].device) : FALSE) - -#define UPL_PAGE_PRESENT(upl, index) \ - ((upl)[(index)].phys_addr != 0) - -#define UPL_PHYS_PAGE(upl, index) \ - ((upl)[(index)].phys_addr) - -#define UPL_SPECULATIVE_PAGE(upl, index) \ - (((upl)[(index)].phys_addr != 0) ? ((upl)[(index)].speculative) : FALSE) - -#define UPL_DIRTY_PAGE(upl, index) \ - (((upl)[(index)].phys_addr != 0) ? ((upl)[(index)].dirty) : FALSE) - -#define UPL_PRECIOUS_PAGE(upl, index) \ - (((upl)[(index)].phys_addr != 0) ? ((upl)[(index)].precious) : FALSE) - -#define UPL_VALID_PAGE(upl, index) \ - (((upl)[(index)].phys_addr != 0) ? (!((upl)[(index)].absent)) : FALSE) - -#define UPL_PAGEOUT_PAGE(upl, index) \ - (((upl)[(index)].phys_addr != 0) ? ((upl)[(index)].pageout) : FALSE) - -#define UPL_SET_PAGE_FREE_ON_COMMIT(upl, index) \ - (((upl)[(index)].phys_addr != 0) ? \ - ((upl)[(index)].pageout = TRUE) : FALSE) - -#define UPL_CLR_PAGE_FREE_ON_COMMIT(upl, index) \ - (((upl)[(index)].phys_addr != 0) ? \ - ((upl)[(index)].pageout = FALSE) : FALSE) - -/* modifier macros for upl_t */ - -#define UPL_SET_CS_VALIDATED(upl, index, value) \ - ((upl)[(index)].cs_validated = ((value) ? TRUE : FALSE)) - -#define UPL_SET_CS_TAINTED(upl, index, value) \ - ((upl)[(index)].cs_tainted = ((value) ? TRUE : FALSE)) - -/* The call prototyped below is used strictly by UPL_GET_INTERNAL_PAGE_LIST */ - -extern vm_size_t upl_offset_to_pagelist; -extern vm_size_t upl_get_internal_pagelist_offset(void); -extern void* upl_get_internal_vectorupl(upl_t); -extern upl_page_info_t* upl_get_internal_vectorupl_pagelist(upl_t); - -/*Use this variant to get the UPL's page list iff:*/ -/*- the upl being passed in is already part of a vector UPL*/ -/*- the page list you want is that of this "sub-upl" and not that of the entire vector-upl*/ - -#define UPL_GET_INTERNAL_PAGE_LIST_SIMPLE(upl) \ - ((upl_page_info_t *)((upl_offset_to_pagelist == 0) ? \ - (uintptr_t)upl + (unsigned int)(upl_offset_to_pagelist = upl_get_internal_pagelist_offset()): \ - (uintptr_t)upl + (unsigned int)upl_offset_to_pagelist)) - -/* UPL_GET_INTERNAL_PAGE_LIST is only valid on internal objects where the */ -/* list request was made with the UPL_INTERNAL flag */ - - -#define UPL_GET_INTERNAL_PAGE_LIST(upl) \ - ((upl_get_internal_vectorupl(upl) != NULL ) ? (upl_get_internal_vectorupl_pagelist(upl)) : \ - ((upl_page_info_t *)((upl_offset_to_pagelist == 0) ? \ - (uintptr_t)upl + (unsigned int)(upl_offset_to_pagelist = upl_get_internal_pagelist_offset()): \ - (uintptr_t)upl + (unsigned int)upl_offset_to_pagelist))) - -__BEGIN_DECLS - -extern ppnum_t upl_phys_page(upl_page_info_t *upl, int index); -extern boolean_t upl_device_page(upl_page_info_t *upl); -extern boolean_t upl_speculative_page(upl_page_info_t *upl, int index); -extern void upl_clear_dirty(upl_t upl, boolean_t value); -extern void upl_set_referenced(upl_t upl, boolean_t value); -extern void upl_range_needed(upl_t upl, int index, int count); - -__END_DECLS - -#endif /* PRIVATE */ - -__BEGIN_DECLS - -extern boolean_t upl_page_present(upl_page_info_t *upl, int index); -extern boolean_t upl_dirty_page(upl_page_info_t *upl, int index); -extern boolean_t upl_valid_page(upl_page_info_t *upl, int index); -extern void upl_deallocate(upl_t upl); - -__END_DECLS - -#endif /* KERNEL */ - -#endif /* _MACH_MEMORY_OBJECT_TYPES_H_ */ diff --git a/include/xnu/mach/message.h b/include/xnu/mach/message.h deleted file mode 100644 index eba414fc1..000000000 --- a/include/xnu/mach/message.h +++ /dev/null @@ -1,812 +0,0 @@ -/* - * Copyright (c) 2000-2005 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@ - */ -/* - * @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 Software.Distribution@CS.CMU.EDU - * 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. - */ -/* - * NOTICE: This file was modified by McAfee Research in 2004 to introduce - * support for mandatory and extensible security protections. This notice - * is included in support of clause 2.2 (b) of the Apple Public License, - * Version 2.0. - * Copyright (c) 2005 SPARTA, Inc. - */ -/* - */ -/* - * File: mach/message.h - * - * Mach IPC message and primitive function definitions. - */ - -#ifndef _MACH_MESSAGE_H_ -#define _MACH_MESSAGE_H_ - -#include -#include -#include -#include -#include - -#include -#include - -/* - * The timeout mechanism uses mach_msg_timeout_t values, - * passed by value. The timeout units are milliseconds. - * It is controlled with the MACH_SEND_TIMEOUT - * and MACH_RCV_TIMEOUT options. - */ - -typedef natural_t mach_msg_timeout_t; - -/* - * The value to be used when there is no timeout. - * (No MACH_SEND_TIMEOUT/MACH_RCV_TIMEOUT option.) - */ - -#define MACH_MSG_TIMEOUT_NONE ((mach_msg_timeout_t) 0) - -/* - * The kernel uses MACH_MSGH_BITS_COMPLEX as a hint. If it isn't on, it - * assumes the body of the message doesn't contain port rights or OOL - * data. The field is set in received messages. A user task must - * use caution in interpreting the body of a message if the bit isn't - * on, because the mach_msg_type's in the body might "lie" about the - * contents. If the bit isn't on, but the mach_msg_types - * in the body specify rights or OOL data, the behavior is undefined. - * (Ie, an error may or may not be produced.) - * - * The value of MACH_MSGH_BITS_REMOTE determines the interpretation - * of the msgh_remote_port field. It is handled like a msgt_name. - * - * The value of MACH_MSGH_BITS_LOCAL determines the interpretation - * of the msgh_local_port field. It is handled like a msgt_name. - * - * MACH_MSGH_BITS() combines two MACH_MSG_TYPE_* values, for the remote - * and local fields, into a single value suitable for msgh_bits. - * - * MACH_MSGH_BITS_CIRCULAR should be zero; is is used internally. - * - * The unused bits should be zero and are reserved for the kernel - * or for future interface expansion. - */ - -#define MACH_MSGH_BITS_ZERO 0x00000000 -#define MACH_MSGH_BITS_REMOTE_MASK 0x000000ff -#define MACH_MSGH_BITS_LOCAL_MASK 0x0000ff00 -#define MACH_MSGH_BITS_COMPLEX 0x80000000U -#define MACH_MSGH_BITS_USER 0x8000ffffU - -#define MACH_MSGH_BITS_CIRCULAR 0x40000000 /* internal use only */ -#define MACH_MSGH_BITS_USED 0xc000ffffU - -#define MACH_MSGH_BITS_PORTS_MASK \ - (MACH_MSGH_BITS_REMOTE_MASK|MACH_MSGH_BITS_LOCAL_MASK) - -#define MACH_MSGH_BITS(remote, local) \ - ((remote) | ((local) << 8)) -#define MACH_MSGH_BITS_REMOTE(bits) \ - ((bits) & MACH_MSGH_BITS_REMOTE_MASK) -#define MACH_MSGH_BITS_LOCAL(bits) \ - (((bits) & MACH_MSGH_BITS_LOCAL_MASK) >> 8) -#define MACH_MSGH_BITS_PORTS(bits) \ - ((bits) & MACH_MSGH_BITS_PORTS_MASK) -#define MACH_MSGH_BITS_OTHER(bits) \ - ((bits) &~ MACH_MSGH_BITS_PORTS_MASK) - -/* - * Every message starts with a message header. - * Following the message header, if the message is complex, are a count - * of type descriptors and the type descriptors themselves - * (mach_msg_descriptor_t). The size of the message must be specified in - * bytes, and includes the message header, descriptor count, descriptors, - * and inline data. - * - * The msgh_remote_port field specifies the destination of the message. - * It must specify a valid send or send-once right for a port. - * - * The msgh_local_port field specifies a "reply port". Normally, - * This field carries a send-once right that the receiver will use - * to reply to the message. It may carry the values MACH_PORT_NULL, - * MACH_PORT_DEAD, a send-once right, or a send right. - * - * The msgh_seqno field carries a sequence number associated with the - * received-from port. A port's sequence number is incremented every - * time a message is received from it. In sent messages, the field's - * value is ignored. - * - * The msgh_id field is uninterpreted by the message primitives. - * It normally carries information specifying the format - * or meaning of the message. - */ - -typedef unsigned int mach_msg_bits_t; -typedef natural_t mach_msg_size_t; -typedef integer_t mach_msg_id_t; - - -#define MACH_MSG_SIZE_NULL (mach_msg_size_t *) 0 - -typedef unsigned int mach_msg_type_name_t; - -#define MACH_MSG_TYPE_MOVE_RECEIVE 16 /* Must hold receive rights */ -#define MACH_MSG_TYPE_MOVE_SEND 17 /* Must hold send rights */ -#define MACH_MSG_TYPE_MOVE_SEND_ONCE 18 /* Must hold sendonce rights */ -#define MACH_MSG_TYPE_COPY_SEND 19 /* Must hold send rights */ -#define MACH_MSG_TYPE_MAKE_SEND 20 /* Must hold receive rights */ -#define MACH_MSG_TYPE_MAKE_SEND_ONCE 21 /* Must hold receive rights */ -#define MACH_MSG_TYPE_COPY_RECEIVE 22 /* Must hold receive rights */ - -typedef unsigned int mach_msg_copy_options_t; - -#define MACH_MSG_PHYSICAL_COPY 0 -#define MACH_MSG_VIRTUAL_COPY 1 -#define MACH_MSG_ALLOCATE 2 -#define MACH_MSG_OVERWRITE 3 -#ifdef MACH_KERNEL -#define MACH_MSG_KALLOC_COPY_T 4 -#endif /* MACH_KERNEL */ - -/* - * In a complex mach message, the mach_msg_header_t is followed by - * a descriptor count, then an array of that number of descriptors - * (mach_msg_*_descriptor_t). The type field of mach_msg_type_descriptor_t - * (which any descriptor can be cast to) indicates the flavor of the - * descriptor. - * - * Note that in LP64, the various types of descriptors are no longer all - * the same size as mach_msg_descriptor_t, so the array cannot be indexed - * as expected. - */ - -typedef unsigned int mach_msg_descriptor_type_t; - -#define MACH_MSG_PORT_DESCRIPTOR 0 -#define MACH_MSG_OOL_DESCRIPTOR 1 -#define MACH_MSG_OOL_PORTS_DESCRIPTOR 2 -#define MACH_MSG_OOL_VOLATILE_DESCRIPTOR 3 - -#pragma pack(4) - -typedef struct -{ - natural_t pad1; - mach_msg_size_t pad2; - unsigned int pad3 : 24; - mach_msg_descriptor_type_t type : 8; -} mach_msg_type_descriptor_t; - -typedef struct -{ - mach_port_t name; -#if !(defined(KERNEL) && defined(__LP64__)) -// Pad to 8 bytes everywhere except the K64 kernel where mach_port_t is 8 bytes - mach_msg_size_t pad1; -#endif - unsigned int pad2 : 16; - mach_msg_type_name_t disposition : 8; - mach_msg_descriptor_type_t type : 8; -#if defined(KERNEL) - uint32_t pad_end; -#endif -} mach_msg_port_descriptor_t; - -typedef struct -{ - uint32_t address; - mach_msg_size_t size; - boolean_t deallocate: 8; - mach_msg_copy_options_t copy: 8; - unsigned int pad1: 8; - mach_msg_descriptor_type_t type: 8; -} mach_msg_ool_descriptor32_t; - -typedef struct -{ - uint64_t address; - boolean_t deallocate: 8; - mach_msg_copy_options_t copy: 8; - unsigned int pad1: 8; - mach_msg_descriptor_type_t type: 8; - mach_msg_size_t size; -} mach_msg_ool_descriptor64_t; - -typedef struct -{ - void* address; -#if !defined(__LP64__) - mach_msg_size_t size; -#endif - boolean_t deallocate: 8; - mach_msg_copy_options_t copy: 8; - unsigned int pad1: 8; - mach_msg_descriptor_type_t type: 8; -#if defined(__LP64__) - mach_msg_size_t size; -#endif -#if defined(KERNEL) && !defined(__LP64__) - uint32_t pad_end; -#endif -} mach_msg_ool_descriptor_t; - -typedef struct -{ - uint32_t address; - mach_msg_size_t count; - boolean_t deallocate: 8; - mach_msg_copy_options_t copy: 8; - mach_msg_type_name_t disposition : 8; - mach_msg_descriptor_type_t type : 8; -} mach_msg_ool_ports_descriptor32_t; - -typedef struct -{ - uint64_t address; - boolean_t deallocate: 8; - mach_msg_copy_options_t copy: 8; - mach_msg_type_name_t disposition : 8; - mach_msg_descriptor_type_t type : 8; - mach_msg_size_t count; -} mach_msg_ool_ports_descriptor64_t; - -typedef struct -{ - void* address; -#if !defined(__LP64__) - mach_msg_size_t count; -#endif - boolean_t deallocate: 8; - mach_msg_copy_options_t copy: 8; - mach_msg_type_name_t disposition : 8; - mach_msg_descriptor_type_t type : 8; -#if defined(__LP64__) - mach_msg_size_t count; -#endif -#if defined(KERNEL) && !defined(__LP64__) - uint32_t pad_end; -#endif -} mach_msg_ool_ports_descriptor_t; - -/* - * LP64support - This union definition is not really - * appropriate in LP64 mode because not all descriptors - * are of the same size in that environment. - */ -#if defined(__LP64__) && defined(KERNEL) -typedef union -{ - mach_msg_port_descriptor_t port; - mach_msg_ool_descriptor32_t out_of_line; - mach_msg_ool_ports_descriptor32_t ool_ports; - mach_msg_type_descriptor_t type; -} mach_msg_descriptor_t; -#else -typedef union -{ - mach_msg_port_descriptor_t port; - mach_msg_ool_descriptor_t out_of_line; - mach_msg_ool_ports_descriptor_t ool_ports; - mach_msg_type_descriptor_t type; -} mach_msg_descriptor_t; -#endif - -typedef struct -{ - mach_msg_size_t msgh_descriptor_count; -} mach_msg_body_t; - -#define MACH_MSG_BODY_NULL (mach_msg_body_t *) 0 -#define MACH_MSG_DESCRIPTOR_NULL (mach_msg_descriptor_t *) 0 - -typedef struct -{ - mach_msg_bits_t msgh_bits; - mach_msg_size_t msgh_size; - mach_port_t msgh_remote_port; - mach_port_t msgh_local_port; - mach_msg_size_t msgh_reserved; - mach_msg_id_t msgh_id; -} mach_msg_header_t; - -#define MACH_MSG_NULL (mach_msg_header_t *) 0 - -typedef struct -{ - mach_msg_header_t header; - mach_msg_body_t body; -} mach_msg_base_t; - -typedef unsigned int mach_msg_trailer_type_t; - -#define MACH_MSG_TRAILER_FORMAT_0 0 - -typedef unsigned int mach_msg_trailer_size_t; - -typedef struct -{ - mach_msg_trailer_type_t msgh_trailer_type; - mach_msg_trailer_size_t msgh_trailer_size; -} mach_msg_trailer_t; - -typedef struct -{ - mach_msg_trailer_type_t msgh_trailer_type; - mach_msg_trailer_size_t msgh_trailer_size; - mach_port_seqno_t msgh_seqno; -} mach_msg_seqno_trailer_t; - -typedef struct -{ - unsigned int val[2]; -} security_token_t; - -typedef struct -{ - mach_msg_trailer_type_t msgh_trailer_type; - mach_msg_trailer_size_t msgh_trailer_size; - mach_port_seqno_t msgh_seqno; - security_token_t msgh_sender; -} mach_msg_security_trailer_t; - -/* - * The audit token is an opaque token which identifies - * Mach tasks and senders of Mach messages as subjects - * to the BSM audit system. Only the appropriate BSM - * library routines should be used to interpret the - * contents of the audit token as the representation - * of the subject identity within the token may change - * over time. - */ -typedef struct -{ - unsigned int val[8]; -} audit_token_t; - -typedef struct -{ - mach_msg_trailer_type_t msgh_trailer_type; - mach_msg_trailer_size_t msgh_trailer_size; - mach_port_seqno_t msgh_seqno; - security_token_t msgh_sender; - audit_token_t msgh_audit; -} mach_msg_audit_trailer_t; - -typedef struct -{ - mach_msg_trailer_type_t msgh_trailer_type; - mach_msg_trailer_size_t msgh_trailer_size; - mach_port_seqno_t msgh_seqno; - security_token_t msgh_sender; - audit_token_t msgh_audit; - mach_port_context_t msgh_context; -} mach_msg_context_trailer_t; - -typedef struct -{ - mach_port_name_t sender; -} msg_labels_t; - -/* - Trailer type to pass MAC policy label info as a mach message trailer. - -*/ - -typedef struct -{ - mach_msg_trailer_type_t msgh_trailer_type; - mach_msg_trailer_size_t msgh_trailer_size; - mach_port_seqno_t msgh_seqno; - security_token_t msgh_sender; - audit_token_t msgh_audit; - mach_port_context_t msgh_context; - int msgh_ad; - msg_labels_t msgh_labels; -} mach_msg_mac_trailer_t; - -#define MACH_MSG_TRAILER_MINIMUM_SIZE sizeof(mach_msg_trailer_t) - -/* - * These values can change from release to release - but clearly - * code cannot request additional trailer elements one was not - * compiled to understand. Therefore, it is safe to use this - * constant when the same module specified the receive options. - * Otherwise, you run the risk that the options requested by - * another module may exceed the local modules notion of - * MAX_TRAILER_SIZE. - */ -typedef mach_msg_mac_trailer_t mach_msg_max_trailer_t; -#define MAX_TRAILER_SIZE ((mach_msg_size_t)sizeof(mach_msg_max_trailer_t)) - -/* - * Legacy requirements keep us from ever updating these defines (even - * when the format_0 trailers gain new option data fields in the future). - * Therefore, they shouldn't be used going forward. Instead, the sizes - * should be compared against the specific element size requested using - * REQUESTED_TRAILER_SIZE. - */ -typedef mach_msg_security_trailer_t mach_msg_format_0_trailer_t; - -/*typedef mach_msg_mac_trailer_t mach_msg_format_0_trailer_t; -*/ - -#define MACH_MSG_TRAILER_FORMAT_0_SIZE sizeof(mach_msg_format_0_trailer_t) - -#define KERNEL_SECURITY_TOKEN_VALUE { {0, 1} } -extern security_token_t KERNEL_SECURITY_TOKEN; - -#define KERNEL_AUDIT_TOKEN_VALUE { {0, 0, 0, 0, 0, 0, 0, 0} } -extern audit_token_t KERNEL_AUDIT_TOKEN; - -typedef integer_t mach_msg_options_t; - -typedef struct -{ - mach_msg_header_t header; -} mach_msg_empty_send_t; - -typedef struct -{ - mach_msg_header_t header; - mach_msg_trailer_t trailer; -} mach_msg_empty_rcv_t; - -typedef union -{ - mach_msg_empty_send_t send; - mach_msg_empty_rcv_t rcv; -} mach_msg_empty_t; - -#pragma pack() - -/* utility to round the message size - will become machine dependent */ -#define round_msg(x) (((mach_msg_size_t)(x) + sizeof (natural_t) - 1) & \ - ~(sizeof (natural_t) - 1)) - -/* - * There is no fixed upper bound to the size of Mach messages. - */ -#define MACH_MSG_SIZE_MAX ((mach_msg_size_t) ~0) - -#if defined(__APPLE_API_PRIVATE) -/* - * But architectural limits of a given implementation, or - * temporal conditions may cause unpredictable send failures - * for messages larger than MACH_MSG_SIZE_RELIABLE. - * - * In either case, waiting for memory is [currently] outside - * the scope of send timeout values provided to IPC. - */ -#define MACH_MSG_SIZE_RELIABLE ((mach_msg_size_t) 256 * 1024) -#endif -/* - * Compatibility definitions, for code written - * when there was a msgh_kind instead of msgh_seqno. - */ -#define MACH_MSGH_KIND_NORMAL 0x00000000 -#define MACH_MSGH_KIND_NOTIFICATION 0x00000001 -#define msgh_kind msgh_seqno -#define mach_msg_kind_t mach_port_seqno_t - -typedef natural_t mach_msg_type_size_t; -typedef natural_t mach_msg_type_number_t; - -/* - * Values received/carried in messages. Tells the receiver what - * sort of port right he now has. - * - * MACH_MSG_TYPE_PORT_NAME is used to transfer a port name - * which should remain uninterpreted by the kernel. (Port rights - * are not transferred, just the port name.) - */ - -#define MACH_MSG_TYPE_PORT_NONE 0 - -#define MACH_MSG_TYPE_PORT_NAME 15 -#define MACH_MSG_TYPE_PORT_RECEIVE MACH_MSG_TYPE_MOVE_RECEIVE -#define MACH_MSG_TYPE_PORT_SEND MACH_MSG_TYPE_MOVE_SEND -#define MACH_MSG_TYPE_PORT_SEND_ONCE MACH_MSG_TYPE_MOVE_SEND_ONCE - -#define MACH_MSG_TYPE_LAST 22 /* Last assigned */ - -/* - * A dummy value. Mostly used to indicate that the actual value - * will be filled in later, dynamically. - */ - -#define MACH_MSG_TYPE_POLYMORPHIC ((mach_msg_type_name_t) -1) - -/* - * Is a given item a port type? - */ - -#define MACH_MSG_TYPE_PORT_ANY(x) \ - (((x) >= MACH_MSG_TYPE_MOVE_RECEIVE) && \ - ((x) <= MACH_MSG_TYPE_MAKE_SEND_ONCE)) - -#define MACH_MSG_TYPE_PORT_ANY_SEND(x) \ - (((x) >= MACH_MSG_TYPE_MOVE_SEND) && \ - ((x) <= MACH_MSG_TYPE_MAKE_SEND_ONCE)) - -#define MACH_MSG_TYPE_PORT_ANY_RIGHT(x) \ - (((x) >= MACH_MSG_TYPE_MOVE_RECEIVE) && \ - ((x) <= MACH_MSG_TYPE_MOVE_SEND_ONCE)) - -typedef integer_t mach_msg_option_t; - -#define MACH_MSG_OPTION_NONE 0x00000000 - -#define MACH_SEND_MSG 0x00000001 -#define MACH_RCV_MSG 0x00000002 -#define MACH_RCV_LARGE 0x00000004 - -#define MACH_SEND_TIMEOUT 0x00000010 -#define MACH_SEND_INTERRUPT 0x00000040 /* libmach implements */ -#define MACH_SEND_NOTIFY 0x00000080 /* arm send-possible notify */ -#define MACH_SEND_ALWAYS 0x00010000 /* internal use only */ -#define MACH_SEND_TRAILER 0x00020000 - -#define MACH_RCV_TIMEOUT 0x00000100 -#define MACH_RCV_NOTIFY 0x00000200 /* reserved - legacy */ -#define MACH_RCV_INTERRUPT 0x00000400 /* libmach implements */ -#define MACH_RCV_OVERWRITE 0x00001000 - -/* - * NOTE: a 0x00------ RCV mask implies to ask for - * a MACH_MSG_TRAILER_FORMAT_0 with 0 Elements, - * which is equivalent to a mach_msg_trailer_t. - * - * XXXMAC: unlike the rest of the MACH_RCV_* flags, MACH_RCV_TRAILER_LABELS - * needs its own private bit since we only calculate its fields when absolutely - * required. - */ -#define MACH_RCV_TRAILER_NULL 0 -#define MACH_RCV_TRAILER_SEQNO 1 -#define MACH_RCV_TRAILER_SENDER 2 -#define MACH_RCV_TRAILER_AUDIT 3 -#define MACH_RCV_TRAILER_CTX 4 -#define MACH_RCV_TRAILER_AV 7 -#define MACH_RCV_TRAILER_LABELS 8 - -#define MACH_RCV_TRAILER_TYPE(x) (((x) & 0xf) << 28) -#define MACH_RCV_TRAILER_ELEMENTS(x) (((x) & 0xf) << 24) -#define MACH_RCV_TRAILER_MASK ((0xff << 24)) - -#define GET_RCV_ELEMENTS(y) (((y) >> 24) & 0xf) - -/* - * XXXMAC: note that in the case of MACH_RCV_TRAILER_LABELS, - * we just fall through to mach_msg_max_trailer_t. - * This is correct behavior since mach_msg_max_trailer_t is defined as - * mac_msg_mac_trailer_t which is used for the LABELS trailer. - * It also makes things work properly if MACH_RCV_TRAILER_LABELS is ORed - * with one of the other options. - */ - -#define REQUESTED_TRAILER_SIZE_NATIVE(y) \ - ((mach_msg_trailer_size_t) \ - ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_NULL) ? \ - sizeof(mach_msg_trailer_t) : \ - ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SEQNO) ? \ - sizeof(mach_msg_seqno_trailer_t) : \ - ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SENDER) ? \ - sizeof(mach_msg_security_trailer_t) : \ - ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_AUDIT) ? \ - sizeof(mach_msg_audit_trailer_t) : \ - ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_CTX) ? \ - sizeof(mach_msg_context_trailer_t) : \ - ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_AV) ? \ - sizeof(mach_msg_mac_trailer_t) : \ - sizeof(mach_msg_max_trailer_t)))))))) - - -#ifdef XNU_KERNEL_PRIVATE - -#define REQUESTED_TRAILER_SIZE(is64, y) REQUESTED_TRAILER_SIZE_NATIVE(y) - -#else /* XNU_KERNEL_PRIVATE */ -#define REQUESTED_TRAILER_SIZE(y) REQUESTED_TRAILER_SIZE_NATIVE(y) -#endif /* XNU_KERNEL_PRIVATE */ - -/* - * Much code assumes that mach_msg_return_t == kern_return_t. - * This definition is useful for descriptive purposes. - * - * See for the format of error codes. - * IPC errors are system 4. Send errors are subsystem 0; - * receive errors are subsystem 1. The code field is always non-zero. - * The high bits of the code field communicate extra information - * for some error codes. MACH_MSG_MASK masks off these special bits. - */ - -typedef kern_return_t mach_msg_return_t; - -#define MACH_MSG_SUCCESS 0x00000000 - - -#define MACH_MSG_MASK 0x00003e00 - /* All special error code bits defined below. */ -#define MACH_MSG_IPC_SPACE 0x00002000 - /* No room in IPC name space for another capability name. */ -#define MACH_MSG_VM_SPACE 0x00001000 - /* No room in VM address space for out-of-line memory. */ -#define MACH_MSG_IPC_KERNEL 0x00000800 - /* Kernel resource shortage handling an IPC capability. */ -#define MACH_MSG_VM_KERNEL 0x00000400 - /* Kernel resource shortage handling out-of-line memory. */ - -#define MACH_SEND_IN_PROGRESS 0x10000001 - /* Thread is waiting to send. (Internal use only.) */ -#define MACH_SEND_INVALID_DATA 0x10000002 - /* Bogus in-line data. */ -#define MACH_SEND_INVALID_DEST 0x10000003 - /* Bogus destination port. */ -#define MACH_SEND_TIMED_OUT 0x10000004 - /* Message not sent before timeout expired. */ -#define MACH_SEND_INTERRUPTED 0x10000007 - /* Software interrupt. */ -#define MACH_SEND_MSG_TOO_SMALL 0x10000008 - /* Data doesn't contain a complete message. */ -#define MACH_SEND_INVALID_REPLY 0x10000009 - /* Bogus reply port. */ -#define MACH_SEND_INVALID_RIGHT 0x1000000a - /* Bogus port rights in the message body. */ -#define MACH_SEND_INVALID_NOTIFY 0x1000000b - /* Bogus notify port argument. */ -#define MACH_SEND_INVALID_MEMORY 0x1000000c - /* Invalid out-of-line memory pointer. */ -#define MACH_SEND_NO_BUFFER 0x1000000d - /* No message buffer is available. */ -#define MACH_SEND_TOO_LARGE 0x1000000e - /* Send is too large for port */ -#define MACH_SEND_INVALID_TYPE 0x1000000f - /* Invalid msg-type specification. */ -#define MACH_SEND_INVALID_HEADER 0x10000010 - /* A field in the header had a bad value. */ -#define MACH_SEND_INVALID_TRAILER 0x10000011 - /* The trailer to be sent does not match kernel format. */ -#define MACH_SEND_INVALID_RT_OOL_SIZE 0x10000015 - /* compatibility: no longer a returned error */ - -#define MACH_RCV_IN_PROGRESS 0x10004001 - /* Thread is waiting for receive. (Internal use only.) */ -#define MACH_RCV_INVALID_NAME 0x10004002 - /* Bogus name for receive port/port-set. */ -#define MACH_RCV_TIMED_OUT 0x10004003 - /* Didn't get a message within the timeout value. */ -#define MACH_RCV_TOO_LARGE 0x10004004 - /* Message buffer is not large enough for inline data. */ -#define MACH_RCV_INTERRUPTED 0x10004005 - /* Software interrupt. */ -#define MACH_RCV_PORT_CHANGED 0x10004006 - /* compatibility: no longer a returned error */ -#define MACH_RCV_INVALID_NOTIFY 0x10004007 - /* Bogus notify port argument. */ -#define MACH_RCV_INVALID_DATA 0x10004008 - /* Bogus message buffer for inline data. */ -#define MACH_RCV_PORT_DIED 0x10004009 - /* Port/set was sent away/died during receive. */ -#define MACH_RCV_IN_SET 0x1000400a - /* compatibility: no longer a returned error */ -#define MACH_RCV_HEADER_ERROR 0x1000400b - /* Error receiving message header. See special bits. */ -#define MACH_RCV_BODY_ERROR 0x1000400c - /* Error receiving message body. See special bits. */ -#define MACH_RCV_INVALID_TYPE 0x1000400d - /* Invalid msg-type specification in scatter list. */ -#define MACH_RCV_SCATTER_SMALL 0x1000400e - /* Out-of-line overwrite region is not large enough */ -#define MACH_RCV_INVALID_TRAILER 0x1000400f - /* trailer type or number of trailer elements not supported */ -#define MACH_RCV_IN_PROGRESS_TIMED 0x10004011 - /* Waiting for receive with timeout. (Internal use only.) */ - - -__BEGIN_DECLS - -/* - * Routine: mach_msg_overwrite - * Purpose: - * Send and/or receive a message. If the message operation - * is interrupted, and the user did not request an indication - * of that fact, then restart the appropriate parts of the - * operation silently (trap version does not restart). - * - * Distinct send and receive buffers may be specified. If - * no separate receive buffer is specified, the msg parameter - * will be used for both send and receive operations. - * - * In addition to a distinct receive buffer, that buffer may - * already contain scatter control information to direct the - * receiving of the message. - */ - -extern mach_msg_return_t mach_msg_overwrite( - mach_msg_header_t *msg, - mach_msg_option_t option, - mach_msg_size_t send_size, - mach_msg_size_t rcv_size, - mach_port_name_t rcv_name, - mach_msg_timeout_t timeout, - mach_port_name_t notify, - mach_msg_header_t *rcv_msg, - mach_msg_size_t rcv_limit); - -#ifndef KERNEL - -/* - * Routine: mach_msg - * Purpose: - * Send and/or receive a message. If the message operation - * is interrupted, and the user did not request an indication - * of that fact, then restart the appropriate parts of the - * operation silently (trap version does not restart). - */ -extern mach_msg_return_t mach_msg( - mach_msg_header_t *msg, - mach_msg_option_t option, - mach_msg_size_t send_size, - mach_msg_size_t rcv_size, - mach_port_name_t rcv_name, - mach_msg_timeout_t timeout, - mach_port_name_t notify); - -#elif defined(MACH_KERNEL_PRIVATE) - -extern mach_msg_return_t mach_msg_receive_results(void); - -#endif /* KERNEL */ - -__END_DECLS - -#endif /* _MACH_MESSAGE_H_ */ - diff --git a/include/xnu/mach/mig.h b/include/xnu/mach/mig.h deleted file mode 100644 index 3d7655076..000000000 --- a/include/xnu/mach/mig.h +++ /dev/null @@ -1,297 +0,0 @@ -/* - * Copyright (c) 2000-2007 Apple 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@ - */ -/* - * @OSF_COPYRIGHT@ - */ - -/* - * Mach MIG Subsystem Interfaces - */ - -#ifndef _MACH_MIG_H_ -#define _MACH_MIG_H_ - -#include -#include -#include -#include - -#include - -#if defined(MACH_KERNEL) - -#if !defined(__MigTypeCheck) -/* Turn MIG type checking on by default for kernel */ -#define __MigTypeCheck 1 -#endif - -#define __MigKernelSpecificCode 1 -#define _MIG_KERNEL_SPECIFIC_CODE_ 1 - -#elif !defined(__MigTypeCheck) - -#if defined(TypeCheck) -/* use legacy setting (temporary) */ -#define __MigTypeCheck TypeCheck -#else -/* default MIG type checking on */ -#define __MigTypeCheck 1 -#endif - -#endif /* !defined(MACH_KERNEL) && !defined(__MigTypeCheck) */ - -/* - * Pack MIG message structs. - * This is an indicator of the need to view shared structs in a - * binary-compatible format - and MIG message structs are no different. - */ -#define __MigPackStructs 1 - -/* - * Definition for MIG-generated server stub routines. These routines - * unpack the request message, call the server procedure, and pack the - * reply message. - */ -typedef void (*mig_stub_routine_t) (mach_msg_header_t *InHeadP, - mach_msg_header_t *OutHeadP); - -typedef mig_stub_routine_t mig_routine_t; - -/* - * Definition for MIG-generated server routine. This routine takes a - * message, and returns the appropriate stub function for handling that - * message. - */ -typedef mig_routine_t (*mig_server_routine_t) (mach_msg_header_t *InHeadP); - -/* - * Generic definition for implementation routines. These routines do - * the real work associated with this request. This generic type is - * used for keeping the pointers in the subsystem array. - */ -typedef kern_return_t (*mig_impl_routine_t)(void); - -typedef mach_msg_type_descriptor_t routine_arg_descriptor; -typedef mach_msg_type_descriptor_t *routine_arg_descriptor_t; -typedef mach_msg_type_descriptor_t *mig_routine_arg_descriptor_t; - -#define MIG_ROUTINE_ARG_DESCRIPTOR_NULL ((mig_routine_arg_descriptor_t)0) - -struct routine_descriptor { - mig_impl_routine_t impl_routine; /* Server work func pointer */ - mig_stub_routine_t stub_routine; /* Unmarshalling func pointer */ - unsigned int argc; /* Number of argument words */ - unsigned int descr_count; /* Number complex descriptors */ - routine_arg_descriptor_t - arg_descr; /* pointer to descriptor array*/ - unsigned int max_reply_msg; /* Max size for reply msg */ -}; -typedef struct routine_descriptor *routine_descriptor_t; - -typedef struct routine_descriptor mig_routine_descriptor; -typedef mig_routine_descriptor *mig_routine_descriptor_t; - -#define MIG_ROUTINE_DESCRIPTOR_NULL ((mig_routine_descriptor_t)0) - -typedef struct mig_subsystem { - mig_server_routine_t server; /* pointer to demux routine */ - mach_msg_id_t start; /* Min routine number */ - mach_msg_id_t end; /* Max routine number + 1 */ - mach_msg_size_t maxsize; /* Max reply message size */ - vm_address_t reserved; /* reserved for MIG use */ - mig_routine_descriptor - routine[1]; /* Routine descriptor array */ -} *mig_subsystem_t; - -#define MIG_SUBSYSTEM_NULL ((mig_subsystem_t)0) - -typedef struct mig_symtab { - char *ms_routine_name; - int ms_routine_number; - void (*ms_routine)(void); /* Since the functions in the - * symbol table have unknown - * signatures, this is the best - * we can do... - */ -} mig_symtab_t; - -#ifdef PRIVATE - -/* MIG object runtime - not ready for public consumption */ - -#ifdef KERNEL_PRIVATE - -/* - * MIG object runtime definitions - * - * Conforming MIG subsystems may enable this support to get - * significant assistance from the base mig_object_t implementation. - * - * Support includes: - * - Transparency from port manipulation. - * - Dymanic port allocation on first "remoting" of an object. - * - Reference conversions from object to port and vice versa. - * - Automatic port deallocation on no-more-senders. - * - Support for multiple server implementations in a single space. - * - Messaging bypass for local servers. - * - Automatic hookup to base dispatch mechanism. - * - General notification support - * Coming soon: - * - User-level support - */ -typedef unsigned int mig_notify_type_t; - -typedef struct MIGIID { - unsigned long data1; - unsigned short data2; - unsigned short data3; - unsigned char data4[8]; -} MIGIID; - -typedef struct IMIGObjectVtbl IMIGObjectVtbl; -typedef struct IMIGNotifyObjectVtbl IMIGNotifyObjectVtbl; - -typedef struct IMIGObject { - const IMIGObjectVtbl *pVtbl; -} IMIGObject; - -typedef struct IMIGNotifyObject { - const IMIGNotifyObjectVtbl *pVtbl; -} IMIGNotifyObject; - -struct IMIGObjectVtbl { - kern_return_t (*QueryInterface)( - IMIGObject *object, - const MIGIID *iid, - void **ppv); - - unsigned long (*AddRef)( - IMIGObject *object); - - unsigned long (*Release)( - IMIGObject *object); - - unsigned long (*GetServer)( - IMIGObject *object, - mig_server_routine_t *server); - - boolean_t (*RaiseNotification)( - IMIGObject *object, - mig_notify_type_t notify_type); - - boolean_t (*RequestNotification)( - IMIGObject *object, - IMIGNotifyObject *notify, - mig_notify_type_t notify_type); -}; - -/* - * IMIGNotifyObject - * - * A variant of the IMIGObject interface that is a sink for - * MIG notifications. - * - * A reference is held on both the subject MIGObject and the target - * MIGNotifyObject. Because of this, care must be exercised to avoid - * reference cycles. Once a notification is raised, the object - * reference is returned and the request must be re-requested (if - * desired). - * - * One interesting note: because this interface is itself a MIG - * object, one may request notification about state changes in - * the MIGNotifyObject itself. - */ -struct IMIGNotifyObjectVtbl { - kern_return_t (*QueryInterface)( - IMIGNotifyObject *notify, - const MIGIID *iid, - void **ppv); - - unsigned long (*AddRef)( - IMIGNotifyObject *notify); - - unsigned long (*Release)( - IMIGNotifyObject *notify); - - unsigned long (*GetServer)( - IMIGNotifyObject *notify, - mig_server_routine_t *server); - - boolean_t (*RaiseNotification)( - IMIGNotifyObject *notify, - mig_notify_type_t notify_type); - - boolean_t (*RequestNotification)( - IMIGNotifyObject *notify, - IMIGNotifyObject *notify_notify, - mig_notify_type_t notify_type); - - void (*HandleNotification)( - IMIGNotifyObject *notify, - IMIGObject *object, - mig_notify_type_t notify_type); -}; - -#endif /* KERNEL_PRIVATE */ -#endif /* PRIVATE */ - -__BEGIN_DECLS - -/* Client side reply port allocate */ -extern mach_port_t mig_get_reply_port(void); - -/* Client side reply port deallocate */ -extern void mig_dealloc_reply_port(mach_port_t reply_port); - -/* Client side reply port "deallocation" */ -extern void mig_put_reply_port(mach_port_t reply_port); - -/* Bounded string copy */ -extern int mig_strncpy(char *dest, const char *src, int len); - -#ifdef KERNEL_PRIVATE - -/* Allocate memory for out-of-stack mig structures */ -extern char *mig_user_allocate(vm_size_t size); - -/* Deallocate memory used for out-of-stack mig structures */ -extern void mig_user_deallocate(char *data, vm_size_t size); - -#else - -/* Allocate memory for out-of-line mig structures */ -extern void mig_allocate(vm_address_t *, vm_size_t); - -/* Deallocate memory used for out-of-line mig structures */ -extern void mig_deallocate(vm_address_t, vm_size_t); - -#endif /* KERNEL_PRIVATE */ - -__END_DECLS - -#endif /* _MACH_MIG_H_ */ diff --git a/include/xnu/mach/mig_errors.h b/include/xnu/mach/mig_errors.h deleted file mode 100644 index f1234bc7b..000000000 --- a/include/xnu/mach/mig_errors.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2000-2007 Apple 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@ - */ -/* - * @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 Software.Distribution@CS.CMU.EDU - * 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. - */ -/* - */ -/* - * Mach Interface Generator errors - * - */ - -#ifndef _MACH_MIG_ERRORS_H_ -#define _MACH_MIG_ERRORS_H_ - -#include -#include -#include -#include - -#include - -/* - * These error codes should be specified as system 4, subsytem 2. - * But alas backwards compatibility makes that impossible. - * The problem is old clients of new servers (eg, the kernel) - * which get strange large error codes when there is a Mig problem - * in the server. Unfortunately, the IPC system doesn't have - * the knowledge to convert the codes in this situation. - */ - -#define MIG_TYPE_ERROR -300 /* client type check failure */ -#define MIG_REPLY_MISMATCH -301 /* wrong reply message ID */ -#define MIG_REMOTE_ERROR -302 /* server detected error */ -#define MIG_BAD_ID -303 /* bad request message ID */ -#define MIG_BAD_ARGUMENTS -304 /* server type check failure */ -#define MIG_NO_REPLY -305 /* no reply should be send */ -#define MIG_EXCEPTION -306 /* server raised exception */ -#define MIG_ARRAY_TOO_LARGE -307 /* array not large enough */ -#define MIG_SERVER_DIED -308 /* server died */ -#define MIG_TRAILER_ERROR -309 /* trailer has an unknown format */ - -/* - * Whenever MIG detects an error, it sends back a generic - * mig_reply_error_t format message. Clients must accept - * these in addition to the expected reply message format. - */ -#pragma pack(4) -typedef struct { - mach_msg_header_t Head; - NDR_record_t NDR; - kern_return_t RetCode; -} mig_reply_error_t; -#pragma pack() - - -__BEGIN_DECLS - -#if !defined(__NDR_convert__mig_reply_error_t__defined) -#define __NDR_convert__mig_reply_error_t__defined - -static __inline__ void -__NDR_convert__mig_reply_error_t(__unused mig_reply_error_t *x) -{ -#if defined(__NDR_convert__int_rep__kern_return_t__defined) - if (x->NDR.int_rep != NDR_record.int_rep) - __NDR_convert__int_rep__kern_return_t(&x->RetCode, x->NDR.int_rep); -#endif /* __NDR_convert__int_rep__kern_return_t__defined */ -} -#endif /* !defined(__NDR_convert__mig_reply_error_t__defined) */ - -__END_DECLS - -#endif /* _MACH_MIG_ERRORS_H_ */ diff --git a/include/xnu/mach/mig_log.h b/include/xnu/mach/mig_log.h deleted file mode 100644 index 44ce00002..000000000 --- a/include/xnu/mach/mig_log.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * 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@ - */ -/* - * @OSF_COPYRIGHT@ - */ - -#ifndef _mig_log_ -#define _mig_log_ - -#include - -#ifdef __APPLE_API_OBSOLETE - -typedef enum { - MACH_MSG_LOG_USER, - MACH_MSG_LOG_SERVER -} mig_who_t; - -typedef enum { - MACH_MSG_REQUEST_BEING_SENT, - MACH_MSG_REQUEST_BEING_RCVD, - MACH_MSG_REPLY_BEING_SENT, - MACH_MSG_REPLY_BEING_RCVD -} mig_which_event_t; - -typedef enum { - MACH_MSG_ERROR_WHILE_PARSING, - MACH_MSG_ERROR_UNKNOWN_ID -} mig_which_error_t; - -extern void MigEventTracer -#if defined(__STDC__) -( - mig_who_t who, - mig_which_event_t what, - mach_msg_id_t msgh_id, - unsigned int size, - unsigned int kpd, - unsigned int retcode, - unsigned int ports, - unsigned int oolports, - unsigned int ool, - char *file, - unsigned int line -); -#else /* !defined(__STDC__) */ -(); -#endif /* !defined(__STDC__) */ - -extern void MigEventErrors -#if defined(__STDC__) -( - mig_who_t who, - mig_which_error_t what, - void *par, - char *file, - unsigned int line -); -#else /* !defined(__STDC__) */ -(); -#endif /* !defined(__STDC__) */ - -extern int mig_errors; -extern int mig_tracing; - -#define LOG_ERRORS if (mig_errors) MigEventErrors -#define LOG_TRACE if (mig_tracing) MigEventTracer - -#endif /* __APPLE_API_OBSOLETE */ - -#endif /* _mach_log_ */ - diff --git a/include/xnu/mach/mk_timer.h b/include/xnu/mach/mk_timer.h deleted file mode 100644 index 396c1a163..000000000 --- a/include/xnu/mach/mk_timer.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2000-2005 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@ - */ -/* - * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. - * - * HISTORY - * - * 31 August 2000 (debo) - * Created. - */ - -#ifndef _MACH_MK_TIMER_H_ -#define _MACH_MK_TIMER_H_ - -#include -#include - -__BEGIN_DECLS - -mach_port_name_t mk_timer_create(void); - -kern_return_t mk_timer_destroy( - mach_port_name_t name); - -kern_return_t mk_timer_arm( - mach_port_name_t name, - uint64_t expire_time); - -kern_return_t mk_timer_cancel( - mach_port_name_t name, - uint64_t *result_time); - -__END_DECLS - -#pragma pack(4) -struct mk_timer_expire_msg { - mach_msg_header_t header; - uint64_t unused[3]; -}; -#pragma pack() - -typedef struct mk_timer_expire_msg mk_timer_expire_msg_t; - -#endif /* _MACH_MK_TIMER_H_ */ diff --git a/include/xnu/mach/mk_traps.h b/include/xnu/mach/mk_traps.h deleted file mode 100644 index 68e71faa9..000000000 --- a/include/xnu/mach/mk_traps.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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@ - */ -/* - * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. - * - * HISTORY - * - * 20 October 2000 (debo) - * Created. - */ - -#ifndef _MACH_MK_TRAPS_H_ -#define _MACH_MK_TRAPS_H_ - -#endif /* _MACH_MK_TRAPS_H_ */ diff --git a/include/xnu/mach/msg_type.h b/include/xnu/mach/msg_type.h deleted file mode 100644 index fb280331b..000000000 --- a/include/xnu/mach/msg_type.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * 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@ - */ -/* - * @OSF_COPYRIGHT@ - */ -/* - * HISTORY - * - * Revision 1.1.1.1 1998/09/22 21:05:30 wsanchez - * Import of Mac OS X kernel (~semeria) - * - * Revision 1.1.1.1 1998/03/07 02:25:46 wsanchez - * Import of OSF Mach kernel (~mburg) - * - * Revision 1.2.6.1 1994/09/23 02:40:41 ezf - * change marker to not FREE - * [1994/09/22 21:41:56 ezf] - * - * Revision 1.2.2.2 1993/06/09 02:42:32 gm - * Added to OSF/1 R1.3 from NMK15.0. - * [1993/06/02 21:17:31 jeffc] - * - * Revision 1.2 1993/04/19 16:37:56 devrcs - * ansi C conformance changes - * [1993/02/02 18:53:54 david] - * - * Revision 1.1 1992/09/30 02:31:51 robert - * Initial revision - * - * $EndLog$ - */ -/* CMU_HIST */ -/* - * Revision 2.3 91/05/14 16:58:02 mrt - * Correcting copyright - * - * Revision 2.2 91/02/05 17:35:10 mrt - * Changed to new Mach copyright - * [91/02/01 17:17:32 mrt] - * - * Revision 2.1 89/08/03 16:03:38 rwd - * Created. - * - * Revision 2.3 89/02/25 18:39:26 gm0w - * Changes for cleanup. - * - * 4-Mar-87 Michael Young (mwyoung) at Carnegie-Mellon University - * Added MSG_TYPE_RPC. - * - * 22-Dec-86 Mary Thompson - * defined MSG_TYPE_CAMELOT, and MSG_TYPE_ENCRYPTED - * - */ -/* CMU_ENDHIST */ -/* - * 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 Software.Distribution@CS.CMU.EDU - * 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. - */ -/* - */ -/* - * This file defines user msg types that may be ored into - * the msg_type field in a msg header. Values 0-5 are reserved - * for use by the kernel and are defined in message.h. - * - */ - -#ifndef MSG_TYPE_H_ -#define MSG_TYPE_H_ - -#define MSG_TYPE_CAMELOT (1 << 6) -#define MSG_TYPE_ENCRYPTED (1 << 7) -#define MSG_TYPE_RPC (1 << 8) /* Reply expected */ - -#include - -#endif /* MSG_TYPE_H_ */ diff --git a/include/xnu/mach/ndr.h b/include/xnu/mach/ndr.h deleted file mode 100644 index 9baa731fe..000000000 --- a/include/xnu/mach/ndr.h +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (c) 2000-2005 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@ - */ -/* - * @OSF_COPYRIGHT@ - */ - -#ifndef _MACH_NDR_H_ -#define _MACH_NDR_H_ - -#include -#include -#include - - -typedef struct { - unsigned char mig_vers; - unsigned char if_vers; - unsigned char reserved1; - unsigned char mig_encoding; - unsigned char int_rep; - unsigned char char_rep; - unsigned char float_rep; - unsigned char reserved2; -} NDR_record_t; - -/* - * MIG supported protocols for Network Data Representation - */ -#define NDR_PROTOCOL_2_0 0 - -/* - * NDR 2.0 format flag type definition and values. - */ -#define NDR_INT_BIG_ENDIAN 0 -#define NDR_INT_LITTLE_ENDIAN 1 -#define NDR_FLOAT_IEEE 0 -#define NDR_FLOAT_VAX 1 -#define NDR_FLOAT_CRAY 2 -#define NDR_FLOAT_IBM 3 -#define NDR_CHAR_ASCII 0 -#define NDR_CHAR_EBCDIC 1 - -extern NDR_record_t NDR_record; - -/* NDR conversion off by default */ - -#if !defined(__NDR_convert__) -#define __NDR_convert__ 0 -#endif /* !defined(__NDR_convert__) */ - -#ifndef __NDR_convert__int_rep__ -#define __NDR_convert__int_rep__ __NDR_convert__ -#endif /* __NDR_convert__int_rep__ */ - -#ifndef __NDR_convert__char_rep__ -#define __NDR_convert__char_rep__ 0 -#endif /* __NDR_convert__char_rep__ */ - -#ifndef __NDR_convert__float_rep__ -#define __NDR_convert__float_rep__ 0 -#endif /* __NDR_convert__float_rep__ */ - -#if __NDR_convert__ - -#define __NDR_convert__NOOP do ; while (0) -#define __NDR_convert__UNKNOWN(s) __NDR_convert__NOOP -#define __NDR_convert__SINGLE(a, f, r) do { r((a), (f)); } while (0) -#define __NDR_convert__ARRAY(a, f, c, r) \ - do { int __i__, __C__ = (c); \ - for (__i__ = 0; __i__ < __C__; __i__++) \ - r(&(a)[__i__], f); } while (0) -#define __NDR_convert__2DARRAY(a, f, s, c, r) \ - do { int __i__, __C__ = (c), __S__ = (s); \ - for (__i__ = 0; __i__ < __C__; __i__++) \ - r(&(a)[__i__ * __S__], f, __S__); } while (0) - -#if __NDR_convert__int_rep__ - -#define __NDR_READSWAP_assign(a, rs) do { *(a) = rs(a); } while (0) - -#define __NDR_READSWAP__uint16_t(a) OSReadSwapInt16((void *)a, 0) -#define __NDR_READSWAP__int16_t(a) (int16_t)OSReadSwapInt16((void *)a, 0) -#define __NDR_READSWAP__uint32_t(a) OSReadSwapInt32((void *)a, 0) -#define __NDR_READSWAP__int32_t(a) (int32_t)OSReadSwapInt32((void *)a, 0) -#define __NDR_READSWAP__uint64_t(a) OSReadSwapInt64((void *)a, 0) -#define __NDR_READSWAP__int64_t(a) (int64_t)OSReadSwapInt64((void *)a, 0) - -__BEGIN_DECLS - -static __inline__ float __NDR_READSWAP__float(float *argp) { - union { - float sv; - uint32_t ull; - } result; - result.ull = __NDR_READSWAP__uint32_t((uint32_t *)argp); - return result.sv; -} - -static __inline__ double __NDR_READSWAP__double(double *argp) { - union { - double sv; - uint64_t ull; - } result; - result.ull = __NDR_READSWAP__uint64_t((uint64_t *)argp); - return result.sv; -} - -__END_DECLS - -#define __NDR_convert__int_rep__int16_t__defined -#define __NDR_convert__int_rep__int16_t(v,f) \ - __NDR_READSWAP_assign(v, __NDR_READSWAP__int16_t) - -#define __NDR_convert__int_rep__uint16_t__defined -#define __NDR_convert__int_rep__uint16_t(v,f) \ - __NDR_READSWAP_assign(v, __NDR_READSWAP__uint16_t) - -#define __NDR_convert__int_rep__int32_t__defined -#define __NDR_convert__int_rep__int32_t(v,f) \ - __NDR_READSWAP_assign(v, __NDR_READSWAP__int32_t) - -#define __NDR_convert__int_rep__uint32_t__defined -#define __NDR_convert__int_rep__uint32_t(v,f) \ - __NDR_READSWAP_assign(v, __NDR_READSWAP__uint32_t) - -#define __NDR_convert__int_rep__int64_t__defined -#define __NDR_convert__int_rep__int64_t(v,f) \ - __NDR_READSWAP_assign(v, __NDR_READSWAP__int64_t) - -#define __NDR_convert__int_rep__uint64_t__defined -#define __NDR_convert__int_rep__uint64_t(v,f) \ - __NDR_READSWAP_assign(v, __NDR_READSWAP__uint64_t) - -#define __NDR_convert__int_rep__float__defined -#define __NDR_convert__int_rep__float(v,f) \ - __NDR_READSWAP_assign(v, __NDR_READSWAP__float) - -#define __NDR_convert__int_rep__double__defined -#define __NDR_convert__int_rep__double(v,f) \ - __NDR_READSWAP_assign(v, __NDR_READSWAP__double) - -#define __NDR_convert__int_rep__boolean_t__defined -#define __NDR_convert__int_rep__boolean_t(v, f) \ - __NDR_convert__int_rep__int32_t(v,f) - -#define __NDR_convert__int_rep__kern_return_t__defined -#define __NDR_convert__int_rep__kern_return_t(v,f) \ - __NDR_convert__int_rep__int32_t(v,f) - -#define __NDR_convert__int_rep__mach_port_name_t__defined -#define __NDR_convert__int_rep__mach_port_name_t(v,f) \ - __NDR_convert__int_rep__uint32_t(v,f) - -#define __NDR_convert__int_rep__mach_msg_type_number_t__defined -#define __NDR_convert__int_rep__mach_msg_type_number_t(v,f) \ - __NDR_convert__int_rep__uint32_t(v,f) - -#endif /* __NDR_convert__int_rep__ */ - -#if __NDR_convert__char_rep__ - -#warning NDR character representation conversions not implemented yet! -#define __NDR_convert__char_rep__char(v,f) __NDR_convert__NOOP -#define __NDR_convert__char_rep__string(v,f,l) __NDR_convert__NOOP - -#endif /* __NDR_convert__char_rep__ */ - -#if __NDR_convert__float_rep__ - -#warning NDR floating point representation conversions not implemented yet! -#define __NDR_convert__float_rep__float(v,f) __NDR_convert__NOOP -#define __NDR_convert__float_rep__double(v,f) __NDR_convert__NOOP - -#endif /* __NDR_convert__float_rep__ */ - -#endif /* __NDR_convert__ */ - -#endif /* _MACH_NDR_H_ */ diff --git a/include/xnu/mach/norma_special_ports.h b/include/xnu/mach/norma_special_ports.h deleted file mode 100644 index e4da723f6..000000000 --- a/include/xnu/mach/norma_special_ports.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2000-2003 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@ - */ -/* - * @OSF_COPYRIGHT@ - */ -/* - * Mach Operating System - * Copyright (c) 1991 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 Software.Distribution@CS.CMU.EDU - * 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/norma_special_ports.h - * - * Defines codes for remote access to special ports. - */ - -#ifndef _MACH_NORMA_SPECIAL_PORTS_H_ -#define _MACH_NORMA_SPECIAL_PORTS_H_ - -#include - -#define norma_get_host_port(host, node, port) \ - (host_get_special_port((host), (node), \ - HOST_PORT, (port))) - -#define norma_get_host_priv_port(host, node, port) \ - (host_get_special_port((host), (node), \ - HOST_PRIV_PORT, (port))) - -#define norma_get_io_master_port(host, node, port) \ - (host_get_special_port((host), (node), \ - HOST_IO_MASTER_PORT, (port))) - -#define norma_get_dynamic_pager_port(host, port) \ - (host_get_special_port((host), 0, \ - HOST_DYNAMIC_PAGER_PORT, (port))) - -#define norma_get_audit_control_port(host, node, port) \ - (host_get_special_port((host), (node), \ - HOST_AUDIT_CONTROL_PORT, (port))) - -#define norma_get_user_notification_port(host, node, port) \ - (host_get_special_port((host), (node), \ - HOST_USER_NOTIFICATION_PORT, (port))) - -#endif /* _MACH_NORMA_SPECIAL_PORTS_H_ */ diff --git a/include/xnu/mach/notify.h b/include/xnu/mach/notify.h deleted file mode 100644 index 845646c5c..000000000 --- a/include/xnu/mach/notify.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2000-2003 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@ - */ -/* - * @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 Software.Distribution@CS.CMU.EDU - * 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/notify.h - * - * Kernel notification message definitions. - */ - -#ifndef _MACH_NOTIFY_H_ -#define _MACH_NOTIFY_H_ - -#include -#include -#include - -/* - * An alternative specification of the notification interface - * may be found in mach/notify.defs. - */ - -#define MACH_NOTIFY_FIRST 0100 -#define MACH_NOTIFY_PORT_DELETED (MACH_NOTIFY_FIRST + 001) - /* A send or send-once right was deleted. */ -#define MACH_NOTIFY_SEND_POSSIBLE (MACH_NOTIFY_FIRST + 002) - /* Now possible to send using specified right */ -#define MACH_NOTIFY_PORT_DESTROYED (MACH_NOTIFY_FIRST + 005) - /* A receive right was (would have been) deallocated */ -#define MACH_NOTIFY_NO_SENDERS (MACH_NOTIFY_FIRST + 006) - /* Receive right has no extant send rights */ -#define MACH_NOTIFY_SEND_ONCE (MACH_NOTIFY_FIRST + 007) - /* An extant send-once right died */ -#define MACH_NOTIFY_DEAD_NAME (MACH_NOTIFY_FIRST + 010) - /* Send or send-once right died, leaving a dead-name */ -#define MACH_NOTIFY_LAST (MACH_NOTIFY_FIRST + 015) - -typedef mach_port_t notify_port_t; - -/* - * Hard-coded message structures for receiving Mach port notification - * messages. However, they are not actual large enough to receive - * the largest trailers current exported by Mach IPC (so they cannot - * be used for space allocations in situations using these new larger - * trailers). Instead, the MIG-generated server routines (and - * related prototypes should be used). - */ -typedef struct { - mach_msg_header_t not_header; - NDR_record_t NDR; - mach_port_name_t not_port;/* MACH_MSG_TYPE_PORT_NAME */ - mach_msg_format_0_trailer_t trailer; -} mach_port_deleted_notification_t; - -typedef struct { - mach_msg_header_t not_header; - NDR_record_t NDR; - mach_port_name_t not_port;/* MACH_MSG_TYPE_PORT_NAME */ - mach_msg_format_0_trailer_t trailer; -} mach_send_possible_notification_t; - -typedef struct { - mach_msg_header_t not_header; - mach_msg_body_t not_body; - mach_msg_port_descriptor_t not_port;/* MACH_MSG_TYPE_PORT_RECEIVE */ - mach_msg_format_0_trailer_t trailer; -} mach_port_destroyed_notification_t; - -typedef struct { - mach_msg_header_t not_header; - NDR_record_t NDR; - mach_msg_type_number_t not_count; - mach_msg_format_0_trailer_t trailer; -} mach_no_senders_notification_t; - -typedef struct { - mach_msg_header_t not_header; - mach_msg_format_0_trailer_t trailer; -} mach_send_once_notification_t; - -typedef struct { - mach_msg_header_t not_header; - NDR_record_t NDR; - mach_port_name_t not_port;/* MACH_MSG_TYPE_PORT_NAME */ - mach_msg_format_0_trailer_t trailer; -} mach_dead_name_notification_t; - -#endif /* _MACH_NOTIFY_H_ */ diff --git a/include/xnu/mach/policy.h b/include/xnu/mach/policy.h deleted file mode 100644 index b6ec795a2..000000000 --- a/include/xnu/mach/policy.h +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Copyright (c) 2000-2005 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@ - */ -/* - * @OSF_COPYRIGHT@ - */ -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989,1988 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 Software.Distribution@CS.CMU.EDU - * 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. - */ -/* - */ - -#ifndef _MACH_POLICY_H_ -#define _MACH_POLICY_H_ - -/* - * mach/policy.h - * - * Definitions for scheduing policy. - */ - -/* - * All interfaces defined here are obsolete. - */ - -#include -#include -#include - -/* - * Old scheduling control interface - */ -typedef int policy_t; -typedef integer_t *policy_info_t; -typedef integer_t *policy_base_t; -typedef integer_t *policy_limit_t; - -/* - * Policy definitions. Policies should be powers of 2, - * but cannot be or'd together other than to test for a - * policy 'class'. - */ -#define POLICY_NULL 0 /* none */ -#define POLICY_TIMESHARE 1 /* timesharing */ -#define POLICY_RR 2 /* fixed round robin */ -#define POLICY_FIFO 4 /* fixed fifo */ - -#define __NEW_SCHEDULING_FRAMEWORK__ - -/* - * Check if policy is of 'class' fixed-priority. - */ -#define POLICYCLASS_FIXEDPRI (POLICY_RR | POLICY_FIFO) - -/* - * Check if policy is valid. - */ -#define invalid_policy(policy) \ - ((policy) != POLICY_TIMESHARE && \ - (policy) != POLICY_RR && \ - (policy) != POLICY_FIFO) - - -/* - * Types for TIMESHARE policy - */ -struct policy_timeshare_base { - integer_t base_priority; -}; -struct policy_timeshare_limit { - integer_t max_priority; -}; -struct policy_timeshare_info { - integer_t max_priority; - integer_t base_priority; - integer_t cur_priority; - boolean_t depressed; - integer_t depress_priority; -}; - -typedef struct policy_timeshare_base *policy_timeshare_base_t; -typedef struct policy_timeshare_limit *policy_timeshare_limit_t; -typedef struct policy_timeshare_info *policy_timeshare_info_t; - -typedef struct policy_timeshare_base policy_timeshare_base_data_t; -typedef struct policy_timeshare_limit policy_timeshare_limit_data_t; -typedef struct policy_timeshare_info policy_timeshare_info_data_t; - - -#define POLICY_TIMESHARE_BASE_COUNT ((mach_msg_type_number_t) \ - (sizeof(struct policy_timeshare_base)/sizeof(integer_t))) -#define POLICY_TIMESHARE_LIMIT_COUNT ((mach_msg_type_number_t) \ - (sizeof(struct policy_timeshare_limit)/sizeof(integer_t))) -#define POLICY_TIMESHARE_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof(struct policy_timeshare_info)/sizeof(integer_t))) - - -/* - * Types for the ROUND ROBIN (RR) policy - */ -struct policy_rr_base { - integer_t base_priority; - integer_t quantum; -}; -struct policy_rr_limit { - integer_t max_priority; -}; -struct policy_rr_info { - integer_t max_priority; - integer_t base_priority; - integer_t quantum; - boolean_t depressed; - integer_t depress_priority; -}; - -typedef struct policy_rr_base *policy_rr_base_t; -typedef struct policy_rr_limit *policy_rr_limit_t; -typedef struct policy_rr_info *policy_rr_info_t; - -typedef struct policy_rr_base policy_rr_base_data_t; -typedef struct policy_rr_limit policy_rr_limit_data_t; -typedef struct policy_rr_info policy_rr_info_data_t; - -#define POLICY_RR_BASE_COUNT ((mach_msg_type_number_t) \ - (sizeof(struct policy_rr_base)/sizeof(integer_t))) -#define POLICY_RR_LIMIT_COUNT ((mach_msg_type_number_t) \ - (sizeof(struct policy_rr_limit)/sizeof(integer_t))) -#define POLICY_RR_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof(struct policy_rr_info)/sizeof(integer_t))) - - -/* - * Types for the FIRST-IN-FIRST-OUT (FIFO) policy - */ -struct policy_fifo_base { - integer_t base_priority; -}; -struct policy_fifo_limit { - integer_t max_priority; -}; -struct policy_fifo_info { - integer_t max_priority; - integer_t base_priority; - boolean_t depressed; - integer_t depress_priority; -}; - -typedef struct policy_fifo_base *policy_fifo_base_t; -typedef struct policy_fifo_limit *policy_fifo_limit_t; -typedef struct policy_fifo_info *policy_fifo_info_t; - -typedef struct policy_fifo_base policy_fifo_base_data_t; -typedef struct policy_fifo_limit policy_fifo_limit_data_t; -typedef struct policy_fifo_info policy_fifo_info_data_t; - -#define POLICY_FIFO_BASE_COUNT ((mach_msg_type_number_t) \ - (sizeof(struct policy_fifo_base)/sizeof(integer_t))) -#define POLICY_FIFO_LIMIT_COUNT ((mach_msg_type_number_t) \ - (sizeof(struct policy_fifo_limit)/sizeof(integer_t))) -#define POLICY_FIFO_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof(struct policy_fifo_info)/sizeof(integer_t))) - -/* - * Aggregate policy types - */ - -struct policy_bases { - policy_timeshare_base_data_t ts; - policy_rr_base_data_t rr; - policy_fifo_base_data_t fifo; -}; - -struct policy_limits { - policy_timeshare_limit_data_t ts; - policy_rr_limit_data_t rr; - policy_fifo_limit_data_t fifo; -}; - -struct policy_infos { - policy_timeshare_info_data_t ts; - policy_rr_info_data_t rr; - policy_fifo_info_data_t fifo; -}; - -typedef struct policy_bases policy_base_data_t; -typedef struct policy_limits policy_limit_data_t; -typedef struct policy_infos policy_info_data_t; - -#endif /* _MACH_POLICY_H_ */ diff --git a/include/xnu/mach/port.h b/include/xnu/mach/port.h deleted file mode 100644 index b09673aba..000000000 --- a/include/xnu/mach/port.h +++ /dev/null @@ -1,372 +0,0 @@ -/* - * Copyright (c) 2000-2006 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@ - */ -/* - * @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 Software.Distribution@CS.CMU.EDU - * 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. - */ -/* - * NOTICE: This file was modified by McAfee Research in 2004 to introduce - * support for mandatory and extensible security protections. This notice - * is included in support of clause 2.2 (b) of the Apple Public License, - * Version 2.0. - */ -/* - */ -/* - * File: mach/port.h - * - * Definition of a Mach port - * - * Mach ports are the endpoints to Mach-implemented communications - * channels (usually uni-directional message queues, but other types - * also exist). - * - * Unique collections of these endpoints are maintained for each - * Mach task. Each Mach port in the task's collection is given a - * [task-local] name to identify it - and the the various "rights" - * held by the task for that specific endpoint. - * - * This header defines the types used to identify these Mach ports - * and the various rights associated with them. For more info see: - * - * - manipulation of port rights in a given space - * - message queue [and port right passing] mechanism - * - */ - -#ifndef _MACH_PORT_H_ -#define _MACH_PORT_H_ - -#include -#include -#include -#include - -/* - * mach_port_name_t - the local identity for a Mach port - * - * The name is Mach port namespace specific. It is used to - * identify the rights held for that port by the task whose - * namespace is implied [or specifically provided]. - * - * Use of this type usually implies just a name - no rights. - * See mach_port_t for a type that implies a "named right." - * - */ - -typedef natural_t mach_port_name_t; -typedef mach_port_name_t *mach_port_name_array_t; - -#ifdef KERNEL - -/* - * mach_port_t - a named port right - * - * In the kernel, "rights" are represented [named] by pointers to - * the ipc port object in question. There is no port namespace for the - * rights to be collected. - * - * Actually, there is namespace for the kernel task. But most kernel - * code - including, but not limited to, Mach IPC code - lives in the - * limbo between the current user-level task and the "next" task. Very - * little of the kernel code runs in full kernel task context. So very - * little of it gets to use the kernel task's port name space. - * - * Because of this implementation approach, all in-kernel rights for - * a given port coalesce [have the same name/pointer]. The actual - * references are counted in the port itself. It is up to the kernel - * code in question to "just remember" how many [and what type of] - * rights it holds and handle them appropriately. - * - */ - -#ifndef MACH_KERNEL_PRIVATE -/* - * For kernel code that resides outside of Mach proper, we opaque the - * port structure definition. - */ -struct ipc_port ; - -#endif /* MACH_KERNEL_PRIVATE */ - -typedef struct ipc_port *ipc_port_t; - -#define IPC_PORT_NULL ((ipc_port_t) 0UL) -#define IPC_PORT_DEAD ((ipc_port_t)~0UL) -#define IPC_PORT_VALID(port) \ - ((port) != IPC_PORT_NULL && (port) != IPC_PORT_DEAD) - -typedef ipc_port_t mach_port_t; - -/* - * Since the 32-bit and 64-bit representations of ~0 are different, - * explicitly handle MACH_PORT_DEAD - */ - -#define CAST_MACH_PORT_TO_NAME(x) ((mach_port_name_t)(uintptr_t)(x)) -#define CAST_MACH_NAME_TO_PORT(x) ((x) == MACH_PORT_DEAD ? (mach_port_t)IPC_PORT_DEAD : (mach_port_t)(uintptr_t)(x)) - -#else /* KERNEL */ - -/* - * mach_port_t - a named port right - * - * In user-space, "rights" are represented by the name of the - * right in the Mach port namespace. Even so, this type is - * presented as a unique one to more clearly denote the presence - * of a right coming along with the name. - * - * Often, various rights for a port held in a single name space - * will coalesce and are, therefore, be identified by a single name - * [this is the case for send and receive rights]. But not - * always [send-once rights currently get a unique name for - * each right]. - * - */ - -#ifndef _MACH_PORT_T -#define _MACH_PORT_T -typedef mach_port_name_t mach_port_t; -#endif - -#endif /* KERNEL */ - -typedef mach_port_t *mach_port_array_t; - -/* - * MACH_PORT_NULL is a legal value that can be carried in messages. - * It indicates the absence of any port or port rights. (A port - * argument keeps the message from being "simple", even if the - * value is MACH_PORT_NULL.) The value MACH_PORT_DEAD is also a legal - * value that can be carried in messages. It indicates - * that a port right was present, but it died. - */ - -#define MACH_PORT_NULL 0 /* intentional loose typing */ -#define MACH_PORT_DEAD ((mach_port_name_t) ~0) -#define MACH_PORT_VALID(name) \ - (((name) != MACH_PORT_NULL) && \ - ((name) != MACH_PORT_DEAD)) - - -/* - * For kernel-selected [assigned] port names, the name is - * comprised of two parts: a generation number and an index. - * This approach keeps the exact same name from being generated - * and reused too quickly [to catch right/reference counting bugs]. - * The dividing line between the constituent parts is exposed so - * that efficient "mach_port_name_t to data structure pointer" - * conversion implementation can be made. But it is possible - * for user-level code to assign their own names to Mach ports. - * These are not required to participate in this algorithm. So - * care should be taken before "assuming" this model. - * - */ - -#ifndef NO_PORT_GEN - -#define MACH_PORT_INDEX(name) ((name) >> 8) -#define MACH_PORT_GEN(name) (((name) & 0xff) << 24) -#define MACH_PORT_MAKE(index, gen) \ - (((index) << 8) | (gen) >> 24) - -#else /* NO_PORT_GEN */ - -#define MACH_PORT_INDEX(name) (name) -#define MACH_PORT_GEN(name) (0) -#define MACH_PORT_MAKE(index, gen) (index) - -#endif /* NO_PORT_GEN */ - - -/* - * These are the different rights a task may have for a port. - * The MACH_PORT_RIGHT_* definitions are used as arguments - * to mach_port_allocate, mach_port_get_refs, etc, to specify - * a particular right to act upon. The mach_port_names and - * mach_port_type calls return bitmasks using the MACH_PORT_TYPE_* - * definitions. This is because a single name may denote - * multiple rights. - */ - -typedef natural_t mach_port_right_t; - -#define MACH_PORT_RIGHT_SEND ((mach_port_right_t) 0) -#define MACH_PORT_RIGHT_RECEIVE ((mach_port_right_t) 1) -#define MACH_PORT_RIGHT_SEND_ONCE ((mach_port_right_t) 2) -#define MACH_PORT_RIGHT_PORT_SET ((mach_port_right_t) 3) -#define MACH_PORT_RIGHT_DEAD_NAME ((mach_port_right_t) 4) -#define MACH_PORT_RIGHT_LABELH ((mach_port_right_t) 5) -#define MACH_PORT_RIGHT_NUMBER ((mach_port_right_t) 6) - -typedef natural_t mach_port_type_t; -typedef mach_port_type_t *mach_port_type_array_t; - -#define MACH_PORT_TYPE(right) \ - ((mach_port_type_t)(((mach_port_type_t) 1) \ - << ((right) + ((mach_port_right_t) 16)))) -#define MACH_PORT_TYPE_NONE ((mach_port_type_t) 0L) -#define MACH_PORT_TYPE_SEND MACH_PORT_TYPE(MACH_PORT_RIGHT_SEND) -#define MACH_PORT_TYPE_RECEIVE MACH_PORT_TYPE(MACH_PORT_RIGHT_RECEIVE) -#define MACH_PORT_TYPE_SEND_ONCE MACH_PORT_TYPE(MACH_PORT_RIGHT_SEND_ONCE) -#define MACH_PORT_TYPE_PORT_SET MACH_PORT_TYPE(MACH_PORT_RIGHT_PORT_SET) -#define MACH_PORT_TYPE_DEAD_NAME MACH_PORT_TYPE(MACH_PORT_RIGHT_DEAD_NAME) -#define MACH_PORT_TYPE_LABELH MACH_PORT_TYPE(MACH_PORT_RIGHT_LABELH) - -/* Convenient combinations. */ - -#define MACH_PORT_TYPE_SEND_RECEIVE \ - (MACH_PORT_TYPE_SEND|MACH_PORT_TYPE_RECEIVE) -#define MACH_PORT_TYPE_SEND_RIGHTS \ - (MACH_PORT_TYPE_SEND|MACH_PORT_TYPE_SEND_ONCE) -#define MACH_PORT_TYPE_PORT_RIGHTS \ - (MACH_PORT_TYPE_SEND_RIGHTS|MACH_PORT_TYPE_RECEIVE) -#define MACH_PORT_TYPE_PORT_OR_DEAD \ - (MACH_PORT_TYPE_PORT_RIGHTS|MACH_PORT_TYPE_DEAD_NAME) -#define MACH_PORT_TYPE_ALL_RIGHTS \ - (MACH_PORT_TYPE_PORT_OR_DEAD|MACH_PORT_TYPE_PORT_SET) - -/* Dummy type bits that mach_port_type/mach_port_names can return. */ - -#define MACH_PORT_TYPE_DNREQUEST 0x80000000 -#define MACH_PORT_TYPE_SPREQUEST 0x40000000 -#define MACH_PORT_TYPE_SPREQUEST_DELAYED 0x20000000 - -/* User-references for capabilities. */ - -typedef natural_t mach_port_urefs_t; -typedef integer_t mach_port_delta_t; /* change in urefs */ - -/* Attributes of ports. (See mach_port_get_receive_status.) */ - -typedef natural_t mach_port_seqno_t; /* sequence number */ -typedef natural_t mach_port_mscount_t; /* make-send count */ -typedef natural_t mach_port_msgcount_t; /* number of msgs */ -typedef natural_t mach_port_rights_t; /* number of rights */ - -/* - * Are there outstanding send rights for a given port? - */ -#define MACH_PORT_SRIGHTS_NONE 0 /* no srights */ -#define MACH_PORT_SRIGHTS_PRESENT 1 /* srights */ -typedef unsigned int mach_port_srights_t; /* status of send rights */ - -typedef struct mach_port_status { - mach_port_rights_t mps_pset; /* count of containing port sets */ - mach_port_seqno_t mps_seqno; /* sequence number */ - mach_port_mscount_t mps_mscount; /* make-send count */ - mach_port_msgcount_t mps_qlimit; /* queue limit */ - mach_port_msgcount_t mps_msgcount; /* number in the queue */ - mach_port_rights_t mps_sorights; /* how many send-once rights */ - boolean_t mps_srights; /* do send rights exist? */ - boolean_t mps_pdrequest; /* port-deleted requested? */ - boolean_t mps_nsrequest; /* no-senders requested? */ - natural_t mps_flags; /* port flags */ -} mach_port_status_t; - -/* System-wide values for setting queue limits on a port */ -#define MACH_PORT_QLIMIT_ZERO ((mach_port_msgcount_t) 0) -#define MACH_PORT_QLIMIT_BASIC ((mach_port_msgcount_t) 5) -#define MACH_PORT_QLIMIT_SMALL ((mach_port_msgcount_t) 16) -#define MACH_PORT_QLIMIT_LARGE ((mach_port_msgcount_t) 1024) -#define MACH_PORT_QLIMIT_KERNEL ((mach_port_msgcount_t) 65536) -#define MACH_PORT_QLIMIT_MIN MACH_PORT_QLIMIT_ZERO -#define MACH_PORT_QLIMIT_DEFAULT MACH_PORT_QLIMIT_BASIC -#define MACH_PORT_QLIMIT_MAX MACH_PORT_QLIMIT_LARGE - -typedef struct mach_port_limits { - mach_port_msgcount_t mpl_qlimit; /* number of msgs */ -} mach_port_limits_t; - -typedef integer_t *mach_port_info_t; /* varying array of natural_t */ - -/* Flavors for mach_port_get/set_attributes() */ -typedef int mach_port_flavor_t; -#define MACH_PORT_LIMITS_INFO 1 /* uses mach_port_status_t */ -#define MACH_PORT_RECEIVE_STATUS 2 /* uses mach_port_limits_t */ -#define MACH_PORT_DNREQUESTS_SIZE 3 /* info is int */ - -#define MACH_PORT_LIMITS_INFO_COUNT ((natural_t) \ - (sizeof(mach_port_limits_t)/sizeof(natural_t))) -#define MACH_PORT_RECEIVE_STATUS_COUNT ((natural_t) \ - (sizeof(mach_port_status_t)/sizeof(natural_t))) -#define MACH_PORT_DNREQUESTS_SIZE_COUNT 1 - -/* - * Structure used to pass information about port allocation requests. - * Must be padded to 64-bits total length. - */ -typedef struct mach_port_qos { - unsigned int name:1; /* name given */ - unsigned int prealloc:1; /* prealloced message */ - boolean_t pad1:30; - natural_t len; -} mach_port_qos_t; - -#if !__DARWIN_UNIX03 && !defined(_NO_PORT_T_FROM_MACH) -/* - * Mach 3.0 renamed everything to have mach_ in front of it. - * These types and macros are provided for backward compatibility - * but are deprecated. - */ -typedef mach_port_t port_t; -typedef mach_port_name_t port_name_t; -typedef mach_port_name_t *port_name_array_t; - -#define PORT_NULL ((port_t) 0) -#define PORT_DEAD ((port_t) ~0) -#define PORT_VALID(name) \ - ((port_t)(name) != PORT_NULL && (port_t)(name) != PORT_DEAD) - -#endif /* !__DARWIN_UNIX03 && !_NO_PORT_T_FROM_MACH */ - -#endif /* _MACH_PORT_H_ */ diff --git a/include/xnu/mach/processor_info.h b/include/xnu/mach/processor_info.h deleted file mode 100644 index bd1f74056..000000000 --- a/include/xnu/mach/processor_info.h +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright (c) 2000-2005 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@ - */ -/* - * @OSF_COPYRIGHT@ - */ -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989 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 Software.Distribution@CS.CMU.EDU - * 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/processor_info.h - * Author: David L. Black - * Date: 1988 - * - * Data structure definitions for processor_info, processor_set_info - */ - -#ifndef _MACH_PROCESSOR_INFO_H_ -#define _MACH_PROCESSOR_INFO_H_ - -#include -#include -#include - -/* - * Generic information structure to allow for expansion. - */ -typedef integer_t *processor_info_t; /* varying array of int. */ -typedef integer_t *processor_info_array_t; /* varying array of int */ - -#define PROCESSOR_INFO_MAX (1024) /* max array size */ -typedef integer_t processor_info_data_t[PROCESSOR_INFO_MAX]; - - -typedef integer_t *processor_set_info_t; /* varying array of int. */ - -#define PROCESSOR_SET_INFO_MAX (1024) /* max array size */ -typedef integer_t processor_set_info_data_t[PROCESSOR_SET_INFO_MAX]; - -/* - * Currently defined information. - */ -typedef int processor_flavor_t; -#define PROCESSOR_BASIC_INFO 1 /* basic information */ -#define PROCESSOR_CPU_LOAD_INFO 2 /* cpu load information */ -#define PROCESSOR_PM_REGS_INFO 0x10000001 /* performance monitor register info */ -#define PROCESSOR_TEMPERATURE 0x10000002 /* Processor core temperature */ - -struct processor_basic_info { - cpu_type_t cpu_type; /* type of cpu */ - cpu_subtype_t cpu_subtype; /* subtype of cpu */ - boolean_t running; /* is processor running */ - int slot_num; /* slot number */ - boolean_t is_master; /* is this the master processor */ -}; - -typedef struct processor_basic_info processor_basic_info_data_t; -typedef struct processor_basic_info *processor_basic_info_t; -#define PROCESSOR_BASIC_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof(processor_basic_info_data_t)/sizeof(natural_t))) - -struct processor_cpu_load_info { /* number of ticks while running... */ - unsigned int cpu_ticks[CPU_STATE_MAX]; /* ... in the given mode */ -}; - -typedef struct processor_cpu_load_info processor_cpu_load_info_data_t; -typedef struct processor_cpu_load_info *processor_cpu_load_info_t; -#define PROCESSOR_CPU_LOAD_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof(processor_cpu_load_info_data_t)/sizeof(natural_t))) - -/* - * Scaling factor for load_average, mach_factor. - */ -#define LOAD_SCALE 1000 - -typedef int processor_set_flavor_t; -#define PROCESSOR_SET_BASIC_INFO 5 /* basic information */ - -struct processor_set_basic_info { - int processor_count; /* How many processors */ - int default_policy; /* When others not enabled */ -}; - -typedef struct processor_set_basic_info processor_set_basic_info_data_t; -typedef struct processor_set_basic_info *processor_set_basic_info_t; -#define PROCESSOR_SET_BASIC_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof(processor_set_basic_info_data_t)/sizeof(natural_t))) - -#define PROCESSOR_SET_LOAD_INFO 4 /* scheduling statistics */ - -struct processor_set_load_info { - int task_count; /* How many tasks */ - int thread_count; /* How many threads */ - integer_t load_average; /* Scaled */ - integer_t mach_factor; /* Scaled */ -}; - -typedef struct processor_set_load_info processor_set_load_info_data_t; -typedef struct processor_set_load_info *processor_set_load_info_t; -#define PROCESSOR_SET_LOAD_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof(processor_set_load_info_data_t)/sizeof(natural_t))) - -#ifdef PRIVATE - -#define PROCESSOR_SET_ENABLED_POLICIES 3 -#define PROCESSOR_SET_ENABLED_POLICIES_COUNT ((mach_msg_type_number_t) \ - (sizeof(policy_t)/sizeof(natural_t))) - -#define PROCESSOR_SET_TIMESHARE_DEFAULT 10 -#define PROCESSOR_SET_TIMESHARE_LIMITS 11 - -#define PROCESSOR_SET_RR_DEFAULT 20 -#define PROCESSOR_SET_RR_LIMITS 21 - -#define PROCESSOR_SET_FIFO_DEFAULT 30 -#define PROCESSOR_SET_FIFO_LIMITS 31 - -#endif /* PRIVATE */ - -#endif /* _MACH_PROCESSOR_INFO_H_ */ diff --git a/include/xnu/mach/prof_types.h b/include/xnu/mach/prof_types.h deleted file mode 100644 index a41037212..000000000 --- a/include/xnu/mach/prof_types.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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@ - */ -/* - * @OSF_FREE_COPYRIGHT@ - */ -/* - * HISTORY - * - * Revision 1.1.1.1 1998/09/22 21:05:30 wsanchez - * Import of Mac OS X kernel (~semeria) - * - * Revision 1.1.1.1 1998/03/07 02:25:46 wsanchez - * Import of OSF Mach kernel (~mburg) - * - * Revision 1.2.7.2 1995/01/26 22:15:46 ezf - * corrected CR - * [1995/01/26 21:16:02 ezf] - * - * Revision 1.2.3.2 1993/06/09 02:43:16 gm - * Added to OSF/1 R1.3 from NMK15.0. - * [1993/06/02 21:18:04 jeffc] - * - * Revision 1.2 1993/04/19 16:39:03 devrcs - * ansi C conformance changes - * [1993/02/02 18:54:26 david] - * - * Revision 1.1 1992/09/30 02:32:04 robert - * Initial revision - * - * $EndLog$ - */ -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989 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 Software.Distribution@CS.CMU.EDU - * 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. - */ -/* - */ - -#ifndef _MACH_PROF_TYPES_H -#define _MACH_PROF_TYPES_H - -#define SAMPLE_MAX 256 /* Max array size */ -typedef unsigned sample_array_t[SAMPLE_MAX]; - -#endif /* _MACH_PROF_TYPES_H */ diff --git a/include/xnu/mach/rpc.h b/include/xnu/mach/rpc.h deleted file mode 100644 index 565d7ac6d..000000000 --- a/include/xnu/mach/rpc.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2002,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@ - */ -/* - * @OSF_COPYRIGHT@ - */ - -/* - * Mach RPC Subsystem Interfaces - */ - -#ifndef _MACH_RPC_H_ -#define _MACH_RPC_H_ - -#include -#include -#include -#include - -#include -#include -#include -#include - -/* - * These are the types for RPC-specific variants of the MIG routine - * descriptor and subsystem data types. - * - * THIS IS ONLY FOR COMPATIBILITY. WE WILL NOT BE IMPLEMENTING THIS. - */ - -/* - * Basic mach rpc types. - */ -typedef unsigned int routine_arg_type; -typedef unsigned int routine_arg_offset; -typedef unsigned int routine_arg_size; - -/* - * Definitions for a signature's argument and routine descriptor's. - */ -struct rpc_routine_arg_descriptor { - routine_arg_type type; /* Port, Array, etc. */ - routine_arg_size size; /* element size in bytes */ - routine_arg_size count; /* number of elements */ - routine_arg_offset offset; /* Offset in list of routine args */ -}; -typedef struct rpc_routine_arg_descriptor *rpc_routine_arg_descriptor_t; - -struct rpc_routine_descriptor { - mig_impl_routine_t impl_routine; /* Server work func pointer */ - mig_stub_routine_t stub_routine; /* Unmarshalling func pointer */ - unsigned int argc; /* Number of argument words */ - unsigned int descr_count; /* Number of complex argument */ - /* descriptors */ - rpc_routine_arg_descriptor_t - arg_descr; /* Pointer to beginning of */ - /* the arg_descr array */ - unsigned int max_reply_msg; /* Max size for reply msg */ -}; -typedef struct rpc_routine_descriptor *rpc_routine_descriptor_t; - -#define RPC_DESCR_SIZE(x) ((x)->descr_count * \ - sizeof(struct rpc_routine_arg_descriptor)) - -struct rpc_signature { - struct rpc_routine_descriptor rd; - struct rpc_routine_arg_descriptor rad[1]; -}; - -#define RPC_SIGBUF_SIZE 8 - -/* - * A subsystem describes a set of server routines that can be invoked by - * mach_rpc() on the ports that are registered with the subsystem. For - * each routine, the routine number is given, along with the - * address of the implementation function in the server and a - * description of the arguments of the routine (it's "signature"). - * - * This structure definition is only a template for what is really a - * variable-length structure (generated by MIG for each subsystem). - * The actual structures do not always have one entry in the routine - * array, and also have a varying number of entries in the arg_descr - * array. Each routine has an array of zero or more arg descriptors - * one for each complex arg. These arrays are all catenated together - * to form the arg_descr field of the subsystem struct. The - * arg_descr field of each routine entry points to a unique sub-sequence - * within this catenated array. The goal is to keep everything - * contiguous. - */ -struct rpc_subsystem { - void *reserved; /* Reserved for system use */ - - mach_msg_id_t start; /* Min routine number */ - mach_msg_id_t end; /* Max routine number + 1 */ - unsigned int maxsize; /* Max mach_msg size */ - vm_address_t base_addr; /* Address of this struct in user */ - - struct rpc_routine_descriptor /* Array of routine descriptors */ - routine[1 /* Actually, (start-end+1) */ - ]; - - struct rpc_routine_arg_descriptor - arg_descriptor[1 /* Actually, the sum of the descr_ */ - ]; /* count fields for all routines */ -}; -typedef struct rpc_subsystem *rpc_subsystem_t; - -#define RPC_SUBSYSTEM_NULL ((rpc_subsystem_t) 0) - -#endif /* _MACH_RPC_H_ */ diff --git a/include/xnu/mach/sdt.h b/include/xnu/mach/sdt.h deleted file mode 100644 index 3268551b2..000000000 --- a/include/xnu/mach/sdt.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _MACH_SDT_H -#define _MACH_SDT_H - -#include - -#endif /* _MACH_SDT_H */ diff --git a/include/xnu/mach/shared_memory_server.h b/include/xnu/mach/shared_memory_server.h deleted file mode 100644 index ea7b9127f..000000000 --- a/include/xnu/mach/shared_memory_server.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2000-2005 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@ - */ -/* - * - * File: mach/shared_memory_server.h - * - * protos and struct definitions for shared library - * server and interface - */ - -/* - * XXX - * - * NOTE: this file is deprecated and will be removed in the near future. - * Any project that includes this file should be changed to: - * 1. use instead of this file, - * 2. handle the new shared regions, now available on more platforms - */ - -#ifndef _MACH_SHARED_MEMORY_SERVER_H_ -#define _MACH_SHARED_MEMORY_SERVER_H_ - -#warning " is deprecated. Please use instead." - -#include -#include -#include -#include - -#define VM_PROT_COW 0x8 /* must not interfere with normal prot assignments */ -#define VM_PROT_ZF 0x10 /* must not interfere with normal prot assignments */ - -#define GLOBAL_SHARED_TEXT_SEGMENT 0x90000000U -#define GLOBAL_SHARED_DATA_SEGMENT 0xA0000000U -#define GLOBAL_SHARED_SEGMENT_MASK 0xF0000000U - -#define SHARED_TEXT_REGION_SIZE 0x10000000 -#define SHARED_DATA_REGION_SIZE 0x10000000 - -#if !defined(__LP64__) - -#define SHARED_LIBRARY_SERVER_SUPPORTED - -#define SHARED_ALTERNATE_LOAD_BASE 0x09000000 - -/* - * Note: the two masks below are useful because the assumption is - * made that these shared regions will always be mapped on natural boundaries - * i.e. if the size is 0x10000000 the object can be mapped at - * 0x20000000, or 0x30000000, but not 0x1000000 - */ -#define SHARED_TEXT_REGION_MASK 0x0FFFFFFF -#define SHARED_DATA_REGION_MASK 0x0FFFFFFF - - -/* flags field aliases for copyin_shared_file and load_shared_file */ - -/* IN */ -#define ALTERNATE_LOAD_SITE 0x1 -#define NEW_LOCAL_SHARED_REGIONS 0x2 -#define QUERY_IS_SYSTEM_REGION 0x4 - -/* OUT */ -#define SF_PREV_LOADED 0x1 -#define SYSTEM_REGION_BACKED 0x2 - - -struct sf_mapping { - vm_offset_t mapping_offset; - vm_size_t size; - vm_offset_t file_offset; - vm_prot_t protection; /* read/write/execute/COW/ZF */ - vm_offset_t cksum; -}; -typedef struct sf_mapping sf_mapping_t; - -#endif /* !defined(__LP64__) */ - -/* - * All shared_region_* declarations are a private interface - * between dyld and the kernel. - * - */ -struct shared_file_mapping_np { - mach_vm_address_t sfm_address; - mach_vm_size_t sfm_size; - mach_vm_offset_t sfm_file_offset; - vm_prot_t sfm_max_prot; - vm_prot_t sfm_init_prot; -}; - -struct shared_region_range_np { - mach_vm_address_t srr_address; - mach_vm_size_t srr_size; -}; - -#ifndef KERNEL - -__BEGIN_DECLS -int shared_region_map_file_np(int fd, - uint32_t mappingCount, - const struct shared_file_mapping_np *mappings, - int64_t *slide_p); -int shared_region_make_private_np(uint32_t rangeCount, - const struct shared_region_range_np *ranges); -__END_DECLS - -#endif /* !KERNEL */ - -#endif /* _MACH_SHARED_MEMORY_SERVER_H_ */ diff --git a/include/xnu/mach/shared_region.h b/include/xnu/mach/shared_region.h deleted file mode 100644 index 2297ba7b7..000000000 --- a/include/xnu/mach/shared_region.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2007 Apple Inc. All rights reserved. - * - * @APPLE_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. 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_LICENSE_HEADER_END@ - */ -/* - * - * File: mach/shared_region.h - * - * protos and struct definitions for shared region - */ - -#ifndef _MACH_SHARED_REGION_H_ -#define _MACH_SHARED_REGION_H_ - -#include -#include -#include -#include - -#define SHARED_REGION_BASE_I386 0x90000000ULL -#define SHARED_REGION_SIZE_I386 0x20000000ULL -#define SHARED_REGION_NESTING_BASE_I386 0x90000000ULL -#define SHARED_REGION_NESTING_SIZE_I386 0x20000000ULL -#define SHARED_REGION_NESTING_MIN_I386 0x00200000ULL -#define SHARED_REGION_NESTING_MAX_I386 0xFFE00000ULL - -#define SHARED_REGION_BASE_X86_64 0x00007FFF70000000ULL -#define SHARED_REGION_SIZE_X86_64 0x000000008FE00000ULL -#define SHARED_REGION_NESTING_BASE_X86_64 0x00007FFF80000000ULL -#define SHARED_REGION_NESTING_SIZE_X86_64 0x0000000040000000ULL -#define SHARED_REGION_NESTING_MIN_X86_64 0x0000000000200000ULL -#define SHARED_REGION_NESTING_MAX_X86_64 0xFFFFFFFFFFE00000ULL - -#define SHARED_REGION_BASE_PPC 0x90000000ULL -#define SHARED_REGION_SIZE_PPC 0x20000000ULL -#define SHARED_REGION_NESTING_BASE_PPC 0x90000000ULL -#define SHARED_REGION_NESTING_SIZE_PPC 0x10000000ULL -#define SHARED_REGION_NESTING_MIN_PPC 0x10000000ULL -#define SHARED_REGION_NESTING_MAX_PPC 0x10000000ULL - -#define SHARED_REGION_BASE_PPC64 0x00007FFF60000000ULL -#define SHARED_REGION_SIZE_PPC64 0x00000000A0000000ULL -#define SHARED_REGION_NESTING_BASE_PPC64 0x00007FFF60000000ULL -#define SHARED_REGION_NESTING_SIZE_PPC64 0x00000000A0000000ULL -#define SHARED_REGION_NESTING_MIN_PPC64 0x0000000010000000ULL -#define SHARED_REGION_NESTING_MAX_PPC64 0x0000000010000000ULL - -#define SHARED_REGION_BASE_ARM 0x30000000ULL -#define SHARED_REGION_SIZE_ARM 0x10000000ULL -#define SHARED_REGION_NESTING_BASE_ARM 0x30000000ULL -#define SHARED_REGION_NESTING_SIZE_ARM 0x10000000ULL -#define SHARED_REGION_NESTING_MIN_ARM ? -#define SHARED_REGION_NESTING_MAX_ARM ? - - -#if defined(__i386__) -#define SHARED_REGION_BASE SHARED_REGION_BASE_I386 -#define SHARED_REGION_SIZE SHARED_REGION_SIZE_I386 -#define SHARED_REGION_NESTING_BASE SHARED_REGION_NESTING_BASE_I386 -#define SHARED_REGION_NESTING_SIZE SHARED_REGION_NESTING_SIZE_I386 -#define SHARED_REGION_NESTING_MIN SHARED_REGION_NESTING_MIN_I386 -#define SHARED_REGION_NESTING_MAX SHARED_REGION_NESTING_MAX_I386 -#elif defined(__x86_64__) -#define SHARED_REGION_BASE SHARED_REGION_BASE_X86_64 -#define SHARED_REGION_SIZE SHARED_REGION_SIZE_X86_64 -#define SHARED_REGION_NESTING_BASE SHARED_REGION_NESTING_BASE_X86_64 -#define SHARED_REGION_NESTING_SIZE SHARED_REGION_NESTING_SIZE_X86_64 -#define SHARED_REGION_NESTING_MIN SHARED_REGION_NESTING_MIN_X86_64 -#define SHARED_REGION_NESTING_MAX SHARED_REGION_NESTING_MAX_X86_64 -#endif - -#ifdef KERNEL_PRIVATE - -/* - * This is routine sets the current source of power. - * Arguments: - * 0 if it is external source (connected to power ) - * 1 if it is internal power source ie battery - */ - -void post_sys_powersource(int); - -#endif /* KERNEL_PRIVATE */ -/* - * All shared_region_* declarations are a private interface - * between dyld and the kernel. - * - */ -struct shared_file_mapping_np { - mach_vm_address_t sfm_address; - mach_vm_size_t sfm_size; - mach_vm_offset_t sfm_file_offset; - vm_prot_t sfm_max_prot; - vm_prot_t sfm_init_prot; -}; -#define VM_PROT_COW 0x8 /* must not interfere with normal prot assignments */ -#define VM_PROT_ZF 0x10 /* must not interfere with normal prot assignments */ -#define VM_PROT_SLIDE 0x20 /* must not interfere with normal prot assignments */ - -#ifndef KERNEL - -__BEGIN_DECLS -int shared_region_check_np(uint64_t *startaddress); -int shared_region_map_np(int fd, - uint32_t mappingCount, - const struct shared_file_mapping_np *mappings); -int shared_region_slide_np(void); -__END_DECLS - -#endif /* !KERNEL */ - -#endif /* _MACH_SHARED_REGION_H_ */ diff --git a/include/xnu/mach/std_types.h b/include/xnu/mach/std_types.h deleted file mode 100644 index f5b838ab2..000000000 --- a/include/xnu/mach/std_types.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2002,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@ - */ -/* - * @OSF_COPYRIGHT@ - */ -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989,1988 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 Software.Distribution@CS.CMU.EDU - * 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. - */ -/* - */ -/* - * Mach standard external interface type definitions. - * - */ - -#ifndef _MACH_STD_TYPES_H_ -#define _MACH_STD_TYPES_H_ - -#include -#include -#include -#include -#include - -#endif /* _MACH_STD_TYPES_H_ */ diff --git a/include/xnu/mach/sync_policy.h b/include/xnu/mach/sync_policy.h deleted file mode 100644 index 50e0b2142..000000000 --- a/include/xnu/mach/sync_policy.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2000-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@ - */ -/* - * @OSF_COPYRIGHT@ - */ - -#ifndef _MACH_SYNC_POLICY_H_ -#define _MACH_SYNC_POLICY_H_ - -typedef int sync_policy_t; - -/* - * These options define the wait ordering of the synchronizers - */ -#define SYNC_POLICY_FIFO 0x0 -#define SYNC_POLICY_FIXED_PRIORITY 0x1 -#define SYNC_POLICY_REVERSED 0x2 -#define SYNC_POLICY_ORDER_MASK 0x3 -#define SYNC_POLICY_LIFO (SYNC_POLICY_FIFO|SYNC_POLICY_REVERSED) - -#ifdef KERNEL_PRIVATE - -/* - * These options provide addition (kernel-private) behaviors - */ - -#define SYNC_POLICY_PREPOST 0x4 - -#endif /* KERNEL_PRIVATE */ - -#define SYNC_POLICY_MAX 0x7 - -#endif /* _MACH_SYNC_POLICY_H_ */ diff --git a/include/xnu/mach/syscall_sw.h b/include/xnu/mach/syscall_sw.h deleted file mode 100644 index a3ef52610..000000000 --- a/include/xnu/mach/syscall_sw.h +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2000-2004 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@ - */ -/* - * @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 Software.Distribution@CS.CMU.EDU - * 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. - */ - -#ifdef PRIVATE - -#ifndef _MACH_SYSCALL_SW_H_ -#define _MACH_SYSCALL_SW_H_ - -/* - * The machine-dependent "syscall_sw.h" file should - * define a macro for - * kernel_trap(trap_name, trap_number, arg_count) - * which will expand into assembly code for the - * trap. - * - * N.B.: When adding calls, do not put spaces in the macros. - */ - -#include - -/* - * These trap numbers should be taken from the - * table in . - */ - -/* - * i386 and x86_64 just load of the stack or use - * registers in order; no munging is required, - * and number of args is ignored. ARM loads args - * into registers beyond r3, unlike the normal - * procedure call standard; we pad for 64-bit args. - */ -kernel_trap(_kernelrpc_mach_vm_allocate_trap,-10,5) /* 4 args, +1 for mach_vm_size_t */ -kernel_trap(_kernelrpc_mach_vm_deallocate_trap,-12,5) /* 3 args, +2 for mach_vm_size_t and mach_vm_address_t */ -kernel_trap(_kernelrpc_mach_vm_protect_trap,-14,7) /* 5 args, +2 for mach_vm_address_t and mach_vm_size_t */ -kernel_trap(_kernelrpc_mach_port_allocate_trap,-16,3) -kernel_trap(_kernelrpc_mach_port_destroy_trap,-17,2) -kernel_trap(_kernelrpc_mach_port_deallocate_trap,-18,2) -kernel_trap(_kernelrpc_mach_port_mod_refs_trap,-19,4) -kernel_trap(_kernelrpc_mach_port_move_member_trap,-20,3) -kernel_trap(_kernelrpc_mach_port_insert_right_trap,-21,4) -kernel_trap(_kernelrpc_mach_port_insert_member_trap,-22,3) -kernel_trap(_kernelrpc_mach_port_extract_member_trap,-23,3) - -kernel_trap(mach_reply_port,-26,0) -kernel_trap(thread_self_trap,-27,0) -kernel_trap(task_self_trap,-28,0) -kernel_trap(host_self_trap,-29,0) - -kernel_trap(mach_msg_trap,-31,7) -kernel_trap(mach_msg_overwrite_trap,-32,9) -kernel_trap(semaphore_signal_trap, -33, 1) -kernel_trap(semaphore_signal_all_trap, -34, 1) -kernel_trap(semaphore_signal_thread_trap, -35, 2) -kernel_trap(semaphore_wait_trap,-36,1) -kernel_trap(semaphore_wait_signal_trap,-37,2) -kernel_trap(semaphore_timedwait_trap,-38,3) -kernel_trap(semaphore_timedwait_signal_trap,-39,4) - -#if !defined(__LP64__) && !defined(__arm__) -kernel_trap(map_fd,-43,5) -#endif /*!defined(__LP64__) && !defined(__arm__) */ - -kernel_trap(task_name_for_pid,-44,3) -kernel_trap(task_for_pid,-45,3) -kernel_trap(pid_for_task,-46,2) - -#if defined(__LP64__) -kernel_trap(macx_swapon,-48, 4) -kernel_trap(macx_swapoff,-49, 2) -#else /* __LP64__ */ -kernel_trap(macx_swapon,-48, 5) -kernel_trap(macx_swapoff,-49, 3) -#endif /* __LP64__ */ -kernel_trap(macx_triggers,-51, 4) -kernel_trap(macx_backing_store_suspend,-52, 1) -kernel_trap(macx_backing_store_recovery,-53, 1) - -/* These are currently used by pthreads even on LP64 */ -/* But as soon as that is fixed - they will go away there */ -kernel_trap(swtch_pri,-59,1) -kernel_trap(swtch,-60,0) - -kernel_trap(syscall_thread_switch,-61,3) -kernel_trap(clock_sleep_trap,-62,5) - -kernel_trap(mach_timebase_info,-89,1) - -#if defined(__LP64__) -/* unit64_t arguments passed in one register in LP64 */ -kernel_trap(mach_wait_until,-90,1) -#else /* __LP64__ */ -kernel_trap(mach_wait_until,-90,2) -#endif /* __LP64__ */ - -kernel_trap(mk_timer_create,-91,0) -kernel_trap(mk_timer_destroy,-92,1) - -#if defined(__LP64__) -/* unit64_t arguments passed in one register in LP64 */ -kernel_trap(mk_timer_arm,-93,2) -#else /* __LP64__ */ -kernel_trap(mk_timer_arm,-93,3) -#endif /* __LP64__ */ - -kernel_trap(mk_timer_cancel,-94,2) - -/* - * N.B: Trap #-100 is in use by IOTrap.s in the IOKit Framework - * (iokit_user_client_trap) - */ -#endif /* _MACH_SYSCALL_SW_H_ */ - -#endif /* PRIVATE */ diff --git a/include/xnu/mach/task_info.h b/include/xnu/mach/task_info.h deleted file mode 100644 index 70234ce39..000000000 --- a/include/xnu/mach/task_info.h +++ /dev/null @@ -1,295 +0,0 @@ -/* - * Copyright (c) 2000-2007 Apple 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@ - */ -/* - * @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 Software.Distribution@CS.CMU.EDU - * 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. - */ -/* - * Machine-independent task information structures and definitions. - * - * The definitions in this file are exported to the user. The kernel - * will translate its internal data structures to these structures - * as appropriate. - * - */ - -#ifndef _MACH_TASK_INFO_H_ -#define _MACH_TASK_INFO_H_ - -#include -#include -#include -#include -#include /* for vm_extmod_statistics_data_t */ -//#include - -#include - -/* - * Generic information structure to allow for expansion. - */ -typedef natural_t task_flavor_t; -typedef integer_t *task_info_t; /* varying array of int */ - -/* Deprecated, use per structure _data_t's instead */ -#define TASK_INFO_MAX (1024) /* maximum array size */ -typedef integer_t task_info_data_t[TASK_INFO_MAX]; - -/* - * Currently defined information structures. - */ - -#pragma pack(4) - -/* Don't use this, use MACH_TASK_BASIC_INFO instead */ -#define TASK_BASIC_INFO_32 4 /* basic information */ -#define TASK_BASIC2_INFO_32 6 - -struct task_basic_info_32 { - integer_t suspend_count; /* suspend count for task */ - natural_t virtual_size; /* virtual memory size (bytes) */ - natural_t resident_size; /* resident memory size (bytes) */ - time_value_t user_time; /* total user run time for - terminated threads */ - time_value_t system_time; /* total system run time for - terminated threads */ - policy_t policy; /* default policy for new threads */ -}; -typedef struct task_basic_info_32 task_basic_info_32_data_t; -typedef struct task_basic_info_32 *task_basic_info_32_t; -#define TASK_BASIC_INFO_32_COUNT \ - (sizeof(task_basic_info_32_data_t) / sizeof(natural_t)) - -/* Don't use this, use MACH_TASK_BASIC_INFO instead */ -struct task_basic_info_64 { - integer_t suspend_count; /* suspend count for task */ - mach_vm_size_t virtual_size; /* virtual memory size (bytes) */ - mach_vm_size_t resident_size; /* resident memory size (bytes) */ - time_value_t user_time; /* total user run time for - terminated threads */ - time_value_t system_time; /* total system run time for - terminated threads */ - policy_t policy; /* default policy for new threads */ -}; -typedef struct task_basic_info_64 task_basic_info_64_data_t; -typedef struct task_basic_info_64 *task_basic_info_64_t; - -#define TASK_BASIC_INFO_64 5 /* 64-bit capable basic info */ -#define TASK_BASIC_INFO_64_COUNT \ - (sizeof(task_basic_info_64_data_t) / sizeof(natural_t)) - - -/* localized structure - cannot be safely passed between tasks of differing sizes */ -/* Don't use this, use MACH_TASK_BASIC_INFO instead */ -struct task_basic_info { - integer_t suspend_count; /* suspend count for task */ - vm_size_t virtual_size; /* virtual memory size (bytes) */ - vm_size_t resident_size; /* resident memory size (bytes) */ - time_value_t user_time; /* total user run time for - terminated threads */ - time_value_t system_time; /* total system run time for - terminated threads */ - policy_t policy; /* default policy for new threads */ -}; - -typedef struct task_basic_info task_basic_info_data_t; -typedef struct task_basic_info *task_basic_info_t; -#define TASK_BASIC_INFO_COUNT \ - (sizeof(task_basic_info_data_t) / sizeof(natural_t)) -#if !defined(__LP64__) -#define TASK_BASIC_INFO TASK_BASIC_INFO_32 -#else -#define TASK_BASIC_INFO TASK_BASIC_INFO_64 -#endif - - - -#define TASK_EVENTS_INFO 2 /* various event counts */ - -struct task_events_info { - integer_t faults; /* number of page faults */ - integer_t pageins; /* number of actual pageins */ - integer_t cow_faults; /* number of copy-on-write faults */ - integer_t messages_sent; /* number of messages sent */ - integer_t messages_received; /* number of messages received */ - integer_t syscalls_mach; /* number of mach system calls */ - integer_t syscalls_unix; /* number of unix system calls */ - integer_t csw; /* number of context switches */ -}; -typedef struct task_events_info task_events_info_data_t; -typedef struct task_events_info *task_events_info_t; -#define TASK_EVENTS_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof(task_events_info_data_t) / sizeof(natural_t))) - -#define TASK_THREAD_TIMES_INFO 3 /* total times for live threads - - only accurate if suspended */ - -struct task_thread_times_info { - time_value_t user_time; /* total user run time for - live threads */ - time_value_t system_time; /* total system run time for - live threads */ -}; - -typedef struct task_thread_times_info task_thread_times_info_data_t; -typedef struct task_thread_times_info *task_thread_times_info_t; -#define TASK_THREAD_TIMES_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof(task_thread_times_info_data_t) / sizeof(natural_t))) - -#define TASK_ABSOLUTETIME_INFO 1 - -struct task_absolutetime_info { - uint64_t total_user; /* total time */ - uint64_t total_system; - uint64_t threads_user; /* existing threads only */ - uint64_t threads_system; -}; - -typedef struct task_absolutetime_info task_absolutetime_info_data_t; -typedef struct task_absolutetime_info *task_absolutetime_info_t; -#define TASK_ABSOLUTETIME_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof (task_absolutetime_info_data_t) / sizeof (natural_t))) - -#define TASK_KERNELMEMORY_INFO 7 - -struct task_kernelmemory_info { - uint64_t total_palloc; /* private kernel mem alloc'ed */ - uint64_t total_pfree; /* private kernel mem freed */ - uint64_t total_salloc; /* shared kernel mem alloc'ed */ - uint64_t total_sfree; /* shared kernel mem freed */ -}; - -typedef struct task_kernelmemory_info task_kernelmemory_info_data_t; -typedef struct task_kernelmemory_info *task_kernelmemory_info_t; -#define TASK_KERNELMEMORY_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof (task_kernelmemory_info_data_t) / sizeof (natural_t))) - -#define TASK_SECURITY_TOKEN 13 -#define TASK_SECURITY_TOKEN_COUNT ((mach_msg_type_number_t) \ - (sizeof(security_token_t) / sizeof(natural_t))) - -#define TASK_AUDIT_TOKEN 15 -#define TASK_AUDIT_TOKEN_COUNT \ - (sizeof(audit_token_t) / sizeof(natural_t)) - - -#define TASK_AFFINITY_TAG_INFO 16 /* This is experimental. */ - -struct task_affinity_tag_info { - integer_t set_count; - integer_t min; - integer_t max; - integer_t task_count; -}; -typedef struct task_affinity_tag_info task_affinity_tag_info_data_t; -typedef struct task_affinity_tag_info *task_affinity_tag_info_t; -#define TASK_AFFINITY_TAG_INFO_COUNT \ - (sizeof(task_affinity_tag_info_data_t) / sizeof(natural_t)) - -#define TASK_DYLD_INFO 17 - -struct task_dyld_info { - mach_vm_address_t all_image_info_addr; - mach_vm_size_t all_image_info_size; - integer_t all_image_info_format; -}; -typedef struct task_dyld_info task_dyld_info_data_t; -typedef struct task_dyld_info *task_dyld_info_t; -#define TASK_DYLD_INFO_COUNT \ - (sizeof(task_dyld_info_data_t) / sizeof(natural_t)) -#define TASK_DYLD_ALL_IMAGE_INFO_32 0 /* format value */ -#define TASK_DYLD_ALL_IMAGE_INFO_64 1 /* format value */ - - -#define TASK_EXTMOD_INFO 19 - -struct task_extmod_info { - unsigned char task_uuid[16]; - vm_extmod_statistics_data_t extmod_statistics; -}; -typedef struct task_extmod_info task_extmod_info_data_t; -typedef struct task_extmod_info *task_extmod_info_t; -#define TASK_EXTMOD_INFO_COUNT \ - (sizeof(task_extmod_info_data_t) / sizeof(natural_t)) - -/* Always 64-bit in user and kernel */ -#define MACH_TASK_BASIC_INFO 20 /* always 64-bit basic info */ - -struct mach_task_basic_info { - mach_vm_size_t virtual_size; /* virtual memory size (bytes) */ - mach_vm_size_t resident_size; /* resident memory size (bytes) */ - mach_vm_size_t resident_size_max; /* maximum resident memory size (bytes) */ - time_value_t user_time; /* total user run time for - terminated threads */ - time_value_t system_time; /* total system run time for - terminated threads */ - policy_t policy; /* default policy for new threads */ - integer_t suspend_count; /* suspend count for task */ -}; -typedef struct mach_task_basic_info mach_task_basic_info_data_t; -typedef struct mach_task_basic_info *mach_task_basic_info_t; -#define MACH_TASK_BASIC_INFO_COUNT \ - (sizeof(mach_task_basic_info_data_t) / sizeof(natural_t)) - -/* - * Obsolete interfaces. - */ - -#define TASK_SCHED_TIMESHARE_INFO 10 -#define TASK_SCHED_RR_INFO 11 -#define TASK_SCHED_FIFO_INFO 12 - -#define TASK_SCHED_INFO 14 - -#pragma pack() - -#endif /* _MACH_TASK_INFO_H_ */ diff --git a/include/xnu/mach/task_ledger.h b/include/xnu/mach/task_ledger.h deleted file mode 100644 index 5d4bc2585..000000000 --- a/include/xnu/mach/task_ledger.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2000-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@ - */ -/* - * @OSF_COPYRIGHT@ - */ - -#ifndef _MACH_TASK_LEDGER_H_ -#define _MACH_TASK_LEDGER_H_ - -/* - * Evolving and likely to change. - */ - -/* - * Definitions for task ledger line items - */ -#define ITEM_THREADS 0 /* number of threads */ -#define ITEM_TASKS 1 /* number of tasks */ - -#define ITEM_VM 2 /* virtual space (bytes)*/ - -#define LEDGER_N_ITEMS 3 /* Total line items */ - -#define LEDGER_UNLIMITED 0 /* ignored item.maximum */ - -#endif /* _MACH_TASK_LEDGER_H_ */ diff --git a/include/xnu/mach/task_policy.h b/include/xnu/mach/task_policy.h deleted file mode 100644 index 71d70526f..000000000 --- a/include/xnu/mach/task_policy.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2000-2005 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@ - */ - -#ifndef _MACH_TASK_POLICY_H_ -#define _MACH_TASK_POLICY_H_ - -#include - -/* - * These are the calls for accessing the policy parameters - * of a particular task. - * - * The extra 'get_default' parameter to the second call is - * IN/OUT as follows: - * 1) if asserted on the way in it indicates that the default - * values should be returned, not the ones currently set, in - * this case 'get_default' will always be asserted on return; - * 2) if unasserted on the way in, the current settings are - * desired and if still unasserted on return, then the info - * returned reflects the current settings, otherwise if - * 'get_default' returns asserted, it means that there are no - * current settings due to other parameters taking precedence, - * and the default ones are being returned instead. - */ - -typedef natural_t task_policy_flavor_t; -typedef integer_t *task_policy_t; - -/* -kern_return_t task_policy_set( - task_t task, - task_policy_flavor_t flavor, - task_policy_t policy_info, - mach_msg_type_number_t count); - -kern_return_t task_policy_get( - task_t task, - task_policy_flavor_t flavor, - task_policy_t policy_info, - mach_msg_type_number_t *count, - boolean_t *get_default); -*/ - -/* - * Defined flavors. - */ -/* - * TASK_CATEGORY_POLICY: - * - * This provides information to the kernel about the role - * of the task in the system. - * - * Parameters: - * - * role: Enumerated as follows: - * - * TASK_UNSPECIFIED is the default, since the role is not - * inherited from the parent. - * - * TASK_FOREGROUND_APPLICATION should be assigned when the - * task is a normal UI application in the foreground from - * the HI point of view. - * **N.B. There may be more than one of these at a given time. - * - * TASK_BACKGROUND_APPLICATION should be assigned when the - * task is a normal UI application in the background from - * the HI point of view. - * - * TASK_CONTROL_APPLICATION should be assigned to the unique - * UI application which implements the pop-up application dialog. - * There can only be one task at a time with this designation, - * which is assigned FCFS. - * - * TASK_GRAPHICS_SERVER should be assigned to the graphics - * management (window) server. There can only be one task at - * a time with this designation, which is assigned FCFS. - */ - -#define TASK_CATEGORY_POLICY 1 - -enum task_role { - TASK_RENICED = -1, - TASK_UNSPECIFIED = 0, - TASK_FOREGROUND_APPLICATION, - TASK_BACKGROUND_APPLICATION, - TASK_CONTROL_APPLICATION, - TASK_GRAPHICS_SERVER, - TASK_THROTTLE_APPLICATION, - TASK_NONUI_APPLICATION, - TASK_DEFAULT_APPLICATION -}; - -typedef enum task_role task_role_t; - -struct task_category_policy { - task_role_t role; -}; - -typedef struct task_category_policy task_category_policy_data_t; -typedef struct task_category_policy *task_category_policy_t; - -#define TASK_CATEGORY_POLICY_COUNT ((mach_msg_type_number_t) \ - (sizeof (task_category_policy_data_t) / sizeof (integer_t))) - -#endif /* _MACH_TASK_POLICY_H_ */ diff --git a/include/xnu/mach/task_special_ports.h b/include/xnu/mach/task_special_ports.h deleted file mode 100644 index fb08e1b7d..000000000 --- a/include/xnu/mach/task_special_ports.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2000-2010 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@ - */ -/* - * @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 Software.Distribution@CS.CMU.EDU - * 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/task_special_ports.h - * - * Defines codes for special_purpose task ports. These are NOT - * port identifiers - they are only used for the task_get_special_port - * and task_set_special_port routines. - * - */ - -#ifndef _MACH_TASK_SPECIAL_PORTS_H_ -#define _MACH_TASK_SPECIAL_PORTS_H_ - -typedef int task_special_port_t; - -#define TASK_KERNEL_PORT 1 /* Represents task to the outside - world.*/ - -#define TASK_HOST_PORT 2 /* The host (priv) port for task. */ - -#define TASK_NAME_PORT 3 /* the name (unpriv) port for task */ - -#define TASK_BOOTSTRAP_PORT 4 /* Bootstrap environment for task. */ - -/* - * Evolving and likely to change. - */ - -#define TASK_SEATBELT_PORT 7 /* Seatbelt compiler/DEM port for task. */ - -/* PORT 8 was the GSSD TASK PORT which transformed to a host port */ - -#define TASK_ACCESS_PORT 9 /* Permission check for task_for_pid. */ - - -/* - * Definitions for ease of use - */ - -#define task_get_kernel_port(task, port) \ - (task_get_special_port((task), TASK_KERNEL_PORT, (port))) - -#define task_set_kernel_port(task, port) \ - (task_set_special_port((task), TASK_KERNEL_PORT, (port))) - -#define task_get_host_port(task, port) \ - (task_get_special_port((task), TASK_HOST_PORT, (port))) - -#define task_set_host_port(task, port) \ - (task_set_special_port((task), TASK_HOST_PORT, (port))) - -#define task_get_bootstrap_port(task, port) \ - (task_get_special_port((task), TASK_BOOTSTRAP_PORT, (port))) - -#define task_set_bootstrap_port(task, port) \ - (task_set_special_port((task), TASK_BOOTSTRAP_PORT, (port))) - -#define task_get_task_access_port(task, port) \ - (task_get_special_port((task), TASK_ACCESS_PORT, (port))) - -#define task_set_task_access_port(task, port) \ - (task_set_special_port((task), TASK_ACCESS_PORT, (port))) - -#endif /* _MACH_TASK_SPECIAL_PORTS_H_ */ diff --git a/include/xnu/mach/thread_info.h b/include/xnu/mach/thread_info.h deleted file mode 100644 index 5f51aeade..000000000 --- a/include/xnu/mach/thread_info.h +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2000-2005 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@ - */ -/* - * @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 Software.Distribution@CS.CMU.EDU - * 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/thread_info - * - * Thread information structure and definitions. - * - * The defintions in this file are exported to the user. The kernel - * will translate its internal data structures to these structures - * as appropriate. - * - */ - -#ifndef _MACH_THREAD_INFO_H_ -#define _MACH_THREAD_INFO_H_ - -#include -#include -#include -#include -#include - -/* - * Generic information structure to allow for expansion. - */ -typedef natural_t thread_flavor_t; -typedef integer_t *thread_info_t; /* varying array of int */ - -#define THREAD_INFO_MAX (1024) /* maximum array size */ -typedef integer_t thread_info_data_t[THREAD_INFO_MAX]; - -/* - * Currently defined information. - */ -#define THREAD_BASIC_INFO 3 /* basic information */ - -struct thread_basic_info { - time_value_t user_time; /* user run time */ - time_value_t system_time; /* system run time */ - integer_t cpu_usage; /* scaled cpu usage percentage */ - policy_t policy; /* scheduling policy in effect */ - integer_t run_state; /* run state (see below) */ - integer_t flags; /* various flags (see below) */ - integer_t suspend_count; /* suspend count for thread */ - integer_t sleep_time; /* number of seconds that thread - has been sleeping */ -}; - -typedef struct thread_basic_info thread_basic_info_data_t; -typedef struct thread_basic_info *thread_basic_info_t; -#define THREAD_BASIC_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof(thread_basic_info_data_t) / sizeof(natural_t))) - -#define THREAD_IDENTIFIER_INFO 4 /* thread id and other information */ - -struct thread_identifier_info { - uint64_t thread_id; /* system-wide unique 64-bit thread id */ - uint64_t thread_handle; /* handle to be used by libproc */ - uint64_t dispatch_qaddr; /* libdispatch queue address */ -}; - -typedef struct thread_identifier_info thread_identifier_info_data_t; -typedef struct thread_identifier_info *thread_identifier_info_t; -#define THREAD_IDENTIFIER_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof(thread_identifier_info_data_t) / sizeof(natural_t))) - -/* - * Scale factor for usage field. - */ - -#define TH_USAGE_SCALE 1000 - -/* - * Thread run states (state field). - */ - -#define TH_STATE_RUNNING 1 /* thread is running normally */ -#define TH_STATE_STOPPED 2 /* thread is stopped */ -#define TH_STATE_WAITING 3 /* thread is waiting normally */ -#define TH_STATE_UNINTERRUPTIBLE 4 /* thread is in an uninterruptible - wait */ -#define TH_STATE_HALTED 5 /* thread is halted at a - clean point */ - -/* - * Thread flags (flags field). - */ -#define TH_FLAGS_SWAPPED 0x1 /* thread is swapped out */ -#define TH_FLAGS_IDLE 0x2 /* thread is an idle thread */ - -/* - * Obsolete interfaces. - */ - -#define THREAD_SCHED_TIMESHARE_INFO 10 -#define THREAD_SCHED_RR_INFO 11 -#define THREAD_SCHED_FIFO_INFO 12 - -#endif /* _MACH_THREAD_INFO_H_ */ diff --git a/include/xnu/mach/thread_policy.h b/include/xnu/mach/thread_policy.h deleted file mode 100644 index 607028837..000000000 --- a/include/xnu/mach/thread_policy.h +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Copyright (c) 2000-2007 Apple 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@ - */ - -#ifndef _MACH_THREAD_POLICY_H_ -#define _MACH_THREAD_POLICY_H_ - -#include - -/* - * These are the calls for accessing the policy parameters - * of a particular thread. - * - * The extra 'get_default' parameter to the second call is - * IN/OUT as follows: - * 1) if asserted on the way in it indicates that the default - * values should be returned, not the ones currently set, in - * this case 'get_default' will always be asserted on return; - * 2) if unasserted on the way in, the current settings are - * desired and if still unasserted on return, then the info - * returned reflects the current settings, otherwise if - * 'get_default' returns asserted, it means that there are no - * current settings due to other parameters taking precedence, - * and the default ones are being returned instead. - */ - -typedef natural_t thread_policy_flavor_t; -typedef integer_t *thread_policy_t; - -/* -kern_return_t thread_policy_set( - thread_t thread, - thread_policy_flavor_t flavor, - thread_policy_t policy_info, - mach_msg_type_number_t count); - -kern_return_t thread_policy_get( - thread_t thread, - thread_policy_flavor_t flavor, - thread_policy_t policy_info, - mach_msg_type_number_t *count, - boolean_t *get_default); -*/ - -/* - * Defined flavors. - */ -/* - * THREAD_STANDARD_POLICY: - * - * This is the standard (fair) scheduling mode, assigned to new - * threads. The thread will be given processor time in a manner - * which apportions approximately equal share to long running - * computations. - * - * Parameters: - * [none] - */ - -#define THREAD_STANDARD_POLICY 1 - -struct thread_standard_policy { - natural_t no_data; -}; - -typedef struct thread_standard_policy thread_standard_policy_data_t; -typedef struct thread_standard_policy *thread_standard_policy_t; - -#define THREAD_STANDARD_POLICY_COUNT 0 - -/* - * THREAD_EXTENDED_POLICY: - * - * Extended form of THREAD_STANDARD_POLICY, which supplies a - * hint indicating whether this is a long running computation. - * - * Parameters: - * - * timeshare: TRUE (the default) results in identical scheduling - * behavior as THREAD_STANDARD_POLICY. - */ - -#define THREAD_EXTENDED_POLICY 1 - -struct thread_extended_policy { - boolean_t timeshare; -}; - -typedef struct thread_extended_policy thread_extended_policy_data_t; -typedef struct thread_extended_policy *thread_extended_policy_t; - -#define THREAD_EXTENDED_POLICY_COUNT ((mach_msg_type_number_t) \ - (sizeof (thread_extended_policy_data_t) / sizeof (integer_t))) - -/* - * THREAD_TIME_CONSTRAINT_POLICY: - * - * This scheduling mode is for threads which have real time - * constraints on their execution. - * - * Parameters: - * - * period: This is the nominal amount of time between separate - * processing arrivals, specified in absolute time units. A - * value of 0 indicates that there is no inherent periodicity in - * the computation. - * - * computation: This is the nominal amount of computation - * time needed during a separate processing arrival, specified - * in absolute time units. - * - * constraint: This is the maximum amount of real time that - * may elapse from the start of a separate processing arrival - * to the end of computation for logically correct functioning, - * specified in absolute time units. Must be (>= computation). - * Note that latency = (constraint - computation). - * - * preemptible: This indicates that the computation may be - * interrupted, subject to the constraint specified above. - */ - -#define THREAD_TIME_CONSTRAINT_POLICY 2 - -struct thread_time_constraint_policy { - uint32_t period; - uint32_t computation; - uint32_t constraint; - boolean_t preemptible; -}; - -typedef struct thread_time_constraint_policy \ - thread_time_constraint_policy_data_t; -typedef struct thread_time_constraint_policy \ - *thread_time_constraint_policy_t; - -#define THREAD_TIME_CONSTRAINT_POLICY_COUNT ((mach_msg_type_number_t) \ - (sizeof (thread_time_constraint_policy_data_t) / sizeof (integer_t))) - -/* - * THREAD_PRECEDENCE_POLICY: - * - * This may be used to indicate the relative value of the - * computation compared to the other threads in the task. - * - * Parameters: - * - * importance: The importance is specified as a signed value. - */ - -#define THREAD_PRECEDENCE_POLICY 3 - -struct thread_precedence_policy { - integer_t importance; -}; - -typedef struct thread_precedence_policy thread_precedence_policy_data_t; -typedef struct thread_precedence_policy *thread_precedence_policy_t; - -#define THREAD_PRECEDENCE_POLICY_COUNT ((mach_msg_type_number_t) \ - (sizeof (thread_precedence_policy_data_t) / sizeof (integer_t))) - -/* - * THREAD_AFFINITY_POLICY: - * - * This policy is experimental. - * This may be used to express affinity relationships - * between threads in the task. Threads with the same affinity tag will - * be scheduled to share an L2 cache if possible. That is, affinity tags - * are a hint to the scheduler for thread placement. - * - * The namespace of affinity tags is generally local to one task. However, - * a child task created after the assignment of affinity tags by its parent - * will share that namespace. In particular, a family of forked processes - * may be created with a shared affinity namespace. - * - * Parameters: - * tag: The affinity set identifier. - */ - -#define THREAD_AFFINITY_POLICY 4 - -struct thread_affinity_policy { - integer_t affinity_tag; -}; - -#define THREAD_AFFINITY_TAG_NULL 0 - -typedef struct thread_affinity_policy thread_affinity_policy_data_t; -typedef struct thread_affinity_policy *thread_affinity_policy_t; - -#define THREAD_AFFINITY_POLICY_COUNT ((mach_msg_type_number_t) \ - (sizeof (thread_affinity_policy_data_t) / sizeof (integer_t))) - -/* - * THREAD_BACKGROUND_POLICY: - */ - -#define THREAD_BACKGROUND_POLICY 5 - -struct thread_background_policy { - integer_t priority; -}; - -typedef struct thread_background_policy thread_background_policy_data_t; -typedef struct thread_background_policy *thread_background_policy_t; - -#define THREAD_BACKGROUND_POLICY_COUNT ((mach_msg_type_number_t) \ - (sizeof (thread_background_policy_data_t) / sizeof (integer_t))) - -#endif /* _MACH_THREAD_POLICY_H_ */ diff --git a/include/xnu/mach/thread_special_ports.h b/include/xnu/mach/thread_special_ports.h deleted file mode 100644 index 1d44c02ed..000000000 --- a/include/xnu/mach/thread_special_ports.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2000-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@ - */ -/* - * @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 Software.Distribution@CS.CMU.EDU - * 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/thread_special_ports.h - * - * Defines codes for special_purpose thread ports. These are NOT - * port identifiers - they are only used for the thread_get_special_port - * and thread_set_special_port routines. - * - */ - -#ifndef _MACH_THREAD_SPECIAL_PORTS_H_ -#define _MACH_THREAD_SPECIAL_PORTS_H_ - -#define THREAD_KERNEL_PORT 1 /* Represents the thread to the outside - world.*/ - -/* - * Definitions for ease of use - */ - -#define thread_get_kernel_port(thread, port) \ - (thread_get_special_port((thread), THREAD_KERNEL_PORT, (port))) - -#define thread_set_kernel_port(thread, port) \ - (thread_set_special_port((thread), THREAD_KERNEL_PORT, (port))) - -#endif /* _MACH_THREAD_SPECIAL_PORTS_H_ */ diff --git a/include/xnu/mach/thread_status.h b/include/xnu/mach/thread_status.h deleted file mode 100644 index aead09bf9..000000000 --- a/include/xnu/mach/thread_status.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2000-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@ - */ -/* - * @OSF_COPYRIGHT@ - */ -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989,1988 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 Software.Distribution@CS.CMU.EDU - * 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/thread_status.h - * Author: Avadis Tevanian, Jr. - * - * This file contains the structure definitions for the user-visible - * thread state. This thread state is examined with the thread_get_state - * kernel call and may be changed with the thread_set_state kernel call. - * - */ - -#ifndef _MACH_THREAD_STATUS_H_ -#define _MACH_THREAD_STATUS_H_ - -/* - * The actual structure that comprises the thread state is defined - * in the machine dependent module. - */ -#include -#include -#include - -/* - * Generic definition for machine-dependent thread status. - */ - -typedef natural_t *thread_state_t; /* Variable-length array */ - -/* THREAD_STATE_MAX is now defined in */ -typedef natural_t thread_state_data_t[THREAD_STATE_MAX]; - -#define THREAD_STATE_FLAVOR_LIST 0 /* List of valid flavors */ -#define THREAD_STATE_FLAVOR_LIST_NEW 128 - -typedef int thread_state_flavor_t; -typedef thread_state_flavor_t *thread_state_flavor_array_t; - -#endif /* _MACH_THREAD_STATUS_H_ */ diff --git a/include/xnu/mach/thread_switch.h b/include/xnu/mach/thread_switch.h deleted file mode 100644 index f5558946a..000000000 --- a/include/xnu/mach/thread_switch.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2000-2004 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@ - */ -/* - * @OSF_COPYRIGHT@ - */ -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989 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 Software.Distribution@CS.CMU.EDU - * 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. - */ -/* - */ - -#ifndef _MACH_THREAD_SWITCH_H_ -#define _MACH_THREAD_SWITCH_H_ - -#include -#include -#include -#include - -/* - * Constant definitions for thread_switch trap. - */ - -#define SWITCH_OPTION_NONE 0 -#define SWITCH_OPTION_DEPRESS 1 -#define SWITCH_OPTION_WAIT 2 - -#define valid_switch_option(opt) (0 <= (opt) && (opt) <= 2) - -#endif /* _MACH_THREAD_SWITCH_H_ */ diff --git a/include/xnu/mach/time_value.h b/include/xnu/mach/time_value.h deleted file mode 100644 index e4f912d9e..000000000 --- a/include/xnu/mach/time_value.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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@ - */ -/* - * @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 Software.Distribution@CS.CMU.EDU - * 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. - */ - -#ifndef _MACH_TIME_VALUE_H_ -#define _MACH_TIME_VALUE_H_ - -#include - -/* - * Time value returned by kernel. - */ - -struct time_value { - integer_t seconds; - integer_t microseconds; -}; - -typedef struct time_value time_value_t; - -/* - * Macros to manipulate time values. Assume that time values - * are normalized (microseconds <= 999999). - */ -#define TIME_MICROS_MAX (1000000) - -#define time_value_add_usec(val, micros) { \ - if (((val)->microseconds += (micros)) \ - >= TIME_MICROS_MAX) { \ - (val)->microseconds -= TIME_MICROS_MAX; \ - (val)->seconds++; \ - } \ -} - -#define time_value_add(result, addend) { \ - (result)->microseconds += (addend)->microseconds; \ - (result)->seconds += (addend)->seconds; \ - if ((result)->microseconds >= TIME_MICROS_MAX) { \ - (result)->microseconds -= TIME_MICROS_MAX; \ - (result)->seconds++; \ - } \ -} - -#endif /* _MACH_TIME_VALUE_H_ */ diff --git a/include/xnu/mach/vm_attributes.h b/include/xnu/mach/vm_attributes.h deleted file mode 100644 index 2be32337b..000000000 --- a/include/xnu/mach/vm_attributes.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2000-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@ - */ -/* - * @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 Software.Distribution@CS.CMU.EDU - * 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/vm_attributes.h - * Author: Alessandro Forin - * - * Virtual memory attributes definitions. - * - * These definitions are in addition to the machine-independent - * ones (e.g. protection), and are only selectively supported - * on specific machine architectures. - * - */ - -#ifndef _MACH_VM_ATTRIBUTES_H_ -#define _MACH_VM_ATTRIBUTES_H_ - -/* - * Types of machine-dependent attributes - */ -typedef unsigned int vm_machine_attribute_t; - -#define MATTR_CACHE 1 /* cachability */ -#define MATTR_MIGRATE 2 /* migrability */ -#define MATTR_REPLICATE 4 /* replicability */ - -/* - * Values for the above, e.g. operations on attribute - */ -typedef int vm_machine_attribute_val_t; - -#define MATTR_VAL_OFF 0 /* (generic) turn attribute off */ -#define MATTR_VAL_ON 1 /* (generic) turn attribute on */ -#define MATTR_VAL_GET 2 /* (generic) return current value */ - -#define MATTR_VAL_CACHE_FLUSH 6 /* flush from all caches */ -#define MATTR_VAL_DCACHE_FLUSH 7 /* flush from data caches */ -#define MATTR_VAL_ICACHE_FLUSH 8 /* flush from instruction caches */ -#define MATTR_VAL_CACHE_SYNC 9 /* sync I+D caches */ -#define MATTR_VAL_CACHE_SYNC 9 /* sync I+D caches */ - -#define MATTR_VAL_GET_INFO 10 /* get page info (stats) */ - -#endif /* _MACH_VM_ATTRIBUTES_H_ */ diff --git a/include/xnu/mach/vm_behavior.h b/include/xnu/mach/vm_behavior.h deleted file mode 100644 index ec0ee729c..000000000 --- a/include/xnu/mach/vm_behavior.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2000-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@ - */ -/* - * @OSF_COPYRIGHT@ - */ -/* - * File: mach/vm_behavior.h - * - * Virtual memory map behavior definitions. - * - */ - -#ifndef _MACH_VM_BEHAVIOR_H_ -#define _MACH_VM_BEHAVIOR_H_ - -/* - * Types defined: - * - * vm_behavior_t behavior codes. - */ - -typedef int vm_behavior_t; - -/* - * Enumeration of valid values for vm_behavior_t. - * These describe expected page reference behavior for - * for a given range of virtual memory. For implementation - * details see vm/vm_fault.c - */ - - -/* - * The following behaviors affect the memory region's future behavior - * and are stored in the VM map entry data structure. - */ -#define VM_BEHAVIOR_DEFAULT ((vm_behavior_t) 0) /* default */ -#define VM_BEHAVIOR_RANDOM ((vm_behavior_t) 1) /* random */ -#define VM_BEHAVIOR_SEQUENTIAL ((vm_behavior_t) 2) /* forward sequential */ -#define VM_BEHAVIOR_RSEQNTL ((vm_behavior_t) 3) /* reverse sequential */ - -/* - * The following "behaviors" affect the memory region only at the time of the - * call and are not stored in the VM map entry. - */ -#define VM_BEHAVIOR_WILLNEED ((vm_behavior_t) 4) /* will need in near future */ -#define VM_BEHAVIOR_DONTNEED ((vm_behavior_t) 5) /* dont need in near future */ -#define VM_BEHAVIOR_FREE ((vm_behavior_t) 6) /* free memory without write-back */ -#define VM_BEHAVIOR_ZERO_WIRED_PAGES ((vm_behavior_t) 7) /* zero out the wired pages of an entry if it is being deleted without unwiring them first */ -#define VM_BEHAVIOR_REUSABLE ((vm_behavior_t) 8) -#define VM_BEHAVIOR_REUSE ((vm_behavior_t) 9) -#define VM_BEHAVIOR_CAN_REUSE ((vm_behavior_t) 10) - -#endif /*_MACH_VM_BEHAVIOR_H_*/ diff --git a/include/xnu/mach/vm_inherit.h b/include/xnu/mach/vm_inherit.h deleted file mode 100644 index d6440e441..000000000 --- a/include/xnu/mach/vm_inherit.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2000-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@ - */ -/* - * @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 Software.Distribution@CS.CMU.EDU - * 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/vm_inherit.h - * Author: Avadis Tevanian, Jr., Michael Wayne Young - * - * Virtual memory map inheritance definitions. - * - */ - -#ifndef _MACH_VM_INHERIT_H_ -#define _MACH_VM_INHERIT_H_ - -/* - * Types defined: - * - * vm_inherit_t inheritance codes. - */ - -typedef unsigned int vm_inherit_t; /* might want to change this */ - -/* - * Enumeration of valid values for vm_inherit_t. - */ - -#define VM_INHERIT_SHARE ((vm_inherit_t) 0) /* share with child */ -#define VM_INHERIT_COPY ((vm_inherit_t) 1) /* copy into child */ -#define VM_INHERIT_NONE ((vm_inherit_t) 2) /* absent from child */ -#define VM_INHERIT_DONATE_COPY ((vm_inherit_t) 3) /* copy and delete */ - -#define VM_INHERIT_DEFAULT VM_INHERIT_COPY -#define VM_INHERIT_LAST_VALID VM_INHERIT_NONE - -#endif /* _MACH_VM_INHERIT_H_ */ diff --git a/include/xnu/mach/vm_param.h b/include/xnu/mach/vm_param.h deleted file mode 100644 index 60e65de24..000000000 --- a/include/xnu/mach/vm_param.h +++ /dev/null @@ -1,299 +0,0 @@ -/* - * Copyright (c) 2000-2006 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@ - */ -/* - * @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 Software.Distribution@CS.CMU.EDU - * 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/vm_param.h - * Author: Avadis Tevanian, Jr., Michael Wayne Young - * Date: 1985 - * - * Machine independent virtual memory parameters. - * - */ - -#ifndef _MACH_VM_PARAM_H_ -#define _MACH_VM_PARAM_H_ - -#include - -#ifdef KERNEL - -#ifndef ASSEMBLER -#include -#endif /* ASSEMBLER */ - -/* - * The machine independent pages are refered to as PAGES. A page - * is some number of hardware pages, depending on the target machine. - */ - -#ifndef ASSEMBLER - -#define PAGE_SIZE_64 (unsigned long long)PAGE_SIZE /* pagesize in addr units */ -#define PAGE_MASK_64 (unsigned long long)PAGE_MASK /* mask for off in page */ - -/* - * Convert addresses to pages and vice versa. No rounding is used. - * The atop_32 and ptoa_32 macros should not be use on 64 bit types. - * The round_page_64 and trunc_page_64 macros should be used instead. - */ - -#define atop_32(x) ((uint32_t)(x) >> PAGE_SHIFT) -#define ptoa_32(x) ((uint32_t)(x) << PAGE_SHIFT) -#define atop_64(x) ((uint64_t)(x) >> PAGE_SHIFT) -#define ptoa_64(x) ((uint64_t)(x) << PAGE_SHIFT) - -#define atop_kernel(x) ((vm_address_t)(x) >> PAGE_SHIFT) -#define ptoa_kernel(x) ((vm_address_t)(x) << PAGE_SHIFT) - -/* - * While the following block is enabled, the legacy atop and ptoa - * macros will behave correctly. If not, they will generate - * invalid lvalue errors. - */ - -#if 1 -#define atop(x) ((vm_address_t)(x) >> PAGE_SHIFT) -#define ptoa(x) ((vm_address_t)(x) << PAGE_SHIFT) -#else -#define atop(x) (0UL = 0) -#define ptoa(x) (0UL = 0) -#endif - -/* - * Page-size rounding macros for the Public fixed-width VM types. - */ -#define mach_vm_round_page(x) (((mach_vm_offset_t)(x) + PAGE_MASK) & ~((signed)PAGE_MASK)) -#define mach_vm_trunc_page(x) ((mach_vm_offset_t)(x) & ~((signed)PAGE_MASK)) - -#define memory_object_round_page(x) (((memory_object_offset_t)(x) + PAGE_MASK) & ~((signed)PAGE_MASK)) -#define memory_object_trunc_page(x) ((memory_object_offset_t)(x) & ~((signed)PAGE_MASK)) - -/* - * Rounding macros for the legacy (scalable with the current task's - * address space size) VM types. - */ - -#define round_page(x) (((vm_offset_t)(x) + PAGE_MASK) & ~((vm_offset_t)PAGE_MASK)) -#define trunc_page(x) ((vm_offset_t)(x) & ~((vm_offset_t)PAGE_MASK)) - -/* - * Round off or truncate to the nearest page. These will work - * for either addresses or counts. (i.e. 1 byte rounds to 1 page - * bytes. The round_page_32 and trunc_page_32 macros should not be - * use on 64 bit types. The round_page_64 and trunc_page_64 macros - * should be used instead. - * - * These should only be used in the rare case the size of the address - * or length is hard-coded as 32 or 64 bit. Otherwise, the macros - * associated with the specific VM type should be used. - */ - -#define round_page_32(x) (((uint32_t)(x) + PAGE_MASK) & ~((uint32_t)PAGE_MASK)) -#define trunc_page_32(x) ((uint32_t)(x) & ~((uint32_t)PAGE_MASK)) -#define round_page_64(x) (((uint64_t)(x) + PAGE_MASK_64) & ~((uint64_t)PAGE_MASK_64)) -#define trunc_page_64(x) ((uint64_t)(x) & ~((uint64_t)PAGE_MASK_64)) - -/* - * Enable the following block to find uses of xxx_32 macros that should - * be xxx_64. These macros only work in C code, not C++. The resulting - * binaries are not functional. Look for invalid lvalue errors in - * the compiler output. - * - * Enabling the following block will also find use of the xxx_64 macros - * that have been passed pointers. The parameters should be case to an - * unsigned long type first. Look for invalid operands to binary + error - * in the compiler output. - */ - -#if 0 -#undef atop_32 -#undef ptoa_32 -#undef round_page_32 -#undef trunc_page_32 -#undef atop_64 -#undef ptoa_64 -#undef round_page_64 -#undef trunc_page_64 - -#ifndef __cplusplus - -#define atop_32(x) \ - (__builtin_choose_expr (sizeof(x) != sizeof(uint64_t), \ - (*(long *)0), \ - (0UL)) = 0) - -#define ptoa_32(x) \ - (__builtin_choose_expr (sizeof(x) != sizeof(uint64_t), \ - (*(long *)0), \ - (0UL)) = 0) - -#define round_page_32(x) \ - (__builtin_choose_expr (sizeof(x) != sizeof(uint64_t), \ - (*(long *)0), \ - (0UL)) = 0) - -#define trunc_page_32(x) \ - (__builtin_choose_expr (sizeof(x) != sizeof(uint64_t), \ - (*(long *)0), \ - (0UL)) = 0) -#else - -#define atop_32(x) (0) -#define ptoa_32(x) (0) -#define round_page_32(x) (0) -#define trunc_page_32(x) (0) - -#endif /* ! __cplusplus */ - -#define atop_64(x) ((uint64_t)((x) + (uint8_t *)0)) -#define ptoa_64(x) ((uint64_t)((x) + (uint8_t *)0)) -#define round_page_64(x) ((uint64_t)((x) + (uint8_t *)0)) -#define trunc_page_64(x) ((uint64_t)((x) + (uint8_t *)0)) - -#endif - -/* - * Determine whether an address is page-aligned, or a count is - * an exact page multiple. - */ - -#define page_aligned(x) (((x) & PAGE_MASK) == 0) - -extern vm_size_t mem_size; /* 32-bit size of memory - limited by maxmem - deprecated */ -extern uint64_t max_mem; /* 64-bit size of memory - limited by maxmem */ - -/* - * The default pager does not handle 64-bit offsets inside its objects, - * so this limits the size of anonymous memory objects to 4GB minus 1 page. - * When we need to allocate a chunk of anonymous memory over that size, - * we have to allocate more than one chunk. - */ -#define ANON_MAX_SIZE 0xFFFFF000ULL -/* - * Work-around for - * Break large anonymous memory areas into 128MB chunks to alleviate - * the cost of copying when copy-on-write is not possible because a small - * portion of it being wired. - */ -#define ANON_CHUNK_SIZE (128ULL * 1024 * 1024) /* 128MB */ - -#ifdef XNU_KERNEL_PRIVATE - -extern uint64_t mem_actual; /* 64-bit size of memory - not limited by maxmem */ -extern uint64_t sane_size; /* Memory size to use for defaults calculations */ -extern addr64_t vm_last_addr; /* Highest kernel virtual address known to the VM system */ - -extern const vm_offset_t vm_min_kernel_address; -extern const vm_offset_t vm_max_kernel_address; - -extern vm_offset_t vm_kernel_stext; -extern vm_offset_t vm_kernel_etext; -extern vm_offset_t vm_kernel_base; -extern vm_offset_t vm_kernel_top; -extern vm_offset_t vm_kernel_slide; -extern vm_offset_t vm_kernel_addrperm; - -#define VM_KERNEL_IS_SLID(_o) \ - (((vm_offset_t)(_o) >= vm_kernel_base) && \ - ((vm_offset_t)(_o) < vm_kernel_top)) -/* - * VM_KERNEL_IS_KEXT is platform-specific, defined in . - * Set default if undefined. - */ -#ifndef VM_KERNEL_IS_KEXT -#define VM_KERNEL_IS_KEXT(_o) (FALSE) -#endif -#define VM_KERNEL_UNSLIDE(_v) \ - ((VM_KERNEL_IS_SLID(_v) || \ - VM_KERNEL_IS_KEXT(_v)) ? \ - (vm_offset_t)(_v) - vm_kernel_slide : \ - (vm_offset_t)(_v)) -#define VM_KERNEL_SLIDE(_u) \ - ((vm_offset_t)(_u) + vm_kernel_slide) - -#define VM_KERNEL_ADDRPERM(_v) \ - (((vm_offset_t)(_v) == 0) ? \ - (vm_offset_t)(0) : \ - (vm_offset_t)(_v) + vm_kernel_addrperm) - -#endif /* XNU_KERNEL_PRIVATE */ - -extern vm_size_t page_size; -extern vm_size_t page_mask; -extern int page_shift; - -/* We need a way to get rid of compiler warnings when we cast from */ -/* a 64 bit value to an address (which may be 32 bits or 64-bits). */ -/* An intptr_t is used convert the value to the right precision, and */ -/* then to an address. This macro is also used to convert addresses */ -/* to 32-bit integers, which is a hard failure for a 64-bit kernel */ -#include -#ifndef __CAST_DOWN_CHECK -#define __CAST_DOWN_CHECK - -#define CAST_DOWN( type, addr ) \ - ( ((type)((uintptr_t) (addr)/(sizeof(type) < sizeof(uintptr_t) ? 0 : 1))) ) - -#define CAST_DOWN_EXPLICIT( type, addr ) ( ((type)((uintptr_t) (addr))) ) - -#endif /* __CAST_DOWN_CHECK */ - -#endif /* ASSEMBLER */ - -#endif /* KERNEL */ - -#endif /* _MACH_VM_PARAM_H_ */ diff --git a/include/xnu/mach/vm_prot.h b/include/xnu/mach/vm_prot.h deleted file mode 100644 index ae2d67584..000000000 --- a/include/xnu/mach/vm_prot.h +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2000-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@ - */ -/* - * @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 Software.Distribution@CS.CMU.EDU - * 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/vm_prot.h - * Author: Avadis Tevanian, Jr., Michael Wayne Young - * - * Virtual memory protection definitions. - * - */ - -#ifndef _MACH_VM_PROT_H_ -#define _MACH_VM_PROT_H_ - -/* - * Types defined: - * - * vm_prot_t VM protection values. - */ - -typedef int vm_prot_t; - -/* - * Protection values, defined as bits within the vm_prot_t type - */ - -#define VM_PROT_NONE ((vm_prot_t) 0x00) - -#define VM_PROT_READ ((vm_prot_t) 0x01) /* read permission */ -#define VM_PROT_WRITE ((vm_prot_t) 0x02) /* write permission */ -#define VM_PROT_EXECUTE ((vm_prot_t) 0x04) /* execute permission */ - -/* - * The default protection for newly-created virtual memory - */ - -#define VM_PROT_DEFAULT (VM_PROT_READ|VM_PROT_WRITE) - -/* - * The maximum privileges possible, for parameter checking. - */ - -#define VM_PROT_ALL (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE) - -/* - * An invalid protection value. - * Used only by memory_object_lock_request to indicate no change - * to page locks. Using -1 here is a bad idea because it - * looks like VM_PROT_ALL and then some. - */ - -#define VM_PROT_NO_CHANGE ((vm_prot_t) 0x08) - -/* - * When a caller finds that he cannot obtain write permission on a - * mapped entry, the following flag can be used. The entry will - * be made "needs copy" effectively copying the object (using COW), - * and write permission will be added to the maximum protections - * for the associated entry. - */ - -#define VM_PROT_COPY ((vm_prot_t) 0x10) - - -/* - * Another invalid protection value. - * Used only by memory_object_data_request upon an object - * which has specified a copy_call copy strategy. It is used - * when the kernel wants a page belonging to a copy of the - * object, and is only asking the object as a result of - * following a shadow chain. This solves the race between pages - * being pushed up by the memory manager and the kernel - * walking down the shadow chain. - */ - -#define VM_PROT_WANTS_COPY ((vm_prot_t) 0x10) - -#ifdef PRIVATE -/* - * The caller wants this memory region treated as if it had a valid - * code signature. - */ - -#define VM_PROT_TRUSTED ((vm_prot_t) 0x20) -#endif /* PRIVATE */ - -/* - * Another invalid protection value. - * Indicates that the other protection bits are to be applied as a mask - * against the actual protection bits of the map entry. - */ -#define VM_PROT_IS_MASK ((vm_prot_t) 0x40) - -#endif /* _MACH_VM_PROT_H_ */ diff --git a/include/xnu/mach/vm_purgable.h b/include/xnu/mach/vm_purgable.h deleted file mode 100644 index 2d8ca3038..000000000 --- a/include/xnu/mach/vm_purgable.h +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2003-2007 Apple 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@ - */ - -/* - * Virtual memory map purgeable object definitions. - * Objects that will be needed in the future (forward cached objects) should be queued LIFO. - * Objects that have been used and are cached for reuse (backward cached) should be queued FIFO. - * Every user of purgeable memory is entitled to using the highest volatile group (7). - * Only if a client wants some of its objects to definitely be purged earlier, it can put those in - * another group. This could be used to make all FIFO objects (in the lower group) go away before - * any LIFO objects (in the higher group) go away. - * Objects that should not get any chance to stay around can be marked as "obsolete". They will - * be emptied before any other objects or pages are reclaimed. Obsolete objects are not emptied - * in any particular order. - * 'purgeable' is recognized as the correct spelling. For historical reasons, definitions - * in this file are spelled 'purgable'. - */ - -#ifndef _MACH_VM_PURGABLE_H_ -#define _MACH_VM_PURGABLE_H_ - -/* - * Types defined: - * - * vm_purgable_t purgeable object control codes. - */ - -typedef int vm_purgable_t; - -/* - * Enumeration of valid values for vm_purgable_t. - */ -#define VM_PURGABLE_SET_STATE ((vm_purgable_t) 0) /* set state of purgeable object */ -#define VM_PURGABLE_GET_STATE ((vm_purgable_t) 1) /* get state of purgeable object */ -#define VM_PURGABLE_PURGE_ALL ((vm_purgable_t) 2) /* purge all volatile objects now */ - -#define VM_PURGABLE_DEBUG_SHIFT 12 -#define VM_PURGABLE_DEBUG_MASK (0x3 << VM_PURGABLE_DEBUG_SHIFT) -#define VM_PURGABLE_DEBUG_EMPTY (0x1 << VM_PURGABLE_DEBUG_SHIFT) -#define VM_PURGABLE_DEBUG_FAULT (0x2 << VM_PURGABLE_DEBUG_SHIFT) - -/* - * Volatile memory ordering groups (group zero objects are purged before group 1, etc... - * It is implementation dependent as to whether these groups are global or per-address space. - * (for the moment, they are global). - */ -#define VM_VOLATILE_GROUP_SHIFT 8 -#define VM_VOLATILE_GROUP_MASK (7 << VM_VOLATILE_GROUP_SHIFT) -#define VM_VOLATILE_GROUP_DEFAULT VM_VOLATILE_GROUP_7 - -#define VM_VOLATILE_GROUP_0 (0 << VM_VOLATILE_GROUP_SHIFT) -#define VM_VOLATILE_GROUP_1 (1 << VM_VOLATILE_GROUP_SHIFT) -#define VM_VOLATILE_GROUP_2 (2 << VM_VOLATILE_GROUP_SHIFT) -#define VM_VOLATILE_GROUP_3 (3 << VM_VOLATILE_GROUP_SHIFT) -#define VM_VOLATILE_GROUP_4 (4 << VM_VOLATILE_GROUP_SHIFT) -#define VM_VOLATILE_GROUP_5 (5 << VM_VOLATILE_GROUP_SHIFT) -#define VM_VOLATILE_GROUP_6 (6 << VM_VOLATILE_GROUP_SHIFT) -#define VM_VOLATILE_GROUP_7 (7 << VM_VOLATILE_GROUP_SHIFT) - -/* - * Purgeable behavior - * Within the same group, FIFO objects will be emptied before objects that are added later. - * LIFO objects will be emptied after objects that are added later. - * - Input only, not returned on state queries. - */ -#define VM_PURGABLE_BEHAVIOR_SHIFT 6 -#define VM_PURGABLE_BEHAVIOR_MASK (1 << VM_PURGABLE_BEHAVIOR_SHIFT) -#define VM_PURGABLE_BEHAVIOR_FIFO (0 << VM_PURGABLE_BEHAVIOR_SHIFT) -#define VM_PURGABLE_BEHAVIOR_LIFO (1 << VM_PURGABLE_BEHAVIOR_SHIFT) - -/* - * Obsolete object. - * Disregard volatile group, and put object into obsolete queue instead, so it is the next object - * to be purged. - * - Input only, not returned on state queries. - */ -#define VM_PURGABLE_ORDERING_SHIFT 5 -#define VM_PURGABLE_ORDERING_MASK (1 << VM_PURGABLE_ORDERING_SHIFT) -#define VM_PURGABLE_ORDERING_OBSOLETE (1 << VM_PURGABLE_ORDERING_SHIFT) -#define VM_PURGABLE_ORDERING_NORMAL (0 << VM_PURGABLE_ORDERING_SHIFT) - - -/* - * Obsolete parameter - do not use - */ -#define VM_VOLATILE_ORDER_SHIFT 4 -#define VM_VOLATILE_ORDER_MASK (1 << VM_VOLATILE_ORDER_SHIFT) -#define VM_VOLATILE_MAKE_FIRST_IN_GROUP (1 << VM_VOLATILE_ORDER_SHIFT) -#define VM_VOLATILE_MAKE_LAST_IN_GROUP (0 << VM_VOLATILE_ORDER_SHIFT) - -/* - * Valid states of a purgeable object. - */ -#define VM_PURGABLE_STATE_MIN 0 /* minimum purgeable object state value */ -#define VM_PURGABLE_STATE_MAX 3 /* maximum purgeable object state value */ -#define VM_PURGABLE_STATE_MASK 3 /* mask to separate state from group */ - -#define VM_PURGABLE_NONVOLATILE 0 /* purgeable object is non-volatile */ -#define VM_PURGABLE_VOLATILE 1 /* purgeable object is volatile */ -#define VM_PURGABLE_EMPTY 2 /* purgeable object is volatile and empty */ -#define VM_PURGABLE_DENY 3 /* (mark) object not purgeable */ - -#define VM_PURGABLE_ALL_MASKS (VM_PURGABLE_STATE_MASK | \ - VM_VOLATILE_ORDER_MASK | \ - VM_PURGABLE_ORDERING_MASK | \ - VM_PURGABLE_BEHAVIOR_MASK | \ - VM_VOLATILE_GROUP_MASK | \ - VM_PURGABLE_DEBUG_MASK) -#endif /* _MACH_VM_PURGABLE_H_ */ diff --git a/include/xnu/mach/vm_region.h b/include/xnu/mach/vm_region.h deleted file mode 100644 index ebc0e8d54..000000000 --- a/include/xnu/mach/vm_region.h +++ /dev/null @@ -1,322 +0,0 @@ -/* - * Copyright (c) 2000-2006 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@ - */ -/* - * @OSF_COPYRIGHT@ - */ -/* - * File: mach/vm_region.h - * - * Define the attributes of a task's memory region - * - */ - -#ifndef _MACH_VM_REGION_H_ -#define _MACH_VM_REGION_H_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#pragma pack(4) - -// LP64todo: all the current tools are 32bit, obviously never worked for 64b -// so probably should be a real 32b ID vs. ptr. -// Current users just check for equality -typedef uint32_t vm32_object_id_t; - -/* - * Types defined: - * - * vm_region_info_t memory region attributes - */ - -#define VM_REGION_INFO_MAX (1024) -typedef int *vm_region_info_t; -typedef int *vm_region_info_64_t; -typedef int *vm_region_recurse_info_t; -typedef int *vm_region_recurse_info_64_t; -typedef int vm_region_flavor_t; -typedef int vm_region_info_data_t[VM_REGION_INFO_MAX]; - -#define VM_REGION_BASIC_INFO_64 9 -struct vm_region_basic_info_64 { - vm_prot_t protection; - vm_prot_t max_protection; - vm_inherit_t inheritance; - boolean_t shared; - boolean_t reserved; - memory_object_offset_t offset; - vm_behavior_t behavior; - unsigned short user_wired_count; -}; -typedef struct vm_region_basic_info_64 *vm_region_basic_info_64_t; -typedef struct vm_region_basic_info_64 vm_region_basic_info_data_64_t; - -#define VM_REGION_BASIC_INFO_COUNT_64 ((mach_msg_type_number_t) \ - (sizeof(vm_region_basic_info_data_64_t)/sizeof(int))) - -/* - * Passing VM_REGION_BASIC_INFO to vm_region_64 - * automatically converts it to a VM_REGION_BASIC_INFO_64. - * Please use that explicitly instead. - */ -#define VM_REGION_BASIC_INFO 10 - -/* - * This is the legacy basic info structure. It is - * deprecated because it passes only a 32-bit memory object - * offset back - too small for many larger objects (e.g. files). - */ -struct vm_region_basic_info { - vm_prot_t protection; - vm_prot_t max_protection; - vm_inherit_t inheritance; - boolean_t shared; - boolean_t reserved; - uint32_t offset; /* too small for a real offset */ - vm_behavior_t behavior; - unsigned short user_wired_count; -}; - -typedef struct vm_region_basic_info *vm_region_basic_info_t; -typedef struct vm_region_basic_info vm_region_basic_info_data_t; - -#define VM_REGION_BASIC_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof(vm_region_basic_info_data_t)/sizeof(int))) - -#define VM_REGION_EXTENDED_INFO 11 - -#define SM_COW 1 -#define SM_PRIVATE 2 -#define SM_EMPTY 3 -#define SM_SHARED 4 -#define SM_TRUESHARED 5 -#define SM_PRIVATE_ALIASED 6 -#define SM_SHARED_ALIASED 7 -#define SM_LARGE_PAGE 8 - -/* - * For submap info, the SM flags above are overlayed when a submap - * is encountered. The field denotes whether or not machine level mapping - * information is being shared. PTE's etc. When such sharing is taking - * place the value returned is SM_TRUESHARED otherwise SM_PRIVATE is passed - * back. - */ - -struct vm_region_extended_info { - vm_prot_t protection; - unsigned int user_tag; - unsigned int pages_resident; - unsigned int pages_shared_now_private; - unsigned int pages_swapped_out; - unsigned int pages_dirtied; - unsigned int ref_count; - unsigned short shadow_depth; - unsigned char external_pager; - unsigned char share_mode; -}; - -typedef struct vm_region_extended_info *vm_region_extended_info_t; -typedef struct vm_region_extended_info vm_region_extended_info_data_t; - -#define VM_REGION_EXTENDED_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof(vm_region_extended_info_data_t)/sizeof(int))) - - -#define VM_REGION_TOP_INFO 12 - -struct vm_region_top_info { - unsigned int obj_id; - unsigned int ref_count; - unsigned int private_pages_resident; - unsigned int shared_pages_resident; - unsigned char share_mode; -}; - -typedef struct vm_region_top_info *vm_region_top_info_t; -typedef struct vm_region_top_info vm_region_top_info_data_t; - -#define VM_REGION_TOP_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof(vm_region_top_info_data_t)/sizeof(int))) - - - -/* - * vm_region_submap_info will return information on a submap or object. - * The user supplies a nesting level on the call. When a walk of the - * user's map is done and a submap is encountered, the nesting count is - * checked. If the nesting count is greater than 1 the submap is entered and - * the offset relative to the address in the base map is examined. If the - * nesting count is zero, the information on the submap is returned. - * The caller may thus learn about a submap and its contents by judicious - * choice of the base map address and nesting count. The nesting count - * allows penetration of recursively mapped submaps. If a submap is - * encountered as a mapped entry of another submap, the caller may bump - * the nesting count and call vm_region_recurse again on the target address - * range. The "is_submap" field tells the caller whether or not a submap - * has been encountered. - * - * Object only fields are filled in through a walking of the object shadow - * chain (where one is present), and a walking of the resident page queue. - * - */ - -struct vm_region_submap_info { - vm_prot_t protection; /* present access protection */ - vm_prot_t max_protection; /* max avail through vm_prot */ - vm_inherit_t inheritance;/* behavior of map/obj on fork */ - uint32_t offset; /* offset into object/map */ - unsigned int user_tag; /* user tag on map entry */ - unsigned int pages_resident; /* only valid for objects */ - unsigned int pages_shared_now_private; /* only for objects */ - unsigned int pages_swapped_out; /* only for objects */ - unsigned int pages_dirtied; /* only for objects */ - unsigned int ref_count; /* obj/map mappers, etc */ - unsigned short shadow_depth; /* only for obj */ - unsigned char external_pager; /* only for obj */ - unsigned char share_mode; /* see enumeration */ - boolean_t is_submap; /* submap vs obj */ - vm_behavior_t behavior; /* access behavior hint */ - vm32_object_id_t object_id; /* obj/map name, not a handle */ - unsigned short user_wired_count; -}; - -typedef struct vm_region_submap_info *vm_region_submap_info_t; -typedef struct vm_region_submap_info vm_region_submap_info_data_t; - -#define VM_REGION_SUBMAP_INFO_COUNT ((mach_msg_type_number_t) \ - (sizeof(vm_region_submap_info_data_t)/sizeof(int))) - -struct vm_region_submap_info_64 { - vm_prot_t protection; /* present access protection */ - vm_prot_t max_protection; /* max avail through vm_prot */ - vm_inherit_t inheritance;/* behavior of map/obj on fork */ - memory_object_offset_t offset; /* offset into object/map */ - unsigned int user_tag; /* user tag on map entry */ - unsigned int pages_resident; /* only valid for objects */ - unsigned int pages_shared_now_private; /* only for objects */ - unsigned int pages_swapped_out; /* only for objects */ - unsigned int pages_dirtied; /* only for objects */ - unsigned int ref_count; /* obj/map mappers, etc */ - unsigned short shadow_depth; /* only for obj */ - unsigned char external_pager; /* only for obj */ - unsigned char share_mode; /* see enumeration */ - boolean_t is_submap; /* submap vs obj */ - vm_behavior_t behavior; /* access behavior hint */ - vm32_object_id_t object_id; /* obj/map name, not a handle */ - unsigned short user_wired_count; -}; - -typedef struct vm_region_submap_info_64 *vm_region_submap_info_64_t; -typedef struct vm_region_submap_info_64 vm_region_submap_info_data_64_t; - -#define VM_REGION_SUBMAP_INFO_COUNT_64 ((mach_msg_type_number_t) \ - (sizeof(vm_region_submap_info_data_64_t)/sizeof(int))) - -struct vm_region_submap_short_info_64 { - vm_prot_t protection; /* present access protection */ - vm_prot_t max_protection; /* max avail through vm_prot */ - vm_inherit_t inheritance;/* behavior of map/obj on fork */ - memory_object_offset_t offset; /* offset into object/map */ - unsigned int user_tag; /* user tag on map entry */ - unsigned int ref_count; /* obj/map mappers, etc */ - unsigned short shadow_depth; /* only for obj */ - unsigned char external_pager; /* only for obj */ - unsigned char share_mode; /* see enumeration */ - boolean_t is_submap; /* submap vs obj */ - vm_behavior_t behavior; /* access behavior hint */ - vm32_object_id_t object_id; /* obj/map name, not a handle */ - unsigned short user_wired_count; -}; - -typedef struct vm_region_submap_short_info_64 *vm_region_submap_short_info_64_t; -typedef struct vm_region_submap_short_info_64 vm_region_submap_short_info_data_64_t; - -#define VM_REGION_SUBMAP_SHORT_INFO_COUNT_64 ((mach_msg_type_number_t) \ - (sizeof(vm_region_submap_short_info_data_64_t)/sizeof(int))) - - -struct mach_vm_read_entry { - mach_vm_address_t address; - mach_vm_size_t size; -}; - -struct vm_read_entry { - vm_address_t address; - vm_size_t size; -}; - -#if VM32_SUPPORT -struct vm32_read_entry { - vm32_address_t address; - vm32_size_t size; -}; -#endif - - -#define VM_MAP_ENTRY_MAX (256) - -typedef struct mach_vm_read_entry mach_vm_read_entry_t[VM_MAP_ENTRY_MAX]; -typedef struct vm_read_entry vm_read_entry_t[VM_MAP_ENTRY_MAX]; -#if VM32_SUPPORT -typedef struct vm32_read_entry vm32_read_entry_t[VM_MAP_ENTRY_MAX]; -#endif - -#pragma pack() - - -#define VM_PAGE_INFO_MAX -typedef int *vm_page_info_t; -typedef int vm_page_info_data_t[VM_PAGE_INFO_MAX]; -typedef int vm_page_info_flavor_t; - -#define VM_PAGE_INFO_BASIC 1 -struct vm_page_info_basic { - int disposition; - int ref_count; - vm_object_id_t object_id; - memory_object_offset_t offset; - int depth; - int __pad; /* pad to 64-bit boundary */ -}; -typedef struct vm_page_info_basic *vm_page_info_basic_t; -typedef struct vm_page_info_basic vm_page_info_basic_data_t; - -#define VM_PAGE_INFO_BASIC_COUNT ((mach_msg_type_number_t) \ - (sizeof(vm_page_info_basic_data_t)/sizeof(int))) - - -#endif /*_MACH_VM_REGION_H_*/ diff --git a/include/xnu/mach/vm_statistics.h b/include/xnu/mach/vm_statistics.h deleted file mode 100644 index 487549894..000000000 --- a/include/xnu/mach/vm_statistics.h +++ /dev/null @@ -1,404 +0,0 @@ -/* - * Copyright (c) 2000-2009 Apple 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@ - */ -/* - * @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 Software.Distribution@CS.CMU.EDU - * 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/vm_statistics.h - * Author: Avadis Tevanian, Jr., Michael Wayne Young, David Golub - * - * Virtual memory statistics structure. - * - */ - -#ifndef _MACH_VM_STATISTICS_H_ -#define _MACH_VM_STATISTICS_H_ - -#include - - -/* - * vm_statistics - * - * History: - * rev0 - original structure. - * rev1 - added purgable info (purgable_count and purges). - * rev2 - added speculative_count. - * - * Note: you cannot add any new fields to this structure. Add them below in - * vm_statistics64. - */ - -struct vm_statistics { - natural_t free_count; /* # of pages free */ - natural_t active_count; /* # of pages active */ - natural_t inactive_count; /* # of pages inactive */ - natural_t wire_count; /* # of pages wired down */ - natural_t zero_fill_count; /* # of zero fill pages */ - natural_t reactivations; /* # of pages reactivated */ - natural_t pageins; /* # of pageins */ - natural_t pageouts; /* # of pageouts */ - natural_t faults; /* # of faults */ - natural_t cow_faults; /* # of copy-on-writes */ - natural_t lookups; /* object cache lookups */ - natural_t hits; /* object cache hits */ - - /* added for rev1 */ - natural_t purgeable_count; /* # of pages purgeable */ - natural_t purges; /* # of pages purged */ - - /* added for rev2 */ - /* - * NB: speculative pages are already accounted for in "free_count", - * so "speculative_count" is the number of "free" pages that are - * used to hold data that was read speculatively from disk but - * haven't actually been used by anyone so far. - */ - natural_t speculative_count; /* # of pages speculative */ -}; - -/* Used by all architectures */ -typedef struct vm_statistics *vm_statistics_t; -typedef struct vm_statistics vm_statistics_data_t; - -/* - * vm_statistics64 - * - * History: - * rev0 - original structure. - * rev1 - added purgable info (purgable_count and purges). - * rev2 - added speculative_count. - * ---- - * rev3 - changed name to vm_statistics64. - * changed some fields in structure to 64-bit on - * arm, i386 and x86_64 architectures. - * rev4 - require 64-bit alignment for efficient access - * in the kernel. No change to reported data. - * - */ - -struct vm_statistics64 { - natural_t free_count; /* # of pages free */ - natural_t active_count; /* # of pages active */ - natural_t inactive_count; /* # of pages inactive */ - natural_t wire_count; /* # of pages wired down */ - uint64_t zero_fill_count; /* # of zero fill pages */ - uint64_t reactivations; /* # of pages reactivated */ - uint64_t pageins; /* # of pageins */ - uint64_t pageouts; /* # of pageouts */ - uint64_t faults; /* # of faults */ - uint64_t cow_faults; /* # of copy-on-writes */ - uint64_t lookups; /* object cache lookups */ - uint64_t hits; /* object cache hits */ - - /* added for rev1 */ - uint64_t purges; /* # of pages purged */ - natural_t purgeable_count; /* # of pages purgeable */ - - /* added for rev2 */ - /* - * NB: speculative pages are already accounted for in "free_count", - * so "speculative_count" is the number of "free" pages that are - * used to hold data that was read speculatively from disk but - * haven't actually been used by anyone so far. - */ - natural_t speculative_count; /* # of pages speculative */ - -} __attribute__((aligned(8))); - -typedef struct vm_statistics64 *vm_statistics64_t; -typedef struct vm_statistics64 vm_statistics64_data_t; - -/* - * VM_STATISTICS_TRUNCATE_TO_32_BIT - * - * This is used by host_statistics() to truncate and peg the 64-bit in-kernel values from - * vm_statistics64 to the 32-bit values of the older structure above (vm_statistics). - */ -#define VM_STATISTICS_TRUNCATE_TO_32_BIT(value) ((uint32_t)(((value) > UINT32_MAX ) ? UINT32_MAX : (value))) - -/* - * vm_extmod_statistics - * - * Structure to record modifications to a task by an - * external agent. - * - * History: - * rev0 - original structure. - */ - -struct vm_extmod_statistics { - int64_t task_for_pid_count; /* # of times task port was looked up */ - int64_t task_for_pid_caller_count; /* # of times this task called task_for_pid */ - int64_t thread_creation_count; /* # of threads created in task */ - int64_t thread_creation_caller_count; /* # of threads created by task */ - int64_t thread_set_state_count; /* # of register state sets in task */ - int64_t thread_set_state_caller_count; /* # of register state sets by task */ -} __attribute__((aligned(8))); - -typedef struct vm_extmod_statistics *vm_extmod_statistics_t; -typedef struct vm_extmod_statistics vm_extmod_statistics_data_t; - - -/* included for the vm_map_page_query call */ - -#define VM_PAGE_QUERY_PAGE_PRESENT 0x1 -#define VM_PAGE_QUERY_PAGE_FICTITIOUS 0x2 -#define VM_PAGE_QUERY_PAGE_REF 0x4 -#define VM_PAGE_QUERY_PAGE_DIRTY 0x8 -#define VM_PAGE_QUERY_PAGE_PAGED_OUT 0x10 -#define VM_PAGE_QUERY_PAGE_COPIED 0x20 -#define VM_PAGE_QUERY_PAGE_SPECULATIVE 0x40 -#define VM_PAGE_QUERY_PAGE_EXTERNAL 0x80 -#define VM_PAGE_QUERY_PAGE_CS_VALIDATED 0x100 -#define VM_PAGE_QUERY_PAGE_CS_TAINTED 0x200 - -#ifdef MACH_KERNEL_PRIVATE - -/* - * Each machine dependent implementation is expected to - * keep certain statistics. They may do this anyway they - * so choose, but are expected to return the statistics - * in the following structure. - */ - -struct pmap_statistics { - integer_t resident_count; /* # of pages mapped (total)*/ - integer_t resident_max; /* # of pages mapped (peak) */ - integer_t wired_count; /* # of pages wired */ -}; - -typedef struct pmap_statistics *pmap_statistics_t; - -#endif /* MACH_KERNEL_PRIVATE */ - -/* - * VM allocation flags: - * - * VM_FLAGS_FIXED - * (really the absence of VM_FLAGS_ANYWHERE) - * Allocate new VM region at the specified virtual address, if possible. - * - * VM_FLAGS_ANYWHERE - * Allocate new VM region anywhere it would fit in the address space. - * - * VM_FLAGS_PURGABLE - * Create a purgable VM object for that new VM region. - * - * VM_FLAGS_NO_PMAP_CHECK - * (for DEBUG kernel config only, ignored for other configs) - * Do not check that there is no stale pmap mapping for the new VM region. - * This is useful for kernel memory allocations at bootstrap when building - * the initial kernel address space while some memory is already in use. - * - * VM_FLAGS_OVERWRITE - * The new VM region can replace existing VM regions if necessary - * (to be used in combination with VM_FLAGS_FIXED). - * - * VM_FLAGS_NO_CACHE - * Pages brought in to this VM region are placed on the speculative - * queue instead of the active queue. In other words, they are not - * cached so that they will be stolen first if memory runs low. - */ -#define VM_FLAGS_FIXED 0x0000 -#define VM_FLAGS_ANYWHERE 0x0001 -#define VM_FLAGS_PURGABLE 0x0002 -#define VM_FLAGS_NO_CACHE 0x0010 -#ifdef KERNEL_PRIVATE -#define VM_FLAGS_PERMANENT 0x0100 /* mapping can NEVER be unmapped */ -#define VM_FLAGS_GUARD_AFTER 0x0200 /* guard page after the mapping */ -#define VM_FLAGS_GUARD_BEFORE 0x0400 /* guard page before the mapping */ -#define VM_FLAGS_SUBMAP 0x0800 /* mapping a VM submap */ -#define VM_FLAGS_ALREADY 0x1000 /* OK if same mapping already exists */ -#define VM_FLAGS_BEYOND_MAX 0x2000 /* map beyond the map's max offset */ -#endif /* KERNEL_PRIVATE */ -#define VM_FLAGS_OVERWRITE 0x4000 /* delete any existing mappings first */ -#ifdef KERNEL_PRIVATE -#define VM_FLAGS_NO_PMAP_CHECK 0x8000 /* do not check that pmap is empty */ -#define VM_FLAGS_MAP_JIT 0x80000 /* Used to mark an entry as describing a JIT region */ -#endif /* KERNEL_PRIVATE */ - -/* - * VM_FLAGS_SUPERPAGE_MASK - * 3 bits that specify whether large pages should be used instead of - * base pages (!=0), as well as the requested page size. - */ -#define VM_FLAGS_SUPERPAGE_MASK 0x70000 /* bits 0x10000, 0x20000, 0x40000 */ -#define VM_FLAGS_SUPERPAGE_SHIFT 16 - -#define SUPERPAGE_NONE 0 /* no superpages, if all bits are 0 */ -#define SUPERPAGE_SIZE_ANY 1 -#define VM_FLAGS_SUPERPAGE_NONE (SUPERPAGE_NONE << VM_FLAGS_SUPERPAGE_SHIFT) -#define VM_FLAGS_SUPERPAGE_SIZE_ANY (SUPERPAGE_SIZE_ANY << VM_FLAGS_SUPERPAGE_SHIFT) -#if defined(__x86_64__) || !defined(KERNEL) -#define SUPERPAGE_SIZE_2MB 2 -#define VM_FLAGS_SUPERPAGE_SIZE_2MB (SUPERPAGE_SIZE_2MB<> 24 -#define VM_SET_FLAGS_ALIAS(flags, alias) \ - (flags) = (((flags) & ~VM_FLAGS_ALIAS_MASK) | \ - (((alias) & ~VM_FLAGS_ALIAS_MASK) << 24)) - -/* These are the flags that we accept from user-space */ -#define VM_FLAGS_USER_ALLOCATE (VM_FLAGS_FIXED | \ - VM_FLAGS_ANYWHERE | \ - VM_FLAGS_PURGABLE | \ - VM_FLAGS_NO_CACHE | \ - VM_FLAGS_OVERWRITE | \ - VM_FLAGS_SUPERPAGE_MASK | \ - VM_FLAGS_ALIAS_MASK) -#define VM_FLAGS_USER_MAP VM_FLAGS_USER_ALLOCATE -#define VM_FLAGS_USER_REMAP (VM_FLAGS_FIXED | \ - VM_FLAGS_ANYWHERE | \ - VM_FLAGS_OVERWRITE) - -#define VM_MEMORY_MALLOC 1 -#define VM_MEMORY_MALLOC_SMALL 2 -#define VM_MEMORY_MALLOC_LARGE 3 -#define VM_MEMORY_MALLOC_HUGE 4 -#define VM_MEMORY_SBRK 5// uninteresting -- no one should call -#define VM_MEMORY_REALLOC 6 -#define VM_MEMORY_MALLOC_TINY 7 -#define VM_MEMORY_MALLOC_LARGE_REUSABLE 8 -#define VM_MEMORY_MALLOC_LARGE_REUSED 9 - -#define VM_MEMORY_ANALYSIS_TOOL 10 - -#define VM_MEMORY_MACH_MSG 20 -#define VM_MEMORY_IOKIT 21 -#define VM_MEMORY_STACK 30 -#define VM_MEMORY_GUARD 31 -#define VM_MEMORY_SHARED_PMAP 32 -/* memory containing a dylib */ -#define VM_MEMORY_DYLIB 33 -#define VM_MEMORY_OBJC_DISPATCHERS 34 - -/* Was a nested pmap (VM_MEMORY_SHARED_PMAP) which has now been unnested */ -#define VM_MEMORY_UNSHARED_PMAP 35 - - -// Placeholders for now -- as we analyze the libraries and find how they -// use memory, we can make these labels more specific. -#define VM_MEMORY_APPKIT 40 -#define VM_MEMORY_FOUNDATION 41 -#define VM_MEMORY_COREGRAPHICS 42 -#define VM_MEMORY_CORESERVICES 43 -#define VM_MEMORY_CARBON VM_MEMORY_CORESERVICES -#define VM_MEMORY_JAVA 44 -#define VM_MEMORY_ATS 50 -#define VM_MEMORY_LAYERKIT 51 -#define VM_MEMORY_CGIMAGE 52 -#define VM_MEMORY_TCMALLOC 53 - -/* private raster data (i.e. layers, some images, QGL allocator) */ -#define VM_MEMORY_COREGRAPHICS_DATA 54 - -/* shared image and font caches */ -#define VM_MEMORY_COREGRAPHICS_SHARED 55 - -/* Memory used for virtual framebuffers, shadowing buffers, etc... */ -#define VM_MEMORY_COREGRAPHICS_FRAMEBUFFERS 56 - -/* Window backing stores, custom shadow data, and compressed backing stores */ -#define VM_MEMORY_COREGRAPHICS_BACKINGSTORES 57 - -/* catch-all for other uses, such as the read-only shared data page */ -#define VM_MEMORY_COREGRAPHICS_MISC VM_MEMORY_COREGRAPHICS - -/* memory allocated by the dynamic loader for itself */ -#define VM_MEMORY_DYLD 60 -/* malloc'd memory created by dyld */ -#define VM_MEMORY_DYLD_MALLOC 61 - -/* Used for sqlite page cache */ -#define VM_MEMORY_SQLITE 62 - -/* JavaScriptCore heaps */ -#define VM_MEMORY_JAVASCRIPT_CORE 63 -/* memory allocated for the JIT */ -#define VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR 64 -#define VM_MEMORY_JAVASCRIPT_JIT_REGISTER_FILE 65 - -/* memory allocated for GLSL */ -#define VM_MEMORY_GLSL 66 - -/* memory allocated for OpenCL.framework */ -#define VM_MEMORY_OPENCL 67 - -/* memory allocated for QuartzCore.framework */ -#define VM_MEMORY_COREIMAGE 68 - -/* memory allocated for WebCore Purgeable Buffers */ -#define VM_MEMORY_WEBCORE_PURGEABLE_BUFFERS 69 - -/* ImageIO memory */ -#define VM_MEMORY_IMAGEIO 70 - -/* CoreProfile memory */ -#define VM_MEMORY_COREPROFILE 71 - -/* assetsd / MobileSlideShow memory */ -#define VM_MEMORY_ASSETSD 72 - -/* Reserve 240-255 for application */ -#define VM_MEMORY_APPLICATION_SPECIFIC_1 240 -#define VM_MEMORY_APPLICATION_SPECIFIC_16 255 - -#define VM_MAKE_TAG(tag) ((tag) << 24) - -#endif /* _MACH_VM_STATISTICS_H_ */ diff --git a/include/xnu/mach/vm_sync.h b/include/xnu/mach/vm_sync.h deleted file mode 100644 index dfb948b5c..000000000 --- a/include/xnu/mach/vm_sync.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2000-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@ - */ -/* - * @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 Software.Distribution@CS.CMU.EDU - * 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/vm_sync.h - * - * Virtual memory synchronisation definitions. - * - */ - -#ifndef _MACH_VM_SYNC_H_ -#define _MACH_VM_SYNC_H_ - -typedef unsigned vm_sync_t; - -/* - * Synchronization flags, defined as bits within the vm_sync_t type - */ - -#define VM_SYNC_ASYNCHRONOUS ((vm_sync_t) 0x01) -#define VM_SYNC_SYNCHRONOUS ((vm_sync_t) 0x02) -#define VM_SYNC_INVALIDATE ((vm_sync_t) 0x04) -#define VM_SYNC_KILLPAGES ((vm_sync_t) 0x08) -#define VM_SYNC_DEACTIVATE ((vm_sync_t) 0x10) -#define VM_SYNC_CONTIGUOUS ((vm_sync_t) 0x20) -#define VM_SYNC_REUSABLEPAGES ((vm_sync_t) 0x40) - -#endif /* _MACH_VM_SYNC_H_ */ diff --git a/include/xnu/mach/vm_types.h b/include/xnu/mach/vm_types.h deleted file mode 100644 index f586d876c..000000000 --- a/include/xnu/mach/vm_types.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2000-2004 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@ - */ -/* - * @OSF_COPYRIGHT@ - * - */ -#ifndef _MACH_VM_TYPES_H_ -#define _MACH_VM_TYPES_H_ - -#include -#include - -#include - -typedef vm_offset_t pointer_t; -typedef vm_offset_t vm_address_t; - -/* - * We use addr64_t for 64-bit addresses that are used on both - * 32 and 64-bit machines. On PPC, they are passed and returned as - * two adjacent 32-bit GPRs. We use addr64_t in places where - * common code must be useable both on 32 and 64-bit machines. - */ -typedef uint64_t addr64_t; /* Basic effective address */ - -/* - * We use reg64_t for addresses that are 32 bits on a 32-bit - * machine, and 64 bits on a 64-bit machine, but are always - * passed and returned in a single GPR on PPC. This type - * cannot be used in generic 32-bit c, since on a 64-bit - * machine the upper half of the register will be ignored - * by the c compiler in 32-bit mode. In c, we can only use the - * type in prototypes of functions that are written in and called - * from assembly language. This type is basically a comment. - */ -typedef uint32_t reg64_t; - -/* - * To minimize the use of 64-bit fields, we keep some physical - * addresses (that are page aligned) as 32-bit page numbers. - * This limits the physical address space to 16TB of RAM. - */ -typedef uint32_t ppnum_t; /* Physical page number */ -#define PPNUM_MAX UINT32_MAX - - -#ifdef KERNEL_PRIVATE - -#include - -#ifndef MACH_KERNEL_PRIVATE -/* - * Use specifically typed null structures for these in - * other parts of the kernel to enable compiler warnings - * about type mismatches, etc... Otherwise, these would - * be void*. - */ -__BEGIN_DECLS - -struct pmap ; -struct _vm_map ; -struct vm_object ; - -__END_DECLS - -#endif /* MACH_KERNEL_PRIVATE */ - -typedef struct pmap *pmap_t; -typedef struct _vm_map *vm_map_t; -typedef struct vm_object *vm_object_t; -typedef struct vm_object_fault_info *vm_object_fault_info_t; - -#define PMAP_NULL ((pmap_t) 0) -#define VM_OBJECT_NULL ((vm_object_t) 0) - -#else /* KERNEL_PRIVATE */ - -typedef mach_port_t vm_map_t; - -#endif /* KERNEL_PRIVATE */ - -#define VM_MAP_NULL ((vm_map_t) 0) - -/* - * Evolving definitions, likely to change. - */ - -typedef uint64_t vm_object_offset_t; -typedef uint64_t vm_object_size_t; - -#ifdef KERNEL_PRIVATE - -#ifndef MACH_KERNEL_PRIVATE - -__BEGIN_DECLS - -struct upl ; -struct vm_map_copy ; -struct vm_named_entry ; - -__END_DECLS - -#endif /* MACH_KERNEL_PRIVATE */ - -typedef struct upl *upl_t; -typedef struct vm_map_copy *vm_map_copy_t; -typedef struct vm_named_entry *vm_named_entry_t; - -#define VM_MAP_COPY_NULL ((vm_map_copy_t) 0) - -#else /* KERNEL_PRIVATE */ - -typedef mach_port_t upl_t; -typedef mach_port_t vm_named_entry_t; - -#endif /* KERNEL_PRIVATE */ - -#define UPL_NULL ((upl_t) 0) -#define VM_NAMED_ENTRY_NULL ((vm_named_entry_t) 0) - -#endif /* _MACH_VM_TYPES_H_ */ diff --git a/platform-include/mach-o/fat.h b/platform-include/mach-o/fat.h index e2bcf433d..f314be3ec 100644 --- a/platform-include/mach-o/fat.h +++ b/platform-include/mach-o/fat.h @@ -1,3 +1,4 @@ +// Modified by Lubos Dolezel for Darling build /* * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. * @@ -42,8 +43,9 @@ * and contains the constants for the possible values of these types. */ #include -#include -#include + +typedef int cpu_type_t; +typedef int cpu_subtype_t; #define FAT_MAGIC 0xcafebabe #define FAT_CIGAM 0xbebafeca /* NXSwapLong(FAT_MAGIC) */ diff --git a/platform-include/mach-o/loader.h b/platform-include/mach-o/loader.h index e5e825836..5b645fc24 100644 --- a/platform-include/mach-o/loader.h +++ b/platform-include/mach-o/loader.h @@ -1,3 +1,4 @@ +// Modified by Lubos Dolezel for Darling build /* * Copyright (c) 1999-2010 Apple Inc. All Rights Reserved. * @@ -27,25 +28,10 @@ * This file describes the format of mach object files. */ #include - -/* - * is needed here for the cpu_type_t and cpu_subtype_t types - * and contains the constants for the possible values of these types. - */ -#include - -/* - * is needed here for the vm_prot_t type and contains the - * constants that are or'ed together for the possible values of this type. - */ #include -/* - * is expected to define the flavors of the thread - * states and the structures of those flavors for each machine. - */ -#include -#include +typedef int cpu_type_t; +typedef int cpu_subtype_t; /* * The 32-bit mach header appears at the very beginning of the object file for diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c9704ae74..ac4b2ab3a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -project(darling-libsystem) +project(darling-src) cmake_minimum_required(VERSION 2.4.0) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") @@ -21,10 +21,29 @@ else(CMAKE_SIZEOF_VOID_P EQUAL 4 OR CMAKE_INSTALL_LIBDIR STREQUAL "lib32") add_definitions(-DTARGET_CPU_X86_64=1 -D__LITTLE_ENDIAN__) endif(CMAKE_SIZEOF_VOID_P EQUAL 4 OR CMAKE_INSTALL_LIBDIR STREQUAL "lib32") +if (CMAKE_INSTALL_LIBDIR STREQUAL "lib32") + set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} -m32") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") + set(CMAKE_ASM_NASM_OBJECT_FORMAT "elf") + SET(CMAKE_C_SIZEOF_DATA_PTR 4) + SET(SUFFIX "32") +endif(CMAKE_INSTALL_LIBDIR STREQUAL "lib32") +if (CMAKE_INSTALL_LIBDIR STREQUAL "lib64") + set(SUFFIX "64") +endif (CMAKE_INSTALL_LIBDIR STREQUAL "lib64") + add_definitions(-D__APPLE__ -D__DYNAMIC__) +configure_file(darling-config.h.in darling-config.h) +include_directories("${CMAKE_CURRENT_BINARY_DIR}") +include_directories("${CMAKE_CURRENT_SOURCE_DIR}") add_subdirectory(bootstrap_cmds) add_subdirectory(kernel) +add_subdirectory(util) +add_subdirectory(libmach-o) +add_subdirectory(libdyld) +add_subdirectory(dyld) include_directories("${CMAKE_CURRENT_SOURCE_DIR}/libc/include") include_directories("${CMAKE_CURRENT_SOURCE_DIR}/libm/Source") diff --git a/config.h.in b/src/darling-config.h.in similarity index 100% rename from config.h.in rename to src/darling-config.h.in diff --git a/src/dyld/CMakeLists.txt b/src/dyld/CMakeLists.txt index ac094b986..d985d67fd 100644 --- a/src/dyld/CMakeLists.txt +++ b/src/dyld/CMakeLists.txt @@ -11,11 +11,14 @@ set(dyld_SRCS dirstructure.cpp ) +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib${SUFFIX}/darling") #SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--enable-new-dtags") SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../libmach-o) + if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86") add_definitions(-DHAS_DEBUG_HELPERS) diff --git a/src/libSystem/CMakeLists.txt b/src/libSystem/CMakeLists.txt deleted file mode 100644 index dd48d5963..000000000 --- a/src/libSystem/CMakeLists.txt +++ /dev/null @@ -1,138 +0,0 @@ -project(libSystem) - -cmake_minimum_required(VERSION 2.4.0) -if(COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) -endif(COMMAND cmake_policy) - -if (NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm.*") -enable_language(ASM_NASM) -endif (NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm.*") - -include(CheckIncludeFile) -CHECK_INCLUDE_FILE(bsd/wchar.h HAS_BSD_WCHAR_H) - -if (NOT "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}" MATCHES ".*clang") - message(FATAL_ERROR "Clang is the only supported compiler (${CMAKE_CXX_COMPILER} used).") -endif (NOT "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}" MATCHES ".*clang") - -configure_file(config.h.in libsystem-config.h) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fblocks -std=c++11") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fblocks -D_GNU_SOURCE") - -#find_path(LIBCXX_INCLUDE_DIR c++/v1/vector) -#if (DEFINED LIBCXX_INCLUDE_DIR) -# message(STATUS "Found libcxx in ${LIBCXX_INCLUDE_DIR}") -#else (DEFINED LIBCXX_INCLUDE_DIR) -# message(FATAL_ERROR "libcxx not found") -#endif (DEFINED LIBCXX_INCLUDE_DIR) - -#include_directories(${LIBCXX_INCLUDE_DIR}) - -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -include_directories(${CMAKE_CURRENT_BINARY_DIR}) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../util) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../libmach-o) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../include) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../include/darwin) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../include/xnu) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../include/xnu/mach) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../include/xnu/bsd) - -#ADD_CUSTOM_COMMAND(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/directmap.nasm" -# COMMAND "${CMAKE_CURRENT_BINARY_DIR}/../../genfuncmap" ARGS "${CMAKE_CURRENT_SOURCE_DIR}/libc/directmap.lst" "${CMAKE_CURRENT_BINARY_DIR}/directmap.nasm") - - -set(libc_SRCS - libc/mac.c - libc/rune-none.c - libc/popcount.c - libc/runetable.c - libc/stack_protector-obsd.c - libc/err.c - libc/errno.cpp - libc/OSAtomic.cpp - libc/strmode.c - libc/sysctl.cpp - libc/dir.cpp - libc/string.cpp - libc/exec.cpp - libc/uname.cpp - libc/stdio.cpp - libc/fopsmisc.cpp - libc/aio.cpp - libc/mount.cpp - libc/nextstep.cpp - libc/arch.cpp - libc/qsort.cpp - libc/misc.cpp - libc/pthread.cpp - libc/sysconf.cpp - libc/net.cpp - libc/getpwent.cpp - libc/signals.cpp - libc/termios.cpp - libc/attrlist.cpp - libc/spawn.cpp - libc/xlocale.cpp - libc/malloc_zone.cpp - libc/namemap.cpp - libc/vis.c - libc/unvis.c - libc/math.cpp - libc/sigsetjmp.cpp - libc/setjmp.nasm - libc/confstr.cpp - libc/progname.cpp - common/auto.cpp - common/path.cpp -) - -if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86.*") - set(libc_SRCS ${libc_SRCS} libc/setjmp.nasm) -elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm.*") - set(libc_SRCS ${libc_SRCS} libc/setjmp-arm.s) -endif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86.*") - -set(asl_SRCS - asl/asl.cpp - asl/ASLClient.cpp - asl/ASLSyslogClient.cpp - asl/ASLMsg.cpp - asl/ASLResponse.cpp -) - -set(bsdkern_SRCS - kernel-bsd/stat.cpp - kernel-bsd/fopsmisc.cpp - kernel-bsd/io.cpp - kernel-bsd/wait.cpp - kernel-bsd/sockets.cpp - kernel-bsd/fs.cpp - kernel-bsd/fcntl.cpp - kernel-bsd/proc.cpp - kernel-bsd/mman.cpp -) - -set(machkern_SRCS - kernel-mach/host.cpp - kernel-mach/lockset.cpp - kernel-mach/semaphore.cpp - kernel-mach/task.cpp - kernel-mach/time.cpp - kernel-mach/vm.cpp - kernel-mach/error.cpp - kernel-mach/Futex.cpp - kernel-mach/FutexSemaphore.cpp - kernel-mach/compat.cpp - kernel-mach/thread.cpp -) - -add_library(System SHARED ${libc_SRCS} ${bsdkern_SRCS} - ${machkern_SRCS} ${asl_SRCS} keymgr/keymgr.c) -# -luuid to make uuid_ functions available for Darwin apps -target_link_libraries(System -ldl -lpthread -luuid mach-o -lrt -lssl -lbsd -lutil ${GNUSTEP_OBJC_CFLAGS}) -add_dependencies(System mach-o) - -install(TARGETS System DESTINATION "lib${SUFFIX}/darling") - diff --git a/src/libSystem/asl/ASLClient.cpp b/src/libSystem/asl/ASLClient.cpp deleted file mode 100644 index 0e2d733e7..000000000 --- a/src/libSystem/asl/ASLClient.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "ASLClient.h" - -ASLClient::ASLClient() - : m_filter(0xffffffff) -{ -} - -int ASLClient::setFilter(int filter) -{ - m_filter = filter; - return true; -} - -bool ASLClient::willBeFilteredOut(int level) -{ - return (m_filter & (1 << level)) == 0; -} - -bool ASLClient::addLogFile(int fd) -{ - m_extraFiles.insert(fd); - return true; -} - -bool ASLClient::removeLogFile(int fd) -{ - m_extraFiles.erase(fd); - return true; -} - diff --git a/src/libSystem/asl/ASLClient.h b/src/libSystem/asl/ASLClient.h deleted file mode 100644 index fb0ef6c3e..000000000 --- a/src/libSystem/asl/ASLClient.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef ASLCLIENT_H -#define ASLCLIENT_H -#include - -class ASLMsg; -class ASLResponse; - -class ASLClient -{ -public: - ASLClient(); - virtual ~ASLClient() {} - virtual bool log(ASLMsg* msg) = 0; - virtual bool logAuxiliary(ASLMsg* msg, const char* title, const char* uti, const char* url) = 0; - virtual int setFilter(int filter); - bool willBeFilteredOut(int level); - virtual ASLResponse* search(ASLMsg* query) = 0; - - virtual bool addLogFile(int fd); - virtual bool removeLogFile(int fd); -protected: - int m_filter; - std::set m_extraFiles; -}; - -#endif - diff --git a/src/libSystem/asl/ASLMsg.cpp b/src/libSystem/asl/ASLMsg.cpp deleted file mode 100644 index 49f919932..000000000 --- a/src/libSystem/asl/ASLMsg.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include "ASLMsg.h" -#include "asl.h" - -ASLMsg::ASLMsg(int type) - : m_type(type) -{ -} - -const char* ASLMsg::get(const char* key) const -{ - auto it = m_pairs.find(key); - if (it == m_pairs.end()) - return nullptr; - else - return it->second.value.c_str(); -} - -bool ASLMsg::set(const char* key, const char* value) -{ - return set(key, 0, value); -} - -bool ASLMsg::set(const char* key, int op, const char* value) -{ - if (op && m_type != ASL_TYPE_QUERY) - return false; - - MapValue v = { (value) ? value : "(nil)", op }; - m_pairs[key] = v; - return true; -} - -const char* ASLMsg::get(int index) const -{ - auto it = m_pairs.begin(); - const char* retval = nullptr; - - while (index > 0 && it != m_pairs.end()) - { - it++; - index--; - } - - if (it != m_pairs.end()) - return it->second.value.c_str(); - else - return nullptr; -} - -bool ASLMsg::unset(const char* key) -{ - m_pairs.erase(key); - return true; -} - diff --git a/src/libSystem/asl/ASLMsg.h b/src/libSystem/asl/ASLMsg.h deleted file mode 100644 index 41b96656b..000000000 --- a/src/libSystem/asl/ASLMsg.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef ASLMSG_H -#define ASLMSG_H -#include -#include - -class ASLMsg -{ -public: - ASLMsg(int type); - - const char* get(const char* key) const; - const char* get(int index) const; - bool set(const char* key, const char* value); - bool set(const char* key, int op, const char* value); - bool unset(const char* key); - - int type() const { return m_type; } -private: - struct MapValue - { - std::string value; - int op; - }; - std::map m_pairs; - int m_type; -}; - -#endif - diff --git a/src/libSystem/asl/ASLResponse.cpp b/src/libSystem/asl/ASLResponse.cpp deleted file mode 100644 index 34220209c..000000000 --- a/src/libSystem/asl/ASLResponse.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "ASLResponse.h" - -ASLResponse::ASLResponse(const std::vector& data) - : m_pos(0) -{ - m_data = data; -} - -ASLResponse::~ASLResponse() -{ - for (ASLMsg* msg : m_data) - delete msg; -} - -ASLMsg* ASLResponse::next() -{ - if (m_pos >= m_data.size()) - return nullptr; - return m_data[m_pos++]; -} - diff --git a/src/libSystem/asl/ASLResponse.h b/src/libSystem/asl/ASLResponse.h deleted file mode 100644 index 8a238c38e..000000000 --- a/src/libSystem/asl/ASLResponse.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef ASLRESPONSE_H -#define ASLRESPONSE_H -#include "ASLMsg.h" -#include - -class ASLResponse -{ -public: - // Takes ownership of these ASLMsg's - ASLResponse(const std::vector& data); - ~ASLResponse(); - ASLMsg* next(); -private: - std::vector m_data; - int m_pos; -}; - -#endif - diff --git a/src/libSystem/asl/ASLSyslogClient.cpp b/src/libSystem/asl/ASLSyslogClient.cpp deleted file mode 100644 index 1a4d75456..000000000 --- a/src/libSystem/asl/ASLSyslogClient.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include "ASLSyslogClient.h" -#include "ASLMsg.h" -#include -#include -#include -#include "asl.h" - -static const std::map g_levels { - std::make_pair(ASL_STRING_EMERG, LOG_EMERG), - std::make_pair(ASL_STRING_ALERT, LOG_ALERT), - std::make_pair(ASL_STRING_CRIT, LOG_CRIT), - std::make_pair(ASL_STRING_ERR, LOG_ERR), - std::make_pair(ASL_STRING_WARNING, LOG_WARNING), - std::make_pair(ASL_STRING_NOTICE, LOG_NOTICE), - std::make_pair(ASL_STRING_INFO, LOG_INFO), - std::make_pair(ASL_STRING_DEBUG, LOG_DEBUG) -}; - -ASLSyslogClient::ASLSyslogClient(const char* ident, const char* facility, uint32_t opts) -{ - int sopts = 0; - - if (opts & ASL_OPT_STDERR) - sopts |= LOG_PERROR; - if (opts & ASL_OPT_NO_DELAY) - sopts |= LOG_NDELAY; - - // This is totally poor man's implementation - ::openlog(ident, sopts, LOG_USER); -} - -ASLSyslogClient::~ASLSyslogClient() -{ - ::closelog(); -} - -bool ASLSyslogClient::log(ASLMsg* msg) -{ - const char* text = msg->get(ASL_KEY_MSG); - const char* level = msg->get(ASL_KEY_LEVEL); - int nlevel = LOG_ERR; - - if (!msg) - return false; - - if (!level) - level = ASL_STRING_ERR; - - // convert level string to int - auto it = g_levels.find(level); - if (it != g_levels.end()) - nlevel = it->second; - - syslog(nlevel, "%s", text); - - // TODO: use ASLFileClient to log to a file - - return true; -} - -bool ASLSyslogClient::logAuxiliary(ASLMsg* msg, const char* title, const char* uti, const char* url) -{ - // TODO - return false; -} - -ASLResponse* ASLSyslogClient::search(ASLMsg* query) -{ - // Not supported - return nullptr; -} - diff --git a/src/libSystem/asl/ASLSyslogClient.h b/src/libSystem/asl/ASLSyslogClient.h deleted file mode 100644 index c20a0425b..000000000 --- a/src/libSystem/asl/ASLSyslogClient.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef ASLSYSLOGCLIENT_H -#define ASLSYSLOGCLIENT_H -#include "ASLClient.h" -#include - -class ASLSyslogClient : public ASLClient -{ -public: - ASLSyslogClient(const char* ident, const char* facility, uint32_t opts); - virtual ~ASLSyslogClient(); - - virtual bool log(ASLMsg* msg) override; - virtual bool logAuxiliary(ASLMsg* msg, const char* title, const char* uti, const char* url) override; - virtual ASLResponse* search(ASLMsg* query) override; -private: -}; - -#endif - diff --git a/src/libSystem/asl/asl.cpp b/src/libSystem/asl/asl.cpp deleted file mode 100644 index 2d80ee7c7..000000000 --- a/src/libSystem/asl/asl.cpp +++ /dev/null @@ -1,184 +0,0 @@ -#include "asl.h" -#include "ASLMsg.h" -#include "ASLClient.h" -#include "ASLSyslogClient.h" -#include "ASLResponse.h" -#include - -static const int DEFAULT_BUFFER_SIZE = 1024; -static const char* ASL_LEVELS[] = { ASL_STRING_EMERG, ASL_STRING_ALERT, ASL_STRING_CRIT, ASL_STRING_ERR, - ASL_STRING_WARNING, ASL_STRING_NOTICE, ASL_STRING_INFO, ASL_STRING_DEBUG }; - -int _asl_lib_log(aslclient asl, uint32_t, aslmsg msg, const char *format, ...) -{ - va_list ap; - int rv; - - va_start(ap, format); - - rv = asl_vlog(asl, msg, -1, format, ap); - va_end(ap); - - return rv; -} - -uint32_t _asl_evaluate_send(aslclient asl, aslmsg msg, int level) -{ - return !asl->willBeFilteredOut(level); -} - -aslclient asl_open(const char *ident, const char *facility, uint32_t opts) -{ - return new ASLSyslogClient(ident, facility, opts); -} - -void asl_close(aslclient asl) -{ - delete asl; -} - -int asl_add_log_file(aslclient asl, int descriptor) -{ - return !asl->addLogFile(descriptor); -} - -int asl_remove_log_file(aslclient asl, int descriptor) -{ - return !asl->removeLogFile(descriptor); -} - -int asl_set_filter(aslclient asl, int f) -{ - return !asl->setFilter(f); -} - -const char *asl_key(aslmsg msg, uint32_t n) -{ - return msg->get(n); -} - -aslmsg asl_new(uint32_t type) -{ - return new ASLMsg(type); -} - -int asl_set(aslmsg msg, const char *key, const char *value) -{ - return !msg->set(key, value); -} - -int asl_unset(aslmsg msg, const char *key) -{ - return !msg->unset(key); -} - -const char *asl_get(aslmsg msg, const char *key) -{ - return msg->get(key); -} - -int asl_log(aslclient asl, aslmsg msg, int level, const char *format, ...) -{ - va_list ap; - int rv; - - va_start(ap, format); - - rv = asl_vlog(asl, msg, level, format, ap); - va_end(ap); - - return rv; -} - -int asl_vlog(aslclient asl, aslmsg msg, int level, const char *format, va_list ap) -{ - char* buffer; - int curSize = DEFAULT_BUFFER_SIZE; - - if (level > 7) - return 1; - - buffer = new char[DEFAULT_BUFFER_SIZE]; - if (!buffer) - return 1; - - while (true) - { - int needed = vsnprintf(buffer, curSize, format, ap); - if (needed < curSize) - break; - - curSize = needed+1; - delete [] buffer; - buffer = new char[curSize]; - - if (!buffer) - return 1; - } - - ASLMsg msg2(*msg); - - msg2.set(ASL_KEY_MSG, buffer); - free(buffer); - - if (level > 0) // non-standard feature to avoid code duplication - msg2.set(ASL_KEY_LEVEL, ASL_LEVELS[level]); - - return !asl->log(&msg2); -} - -int asl_send(aslclient asl, aslmsg msg) -{ - return !asl->log(msg); -} - -void asl_free(aslmsg msg) -{ - delete msg; -} - -int asl_set_query(aslmsg msg, const char *key, const char *value, uint32_t op) -{ - return !msg->set(key, op, value); -} - -aslresponse asl_search(aslclient asl, aslmsg msg) -{ - return asl->search(msg); -} - -aslmsg aslresponse_next(aslresponse r) -{ - return r->next(); -} - -void aslresponse_free(aslresponse r) -{ - delete r; -} - -int asl_create_auxiliary_file(aslmsg msg, const char *title, const char *uti, int *out_descriptor) -{ - return 1; // TODO -} - -int asl_close_auxiliary_file(int descriptor) -{ - return 1; // TODO -} - -int asl_log_auxiliary_location(aslmsg msg, const char *title, const char *uti, const char *url) -{ - return 1; // TODO -} - -aslclient asl_open_from_file(int descriptor, const char *ident, const char *facility) -{ - return nullptr; // TODO -} - -int asl_log_descriptor(aslclient asl, aslmsg msg, int level, int descriptor, uint32_t fd_type) -{ - return 1; // TODO -} - diff --git a/src/libSystem/asl/asl.h b/src/libSystem/asl/asl.h deleted file mode 100644 index 33766ae0f..000000000 --- a/src/libSystem/asl/asl.h +++ /dev/null @@ -1,144 +0,0 @@ -#ifndef _ASL_H -#define _ASL_H - -#include -#include - -#define ASL_LEVEL_EMERG 0 -#define ASL_LEVEL_ALERT 1 -#define ASL_LEVEL_CRIT 2 -#define ASL_LEVEL_ERR 3 -#define ASL_LEVEL_WARNING 4 -#define ASL_LEVEL_NOTICE 5 -#define ASL_LEVEL_INFO 6 -#define ASL_LEVEL_DEBUG 7 - -#define ASL_STRING_EMERG "Emergency" -#define ASL_STRING_ALERT "Alert" -#define ASL_STRING_CRIT "Critical" -#define ASL_STRING_ERR "Error" -#define ASL_STRING_WARNING "Warning" -#define ASL_STRING_NOTICE "Notice" -#define ASL_STRING_INFO "Info" -#define ASL_STRING_DEBUG "Debug" - -#define ASL_QUERY_OP_CASEFOLD 0x0010 -#define ASL_QUERY_OP_PREFIX 0x0020 -#define ASL_QUERY_OP_SUFFIX 0x0040 -#define ASL_QUERY_OP_SUBSTRING 0x0060 -#define ASL_QUERY_OP_NUMERIC 0x0080 -#define ASL_QUERY_OP_REGEX 0x0100 - -#define ASL_QUERY_OP_EQUAL 0x0001 -#define ASL_QUERY_OP_GREATER 0x0002 -#define ASL_QUERY_OP_GREATER_EQUAL 0x0003 -#define ASL_QUERY_OP_LESS 0x0004 -#define ASL_QUERY_OP_LESS_EQUAL 0x0005 -#define ASL_QUERY_OP_NOT_EQUAL 0x0006 -#define ASL_QUERY_OP_TRUE 0x0007 - -#define ASL_KEY_TIME "Time" -#define ASL_KEY_TIME_NSEC "TimeNanoSec" -#define ASL_KEY_HOST "Host" -#define ASL_KEY_SENDER "Sender" -#define ASL_KEY_FACILITY "Facility" -#define ASL_KEY_PID "PID" -#define ASL_KEY_UID "UID" -#define ASL_KEY_GID "GID" -#define ASL_KEY_LEVEL "Level" -#define ASL_KEY_MSG "Message" -#define ASL_KEY_READ_UID "ReadUID" -#define ASL_KEY_READ_GID "ReadGID" -#define ASL_KEY_EXPIRE_TIME "ASLExpireTime" -#define ASL_KEY_MSG_ID "ASLMessageID" -#define ASL_KEY_SESSION "Session" -#define ASL_KEY_REF_PID "RefPID" -#define ASL_KEY_REF_PROC "RefProc" -#define ASL_KEY_AUX_TITLE "ASLAuxTitle" -#define ASL_KEY_AUX_UTI "ASLAuxUTI" -#define ASL_KEY_AUX_URL "ASLAuxURL" -#define ASL_KEY_AUX_DATA "ASLAuxData" -#define ASL_KEY_OPTION "ASLOption" -#define ASL_KEY_SENDER_INSTANCE "SenderInstance" - -#define ASL_TYPE_MSG 0 -#define ASL_TYPE_QUERY 1 - -#define ASL_FILTER_MASK_EMERG 0x01 -#define ASL_FILTER_MASK_ALERT 0x02 -#define ASL_FILTER_MASK_CRIT 0x04 -#define ASL_FILTER_MASK_ERR 0x08 -#define ASL_FILTER_MASK_WARNING 0x10 -#define ASL_FILTER_MASK_NOTICE 0x20 -#define ASL_FILTER_MASK_INFO 0x40 -#define ASL_FILTER_MASK_DEBUG 0x80 - -#define ASL_OPT_STDERR 0x00000001 -#define ASL_OPT_NO_DELAY 0x00000002 -#define ASL_OPT_NO_REMOTE 0x00000004 - -#define ASL_LOG_DESCRIPTOR_READ 1 -#define ASL_LOG_DESCRIPTOR_WRITE 2 - -extern "C" { - -class ASLClient; -class ASLMsg; -class ASLResponse; - -typedef ASLClient* aslclient; -typedef ASLMsg* aslmsg; -typedef ASLResponse* aslresponse; - -int _asl_lib_log(aslclient asl, uint32_t eval, aslmsg msg, const char *format, ...); -uint32_t _asl_evaluate_send(aslclient asl, aslmsg msg, int level); - -aslclient asl_open(const char* ident, const char* facility, uint32_t opts); - -void asl_close(aslclient asl); - -int asl_add_log_file(aslclient asl, int descriptor); - -int asl_remove_log_file(aslclient asl, int descriptor); - -int asl_set_filter(aslclient asl, int f); - -const char* asl_key(aslmsg msg, uint32_t n); - -aslmsg asl_new(uint32_t type); - -int asl_set(aslmsg msg, const char* key, const char* value); - -int asl_unset(aslmsg msg, const char* key); - -const char* asl_get(aslmsg msg, const char* key); - -int asl_log(aslclient asl, aslmsg msg, int level, const char* format, ...); - -int asl_vlog(aslclient asl, aslmsg msg, int level, const char* format, va_list ap); - -int asl_send(aslclient asl, aslmsg msg); - -void asl_free(aslmsg msg); - -int asl_set_query(aslmsg msg, const char* key, const char* value, uint32_t op); - -aslresponse asl_search(aslclient asl, aslmsg msg); - -aslmsg aslresponse_next(aslresponse r); - -void aslresponse_free(aslresponse r); - -int asl_create_auxiliary_file(aslmsg msg, const char* title, const char* uti, int* out_descriptor); - -int asl_close_auxiliary_file(int descriptor); - -int asl_log_auxiliary_location(aslmsg msg, const char* title, const char* uti, const char* url); - -aslclient asl_open_from_file(int descriptor, const char* ident, const char* facility); - -int asl_log_descriptor(aslclient asl, aslmsg msg, int level, int descriptor, uint32_t fd_type); - -} - -#endif diff --git a/src/libSystem/common/auto.cpp b/src/libSystem/common/auto.cpp deleted file mode 100644 index 71baf9a55..000000000 --- a/src/libSystem/common/auto.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "auto.h" - -int Darling::flagsDarwinToNative(const MappedFlag* flags, size_t count, int darwin) -{ - int out = 0; - for (size_t i = 0; i < count; i++) - { - if (darwin & flags[i].darwin) - out |= flags[i].native; - } - return out; -} - -int Darling::flagsNativeToDarwin(const MappedFlag* flags, size_t count, int native) -{ - int out = 0; - for (size_t i = 0; i < count; i++) - { - if (native & flags[i].native) - out |= flags[i].darwin; - } - return out; -} - diff --git a/src/libSystem/common/auto.h b/src/libSystem/common/auto.h deleted file mode 100644 index a0f898f2c..000000000 --- a/src/libSystem/common/auto.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef COMMON_AUTO_H -#define COMMON_AUTO_H -#include "path.h" -#include "../libc/errno.h" - -inline bool retvalOK(void* p) { return p != 0; } -inline bool retvalOK(int p) { return p != -1; } - -#define MAP_FUNCTION1(rv,name,a1type) extern "C" rv __darwin_##name (a1type a1) { rv v = name(a1); if (!retvalOK(v)) errnoOut(); return v; } -#define MAP_FUNCTION2(rv,name,a1type,a2type) extern "C" rv __darwin_##name (a1type a1,a2type a2) { rv v = name(a1,a2); if (!retvalOK(v)) errnoOut(); return v; } -#define MAP_FUNCTION3(rv,name,a1type,a2type,a3type) extern "C" rv __darwin_##name (a1type a1,a2type a2,a3type a3) { rv v = name(a1,a2,a3); if (!retvalOK(v)) errnoOut(); return v; } -#define MAP_FUNCTION4(rv,name,a1type,a2type,a3type,a4type) extern "C" rv __darwin_##name (a1type a1,a2type a2,a3type a3,a4type a4) { rv v = name(a1,a2,a3,a4); if (!retvalOK(v)) errnoOut(); return v; } - -template RetVal AutoPathErrno(Func f, const char* pathname, Params... params) -{ - RetVal rv = f(translatePathCI(pathname), params...); - if (!retvalOK(rv)) - errnoOut(); - return rv; -} - -template RetVal AutoPathErrno(Func f, char* pathname, Params... params) -{ - translatePathCI(pathname); - RetVal rv = f(pathname, params...); - if (!retvalOK(rv)) - errnoOut(); - return rv; -} - -template RetVal AutoErrno(Func f, Params... params) -{ - RetVal rv = f(params...); - if (!retvalOK(rv)) - errnoOut(); - return rv; -} - -template int AutoErrnoPosix(Func f, Params... params) -{ - int rv = f(params...); - if (rv != 0) - rv = errnoLinuxToDarwin(rv); - return rv; -} - -namespace Darling -{ - struct MappedFlag - { - int darwin; - int native; - }; - int flagsDarwinToNative(const MappedFlag* flags, size_t count, int darwin); - int flagsNativeToDarwin(const MappedFlag* flags, size_t count, int native); -} - -#endif diff --git a/src/libSystem/common/path.cpp b/src/libSystem/common/path.cpp deleted file mode 100644 index 333607951..000000000 --- a/src/libSystem/common/path.cpp +++ /dev/null @@ -1,89 +0,0 @@ -#include "path.h" -#include "config.h" -#include -#include -#include -#include -#include "trace.h" -#ifdef TEST_PATH -# include -#endif - -void translatePathCI(char* path) -{ - char* p = path; - char* const end = path + strlen(path); - char buffer[PATH_MAX]; - - if (::access(path, R_OK) == 0) // shortcut - return; - - if (*p == '/') - p++; - - while (p < end) - { - // list the contents of [path,p] - DIR* dir; - struct dirent* ent; - char* nextp = strchr(p, '/'); - // if we're in the middle of a path, prefer dirs or symlinks to dirs - bool preferDirOrSymlink = nextp != 0; - char good[PATH_MAX] = ""; - - memcpy(buffer, path, p-path); - buffer[p-path] = 0; - - dir = ::opendir(buffer); - if (!dir) - return; - - if (!nextp) - nextp = p + strlen(p); - - memcpy(buffer, p, nextp-p); - buffer[nextp-p] = 0; - - while ((ent = ::readdir(dir)) != 0) - { - if (strcasecmp(ent->d_name, buffer)) - continue; - strcpy(good, ent->d_name); - if ((ent->d_type == DT_DIR || ent->d_type == DT_LNK) && preferDirOrSymlink) - break; - } - - ::closedir(dir); - - if (!good[0]) // not found - break; - - memcpy(p, good, nextp-p); - p = nextp + 1; // skip the slash - } -} - -char* translatePathCI(const char* path) -{ - //TRACE1(path); - static char buf[DARWIN_MAXPATHLEN]; - if (path != &buf[0]) - strcpy(buf, path); - translatePathCI(buf); - return buf; - //return strdup(path); -} - -#ifdef TEST_PATH -int main(int argc, char** argv) -{ - if (argc != 2) - return 1; - - char buf[PATH_MAX]; - strcpy(buf, argv[1]); - translatePathCI(buf); - - std::cout << buf << std::endl; -} -#endif diff --git a/src/libSystem/common/path.h b/src/libSystem/common/path.h deleted file mode 100644 index df4957edb..000000000 --- a/src/libSystem/common/path.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef COMMON_PATH_H -#define COMMON_PATH_H - -#define DARWIN_MAXPATHLEN 1024 -#define DARWIN_MAXNAMLEN 255 - -// Will try to correct the case of an existing path or existing path segments -// Rationale: HFS+ used on OS X is a case insensitive file system -void translatePathCI(char* path); - -// This uses a temporary TLS buffer -char* translatePathCI(const char* path); - -#endif diff --git a/src/libSystem/config.h.in b/src/libSystem/config.h.in deleted file mode 100644 index 07fbcb81a..000000000 --- a/src/libSystem/config.h.in +++ /dev/null @@ -1,24 +0,0 @@ - - -/* - * Credit: - * - * David Chisnall - * http://comments.gmane.org/gmane.comp.desktop.etoile.devel/1556 - * - * */ - -#ifdef __block -# undef __block -# include -# define __block __attribute__((__blocks__(byref))) -#else -# include -#endif - -#include - -#define __uint64_t uint64_t -#define __darwin_natural_t long - -#cmakedefine HAS_BSD_WCHAR_H diff --git a/src/libSystem/kernel-bsd/fcntl.cpp b/src/libSystem/kernel-bsd/fcntl.cpp deleted file mode 100644 index 75808c634..000000000 --- a/src/libSystem/kernel-bsd/fcntl.cpp +++ /dev/null @@ -1,267 +0,0 @@ -#include "config.h" -#include "fcntl.h" -#include -#include -#include -#include -#include -#include "../libc/darwin_errno_codes.h" -#include "../common/auto.h" -#include "../common/path.h" -#include "io.h" -#include "../libc/errno.h" - -#define REQUIRE_ARG_PTR(arg) { if (!arg) { errno = DARWIN_EINVAL; return -1; } } - -int __darwin_fcntl(int fd, int cmd, void* arg) -{ - switch (cmd) - { - case DARWIN_F_DUPFD: - cmd = F_DUPFD; - break; - case DARWIN_F_DUPFD_CLOEXEC: - cmd = F_DUPFD_CLOEXEC; - break; - case DARWIN_F_GETFD: // CLOEXEC is compatible - cmd = F_GETFD; - break; - case DARWIN_F_SETFD: - cmd = F_SETFD; - break; - case DARWIN_F_GETFL: - { - int value = fcntl(fd, F_GETFL); - if (value == -1) - { - errnoOut(); - return -1; - } - else - { - int d = Darling::openflagsNativeToDarwin(value); - if (value & O_NONBLOCK) - d |= DARWIN_O_NONBLOCK; - return d; - } - break; - } - case DARWIN_F_SETFL: - { - int orig = (int)(uintptr_t) arg; - int value; - value = Darling::openflagsDarwinToNative(value); - - if (orig & DARWIN_O_NONBLOCK) - value |= O_NONBLOCK; - - cmd = F_SETFL; - arg = (void*)(uintptr_t(value) & 0xffffffff); - break; - } - case DARWIN_F_GETOWN: - cmd = F_GETOWN; - break; - case DARWIN_F_SETOWN: - cmd = F_SETOWN; - break; - case DARWIN_F_GETPATH: - { - REQUIRE_ARG_PTR(arg); - - char procpath[255]; - int rv; - - sprintf(procpath, "/proc/%d/fd/%d", getpid(), fd); - rv = readlink(procpath, (char*) arg, DARWIN_MAXPATHLEN); - - if (rv == -1) - { - errnoOut(); - return -1; - } - ((char*) arg)[rv] = 0; - return 0; - } - case DARWIN_F_PREALLOCATE: - { - REQUIRE_ARG_PTR(arg); - - __darwin_fallocate* fa = static_cast<__darwin_fallocate*>(arg); - fa->allocated = 0; - - // We disregard fa->flags, it's not supported on Linux - - if (fa->mode == DARWIN_F_PEOFPOSMODE) // like SEEK_END - { - struct stat st; - if (fstat(fd, &st) == -1) - { - errnoOut(); - return -1; - } - fa->offset += st.st_size; - } - else if (fa->mode == DARWIN_F_VOLPOSMODE) // like SEEK_CUR - { - fa->offset += lseek(fd, 0, SEEK_CUR); - } - else - { - errno = DARWIN_EINVAL; - return -1; - } - - int err = posix_fallocate(fd, fa->offset, fa->length); - if (err) // doesn't use errno! - { - errno = errnoLinuxToDarwin(err); - return -1; - } - else - { - fa->allocated = fa->length; - return 0; - } - } - case DARWIN_F_SETSIZE: - { - uint64_t size = uint64_t(arg); - - // Not identical to what F_SETSIZE is supposed to do - // but it's the best we can do. - if (ftruncate(fd, size) == -1) - { - errnoOut(); - return -1; - } - return 0; - } - case DARWIN_F_RDADVISE: - { - REQUIRE_ARG_PTR(arg); - - const __darwin_rdadvise* adv = static_cast<__darwin_rdadvise*>(arg); - int err = posix_fadvise(fd, adv->offset, adv->count, POSIX_FADV_WILLNEED); - - if (err) // doesn't use errno! - { - errno = errnoLinuxToDarwin(err); - return -1; - } - else - return 0; - } - case DARWIN_F_RDAHEAD: - { - REQUIRE_ARG_PTR(arg); - - int advice = (arg) ? POSIX_FADV_NORMAL : POSIX_FADV_RANDOM; - int err = posix_fadvise(fd, 0, 1, advice); // on Linux, the offset and length doesn't matter for these advices - - if (err) // doesn't use errno! - { - errno = errnoLinuxToDarwin(err); - return -1; - } - else - return 0; - } - case DARWIN_F_NOCACHE: - { - struct stat st; - if (fstat(fd, &st) == -1) - { - errnoOut(); - return -1; - } - - // This is as close as we can get... - - int advice = (arg) ? POSIX_FADV_NORMAL : POSIX_FADV_DONTNEED; - int err = posix_fadvise(fd, 0, 1, advice); - - if (err) // doesn't use errno! - { - errno = errnoLinuxToDarwin(err); - return -1; - } - else - return 0; - } - case DARWIN_F_FULLFSYNC: - { - if (fsync(fd) == -1) - { - errnoOut(); - return -1; - } - - // This is as close as we can get... - // Linux 2.6.39+ - if (syncfs(fd) == -1) - { - errnoOut(); - return -1; - } - return 0; - } - case DARWIN_F_GETLK: - { - REQUIRE_ARG_PTR(arg); - - __darwin_flock* lock = static_cast<__darwin_flock*>(arg); - struct flock native; - - memset(lock, 0, sizeof(*lock)); - - if (fcntl(fd, F_GETLK, &native) == -1) - { - errnoOut(); - return -1; - } - - lock->l_start = native.l_start; - lock->l_len = native.l_len; - lock->l_pid = native.l_pid; - lock->l_type = native.l_type; - lock->l_whence = native.l_whence; - - return 0; - } - case DARWIN_F_SETLK: - case DARWIN_F_SETLKW: - { - REQUIRE_ARG_PTR(arg); - - int ncmd = (cmd == DARWIN_F_SETLK) ? F_SETLK : F_SETLKW; - const __darwin_flock* lock = static_cast<__darwin_flock*>(arg); - struct flock native; - - native.l_start = lock->l_start; - native.l_len = lock->l_len; - native.l_pid = lock->l_pid; - native.l_type = lock->l_type; - native.l_whence = lock->l_whence; - - return AutoErrno(fcntl, fd, ncmd, &native); - } - case DARWIN_F_SETNOSIGPIPE: - case DARWIN_F_GETNOSIGPIPE: - case DARWIN_F_READBOOTSTRAP: - case DARWIN_F_WRITEBOOTSTRAP: - case DARWIN_F_LOG2PHYS: - case DARWIN_F_LOG2PHYS_EXT: - { - errno = DARWIN_ENOSYS; - return -1; - } - - default: - errno = DARWIN_EINVAL; - return -1; - } - - return AutoErrno(fcntl, fd, cmd, arg); -} - diff --git a/src/libSystem/kernel-bsd/fcntl.h b/src/libSystem/kernel-bsd/fcntl.h deleted file mode 100644 index 9074a3dda..000000000 --- a/src/libSystem/kernel-bsd/fcntl.h +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef BSD_FCNTL_H -#define BSD_FCNTL_H -#include -#include - -#define DARWIN_F_DUPFD 0 -#define DARWIN_F_DUPFD_CLOEXEC 67 -#define DARWIN_F_GETFD 1 -#define DARWIN_F_SETFD 2 -#define DARWIN_F_GETFL 3 -#define DARWIN_F_SETFL 4 -#define DARWIN_F_GETOWN 5 -#define DARWIN_F_SETOWN 6 -#define DARWIN_F_GETLK 7 -#define DARWIN_F_SETLK 8 -#define DARWIN_F_SETLKW 9 -#define DARWIN_F_GETPATH 50 -#define DARWIN_F_PREALLOCATE 42 -#define DARWIN_F_SETSIZE 43 -#define DARWIN_F_RDADVISE 44 -#define DARWIN_F_RDAHEAD 45 -#define DARWIN_F_READBOOTSTRAP 46 -#define DARWIN_F_WRITEBOOTSTRAP 47 -#define DARWIN_F_NOCACHE 48 -#define DARWIN_F_LOG2PHYS 49 -#define DARWIN_F_LOG2PHYS_EXT 65 -#define DARWIN_F_FULLFSYNC 51 -#define DARWIN_F_SETNOSIGPIPE 73 -#define DARWIN_F_GETNOSIGPIPE 74 - -#define DARWIN_FD_CLOEXEC 1 -#define DARWIN_F_RDLCK 1 -#define DARWIN_F_UNLCK 2 -#define DARWIN_F_WRLCK 3 - -#define DARWIN_F_PEOFPOSMODE 3 -#define DARWIN_F_VOLPOSMODE 4 - -#define DARWIN_O_NONBLOCK 4 - -struct __darwin_flock -{ - int64_t l_start; - int64_t l_len; - pid_t l_pid; - short l_type; - short l_whence; -}; - -struct __darwin_fallocate -{ - uint32_t flags; - int mode; - uint64_t offset, length; - uint64_t allocated; -}; - -struct __darwin_rdadvise -{ - uint64_t offset; - int count; -}; - -#ifdef __cplusplus -static_assert(sizeof(__darwin_flock) == 24, "Invalid __darwin_flock size"); -extern "C" { -#endif - -int __darwin_fcntl(int fd, int cmd, void* arg); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/src/libSystem/kernel-bsd/fopsmisc.cpp b/src/libSystem/kernel-bsd/fopsmisc.cpp deleted file mode 100644 index 34c974dd9..000000000 --- a/src/libSystem/kernel-bsd/fopsmisc.cpp +++ /dev/null @@ -1,136 +0,0 @@ -#include "config.h" -#include "fopsmisc.h" -#include "libc/errno.h" -#include "common/path.h" -#include "common/auto.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -int __darwin_access(const char *pathname, int mode) -{ - //std::cout << "access: " << pathname << std::endl; - if ((mode & W_OK) == 0 && Darling::MachOMgr::instance()->hasSysRoot()) - { - // Try to apply a sysroot prefix - const char* prefixed; - std::string lpath = Darling::MachOMgr::instance()->sysRoot(); - - lpath += '/'; - lpath += pathname; - - prefixed = translatePathCI(lpath.c_str()); - if (::access(prefixed, F_OK) == 0) - { - int rv = ::access(prefixed, mode); - if (rv == -1) - errnoOut(); - return rv; - } - } - - return AutoPathErrno(access, pathname, mode); -} - -int __darwin_chown(const char *path, uid_t owner, gid_t group) -{ - return AutoPathErrno(chown, path, owner, group); -} - -MAP_FUNCTION3(int,fchown,int,uid_t,gid_t); -MAP_FUNCTION2(int,fchmod,int,mode_t); -MAP_FUNCTION1(int,fchdir,int); - -int __darwin_lchown(const char *path, uid_t owner, gid_t group) -{ - return AutoPathErrno(lchown, path, owner, group); -} - -int __darwin_chmod(const char *path, mode_t mode) -{ - return AutoPathErrno(chmod, path, mode); -} - -ssize_t __darwin_readlink(const char *path, char *buf, size_t bufsiz) -{ - return AutoPathErrno(readlink, path, buf, bufsiz); -} - -template int TwoPathOp(Func f, const char* oldpath, const char* newpath) -{ - char op[DARWIN_MAXPATHLEN]; - char np[DARWIN_MAXPATHLEN]; - - strcpy(op, oldpath); - strcpy(np, newpath); - - translatePathCI(op); - translatePathCI(np); - - int rv = f(op, np); - if (rv == -1) - errnoOut(); - - return rv; -} - -int __darwin_symlink(const char *oldpath, const char *newpath) -{ - return TwoPathOp(symlink, oldpath, newpath); -} - -int __darwin_link(const char *oldpath, const char *newpath) -{ - return TwoPathOp(link, oldpath, newpath); -} - -int __darwin_unlink(const char *pathname) -{ - return AutoPathErrno(unlink, pathname); -} - -int __darwin_rmdir(const char *pathname) -{ - return AutoPathErrno(rmdir, pathname); -} - -int __darwin_mknod(const char *pathname, mode_t mode, dev_t dev) -{ - // TODO: check dev_t compatibility - return AutoPathErrno(mknod, pathname, mode, dev); -} - -int __darwin_mkdir(const char *pathname, mode_t mode) -{ - return AutoPathErrno(mkdir, pathname, mode); -} - -int __darwin_chdir(const char *path) -{ - if (Darling::MachOMgr::instance()->hasSysRoot()) - { - // Try to apply a sysroot prefix - const char* prefixed; - std::string lpath = Darling::MachOMgr::instance()->sysRoot(); - - lpath += '/'; - lpath += path; - - prefixed = translatePathCI(lpath.c_str()); - if (::chdir(prefixed) == 0) - return 0; - } - - return AutoPathErrno(chdir, path); -} - -int __darwin_acct(const char *filename) -{ - return AutoPathErrno(acct, filename); -} diff --git a/src/libSystem/kernel-bsd/fopsmisc.h b/src/libSystem/kernel-bsd/fopsmisc.h deleted file mode 100644 index e6b0df080..000000000 --- a/src/libSystem/kernel-bsd/fopsmisc.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef FOPSMISC_H -#define FOPSMISC_H -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -int __darwin_access(const char *pathname, int mode); -int __darwin_chown(const char *path, uid_t owner, gid_t group); -// int fchown(int fd, uid_t owner, gid_t group); -int __darwin_lchown(const char *path, uid_t owner, gid_t group); -int __darwin_chmod(const char *path, mode_t mode); -// int __darwin_fchmod(int fd, mode_t mode); - -ssize_t __darwin_readlink(const char *path, char *buf, size_t bufsiz); -int __darwin_symlink(const char *oldpath, const char *newpath); -int __darwin_link(const char *oldpath, const char *newpath); - -int __darwin_unlink(const char *pathname); -int __darwin_rmdir(const char *pathname); -int __darwin_mknod(const char *pathname, mode_t mode, dev_t dev); -int __darwin_mkdir(const char *pathname, mode_t mode); - - -int __darwin_chdir(const char *path); -int __darwin_acct(const char *filename); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/src/libSystem/kernel-bsd/fs.cpp b/src/libSystem/kernel-bsd/fs.cpp deleted file mode 100644 index 7d2f0de1b..000000000 --- a/src/libSystem/kernel-bsd/fs.cpp +++ /dev/null @@ -1,213 +0,0 @@ -#include "config.h" -#include "fs.h" -#include -#include "common/path.h" -#include "common/auto.h" -#include "libc/errno.h" -#include "libc/darwin_errno_codes.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "log.h" - -template void StatfsLinuxToDarwinGen(const char* path, const struct statvfs* in, Out* out) -{ - out->f_bsize = in->f_bsize; - out->f_blocks = out->f_iosize = in->f_blocks; - out->f_bfree = in->f_bfree; - out->f_bavail = in->f_bavail; - out->f_files = in->f_files; - out->f_ffree = in->f_ffree; - out->f_fsid.val[0] = in->f_fsid; - - if (in->f_flag & ST_RDONLY) - out->f_flags |= DARWIN_MNT_RDONLY; - if (in->f_flag & ST_NOSUID) - out->f_flags |= DARWIN_MNT_NOSUID; - - struct mntent* ent = findMountForPath(path); - if (ent) - { - strncpy(out->f_mntfromname, ent->mnt_fsname, sizeof(out->f_mntfromname)-1); // we assume zeroed out, no need to set the last char to NUL - strncpy(out->f_mntonname, ent->mnt_dir, sizeof(out->f_mntonname)-1); - strncpy(out->f_fstypename, ent->mnt_fsname, sizeof(out->f_fstypename)-1); - } -} - -template int __darwin_statfsGen(const char* path, T* buf) -{ - struct statvfs st; - int rv; - - ::memset(buf, 0, sizeof(*buf)); - - rv = statvfs(path, &st); - if (rv == -1) - errnoOut(); - else - StatfsLinuxToDarwinGen(path, &st, buf); - - return rv; -} - -int __darwin_statfs(const char* path, struct __darwin_statfs* buf) -{ - return __darwin_statfsGen(translatePathCI(path), buf); -} - -int __darwin_statfs64(const char* path, struct __darwin_statfs64* buf) -{ - return __darwin_statfsGen(translatePathCI(path), buf); -} - -template int __darwin_fstatfsGen(int fd, T* out) -{ - char buf[PATH_MAX], buf2[PATH_MAX]; - sprintf(buf, "/proc/%d/fd/%d", getpid(), fd); - - memset(out, 0, sizeof(*out)); - - if (::readlink(buf, buf2, sizeof buf2) == -1) - { - errnoOut(); - return -1; - } - - return __darwin_statfsGen(buf2, out); -} - -int __darwin_fstatfs(int fd, struct __darwin_statfs* buf) -{ - return __darwin_fstatfsGen(fd, buf); -} - -int __darwin_fstatfs64(int fd, struct __darwin_statfs64* buf) -{ - return __darwin_fstatfsGen(fd, buf); -} - -template int __darwin_getfsstatGen(Stat* buf, int bufsize, int flags) -{ - FILE* f = setmntent("/proc/mounts", "r"); - struct mntent *ent; - - if (!f) - { - LOG << "Cannot access /proc/mounts!\n"; - errno = DARWIN_ENOENT; - return -1; - } - - int count = 0; - while ( (ent = getmntent(f)) != 0 && ((count+1)*sizeof(*buf) < bufsize || !buf) ) - { - if (buf) - { - int rv = __darwin_statfsGen(ent->mnt_dir, buf+count); - if (rv == -1) - break; - } - count++; - } - - endmntent(f); - return count; -} - -int __darwin_getfsstat(struct __darwin_statfs* buf, int bufsize, int flags) -{ - return __darwin_getfsstatGen(buf, bufsize, flags); -} - -int __darwin_getfsstat64(struct __darwin_statfs64* buf, int bufsize, int flags) -{ - return __darwin_getfsstatGen(buf, bufsize, flags); -} - -void StatfsLinuxToDarwin(const char* path, const struct statvfs* in, struct __darwin_statfs* out) -{ - StatfsLinuxToDarwinGen(path, in, out); -} - -void StatfsLinuxToDarwin(const char* path, const struct statvfs* in, struct __darwin_statfs64* out) -{ - StatfsLinuxToDarwinGen(path, in, out); -} - -struct mntent* findMountForPath(const char* path) -{ - FILE* f = setmntent("/proc/mounts", "r"); - struct mntent *ent, *rv = 0; - - if (!f) - { - LOG << "Cannot access /proc/mounts!\n"; - return 0; - } - - while ((ent = getmntent(f))) - { - if (strncmp(ent->mnt_dir, path, strlen(ent->mnt_dir)) == 0) - { - rv = ent; - break; - } - } - - endmntent(f); - return rv; -} - -#define EXT2_IMMUTABLE_FL 0x00000010 -#define EXT2_APPEND_FL 0x00000020 -#define EXT2_NODUMP_FL 0x00000040 - -#define UF_NODUMP 0x00000001 -#define UF_IMMUTABLE 0x00000002 -#define UF_APPEND 0x00000004 - -static const Darling::MappedFlag g_fflags[] = { - { UF_NODUMP, EXT2_NODUMP_FL}, { UF_IMMUTABLE, EXT2_IMMUTABLE_FL }, { UF_APPEND, EXT2_APPEND_FL}, -}; - -int chflags(const char *path, unsigned int flags) -{ - int rv; - int fd = ::open(path, O_RDWR); - if (fd == -1) - { - errnoOut(); - return -1; - } - - rv = fchflags(fd, flags); - ::close(fd); - - return rv; -} - -int fchflags(int fd, unsigned int flags) -{ - int rv; - - flags = Darling::flagsDarwinToNative(g_fflags, sizeof(g_fflags)/sizeof(g_fflags[0]), flags); - rv = ioctl(fd, FS_IOC_SETFLAGS, &flags); - - if (rv) - errnoOut(); - - return rv; -} - -int lchflags(const char *path, unsigned int flags) -{ - return DARWIN_ENOSYS; // not possible on Linux -} - - diff --git a/src/libSystem/kernel-bsd/fs.h b/src/libSystem/kernel-bsd/fs.h deleted file mode 100644 index 3f2629a07..000000000 --- a/src/libSystem/kernel-bsd/fs.h +++ /dev/null @@ -1,93 +0,0 @@ -#ifndef BSD_FS_H -#define BSD_FS_H -#include -#include "common/path.h" - -#define MFSNAMELEN 15 -#define MFSTYPENAMELEN 16 -#define MNAMELEN 90 - -#define DARWIN_MNT_RDONLY 0x1 -#define DARWIN_MNT_SYNCHRONOUS 0x2 -#define DARWIN_MNT_NOEXEC 0x4 -#define DARWIN_MNT_NOSUID 0x8 -#define DARWIN_MNT_NODEV 0x10 -#define DARWIN_MNT_UNION 0x20 -#define DARWIN_MNT_ASYNC 0x40 -#define DARWIN_MNT_CPROTECT 0x80 - - -typedef struct { int32_t val[2]; } darwin_fsid_t; - -struct __darwin_statfs64 -{ - uint32_t f_bsize; - int32_t f_iosize; - uint64_t f_blocks; - uint64_t f_bfree; - uint64_t f_bavail; - uint64_t f_files; - uint64_t f_ffree; - darwin_fsid_t f_fsid; - uint32_t f_owner; - uint32_t f_type; - uint32_t f_flags; - uint32_t f_fssubtype; - char f_fstypename[MFSTYPENAMELEN]; - char f_mntonname[DARWIN_MAXPATHLEN]; - char f_mntfromname[DARWIN_MAXPATHLEN]; - uint32_t f_reserved[8]; -}; - -struct __darwin_statfs -{ - short f_otype; - short f_oflags; - long f_bsize; - long f_iosize; - long f_blocks; - long f_bfree; - long f_bavail; - long f_files; - long f_ffree; - darwin_fsid_t f_fsid; - uint32_t f_owner; - short f_reserved1; - short f_type; - long f_flags; - long f_reserved2[2]; - char f_fstypename[MFSNAMELEN]; - char f_mntonname[MNAMELEN]; - char f_mntfromname[MNAMELEN]; - char f_reserved3; - long f_reserved4[4]; -}; - -#ifdef __cplusplus -extern "C" -{ -#endif - -int __darwin_statfs(const char* path, struct __darwin_statfs* buf); -int __darwin_statfs64(const char* path, struct __darwin_statfs64* buf) asm("__darwin_statfs$INODE64"); -int __darwin_fstatfs(int fd, struct __darwin_statfs* buf); -int __darwin_fstatfs64(int fd, struct __darwin_statfs64* buf) asm("__darwin_fstatfs$INODE64"); -int __darwin_getfsstat(struct __darwin_statfs* buf, int bufsize, int flags); -int __darwin_getfsstat64(struct __darwin_statfs64* buf, int bufsize, int flags) asm("__darwin_getfsstat$INODE64"); - -int chflags(const char *path, unsigned int flags); -int fchflags(int fd, unsigned int flags); -int lchflags(const char *path, unsigned int flags); - -#ifdef __cplusplus -} - -// out assumed to have been zeroed out -void StatfsLinuxToDarwin(const char* path, const struct statvfs* in, struct __darwin_statfs* out); -void StatfsLinuxToDarwin(const char* path, const struct statvfs* in, struct __darwin_statfs64* out); - -struct mntent; -struct mntent* findMountForPath(const char* path); -#endif - -#endif diff --git a/src/libSystem/kernel-bsd/io.cpp b/src/libSystem/kernel-bsd/io.cpp deleted file mode 100644 index 0bee69afb..000000000 --- a/src/libSystem/kernel-bsd/io.cpp +++ /dev/null @@ -1,107 +0,0 @@ -#include "config.h" -#include "io.h" -#include "log.h" -#include "trace.h" -#include "libc/errno.h" -#include "libc/darwin_errno_codes.h" -#include "common/path.h" -#include "common/auto.h" -#include -#include -#include - -static const Darling::MappedFlag g_openflags[] = { - { DARWIN_O_ASYNC, O_ASYNC}, { DARWIN_O_SYNC, O_SYNC }, { DARWIN_O_NOFOLLOW, O_NOFOLLOW}, - { DARWIN_O_CREAT, O_CREAT }, { DARWIN_O_TRUNC, O_TRUNC }, { DARWIN_O_EXCL, O_EXCL }, - { DARWIN_O_NOCTTY, O_NOCTTY }, { DARWIN_O_DIRECTORY, O_DIRECTORY }, { DARWIN_O_DSYNC, O_DSYNC }, -}; - -int Darling::openflagsDarwinToNative(int flags) -{ - return Darling::flagsDarwinToNative(g_openflags, sizeof(g_openflags)/sizeof(g_openflags[0]), flags); -} - -int Darling::openflagsNativeToDarwin(int flags) -{ - return Darling::flagsNativeToDarwin(g_openflags, sizeof(g_openflags)/sizeof(g_openflags[0]), flags); -} - -int __darwin_open(const char* path, int flags, mode_t mode) -{ - TRACE3(path,flags,mode); - - int linux_flags = 0; - linux_flags |= flags & O_ACCMODE; - - if (flags & ( DARWIN_O_EVTONLY|DARWIN_O_SYMLINK|DARWIN_O_POPUP|DARWIN_O_ALERT)) - { - LOG << "Unsupported open flags: " << flags << std::endl; - errno = DARWIN_EINVAL; - return -1; - } - linux_flags |= Darling::flagsDarwinToNative(g_openflags, sizeof(g_openflags)/sizeof(g_openflags[0]), flags); - - if (flags & DARWIN_O_SHLOCK) - { - errno = DARWIN_EINVAL; - fprintf(stderr, "Unsupported open flag=%d\n", flags); - return -1; - } - - if (flags & DARWIN_O_EXLOCK) - { - fprintf(stderr, "Unsupported open flag=%d\n", flags); - errno = DARWIN_EINVAL; - return -1; - } - - // Apply sysroot - //std::cout << "File: " << path << std::endl; - //std::cout << "Sysroot: " << g_sysroot << std::endl; - // std::cout << "Flag: " << (linux_flags & O_RDONLY) << std::endl; - if ( (linux_flags & O_ACCMODE) == 0 && Darling::MachOMgr::instance()->hasSysRoot()) - { - const char* prefixed; - std::string lpath = Darling::MachOMgr::instance()->sysRoot(); - - lpath += '/'; - lpath += path; - - prefixed = translatePathCI(lpath.c_str()); - - if (::access(prefixed, F_OK) == 0) - path = prefixed; - else - path = translatePathCI(path); - } - else - path = translatePathCI(path); - - int rv = open(path, linux_flags, mode); - if (rv == -1) - errnoOut(); - return rv; -} - -int __darwin_creat(const char *pathname, mode_t mode) -{ - return AutoPathErrno(creat, pathname, mode); -} - -MAP_FUNCTION1(int,close,int); -MAP_FUNCTION1(int,fsync,int); -MAP_FUNCTION1(int,fdatasync,int); -MAP_FUNCTION3(ssize_t,read,int,void*,size_t); -MAP_FUNCTION3(ssize_t,write,int,const void*,size_t); - -off64_t __darwin_lseek(int fd, off64_t offset, int whence) -{ - off64_t rv = lseek64(fd, offset, whence); - if (rv == -1) - errnoOut(); - return rv; -} - -MAP_FUNCTION1(int,dup,int); -MAP_FUNCTION2(int,dup2,int,int); - diff --git a/src/libSystem/kernel-bsd/io.h b/src/libSystem/kernel-bsd/io.h deleted file mode 100644 index c9c3bf702..000000000 --- a/src/libSystem/kernel-bsd/io.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef BSD_IO_H -#define BSD_IO_H -#include -#include -#include - -#define DARWIN_O_EXLOCK 0x20 -#define DARWIN_O_SHLOCK 0x10 -#define DARWIN_O_ASYNC 0x40 -#define DARWIN_O_SYNC 0x80 -#define DARWIN_O_NOFOLLOW 0x100 -#define DARWIN_O_CREAT 0x200 -#define DARWIN_O_TRUNC 0x400 -#define DARWIN_O_EXCL 0x800 -#define DARWIN_O_EVTONLY 0x8000 -#define DARWIN_O_NOCTTY 0x20000 -#define DARWIN_O_DIRECTORY 0x100000 -#define DARWIN_O_SYMLINK 0x200000 -#define DARWIN_O_DSYNC 0x400000 -#define DARWIN_O_POPUP 0x80000000 -#define DARWIN_O_ALERT 0x20000000 - -#ifdef __cplusplus -extern "C" -{ -#endif - -int __darwin_open(const char* path, int flags, mode_t mode); -int __darwin_creat(const char *pathname, mode_t mode); -int __darwin_close(int fd); -int __darwin_fsync(int fd); -int __darwin_fdatasync(int fd); - -#ifdef __cplusplus -} - -namespace Darling -{ - int openflagsDarwinToNative(int flags); - int openflagsNativeToDarwin(int flags); -} -#endif - -#endif diff --git a/src/libSystem/kernel-bsd/mman.cpp b/src/libSystem/kernel-bsd/mman.cpp deleted file mode 100644 index bc506278f..000000000 --- a/src/libSystem/kernel-bsd/mman.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "mman.h" -#include -#include -#include "../common/auto.h" - -const static Darling::MappedFlag mmapFlags[] = { - { DARWIN_MAP_ANON, MAP_ANONYMOUS }, - { DARWIN_MAP_FIXED, MAP_FIXED }, - { DARWIN_MAP_PRIVATE, MAP_PRIVATE }, - { DARWIN_MAP_SHARED, MAP_SHARED }, -}; - -void* __darwin_mmap(void *addr, size_t len, int prot, int flags, int fd, uint64_t offset) -{ - int nativeFlags = Darling::flagsDarwinToNative(mmapFlags, sizeof(mmapFlags)/sizeof(mmapFlags[0]), flags); - void* rv = ::mmap(addr, len, prot, nativeFlags, fd, offset); - - if (rv == MAP_FAILED) - errnoOut(); - return rv; -} - -MAP_FUNCTION2(int, munmap, void*, size_t); -MAP_FUNCTION3(int, mprotect, void*, size_t, int); -MAP_FUNCTION3(int, mincore, void*, size_t, unsigned char*); - -int __darwin_minherit(caddr_t addr, size_t len, int inherit) -{ - STUB(); - return 0; -} - -int __darwin_madvise(void *addr, size_t len, int advice) -{ - if (advice == DARWIN_MADV_FREE) - advice = MADV_DONTNEED; - else if (advice == DARWIN_MADV_ZERO_WIRED_PAGES) - return 0; - - return AutoErrno(madvise, addr, len, advice); -} - -MAP_FUNCTION3(int, posix_madvise, void*, size_t, int); - -MAP_FUNCTION2(int, mlock, const void*, size_t); -MAP_FUNCTION2(int, munlock, const void*, size_t); diff --git a/src/libSystem/kernel-bsd/mman.h b/src/libSystem/kernel-bsd/mman.h deleted file mode 100644 index 69a4b242d..000000000 --- a/src/libSystem/kernel-bsd/mman.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef MMAN_H -#define MMAN_H -#include -#include - -extern "C" { - -#define DARWIN_MAP_ANON 0x1000 -#define DARWIN_MAP_FIXED 16 -#define DARWIN_MAP_SHARED 1 -#define DARWIN_MAP_PRIVATE 2 - -#define DARWIN_MADV_FREE 5 -#define DARWIN_MADV_ZERO_WIRED_PAGES 6 - -void* __darwin_mmap(void *addr, size_t len, int prot, int flags, int fd, uint64_t offset); -int __darwin_munmap(void *addr, size_t len); - -int __darwin_mprotect(void *addr, size_t len, int prot); -int __darwin_mincore(void* addr, size_t len, unsigned char *vec); -int __darwin_minherit(void* addr, size_t len, int inherit); - -int __darwin_madvise(void *addr, size_t len, int advice); -int __darwin_posix_madvise(void *addr, size_t len, int advice); - -int __darwin_mlock(const void *addr, size_t len); -int __darwin_munlock(const void *addr, size_t len); - -} - -#endif diff --git a/src/libSystem/kernel-bsd/proc.cpp b/src/libSystem/kernel-bsd/proc.cpp deleted file mode 100644 index 0ed55ec36..000000000 --- a/src/libSystem/kernel-bsd/proc.cpp +++ /dev/null @@ -1,393 +0,0 @@ -/* -This file is part of Darling. - -Copyright (C) 2013 Lubos Dolezel - -Darling is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Darling is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Darling. If not, see . -*/ - -#include "config.h" -#include "proc.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../libc/darwin_errno_codes.h" -#include "../libc/errno.h" - -static std::string getProcStatElement(const char* pid, int elem); -static int sys_syslog(int type, char *bufp, int len); /* No wrapper provided in glibc */ - -int proc_name(int pid, void * buffer, uint32_t buffersize) -{ - std::stringstream path; - std::ifstream procf; - char procname[1024]; - size_t read; - - path << "/proc/" << pid << "/cmdline"; - procf.open(path.str().c_str()); - - if (!procf.is_open()) - { - errno = DARWIN_ENOENT; - return 0; - } - - procf.read(procname, sizeof procname); - read = procf.gcount(); - - for (size_t i = 0; i < read-1; i++) - { - if (!procname[i]) - procname[i] = ' '; - } - - if (buffer) - { - if (buffersize >= read) - { - memcpy(buffer, procname, read); - return read; - } - else - { - *((char*) buffer) = 0; - return 0; - } - } - - return 0; -} - -int proc_pidpath(int pid, void * buffer, uint32_t buffersize) -{ - std::stringstream path; - char exe[1024]; - ssize_t len; - - path << "/proc/" << pid << "/exe"; - - if (access(path.str().c_str(), F_OK) != 0) - { - errno = DARWIN_ENOENT; - return 0; - } - - len = readlink(path.str().c_str(), exe, sizeof(exe)-1); - if (len < 0) - { - errnoOut(); - return 0; - } - exe[len] = 0; - - if (buffer && buffersize >= len+1) - { - memcpy(buffer, exe, len+1); - return len+1; - } - - return 0; -} - -int proc_pidinfo(int pid, int flavor, uint64_t arg, void *buffer, int buffersize) -{ - // TODO - return 0; -} - -int proc_listpids(uint32_t type, uint32_t typeinfo, void *buffer, int buffersize) -{ - // buffer is an array of pid_t - pid_t* pidOut = static_cast(buffer); - DIR* dirProc = opendir("/proc"); - const uid_t uid = getuid(); - int count = 0; - - if (!dirProc) - return 0; - - while (struct dirent* ent = readdir(dirProc)) - { - if (!isdigit(ent->d_name[0])) - continue; - - bool pass; - - if (type == PROC_ALL_PIDS) - pass = true; - else if (type == PROC_UID_ONLY || type == PROC_RUID_ONLY) // not sure what to do with PROC_RUID_ONLY - { - char path[100]; - struct stat st; - - strcpy(path, "/proc/"); - strcat(path, ent->d_name); - strcat(path, "/cmdline"); - - if (stat(path, &st) == -1) - continue; - - pass = st.st_uid == uid; - } - else if (type == PROC_PGRP_ONLY) - { - std::string grp = getProcStatElement(ent->d_name, 4); - if (atoi(grp.c_str()) == typeinfo) - pass = true; - } - else if (type == PROC_TTY_ONLY) - { - std::string grp = getProcStatElement(ent->d_name, 6); - if (atoi(grp.c_str()) == typeinfo) - pass = true; - } - else - return 0; - - if (pidOut && count < buffersize / sizeof(pid_t)) - pidOut[count++] = atoi(ent->d_name); - } - - closedir(dirProc); - - return count*sizeof(pid_t); -} - -int proc_pidfdinfo(int pid, int fd, int flavor, void* buffer, int buffersize) -{ - // TODO - return 0; -} - -int proc_regionfilename(int pid, uint64_t address, void * buffer, uint32_t buffersize) -{ - std::ifstream file; - std::string line; - std::stringstream fname; - - fname << "/proc/" << pid << "/maps"; - file.open(fname.str().c_str()); - - if (!file.is_open()) - return 0; - - while (std::getline(file, line)) - { - if (line.empty()) continue; - - const char* s = line.c_str(); - uint64_t start, end; - - start = strtoll(s, (char**) &s, 16); - s++; - end = strtoll(s, (char**) &s, 16); - - if (address >= start && address < end) - { - if (line.size() > 74) - { - const char* file = line.c_str()+73; - - strncpy((char*) buffer, file, buffersize-1); - *((char*) buffer + buffersize) = 0; - - return strlen((char*) buffer) + 1; - } - else - { - *((char*) buffer) = 0; - return 1; - } - } - - } - return 0; -} - -int proc_kmsgbuf(void* buffer, uint32_t buffersize) -{ - if (buffer) - { - int rv = sys_syslog(/*SYSLOG_ACTION_READ_ALL*/ 3, static_cast(buffer), buffersize); - if (rv == -1) - { - errnoOut(); - return 0; - } - else - return rv; - } - - return 0; -} - -int proc_libversion(int *major, int * minor) -{ - if (major) - *major = 1; - if (minor) - *minor = 1; - return 0; -} - -int proc_setpcontrol(const int control) -{ - // TODO: specify options how to react on resource starvation - // Doable on Linux? - return 0; -} - -int proc_listpidspath(uint32_t type, uint32_t typeInfo, const char* path, uint32_t pathFlags, void* buffer, int buffersize) -{ - // fuser-like functionality - std::unique_ptr pids(new pid_t[4096]); - int count = 0; - int npids; - dev_t devid; - - auto AddElem = [&](pid_t pid) -> void - { - if (buffer) - { - pid_t* p = static_cast(buffer); - if (buffersize/sizeof(pid_t) >= (count+1)) - p[count++] = pid; - } - }; - - if (pathFlags & PROC_LISTPIDSPATH_PATH_IS_VOLUME) - { - struct stat st; - if (stat(path, &st) == -1) - return 0; - devid = st.st_dev; - } - - npids = proc_listpids(type, typeInfo, pids.get(), 4096*sizeof(pid_t)); - - for (int i = 0; i < npids/sizeof(pid_t); i++) - { - char dpath[100]; - DIR* dir; - struct dirent* ent; - int orig; - - sprintf(dpath, "/proc/%d/fd/", pids[i]); - orig = strlen(dpath); - dir = opendir(dpath); - - if (!dir) - continue; - - while ((ent = readdir(dir))) - { - if (ent->d_name[0] == '.') - continue; - - strcat(dpath, ent->d_name); - - if (pathFlags & PROC_LISTPIDSPATH_PATH_IS_VOLUME) // like `fuser -m` - { - struct stat st; - int rv; - - rv = stat(dpath, &st); - dpath[orig] = 0; - - if (rv == -1) - continue; - - if (st.st_dev == devid) - AddElem(pids[i]); - } - else // like `fuser` - { - char lpath[PATH_MAX]; - ssize_t bytes; - - bytes = readlink(dpath, lpath, sizeof(lpath)); - dpath[orig] = 0; - - if (bytes < 0) - continue; - - lpath[bytes] = 0; - - if (strcmp(lpath, path) == 0) - AddElem(pids[i]); - } - } - - closedir(dir); - } - - return count*sizeof(pid_t); -} - -std::string getProcStatElement(const char* pid, int elem) -{ - char path[100] = "/proc/"; - std::ifstream file; - std::string result; - - strcat(path, pid); - strcat(path, "/stat"); - - file.open(path); - - if (!file.is_open()) - return std::string(); - - for (int p = 0; p <= elem; p++) - { - int par = 0; - while (true) - { - int c = file.get(); - if (!par && c == ' ') - break; - if (par == 2 && c == ')') - { - file.get(); - break; - } - if (!par && c == '(') - par = 2; - else - { - par = 1; - result += char(c); - } - } - } - - return result; -} - -int sys_syslog(int type, char *bufp, int len) -{ - return syscall(SYS_syslog, type, bufp, len); -} - diff --git a/src/libSystem/kernel-bsd/proc.h b/src/libSystem/kernel-bsd/proc.h deleted file mode 100644 index 7006779bd..000000000 --- a/src/libSystem/kernel-bsd/proc.h +++ /dev/null @@ -1,98 +0,0 @@ -/* -This file is part of Darling. - -Copyright (C) 2013 Lubos Dolezel - -Darling is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Darling is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Darling. If not, see . -*/ - -#ifndef MACH_PROC_H -#define MACH_PROC_H -#include - -extern "C" -{ - -// For proc_listpidspath -#define PROC_LISTPIDSPATH_PATH_IS_VOLUME 1 -#define PROC_LISTPIDSPATH_EXCLUDE_EVTONLY 2 // exclude O_EVTONLY fds, not doable on Linux (no O_EVTONLY on Linux) - -// For proc_listpids -#define PROC_ALL_PIDS 1 -#define PROC_PGRP_ONLY 2 -#define PROC_TTY_ONLY 3 -#define PROC_UID_ONLY 4 -#define PROC_RUID_ONLY 5 - - int proc_name(int pid, void* buffer, uint32_t buffersize); - int proc_pidpath(int pid, void* buffer, uint32_t buffersize); - int proc_pidinfo(int pid, int flavor, uint64_t arg, void* buffer, int buffersize); - int proc_listpids(uint32_t type, uint32_t typeinfo, void* buffer, int buffersize); - int proc_pidfdinfo(int pid, int fd, int flavor, void* buffer, int buffersize); - int proc_regionfilename(int pid, uint64_t address, void* buffer, uint32_t buffersize); - int proc_kmsgbuf(void* buffer, uint32_t buffersize); - int proc_libversion(int* major, int* minor); - int proc_setpcontrol(const int control); - int proc_listpidspath(uint32_t type, uint32_t typeInfo, const char* path, uint32_t pathFlags, void* buffer, int buffersize); - - struct proc_taskinfo - { - uint64_t pti_virtual_size, - pti_resident_size, - pti_total_user, - pti_total_system, - pti_threads_user, - pti_threads_system; - int32_t pti_policy, - pti_faults, - pti_pageins, - pti_cow_faults, - pti_messages_sent, - pti_messages_received, - pti_syscalls_mach, - pti_syscalls_unix, - pti_csw, - pti_threadnum, - pti_numrunning, - pti_priority; - }; - - struct proc_regioninfo - { - uint32_t pri_protection, - pri_max_protection, - pri_inheritance, - pri_flags; - uint64_t pri_offset; - uint32_t pri_behavior, - pri_user_wired_count, - pri_user_tag, - pri_pages_resident, - pri_pages_shared_now_private, - pri_pages_swapped_out, - pri_pages_dirtied, - pri_ref_count, - pri_shadow_depth, - pri_share_mode, - pri_private_pages_resident, - pri_shared_pages_resident, - pri_obj_id, - pri_depth; - uint64_t pri_address, - pri_size; - }; -} - -#endif - diff --git a/src/libSystem/kernel-bsd/sockets.cpp b/src/libSystem/kernel-bsd/sockets.cpp deleted file mode 100644 index 1198b7146..000000000 --- a/src/libSystem/kernel-bsd/sockets.cpp +++ /dev/null @@ -1,272 +0,0 @@ -#include "config.h" -#include -#include "sockets.h" -#include "libc/darwin_errno_codes.h" -#include "libc/errno.h" -#include "common/path.h" -#include "common/auto.h" -#include -#include -#include -#include -#include - -using namespace Darling; - -short Darling::familyDarwinToLinux(short f) -{ - switch (f) - { - case DARWIN_AF_UNSPEC: - return AF_UNSPEC; - case DARWIN_AF_UNIX: - return AF_UNIX; - case DARWIN_AF_INET: - return AF_INET; - //case DARWIN_AF_APPLETALK: - // return AF_APPLETALK; - case DARWIN_AF_IPX: - return AF_IPX; - case DARWIN_AF_INET6: - return AF_INET6; - default: - return -1; - } -} - -short Darling::familyLinuxToDarwin(short f) -{ - switch (f) - { - case AF_UNSPEC: - return DARWIN_AF_UNSPEC; - case AF_UNIX: - return DARWIN_AF_UNIX; - case AF_INET: - return DARWIN_AF_INET; - //case AF_APPLETALK: - // return DARWIN_AF_APPLETALK; - case AF_IPX: - return DARWIN_AF_IPX; - case AF_INET6: - return DARWIN_AF_INET6; - default: - return -1; - } -} - -bool Darling::sockaddrFixupIn(struct sockaddr* addr, socklen_t len) -{ - if (offsetof(struct sockaddr,sa_family) == 0) - { - // BSD/Darwin has offset of 1 - //memmove(addr, reinterpret_cast(addr)+1, len-1); - short f = *reinterpret_cast(reinterpret_cast(addr)+1); - addr->sa_family = f; - } - addr->sa_family = familyDarwinToLinux(addr->sa_family); - return addr->sa_family != 0xffff; -} - -bool Darling::sockaddrFixupOut(struct sockaddr* addr, socklen_t len) -{ - bool ok; - addr->sa_family = familyLinuxToDarwin(addr->sa_family); - ok = addr->sa_family != 0xffff; - - if (offsetof(struct sockaddr,sa_family) == 0) - { - // BSD/Darwin has offset of 1 - // memmove(reinterpret_cast(addr)+1, addr, len-1); - short f = addr->sa_family; - *reinterpret_cast(reinterpret_cast(addr)+1) = f; - } - return ok; -} - -int __darwin_select(int fd, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, __darwin_timeval* timeout) -{ - struct timeval n; - int rv; - - if (timeout != nullptr) - { - n = timeval { timeout->tv_sec, timeout->tv_usec }; - rv = ::select(fd, readfds, writefds, exceptfds, &n); - } - else - rv = ::select(fd, readfds, writefds, exceptfds, nullptr); - - if (rv == -1) - errnoOut(); - - return rv; -} - -MAP_FUNCTION3(int,poll,struct pollfd*,nfds_t,int); - -int __darwin_accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen) -{ - int rv = ::accept(sockfd, addr, addrlen); - if (rv == -1) - errnoOut(); - else - sockaddrFixupOut(addr, *addrlen); - return rv; -} - -MAP_FUNCTION4(ssize_t,send,int,const void*,size_t,int); -MAP_FUNCTION3(ssize_t,sendmsg,int,struct msghdr*,int); - -ssize_t __darwin_sendto(int socket, const void *buffer, size_t length, int flags, const struct sockaddr *dest_addr, socklen_t dest_len) -{ - struct sockaddr* buf = reinterpret_cast(alloca(dest_len)); - memcpy(buf, dest_addr, dest_len); - - if (!sockaddrFixupIn(buf, dest_len)) - { - errno = DARWIN_EAFNOSUPPORT; - return -1; - } - - return AutoErrno(sendto,socket,buffer,length,flags,buf,dest_len); -} - -MAP_FUNCTION4(ssize_t,recv,int,void*,size_t,int); -MAP_FUNCTION3(ssize_t,recvmsg,int,struct msghdr*,int); // TODO: check msghdr - -ssize_t __darwin_recvfrom(int socket, void * buffer, size_t length, int flags, struct sockaddr * address, socklen_t * address_len) -{ - ssize_t s = AutoErrno(recvfrom,socket,buffer,length,flags,address,address_len); - if (s != -1) - sockaddrFixupOut(address, *address_len); - return s; -} - -// for SOL_SOCKET -static int MapSockOptname(int opt) -{ - switch (opt) - { - case DARWIN_SO_DEBUG: - return SO_DEBUG; - case DARWIN_SO_ACCEPTCONN: - return SO_ACCEPTCONN; - case DARWIN_SO_REUSEADDR: - return SO_REUSEADDR; - case DARWIN_SO_KEEPALIVE: - return SO_KEEPALIVE; - case DARWIN_SO_DONTROUTE: - return SO_DONTROUTE; - case DARWIN_SO_BROADCAST: - return SO_BROADCAST; - case DARWIN_SO_LINGER_SEC: - case DARWIN_SO_LINGER: - return SO_LINGER; - //case DARWIN_SO_REUSEPORT: - // return SO_REUSEPORT; - case DARWIN_SO_TIMESTAMP: - return SO_TIMESTAMP; - case DARWIN_SO_OOBINLINE: - return SO_OOBINLINE; - case DARWIN_SO_SNDBUF: - return SO_SNDBUF; - case DARWIN_SO_RCVBUF: - return SO_RCVBUF; - case DARWIN_SO_RCVLOWAT: - return SO_RCVLOWAT; - case DARWIN_SO_SNDLOWAT: - return SO_SNDLOWAT; - case DARWIN_SO_RCVTIMEO: - return SO_RCVTIMEO; - case DARWIN_SO_SNDTIMEO: - return SO_SNDTIMEO; - case DARWIN_SO_ERROR: - return SO_ERROR; - case DARWIN_SO_TYPE: - return SO_TYPE; - default: - return -1; - } -} - -int __darwin_getsockopt(int socket, int level, int option_name, void * option_value, socklen_t * option_len) -{ - int orig_opt = option_name; - if (level == SOL_SOCKET) - option_name = MapSockOptname(option_name); - - int rv = getsockopt(socket,level,option_name,option_value,option_len); - if (rv != -1) - { - if (level == SOL_SOCKET && orig_opt == DARWIN_SO_LINGER) - { - linger* l = reinterpret_cast(option_value); - l->l_linger *= 100; // convert to ticks, 1 tick = 1/100 s - } - } - else - errnoOut(); - - return rv; -} - -int __darwin_setsockopt(int socket, int level, int option_name, const void *option_value, socklen_t option_len) -{ - int orig_opt = option_name; - if (level == SOL_SOCKET) - { - option_name = MapSockOptname(option_name); - if (orig_opt == DARWIN_SO_LINGER && option_len == sizeof(linger)) - { - linger* l = reinterpret_cast(alloca(sizeof(linger))); - const linger* o = reinterpret_cast(option_value); - l->l_onoff = o->l_onoff; - l->l_linger = (o->l_linger+99) / 100; // round up to seconds - option_value = l; - } - } - - return AutoErrno(setsockopt,socket,level,option_name,option_value,option_len); -} - -int __darwin_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen) -{ - struct sockaddr* ma = reinterpret_cast(malloc(addrlen)); - - memcpy(ma, addr, addrlen); - - if (!sockaddrFixupIn(ma, addrlen)) - { - free(ma); - errno = DARWIN_EAFNOSUPPORT; - return -1; - } - else - { - int rv = ::connect(sockfd, ma, addrlen); - if (rv == -1) - errnoOut(); - free(ma); - return rv; - } -} - -int __darwin_socket(int domain, int type, int protocol) -{ - domain = familyDarwinToLinux(domain); - if (domain == -1) - { - errno = DARWIN_EAFNOSUPPORT; - return -1; - } - else - { - int rv = ::socket(domain, type, protocol); - if (rv == -1) - errnoOut(); - return rv; - } -} - - diff --git a/src/libSystem/kernel-bsd/sockets.h b/src/libSystem/kernel-bsd/sockets.h deleted file mode 100644 index 93bda3235..000000000 --- a/src/libSystem/kernel-bsd/sockets.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef BSD_SOCKETS_H -#define BSD_SOCKETS_H - -#define DARWIN_SO_DEBUG 0x1 -#define DARWIN_SO_ACCEPTCONN 0x2 -#define DARWIN_SO_REUSEADDR 0x4 -#define DARWIN_SO_KEEPALIVE 0x8 -#define DARWIN_SO_DONTROUTE 0x10 -#define DARWIN_SO_BROADCAST 0x20 -#define DARWIN_SO_LINGER_SEC 0x1080 -#define DARWIN_SO_LINGER 0x80 -#define DARWIN_SO_REUSEPORT 0x0200 -#define DARWIN_SO_TIMESTAMP 0x0400 -#define DARWIN_SO_OOBINLINE 0x0100 -#define DARWIN_SO_SNDBUF 0x1001 -#define DARWIN_SO_RCVBUF 0x1002 -#define DARWIN_SO_RCVLOWAT 0x1004 -#define DARWIN_SO_SNDLOWAT 0x1003 -#define DARWIN_SO_RCVTIMEO 0x1006 -#define DARWIN_SO_SNDTIMEO 0x1005 -#define DARWIN_SO_ERROR 0x1007 -#define DARWIN_SO_TYPE 0x1008 - -#define DARWIN_AF_UNSPEC 0 -#define DARWIN_AF_UNIX 1 -#define DARWIN_AF_INET 2 -#define DARWIN_AF_APPLETALK 16 -#define DARWIN_AF_IPX 23 -#define DARWIN_AF_INET6 30 - -struct __darwin_timeval -{ - long tv_sec; - int tv_usec; -}; - -#ifdef __cplusplus -extern "C" -{ -#endif - -int __darwin_select(int fd, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, struct __darwin_timeval* timeout); -ssize_t __darwin_sendto(int socket, const void *buffer, size_t length, int flags, const struct sockaddr *dest_addr, socklen_t dest_len); -ssize_t __darwin_recvfrom(int socket, void * buffer, size_t length, int flags, struct sockaddr * address, socklen_t * address_len); - -int __darwin_getsockopt(int socket, int level, int option_name, void * option_value, socklen_t * option_len); - -int __darwin_setsockopt(int socket, int level, int option_name, const void *option_value, socklen_t option_len); - -int __darwin_socket(int domain, int type, int protocol); -int __darwin_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen); -int __darwin_accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen); - -#ifdef __cplusplus -} - -namespace Darling -{ - short familyDarwinToLinux(short f); - short familyLinuxToDarwin(short f); - bool sockaddrFixupIn(struct sockaddr* addr, socklen_t len); - bool sockaddrFixupOut(struct sockaddr* addr, socklen_t len); -} -#endif - -#endif diff --git a/src/libSystem/kernel-bsd/stat.cpp b/src/libSystem/kernel-bsd/stat.cpp deleted file mode 100644 index 59b7ff40d..000000000 --- a/src/libSystem/kernel-bsd/stat.cpp +++ /dev/null @@ -1,145 +0,0 @@ -#include "config.h" -#include "stat.h" -#include "trace.h" -#include "common/path.h" -#include "libc/errno.h" -#include -#include -#include -#include -#include - -static void convertStat64(struct stat64* linux_buf, struct __darwin_stat64* mac) -{ - mac->st_dev = linux_buf->st_dev; - mac->st_mode = linux_buf->st_mode; - mac->st_nlink = linux_buf->st_nlink; - mac->st_ino = linux_buf->st_ino; - mac->st_uid = linux_buf->st_uid; - mac->st_gid = linux_buf->st_gid; - mac->st_rdev = linux_buf->st_rdev; - mac->st_size = linux_buf->st_size; - mac->st_blksize = linux_buf->st_blksize; - mac->st_blocks = linux_buf->st_blocks; - mac->st_atimespec.tv_sec = linux_buf->st_atime; - mac->st_mtimespec.tv_sec = linux_buf->st_mtime; - mac->st_ctimespec.tv_sec = linux_buf->st_ctime; -} - -static void convertStat(struct stat64* linux_buf, struct __darwin_stat* mac) -{ - mac->st_dev = linux_buf->st_dev; - mac->st_mode = linux_buf->st_mode; - mac->st_nlink = linux_buf->st_nlink; - mac->st_ino = linux_buf->st_ino; - mac->st_uid = linux_buf->st_uid; - mac->st_gid = linux_buf->st_gid; - mac->st_rdev = linux_buf->st_rdev; - mac->st_size = linux_buf->st_size; - mac->st_blksize = linux_buf->st_blksize; - mac->st_blocks = linux_buf->st_blocks; - mac->st_atimespec.tv_sec = linux_buf->st_atime; - mac->st_mtimespec.tv_sec = linux_buf->st_mtime; - mac->st_ctimespec.tv_sec = linux_buf->st_ctime; -} - -int __darwin_stat64(const char* path, struct __darwin_stat64* mac) -{ - TRACE2(path, mac); - struct stat64 linux_buf; - - if (Darling::MachOMgr::instance()->hasSysRoot()) - { - const char* prefixed; - std::string lpath = Darling::MachOMgr::instance()->sysRoot(); - - lpath += '/'; - lpath += path; - - prefixed = translatePathCI(lpath.c_str()); - if (::access(prefixed, F_OK) == 0) - path = prefixed; - else - path = translatePathCI(path); - } - else - path = translatePathCI(path); - - int ret = stat64(translatePathCI(path), &linux_buf); - if (ret == -1) - errnoOut(); - - convertStat64(&linux_buf, mac); - return ret; -} - -int __darwin_fstat64(int fd, struct __darwin_stat64* mac) -{ - TRACE2(fd, mac); - struct stat64 linux_buf; - int ret = fstat64(fd, &linux_buf); - if (ret == -1) - errnoOut(); - - convertStat64(&linux_buf, mac); - return ret; -} - -int __darwin_lstat64(const char* path, struct __darwin_stat64* mac) -{ - TRACE2(path, mac); - struct stat64 linux_buf; - int ret = lstat64(translatePathCI(path), &linux_buf); - if (ret == -1) - errnoOut(); - - convertStat64(&linux_buf, mac); - return ret; -} - -int __darwin_stat(const char* path, struct __darwin_stat* mac) -{ - TRACE2(path, mac); - struct stat64 linux_buf; - int ret = stat64(translatePathCI(path), &linux_buf); - if (ret == -1) - errnoOut(); - - convertStat(&linux_buf, mac); - return ret; -} - -int __darwin_fstat(int fd, struct __darwin_stat* mac) -{ - TRACE2(fd, mac); - struct stat64 linux_buf; - int ret = fstat64(fd, &linux_buf); - if (ret == -1) - errnoOut(); - - convertStat(&linux_buf, mac); - return ret; -} - -int __darwin_lstat(const char* path, struct __darwin_stat* mac) -{ - TRACE2(path, mac); - struct stat64 linux_buf; - int ret = lstat64(translatePathCI(path), &linux_buf); - if (ret == -1) - errnoOut(); - - convertStat(&linux_buf, mac); - return ret; -} - -#ifdef TEST -int main() -{ - printf("sizeof(__darwin_stat64) = %d\n", sizeof(struct __darwin_stat64)); - printf("sizeof(__darwin_stat) = %d\n", sizeof(struct __darwin_stat)); - return 0; -} - -#endif - diff --git a/src/libSystem/kernel-bsd/stat.h b/src/libSystem/kernel-bsd/stat.h deleted file mode 100644 index 5642db1e8..000000000 --- a/src/libSystem/kernel-bsd/stat.h +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef BSD_STAT_H -#define BSD_STAT_H -#include -#include - -struct __darwin_timespec { - time_t tv_sec; - long tv_nsec; -}; - -typedef int32_t __darwin_dev_t; -typedef uint16_t __darwin_mode_t; -typedef uint16_t __darwin_nlink_t; -typedef uint64_t __darwin_ino64_t; -typedef uint32_t __darwin_uid_t; -typedef uint32_t __darwin_gid_t; - -// target: current (INODE64) -// sizeof() = 144 on x86_64 -// sizeof() = 108 on x86 - -// target: legacy (10.3) -// sizeof() = 120 on x86_64 -// sizeof() = 96 on x86 -// 92 - -// From /usr/include/sys/stat.h -struct __darwin_stat64 { - __darwin_dev_t st_dev; - __darwin_mode_t st_mode; - __darwin_nlink_t st_nlink; - __darwin_ino64_t st_ino; - __darwin_uid_t st_uid; - __darwin_gid_t st_gid; - __darwin_dev_t st_rdev; - struct __darwin_timespec st_atimespec; - struct __darwin_timespec st_mtimespec; - struct __darwin_timespec st_ctimespec; - struct __darwin_timespec st_birthtimespec; - uint64_t st_size; - uint64_t st_blocks; - uint32_t st_blksize; - __uint32_t st_flags; - __uint32_t st_gen; - __int32_t st_lspare; - __int64_t st_qspare[2]; -}; - -struct __darwin_stat { - __darwin_dev_t st_dev; - uint32_t st_ino; - __darwin_mode_t st_mode; - __darwin_nlink_t st_nlink; - __darwin_uid_t st_uid; - __darwin_gid_t st_gid; - __darwin_dev_t st_rdev; - struct __darwin_timespec st_atimespec; - struct __darwin_timespec st_mtimespec; - struct __darwin_timespec st_ctimespec; - uint64_t st_size; - uint64_t st_blocks; - uint32_t st_blksize; - __uint32_t st_flags; - __uint32_t st_gen; - __int32_t st_lspare; - __int64_t st_qspare[2]; -}; - -#ifdef __cplusplus -extern "C" -{ -#endif - -int __darwin_stat64(const char* path, struct __darwin_stat64* mac) asm("__darwin_stat$INODE64"); -int __darwin_fstat64(int fd, struct __darwin_stat64* mac) asm("__darwin_fstat$INODE64"); -int __darwin_lstat64(const char* path, struct __darwin_stat64* mac) asm("__darwin_lstat$INODE64"); - -int __darwin_stat(const char* path, struct __darwin_stat* mac); -int __darwin_fstat(int fd, struct __darwin_stat* mac); -int __darwin_lstat(const char* path, struct __darwin_stat* mac); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/libSystem/kernel-bsd/wait.cpp b/src/libSystem/kernel-bsd/wait.cpp deleted file mode 100644 index d6aa076f0..000000000 --- a/src/libSystem/kernel-bsd/wait.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "config.h" -#include "wait.h" -#include "libc/errno.h" -#include "libc/darwin_errno_codes.h" -#include "libc/signals.h" -#include "log.h" -#include -#include - -int __darwin_kill(pid_t pid, int sig) -{ - int rv = kill(pid, Darling::signalDarwinToLinux(sig)); - if (rv == -1) - errnoOut(); - return rv; -} - -pid_t __darwin_wait(int *stat_loc) -{ - return __darwin_waitpid(-1, stat_loc, 0); -} - -// options are compatible -pid_t __darwin_wait3(int *stat_loc, int options, struct rusage *rusage) -{ - pid_t rv = __darwin_waitpid(-1, stat_loc, options); - if (rv && rusage) - getrusage(RUSAGE_CHILDREN, rusage); // TODO: may not be correct - return rv; -} - -pid_t __darwin_wait4(pid_t pid, int *stat_loc, int options, struct rusage *rusage) -{ - pid_t rv = __darwin_waitpid(pid, stat_loc, options); - if (rv && rusage) - getrusage(RUSAGE_CHILDREN, rusage); // TODO: may not be correct - return rv; -} - -pid_t __darwin_waitpid(pid_t pid, int *stat_loc, int options) -{ - pid_t rv = waitpid(pid, stat_loc, options); - if (WIFSIGNALED(*stat_loc)) - { - // rewrite the signal number - // 0x7f on Linux - int signum = (*stat_loc) & (0x7f); - signum = Darling::signalLinuxToDarwin(signum); - *stat_loc &= ~(0x7f); - *stat_loc |= signum; - } - return rv; // TODO: check if compatible -} - diff --git a/src/libSystem/kernel-bsd/wait.h b/src/libSystem/kernel-bsd/wait.h deleted file mode 100644 index 15020bbab..000000000 --- a/src/libSystem/kernel-bsd/wait.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef BSD_WAIT_H -#define BSD_WAIT_H -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -int __darwin_kill(pid_t pid, int sig); -pid_t __darwin_wait(int *stat_loc); -pid_t __darwin_wait3(int *stat_loc, int options, struct rusage *rusage); -pid_t __darwin_wait4(pid_t pid, int *stat_loc, int options, struct rusage *rusage); -pid_t __darwin_waitpid(pid_t pid, int *stat_loc, int options); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/libSystem/kernel-mach/Futex.cpp b/src/libSystem/kernel-mach/Futex.cpp deleted file mode 100644 index 7da211148..000000000 --- a/src/libSystem/kernel-mach/Futex.cpp +++ /dev/null @@ -1,124 +0,0 @@ -#include "config.h" -#include "Futex.h" -#include -#include -#include -#include -#include -#include "../../util/log.h" - -Darling::Futex::Futex() -: m_lock(1), m_owner(0), m_readyToHandOff(0), m_handOffTarget(0) -{ -} - -void Darling::Futex::acquire() -{ - if (m_owner == gettid()) - LOG << "Deadlock will now happen in Darling::Futex::acquire()\n"; - while (true) - { - int result = __sync_sub_and_fetch(&m_lock, 1); - if (result < 0) - { - // contention case - LOG << gettid() << ": Contention with value " << result << std::endl; - futex(&m_lock, FUTEX_WAIT, result); - } - else - { - LOG << gettid() << ": Lock acquired\n"; - m_owner = gettid(); - break; - } - } -} - -void Darling::Futex::release() -{ - assert(m_owner == gettid()); - m_owner = 0; - - int result = __sync_add_and_fetch(&m_lock, 1); - - if (result != 1) - { - // contention case - LOG << gettid() << ": Lock released, contended\n"; - m_lock = 1; - futex(&m_lock, FUTEX_WAKE, 2); - } - else - LOG << gettid() << ": Lock released\n"; -} - -Darling::Futex::TryAcquireResult Darling::Futex::try_acquire() -{ - if (m_owner == gettid()) - return ResultAlreadyOwned; - - bool success = __sync_bool_compare_and_swap(&m_lock, 1, 0); - if (success) - m_owner = gettid(); - - return success ? ResultOK : ResultLocked; -} - -void Darling::Futex::handoff() -{ - assert(m_owner == gettid()); - - // Wait for the handoff target - while (true) - { - pid_t target = m_handOffTarget; - if (target != 0) - break; - else - futex(&m_handOffTarget, FUTEX_WAIT, target); - } - - // Let the target know we're here - m_readyToHandOff = 1; - m_owner = m_handOffTarget; // Pass the ownership to the target - futex(&m_readyToHandOff, FUTEX_WAKE, 1); -} - -bool Darling::Futex::handoff_accept() -{ - assert(m_owner != gettid()); - - if (m_handOffTarget != 0) - return false; - - // Let the owner know we're here - m_handOffTarget = gettid(); - futex(&m_handOffTarget, FUTEX_WAKE, 1); - - // Wait for the owner - while (true) - { - int ready = m_readyToHandOff; - if (ready != 0) - break; - else - futex(&m_readyToHandOff, FUTEX_WAIT, ready); - } - - // Reset the variables - m_handOffTarget = 0; - m_readyToHandOff = 0; - - return true; -} - -pid_t Darling::Futex::gettid() -{ - return syscall(SYS_gettid); -} - -int Darling::Futex::futex(int *uaddr, int op, int val, const struct timespec *timeout, int *uaddr2, int val3) -{ - return syscall(SYS_futex, uaddr, op, val, timeout, uaddr2, val3); -} - diff --git a/src/libSystem/kernel-mach/Futex.h b/src/libSystem/kernel-mach/Futex.h deleted file mode 100644 index 746899dbf..000000000 --- a/src/libSystem/kernel-mach/Futex.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef LINUX_FUTEX_H -#define LINUX_FUTEX_H -#include - -namespace Darling -{ - -class Futex -{ -public: - Futex(); - - // Lock the futex. - void acquire(); - - // Unlock the futex. - void release(); - - // Try lock the futex - enum TryAcquireResult { ResultOK = 0, ResultAlreadyOwned = 1, ResultLocked = 2 }; - TryAcquireResult try_acquire(); - - // Transfer the lock ownership to another thread calling handoff_accept(). - void handoff(); - - // Accept the lock ownership transfer from another thread calling handoff(). - // Returns false if there is another thread waiting for a handoff. - bool handoff_accept(); - - // Returns the (thread) PID that currently owns the futex or zero - inline pid_t owner() const { return m_owner; } - - // Performs the gettid system call. - static pid_t gettid(); - - // Performs the futex system call. - static int futex(int *uaddr, int op, int val, const struct timespec *timeout = nullptr, int *uaddr2 = nullptr, int val3 = 0); -private: - int m_lock; - pid_t m_owner; - int m_readyToHandOff; - pid_t m_handOffTarget; -}; - -} - -#endif diff --git a/src/libSystem/kernel-mach/FutexSemaphore.cpp b/src/libSystem/kernel-mach/FutexSemaphore.cpp deleted file mode 100644 index 91d9df4a3..000000000 --- a/src/libSystem/kernel-mach/FutexSemaphore.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include "FutexSemaphore.h" -#include "Futex.h" -#include -#include "../../util/log.h" - -Darling::FutexSemaphore::FutexSemaphore(int value) -: m_counter(value), m_waiting(0) -{ -} - -void Darling::FutexSemaphore::signal() -{ - if (__sync_fetch_and_add(&m_counter, 1) == 0) - Futex::futex(&m_counter, FUTEX_WAKE, 1); -} - -void Darling::FutexSemaphore::signalAll() -{ - if (m_waiting > 0) - { - int count = m_waiting; - - m_counter = count; - //LOG << "Signalling " << count << " threads\n"; - Futex::futex(&m_counter, FUTEX_WAKE, count); - } -} - -void Darling::FutexSemaphore::wait() -{ - while (true) - { - int value = m_counter; - if (value > 0) - { - //LOG << "Value is " << value << ", trying to decrement\n"; - if (__sync_bool_compare_and_swap(&m_counter, value, value-1)) - break; - } - else - { - __sync_fetch_and_add(&m_waiting, 1); - Futex::futex(&m_counter, FUTEX_WAIT, value); - __sync_fetch_and_sub(&m_waiting, 1); - } - } -} - - diff --git a/src/libSystem/kernel-mach/FutexSemaphore.h b/src/libSystem/kernel-mach/FutexSemaphore.h deleted file mode 100644 index 152246179..000000000 --- a/src/libSystem/kernel-mach/FutexSemaphore.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef FUTEXSEMAPHORE_H -#define FUTEXSEMAPHORE_H - -namespace Darling { - -class FutexSemaphore -{ -public: - FutexSemaphore(int value); - void signal(); - - // This seems to be inherently broken - void signalAll(); - void wait(); -private: - int m_counter; - int m_waiting; -}; - -} - -#endif diff --git a/src/libSystem/kernel-mach/compat.cpp b/src/libSystem/kernel-mach/compat.cpp deleted file mode 100644 index 736284162..000000000 --- a/src/libSystem/kernel-mach/compat.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "compat.h" - -void (*mach_init_routine)() = []() {}; -void* (*_cthread_init_routine)() = []() -> void* { return nullptr; }; -void (*_cthread_exit_routine) (int) = [](int) {}; - - diff --git a/src/libSystem/kernel-mach/compat.h b/src/libSystem/kernel-mach/compat.h deleted file mode 100644 index 197c505e9..000000000 --- a/src/libSystem/kernel-mach/compat.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef MACH_COMPAT_H -#define MACH_COMPAT_H - -extern "C" void (*mach_init_routine)(); -extern "C" void* (*_cthread_init_routine)(); -extern "C" void (*_cthread_exit_routine) (int); - -#endif - diff --git a/src/libSystem/kernel-mach/error.cpp b/src/libSystem/kernel-mach/error.cpp deleted file mode 100644 index aaa9333ab..000000000 --- a/src/libSystem/kernel-mach/error.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "error.h" -#include - -const char* mach_error_string(kern_return_t code) -{ - switch (code) - { - case KERN_SUCCESS: - return "Success"; - case KERN_FAILURE: - return "Generic failure"; - case KERN_INVALID_ARGUMENT: - return "Invalid argument"; - case KERN_ALREADY_WAITING: - return "Another thread is already waiting for the operation"; - case KERN_RESOURCE_SHORTAGE: - return "Out of memory"; - case KERN_LOCK_OWNED_SELF: - return "The calling thread already owns the lock"; - case KERN_LOCK_OWNED: - return "The lock is already owned by another thread"; - case KERN_INVALID_ADDRESS: - return "Invalid address"; - case KERN_NO_SPACE: - return "No virtual memory space"; - case KERN_PROTECTION_FAILURE: - return "Access denied"; - default: - { - static __thread char buf[20]; - sprintf(buf, "Error code %d", code); - return buf; - } - } -} - -void mach_error(const char* str, kern_return_t code) -{ - const char* msg = mach_error_string(code); - fprintf(stderr, "%s %s\n", str, msg); -} - -const char* mach_error_type(kern_return_t code) -{ - return "error type dummy"; -} - diff --git a/src/libSystem/kernel-mach/error.h b/src/libSystem/kernel-mach/error.h deleted file mode 100644 index 1e9698da8..000000000 --- a/src/libSystem/kernel-mach/error.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef MACH_ERROR_H -#define MACH_ERROR_H -#include - -#ifdef __cplusplus -extern "C" { -#endif - -const char* mach_error_string(kern_return_t code); -void mach_error(const char* str, kern_return_t code); -const char* mach_error_type(kern_return_t code); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/src/libSystem/kernel-mach/host.cpp b/src/libSystem/kernel-mach/host.cpp deleted file mode 100644 index fe9c7af17..000000000 --- a/src/libSystem/kernel-mach/host.cpp +++ /dev/null @@ -1,182 +0,0 @@ -#include "config.h" -#include "host.h" -#include "trace.h" -#include -#include -#include -#include -#include -#include -#include - -__attribute__((constructor)) static void checkProcfs() -{ - if (::access("/proc/", X_OK) == -1) - { - std::cerr << "/proc is required to be mounted.\n"; - abort(); - } -} - -kern_return_t host_page_size(host_t host, size_t* size) -{ - TRACE2(host, size); - - // TODO: add a check for host - - *size = getpagesize(); - return KERN_SUCCESS; -} - -static void getPhysicalLogicalCPUCounts(int& physical, int& logical) -{ - std::ifstream file("/proc/cpuinfo"); - std::string line; - std::set phys_ids; - - physical = logical = 0; - - while(std::getline(file, line)) - { - if (line.compare(0, 10, "processor\t") == 0) - { - logical++; - } - else if (line.compare(0, 12, "physical id\t") == 0) - { - phys_ids.insert(atoi(line.c_str() + 14)); - } - } - - physical = phys_ids.size(); -} - -// TODO: test this function -kern_return_t host_info(host_t host, int flavor, host_basic_info* info, long* info_cnt) -{ - if (flavor != HOST_BASIC_INFO) - { - LOG << "Unsupported host_info flavor: " << flavor << std::endl; - return KERN_FAILURE; - } - - memset(info, 0, sizeof(*info)); - -#if defined(__i386__) - info->cpu_type = CPU_TYPE_I386; - info->cpu_subtype = CPU_SUBTYPE_I386_ALL; -#elif defined(__x86_64__) - info->cpu_type = CPU_TYPE_I386; // TODO: check the behavior on Darwin! - info->cpu_subtype = CPU_SUBTYPE_I386_ALL; -#elif defined(__arm__) - info->cpu_type = CPU_TYPE_ARM; - info->cpu_subtype = CPU_SUBTYPE_ARM_ALL; -#else -# error Unsupported platform -#endif - - info->max_cpus = sysconf(_SC_NPROCESSORS_CONF); - info->avail_cpus = sysconf(_SC_NPROCESSORS_ONLN); - - int64_t pages = ::sysconf(_SC_PHYS_PAGES); - int64_t page_size = ::sysconf(_SC_PAGE_SIZE); - int64_t max_mem = pages * page_size; - - if (*info_cnt >= sizeof(*info)) - { - info->max_mem = max_mem; - info->physical_cpu_max = info->logical_cpu_max = info->max_cpus; - - getPhysicalLogicalCPUCounts(info->physical_cpu, info->logical_cpu); - } - - info->memory_size = (max_mem <= 0x80000000) ? int32_t(max_mem) : 0x80000000; // 2 GB cap - - *info_cnt = std::min(sizeof(*info), *info_cnt); - - return KERN_SUCCESS; -} - -static std::vector getTicksLine() -{ - std::ifstream file("/proc/stat"); - std::string dummy; - std::vector rv; - - if (!file.is_open()) - return rv; - - file >> dummy; - if (dummy != "cpu") - return rv; - - for (int i = 0; i < 7; i++) - { - int n; - file >> n; - rv.push_back(n); - } - - return rv; -} - -kern_return_t host_statistics(host_t host, int flavor, void* out, long* out_cnt) -{ - memset(out, 0, *out_cnt); - - if (flavor == HOST_LOAD_INFO) - { - host_load_info* info = static_cast(out); - if (*out_cnt < sizeof(host_load_info)) - return KERN_INVALID_ARGUMENT; - - double nat_avg[3]; - if (getloadavg(nat_avg, 3) == -1) - return KERN_FAILURE; - - // We're diverging from what Mach returns here, but this is as close as we can get - info->avenrun[0] = int(nat_avg[0]); - info->avenrun[1] = int(nat_avg[1]); - info->avenrun[2] = int(nat_avg[2]); - - *out_cnt = sizeof(*info); - - return KERN_SUCCESS; - } - else if (flavor == HOST_VM_INFO) - { - return KERN_FAILURE; // not implementable? - } - else if (flavor == HOST_CPU_LOAD_INFO) - { - host_cpu_load_info* load = static_cast(out); - if (*out_cnt < sizeof(host_cpu_load_info)) - return KERN_INVALID_ARGUMENT; - - std::vector ticks = getTicksLine(); - if (ticks.size() < 4) - return KERN_FAILURE; - - load->cpu_ticks[CPU_STATE_USER] = ticks[0]; - load->cpu_ticks[CPU_STATE_NICE] = ticks[1]; - load->cpu_ticks[CPU_STATE_SYSTEM] = ticks[2]; - load->cpu_ticks[CPU_STATE_IDLE] = ticks[3]; - - *out_cnt = sizeof(*load); - - return KERN_SUCCESS; - } - else if (flavor == HOST_VM_INFO64) - { - return KERN_FAILURE; // not implementable? - } - - return KERN_INVALID_ARGUMENT; -} - -host_t mach_host_self() -{ - static struct host h; - return &h; -} - diff --git a/src/libSystem/kernel-mach/host.h b/src/libSystem/kernel-mach/host.h deleted file mode 100644 index afa4a5a87..000000000 --- a/src/libSystem/kernel-mach/host.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef MACH_HOST_H -#define MACH_HOST_H -#include -#include -#include -#include - -struct host -{ - long dummy; -}; - -#ifdef __cplusplus -extern "C" -{ -#endif - -typedef host* host_t; -typedef long host_priv_t; - - -kern_return_t host_page_size(host_t host, vm_size_t* size); -kern_return_t host_info(host_t host, int flavor, host_basic_info* info, long* info_cnt); -kern_return_t host_statistics(host_t host, int flavor, void* out, long* out_cnt); -host_t mach_host_self(); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/libSystem/kernel-mach/lockset.cpp b/src/libSystem/kernel-mach/lockset.cpp deleted file mode 100644 index 897d45310..000000000 --- a/src/libSystem/kernel-mach/lockset.cpp +++ /dev/null @@ -1,118 +0,0 @@ -#include "config.h" -#include "lockset.h" -#include -#include -#include -#include -#include "mach-stub.h" -#include "trace.h" -#include "Futex.h" - -struct lock_set -{ - int lock_count; - Darling::Futex* futexes; -}; - -kern_return_t lock_acquire(lock_set_t lock_set, int lock_id) -{ - TRACE2(lock_set, lock_id); - if (!lock_set || lock_id >= lock_set->lock_count) - return KERN_INVALID_ARGUMENT; - - lock_set->futexes[lock_id].acquire(); - - return KERN_SUCCESS; -} - -kern_return_t lock_handoff(lock_set_t lock_set, int lock_id) -{ - if (!lock_set || lock_id >= lock_set->lock_count) - return KERN_INVALID_ARGUMENT; - - lock_set->futexes[lock_id].handoff(); - - return KERN_SUCCESS; -} - -kern_return_t lock_handoff_accept(lock_set_t lock_set, int lock_id) -{ - if (!lock_set || lock_id >= lock_set->lock_count) - return KERN_INVALID_ARGUMENT; - - if (!lock_set->futexes[lock_id].handoff_accept()) - return KERN_ALREADY_WAITING; - else - return KERN_SUCCESS; -} - -kern_return_t lock_make_stable(lock_set_t lock_set, int lock_id) -{ - // Whatever the hell is an unstable lock - return KERN_SUCCESS; -} - -kern_return_t lock_release(lock_set_t lock_set, int lock_id) -{ - TRACE2(lock_set, lock_id); - - if (!lock_set || lock_id >= lock_set->lock_count) - return KERN_INVALID_ARGUMENT; - - lock_set->futexes[lock_id].release(); - - return KERN_SUCCESS; -} - -kern_return_t lock_set_create(darwin_task_t task, lock_set_t* lockset, int locks, int policy) -{ - *lockset = 0; - - TRACE4(task, lockset, locks, policy); - CHECK_TASK_SELF(task); - - if (locks <= 0 || !lockset) - return KERN_INVALID_ARGUMENT; - - *lockset = new lock_set; - if (!*lockset) - return KERN_RESOURCE_SHORTAGE; - - (*lockset)->lock_count = locks; - - (*lockset)->futexes = new Darling::Futex[locks]; - if (!(*lockset)->futexes) - return KERN_RESOURCE_SHORTAGE; - - return KERN_SUCCESS; -} - -kern_return_t lock_set_destroy (darwin_task_t task, lock_set_t lockset) -{ - TRACE2(task, lockset); - CHECK_TASK_SELF(task); - - if (!lockset) - return KERN_INVALID_ARGUMENT; - - delete [] lockset->futexes; - delete lockset; - - return KERN_SUCCESS; -} - -kern_return_t lock_try (lock_set_t lock_set, int lock_id) -{ - TRACE2(lock_set, lock_id); - if (!lock_set || lock_id >= lock_set->lock_count) - return KERN_INVALID_ARGUMENT; - - Darling::Futex::TryAcquireResult result = lock_set->futexes[lock_id].try_acquire(); - if (result == Darling::Futex::ResultAlreadyOwned) - return KERN_LOCK_OWNED_SELF; - else if (result == Darling::Futex::ResultLocked) - return KERN_LOCK_OWNED; - else - return KERN_SUCCESS; -} - diff --git a/src/libSystem/kernel-mach/lockset.h b/src/libSystem/kernel-mach/lockset.h deleted file mode 100644 index 67730a086..000000000 --- a/src/libSystem/kernel-mach/lockset.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef LOCKSET_H -#define LOCKSET_H -#include -#include "task.h" - -struct lock_set; -typedef lock_set* lock_set_t; - -#ifdef __cplusplus -extern "C" { -#endif - -kern_return_t lock_acquire(lock_set_t lock_set, int lock_id); - -kern_return_t lock_handoff(lock_set_t lock_set, int lock_id); - -kern_return_t lock_handoff_accept(lock_set_t lock_set, int lock_id); - -kern_return_t lock_make_stable(lock_set_t lock_set, int lock_id); - -kern_return_t lock_release(lock_set_t lock_set, int lock_id); - -kern_return_t lock_set_create(darwin_task_t task, lock_set_t* lock_set, int locks, int policy); - -kern_return_t lock_set_destroy (darwin_task_t task, lock_set_t lock_set); - -kern_return_t lock_try (lock_set_t lock_set, int lock_id); - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/src/libSystem/kernel-mach/mach-stub.h b/src/libSystem/kernel-mach/mach-stub.h deleted file mode 100644 index a4ef55e71..000000000 --- a/src/libSystem/kernel-mach/mach-stub.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef MACH_STUB_H -#define MACH_STUB_H -#include - -#define MACH_STUB() { fprintf(stderr, "MACH_STUB(): %s\n", __PRETTY_FUNCTION__); return KERN_FAILURE; } -#define CHECK_TASK_SELF(task) { if (task->pid != getpid()) MACH_STUB(); } - -#endif diff --git a/src/libSystem/kernel-mach/semaphore.cpp b/src/libSystem/kernel-mach/semaphore.cpp deleted file mode 100644 index 7d5d66eae..000000000 --- a/src/libSystem/kernel-mach/semaphore.cpp +++ /dev/null @@ -1,81 +0,0 @@ -#include "config.h" -#include -#include "semaphore.h" -#include "mach-stub.h" -#include "trace.h" -#include -#include -#include "FutexSemaphore.h" - -kern_return_t semaphore_create(darwin_task_t task, esemaphore_t *semaphore, int policy, int value) -{ - TRACE4(task, semaphore, policy, value); - CHECK_TASK_SELF(task); - - if (value < 0) - return KERN_INVALID_ARGUMENT; - - if (!semaphore) - return KERN_INVALID_ARGUMENT; - - *semaphore = new struct semaphore; - if (!*semaphore) - return KERN_RESOURCE_SHORTAGE; - - (*semaphore)->sem = new Darling::FutexSemaphore(value); - - return KERN_SUCCESS; -} - -kern_return_t semaphore_destroy(darwin_task_t task, esemaphore_t semaphore) -{ - TRACE2(task, semaphore); - CHECK_TASK_SELF(task); - - if (!semaphore) - return KERN_INVALID_ARGUMENT; - - delete semaphore->sem; - delete semaphore; - return KERN_SUCCESS; -} - -kern_return_t semaphore_signal(esemaphore_t semaphore) -{ - TRACE1(semaphore); - if (!semaphore) - return KERN_INVALID_ARGUMENT; - - semaphore->sem->signal(); - - return KERN_SUCCESS; -} - -kern_return_t semaphore_signal_all(esemaphore_t semaphore) -{ - TRACE1(semaphore); - if (!semaphore) - return KERN_INVALID_ARGUMENT; - - semaphore->sem->signalAll(); - - return KERN_SUCCESS; -} - -kern_return_t semaphore_wait(esemaphore_t semaphore) -{ - TRACE1(semaphore); - if (!semaphore) - return KERN_INVALID_ARGUMENT; - - semaphore->sem->wait(); - - return KERN_SUCCESS; -} - -kern_return_t semaphore_timedwait(esemaphore_t semaphore, mach_timespec_t ts) -{ - STUB(); - return semaphore_wait(semaphore); -} - diff --git a/src/libSystem/kernel-mach/semaphore.h b/src/libSystem/kernel-mach/semaphore.h deleted file mode 100644 index ab14a0ff4..000000000 --- a/src/libSystem/kernel-mach/semaphore.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef MACH_SEMAPHORE_H -#define MACH_SEMAPHORE_H -#include -#include "task.h" -#include -#include - -namespace Darling -{ - class FutexSemaphore; -} - -struct semaphore -{ - Darling::FutexSemaphore* sem; -}; - -typedef semaphore* esemaphore_t; - -#ifdef __cplusplus -extern "C" -{ -#endif - -kern_return_t semaphore_create(darwin_task_t task, esemaphore_t *semaphore, int policy, int value); - -kern_return_t semaphore_destroy(darwin_task_t task, esemaphore_t semaphore); - -kern_return_t semaphore_signal(esemaphore_t semaphore); - -kern_return_t semaphore_signal_all(esemaphore_t semaphore); - -kern_return_t semaphore_wait(esemaphore_t semaphore); - -kern_return_t semaphore_timedwait(esemaphore_t semaphore, mach_timespec_t ts); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/src/libSystem/kernel-mach/task.cpp b/src/libSystem/kernel-mach/task.cpp deleted file mode 100644 index 3726373db..000000000 --- a/src/libSystem/kernel-mach/task.cpp +++ /dev/null @@ -1,109 +0,0 @@ -#include "config.h" -#include "task.h" -#include -#include -#include -#include -#include -#include -#include - -darwin_task_t mach_task_self_ = new darwin_task(::getpid()); - -kern_return_t mach_port_deallocate(darwin_task_t task, void* port) -{ - free(port); - return KERN_SUCCESS; -} - -kern_return_t pid_for_task(mach_port_name_t t, int *pid) -{ - // TODO: this is supposed to be for the specified task but for now, just return our pid - if (pid) - { - *pid = mach_task_self_->pid; - } - return KERN_SUCCESS; -} - -kern_return_t mach_port_mod_refs(ipc_space_t task, mach_port_name_t name, mach_port_right_t right, mach_port_delta_t delta) -{ - return KERN_SUCCESS; -} - -// task_info structures - -#define TASK_DYLD_INFO 17 - -struct task_dyld_info { - mach_vm_address_t all_image_info_addr; - mach_vm_size_t all_image_info_size; - integer_t all_image_info_format; -}; -typedef struct task_dyld_info task_dyld_info_data_t; -typedef struct task_dyld_info *task_dyld_info_t; -#define TASK_DYLD_ALL_IMAGE_INFO_32 0 -#define TASK_DYLD_ALL_IMAGE_INFO_64 1 - -enum dyld_image_mode { dyld_image_adding=0, dyld_image_removing=1 }; -typedef void (*dyld_image_notifier)(enum dyld_image_mode mode, uint32_t infoCount, const struct dyld_image_info info[]); - -struct dyld_all_image_infos { -uint32_t version; -uint32_t infoArrayCount; -const struct dyld_image_info* infoArray; -dyld_image_notifier notification; -bool processDetachedFromSharedRegion; -bool libSystemInitialized; -const struct mach_header* dyldImageLoadAddress; -void* jitInfo; -const char* dyldVersion; -const char* errorMessage; -uintptr_t terminationFlags; -void* coreSymbolicationShmPage; -uintptr_t systemOrderFlag; -uintptr_t uuidArrayCount; -const struct dyld_uuid_info* uuidArray; -struct dyld_all_image_infos* dyldAllImageInfosAddress; -uintptr_t initialImageCount; -uintptr_t errorKind; -const char* errorClientOfDylibPath; -const char* errorTargetDylibPath; -const char* errorSymbol; -uintptr_t sharedCacheSlide; -}; - -struct dyld_all_image_infos dyld_all_image_infos = { 12 }; - -kern_return_t task_info(task_name_t target_task, task_flavor_t flavor, task_info_t task_info_out, mach_msg_type_number_t *task_info_outCnt) -{ - std::cerr << "task_info(" << target_task << ", " << flavor << ", " << task_info_out << ", " << task_info_outCnt << " = " << *task_info_outCnt << ")" << std::endl; - - switch (flavor) - { - case TASK_DYLD_INFO: - { - task_dyld_info_t dyld_info = (task_dyld_info_t)task_info_out; - dyld_info->all_image_info_addr = (mach_vm_address_t)&dyld_all_image_infos; - dyld_info->all_image_info_size = sizeof(dyld_all_image_infos); - - if (sizeof(void*) == 8) - dyld_info->all_image_info_format = TASK_DYLD_ALL_IMAGE_INFO_64; - else - dyld_info->all_image_info_format = TASK_DYLD_ALL_IMAGE_INFO_32; - - break; - } - default: - // TODO: get the requested info flavor. For now, just zero the provided buffer - for (int i=0; i<*task_info_outCnt; i++) - { - task_info_out[i] = 0; - } - break; - } - - return KERN_SUCCESS; -} - - diff --git a/src/libSystem/kernel-mach/task.h b/src/libSystem/kernel-mach/task.h deleted file mode 100644 index 7487fdbdb..000000000 --- a/src/libSystem/kernel-mach/task.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef MACH_TASK_H -#define MACH_TASK_H -#include -#include - -struct darwin_task -{ - darwin_task(pid_t p) : pid(p) {} - pid_t pid; -}; - -typedef darwin_task* darwin_task_t; - -typedef unsigned int natural_t; -typedef int integer_t; - -typedef natural_t mach_port_name_t; -typedef mach_port_name_t mach_port_t; -typedef mach_port_t ipc_space_t; -typedef natural_t mach_port_right_t; -typedef integer_t mach_port_delta_t; -typedef mach_port_t task_name_t; -typedef natural_t task_flavor_t; -typedef integer_t *task_info_t; -typedef natural_t mach_msg_type_number_t; -typedef mach_port_t vm_map_t; -typedef uint64_t mach_vm_address_t; -typedef uint64_t mach_vm_size_t; -typedef int *vm_region_recurse_info_t; - -#ifdef __cplusplus -extern "C" -{ -#endif - extern darwin_task_t mach_task_self_; - inline darwin_task_t mach_task_self() { return mach_task_self_; } - kern_return_t mach_port_deallocate(darwin_task_t task, void* port); - kern_return_t pid_for_task(mach_port_name_t t, int *pid); - kern_return_t mach_port_mod_refs(ipc_space_t task, mach_port_name_t name, mach_port_right_t right, mach_port_delta_t delta); - kern_return_t task_info(task_name_t target_task, task_flavor_t flavor, task_info_t task_info_out, mach_msg_type_number_t *task_info_outCnt); - - // mach_vm.h - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/libSystem/kernel-mach/thread.cpp b/src/libSystem/kernel-mach/thread.cpp deleted file mode 100644 index f249de116..000000000 --- a/src/libSystem/kernel-mach/thread.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "thread.h" -#include -#include -#include -#include -#include "../libc/pthread.h" - -kern_return_t thread_info(thread_act_t target_act, thread_flavor_t flavor, void* infoOut, mach_msg_type_number_t* count) -{ - if (!infoOut || !count) - return KERN_INVALID_ARGUMENT; - - switch (flavor) - { - case THREAD_IDENTIFIER_INFO: - { - std::stringstream ss; - std::ifstream fs; - std::string procpath; - thread_identifier_info* info = static_cast(infoOut); - - if (*count < THREAD_IDENTIFIER_INFO_COUNT) - return KERN_NO_SPACE; - *count = THREAD_IDENTIFIER_INFO_COUNT; - - //info->thread_handle = Darling::tidForPthread(pthread_t(target_act)); - info->thread_handle = target_act; - info->dispatch_qaddr = 0; - info->thread_id = info->thread_handle; - - ss << "/proc/" << getpid() << "/task/" << info->thread_handle << "/stat"; - procpath = ss.str(); - fs.open(procpath.c_str(), std::ios_base::in); - - if (fs.is_open()) - { - uint64_t dummy; - for (int i = 0; i < 22; i++) - fs >> dummy; - info->thread_id = info->thread_handle << 32; - info->thread_id |= dummy & 0xffffffff; // OR thread start time into lower 32 bits - } - - return KERN_SUCCESS; - } - case THREAD_BASIC_INFO: - return KERN_FAILURE; - default: - return KERN_INVALID_ARGUMENT; - } -} - diff --git a/src/libSystem/kernel-mach/thread.h b/src/libSystem/kernel-mach/thread.h deleted file mode 100644 index 3064be7c9..000000000 --- a/src/libSystem/kernel-mach/thread.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef THREAD_H -#define THREAD_H -#include -#include "task.h" - -#define THREAD_BASIC_INFO 3 -#define THREAD_IDENTIFIER_INFO 4 - -typedef natural_t thread_act_t; -typedef natural_t thread_flavor_t; - -struct thread_identifier_info -{ - uint64_t thread_id; - uint64_t thread_handle; - uint64_t dispatch_qaddr; -}; - -#define THREAD_IDENTIFIER_INFO_COUNT (sizeof(struct thread_identifier_info) / sizeof(natural_t)) - -#ifdef __cplusplus -extern "C" { -#endif - -kern_return_t thread_info(thread_act_t target_act, thread_flavor_t flavor, void* infoOut, mach_msg_type_number_t* count); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/src/libSystem/kernel-mach/time.cpp b/src/libSystem/kernel-mach/time.cpp deleted file mode 100644 index 534e45832..000000000 --- a/src/libSystem/kernel-mach/time.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "config.h" -#include "time.h" -#include -#include - -uint64_t mach_absolute_time() -{ - timespec ts; - if (clock_gettime(CLOCK_MONOTONIC_RAW, &ts) == -1) - return 0; - else - return ts.tv_nsec * 1000000000ll + ts.tv_nsec; -} - -int mach_timebase_info(struct mach_timebase_info* info) -{ - info->numer = 1; - info->denom = 1; // we provide nanoseconds - return KERN_SUCCESS; -} diff --git a/src/libSystem/kernel-mach/time.h b/src/libSystem/kernel-mach/time.h deleted file mode 100644 index a2217ebd3..000000000 --- a/src/libSystem/kernel-mach/time.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef MACH_TIME_H -#define MACH_TIME_H -#include -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -uint64_t mach_absolute_time(); -int mach_timebase_info(struct mach_timebase_info* info); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/libSystem/kernel-mach/vm.cpp b/src/libSystem/kernel-mach/vm.cpp deleted file mode 100644 index 750a60a12..000000000 --- a/src/libSystem/kernel-mach/vm.cpp +++ /dev/null @@ -1,232 +0,0 @@ -#include "config.h" -#include "vm.h" -#include "task.h" -#include "mach-stub.h" -#include "trace.h" -#include -#include -#include -#include -#include -#include -#include - -static bool memory_readable(const void* ptr, size_t bytes) -{ - int fd = ::open("/dev/null", O_WRONLY); - if (fd == -1) - return false; - - int r = ::write(fd, ptr, bytes); - ::close(fd); - - if (r != bytes) - { - if (errno == EFAULT) - return false; - } - return true; -} - -static bool memory_writable(void* ptr, size_t bytes) -{ - int fd = ::open("/dev/zero", O_RDONLY); - if (fd == -1) - return false; - - int r = ::read(fd, ptr, bytes); - ::close(fd); - - if (r != bytes) - { - if (errno == EFAULT) - return false; - } - return true; -} - -kern_return_t vm_msync(vm_task_t target_task, void* addr, vm_size_t size, vm_sync_t in_flags) -{ - TRACE4(target_task, addr, size, in_flags); - CHECK_TASK_SELF(target_task); - - int flags = 0; - if (in_flags & VM_SYNC_SYNCHRONOUS) - flags |= MS_SYNC; - if (in_flags & VM_SYNC_ASYNCHRONOUS) - flags |= MS_ASYNC; - if (in_flags & VM_SYNC_INVALIDATE) - flags |= MS_INVALIDATE; - - if (::msync(addr, size, flags) == -1) - return KERN_INVALID_ADDRESS; - else - return KERN_SUCCESS; -} - -kern_return_t vm_allocate(vm_task_t target_task, void** addr, vm_size_t size, boolean_t anywhere) -{ - TRACE4(target_task, addr, size, anywhere); - CHECK_TASK_SELF(target_task); - - int flags = MAP_ANONYMOUS|MAP_PRIVATE; - - if (!anywhere) - flags |= MAP_FIXED; - - // Give the memory all permissions, as per vm_allocate definition - *addr = ::mmap(*addr, size, PROT_EXEC|PROT_READ|PROT_WRITE, flags, 0, 0); - - if (!*addr) - { - if (errno == EINVAL) - return KERN_INVALID_ADDRESS; - else - return KERN_NO_SPACE; // No other return values are permitted - } - else - return KERN_SUCCESS; -} - -kern_return_t vm_deallocate(vm_task_t target_task, void* addr, vm_size_t size) -{ - TRACE3(target_task, addr, size); - CHECK_TASK_SELF(target_task); - - if (::munmap(addr, size) == -1) - return KERN_INVALID_ADDRESS; - else - return KERN_SUCCESS; -} - -kern_return_t vm_copy(vm_task_t target_task, const void* source_address, vm_size_t count, void* dest_address) -{ - TRACE4(target_task, source_address, count, dest_address); - CHECK_TASK_SELF(target_task); - - if (!memory_readable(source_address, count)) - return KERN_INVALID_ADDRESS; - if (!memory_writable(dest_address, count)) - return KERN_INVALID_ADDRESS; - - ::memcpy(dest_address, source_address, count); - return KERN_SUCCESS; -} - -kern_return_t vm_write(vm_task_t target_task, void* address, const void* data, vm_size_t data_count) -{ - TRACE4(target_task, address, data, data_count); - CHECK_TASK_SELF(target_task); - - if (!memory_writable(address, data_count)) - return KERN_INVALID_ADDRESS; - if (!memory_readable(data, data_count)) - return KERN_INVALID_ADDRESS; - - ::memcpy(address, data, data_count); - return KERN_SUCCESS; -} - -kern_return_t vm_behavior_set (vm_task_t target_task, void* address, vm_size_t size, vm_behavior_t behavior) -{ - CHECK_TASK_SELF(target_task); - MACH_STUB(); -} - -kern_return_t vm_inherit (vm_task_t target_task, void* address, vm_size_t size, vm_inherit_t new_inheritance) -{ - CHECK_TASK_SELF(target_task); - MACH_STUB(); -} - -kern_return_t vm_machine_attribute(vm_task_t target_task, void* address, vm_size_t size, vm_machine_attribute_t attribute, vm_machine_attribute_val_t value) -{ - CHECK_TASK_SELF(target_task); - MACH_STUB(); -} - -kern_return_t vm_map(vm_task_t target_task, void* address, vm_size_t size, void* mask, boolean_t anywhere, memory_object_t memory_object, vm_offset_t offset, - boolean_t copy, vm_prot_t cur_protection, vm_prot_t max_protection, vm_inherit_t inheritance) -{ - CHECK_TASK_SELF(target_task); - MACH_STUB(); -} - -kern_return_t vm_protect(vm_task_t target_task, void* address, vm_size_t size, boolean_t set_maximum, vm_prot_t new_protection) -{ - TRACE5(target_task, address, size, set_maximum, new_protection); - CHECK_TASK_SELF(target_task); - - // FIXME: Here we ignore set_maximum, not sure what to do with that - int flags = 0; - - if (new_protection & VM_PROT_READ) - flags |= PROT_READ; - if (new_protection & VM_PROT_WRITE) - flags |= PROT_WRITE; - if (new_protection & VM_PROT_EXECUTE) - flags |= PROT_EXEC; - - if (::mprotect(address, size, flags) == -1) - { - if (errno == EACCES) - return KERN_PROTECTION_FAILURE; - else if (errno == EINVAL || errno == ENOMEM) - return KERN_INVALID_ADDRESS; - else - return KERN_FAILURE; - } - else - return KERN_SUCCESS; -} - -kern_return_t vm_read(vm_task_t target_task, const void* address, vm_size_t size, void** data_out, natural_t* data_count) -{ - TRACE5(target_task, address, size, data_out, data_count); - CHECK_TASK_SELF(target_task); - - if (!memory_readable(address, size)) - return KERN_INVALID_ADDRESS; - - kern_return_t ret = vm_allocate(mach_task_self_, data_out, size, true); - if (ret != KERN_SUCCESS) - return ret; - - ::memcpy(*data_out, address, size); - *data_count = size; // Is this correct? - - return KERN_SUCCESS; -} - -kern_return_t vm_read_overwrite (vm_task_t target_task, void* address, vm_size_t size, void* data_in, natural_t* data_count) -{ - CHECK_TASK_SELF(target_task); - MACH_STUB(); -} - -kern_return_t vm_region(vm_task_t target_task, void* address, vm_size_t size, vm_region_flavor_t flavor, vm_region_info_t info, mach_msg_type_number_t info_count, memory_object_name_t object_name) -{ - CHECK_TASK_SELF(target_task); - MACH_STUB(); -} - -kern_return_t vm_remap(vm_task_t target_task, void* target_address, vm_size_t size, void* mask, boolean_t anywhere, mach_port_t source_task, void* source_address, boolean_t copy, - vm_prot_t cur_protection, vm_prot_t max_protection, vm_inherit_t inheritance) -{ - CHECK_TASK_SELF(target_task); - MACH_STUB(); -} - -kern_return_t vm_wire(host_priv_t host, vm_task_t target_task, void* address, vm_size_t size, vm_prot_t wired_access) -{ - CHECK_TASK_SELF(target_task); - MACH_STUB(); -} - -kern_return_t mach_vm_region_recurse(vm_task_t target_task, void *address, vm_size_t *size, natural_t *nesting_depth, void* info, mach_msg_type_number_t *infoCnt) -{ - // TODO: browse /proc/$pid/maps - *infoCnt = 0; - return KERN_SUCCESS; -} - diff --git a/src/libSystem/kernel-mach/vm.h b/src/libSystem/kernel-mach/vm.h deleted file mode 100644 index 66d112082..000000000 --- a/src/libSystem/kernel-mach/vm.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef MACH_VM_H -#define MACH_VM_H -#include "task.h" -#include "host.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -typedef darwin_task_t vm_task_t; - -kern_return_t vm_msync(vm_task_t target_task, void* addr, vm_size_t size, vm_sync_t in_flags); -kern_return_t vm_allocate(vm_task_t target_task, void** addr, vm_size_t size, boolean_t anywhere); -kern_return_t vm_deallocate(vm_task_t target_task, void* addr, vm_size_t size); -kern_return_t vm_copy(vm_task_t target_task, const void* source_address, vm_size_t count, void* dest_address); -kern_return_t vm_write(vm_task_t target_task, void* address, const void* data, vm_size_t data_count); -kern_return_t vm_behavior_set (vm_task_t target_task, void* address, vm_size_t size, vm_behavior_t behavior); -kern_return_t vm_inherit (vm_task_t target_task, void* address, vm_size_t size, vm_inherit_t new_inheritance); -kern_return_t vm_machine_attribute(vm_task_t target_task, void* address, vm_size_t size, vm_machine_attribute_t attribute, vm_machine_attribute_val_t value); - -kern_return_t vm_map(vm_task_t target_task, void* address, vm_size_t size, void* mask, boolean_t anywhere, memory_object_t memory_object, vm_offset_t offset, - boolean_t copy, vm_prot_t cur_protection, vm_prot_t max_protection, vm_inherit_t inheritance); - -kern_return_t vm_protect(vm_task_t target_task, void* address, vm_size_t size, boolean_t set_maximum, vm_prot_t new_protection); - -kern_return_t vm_read(vm_task_t target_task, const void* address, vm_size_t size, void** data_out, natural_t* data_count); - -kern_return_t vm_read_overwrite (vm_task_t target_task, void* address, vm_size_t size, void* data_in, natural_t* data_count); - -kern_return_t vm_region(vm_task_t target_task, void* address, vm_size_t size, vm_region_flavor_t flavor, vm_region_info_t info, mach_msg_type_number_t info_count, memory_object_name_t object_name); - -kern_return_t vm_remap(vm_task_t target_task, void* target_address, vm_size_t size, void* mask, boolean_t anywhere, mach_port_t source_task, void* source_address, boolean_t copy, - vm_prot_t cur_protection, vm_prot_t max_protection, vm_inherit_t inheritance); - -kern_return_t vm_wire(host_priv_t host, vm_task_t target_task, void* address, vm_size_t size, vm_prot_t wired_access); -kern_return_t mach_vm_region_recurse(vm_task_t target_task, void *address, vm_size_t *size, natural_t *nesting_depth, void* info, mach_msg_type_number_t *infoCnt); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif diff --git a/src/libSystem/keymgr/keymgr.c b/src/libSystem/keymgr/keymgr.c deleted file mode 100644 index 90f3ea0c5..000000000 --- a/src/libSystem/keymgr/keymgr.c +++ /dev/null @@ -1,584 +0,0 @@ -/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 Apple Computer, Inc. - Copyright (C) 1997, 2001 Free Software Foundation, Inc. - -This file is part of KeyMgr. - -KeyMgr is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 2, or (at your option) any later -version. - -In addition to the permissions in the GNU General Public License, -Apple Computer and the Free Software Foundation gives you unlimited -permission to link the compiled version of this file into combinations -with other programs, and to distribute those combinations without any -restriction coming from the use of this file. (The General Public -License restrictions do apply in other respects; for example, they -cover modification of the file, and distribution when not linked into -a combine executable.) - -KeyMgr is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with KeyMgr; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. */ - -/* The FSF-copyright part is the definition of 'struct - old_object'. It was taken from unwind-dw2-fde.h from GCC 3.1. */ - -/* - * keymgr - Create and maintain process-wide global data known to - * all threads across all dynamic libraries. - * - */ - -/* #include */ -#include -#include -#include -#include -#include "../libc/OSAtomic.h" -#include -#include "keymgr.h" - -/* On x86 or later platforms, there's no need to support the TLS SPIs. - The only reason to support them on ppc64 is because the tools - shipped with Tiger included a libsupc++.a which used these - functions. (To do: investigate whether anyone ever actually used - that library for ppc64.) */ -#if defined(__ppc__) || defined(__ppc64__) -#define WANT_TLS_SPIS 1 -#endif - -#ifndef ESUCCESS -#define ESUCCESS 0 -#endif - -/* Types of node, used for error checking. */ -typedef enum node_kinds { - NODE_PROCESSWIDE_PTR=1, -#ifdef WANT_TLS_SPIS - NODE_THREAD_SPECIFIC_DATA -#endif -} TnodeKind; - -/* These values are internal; the subflags of NM_ENHANCED_LOCKING are - defined in keymgr.h and are not internal. */ -enum { - NM_ENHANCED_LOCKING=3 -}; - -/* Base node kind for keymgr node list; also used to represent per - thread variables (NODE_THREAD_SPECIFIC_DATA). */ - -typedef struct Skey_data { - struct Skey_data * next; - unsigned int handle; /* Key id of variable. */ - unsigned char node_kind; /* What kind of variable is this? */ - unsigned char flags; /* Flags controlling behavior of variable. */ - unsigned short refcount; /* If recursion has been enabled, reference - count. */ - void *ptr; /* Data associated with variable. */ - pthread_mutex_t thread_lock; /* Semaphore for this specific variable. */ -} Tkey_Data; - -typedef struct Sinfo_Node { - unsigned int size; /* Size of this node. */ - unsigned short major_version; /* API major version. */ - unsigned short minor_version; /* API minor version. */ -} Tinfo_Node; - -/* Static variables for initial __keymgr_global values. */ - -static const Tinfo_Node keymgr_info = { - sizeof (Tinfo_Node), - KEYMGR_API_REV_MAJOR, - KEYMGR_API_REV_MINOR -}; - -/* __keymgr_global - contains pointers to keymgr data that needs to be - global and known across all dlls/plugins. */ -struct { - /* Formerly, a pthreads semaphore for accessing the keymgr global data. - Now unused. */ - void *unused; - - /* Pointer to keymgr global list. This pointer was previously - contained in __eh_global_dataptr. */ - Tkey_Data * volatile keymgr_globals; - - /* Pointer to keymgr information node. This is part of the semi-public - ABI of keymgr. */ - const Tinfo_Node *keymgr_info; -} __attribute__((aligned (32))) __keymgr_global = { - NULL, - NULL, - &keymgr_info -}; - -#if defined(__ppc__) -/* Initialize keymgr. */ - -void _init_keymgr (void) -{ - /* This routine is now empty, but is part of keymgr's ABI on ppc and - so can't be completely removed. */ -} -#endif - -/* Find any Tkey_Data associated with KEY. If none exists, or KIND - does not match, return NULL. */ - -static Tkey_Data * -get_key_element (unsigned int key, TnodeKind kind) -{ - Tkey_Data *keyArray; - - for (keyArray = __keymgr_global.keymgr_globals; - keyArray != NULL; - keyArray = keyArray->next) - if (keyArray->handle == key) - { - if (keyArray->node_kind == kind) - return keyArray; - else - return NULL; - } - - return NULL; -} - -/* Find any Tkey_Data associated with KEY. If none exists, create one - and add it to the list. Put it in *RESULT. - - On success, return 0, otherwise: - [EINVAL] The node existed but was not of type KIND. - [ENOMEM] Out of memory, couldn't create node. - [EAGAIN] The mutex associated with the new node couldn't be created. - This can only happen when KIND == NODE_PROCESSWIDE_PTR. - - The aims of this routine are: - - - After execution, there should be exactly one element in the list - with HANDLE set to KEY. - - The pointer to that element should be returned in *RESULT. - - In addition, we know that: - - - The list only has elements added, never removed, and they are - always added to the head of the list. -*/ - -static int -get_or_create_key_element (unsigned int key, TnodeKind kind, - Tkey_Data **result) -{ - Tkey_Data *searchEnd = NULL; - Tkey_Data *newEntry = NULL; - - for (;;) - { - Tkey_Data *keyArrayStart = __keymgr_global.keymgr_globals; - Tkey_Data *keyArray; - - /* At this point, we know that we have not searched the elements - between keyArrayStart and searchEnd, but we have previously searched - searchEnd (if not NULL) and all the elements after it. */ - - for (keyArray = keyArrayStart; - keyArray != searchEnd; - keyArray = keyArray->next) - if (keyArray->handle == key) - { - /* Found an existing entry for KEY. Free any new entry we - created in a previous pass through the loop. */ - if (newEntry) - { - if (kind == NODE_PROCESSWIDE_PTR) - /* This call should never fail. */ - if (pthread_mutex_destroy (&newEntry->thread_lock) - != ESUCCESS) - abort (); - free (newEntry); - } - - if (keyArray->node_kind != kind) - return EINVAL; - *result = keyArray; - return ESUCCESS; - } - - /* At this point, we know that there is no entry after keyArrayStart - which matches KEY. We will try to add one. */ - - if (! newEntry) - { - /* Create the new entry. */ - newEntry = (Tkey_Data *) malloc (sizeof (Tkey_Data)); - if (newEntry == NULL) - return ENOMEM; - - if (kind == NODE_PROCESSWIDE_PTR) - { - pthread_mutexattr_t attr; - int errnum; - - newEntry->refcount = 0; - newEntry->flags = 0; - - errnum = pthread_mutexattr_init (&attr); - if (errnum == ESUCCESS) - { - pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_ERRORCHECK); - errnum = pthread_mutex_init (&newEntry->thread_lock, &attr); - pthread_mutexattr_destroy (&attr); - } - if (errnum != ESUCCESS) - { - free (newEntry); - return errnum; - } - } - - newEntry->handle = key; - newEntry->ptr = NULL; - newEntry->node_kind = kind; - } - - /* The compare-and-swap will succeed only if the list head is - keyArrayStart, and we are prepending newEntry onto the list, - so the next element after newEntry should be keyArrayStart. */ - - newEntry->next = keyArrayStart; - - /* The barrier is necessary to ensure that newEntry->next is seen - to be set by any thread that sees newEntry in the list. */ - - /* If the compare-and-swap succeeds, it means that the head of - the list did not change between the search above and the - store of newEntry. Therefore, since we searched all the - elements from the head at that time, we can be sure that the - entry we're adding is not in the list. */ -#ifdef __LP64__ - if (OSAtomicCompareAndSwap64Barrier ( - (int64_t) keyArrayStart, - (int64_t) newEntry, - (int64_t *) &__keymgr_global.keymgr_globals)) -#else - if (OSAtomicCompareAndSwap32Barrier ( - (int32_t) keyArrayStart, - (int32_t) newEntry, - (int32_t *) &__keymgr_global.keymgr_globals)) -#endif - { - *result = newEntry; - return ESUCCESS; - } - /* Another thread changed the list. The entries between - keyArrayStart and searchEnd were searched above, so now we - can stop searching at keyArrayStart. We know we will make - progress in the next loop iteration because the new searchEnd - will not be equal to __keymgr_global.keymgr_globals and so we - will search at least one new element. Since the list can - have at most one element for each valid key, eventually there - will be no more elements to search and so we will stop reaching - this point and looping. */ - searchEnd = keyArrayStart; - } -} - -#ifdef WANT_TLS_SPIS -/* Return the data associated with KEY for the current thread. - Return NULL if there is no such data. */ - -void * -_keymgr_get_per_thread_data (unsigned int key) -{ - Tkey_Data * keyArray; - void * key_data; - - keyArray = get_key_element (key, NODE_THREAD_SPECIFIC_DATA); - - /* If the element hasn't been set, the answer is always NULL. */ - if (keyArray == NULL) - return NULL; - - /* On all platforms we run on, a pointer-sized load from an aligned - address is atomic. */ - key_data = keyArray->ptr; - - /* key_data might be NULL if this entry is in the process of being - created. In that case, return NULL. */ - if (key_data == NULL) - return NULL; - - return pthread_getspecific ((pthread_key_t) key_data); -} - -/* Set the data for KEY for this thread to be KEYDATA. Return 0 on success, - or: - - [ENOMEM] Out of memory. - [EINVAL] The KEY was previously used to store process-wide data. - [EAGAIN] The system lacked the necessary resources to create - another thread-specific data key, or the system- imposed - limit on the total number of keys per process - [PTHREAD_KEYS_MAX] would be exceeded. This error can't - happen after the first successful call to - _keymgr_set_per_thread_data from a particular thread with - a particular KEY. -*/ - -int -_keymgr_set_per_thread_data (unsigned int key, void *keydata) -{ - volatile Tkey_Data * keyArray; - pthread_key_t pthread_key; - void *ptr; - int errnum; - - errnum = get_or_create_key_element (key, NODE_THREAD_SPECIFIC_DATA, - (Tkey_Data **)&keyArray); - if (errnum != ESUCCESS) - return errnum; - - /* This routine doesn't lock *keyArray. Instead, it relies on the - fact that keyArray->ptr is either NULL or a valid pthread key value, - and it only changes once, from NULL to a valid value. */ - - ptr = keyArray->ptr; - if (ptr == NULL) - { - void (*destructor)(void *); - bool neededInit; - - switch (key) - { - case KEYMGR_EH_CONTEXT_KEY: - case KEYMGR_EH_GLOBALS_KEY: - destructor = free; - break; - default: - destructor = NULL; - break; - } - if ((errnum = pthread_key_create (&pthread_key, destructor)) != 0) - return errnum; - -#ifdef __LP64__ - neededInit = OSAtomicCompareAndSwap64 ((int64_t) NULL, - (int64_t) pthread_key, - (int64_t *) &keyArray->ptr); -#else - neededInit = OSAtomicCompareAndSwap32 ((int32_t) NULL, - (int32_t) pthread_key, - (int32_t *) &keyArray->ptr); -#endif - if (!neededInit) - pthread_key_delete (pthread_key); - ptr = keyArray->ptr; - } - pthread_key = (pthread_key_t) ptr; - - return pthread_setspecific (pthread_key, keydata); -} -#endif /* WANT_TLS_SPIS */ - - -/* - * These routines provide management of a process wide, thread safe, - * persistent pointer. If a pointer is created by a bundle/plug-in - * and placed in here, it will persist for the life of the process, - * even after the bundle has been unloaded. This is especially useful - * for data shared across plugins and across repeated plugin loads and - * unloads. - */ - -/* Get the processwide data associated with KEY into *RESULT, - and lock a lock associated with KEY. - - On success, return 0, otherwise: - - [EINVAL] KEY was previously used to store thread-specific data. - [ENOMEM] Out of memory, couldn't create node. - [EAGAIN] The mutex associated with the new node couldn't be created. - [EDEADLK] A deadlock would occur if the thread blocked waiting - for the lock. -*/ - -int -_keymgr_get_and_lock_processwide_ptr_2 (unsigned int key, void ** result) -{ - Tkey_Data *keyArray; - int errnum; - - errnum = get_or_create_key_element (key, NODE_PROCESSWIDE_PTR, &keyArray); - if (errnum != ESUCCESS) - return errnum; - - if ((errnum = pthread_mutex_lock (&keyArray->thread_lock)) != ESUCCESS) - return errnum; - - keyArray->refcount++; - *result = keyArray->ptr; - return ESUCCESS; -} - -/* For backwards compatibility; like _keymgr_get_and_lock_processwide_ptr_2 - but returns the pointer or NULL on error. */ - -void * -_keymgr_get_and_lock_processwide_ptr (unsigned int key) -{ - void *result = NULL; - _keymgr_get_and_lock_processwide_ptr_2 (key, &result); - return result; -} - -/* Unlock the lock associated with NODE. Return 0 on success. - Returns EPERM if the lock is not locked by the current thread. */ - -static int -unlock_node (Tkey_Data *node) -{ - int result; - - node->refcount--; - result = pthread_mutex_unlock (&node->thread_lock); - if (result != ESUCCESS) - node->refcount++; - return result; -} - -/* Set the processwide data associated with KEY to PTR, and unlock - the lock associated with KEY. - - On success, returns 0. On failure, returns: - - [EINVAL] KEY was previously used to store thread-specific data. - [ENOMEM] Out of memory, couldn't create node. - [EAGAIN] The mutex associated with the new node couldn't be created. - [EPERM] The lock was not locked by the current thread. -*/ - -int -_keymgr_set_and_unlock_processwide_ptr (unsigned int key, void *ptr) -{ - Tkey_Data *keyArray; - int result; - - result = get_or_create_key_element (key, NODE_PROCESSWIDE_PTR, &keyArray); - if (result != ESUCCESS) - return result; - - keyArray->ptr = ptr; - return unlock_node (keyArray); -} - -/* Unlock the lock associated with KEY. - - On success, returns 0. On failure, returns: - - [EINVAL] KEY was not previously used to store process-specific data. - [EPERM] The lock was not locked by the current thread. -*/ - -int -_keymgr_unlock_processwide_ptr (unsigned int key) -{ - Tkey_Data *keyArray; - - keyArray = get_key_element (key, NODE_PROCESSWIDE_PTR); - if (keyArray == NULL) - return EINVAL; - - return unlock_node (keyArray); -} - -/* Set the locking mode of KEY to MODE. This should not be done while - KEY is locked or another thread might be using KEY. - - On success, returns 0. On failure, returns: - [EINVAL] KEY was previously used to store thread-specific data. - [ENOMEM] Out of memory. - [EBUSY] The mutex associated with the node was locked. -*/ - -int -_keymgr_set_lockmode_processwide_ptr (unsigned int key, unsigned int mode) -{ - Tkey_Data *keyArray; - pthread_mutexattr_t attr; - int type; - int result; - - result = get_or_create_key_element (key, NODE_PROCESSWIDE_PTR, &keyArray); - if (result != ESUCCESS) - return result; - - if (mode == keyArray->flags) - return ESUCCESS; - - result = pthread_mutexattr_init (&attr); - if (result != ESUCCESS) - return result; - - if (mode == NM_ALLOW_RECURSION) - type = PTHREAD_MUTEX_RECURSIVE; - else - type = PTHREAD_MUTEX_ERRORCHECK; - pthread_mutexattr_settype (&attr, type); - - /* Delete the old mutex and create a new one. */ - result = pthread_mutex_destroy (&keyArray->thread_lock); - /* Apple's implementation of pthread_mutex_init can't fail in this - situation. */ - if (result == ESUCCESS) - result = pthread_mutex_init (&keyArray->thread_lock, &attr); - - pthread_mutexattr_destroy (&attr); - - if (result == ESUCCESS) - keyArray->flags = mode; - return result; -} - -/* Returns the locking mode of the lock associated with KEY, if any, - or 0 if there is no such lock. */ - -unsigned int -_keymgr_get_lockmode_processwide_ptr (unsigned int key) -{ - Tkey_Data *keyArray; - - keyArray = get_key_element (key, NODE_PROCESSWIDE_PTR); - if (keyArray == NULL) - return 0; - return keyArray->flags; -} - -/* Return the number of locks on KEY. To call this routine safely, - you should be holding one of them, thus 0 is an error return. */ - -int -_keymgr_get_lock_count_processwide_ptr (unsigned int key) -{ - Tkey_Data *keyArray; - - keyArray = get_key_element (key, NODE_PROCESSWIDE_PTR); - if (keyArray == NULL) - return 0; - return keyArray->refcount; -} - -/*********************************************/ -/* dummy */ - -void __keymgr_dwarf2_register_sections(void) -{ -} - diff --git a/src/libSystem/keymgr/keymgr.h b/src/libSystem/keymgr/keymgr.h deleted file mode 100644 index 9990d3eee..000000000 --- a/src/libSystem/keymgr/keymgr.h +++ /dev/null @@ -1,125 +0,0 @@ -/* Copyright (C) 1999, 2000, 2001, 2002, 2003 Apple Computer, Inc. - -This file is part of KeyMgr. - -KeyMgr is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 2, or (at your option) any later -version. - -In addition to the permissions in the GNU General Public License, -Apple Computer gives you unlimited permission to link the compiled -version of this file into combinations with other programs, and to -distribute those combinations without any restriction coming from the -use of this file. (The General Public License restrictions do apply -in other respects; for example, they cover modification of the file, -and distribution when not linked into a combine executable.) - -KeyMgr is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with KeyMgr; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. */ - -#ifndef __KEYMGR_H -#define __KEYMGR_H - -#ifdef __cplusplus -extern "C" { -#endif - - - -/* - * keymgr - Create and maintain process-wide global data known to - * all threads across all dynamic libraries. - * - */ - -enum { - NM_ALLOW_RECURSION = 1, - NM_RECURSION_ILLEGAL = 2 -}; - -extern void * _keymgr_get_per_thread_data (unsigned int key); -extern int _keymgr_set_per_thread_data (unsigned int key, void *keydata); -extern void *_keymgr_get_and_lock_processwide_ptr (unsigned int key); -extern int _keymgr_get_and_lock_processwide_ptr_2 (unsigned int key, void **); -extern int _keymgr_set_and_unlock_processwide_ptr (unsigned int key, - void *ptr); -extern int _keymgr_unlock_processwide_ptr (unsigned int key); -extern int _keymgr_set_lockmode_processwide_ptr (unsigned int key, - unsigned int mode); -extern unsigned int _keymgr_get_lockmode_processwide_ptr (unsigned int key); -extern int _keymgr_get_lock_count_processwide_ptr (unsigned int key); - -/* - * Keys currently in use: - */ - -/* Head pointer of exception context node. */ -#define KEYMGR_EH_CONTEXT_KEY 1 - -/* New handler. */ -#define KEYMGR_NEW_HANDLER_KEY 2 - -/* Unexpected exception handler. */ -#define KEYMGR_UNEXPECTED_HANDLER_KEY 3 - -/* Terminate handler. */ -#define KEYMGR_TERMINATE_HANDLER_KEY 4 - -/* Runtime mode bits. */ -#define KEYMGR_MODE_BITS 5 - -/* Head pointer of the list of open streams. */ -#define KEYMGR_IO_LIST 6 - -/* libstdc++ for GCC 2.95 stdin. */ -#define KEYMGR_IO_STDIN 7 - -/* libstdc++ for GCC 2.95 stdout. */ -#define KEYMGR_IO_STDOUT 8 - -/* libstdc++ for GCC 2.95 stdout. */ -#define KEYMGR_IO_STDERR 9 - -/* Number of plugins/main program currently using streams in GCC 2.95. */ -#define KEYMGR_IO_REFCNT 10 - -/* Flags controlling the behavior of C++ I/O. */ -#define KEYMGR_IO_MODE_BITS 11 - -/* Head pointer for list of per image dwarf2 unwind sections. */ -#define KEYMGR_ZOE_IMAGE_LIST 12 - -/* C++ runtime EH global data. */ -#define KEYMGR_EH_GLOBALS_KEY 13 - -/* atexit() and __cxa_atexit routine list. */ -#define KEYMGR_ATEXIT_LIST 14 - -/* KeyMgr 3.x is the first one supporting GCC3 stuff natively. */ -#define KEYMGR_API_MAJOR_GCC3 3 -/* ... with these keys. */ -#define KEYMGR_GCC3_LIVE_IMAGE_LIST 301 /* loaded images */ -#define KEYMGR_GCC3_DW2_OBJ_LIST 302 /* Dwarf2 object list */ - -/* - * Other important data. - */ - -/* Major revision number of the keymgr API. */ -#define KEYMGR_API_REV_MAJOR 5 -/* Minor revision number of the keymgr API. */ -#define KEYMGR_API_REV_MINOR 0 - -#ifdef __cplusplus -} -#endif - -#endif /* __KEYMGR_H */ diff --git a/src/libSystem/libc/OSAtomic.cpp b/src/libSystem/libc/OSAtomic.cpp deleted file mode 100644 index c0e629fe5..000000000 --- a/src/libSystem/libc/OSAtomic.cpp +++ /dev/null @@ -1,246 +0,0 @@ -#include "OSAtomic.h" -#include "libc-stub.h" -#include -#include -#include - -int32_t OSAtomicAdd32(int32_t theAmount, volatile int32_t *theValue) -{ - return __sync_add_and_fetch(theValue, theAmount); -} - -int32_t OSAtomicAdd32Barrier(int32_t theAmount, volatile int32_t *theValue) -{ - return __sync_add_and_fetch(theValue, theAmount); -} - -int32_t OSAtomicIncrement32(volatile int32_t *theValue) -{ - return OSAtomicAdd32(1, theValue); -} - -int32_t OSAtomicIncrement32Barrier(volatile int32_t *theValue) -{ - return OSAtomicAdd32Barrier(1, theValue); -} - -int32_t OSAtomicDecrement32(volatile int32_t *theValue) -{ - return OSAtomicAdd32(-1, theValue); -} - -int32_t OSAtomicDecrement32Barrier(volatile int32_t *theValue) -{ - return OSAtomicAdd32Barrier(-1, theValue); -} - -int32_t OSAtomicOr32(uint32_t theMask, volatile uint32_t *theValue) -{ - return __sync_or_and_fetch(theValue, theMask); -} - -int32_t OSAtomicOr32Barrier(uint32_t theMask, volatile uint32_t *theValue) -{ - return __sync_or_and_fetch(theValue, theMask); -} - -int32_t OSAtomicAnd32(uint32_t theMask, volatile uint32_t *theValue) -{ - return __sync_and_and_fetch(theValue, theMask); -} - -int32_t OSAtomicAnd32Barrier(uint32_t theMask, volatile uint32_t *theValue) -{ - return __sync_and_and_fetch(theValue, theMask); -} - -int32_t OSAtomicXor32(uint32_t theMask, volatile uint32_t *theValue) -{ - return __sync_xor_and_fetch(theValue, theMask); -} - -int32_t OSAtomicXor32Barrier(uint32_t theMask, volatile uint32_t *theValue) -{ - return __sync_xor_and_fetch(theValue, theMask); -} - -int32_t OSAtomicOr32Orig(uint32_t theMask, volatile uint32_t *theValue) -{ - return __sync_fetch_and_or(theValue, theMask); -} - -int32_t OSAtomicOr32OrigBarrier(uint32_t theMask, volatile uint32_t *theValue) -{ - return __sync_fetch_and_or(theValue, theMask); -} - -int32_t OSAtomicAnd32Orig(uint32_t theMask, volatile uint32_t *theValue) -{ - return __sync_fetch_and_and(theValue, theMask); -} - -int32_t OSAtomicAnd32OrigBarrier(uint32_t theMask, volatile uint32_t *theValue) -{ - return __sync_fetch_and_and(theValue, theMask); -} - -int32_t OSAtomicXor32Orig(uint32_t theMask, volatile uint32_t *theValue) -{ - return __sync_fetch_and_xor(theValue, theMask); -} - -int32_t OSAtomicXor32OrigBarrier(uint32_t theMask, volatile uint32_t *theValue) -{ - return __sync_fetch_and_xor(theValue, theMask); -} - -int64_t OSAtomicAdd64(int64_t theAmount, volatile int64_t *theValue) -{ - return __sync_add_and_fetch(theValue, theAmount); -} - -int64_t OSAtomicAdd64Barrier(int64_t theAmount, volatile int64_t *theValue) -{ - return __sync_add_and_fetch(theValue, theAmount); -} - -int64_t OSAtomicIncrement64(volatile int64_t *theValue) -{ - return OSAtomicAdd64(1, theValue); -} - -int64_t OSAtomicIncrement64Barrier(volatile int64_t *theValue) -{ - return OSAtomicAdd64Barrier(1, theValue); -} - -int64_t OSAtomicDecrement64(volatile int64_t *theValue) -{ - return OSAtomicAdd64(-1, theValue); -} - -int64_t OSAtomicDecrement64Barrier(volatile int64_t *theValue) -{ - return OSAtomicAdd64Barrier(-1, theValue); -} - -bool OSAtomicCompareAndSwapInt(int oldValue, int newValue, volatile int *theValue) -{ - return __sync_bool_compare_and_swap(theValue, oldValue, newValue); -} - -bool OSAtomicCompareAndSwapIntBarrier(int oldValue, int newValue, volatile int *theValue) -{ - return __sync_bool_compare_and_swap(theValue, oldValue, newValue); -} - -bool OSAtomicCompareAndSwapLong(long oldValue, long newValue, volatile long *theValue) -{ - return __sync_bool_compare_and_swap(theValue, oldValue, newValue); -} - -bool OSAtomicCompareAndSwapLongBarrier(long oldValue, long newValue, volatile long *theValue) -{ - return __sync_bool_compare_and_swap(theValue, oldValue, newValue); -} - -bool OSAtomicCompareAndSwapPtr(void* oldValue, void* newValue, void* volatile *theValue) -{ - return __sync_bool_compare_and_swap(theValue, oldValue, newValue); -} - -bool OSAtomicCompareAndSwapPtrBarrier(void* oldValue, void* newValue, void* volatile *theValue) -{ - return __sync_bool_compare_and_swap(theValue, oldValue, newValue); -} - -bool OSAtomicCompareAndSwap32(int32_t oldValue, int32_t newValue, volatile int32_t *theValue) -{ - return __sync_bool_compare_and_swap(theValue, oldValue, newValue); -} - -bool OSAtomicCompareAndSwap32Barrier(int32_t oldValue, int32_t newValue, volatile int32_t *theValue) -{ - return __sync_bool_compare_and_swap(theValue, oldValue, newValue); -} - -bool OSAtomicCompareAndSwap64(int64_t oldValue, int64_t newValue, volatile int64_t *theValue) -{ - return __sync_bool_compare_and_swap(theValue, oldValue, newValue); -} - -bool OSAtomicCompareAndSwap64Barrier(int64_t oldValue, int64_t newValue, volatile int64_t *theValue) -{ - return __sync_bool_compare_and_swap(theValue, oldValue, newValue); -} - -bool OSAtomicTestAndSet(uint32_t n, volatile void *theAddress) -{ - LIBC_STUB(); - return false; -} - -bool OSAtomicTestAndSetBarrier(uint32_t n, volatile void *theAddress) -{ - LIBC_STUB(); - return false; -} - -bool OSAtomicTestAndClear(uint32_t n, volatile void *theAddress) -{ - LIBC_STUB(); - return false; -} - -bool OSAtomicTestAndClearBarrier(uint32_t n, volatile void *theAddress) -{ - LIBC_STUB(); - return false; -} - -bool OSSpinLockTry(OSSpinLock *lock) -{ - return __sync_bool_compare_and_swap(lock, 0, 1); -} - -void OSSpinLockLock(OSSpinLock *lock) -{ - // We cannot use pthread spinlocks, these need init and destruction - while (!OSSpinLockTry(lock)) - sched_yield(); -} - -void OSSpinLockUnlock(OSSpinLock *lock) -{ - bool success = __sync_bool_compare_and_swap(lock, 1, 0); - assert(success); // Will fail if spinlock wasn't locked -} - -// http://i.stack.imgur.com/FSBA3.png -void OSAtomicEnqueue(OSQueueHead *list, void *_new, size_t offset) -{ - /* - long* newNext = reinterpret_cast(reinterpret_cast(_new) + offset); - *newNext = 0; - - // If the queue is not empty - if (!__sync_bool_compare_and_swap(list->p, 0, _new)) - { - void* prevTop = __sync_lock_test_and_set(list->p, _new); - *newNext = prevTop; // FIXME: this place may cause races with OSAtomicDequeue - } - */ - LIBC_STUB(); -} - -void* OSAtomicDequeue(OSQueueHead *list, size_t offset) -{ - LIBC_STUB(); - return nullptr; -} - -void OSMemoryBarrier() -{ - __atomic_thread_fence(__ATOMIC_SEQ_CST); -} - diff --git a/src/libSystem/libc/OSAtomic.h b/src/libSystem/libc/OSAtomic.h deleted file mode 100644 index 8b2e9ff88..000000000 --- a/src/libSystem/libc/OSAtomic.h +++ /dev/null @@ -1,112 +0,0 @@ -#ifndef OSATOMIC_H -#define OSATOMIC_H -#include -#include - -typedef pthread_spinlock_t OSSpinLock; -struct OSQueueHead -{ - void* p; - long l; -}; - -#ifdef __cplusplus -extern "C" { -#else -#define bool int -#endif - -int32_t OSAtomicAdd32(int32_t theAmount, volatile int32_t *theValue); - -int32_t OSAtomicAdd32Barrier(int32_t theAmount, volatile int32_t *theValue); - -int32_t OSAtomicIncrement32(volatile int32_t *theValue); - -int32_t OSAtomicIncrement32Barrier(volatile int32_t *theValue); - -int32_t OSAtomicDecrement32(volatile int32_t *theValue); - -int32_t OSAtomicDecrement32Barrier(volatile int32_t *theValue); - -int32_t OSAtomicOr32(uint32_t theMask, volatile uint32_t *theValue); - -int32_t OSAtomicOr32Barrier(uint32_t theMask, volatile uint32_t *theValue); - -int32_t OSAtomicAnd32(uint32_t theMask, volatile uint32_t *theValue); - -int32_t OSAtomicAnd32Barrier(uint32_t theMask, volatile uint32_t *theValue); - -int32_t OSAtomicXor32(uint32_t theMask, volatile uint32_t *theValue); - -int32_t OSAtomicXor32Barrier(uint32_t theMask, volatile uint32_t *theValue); - -int32_t OSAtomicOr32Orig(uint32_t theMask, volatile uint32_t *theValue); - -int32_t OSAtomicOr32OrigBarrier(uint32_t theMask, volatile uint32_t *theValue); - -int32_t OSAtomicAnd32Orig(uint32_t theMask, volatile uint32_t *theValue); - -int32_t OSAtomicAnd32OrigBarrier(uint32_t theMask, volatile uint32_t *theValue); - -int32_t OSAtomicXor32Orig(uint32_t theMask, volatile uint32_t *theValue); - -int32_t OSAtomicXor32OrigBarrier(uint32_t theMask, volatile uint32_t *theValue); - -int64_t OSAtomicAdd64(int64_t theAmount, volatile int64_t *theValue); - -int64_t OSAtomicAdd64Barrier(int64_t theAmount, volatile int64_t *theValue); - -int64_t OSAtomicIncrement64(volatile int64_t *theValue); - -int64_t OSAtomicIncrement64Barrier(volatile int64_t *theValue); - -int64_t OSAtomicDecrement64(volatile int64_t *theValue); - -int64_t OSAtomicDecrement64Barrier(volatile int64_t *theValue); - -bool OSAtomicCompareAndSwapInt(int oldValue, int newValue, volatile int *theValue); - -bool OSAtomicCompareAndSwapIntBarrier(int oldValue, int newValue, volatile int *theValue); - -bool OSAtomicCompareAndSwapLong(long oldValue, long newValue, volatile long *theValue); - -bool OSAtomicCompareAndSwapLongBarrier(long oldValue, long newValue, volatile long *theValue); - -bool OSAtomicCompareAndSwapPtr(void* oldValue, void* newValue, void* volatile *theValue); - -bool OSAtomicCompareAndSwapPtrBarrier(void* oldValue, void* newValue, void* volatile *theValue); - -bool OSAtomicCompareAndSwap32(int32_t oldValue, int32_t newValue, volatile int32_t *theValue); - -bool OSAtomicCompareAndSwap32Barrier(int32_t oldValue, int32_t newValue, volatile int32_t *theValue); - -bool OSAtomicCompareAndSwap64(int64_t oldValue, int64_t newValue, volatile int64_t *theValue); - -bool OSAtomicCompareAndSwap64Barrier(int64_t oldValue, int64_t newValue, volatile int64_t *theValue); - -bool OSAtomicTestAndSet(uint32_t n, volatile void *theAddress); - -bool OSAtomicTestAndSetBarrier(uint32_t n, volatile void *theAddress); - -bool OSAtomicTestAndClear(uint32_t n, volatile void *theAddress); - -bool OSAtomicTestAndClearBarrier(uint32_t n, volatile void *theAddress); - -bool OSSpinLockTry(OSSpinLock *lock); - -void OSSpinLockLock(OSSpinLock *lock); - -void OSSpinLockUnlock(OSSpinLock *lock); - -void OSAtomicEnqueue(struct OSQueueHead *list, void *_new, size_t offset); - -void* OSAtomicDequeue(struct OSQueueHead *list, size_t offset); - -void OSMemoryBarrier(); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/src/libSystem/libc/aio.cpp b/src/libSystem/libc/aio.cpp deleted file mode 100644 index 95d6d399e..000000000 --- a/src/libSystem/libc/aio.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "aio.h" -#include "errno.h" -#include "common/path.h" -#include "common/auto.h" - -MAP_FUNCTION1(int,aio_read,struct aiocb*); -MAP_FUNCTION1(int,aio_write,struct aiocb*); - -int __darwin_aio_fsync(int op, struct aiocb *aiocbp) -{ - int rv = aio_fsync(op, aiocbp); - if (rv > 0) - rv = errnoLinuxToDarwin(rv); - else if (rv == -1) - errnoOut(); - return rv; -} - -int __darwin_aio_error(const struct aiocb *aiocbp) -{ - int rv = aio_error(aiocbp); - if (rv > 0) - rv = errnoLinuxToDarwin(rv); - else if (rv == -1) - errnoOut(); - return rv; -} - -MAP_FUNCTION1(ssize_t,aio_return,struct aiocb*); -MAP_FUNCTION3(int,aio_suspend,const struct aiocb * const*,int,const struct timespec *); - -int __darwin_aio_cancel(int fd, struct aiocb *aiocbp) -{ - int rv = aio_cancel(fd, aiocbp); - if (rv > 0) - rv = errnoLinuxToDarwin(rv); - else if (rv == -1) - errnoOut(); - return rv; -} - -int __darwin_lio_listio(int mode, struct aiocb *const aiocb_list[], int nitems, struct sigevent *sevp) -{ - int rv = lio_listio(mode, aiocb_list, nitems, sevp); - if (rv > 0) - rv = errnoLinuxToDarwin(rv); - else if (rv == -1) - errnoOut(); - return rv; -} - diff --git a/src/libSystem/libc/aio.h b/src/libSystem/libc/aio.h deleted file mode 100644 index b650d0de2..000000000 --- a/src/libSystem/libc/aio.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef LIBC_AIO_H -#define LIBC_AIO_H -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -#define DARWIN_LIO_NOWAIT 0x1 -#define DARWIN_LIO_WAIT 0x2 -#define DARWIN_LIO_NOP 0x0 -#define DARWIN_LIO_READ 0x1 -#define DARWIN_LIO_WRITE 0x2 -#define DARWIN_AIO_ALLDONE 0x1 -#define DARWIN_AIO_CANCELED 0x2 -#define DARWIN_AIO_NOTCANCELED 0x4 - -#ifndef DARWIN_O_SYNC -#define DARWIN_O_SYNC 0x0080 -#define DARWIN_O_DSYNC 0x400000 -#endif - -int __darwin_aio_read(struct aiocb *aiocbp); -int __darwin_aio_write(struct aiocb *aiocbp); -int __darwin_aio_fsync(int op, struct aiocb *aiocbp); // flags -int __darwin_aio_error(const struct aiocb *aiocbp); -ssize_t __darwin_aio_return(struct aiocb *aiocbp); -int __darwin_aio_suspend(const struct aiocb * const aiocb_list[], int nitems, const struct timespec *timeout); -int __darwin_aio_cancel(int fd, struct aiocb *aiocbp); // flags -int __darwin_lio_listio(int mode, struct aiocb *const aiocb_list[], int nitems, struct sigevent *sevp); // flags - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/src/libSystem/libc/arch.cpp b/src/libSystem/libc/arch.cpp deleted file mode 100644 index 7ab359cef..000000000 --- a/src/libSystem/libc/arch.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#include "arch.h" -#include - -// This was dumped on snow leopard. -static NXArchInfo __darwin_all_arch_infos[] = { - // The first entry indicates the local arch. - { "hppa", 11, 0, 2, "HP-PA" }, - { "i386", 7, 3, 1, "Intel 80x86" }, - { "x86_64", 16777223, 3, 1, "Intel x86-64" }, - { "i860", 15, 0, 2, "Intel 860" }, - { "m68k", 6, 1, 2, "Motorola 68K" }, - { "m88k", 13, 0, 2, "Motorola 88K" }, - { "ppc", 18, 0, 2, "PowerPC" }, - { "ppc64", 16777234, 0, 2, "PowerPC 64-bit" }, - { "sparc", 14, 0, 2, "SPARC" }, - { "arm", 12, 0, 1, "ARM" }, - { "any", -1, -1, 0, "Architecture Independent" }, - { "veo", 255, 2, 2, "veo" }, - { "hppa7100LC", 11, 1, 2, "HP-PA 7100LC" }, - { "m68030", 6, 3, 2, "Motorola 68030" }, - { "m68040", 6, 2, 2, "Motorola 68040" }, - { "i486", 7, 4, 1, "Intel 80486" }, - { "i486SX", 7, 132, 1, "Intel 80486SX" }, - { "pentium", 7, 5, 1, "Intel Pentium" }, - { "i586", 7, 5, 1, "Intel 80586" }, - { "pentpro", 7, 22, 1, "Intel Pentium Pro" }, - { "i686", 7, 22, 1, "Intel Pentium Pro" }, - { "pentIIm3", 7, 54, 1, "Intel Pentium II Model 3" }, - { "pentIIm5", 7, 86, 1, "Intel Pentium II Model 5" }, - { "pentium4", 7, 10, 1, "Intel Pentium 4" }, - { "ppc601", 18, 1, 2, "PowerPC 601" }, - { "ppc603", 18, 3, 2, "PowerPC 603" }, - { "ppc603e", 18, 4, 2, "PowerPC 603e" }, - { "ppc603ev", 18, 5, 2, "PowerPC 603ev" }, - { "ppc604", 18, 6, 2, "PowerPC 604" }, - { "ppc604e", 18, 7, 2, "PowerPC 604e" }, - { "ppc750", 18, 9, 2, "PowerPC 750" }, - { "ppc7400", 18, 10, 2, "PowerPC 7400" }, - { "ppc7450", 18, 11, 2, "PowerPC 7450" }, - { "ppc970", 18, 100, 2, "PowerPC 970" }, - { "ppc970-64", 16777234, 100, 2, "PowerPC 970 64-bit" }, - { "armv4t", 12, 5, 1, "arm v4t" }, - { "armv5", 12, 7, 1, "arm v5" }, - { "xscale", 12, 8, 1, "arm xscale" }, - { "armv6", 12, 6, 1, "arm v6" }, - { "armv7", 12, 9, 1, "arm v7" }, - { "little", -1, 0, 1, "Little Endian" }, - { "big", -1, 1, 2, "Big Endian" }, - { "veo1", 255, 1, 2, "veo 1" }, - { "veo2", 255, 2, 2, "veo 2" }, - { NULL, 0, 0, 0, NULL }, -}; - -const NXArchInfo* NXGetAllArchInfos() -{ - return __darwin_all_arch_infos; -} - -const NXArchInfo* NXGetLocalArchInfo() -{ -#if defined(__i386__) - return &__darwin_all_arch_infos[1]; -#elif defined(__x86_64__) - return &__darwin_all_arch_infos[2]; -#elif defined(__arm__) - return &__darwin_all_arch_infos[9]; -#else -# error Unsupported architecture! -#endif -} - -const NXArchInfo* NXGetArchInfoFromName(const char *name) -{ - NXArchInfo* info = __darwin_all_arch_infos; - for (; info->name; info++) - { - if (!strcmp(info->name, name)) - return info; - } - return 0; -} - - diff --git a/src/libSystem/libc/arch.h b/src/libSystem/libc/arch.h deleted file mode 100644 index a66a70cef..000000000 --- a/src/libSystem/libc/arch.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef LIBC_ARCH_H -#define LIBC_ARCH_H -#include - -struct NXArchInfo -{ - const char* name; - int32_t cputype; - int32_t cpusubtype; - int byteorder; - const char* description; -}; - -#ifdef __cplusplus -extern "C" -{ -#endif - -const NXArchInfo* NXGetAllArchInfos(); -const NXArchInfo* NXGetLocalArchInfo(); -const NXArchInfo* NXGetArchInfoFromName(const char *name); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/src/libSystem/libc/attrlist.cpp b/src/libSystem/libc/attrlist.cpp deleted file mode 100644 index fe101f3b8..000000000 --- a/src/libSystem/libc/attrlist.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "attrlist.h" -#include "darwin_errno_codes.h" -#include - -int getattrlist(const char* path, struct attrlist* attrs, void* buf, size_t bufSize, unsigned long options) -{ - errno = DARWIN_ENOTSUP; - return -1; -} - -int setattrlist(const char* path, struct attrlist* attrs, void* buf, size_t bufSize, unsigned long options) -{ - errno = DARWIN_ENOTSUP; - return -1; -} - diff --git a/src/libSystem/libc/attrlist.h b/src/libSystem/libc/attrlist.h deleted file mode 100644 index fe7376171..000000000 --- a/src/libSystem/libc/attrlist.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef LIBC_ATTRLIST_H -#define LIBC_ATTRLIST_H -#include - -#ifdef __cplusplus -extern "C" { -#endif - -int getattrlist(const char* path, struct attrlist* attrs, void* buf, size_t bufSize, unsigned long options); -int setattrlist(const char* path, struct attrlist* attrs, void* buf, size_t bufSize, unsigned long options); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/src/libSystem/libc/confstr.cpp b/src/libSystem/libc/confstr.cpp deleted file mode 100644 index e276b19eb..000000000 --- a/src/libSystem/libc/confstr.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include "config.h" -#include "confstr.h" -#include -#include -#include -#include -#include -#include "darwin_errno_codes.h" - -size_t __darwin_confstr(int name, char* buf, size_t len) -{ - switch (name) - { - case DARWIN__CS_DARWIN_USER_DIR: - { - const char* home = getenv("HOME"); - if (!home) - { - if (len > 0) - *buf = 0; - return 0; - } - else - return strlcpy(buf, home, len) + 1; - } - case DARWIN__CS_DARWIN_USER_TEMP_DIR: - { - const char* tmp = getenv("TMPDIR"); - - if (!tmp) - tmp = "/tmp"; - - return strlcpy(buf, tmp, len) + 1; - } - case DARWIN__CS_DARWIN_USER_CACHE_DIR: - { - std::string cacheDir; - const char* home = getenv("HOME"); - - if (!home) - { - if (len > 0) - *buf = 0; - return 0; - } - - cacheDir = home; - cacheDir += "/.cache"; - - return strlcpy(buf, cacheDir.c_str(), len) + 1; - } - case _CS_PATH: - return confstr(name, buf, len); - default: - errno = DARWIN_EINVAL; - return 0; - } -} diff --git a/src/libSystem/libc/confstr.h b/src/libSystem/libc/confstr.h deleted file mode 100644 index ee6f672fe..000000000 --- a/src/libSystem/libc/confstr.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef CONFSTR_H -#define CONFSTR_H -#include - -extern "C" { - -#define DARWIN__CS_DARWIN_USER_DIR 65536 -#define DARWIN__CS_DARWIN_USER_TEMP_DIR 65537 -#define DARWIN__CS_DARWIN_USER_CACHE_DIR 65538 - -size_t __darwin_confstr(int name, char* buf, size_t len); - -} - -#endif diff --git a/src/libSystem/libc/darwin_errno_codes.h b/src/libSystem/libc/darwin_errno_codes.h deleted file mode 100644 index 382ea6926..000000000 --- a/src/libSystem/libc/darwin_errno_codes.h +++ /dev/null @@ -1,115 +0,0 @@ -#ifndef DARWIN_ERRNO_CODES_H -#define DARWIN_ERRNO_CODES_H - -/* $ awk '/#define[ \t]([A-Z]+)[\t ]+([0-9]+)/ { print "#define DARWIN_" $2 " " $3; }' < errno.h */ - -#define DARWIN_EPERM 1 -#define DARWIN_ENOENT 2 -#define DARWIN_ESRCH 3 -#define DARWIN_EINTR 4 -#define DARWIN_EIO 5 -#define DARWIN_ENXIO 6 -#define DARWIN_ENOEXEC 8 -#define DARWIN_EBADF 9 -#define DARWIN_ECHILD 10 -#define DARWIN_EDEADLK 11 -#define DARWIN_ENOMEM 12 -#define DARWIN_EACCES 13 -#define DARWIN_EFAULT 14 -#define DARWIN_ENOTBLK 15 -#define DARWIN_EBUSY 16 -#define DARWIN_EEXIST 17 -#define DARWIN_EXDEV 18 -#define DARWIN_ENODEV 19 -#define DARWIN_ENOTDIR 20 -#define DARWIN_EISDIR 21 -#define DARWIN_EINVAL 22 -#define DARWIN_ENFILE 23 -#define DARWIN_EMFILE 24 -#define DARWIN_ENOTTY 25 -#define DARWIN_ETXTBSY 26 -#define DARWIN_EFBIG 27 -#define DARWIN_ENOSPC 28 -#define DARWIN_ESPIPE 29 -#define DARWIN_EROFS 30 -#define DARWIN_EMLINK 31 -#define DARWIN_EPIPE 32 -#define DARWIN_EDOM 33 -#define DARWIN_ERANGE 34 -#define DARWIN_EAGAIN 35 -#define DARWIN_EINPROGRESS 36 -#define DARWIN_EALREADY 37 -#define DARWIN_ENOTSOCK 38 -#define DARWIN_EDESTADDRREQ 39 -#define DARWIN_EMSGSIZE 40 -#define DARWIN_EPROTOTYPE 41 -#define DARWIN_ENOPROTOOPT 42 -#define DARWIN_EPROTONOSUPPORT 43 -#define DARWIN_ESOCKTNOSUPPORT 44 -#define DARWIN_ENOTSUP 45 -#define DARWIN_EPFNOSUPPORT 46 -#define DARWIN_EAFNOSUPPORT 47 -#define DARWIN_EADDRINUSE 48 -#define DARWIN_EADDRNOTAVAIL 49 -#define DARWIN_ENETDOWN 50 -#define DARWIN_ENETUNREACH 51 -#define DARWIN_ENETRESET 52 -#define DARWIN_ECONNABORTED 53 -#define DARWIN_ECONNRESET 54 -#define DARWIN_ENOBUFS 55 -#define DARWIN_EISCONN 56 -#define DARWIN_ENOTCONN 57 -#define DARWIN_ESHUTDOWN 58 -#define DARWIN_ETOOMANYREFS 59 -#define DARWIN_ETIMEDOUT 60 -#define DARWIN_ECONNREFUSED 61 -#define DARWIN_ELOOP 62 -#define DARWIN_ENAMETOOLONG 63 -#define DARWIN_EHOSTDOWN 64 -#define DARWIN_EHOSTUNREACH 65 -#define DARWIN_ENOTEMPTY 66 -#define _DARWIN_EPROCLIM 67 -#define DARWIN_EUSERS 68 -#define DARWIN_EDQUOT 69 -#define DARWIN_ESTALE 70 -#define DARWIN_EREMOTE 71 -#define _DARWIN_EBADRPC 72 -#define _DARWIN_ERPCMISMATCH 73 -#define _DARWIN_EPROGUNAVAIL 74 -#define _DARWIN_EPROGMISMATCH 75 -#define _DARWIN_EPROCUNAVAIL 76 -#define DARWIN_ENOLCK 77 -#define DARWIN_ENOSYS 78 -#define _DARWIN_EFTYPE 79 -#define _DARWIN_EAUTH 80 -#define _DARWIN_ENEEDAUTH 81 -#define _DARWIN_EPWROFF 82 -#define _DARWIN_EDEVERR 83 -#define DARWIN_EOVERFLOW 84 -#define _DARWIN_EBADEXEC 85 -#define _DARWIN_EBADARCH 86 -#define _DARWIN_ESHLIBVERS 87 -#define _DARWIN_EBADMACHO 88 -#define DARWIN_ECANCELED 89 -#define DARWIN_EIDRM 90 -#define DARWIN_ENOMSG 91 -#define DARWIN_EILSEQ 92 -#define _DARWIN_ENOATTR 93 -#define DARWIN_EBADMSG 94 -#define DARWIN_EMULTIHOP 95 -#define DARWIN_ENODATA 96 -#define DARWIN_ENOLINK 97 -#define DARWIN_ENOSR 98 -#define DARWIN_ENOSTR 99 -#define DARWIN_EPROTO 100 -#define DARWIN_ETIME 101 -#define DARWIN_EOPNOTSUPP 102 -#define _DARWIN_ENOPOLICY 103 -#define DARWIN_ENOTRECOVERABLE 104 -#define DARWIN_EOWNERDEAD 105 -#define _DARWIN_EQFULL 106 -#define _DARWIN_ELAST 106 -#define _DARWIN_ECVCERORR 256 -#define _DARWIN_ECVPERORR 512 - -#endif diff --git a/src/libSystem/libc/darwin_to_linux.map b/src/libSystem/libc/darwin_to_linux.map deleted file mode 100644 index a2d3761f8..000000000 --- a/src/libSystem/libc/darwin_to_linux.map +++ /dev/null @@ -1,87 +0,0 @@ -darwin_to_linux[DARWIN_EPERM] = EPERM; -darwin_to_linux[DARWIN_ENOENT] = ENOENT; -darwin_to_linux[DARWIN_ESRCH] = ESRCH; -darwin_to_linux[DARWIN_EINTR] = EINTR; -darwin_to_linux[DARWIN_EIO] = EIO; -darwin_to_linux[DARWIN_ENXIO] = ENXIO; -darwin_to_linux[DARWIN_ENOEXEC] = ENOEXEC; -darwin_to_linux[DARWIN_EBADF] = EBADF; -darwin_to_linux[DARWIN_ECHILD] = ECHILD; -darwin_to_linux[DARWIN_EDEADLK] = EDEADLK; -darwin_to_linux[DARWIN_ENOMEM] = ENOMEM; -darwin_to_linux[DARWIN_EACCES] = EACCES; -darwin_to_linux[DARWIN_EFAULT] = EFAULT; -darwin_to_linux[DARWIN_ENOTBLK] = ENOTBLK; -darwin_to_linux[DARWIN_EBUSY] = EBUSY; -darwin_to_linux[DARWIN_EEXIST] = EEXIST; -darwin_to_linux[DARWIN_EXDEV] = EXDEV; -darwin_to_linux[DARWIN_ENODEV] = ENODEV; -darwin_to_linux[DARWIN_ENOTDIR] = ENOTDIR; -darwin_to_linux[DARWIN_EISDIR] = EISDIR; -darwin_to_linux[DARWIN_EINVAL] = EINVAL; -darwin_to_linux[DARWIN_ENFILE] = ENFILE; -darwin_to_linux[DARWIN_EMFILE] = EMFILE; -darwin_to_linux[DARWIN_ENOTTY] = ENOTTY; -darwin_to_linux[DARWIN_ETXTBSY] = ETXTBSY; -darwin_to_linux[DARWIN_EFBIG] = EFBIG; -darwin_to_linux[DARWIN_ENOSPC] = ENOSPC; -darwin_to_linux[DARWIN_ESPIPE] = ESPIPE; -darwin_to_linux[DARWIN_EROFS] = EROFS; -darwin_to_linux[DARWIN_EMLINK] = EMLINK; -darwin_to_linux[DARWIN_EPIPE] = EPIPE; -darwin_to_linux[DARWIN_EDOM] = EDOM; -darwin_to_linux[DARWIN_ERANGE] = ERANGE; -darwin_to_linux[DARWIN_EAGAIN] = EAGAIN; -darwin_to_linux[DARWIN_EINPROGRESS] = EINPROGRESS; -darwin_to_linux[DARWIN_EALREADY] = EALREADY; -darwin_to_linux[DARWIN_ENOTSOCK] = ENOTSOCK; -darwin_to_linux[DARWIN_EDESTADDRREQ] = EDESTADDRREQ; -darwin_to_linux[DARWIN_EMSGSIZE] = EMSGSIZE; -darwin_to_linux[DARWIN_EPROTOTYPE] = EPROTOTYPE; -darwin_to_linux[DARWIN_ENOPROTOOPT] = ENOPROTOOPT; -darwin_to_linux[DARWIN_EPROTONOSUPPORT] = EPROTONOSUPPORT; -darwin_to_linux[DARWIN_ESOCKTNOSUPPORT] = ESOCKTNOSUPPORT; -darwin_to_linux[DARWIN_ENOTSUP] = ENOTSUP; -darwin_to_linux[DARWIN_EPFNOSUPPORT] = EPFNOSUPPORT; -darwin_to_linux[DARWIN_EAFNOSUPPORT] = EAFNOSUPPORT; -darwin_to_linux[DARWIN_EADDRINUSE] = EADDRINUSE; -darwin_to_linux[DARWIN_EADDRNOTAVAIL] = EADDRNOTAVAIL; -darwin_to_linux[DARWIN_ENETDOWN] = ENETDOWN; -darwin_to_linux[DARWIN_ENETUNREACH] = ENETUNREACH; -darwin_to_linux[DARWIN_ENETRESET] = ENETRESET; -darwin_to_linux[DARWIN_ECONNABORTED] = ECONNABORTED; -darwin_to_linux[DARWIN_ECONNRESET] = ECONNRESET; -darwin_to_linux[DARWIN_ENOBUFS] = ENOBUFS; -darwin_to_linux[DARWIN_EISCONN] = EISCONN; -darwin_to_linux[DARWIN_ENOTCONN] = ENOTCONN; -darwin_to_linux[DARWIN_ESHUTDOWN] = ESHUTDOWN; -darwin_to_linux[DARWIN_ETOOMANYREFS] = ETOOMANYREFS; -darwin_to_linux[DARWIN_ETIMEDOUT] = ETIMEDOUT; -darwin_to_linux[DARWIN_ECONNREFUSED] = ECONNREFUSED; -darwin_to_linux[DARWIN_ELOOP] = ELOOP; -darwin_to_linux[DARWIN_ENAMETOOLONG] = ENAMETOOLONG; -darwin_to_linux[DARWIN_EHOSTDOWN] = EHOSTDOWN; -darwin_to_linux[DARWIN_EHOSTUNREACH] = EHOSTUNREACH; -darwin_to_linux[DARWIN_ENOTEMPTY] = ENOTEMPTY; -darwin_to_linux[DARWIN_EUSERS] = EUSERS; -darwin_to_linux[DARWIN_EDQUOT] = EDQUOT; -darwin_to_linux[DARWIN_ESTALE] = ESTALE; -darwin_to_linux[DARWIN_EREMOTE] = EREMOTE; -darwin_to_linux[DARWIN_ENOLCK] = ENOLCK; -darwin_to_linux[DARWIN_ENOSYS] = ENOSYS; -darwin_to_linux[DARWIN_EOVERFLOW] = EOVERFLOW; -darwin_to_linux[DARWIN_ECANCELED] = ECANCELED; -darwin_to_linux[DARWIN_EIDRM] = EIDRM; -darwin_to_linux[DARWIN_ENOMSG] = ENOMSG; -darwin_to_linux[DARWIN_EILSEQ] = EILSEQ; -darwin_to_linux[DARWIN_EBADMSG] = EBADMSG; -darwin_to_linux[DARWIN_EMULTIHOP] = EMULTIHOP; -darwin_to_linux[DARWIN_ENODATA] = ENODATA; -darwin_to_linux[DARWIN_ENOLINK] = ENOLINK; -darwin_to_linux[DARWIN_ENOSR] = ENOSR; -darwin_to_linux[DARWIN_ENOSTR] = ENOSTR; -darwin_to_linux[DARWIN_EPROTO] = EPROTO; -darwin_to_linux[DARWIN_ETIME] = ETIME; -darwin_to_linux[DARWIN_EOPNOTSUPP] = EOPNOTSUPP; -darwin_to_linux[DARWIN_ENOTRECOVERABLE] = ENOTRECOVERABLE; -darwin_to_linux[DARWIN_EOWNERDEAD] = EOWNERDEAD; diff --git a/src/libSystem/libc/dir.cpp b/src/libSystem/libc/dir.cpp deleted file mode 100644 index 0a03a60fe..000000000 --- a/src/libSystem/libc/dir.cpp +++ /dev/null @@ -1,308 +0,0 @@ -#include "config.h" -#include "dir.h" -#include "trace.h" -#include "errno.h" -#include "trace.h" -#include "common/auto.h" -#include "common/path.h" -#include -#include -#include -#include -#include "darwin_errno_codes.h" - -static darwin_dirent* convertDirent(const struct dirent* ent); -static darwin_dirent64* convertDirent64(const struct dirent* ent); - -darwin_dirent64* __darwin_readdir64(DIR* dirp) -{ - TRACE1(dirp); - struct dirent* linux_buf = readdir(dirp); - if (!linux_buf) - { - errnoOut(); - return 0; - } - - //TRACE() << ARG(dirp) << linux_buf->d_name; - - return convertDirent64(linux_buf); -} - -darwin_dirent* __darwin_readdir(DIR* dirp) -{ - TRACE1(dirp); - struct dirent* linux_buf = readdir(dirp); - if (!linux_buf) - { - errnoOut(); - return 0; - } - - return convertDirent(linux_buf); -} - -template -int __darwin_readdir_r_generic(DIR *dirp, EntType *entry, EntType **result, ConvType convFunc) -{ - struct dirent ent; - struct dirent* native_result; - int rv; - - if (!result || !entry) - { - errno = DARWIN_EINVAL; - return -1; - } - - rv = readdir_r(dirp, &ent, &native_result); - - if (rv != 0) - { - errnoOut(); - return rv; - } - - if (!native_result) - *result = nullptr; - else - { - *entry = *convFunc(&ent); - *result = entry; - } - - return rv; -} - -int __darwin_readdir_r(DIR *dirp, struct darwin_dirent *entry, struct darwin_dirent **result) -{ - return __darwin_readdir_r_generic(dirp, entry, result, convertDirent); -} - -int __darwin_readdir_r64(DIR *dirp, struct darwin_dirent64 *entry, struct darwin_dirent64 **result) -{ - return __darwin_readdir_r_generic(dirp, entry, result, convertDirent64); -} - -darwin_dirent* convertDirent(const struct dirent* linux_buf) -{ - static __thread darwin_dirent mac; - - mac.d_ino = linux_buf->d_ino; - mac.d_reclen = linux_buf->d_reclen; - -#ifdef _DIRENT_HAVE_D_TYPE - mac.d_type = linux_buf->d_type; -#else - mac.d_type = DT_UNKNOWN; -#endif - - mac.d_namlen = strlen(linux_buf->d_name); - strcpy(mac.d_name, linux_buf->d_name); - - return &mac; -} - -darwin_dirent64* convertDirent64(const struct dirent* linux_buf) -{ - static __thread darwin_dirent64 mac; - - mac.d_ino = linux_buf->d_ino; - mac.d_reclen = linux_buf->d_reclen; - -#ifdef _DIRENT_HAVE_D_TYPE - mac.d_type = linux_buf->d_type; -#else - mac.d_type = DT_UNKNOWN; -#endif - mac.d_namlen = strlen(linux_buf->d_name); -#ifdef _DIRENT_HAVE_D_OFF - mac.d_seekoff = linux_buf->d_off; -#else - mac.d_seekoff = 0; -#endif - - strcpy(mac.d_name, linux_buf->d_name); - return &mac; -} - -DIR* __darwin_opendir(const char *name) -{ - TRACE1(name); - - if (Darling::MachOMgr::instance()->hasSysRoot()) - { - const char* prefixed; - std::string lpath = Darling::MachOMgr::instance()->sysRoot(); - - lpath += '/'; - lpath += name; - - prefixed = translatePathCI(lpath.c_str()); - - if (::access(prefixed, F_OK) == 0) - name = prefixed; - else - name = translatePathCI(name); - } - else - name = translatePathCI(name); - - DIR* rv = opendir(name); - if (!rv) - errnoOut(); - return rv; -} - -MAP_FUNCTION1(DIR*, fdopendir, int); -MAP_FUNCTION1(int, closedir, DIR*); -MAP_FUNCTION4(ssize_t, getdirentries, int, char*, size_t, off_t*); - -// scandir impl - -static __thread int (*orig_filter)(const struct darwin_dirent *) = 0; -static __thread int (*orig_compar)(const struct darwin_dirent **, const struct darwin_dirent **) = 0; -static __thread int (*orig_filter64)(const struct darwin_dirent64 *) = 0; -static __thread int (*orig_compar64)(const struct darwin_dirent64 **, const struct darwin_dirent64 **) = 0; - -static int native_filter(const struct dirent* e) -{ - darwin_dirent* ee = convertDirent(e); - return orig_filter(ee); -} - -static int native_compar(const struct dirent** a, const struct dirent** b) -{ - darwin_dirent xa, xb; - darwin_dirent *aa, *bb; - aa = &xa; - bb = &xb; - xa = *convertDirent(*a); - xb = *convertDirent(*b); - - return orig_compar(const_cast(&aa), const_cast(&bb)); -} - -static int native_filter64(const struct dirent* e) -{ - darwin_dirent64* ee = convertDirent64(e); - return orig_filter64(ee); -} - -static int native_compar64(const struct dirent** a, const struct dirent** b) -{ - darwin_dirent64 xa, xb; - darwin_dirent64 *aa, *bb; - aa = &xa; - bb = &xb; - xa = *convertDirent64(*a); - xb = *convertDirent64(*b); - - return orig_compar64(const_cast(&aa), const_cast(&bb)); -} - -int __darwin_scandir(const char *dirp, struct darwin_dirent ***namelist, - int (*filter)(const struct darwin_dirent *), - int (*compar)(const struct darwin_dirent **, const struct darwin_dirent **)) -{ - struct dirent** nl; - - *namelist = 0; - orig_filter = filter; - orig_compar = compar; - - int (*my_filter)(const struct dirent *) = 0; - - if (filter) - my_filter = native_filter; - - int rv = scandir(translatePathCI(dirp), &nl, my_filter, native_compar); - if (rv == -1) - { - errnoOut(); - return -1; - } - else - { - *namelist = reinterpret_cast(malloc(rv * sizeof(struct darwin_dirent*))); - for (int i = 0; i < rv; i++) - { - (*namelist)[i] = reinterpret_cast(malloc(sizeof(struct darwin_dirent))); - *(*namelist)[i] = *convertDirent(nl[i]); - free(nl[i]); - } - free(nl); - return rv; - } -} - -int __darwin_scandir64(const char *dirp, struct darwin_dirent64 ***namelist, - int (*filter)(const struct darwin_dirent64 *), - int (*compar)(const struct darwin_dirent64 **, const struct darwin_dirent64 **)) -{ - struct dirent** nl; - - *namelist = 0; - orig_filter64 = filter; - orig_compar64 = compar; - - int (*my_filter)(const struct dirent *) = 0; - - if (filter) - my_filter = native_filter; - - int rv = scandir(translatePathCI(dirp), &nl, my_filter, native_compar); - if (rv == -1) - { - errnoOut(); - return -1; - } - else - { - *namelist = reinterpret_cast(malloc(rv * sizeof(struct darwin_dirent64*))); - for (int i = 0; i < rv; i++) - { - (*namelist)[i] = reinterpret_cast(malloc(sizeof(struct darwin_dirent64))); - *(*namelist)[i] = *convertDirent64(nl[i]); - free(nl[i]); - } - free(nl); - return rv; - } -} - -template int darwin_sortconv(const void *a, const void *b, Func f) -{ - const T** aa = reinterpret_cast(const_cast(a)); - const T** bb = reinterpret_cast(const_cast(b)); - struct dirent na, nb; - struct dirent *pna, *pnb; - - pna = &na; - pnb = &nb; - - strcpy(pna->d_name, (*aa)->d_name); - strcpy(pnb->d_name, (*bb)->d_name); - - return f(const_cast(&pna), const_cast(&pnb)); -} - -int __darwin_alphasort(const void *a, const void *b) -{ - return darwin_sortconv(a, b, alphasort); -} - -int __darwin_alphasort64(const void *a, const void *b) -{ - return darwin_sortconv(a, b, alphasort); -} - -int __darwin_versionsort(const void *a, const void *b) -{ - return darwin_sortconv(a, b, versionsort); -} - -int __darwin_versionsort64(const void *a, const void *b) -{ - return darwin_sortconv(a, b, versionsort); -} diff --git a/src/libSystem/libc/dir.h b/src/libSystem/libc/dir.h deleted file mode 100644 index efc6db4fa..000000000 --- a/src/libSystem/libc/dir.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef LIBC_DIR_H -#define LIBC_DIR_H -#include "common/path.h" -#include -#include -#include - -struct darwin_dirent64 -{ - uint64_t d_ino; - uint64_t d_seekoff; - uint16_t d_reclen; - uint16_t d_namlen; - uint8_t d_type; - char d_name[DARWIN_MAXPATHLEN]; -}; - -#pragma pack(4) -struct darwin_dirent { - uint32_t d_ino; - uint16_t d_reclen; - uint8_t d_type; - uint8_t d_namlen; - char d_name[DARWIN_MAXNAMLEN + 1]; -}; -#pragma pack() - -#ifdef __cplusplus -extern "C" -{ -#endif - -darwin_dirent64* __darwin_readdir64(DIR* dirp) asm("__darwin_readdir$INODE64"); -darwin_dirent* __darwin_readdir(DIR* dirp); -int __darwin_readdir_r(DIR *dirp, struct darwin_dirent *entry, struct darwin_dirent **result); -int __darwin_readdir_r64(DIR *dirp, struct darwin_dirent64 *entry, struct darwin_dirent64 **result) asm("__darwin_readdir_r$INODE64"); - -DIR* __darwin_opendir(const char *name); // opendir$INODE64 in aliases -// DIR* __darwin_fdopendir(int fd); // not present on Darwin -int __darwin_closedir(DIR *dirp); - -int __darwin_scandir(const char *dirp, struct darwin_dirent ***namelist, - int (*filter)(const struct darwin_dirent *), - int (*compar)(const struct darwin_dirent **, const struct darwin_dirent **)); -int __darwin_scandir64(const char *dirp, struct darwin_dirent64 ***namelist, - int (*filter)(const struct darwin_dirent64 *), - int (*compar)(const struct darwin_dirent64 **, const struct darwin_dirent64 **)) asm("__darwin_scandir$INODE64"); - -// dirfs is compatible (no errors) -// rewinddir is compatible (no errors) -// seekdir is compatible -// getdirentries macro-mapped - -// alphasort -// versionsort - -int __darwin_alphasort(const void *a, const void *b); -int __darwin_alphasort64(const void *a, const void *b) asm("__darwin_alphasort$INODE64"); - -int __darwin_versionsort(const void *a, const void *b); -int __darwin_versionsort64(const void *a, const void *b) asm("__darwin_versionsort$INODE64"); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/libSystem/libc/err.c b/src/libSystem/libc/err.c deleted file mode 100644 index 411115753..000000000 --- a/src/libSystem/libc/err.c +++ /dev/null @@ -1,323 +0,0 @@ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _GNU_SOURCE -# define _GNU_SOURCE -#endif - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)err.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ -#include -//__FBSDID("$FreeBSD: src/lib/libc/gen/err.c,v 1.15 2008/04/03 20:36:44 imp Exp $"); - -//#include "namespace.h" -#include "err.h" -#include -#include -#include -#include -#include -#include "errno.h" -//#include -//#include "un-namespace.h" - -#ifdef __BLOCKS__ -#include -#endif /* __BLOCKS__ */ -//#include "libc_private.h" - -#define ERR_EXIT_UNDEF 0 -#ifdef __BLOCKS__ -#define ERR_EXIT_BLOCK 1 -#endif /* __BLOCKS__ */ -#define ERR_EXIT_FUNC 2 -struct _e_err_exit { - unsigned int type; -#ifdef __BLOCKS__ - union { -#endif /* __BLOCKS__ */ - void (*func)(int); -#ifdef __BLOCKS__ - void (^block)(int); - }; -#endif /* __BLOCKS__ */ -}; - -#define __private_extern__ static -#ifdef BUILDING_VARIANT - -__private_extern__ FILE *_e_err_file; /* file to use for error output */ -__private_extern__ struct _e_err_exit _e_err_exit; -__private_extern__ void _e_visprintf(FILE * __restrict, const char * __restrict, va_list); - -#else /* !BUILDING_VARIANT */ - -__private_extern__ FILE *_e_err_file = NULL; /* file to use for error output */ -__private_extern__ struct _e_err_exit _e_err_exit = {ERR_EXIT_UNDEF}; - -/* - * zero means pass as is - * 255 means use \nnn (octal) - * otherwise use \x (x is value) - * (NUL isn't used) - */ -static unsigned char escape[256] = { - /* NUL */ - 0, /* Unused: strings can't contain nulls */ - /* SOH STX ETX EOT ENQ ACK BEL */ - 255, 255, 255, 255, 255, 255, 'a', - /* BS HT NL VT NP CR SO SI */ - 'b', 0, 0, 'v', 'f', 'r', 255, 255, - /* DLE DC1 DC2 DC3 DC4 NAK SYN ETB */ - 255, 255, 255, 255, 255, 255, 255, 255, - /* CAN EM SUB ESC FS GS RS US */ - 255, 255, 255, 255, 255, 255, 255, 255, - /* the rest are zero */ -}; - -/* - * Make characters visible. If we can't allocate enough - * memory, we fall back on vfprintf(). - */ -__private_extern__ void -_e_visprintf(FILE * __restrict stream, const char * __restrict format, va_list ap) -{ - int failed = 0; - char *str, *visstr; - va_list backup; - - va_copy(backup, ap); - vasprintf(&str, format, ap); - if (str != NULL) { - if ((visstr = malloc(4 * strlen(str) + 1)) != NULL) { - unsigned char *fp = (unsigned char *)str; - unsigned char *tp = (unsigned char *)visstr; - while(*fp) { - switch(escape[*fp]) { - case 0: - *tp++ = *fp; - break; - case 255: - sprintf((char *)tp, "\\%03o", *fp); - tp += 4; - break; - default: - *tp++ = '\\'; - *tp++ = escape[*fp]; - break; - } - fp++; - } - *tp = 0; - fputs(visstr, stream); - free(visstr); - } else - failed = 1; - free(str); - } else - failed = 1; - if (failed) - vfprintf(stream, format, backup); - va_end(backup); -} - -/* - * This is declared to take a `void *' so that the caller is not required - * to include first. However, it is really a `FILE *', and the - * manual page documents it as such. - */ -void -__darwin_err_set_file(void *fp) -{ - if (fp) - _e_err_file = fp; - else - _e_err_file = stderr; -} - -void -__darwin_err_set_exit(void (*ef)(int)) -{ - _e_err_exit.type = ERR_EXIT_FUNC; - _e_err_exit.func = ef; -} - -#ifdef __BLOCKS__ -void -__darwin_err_set_exit_b(void (^ef)(int)) -{ - _e_err_exit.type = ERR_EXIT_BLOCK; - _e_err_exit.block = Block_copy(ef); -} -#endif /* __BLOCKS__ */ -#endif /* !BUILDING_VARIANT */ - -/*__weak_reference(__darwin__err, __darwin_err);*/ - -void -__darwin__err(int eval, const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - __darwin_verrc(eval, errno, fmt, ap); - va_end(ap); -} - -void -__darwin_verr(eval, fmt, ap) - int eval; - const char *fmt; - va_list ap; -{ - __darwin_verrc(eval, errno, fmt, ap); -} - -void -__darwin_errc(int eval, int code, const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - __darwin_verrc(eval, code, fmt, ap); - va_end(ap); -} - -void -__darwin_verrc(int eval, int code, const char *fmt, va_list ap) -{ - code = errnoDarwinToLinux(code); - if (_e_err_file == 0) - __darwin_err_set_file((FILE *)0); - fprintf(_e_err_file, "%s: ", program_invocation_name); - if (fmt != NULL) { - _e_visprintf(_e_err_file, fmt, ap); - fprintf(_e_err_file, ": "); - } - fprintf(_e_err_file, "%s\n", strerror(code)); - if (_e_err_exit.type) - { -#ifdef __BLOCKS__ - if (_e_err_exit.type == ERR_EXIT_BLOCK) - _e_err_exit.block(eval); - else -#endif /* __BLOCKS__ */ - _e_err_exit.func(eval); - } - exit(eval); -} - -void -__darwin_errx(int eval, const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - __darwin_verrx(eval, fmt, ap); - va_end(ap); -} - -void -__darwin_verrx(int eval, const char *fmt, va_list ap) -{ - if (_e_err_file == 0) - __darwin_err_set_file((FILE *)0); - fprintf(_e_err_file, "%s: ", program_invocation_name); - if (fmt != NULL) - _e_visprintf(_e_err_file, fmt, ap); - fprintf(_e_err_file, "\n"); - if (_e_err_exit.type) - { -#ifdef __BLOCKS__ - if (_e_err_exit.type == ERR_EXIT_BLOCK) - _e_err_exit.block(eval); - else -#endif /* __BLOCKS__ */ - _e_err_exit.func(eval); - } - exit(eval); -} - -/* __weak_reference(__darwin__warn, __darwin_warn); */ - -void -__darwin__warn(const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - __darwin_vwarnc(errno, fmt, ap); - va_end(ap); -} - -void -__darwin_vwarn(const char *fmt, va_list ap) -{ - __darwin_vwarnc(errno, fmt, ap); -} - -void -__darwin_arnc(int code, const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - __darwin_vwarnc(code, fmt, ap); - va_end(ap); -} - -void -__darwin_vwarnc(int code, const char *fmt, va_list ap) -{ - code = errnoDarwinToLinux(code); - if (_e_err_file == 0) - __darwin_err_set_file((FILE *)0); - fprintf(_e_err_file, "%s: ", program_invocation_name); - if (fmt != NULL) { - _e_visprintf(_e_err_file, fmt, ap); - fprintf(_e_err_file, ": "); - } - fprintf(_e_err_file, "%s\n", strerror(code)); -} - -void -__darwin_warnx(const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - __darwin_vwarnx(fmt, ap); - va_end(ap); -} - -void -__darwin_vwarnx(const char *fmt, va_list ap) -{ - if (_e_err_file == 0) - __darwin_err_set_file((FILE *)0); - fprintf(_e_err_file, "%s: ", program_invocation_name); - if (fmt != NULL) - _e_visprintf(_e_err_file, fmt, ap); - fprintf(_e_err_file, "\n"); -} diff --git a/src/libSystem/libc/err.h b/src/libSystem/libc/err.h deleted file mode 100644 index 29549c906..000000000 --- a/src/libSystem/libc/err.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef LIBC_ERR_H -#define LIBC_ERR_H -#include - -#ifdef __cplusplus -extern "C" { -#endif - -void __darwin_err(int eval, const char *fmt, ...); - -void -__darwin_err_set_exit(void (*exitf)(int)); - -#ifdef __BLOCKS__ -void -__darwin_err_set_exit_b(void (^exitb)(int)); -#endif - -void -__darwin_err_set_file(void *vfp); - -void -__darwin_errc(int eval, int code, const char *fmt, ...); - -void -__darwin_errx(int eval, const char *fmt, ...); - -void -__darwin_warn(const char *fmt, ...); - -void -__darwin_warnc(int code, const char *fmt, ...); - -void -__darwin_warnx(const char *fmt, ...); - -void -__darwin_verr(int eval, const char *fmt, va_list args); - -void -__darwin_verrc(int eval, int code, const char *fmt, va_list args); - -void -__darwin_verrx(int eval, const char *fmt, va_list args); - -void -__darwin_vwarn(const char *fmt, va_list args); - -void -__darwin_vwarnc(int code, const char *fmt, va_list args); - -void -__darwin_vwarnx(const char *fmt, va_list args); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/src/libSystem/libc/errno.cpp b/src/libSystem/libc/errno.cpp deleted file mode 100644 index a65de0d37..000000000 --- a/src/libSystem/libc/errno.cpp +++ /dev/null @@ -1,97 +0,0 @@ -#include "config.h" -#include -#include -#include -#include -#include -#include "errno.h" -#include "trace.h" -#include "darwin_errno_codes.h" - -static void initErrnoMappingTable() __attribute__ ((constructor)); -static int darwin_to_linux[140]; -static int linux_to_darwin[140]; - -// This is deprecated, we don't bother to support that -extern "C" const char * const __darwin_sys_errlist[0]; -extern "C" const int __darwin_sys_nerr = 0; - -// For a non-gnu version of strerror_r -extern "C" int __xpg_strerror_r (int __errnum, char *__buf, size_t __buflen) - __THROW __nonnull ((2)); - -/* -int* __error() -{ - return &errno; -} -*/ - -int cthread_errno() -{ - return errno; -} - -void initErrnoMappingTable() -{ - ::memset(darwin_to_linux, 0, sizeof(darwin_to_linux)); - ::memset(linux_to_darwin, 0, sizeof(linux_to_darwin)); - -# include "darwin_to_linux.map" -# include "linux_to_darwin.map" - - darwin_to_linux[_DARWIN_EBADEXEC] = ENOEXEC; - darwin_to_linux[_DARWIN_EBADARCH] = ENOEXEC; - darwin_to_linux[_DARWIN_EBADMACHO] = ENOEXEC; -} - -static int errnoDoMap(int err, int* map) -{ - if (err < sizeof(darwin_to_linux)/sizeof(darwin_to_linux[0])-1) - { - int e = map[err]; - if (!e) - e = err; // preserve the original value and hope for the best - return e; - } - else - return 0; -} - -int errnoDarwinToLinux(int err) -{ - return errnoDoMap(err, darwin_to_linux); -} - -int errnoLinuxToDarwin(int err) -{ - return errnoDoMap(err, linux_to_darwin); -} - -char* __darwin_strerror(int errnum) -{ - TRACE1(errnum); - errnum = errnoDarwinToLinux(errnum); - return ::strerror(errnum); -} - -int __darwin_strerror_r(int errnum, char *strerrbuf, size_t buflen) -{ - TRACE() << ARG(errnum) << ARGP(strerrbuf) << ARG(buflen); - errnum = errnoDarwinToLinux(errnum); - return ::__xpg_strerror_r(errnum, strerrbuf, buflen); -} - -void __darwin_perror(const char *s) -{ - TRACE1(s); - // First map the error back - errno = errnoDarwinToLinux(errno); - ::perror(s); - // Now map it back again - errno = errnoLinuxToDarwin(errno); -} - -void errnoOut() { errno = errnoLinuxToDarwin(errno); } -void errnoIn() { errno = errnoDarwinToLinux(errno); } - diff --git a/src/libSystem/libc/errno.h b/src/libSystem/libc/errno.h deleted file mode 100644 index b5fbe4261..000000000 --- a/src/libSystem/libc/errno.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef DARWIN_ERRNO_H -#define DARWIN_ERRNO_H -#include -#include -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -int *__error(); -int cthread_errno(void); - -char* __darwin_strerror(int errnum); -int __darwin_strerror_r(int errnum, char *strerrbuf, size_t buflen); - -int errnoDarwinToLinux(int err); -int errnoLinuxToDarwin(int err); -void errnoOut(); -void errnoIn(); - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/src/libSystem/libc/exec.cpp b/src/libSystem/libc/exec.cpp deleted file mode 100644 index 179ed5471..000000000 --- a/src/libSystem/libc/exec.cpp +++ /dev/null @@ -1,226 +0,0 @@ -#include "config.h" -#include "exec.h" -#include "common/path.h" -#include "libc/darwin_errno_codes.h" -#include "libc/errno.h" -#include "trace.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "MachO.h" - -// FIXME: this will fail when a 32-bit OS X app exec()s a 64-bit OS X app (or vice versa)! -static const char* getSelfPath() -{ - static char selfpath[PATH_MAX]; - - if (!selfpath[0]) - { - int rd = readlink("/proc/self/exe", selfpath, sizeof(selfpath)-1); - if (rd != -1) - selfpath[rd] = 0; - } - - return selfpath; -} - -const char* Darling::findInPath(const char* file) -{ - static __thread char buffer[DARWIN_MAXPATHLEN]; - - if (*file == '/') - return file; - - if (strchr(file, '/') != 0) - { - // No PATH resolution, only fix the case - strcpy(buffer, file); - translatePathCI(buffer); - return buffer; - } - - const char* path = getenv("PATH"); - if (!path) - { - // Get the default path. - size_t len = confstr(_CS_PATH, 0, 0); - char* buf = reinterpret_cast( alloca(len + 1) ); - buf[0] = ':'; - - confstr(_CS_PATH, buf + 1, len); - - path = buf; - } - - const char* p = path; - do - { - const char* end = strchrnul(p, ':'); - size_t len = end-p; - memcpy(buffer, p, len); - if (buffer[len-1] != '/') - buffer[len++] = '/'; - - strcpy(buffer+len, file); - - translatePathCI(buffer); - - if (::access(buffer, X_OK) == 0) - return buffer; - } - while (*p++); - - return 0; -} - -char* const* Darling::prependLoaderPath(char *const argv[], const char* fullMachoPath) -{ - int count = 0; - const char** rv; - - while (argv[count++]); - - rv = new const char*[count+1]; - rv[0] = getSelfPath(); - memcpy(rv+1, argv, count * sizeof(char*)); - - rv[1] = fullMachoPath; - - return const_cast(rv); -} - -int __darwin_execl(const char *path, const char *arg, ...) -{ - TRACE1(path); - - va_list vl; - va_start(vl, arg); - std::vector argv; - char* an_arg; - - argv.push_back(const_cast(arg)); - while ((an_arg = va_arg(vl, char*)) != 0) - argv.push_back(an_arg); - - argv.push_back(0); - va_end(vl); - - return __darwin_execv(path, &argv[0]); -} - -int __darwin_execlp(const char *file, const char *arg, ...) -{ - TRACE1(file); - - va_list vl; - va_start(vl, arg); - std::vector argv; - char* an_arg; - - argv.push_back(const_cast(arg)); - while ((an_arg = va_arg(vl, char*)) != 0) - argv.push_back(an_arg); - - argv.push_back(0); - va_end(vl); - - return __darwin_execvp(file, &argv[0]); -} - -int __darwin_execle(const char *path, const char *arg, ... /*, char * const envp[]*/) -{ - TRACE1(path); - - va_list vl; - va_start(vl, arg); - std::vector argv; - char* an_arg; - char** envp; - - argv.push_back(const_cast(arg)); - while ((an_arg = va_arg(vl, char*)) != 0) - argv.push_back(an_arg); - - argv.push_back(0); - envp = va_arg(vl, char**); - va_end(vl); - - // using an execvpe version, but given the behavior of FindInPath(), it should be OK - return __darwin_execvpe(path, &argv[0], envp); -} - -int __darwin_execv(const char *path, char *const argv[]) -{ - TRACE1(path); - path = translatePathCI(path); - - if (!MachO::isMachO(path)) - { - int rv = execv(path, argv); - errnoOut(); - return rv; - } - else - { - argv = Darling::prependLoaderPath(argv, path); - int rv = execvp(getSelfPath(), argv); // TODO: change to execv? - - LOG << "Executing with loader at " << getSelfPath() << std::endl; - - errnoOut(); - - delete [] argv; - return rv; - } -} - -int __darwin_execvp(const char *file, char *const argv[]) -{ - TRACE1(file); - - const char* path = Darling::findInPath(file); - if (!path) - { - LOG << "Path failed to be located: " << file << std::endl; - errno = DARWIN_ENOENT; - return -1; - } - - return __darwin_execv(path, argv); -} - -int __darwin_execvpe(const char *file, char *const argv[], char *const envp[]) -{ - TRACE1(file); - - const char* path = Darling::findInPath(file); - if (!path) - { - errno = DARWIN_ENOENT; - return -1; - } - - if (!MachO::isMachO(path)) - { - int rv = execv(path, argv); - errnoOut(); - return rv; - } - else - { - argv = Darling::prependLoaderPath(argv, path); - int rv = execvpe(getSelfPath(), argv, envp); - errnoOut(); - - delete [] argv; - return rv; - } -} - diff --git a/src/libSystem/libc/exec.h b/src/libSystem/libc/exec.h deleted file mode 100644 index 8fc967949..000000000 --- a/src/libSystem/libc/exec.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef LIBC_EXEC_H -#define LIBC_EXEC_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -int __darwin_execl(const char *path, const char *arg, ...); -int __darwin_execlp(const char *file, const char *arg, ...); -int __darwin_execle(const char *path, const char *arg, ... /*, char * const envp[]*/); -int __darwin_execv(const char *path, char *const argv[]); -int __darwin_execvp(const char *file, char *const argv[]); -int __darwin_execvpe(const char *file, char *const argv[], char *const envp[]); - -#ifdef __cplusplus -} - -namespace Darling -{ - const char* findInPath(const char* file); - char* const* prependLoaderPath(char *const argv[], const char* fullMachoPath); -} -#endif - -#endif diff --git a/src/libSystem/libc/fopsmisc.cpp b/src/libSystem/libc/fopsmisc.cpp deleted file mode 100644 index f44bf1770..000000000 --- a/src/libSystem/libc/fopsmisc.cpp +++ /dev/null @@ -1,64 +0,0 @@ -#include "config.h" -#include "fopsmisc.h" -#include "errno.h" -#include "darwin_errno_codes.h" -#include "common/path.h" -#include "common/auto.h" -#include "trace.h" -#include -#include - -char *__darwin_realpath(const char *path, char *resolved_path) -{ - TRACE2(path, resolved_path); - bool ownbuf = false; - - if (!path) - { - errno = DARWIN_EINVAL; - return 0; - } - - path = translatePathCI(path); - - if (!resolved_path) // DARWIN_EXTSN - { - ownbuf = true; - resolved_path = static_cast(malloc(DARWIN_MAXPATHLEN)); - } - - char* rv = realpath(path, resolved_path); - if (!rv) - { - if (ownbuf) - free(resolved_path); - errnoOut(); - } - - return rv; -} - -int __darwin_mkstemp(char *tpl) -{ - TRACE1(tpl); - return AutoPathErrno(mkstemp, tpl); -} - -int __darwin_mkostemp (char *tpl, int flags) -{ - TRACE2(tpl, flags); - return AutoPathErrno(mkostemp, tpl, flags); -} - -char *__darwin_mktemp(char *tpl) -{ - TRACE1(tpl); - return AutoPathErrno(mktemp, tpl); -} - -char *__darwin_tempnam(const char *dir, const char *pfx) -{ - TRACE2(dir, pfx); - return AutoPathErrno(tempnam, dir, pfx); -} - diff --git a/src/libSystem/libc/fopsmisc.h b/src/libSystem/libc/fopsmisc.h deleted file mode 100644 index 58393b039..000000000 --- a/src/libSystem/libc/fopsmisc.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef LIBC_FOPSMISC_H -#define LIBC_FOPSMISC_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -char *__darwin_realpath(const char *path, char *resolved_path); -int __darwin_mkstemp(char *tpl); -int __darwin_mkostemp (char *tpl, int flags); -char *__darwin_mktemp(char *tpl); -char *__darwin_tempnam(const char *dir, const char *pfx); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/src/libSystem/libc/getpwent.cpp b/src/libSystem/libc/getpwent.cpp deleted file mode 100644 index 0bbba0578..000000000 --- a/src/libSystem/libc/getpwent.cpp +++ /dev/null @@ -1,95 +0,0 @@ -#include "config.h" -#include "getpwent.h" -#include "darwin_errno_codes.h" -#include -#include -#include -#include -#include -#include "errno.h" - -static void passwdLinuxToDarwin(const struct passwd* in, __darwin_passwd* out) -{ - memset(out, 0, sizeof(*out)); - out->pw_name = in->pw_name; - out->pw_passwd = in->pw_passwd; - out->pw_uid = in->pw_uid; - out->pw_gid = in->pw_gid; - out->pw_gecos = in->pw_gecos; - out->pw_dir = in->pw_dir; - out->pw_shell = in->pw_shell; -} - -static __darwin_passwd* passwdLinuxToDarwin(const struct passwd* in) -{ - if (!in) - return nullptr; - - static __thread __darwin_passwd pwd; - passwdLinuxToDarwin(in, &pwd); - return &pwd; -} - -__darwin_passwd* __darwin_getpwent() -{ - return passwdLinuxToDarwin(getpwent()); -} - -__darwin_passwd* __darwin_getpwnam(const char* login) -{ - return passwdLinuxToDarwin(getpwnam(login)); -} - -template int GenericGet_R(Func f, Param p, struct __darwin_passwd *pwd, - char *buffer, size_t bufsize, struct __darwin_passwd **result) -{ - static_assert(sizeof(struct __darwin_passwd) >= sizeof(struct passwd), "struct passwd is too small on this platform!"); - - int rv = f(p, reinterpret_cast(pwd), buffer, bufsize, reinterpret_cast(result)); - if (rv != 0) - { - return errnoLinuxToDarwin(rv); - } - else - { - if (*result) - { - struct passwd l; - memcpy(&l, *result, sizeof(l)); - passwdLinuxToDarwin(&l, *result); - } - - return 0; - } -} - -int __darwin_getpwnam_r(const char *name, struct __darwin_passwd *pwd, char *buffer, size_t bufsize, struct __darwin_passwd **result) -{ - return GenericGet_R(getpwnam_r, name, pwd, buffer, bufsize, result); -} - -__darwin_passwd* __darwin_getpwuid(uid_t uid) -{ - return passwdLinuxToDarwin(getpwuid(uid)); -} - -int __darwin_getpwuid_r(uid_t uid, struct __darwin_passwd *pwd, char *buffer, size_t bufsize, struct __darwin_passwd **result) -{ - return GenericGet_R(getpwuid_r, uid, pwd, buffer, bufsize, result); -} - -int __darwin_getpwuuid(/* ... */) -{ - errno = DARWIN_ENOSYS; - return -1; -} - -int __darwin_getpwuuid_r(/* ... */) -{ - errno = DARWIN_ENOSYS; - return -1; -} - -int __darwin_setpassent(int stayopen); - - diff --git a/src/libSystem/libc/getpwent.h b/src/libSystem/libc/getpwent.h deleted file mode 100644 index b01dbb128..000000000 --- a/src/libSystem/libc/getpwent.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef LIBC_GETPWENT_H -#define LIBC_GETPWENT_H -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -struct __darwin_passwd -{ - const char* pw_name; - const char* pw_passwd; - uid_t pw_uid; - gid_t pw_gid; - time_t pw_change; - const char* pw_class; - const char* pw_gecos; - const char* pw_dir; - const char* pw_shell; - time_t pw_expire; -}; - -__darwin_passwd* __darwin_getpwent(); -__darwin_passwd* __darwin_getpwnam(const char* login); -int __darwin_getpwnam_r(const char *name, struct __darwin_passwd *pwd, char *buffer, size_t bufsize, struct __darwin_passwd **result); -__darwin_passwd* __darwin_getpwuid(uid_t uid); -int __darwin_getpwuid_r(uid_t uid, struct __darwin_passwd *pwd, char *buffer, size_t bufsize, struct __darwin_passwd **result); -int __darwin_getpwuuid(/* ... */); -int __darwin_getpwuuid_r(/* ... */); -int __darwin_setpassent(int stayopen); - -// not needed, compatible -// void __darwin_setpwent(); -// void __darwin_endpwent(); - -#ifdef __cplusplus -} -#endif - - -#endif - diff --git a/src/libSystem/libc/libc-stub.h b/src/libSystem/libc/libc-stub.h deleted file mode 100644 index 44f960b81..000000000 --- a/src/libSystem/libc/libc-stub.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef LIBC_STUB_H -#define LIBC_STUB_H -#include - -#define LIBC_STUB() STUB() - -#endif - diff --git a/src/libSystem/libc/linux_to_darwin.map b/src/libSystem/libc/linux_to_darwin.map deleted file mode 100644 index 11d736959..000000000 --- a/src/libSystem/libc/linux_to_darwin.map +++ /dev/null @@ -1,87 +0,0 @@ -linux_to_darwin[EPERM] = DARWIN_EPERM; -linux_to_darwin[ENOENT] = DARWIN_ENOENT; -linux_to_darwin[ESRCH] = DARWIN_ESRCH; -linux_to_darwin[EINTR] = DARWIN_EINTR; -linux_to_darwin[EIO] = DARWIN_EIO; -linux_to_darwin[ENXIO] = DARWIN_ENXIO; -linux_to_darwin[ENOEXEC] = DARWIN_ENOEXEC; -linux_to_darwin[EBADF] = DARWIN_EBADF; -linux_to_darwin[ECHILD] = DARWIN_ECHILD; -linux_to_darwin[EDEADLK] = DARWIN_EDEADLK; -linux_to_darwin[ENOMEM] = DARWIN_ENOMEM; -linux_to_darwin[EACCES] = DARWIN_EACCES; -linux_to_darwin[EFAULT] = DARWIN_EFAULT; -linux_to_darwin[ENOTBLK] = DARWIN_ENOTBLK; -linux_to_darwin[EBUSY] = DARWIN_EBUSY; -linux_to_darwin[EEXIST] = DARWIN_EEXIST; -linux_to_darwin[EXDEV] = DARWIN_EXDEV; -linux_to_darwin[ENODEV] = DARWIN_ENODEV; -linux_to_darwin[ENOTDIR] = DARWIN_ENOTDIR; -linux_to_darwin[EISDIR] = DARWIN_EISDIR; -linux_to_darwin[EINVAL] = DARWIN_EINVAL; -linux_to_darwin[ENFILE] = DARWIN_ENFILE; -linux_to_darwin[EMFILE] = DARWIN_EMFILE; -linux_to_darwin[ENOTTY] = DARWIN_ENOTTY; -linux_to_darwin[ETXTBSY] = DARWIN_ETXTBSY; -linux_to_darwin[EFBIG] = DARWIN_EFBIG; -linux_to_darwin[ENOSPC] = DARWIN_ENOSPC; -linux_to_darwin[ESPIPE] = DARWIN_ESPIPE; -linux_to_darwin[EROFS] = DARWIN_EROFS; -linux_to_darwin[EMLINK] = DARWIN_EMLINK; -linux_to_darwin[EPIPE] = DARWIN_EPIPE; -linux_to_darwin[EDOM] = DARWIN_EDOM; -linux_to_darwin[ERANGE] = DARWIN_ERANGE; -linux_to_darwin[EAGAIN] = DARWIN_EAGAIN; -linux_to_darwin[EINPROGRESS] = DARWIN_EINPROGRESS; -linux_to_darwin[EALREADY] = DARWIN_EALREADY; -linux_to_darwin[ENOTSOCK] = DARWIN_ENOTSOCK; -linux_to_darwin[EDESTADDRREQ] = DARWIN_EDESTADDRREQ; -linux_to_darwin[EMSGSIZE] = DARWIN_EMSGSIZE; -linux_to_darwin[EPROTOTYPE] = DARWIN_EPROTOTYPE; -linux_to_darwin[ENOPROTOOPT] = DARWIN_ENOPROTOOPT; -linux_to_darwin[EPROTONOSUPPORT] = DARWIN_EPROTONOSUPPORT; -linux_to_darwin[ESOCKTNOSUPPORT] = DARWIN_ESOCKTNOSUPPORT; -linux_to_darwin[ENOTSUP] = DARWIN_ENOTSUP; -linux_to_darwin[EPFNOSUPPORT] = DARWIN_EPFNOSUPPORT; -linux_to_darwin[EAFNOSUPPORT] = DARWIN_EAFNOSUPPORT; -linux_to_darwin[EADDRINUSE] = DARWIN_EADDRINUSE; -linux_to_darwin[EADDRNOTAVAIL] = DARWIN_EADDRNOTAVAIL; -linux_to_darwin[ENETDOWN] = DARWIN_ENETDOWN; -linux_to_darwin[ENETUNREACH] = DARWIN_ENETUNREACH; -linux_to_darwin[ENETRESET] = DARWIN_ENETRESET; -linux_to_darwin[ECONNABORTED] = DARWIN_ECONNABORTED; -linux_to_darwin[ECONNRESET] = DARWIN_ECONNRESET; -linux_to_darwin[ENOBUFS] = DARWIN_ENOBUFS; -linux_to_darwin[EISCONN] = DARWIN_EISCONN; -linux_to_darwin[ENOTCONN] = DARWIN_ENOTCONN; -linux_to_darwin[ESHUTDOWN] = DARWIN_ESHUTDOWN; -linux_to_darwin[ETOOMANYREFS] = DARWIN_ETOOMANYREFS; -linux_to_darwin[ETIMEDOUT] = DARWIN_ETIMEDOUT; -linux_to_darwin[ECONNREFUSED] = DARWIN_ECONNREFUSED; -linux_to_darwin[ELOOP] = DARWIN_ELOOP; -linux_to_darwin[ENAMETOOLONG] = DARWIN_ENAMETOOLONG; -linux_to_darwin[EHOSTDOWN] = DARWIN_EHOSTDOWN; -linux_to_darwin[EHOSTUNREACH] = DARWIN_EHOSTUNREACH; -linux_to_darwin[ENOTEMPTY] = DARWIN_ENOTEMPTY; -linux_to_darwin[EUSERS] = DARWIN_EUSERS; -linux_to_darwin[EDQUOT] = DARWIN_EDQUOT; -linux_to_darwin[ESTALE] = DARWIN_ESTALE; -linux_to_darwin[EREMOTE] = DARWIN_EREMOTE; -linux_to_darwin[ENOLCK] = DARWIN_ENOLCK; -linux_to_darwin[ENOSYS] = DARWIN_ENOSYS; -linux_to_darwin[EOVERFLOW] = DARWIN_EOVERFLOW; -linux_to_darwin[ECANCELED] = DARWIN_ECANCELED; -linux_to_darwin[EIDRM] = DARWIN_EIDRM; -linux_to_darwin[ENOMSG] = DARWIN_ENOMSG; -linux_to_darwin[EILSEQ] = DARWIN_EILSEQ; -linux_to_darwin[EBADMSG] = DARWIN_EBADMSG; -linux_to_darwin[EMULTIHOP] = DARWIN_EMULTIHOP; -linux_to_darwin[ENODATA] = DARWIN_ENODATA; -linux_to_darwin[ENOLINK] = DARWIN_ENOLINK; -linux_to_darwin[ENOSR] = DARWIN_ENOSR; -linux_to_darwin[ENOSTR] = DARWIN_ENOSTR; -linux_to_darwin[EPROTO] = DARWIN_EPROTO; -linux_to_darwin[ETIME] = DARWIN_ETIME; -linux_to_darwin[EOPNOTSUPP] = DARWIN_EOPNOTSUPP; -linux_to_darwin[ENOTRECOVERABLE] = DARWIN_ENOTRECOVERABLE; -linux_to_darwin[EOWNERDEAD] = DARWIN_EOWNERDEAD; diff --git a/src/libSystem/libc/mac.c b/src/libSystem/libc/mac.c deleted file mode 100644 index d15a23fe6..000000000 --- a/src/libSystem/libc/mac.c +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright 2011 Shinichiro Hamaji. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY Shinichiro Hamaji ``AS IS'' AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Shinichiro Hamaji OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -// USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -// SUCH DAMAGE. - -// Emulation for functions in Mac. - -#ifndef _GNU_SOURCE -# define _GNU_SOURCE -#endif - -#include "config.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#ifdef NOLOG -# define LOGF(...) if (0) fprintf(stderr, __VA_ARGS__) -#else -int LIBMAC_LOG; -# define LOGF(...) if (LIBMAC_LOG) fprintf(stderr, __VA_ARGS__) -#endif - -typedef __darwin_rune_t rune_t; -typedef int __darwin_ct_rune_t; /* ct_rune_t */ - -int __maskrune(__darwin_ct_rune_t _c, unsigned long _f) { - return _DefaultRuneLocale.__runetype[_c & 0xff] & _f; -} - -int __maskrune_l(__darwin_ct_rune_t _c, unsigned long _f, void* l) { - return __maskrune(_c, _f); -} - -void libiconv_set_relocation_prefix(const char* orig, const char* curr) { -} - -int task_get_exception_ports() { - fprintf(stderr, "task_get_exception_ports\n"); - return 0; -} - -int task_set_exception_ports() { - fprintf(stderr, "task_set_exception_ports\n"); - return 0; -} - -#define __DARWIN_LC_ALL_MASK ( __DARWIN_LC_COLLATE_MASK \ - | __DARWIN_LC_CTYPE_MASK \ - | __DARWIN_LC_MESSAGES_MASK \ - | __DARWIN_LC_MONETARY_MASK \ - | __DARWIN_LC_NUMERIC_MASK \ - | __DARWIN_LC_TIME_MASK ) -#define __DARWIN_LC_COLLATE_MASK (1 << 0) -#define __DARWIN_LC_CTYPE_MASK (1 << 1) -#define __DARWIN_LC_MESSAGES_MASK (1 << 2) -#define __DARWIN_LC_MONETARY_MASK (1 << 3) -#define __DARWIN_LC_NUMERIC_MASK (1 << 4) -#define __DARWIN_LC_TIME_MASK (1 << 5) - -locale_t __darwin_newlocale(int category_mask, const char* locale, - locale_t base) { - LOGF("newlocale: %d %p %p\n", category_mask, locale, base); - int linux_category_mask = 0; - if (__DARWIN_LC_COLLATE_MASK & category_mask) - linux_category_mask |= LC_COLLATE_MASK; - if (__DARWIN_LC_CTYPE_MASK & category_mask) - linux_category_mask |= LC_CTYPE_MASK; - if (__DARWIN_LC_MESSAGES_MASK & category_mask) - linux_category_mask |= LC_MESSAGES_MASK; - if (__DARWIN_LC_MONETARY_MASK & category_mask) - linux_category_mask |= LC_MONETARY_MASK; - if (__DARWIN_LC_NUMERIC_MASK & category_mask) - linux_category_mask |= LC_NUMERIC_MASK; - if (__DARWIN_LC_TIME_MASK & category_mask) - linux_category_mask |= LC_TIME_MASK; - // Apple's newlocale allows base=LC_GLOBAL_LOCALE, while glibc crashes. - // It seems the behavior is unspecified for this case. - // http://pubs.opengroup.org/onlinepubs/9699919799/functions/newlocale.html - // We'll use current locale (NULL) instead of the global locale. - if (base == LC_GLOBAL_LOCALE) - base = NULL; - // It seems the following 5 locales are the same as "C" for Mac. - if (!strcmp(locale, "en_US") || - !strcmp(locale, "en_US.ISO8859-1") || - !strcmp(locale, "en_US.ISO8859-15") || - !strcmp(locale, "en_US.US-ASCII") || - !strcmp(locale, "en_US.UTF-8")) - locale = "C"; - return newlocale(linux_category_mask, locale, base); -} - -int __darwin_compat_mode(const char* function, const char* mode) { - LOGF("compat_mode: %s %s\n", function, mode); - // We don't consider bootstrap, legacy, and error. - // http://opensource.apple.com/source/Libc/Libc-763.13/gen/get_compat.c - // TODO(hamaji): Support binary operators. - return !strcasecmp(mode, "unix2003"); -} diff --git a/src/libSystem/libc/malloc_zone.cpp b/src/libSystem/libc/malloc_zone.cpp deleted file mode 100644 index c5b312855..000000000 --- a/src/libSystem/libc/malloc_zone.cpp +++ /dev/null @@ -1,75 +0,0 @@ -#include "malloc_zone.h" -#include - -static uint32_t dummy = 0xbaadf00d; - -malloc_zone_t* malloc_create_zone(vm_size_t start_size, unsigned flags) -{ - return malloc_default_zone(); -} - -void malloc_destroy_zone(malloc_zone_t *zone) -{ -} - -malloc_zone_t* malloc_default_zone() -{ - return &dummy; -} - -malloc_zone_t* malloc_zone_from_ptr(const void *ptr) -{ - return malloc_default_zone(); -} - -void* malloc_zone_malloc(malloc_zone_t *zone, size_t size) -{ - return malloc(size); -} - -void* malloc_zone_calloc(malloc_zone_t *zone, size_t num_items, size_t size) -{ - return calloc(num_items, size); -} - -void* malloc_zone_valloc(malloc_zone_t *zone, size_t size) -{ - return valloc(size); -} - -void* malloc_zone_realloc(malloc_zone_t *zone, void *ptr, size_t size) -{ - return realloc(ptr, size); -} - -void* malloc_zone_memalign(malloc_zone_t *zone, size_t alignment, size_t size) -{ - return memalign(alignment, size); -} - -void malloc_zone_free(malloc_zone_t *zone, void *ptr) -{ - return free(ptr); -} - -void malloc_set_zone_name(malloc_zone_t *zone, const char *name) -{ - // TODO -} -const char *malloc_get_zone_name(malloc_zone_t *zone) -{ - // TODO - return "malloc_get_zone_name_NotImplemented"; -} - -void malloc_zone_statistics(malloc_zone_t* zone, __darwin_malloc_statistics_t* stats) -{ - struct mallinfo info = mallinfo(); - - // No idea if this is even nearly correct - stats->size_allocated = info.uordblks; - stats->size_in_use = info.hblkhd; - stats->max_size_in_use = info.usmblks; - stats->blocks_in_use = stats->size_in_use; -} - diff --git a/src/libSystem/libc/malloc_zone.h b/src/libSystem/libc/malloc_zone.h deleted file mode 100644 index dc8fed69c..000000000 --- a/src/libSystem/libc/malloc_zone.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef LIBC_MALLOC_ZONE_H -#define LIBC_MALLOC_ZONE_H -#include -#include - -typedef uint32_t malloc_zone_t; -typedef uintptr_t vm_size_t; - -struct __darwin_malloc_statistics_t -{ - unsigned blocks_in_use; - size_t size_in_use; - size_t max_size_in_use; - size_t size_allocated; -}; - - -extern "C" { - -malloc_zone_t* malloc_create_zone(vm_size_t start_size, unsigned flags); -void malloc_destroy_zone(malloc_zone_t *zone); -malloc_zone_t* malloc_default_zone(); -malloc_zone_t* malloc_zone_from_ptr(const void *ptr); -void* malloc_zone_malloc(malloc_zone_t *zone, size_t size); -void* malloc_zone_calloc(malloc_zone_t *zone, size_t num_items, size_t size); -void* malloc_zone_valloc(malloc_zone_t *zone, size_t size); -void* malloc_zone_realloc(malloc_zone_t *zone, void *ptr, size_t size); -void* malloc_zone_memalign(malloc_zone_t *zone, size_t alignment, size_t size); -void malloc_zone_free(malloc_zone_t *zone, void *ptr); -void malloc_set_zone_name(malloc_zone_t *zone, const char *name); -const char *malloc_get_zone_name(malloc_zone_t *zone); - -void malloc_zone_statistics(malloc_zone_t* zone, __darwin_malloc_statistics_t* stats); - -} - -#endif - diff --git a/src/libSystem/libc/math.cpp b/src/libSystem/libc/math.cpp deleted file mode 100644 index 530a40b5f..000000000 --- a/src/libSystem/libc/math.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "math.h" -#include - -long int __fpclassifyd(double arg) -{ - return std::fpclassify(arg); -} - -long int __isnormald(double x) -{ - return std::isnormal(x); -} - -long int __isfinited(double x) -{ - return std::isfinite(x); -} - -long int __isnand(double x) -{ - return std::isnan(x); -} - -long int __signbitd(double arg) -{ - return std::signbit(arg); -} - diff --git a/src/libSystem/libc/math.h b/src/libSystem/libc/math.h deleted file mode 100644 index c31473d5e..000000000 --- a/src/libSystem/libc/math.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef LIBC_MATH_H -#define LIBC_MATH_H - -extern "C" { - -long int __fpclassifyd(double arg); -long int __isnormald(double x); -long int __isfinited(double x); -long int __isnand(double x); -long int __signbitd(double arg); - -} - -#endif - diff --git a/src/libSystem/libc/misc.cpp b/src/libSystem/libc/misc.cpp deleted file mode 100644 index a79e10919..000000000 --- a/src/libSystem/libc/misc.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "config.h" -#include "misc.h" -#include "trace.h" -#include -#include -#include - -const char* locale_charset() -{ - return nl_langinfo(CODESET); -} - -extern "C" void* __darwin_realloc(void* p, size_t s) -{ - TRACE2(p, s); - //if (p < (void*)0xffff) - // p = 0; - return realloc(p,s); -} - -int __darwin_atexit(void (*function)(void)) -{ - return atexit(function); -} - -void* __darwin_malloc(size_t size) -{ - void* p = malloc(size); - if (p != nullptr) - memset(p, 0, size); - return p; -} diff --git a/src/libSystem/libc/misc.h b/src/libSystem/libc/misc.h deleted file mode 100644 index 3e0be32f1..000000000 --- a/src/libSystem/libc/misc.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef LIBC_MISC_H -#define LIBC_MISC_H -#include - -extern "C" -{ - -const char* locale_charset(); - -// atexit() is strange, it seems to be always inlined and cannot be resolved with dlsym() -int __darwin_atexit(void (*function)(void)); - -void* __darwin_malloc(size_t size); - -} - -#endif - diff --git a/src/libSystem/libc/mount.cpp b/src/libSystem/libc/mount.cpp deleted file mode 100644 index 8a4212e19..000000000 --- a/src/libSystem/libc/mount.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "mount.h" -#include -#include "libc/darwin_errno_codes.h" -#include - -template int __darwin_getmntinfoGen(Fsstatfun f, Statfs** mntbufp, int flags) -{ - static __thread Statfs* lastMntbufp = 0; - - *mntbufp = 0; - - if (lastMntbufp) - { - delete [] lastMntbufp; - lastMntbufp = 0; - } - - int count = f(0, 0, 0); - - if (count < 0) - return -1; - - lastMntbufp = new Statfs[count]; - if (!lastMntbufp) - { - errno = DARWIN_ENOMEM; - return -1; - } - - count = f(lastMntbufp, count*sizeof(Statfs), 0); - - if (count < 0) - { - delete [] lastMntbufp; - lastMntbufp = 0; - return -1; - } - - *mntbufp = lastMntbufp; - return count; -} - -int __darwin_getmntinfo(struct __darwin_statfs** mntbufp, int flags) -{ - return __darwin_getmntinfoGen(__darwin_getfsstat, mntbufp, flags); -} - -int __darwin_getmntinfo64(struct __darwin_statfs64** mntbufp, int flags) -{ - return __darwin_getmntinfoGen(__darwin_getfsstat64, mntbufp, flags); -} - diff --git a/src/libSystem/libc/mount.h b/src/libSystem/libc/mount.h deleted file mode 100644 index 5327fefec..000000000 --- a/src/libSystem/libc/mount.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef LIBC_MOUNT_H -#define LIBC_MOUNT_H -#include "kernel-bsd/fs.h" - -extern "C" -{ - -int __darwin_getmntinfo(struct __darwin_statfs** mntbufp, int flags); -int __darwin_getmntinfo64(struct __darwin_statfs64** mntbufp, int flags) asm("__darwin_getmntinfo$INODE64"); - -} - -#endif diff --git a/src/libSystem/libc/namemap.cpp b/src/libSystem/libc/namemap.cpp deleted file mode 100644 index b0ef712df..000000000 --- a/src/libSystem/libc/namemap.cpp +++ /dev/null @@ -1,90 +0,0 @@ -#include -#include -#include -#include -#include -#include "../util/stlutils.h" - -namespace Darling -{ - typedef bool (*DlsymHookFunc)(char* symName); - void registerDlsymHook(DlsymHookFunc func); - void deregisterDlsymHook(DlsymHookFunc func); -}; - -static const char* g_directmap = -#include "namemap.lst" -; - -static std::map* g_nameMap; - -static bool NameTranslator(char* symName); - -__attribute__((constructor)) - static void initTranslation() -{ - std::istringstream istr(g_directmap); - std::string line; - - g_nameMap = new std::map; - - while (std::getline(istr, line)) - { - if (line.empty() || line[0] == '#') - continue; - - std::vector segs = string_explode(line, ';'); - if (segs.size() < 2) - continue; - - if (segs[0].compare(0, 3, "32!") == 0) - { -#ifdef __x86_64__ - continue; -#else - segs[0] = segs[0].substr(3); -#endif - } - - if (segs[0].compare(0, 3, "64!") == 0) - { -#ifdef __i386__ - continue; -#else - segs[0] = segs[0].substr(3); -#endif - } - - // std::cout << segs[0] << " -> " << segs[1] << std::endl; - (*g_nameMap)[segs[0]] = segs[1]; - } - - Darling::registerDlsymHook(NameTranslator); -} - -__attribute__((destructor)) - static void exitTranslation() -{ - Darling::deregisterDlsymHook(NameTranslator); - delete g_nameMap; -} - -bool NameTranslator(char* symName) -{ - auto it = g_nameMap->find(symName); - if (it != g_nameMap->end()) - { - strcpy(symName, it->second.c_str()); - return true; - } - - it = g_nameMap->find(std::string("__darwin_")+symName); - if (it != g_nameMap->end()) - { - strcpy(symName, it->second.c_str()); - return true; - } - - return false; -} - diff --git a/src/libSystem/libc/namemap.lst b/src/libSystem/libc/namemap.lst deleted file mode 100644 index ec2856b67..000000000 --- a/src/libSystem/libc/namemap.lst +++ /dev/null @@ -1,64 +0,0 @@ -R"( - -__error;__errno_location -__assert_rtn;__assert_fail - -# libstdc++ -64!_ZNSt13basic_filebufIwSt11char_traitsIwEE7seekoffExSt12_Ios_SeekdirSt13_Ios_Openmode;_ZNSt13basic_filebufIwSt11char_traitsIwEE7seekoffElSt12_Ios_SeekdirSt13_Ios_Openmode -64!_ZNSt13basic_filebufIcSt11char_traitsIcEE7seekoffExSt12_Ios_SeekdirSt13_Ios_Openmode;_ZNSt13basic_filebufIcSt11char_traitsIcEE7seekoffElSt12_Ios_SeekdirSt13_Ios_Openmode -64!_ZNSi5seekgExSt12_Ios_Seekdir;_ZNSi5seekgElSt12_Ios_Seekdir -64!_ZNSt13basic_istreamIwSt11char_traitsIwEE5seekgExSt12_Ios_Seekdir;_ZNSt13basic_istreamIwSt11char_traitsIwEE5seekgElSt12_Ios_Seekdir -64!_ZNSo5seekpExSt12_Ios_Seekdir;_ZNSo5seekpElSt12_Ios_Seekdir -64!_ZNSt13basic_ostreamIwSt11char_traitsIwEE5seekpExSt12_Ios_Seekdir;_ZNSt13basic_ostreamIwSt11char_traitsIwEE5seekpElSt12_Ios_Seekdir -64!_ZNSt15basic_stringbufIcSt11char_traitsIcESaIcEE7seekoffExSt12_Ios_SeekdirSt13_Ios_Openmode;_ZNSt15basic_stringbufIcSt11char_traitsIcESaIcEE7seekoffElSt12_Ios_SeekdirSt13_Ios_Openmode -64!_ZNSt15basic_stringbufIwSt11char_traitsIwESaIwEE7seekoffExSt12_Ios_SeekdirSt13_Ios_Openmode;_ZNSt15basic_stringbufIwSt11char_traitsIwESaIwEE7seekoffElSt12_Ios_SeekdirSt13_Ios_Openmode -64!_ZNSt15basic_streambufIcSt11char_traitsIcEE7seekoffExSt12_Ios_SeekdirSt13_Ios_Openmode;_ZNSt15basic_streambufIcSt11char_traitsIcEE7seekoffElSt12_Ios_SeekdirSt13_Ios_Openmode -64!_ZNSt15basic_streambufIcSt11char_traitsIcEE10pubseekoffExSt12_Ios_SeekdirSt13_Ios_Openmode;_ZNSt15basic_streambufIcSt11char_traitsIcEE10pubseekoffElSt12_Ios_SeekdirSt13_Ios_Openmode -64!_ZNSt15basic_streambufIwSt11char_traitsIwEE7seekoffExSt12_Ios_SeekdirSt13_Ios_Openmode;_ZNSt15basic_streambufIwSt11char_traitsIwEE7seekoffElSt12_Ios_SeekdirSt13_Ios_Openmode -64!_ZNSt15basic_streambufIwSt11char_traitsIwEE10pubseekoffExSt12_Ios_SeekdirSt13_Ios_Openmode;_ZNSt15basic_streambufIwSt11char_traitsIwEE10pubseekoffElSt12_Ios_SeekdirSt13_Ios_Openmode -64!_ZNSt12strstreambuf7seekoffExSt12_Ios_SeekdirSt13_Ios_Openmode;_ZNSt12strstreambuf7seekoffElSt12_Ios_SeekdirSt13_Ios_Openmode - -32!_Znwm;_Znwj -32!_Znam;_Znaj -32!_ZNSt6locale5_ImplC2ERKS0_m;_ZNSt6locale5_ImplC2ERKS0_j -32!_ZNSt6locale5_ImplC1ERKS0_m;_ZNSt6locale5_ImplC1ERKS0_j -32!_ZNSt7codecvtIwc11__mbstate_tEC2Em;_ZNSt7codecvtIwc11__mbstate_tEC2Ej -32!_ZNKSt7codecvtIwc11__mbstate_tE9do_lengthERS0_PKcS4_m;_ZNKSt7codecvtIwc11__mbstate_tE9do_lengthERS0_PKcS4_j -32!_ZnwmRKSt9nothrow_t;_ZnwjRKSt9nothrow_t - -opendir$INODE64;opendir -CC_MD5_Init;MD5_Init -CC_MD5_Update;MD5_Update -CC_MD5_Final;MD5_Final -CC_MD5;MD5 -CC_SHA1_Init;SHA1_Init -CC_SHA1_Update;SHA1_Update -CC_SHA1_Final;SHA1_Final -__darwin_atexit;__cxa_atexit -__darwin_select$1050;__darwin_select -__darwin_warn;__darwin__warn -__darwin_err;__darwin__err - -# dir.cpp -__darwin_opendir$INODE64;__darwin_opendir -__darwin_rewinddir$INODE64;rewinddir -__darwin_rewinddir;rewinddir -__darwin_telldir$INODE64;telldir - -__darwin_curl_mfprintf;__darwin_fprintf -__darwin_curl_mvfprintf;__darwin_vfprintf - -realpath$DARWIN_EXTSN;__darwin_realpath - -libintl_gettext;gettext -libintl_dgettext;dgettext -libintl_ngettext;ngettext -libintl_dngettext;dngettext -libintl_dcngettext;dcngettext -libintl_textdomain;textdomain -libintl_bindtextdomain;bindtextdomain -libintl_bind_textdomain_codeset;bind_textdomain_codeset -libintl_setlocale;setlocale - -)" - diff --git a/src/libSystem/libc/net.cpp b/src/libSystem/libc/net.cpp deleted file mode 100644 index a1f7549d2..000000000 --- a/src/libSystem/libc/net.cpp +++ /dev/null @@ -1,130 +0,0 @@ -#include "config.h" -#include "net.h" -#include "common/auto.h" -#include "kernel-bsd/sockets.h" -#include -#include -#include -#include - -static Darling::MappedFlag g_flags[] = { - { DARWIN_AI_ADDRCONFIG, AI_ADDRCONFIG }, - { DARWIN_AI_ALL, AI_ALL }, - { DARWIN_AI_CANONNAME, AI_CANONNAME }, - { DARWIN_AI_NUMERICHOST, AI_NUMERICHOST }, - { DARWIN_AI_NUMERICSERV, AI_NUMERICSERV }, - { DARWIN_AI_PASSIVE, AI_PASSIVE }, - { DARWIN_AI_V4MAPPED, AI_V4MAPPED } -}; - -int __darwin_getaddrinfo(const char *hostname, const char *servname, const struct __darwin_addrinfo *hints, struct __darwin_addrinfo **res) -{ - struct addrinfo* chints; - - if (hints) - { - chints = new struct addrinfo; - - const struct __darwin_addrinfo* next = hints; - struct addrinfo* cnext = chints; - - while (next) - { - memset(cnext, 0, sizeof(*cnext)); - cnext->ai_family = Darling::familyDarwinToLinux(next->ai_family); - cnext->ai_flags = Darling::flagsDarwinToNative(g_flags, sizeof(g_flags)/sizeof(g_flags[0]), next->ai_flags); - cnext->ai_socktype = next->ai_socktype; - - next = next->ai_next; - - if (next) - { - cnext->ai_next = new struct addrinfo; - cnext = cnext->ai_next; - } - else - cnext->ai_next = 0; - } - } - else - chints = 0; - - struct addrinfo* nres; - int rv = getaddrinfo(hostname, servname, chints, &nres); - - // delete native hints - while (chints) - { - struct addrinfo* i = chints->ai_next; - delete chints; - chints = i; - } - - *res = 0; - if (!rv) - { - // convert the native addrinfo - struct addrinfo* next = nres; - struct __darwin_addrinfo* cnext = *res = new __darwin_addrinfo; - while (next) - { - cnext->ai_family = Darling::familyLinuxToDarwin(next->ai_family); - cnext->ai_flags = Darling::flagsNativeToDarwin(g_flags, sizeof(g_flags)/sizeof(g_flags[0]), next->ai_flags); - - if (next->ai_canonname) - cnext->ai_canonname = strdup(next->ai_canonname); - else - cnext->ai_canonname = 0; - - cnext->ai_socktype = next->ai_socktype; - cnext->ai_protocol = next->ai_protocol; - cnext->ai_addrlen = next->ai_addrlen; - - cnext->ai_addr = static_cast(malloc(cnext->ai_addrlen)); - memcpy(cnext->ai_addr, next->ai_addr, cnext->ai_addrlen); - - Darling::sockaddrFixupOut(cnext->ai_addr, cnext->ai_addrlen); - next = next->ai_next; - - if (next) - { - cnext->ai_next = new __darwin_addrinfo; - cnext = cnext->ai_next; - } - else - cnext->ai_next = 0; - } - freeaddrinfo(nres); - } - else - { - errnoOut(); - } - - return rv; -} - - -void __darwin_freeaddrinfo(struct __darwin_addrinfo* res) -{ - while (res) - { - struct __darwin_addrinfo* n = res->ai_next; - free(res->ai_canonname); - free(res->ai_addr); - delete res; - res = n; - } -} - -const char* __darwin_inet_ntop(int af, const void* src, char* dst, socklen_t size) -{ - af = Darling::familyDarwinToLinux(af); - const char* rv = inet_ntop(af, src, dst, size); - - if (!rv) - errnoOut(); - - return rv; -} - diff --git a/src/libSystem/libc/net.h b/src/libSystem/libc/net.h deleted file mode 100644 index 42674e203..000000000 --- a/src/libSystem/libc/net.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef LIBC_NET_H -#define LIBC_NET_H -#include -#include -#include - -#define DARWIN_AI_ADDRCONFIG 1024 -#define DARWIN_AI_ALL 256 -#define DARWIN_AI_CANONNAME 2 -#define DARWIN_AI_NUMERICHOST 4 -#define DARWIN_AI_NUMERICSERV 4096 -#define DARWIN_AI_PASSIVE 1 -#define DARWIN_AI_V4MAPPED 2048 - -struct __darwin_addrinfo -{ - int ai_flags; - int ai_family; - int ai_socktype; - int ai_protocol; - socklen_t ai_addrlen; - char *ai_canonname; - struct sockaddr *ai_addr; - struct __darwin_addrinfo *ai_next; -}; - - -extern "C" -{ - -int __darwin_getaddrinfo(const char *hostname, const char *servname, const struct __darwin_addrinfo *hints, struct __darwin_addrinfo **res); -void __darwin_freeaddrinfo(struct __darwin_addrinfo* res); -const char* __darwin_inet_ntop(int af, const void* src, char* dst, socklen_t size); - -} - -#endif - diff --git a/src/libSystem/libc/nextstep.cpp b/src/libSystem/libc/nextstep.cpp deleted file mode 100644 index 1487afb41..000000000 --- a/src/libSystem/libc/nextstep.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "config.h" -#include "nextstep.h" -#include -#include -#include -#include - -using namespace Darling; - -char*** _NSGetEnviron() -{ - MachOObject* mainModule = MachOMgr::instance()->mainModule(); - - // When dyld is used as a simple loader, we fall back to direct access to global environ - if (!mainModule) - return &environ; - else - { - char*** env; - mainModule->commandLine(nullptr, nullptr, &env); - return env; - } -} - -int* _NSGetArgc() -{ - MachOObject* mainModule = MachOMgr::instance()->mainModule(); - - if (!mainModule) - return nullptr; - else - { - int* argc; - mainModule->commandLine(&argc, nullptr, nullptr); - return argc; - } -} - -char*** _NSGetArgv() -{ - MachOObject* mainModule = MachOMgr::instance()->mainModule(); - - if (!mainModule) - return nullptr; - else - { - char*** argv; - mainModule->commandLine(nullptr, &argv, nullptr); - return argv; - } -} - diff --git a/src/libSystem/libc/nextstep.h b/src/libSystem/libc/nextstep.h deleted file mode 100644 index 566aa9ec4..000000000 --- a/src/libSystem/libc/nextstep.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef LIBC_NEXTSTEP_H -#define LIBC_NEXTSTEP_H - -extern "C" -{ - -char*** _NSGetEnviron(); -int* _NSGetArgc(); -char*** _NSGetArgv(); - -} - -#endif diff --git a/src/libSystem/libc/popcount.c b/src/libSystem/libc/popcount.c deleted file mode 100644 index 4f031bfd2..000000000 --- a/src/libSystem/libc/popcount.c +++ /dev/null @@ -1,14 +0,0 @@ -#include - -int __darwin___popcountdi2(int64_t a) -{ - return __builtin_popcountll(a); -} - -int __darwin___popcountsi2(int a) -{ - return __builtin_popcount(a); -} - - - diff --git a/src/libSystem/libc/progname.cpp b/src/libSystem/libc/progname.cpp deleted file mode 100644 index ddfa6ed35..000000000 --- a/src/libSystem/libc/progname.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "config.h" -#include -#include -#include - -using namespace Darling; - -__attribute__((constructor)) static void initProgname() -{ - MachOObject* main = MachOMgr::instance()->mainModule(); - - if (main) - setprogname(main->name()); -} diff --git a/src/libSystem/libc/pthread.cpp b/src/libSystem/libc/pthread.cpp deleted file mode 100644 index 0bf64e1b9..000000000 --- a/src/libSystem/libc/pthread.cpp +++ /dev/null @@ -1,450 +0,0 @@ -#include "pthread.h" -#include "errno.h" -#include -#include -#include -#include -#include -#include - -static Darling::Mutex g_pthreadMutex; -static pthread_key_t g_pthreadDestructor; -static std::map g_pthreadToTid __attribute__ ((init_priority (101))); - -static void pthread_destroyed(void*) -{ - Darling::MutexLock lock(g_pthreadMutex); - auto it = g_pthreadToTid.find(pthread_self()); - - if (it != g_pthreadToTid.end()) - g_pthreadToTid.erase(it); -} - -__attribute__((constructor)) -static void initPthreadDestructor() -{ - pthread_key_create(&g_pthreadDestructor, pthread_destroyed); - g_pthreadToTid[pthread_self()] = syscall(SYS_gettid); -} - -struct WrapPthreadArg -{ - void *(*start_routine) (void *); - void *arg; -}; - -static void* StartRoutineWrapper(void* a) -{ - WrapPthreadArg* wrap = static_cast(a); - WrapPthreadArg mywrap = *wrap; - - // Set something into the key so that we get called when the thread exits - // (and however it exits) - pthread_setspecific(g_pthreadDestructor, &mywrap); - - g_pthreadMutex.lock(); - g_pthreadToTid[pthread_self()] = syscall(SYS_gettid); - g_pthreadMutex.unlock(); - - delete wrap; - - return mywrap.start_routine(mywrap.arg); -} - -pid_t Darling::tidForPthread(pthread_t pth) -{ - Darling::MutexLock lock(g_pthreadMutex); - auto it = g_pthreadToTid.find(pth); - - if (it != g_pthreadToTid.end()) - return it->second; - else - return 0; -} - -int __darwin_pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg) -{ - WrapPthreadArg* wrap = new WrapPthreadArg { start_routine, arg }; - int rv = pthread_create(thread, attr, StartRoutineWrapper, wrap); - - if (rv != 0) - delete wrap; - - return errnoLinuxToDarwin(rv); -} - -pid_t __darwin_pthread_mach_thread_np(pthread_t pth) -{ - return Darling::tidForPthread(pth); -} - -int __darwin_pthread_mutexattr_settype(pthread_mutexattr_t* attr, int kind) -{ - switch (kind) - { - case __DARWIN_PTHREAD_MUTEX_NORMAL: - kind = PTHREAD_MUTEX_FAST_NP; - break; - case __DARWIN_PTHREAD_MUTEX_ERRORCHECK: - kind = PTHREAD_MUTEX_ERRORCHECK_NP; - break; - case __DARWIN_PTHREAD_MUTEX_RECURSIVE: - kind = PTHREAD_MUTEX_RECURSIVE_NP; - break; - default: - fprintf(stderr, "Unknown pthread_mutexattr_settype kind: %d\n", kind); - } - int rv = pthread_mutexattr_settype(attr, kind); - if (rv == -1) - errnoOut(); - return rv; -} - - -static int TranslatePshared(int pshared) -{ - switch (pshared) - { - case __DARWIN_PTHREAD_PROCESS_SHARED: - return PTHREAD_PROCESS_SHARED; - case __DARWIN_PTHREAD_PROCESS_PRIVATE: - return PTHREAD_PROCESS_PRIVATE; - default: - fprintf(stderr, "Unknown pthread_mutexattr_setpshared pshared: %d\n", - pshared); - return pshared; - } -} -int __darwin_pthread_mutexattr_setpshared(pthread_mutexattr_t* attr, int pshared) -{ - pshared = TranslatePshared(pshared); - int rv = pthread_mutexattr_setpshared(attr, pshared); - if (rv == -1) - errnoOut(); - return rv; -} - -template int AutoAllocLockGeneric(Func f, __darwin_pthread_rwlock_t* rwlock, Args... args) -{ - int rv; - if (rwlock->signature == __darwin_pthread_rwlock_t::SIGNATURE_MACRO_INITIALIZED) - { - rv = __darwin_pthread_rwlock_init(rwlock, 0); - if (rv) - return rv; - } - - rv = f(&rwlock->native, args...); - if (rv) - rv = errnoLinuxToDarwin(rv); - return rv; -} - -static int InitializeMacroInitializedMutex(__darwin_pthread_mutex_t* mutex) -{ - pthread_mutexattr_t mta; - pthread_mutexattr_init(&mta); - int type; - - switch (mutex->signature) - { - case __darwin_pthread_mutex_t::SIGNATURE_MACRO_INITIALIZED_R: - type = PTHREAD_MUTEX_RECURSIVE; - break; - case __darwin_pthread_mutex_t::SIGNATURE_MACRO_INITIALIZED_E: - type = PTHREAD_MUTEX_ERRORCHECK; - break; - case __darwin_pthread_mutex_t::SIGNATURE_MACRO_INITIALIZED: - default: - type = PTHREAD_MUTEX_NORMAL; - } - - pthread_mutexattr_settype(&mta, type); - - return __darwin_pthread_mutex_init(mutex, &mta); -} - -template int AutoAllocMutexGeneric(Func f, __darwin_pthread_mutex_t* mutex, Args... args) -{ - int rv; - if (mutex->signature != __darwin_pthread_mutex_t::SIGNATURE_NATIVE_INITIALIZED) - { - rv = InitializeMacroInitializedMutex(mutex); - if (rv) - return rv; - } - - rv = f(&mutex->native, args...); - if (rv) - rv = errnoLinuxToDarwin(rv); - return rv; -} - -int __darwin_pthread_rwlockattr_setpshared(pthread_rwlockattr_t* attr, int pshared) -{ - pshared = TranslatePshared(pshared); - int rv = pthread_rwlockattr_setpshared(attr, pshared); - if (rv == -1) - errnoOut(); - return rv; -} - -int __darwin_pthread_rwlock_init(__darwin_pthread_rwlock_t* rwlock, const pthread_rwlockattr_t* attr) -{ - rwlock->signature = __darwin_pthread_rwlock_t::SIGNATURE_NATIVE_INITIALIZED; - int rv = pthread_rwlock_init(&rwlock->native, attr); - if (rv != 0) - rv = errnoLinuxToDarwin(rv); - return rv; -} - -int __darwin_pthread_rwlock_destroy(__darwin_pthread_rwlock_t *rwlock) -{ - if (rwlock->signature == __darwin_pthread_rwlock_t::SIGNATURE_NATIVE_INITIALIZED) - { - int rv = pthread_rwlock_destroy(&rwlock->native); - if (rv != 0) - rv = errnoLinuxToDarwin(rv); - return rv; - } - else - return 0; -} - -int __darwin_pthread_rwlock_rdlock(__darwin_pthread_rwlock_t *rwlock) -{ - return AutoAllocLockGeneric(pthread_rwlock_rdlock, rwlock); -} - -int __darwin_pthread_rwlock_tryrdlock(__darwin_pthread_rwlock_t *rwlock) -{ - return AutoAllocLockGeneric(pthread_rwlock_tryrdlock, rwlock); -} - -int __darwin_pthread_rwlock_trywrlock(__darwin_pthread_rwlock_t *rwlock) -{ - return AutoAllocLockGeneric(pthread_rwlock_trywrlock, rwlock); -} - -int __darwin_pthread_rwlock_wrlock(__darwin_pthread_rwlock_t *rwlock) -{ - return AutoAllocLockGeneric(pthread_rwlock_wrlock, rwlock); -} - -int __darwin_pthread_rwlock_timedrdlock(__darwin_pthread_rwlock_t* rwlock, const struct timespec* abs_timeout) -{ - return AutoAllocLockGeneric(pthread_rwlock_timedrdlock, rwlock, abs_timeout); -} - -int __darwin_pthread_rwlock_unlock(__darwin_pthread_rwlock_t *rwlock) -{ - return AutoAllocLockGeneric(pthread_rwlock_unlock, rwlock); -} - -int __darwin_pthread_mutex_init(__darwin_pthread_mutex_t* mutex, const pthread_mutexattr_t* attr) -{ - int rv = pthread_mutex_init(&mutex->native, attr); - mutex->signature = __darwin_pthread_mutex_t::SIGNATURE_NATIVE_INITIALIZED; - if (rv) - rv = errnoLinuxToDarwin(rv); - return rv; -} - -int __darwin_pthread_mutex_destroy(__darwin_pthread_mutex_t* mutex) -{ - if (mutex->signature == __darwin_pthread_mutex_t::SIGNATURE_NATIVE_INITIALIZED) - { - int rv = pthread_mutex_destroy(&mutex->native); - if (rv) - rv = errnoLinuxToDarwin(rv); - return rv; - } - return 0; -} - -int __darwin_pthread_mutex_lock(__darwin_pthread_mutex_t* mutex) -{ - return AutoAllocMutexGeneric(pthread_mutex_lock, mutex); -} - -int __darwin_pthread_mutex_trylock(__darwin_pthread_mutex_t* mutex) -{ - return AutoAllocMutexGeneric(pthread_mutex_trylock, mutex); -} - -int __darwin_pthread_mutex_unlock(__darwin_pthread_mutex_t* mutex) -{ - return AutoAllocMutexGeneric(pthread_mutex_unlock, mutex); -} - -template int AutoAllocConditionGeneric(Func f, __darwin_pthread_cond_t* cond, Args... args) -{ - int rv; - if (cond->signature != __darwin_pthread_cond_t::SIGNATURE_NATIVE_INITIALIZED) - { - rv = __darwin_pthread_cond_init(cond, nullptr); - if (rv) - return rv; - } - - rv = f(cond->native, args...); - if (rv) - rv = errnoLinuxToDarwin(rv); - return rv; -} - -int __darwin_pthread_cond_init(__darwin_pthread_cond_t *cond, const pthread_condattr_t *attr) -{ - cond->native = new pthread_cond_t; - int rv = pthread_cond_init(cond->native, attr); - cond->signature = __darwin_pthread_cond_t::SIGNATURE_NATIVE_INITIALIZED; - if (rv) - rv = errnoLinuxToDarwin(rv); - return rv; -} - -int __darwin_pthread_cond_destroy(__darwin_pthread_cond_t *cond) -{ - if (cond->signature == __darwin_pthread_cond_t::SIGNATURE_NATIVE_INITIALIZED) - { - int rv = pthread_cond_destroy(cond->native); - delete cond->native; - if (rv) - rv = errnoLinuxToDarwin(rv); - return rv; - } - return 0; -} - -int __darwin_pthread_cond_signal(__darwin_pthread_cond_t *cond) -{ - return AutoAllocConditionGeneric(pthread_cond_signal, cond); -} - -int __darwin_pthread_cond_broadcast(__darwin_pthread_cond_t *cond) -{ - return AutoAllocConditionGeneric(pthread_cond_broadcast, cond); -} - -int __darwin_pthread_cond_timedwait(__darwin_pthread_cond_t *cond, __darwin_pthread_mutex_t* mutex, const struct timespec *abstime) -{ - int rv; - if (mutex->signature != __darwin_pthread_mutex_t::SIGNATURE_NATIVE_INITIALIZED) - { - rv = InitializeMacroInitializedMutex(mutex); - if (rv) - return rv; - } - - return AutoAllocConditionGeneric(pthread_cond_timedwait, cond, &mutex->native, abstime); -} - -int __darwin_pthread_cond_wait(__darwin_pthread_cond_t *cond, __darwin_pthread_mutex_t* mutex) -{ - int rv; - if (mutex->signature != __darwin_pthread_mutex_t::SIGNATURE_NATIVE_INITIALIZED) - { - rv = InitializeMacroInitializedMutex(mutex); - if (rv) - return rv; - } - - return AutoAllocConditionGeneric(pthread_cond_wait, cond, &mutex->native); -} - -int __darwin_pthread_once(__darwin_pthread_once_t *once_control, void (*init_routine)(void)) -{ - return pthread_once(&once_control->native, init_routine); -} - -size_t pthread_get_stacksize_np(pthread_t pth) -{ - pthread_attr_t attr; - void* addr; - size_t size = 0; - - if (pthread_getattr_np(pth, &attr) == 0) - { - pthread_attr_getstack(&attr, &addr, &size); - pthread_attr_destroy(&attr); - } - - return size; -} - -void* pthread_get_stackaddr_np(pthread_t pth) -{ - pthread_attr_t attr; - void* addr = nullptr; - size_t size = 0; - - if (pthread_getattr_np(pth, &attr) == 0) - { - pthread_attr_getstack(&attr, &addr, &size); - pthread_attr_destroy(&attr); - } - - return addr; -} - -int __darwin_pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate) -{ - int err; - - if (detachstate == __DARWIN_PTHREAD_CREATE_JOINABLE) - detachstate = PTHREAD_CREATE_JOINABLE; - else if (detachstate == __DARWIN_PTHREAD_CREATE_DETACHED) - detachstate = PTHREAD_CREATE_DETACHED; - - err = pthread_attr_setdetachstate(attr, detachstate); - - if (err != 0) - err = errnoLinuxToDarwin(err); - - return err; -} - -int __darwin_pthread_attr_getdetachstate(pthread_attr_t *attr, int *detachstate) -{ - int err; - - err = pthread_attr_getdetachstate(attr, detachstate); - - if (err != 0) - { - err = errnoLinuxToDarwin(err); - return err; - } - - if (*detachstate == PTHREAD_CREATE_JOINABLE) - *detachstate = __DARWIN_PTHREAD_CREATE_JOINABLE; - else if (*detachstate == PTHREAD_CREATE_DETACHED) - *detachstate = __DARWIN_PTHREAD_CREATE_DETACHED; - - return 0; -} - -int __darwin_pthread_sigmask(int how, const __darwin_sigset_t *set, __darwin_sigset_t *oldset) -{ - std::unique_ptr nset; - std::unique_ptr noldset; - - if (set) - { - nset.reset(new sigset_t); - *nset = Darling::sigsetDarwinToLinux(set); - } - if (oldset) - noldset.reset(new sigset_t); - - // -1 -> conversion from Darwin to Linux - int rv = pthread_sigmask(how - 1, nset.get(), noldset.get()); - - if (rv == -1) - errnoOut(); - else if (oldset) - *oldset = Darling::sigsetLinuxToDarwin(noldset.get()); - - return rv; -} - diff --git a/src/libSystem/libc/pthread.h b/src/libSystem/libc/pthread.h deleted file mode 100644 index e352a7ec1..000000000 --- a/src/libSystem/libc/pthread.h +++ /dev/null @@ -1,107 +0,0 @@ -#ifndef LIBC_PTHREAD_H -#define LIBC_PTHREAD_H -#include -#include -#include "signals.h" - -#ifdef __cplusplus -namespace Darling -{ - pid_t tidForPthread(pthread_t pth); -} -#endif - -#define __DARWIN_PTHREAD_MUTEX_NORMAL 0 -#define __DARWIN_PTHREAD_MUTEX_ERRORCHECK 1 -#define __DARWIN_PTHREAD_MUTEX_RECURSIVE 2 -#define __DARWIN_PTHREAD_PROCESS_SHARED 1 -#define __DARWIN_PTHREAD_PROCESS_PRIVATE 2 -#define __DARWIN_PTHREAD_CREATE_JOINABLE 1 -#define __DARWIN_PTHREAD_CREATE_DETACHED 2 - -struct __darwin_pthread_rwlock_t // 200 bytes on Darwin -{ - enum { SIGNATURE_MACRO_INITIALIZED = 0x2da8b3b4, SIGNATURE_NATIVE_INITIALIZED = 0x12345678 }; - uint32_t signature; - pthread_rwlock_t native; // this will fit on Linux -}; - -struct __darwin_pthread_mutex_t -{ - enum { SIGNATURE_MACRO_INITIALIZED = 0x32aaaba7, SIGNATURE_MACRO_INITIALIZED_R = 0x32aaaba2, SIGNATURE_MACRO_INITIALIZED_E = 0x32aaaba1, SIGNATURE_NATIVE_INITIALIZED = 0x12345678 }; - uint32_t signature; - pthread_mutex_t native; // this will fit on Linux (40 vs 64) -}; - -struct __darwin_pthread_cond_t -{ - enum { SIGNATURE_MACRO_INITIALIZED = 0x3cb0b1bb, SIGNATURE_NATIVE_INITIALIZED = 0x12345678 }; - uint32_t signature; - pthread_cond_t *native; // this will NOT fit on linux (48 vs 44) (allocated instead) -}; - -struct __darwin_pthread_once_t -{ - enum { SIGNATURE_MACRO_INITIALIZED = 0x30b1bcba }; - uint32_t signature; - union - { - uint32_t data[2]; - pthread_once_t native; - }; -}; - -static_assert(sizeof(pthread_mutex_t) <= 60, "pthread_mutex_t is too big on this platform!"); -static_assert(sizeof(pthread_rwlock_t) <= 196, "pthread_rwlock_t is too big on this platform!"); - -extern "C" -{ - -int __darwin_pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg); - -int __darwin_pthread_once(__darwin_pthread_once_t *once_control, void (*init_routine)(void)); - -int __darwin_pthread_mutexattr_settype(pthread_mutexattr_t* attr, int kind); -int __darwin_pthread_mutexattr_setpshared(pthread_mutexattr_t* attr, int pshared); - -// pthread_rwlock -int __darwin_pthread_rwlockattr_setpshared(pthread_rwlockattr_t* attr, int pshared); -int __darwin_pthread_rwlock_init(__darwin_pthread_rwlock_t* rwlock, const pthread_rwlockattr_t* attr); -int __darwin_pthread_rwlock_destroy(__darwin_pthread_rwlock_t *rwlock); -int __darwin_pthread_rwlock_rdlock(__darwin_pthread_rwlock_t *rwlock); -int __darwin_pthread_rwlock_tryrdlock(__darwin_pthread_rwlock_t *rwlock); -int __darwin_pthread_rwlock_trywrlock(__darwin_pthread_rwlock_t *rwlock); -int __darwin_pthread_rwlock_wrlock(__darwin_pthread_rwlock_t *rwlock); -int __darwin_pthread_rwlock_timedrdlock(__darwin_pthread_rwlock_t* rwlock, const struct timespec* abs_timeout); -int __darwin_pthread_rwlock_unlock(__darwin_pthread_rwlock_t *rwlock); - -// pthread_mutex -int __darwin_pthread_mutex_init(__darwin_pthread_mutex_t*, const pthread_mutexattr_t* attr); -int __darwin_pthread_mutex_destroy(__darwin_pthread_mutex_t* mutex); -int __darwin_pthread_mutex_lock(__darwin_pthread_mutex_t* mutex); -int __darwin_pthread_mutex_trylock(__darwin_pthread_mutex_t* mutex); -int __darwin_pthread_mutex_unlock(__darwin_pthread_mutex_t* mutex); - -// pthread_cond -int __darwin_pthread_cond_init(__darwin_pthread_cond_t *cond, const pthread_condattr_t *attr); -int __darwin_pthread_cond_destroy(__darwin_pthread_cond_t *cond); -int __darwin_pthread_cond_signal(__darwin_pthread_cond_t *cond); -int __darwin_pthread_cond_broadcast(__darwin_pthread_cond_t *cond); -int __darwin_pthread_cond_timedwait(__darwin_pthread_cond_t *cond, __darwin_pthread_mutex_t* mutex, const struct timespec *abstime); -int __darwin_pthread_cond_wait(__darwin_pthread_cond_t *cond, __darwin_pthread_mutex_t* mutex); - -pid_t __darwin_pthread_mach_thread_np(pthread_t pth); - -size_t pthread_get_stacksize_np(pthread_t pth); -void* pthread_get_stackaddr_np(pthread_t pth); - -int __darwin_pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate); -int __darwin_pthread_attr_getdetachstate(pthread_attr_t *attr, int *detachstate); - -int __darwin_pthread_sigmask(int how, const __darwin_sigset_t *set, __darwin_sigset_t *oldset); - -// TODO: add other pthread functions for errno translation - -} - -#endif diff --git a/src/libSystem/libc/qsort.cpp b/src/libSystem/libc/qsort.cpp deleted file mode 100644 index 3b2f5f84e..000000000 --- a/src/libSystem/libc/qsort.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "qsort.h" - -static int __darwin_qsort_r_helper(const void* a, const void* b, void* data) -{ - __darwin_qsort_r_context* ctx = (__darwin_qsort_r_context*)data; - return ctx->compar(ctx->thunk, a, b); -} - -void __darwin_qsort_r(void* base, size_t nel, size_t width, void* thunk, - int (*compar)(void*, const void*, const void*)) -{ - __darwin_qsort_r_context ctx; - ctx.compar = compar; - ctx.thunk = thunk; - qsort_r(base, nel, width, &__darwin_qsort_r_helper, &ctx); -} - diff --git a/src/libSystem/libc/qsort.h b/src/libSystem/libc/qsort.h deleted file mode 100644 index f01ca5b1b..000000000 --- a/src/libSystem/libc/qsort.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef LIBC_QSORT_H -#define LIBC_QSORT_H -#include - -struct __darwin_qsort_r_context -{ - int (*compar)(void*, const void*, const void*); - void* thunk; -}; - - -extern "C" -{ - -void __darwin_qsort_r(void* base, size_t nel, size_t width, void* thunk, - int (*compar)(void*, const void*, const void*)); - -} - -#endif diff --git a/src/libSystem/libc/rune-none.c b/src/libSystem/libc/rune-none.c deleted file mode 100644 index 4e8c17fc0..000000000 --- a/src/libSystem/libc/rune-none.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include "rune.h" - -rune_t _none_sgetrune(const char* string, size_t n, char const** result) -{ - if (n < 1) - { - if (result) - *result = string; - return _INVALID_RUNE; - } - else if (result) - *result = string + 1; - return ((rune_t) *string) & 0xff; -} - -int _none_sputrune(rune_t c, char* string, size_t n, char** result) -{ - if (n >= 1) - { - if (string) - *string = c; - if (result) - *result = string + 1; - } - else if (result) - *result = NULL; - - return 1; -} - diff --git a/src/libSystem/libc/rune.h b/src/libSystem/libc/rune.h deleted file mode 100644 index 021c7dd57..000000000 --- a/src/libSystem/libc/rune.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef RUNE_H -#define RUNE_H -#include - -typedef __darwin_rune_t rune_t; -typedef int __darwin_ct_rune_t; /* ct_rune_t */ - -#define _INVALID_RUNE _DefaultRuneLocale.__invalid_rune - -rune_t _none_sgetrune(const char *string, size_t n, char const **result); -int _none_sputrune(rune_t c, char *string, size_t n, char** result); - -#define _RUNETYPE_A 0x00000100 -#define _RUNETYPE_C 0x00000200 -#define _RUNETYPE_D 0x00000400 -#define _RUNETYPE_G 0x00000800 -#define _RUNETYPE_L 0x00001000 -#define _RUNETYPE_P 0x00002000 -#define _RUNETYPE_S 0x00004000 -#define _RUNETYPE_U 0x00008000 -#define _RUNETYPE_X 0x00010000 -#define _RUNETYPE_B 0x00020000 -#define _RUNETYPE_R 0x00040000 -#define _RUNETYPE_I 0x00080000 -#define _RUNETYPE_T 0x00100000 -#define _RUNETYPE_Q 0x00200000 -#define _RUNETYPE_SW1 0x40000000 - -#endif diff --git a/src/libSystem/libc/runetable.c b/src/libSystem/libc/runetable.c deleted file mode 100644 index 28947cf28..000000000 --- a/src/libSystem/libc/runetable.c +++ /dev/null @@ -1,320 +0,0 @@ - -/* $NetBSD: runetable.c,v 1.28 2013/04/13 10:21:21 joerg Exp $ */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: src/lib/libc/locale/table.c,v 1.13 2000/02/08 07:43:25 obrien Exp $ - */ - -#include -#include "rune.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)table.c 8.1 (Berkeley) 6/27/93"; -#else -__RCSID("$NetBSD: runetable.c,v 1.28 2013/04/13 10:21:21 joerg Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -_RuneLocale _DefaultRuneLocale = { - _RUNE_MAGIC_A, - "none", - _none_sgetrune, - _none_sputrune, - 0xFFFD, - - { /*00*/ _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - /*08*/ _RUNETYPE_C, - _RUNETYPE_C|_RUNETYPE_S|_RUNETYPE_B, - _RUNETYPE_C|_RUNETYPE_S, - _RUNETYPE_C|_RUNETYPE_S, - _RUNETYPE_C|_RUNETYPE_S, - _RUNETYPE_C|_RUNETYPE_S, - _RUNETYPE_C, - _RUNETYPE_C, - /*10*/ _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - /*18*/ _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - /*20*/ _RUNETYPE_S|_RUNETYPE_B|_RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - /*28*/ _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - /*30*/ _RUNETYPE_D|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_X|_RUNETYPE_SW1|0, - _RUNETYPE_D|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_X|_RUNETYPE_SW1|1, - _RUNETYPE_D|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_X|_RUNETYPE_SW1|2, - _RUNETYPE_D|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_X|_RUNETYPE_SW1|3, - _RUNETYPE_D|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_X|_RUNETYPE_SW1|4, - _RUNETYPE_D|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_X|_RUNETYPE_SW1|5, - _RUNETYPE_D|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_X|_RUNETYPE_SW1|6, - _RUNETYPE_D|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_X|_RUNETYPE_SW1|7, - /*38*/ _RUNETYPE_D|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_X|_RUNETYPE_SW1|8, - _RUNETYPE_D|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_X|_RUNETYPE_SW1|9, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - /*40*/ _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_X|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1|10, - _RUNETYPE_U|_RUNETYPE_X|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1|11, - _RUNETYPE_U|_RUNETYPE_X|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1|12, - _RUNETYPE_U|_RUNETYPE_X|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1|13, - _RUNETYPE_U|_RUNETYPE_X|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1|14, - _RUNETYPE_U|_RUNETYPE_X|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1|15, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - /*48*/ _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - /*50*/ _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - /*58*/ _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - /*60*/ _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_X|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1|10, - _RUNETYPE_L|_RUNETYPE_X|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1|11, - _RUNETYPE_L|_RUNETYPE_X|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1|12, - _RUNETYPE_L|_RUNETYPE_X|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1|13, - _RUNETYPE_L|_RUNETYPE_X|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1|14, - _RUNETYPE_L|_RUNETYPE_X|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1|15, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - /*68*/ _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - /*70*/ _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - /*78*/ _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_C, -#ifdef ALL_80_TO_FF_SW1 - /*80*/ _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - /*90*/ _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - /*A0*/ _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - /*B0*/ _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - /*C0*/ _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - /*D0*/ _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - /*E0*/ _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - /*F0*/ _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, -#endif - }, - { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x40, 'a', 'b', 'c', 'd', 'e', 'f', 'g', - 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', - 'x', 'y', 'z', 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, - 0x60, 'a', 'b', 'c', 'd', 'e', 'f', 'g', - 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', - 'x', 'y', 'z', 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, - 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, - 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, - 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, - 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, - 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, - 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, - 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, - 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, - 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, - 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, - 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, - 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, - }, - { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x40, 'A', 'B', 'C', 'D', 'E', 'F', 'G', - 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', - 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', - 'X', 'Y', 'Z', 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, - 0x60, 'A', 'B', 'C', 'D', 'E', 'F', 'G', - 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', - 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', - 'X', 'Y', 'Z', 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, - 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, - 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, - 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, - 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, - 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, - 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, - 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, - 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, - 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, - 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, - 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, - 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, - }, -}; - - - diff --git a/src/libSystem/libc/setjmp-arm.s b/src/libSystem/libc/setjmp-arm.s deleted file mode 100644 index 108e017c4..000000000 --- a/src/libSystem/libc/setjmp-arm.s +++ /dev/null @@ -1,20 +0,0 @@ -.globl __darwin_longjmp -.globl __darwin_setjmp - -__darwin_longjmp: - -ldmia r0!, { r4-r8, r10-r14 } -vldmia r0, { d8-d15 } -movs r0, r1 -moveq r0, #1 -bx r14 - -__darwin_setjmp: - -stmia r0!, { r4-r8, r10-r14 } -vstmia r0, { d8-d15 } -mov r0, #0 -bx r14 - -// TODO: signal save variants - diff --git a/src/libSystem/libc/setjmp.h b/src/libSystem/libc/setjmp.h deleted file mode 100644 index 08824c7f1..000000000 --- a/src/libSystem/libc/setjmp.h +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef LIBC_SETJMP_H -#define LIBC_SETJMP_H -#include -#include "signals.h" - -//#pragma pack (1) -#if defined(__x86_64__) - -struct darwin_jmp_buf_t -{ - int64_t rbp, rbx, r12, r13, r14, r15, rip, rsp; - int32_t mxcsr; - int16_t fpstate; - __darwin_sigset_t sigset; - stack_t stack; -}; - -#define JMP_BUF_HAS_STACK - -typedef darwin_jmp_buf_t* darwin_jmp_buf; -typedef darwin_jmp_buf darwin_sigjmp_buf; - -#elif defined(__i386__) - -struct darwin_jmp_buf_t -{ - int32_t edi, esi, ebx, ebp, eip, esp; - int32_t mxcsr; - int16_t fpstate; - __darwin_sigset_t sigset; - stack_t stack; -}; - -#define JMP_BUF_HAS_STACK - -typedef darwin_jmp_buf_t* darwin_jmp_buf; -typedef darwin_jmp_buf darwin_sigjmp_buf; - -#elif defined(__arm__) - -struct darwin_jmp_buf_t -{ - int32_t r4, r5, r6, r7, r8, r10, r11; - int32_t sp, lr; - int32_t d8, d9, d10, d11, d12, d13, d14, d15; - int32_t sig, fstmx; - int32_t reserved; -}; - -struct darwin_sigjmp_buf_t -{ - int32_t r4, r5, r6, r7, r8, r10, r11; - int32_t sp, lr; - int32_t d8, d9, d10, d11, d12, d13, d14, d15; - int32_t sig, fstmx; - int32_t reserved; - __darwin_sigset_t sigset; -}; - -typedef darwin_jmp_buf_t* darwin_jmp_buf; -typedef darwin_sigjmp_buf_t* darwin_sigjmp_buf; - -#else -# error Unsupported platform! -#endif - -extern "C" { - -// defined in assembly -int __darwin_setjmp(darwin_jmp_buf buf); -int __darwin_sigsetjmp(darwin_sigjmp_buf buf, int savesigs); -void __darwin_longjmp(darwin_jmp_buf env, int val); -void __darwin_siglongjmp(darwin_sigjmp_buf env, int val); - -// internal calls -void __darwin_savesigs(darwin_sigjmp_buf env); -void __darwin_restoresigs(darwin_sigjmp_buf env); - -} - -#endif - diff --git a/src/libSystem/libc/setjmp.nasm b/src/libSystem/libc/setjmp.nasm deleted file mode 100644 index 95ea75f8b..000000000 --- a/src/libSystem/libc/setjmp.nasm +++ /dev/null @@ -1,170 +0,0 @@ - -global __darwin_setjmp -global __darwin_sigsetjmp -global __darwin_longjmp -global __darwin_siglongjmp - -extern __darwin_savesigs -extern __darwin_restoresigs - -section .note.GNU-stack noalloc noexec nowrite progbits - -%ifidn __OUTPUT_FORMAT__, elf64 - -BITS 64 -section text - -__darwin_setjmp: - mov rsi, 1 - -__darwin_sigsetjmp: - - test rsi, rsi - jz .no_sig_save_z - - push rdi - call __darwin_savesigs WRT ..plt - pop rdi - jmp .no_sig_save - -.no_sig_save_z: - mov dword [rdi+88], 0 ; zero out signal stack flags -.no_sig_save: - mov rax, [rsp] - lea rcx, [rsp+8] - - mov [rdi], rbp - mov [rdi+8], rbx - mov [rdi+16], r12 - mov [rdi+24], r13 - mov [rdi+32], r14 - mov [rdi+40], r15 - mov [rdi+48], rax ; ret addr - mov [rdi+56], rcx ; rsp - - stmxcsr [rdi+64] - fnstcw [rdi+68] - - xor eax, eax - ret - -__darwin_longjmp: -__darwin_siglongjmp: - - push rdi - call __darwin_restoresigs WRT ..plt - pop rdi - - mov eax, 1 - test esi, esi - cmovnz eax, esi - - mov rbp, [rdi] - mov rbx, [rdi+8] - mov r12, [rdi+16] - mov r13, [rdi+24] - mov r14, [rdi+32] - mov r15, [rdi+40] - mov rsp, [rdi+56] - - fninit - ldmxcsr [rdi+64] - fldcw [rdi+68] - cld - - jmp [rdi+48] - -%elifidn __OUTPUT_FORMAT__, elf - -BITS 32 -section text - -extern _GLOBAL_OFFSET_TABLE_ - -%macro gotcall 1 - push ebx - call .get_GOT -.get_GOT: - pop ebx - add ebx,_GLOBAL_OFFSET_TABLE_+$$-.get_GOT wrt ..gotpc - lea ecx, [ebx + %1 WRT ..got] - pop ebx - - call [ecx] -%endmacro - -__darwin_setjmp: - - mov eax, [esp+4] - push eax - gotcall __darwin_savesigs - add esp, 4 - - jmp no_sig_save - -__darwin_sigsetjmp: - - test dword [esp+8], 0 - je .no_sig_save_z - - mov eax, [esp+4] - push eax - gotcall __darwin_savesigs - add esp, 4 - - jmp no_sig_save - -.no_sig_save_z: - mov ecx, [esp+4] - mov dword [ecx+44], 0 ; zero out signal stack flags - -no_sig_save: - - mov ecx, [esp+4] - mov [ecx], edi - mov [ecx+4], esi - mov [ecx+8], ebx - mov [ecx+12], ebp - mov eax, [esp] - mov [ecx+16], eax - lea eax, [esp+4] - mov [ecx+20], eax - - stmxcsr [ecx+24] - fnstcw [ecx+28] - - xor eax, eax - ret - -__darwin_longjmp: -__darwin_siglongjmp: - mov eax, [esp+4] - push eax - gotcall __darwin_restoresigs - add esp, 4 - -no_sig_restore: - - mov eax, 1 - test dword [esp+8], 0 - cmovne eax, [esp+8] - - mov ecx, [esp+4] - mov edi, [ecx] - mov esi, [ecx+4] - mov ebx, [ecx+8] - mov ebp, [ecx+12] - mov esp, [ecx+20] - - fninit - ldmxcsr [ecx+24] - fldcw [ecx+28] - cld - - jmp [ecx+16] - -%else - -%error "Unsupported platform" - -%endif diff --git a/src/libSystem/libc/signals.cpp b/src/libSystem/libc/signals.cpp deleted file mode 100644 index a4f72fb9c..000000000 --- a/src/libSystem/libc/signals.cpp +++ /dev/null @@ -1,286 +0,0 @@ -#include "config.h" -#include "signals.h" -#include "errno.h" -#include "common/auto.h" -#include "Bidimap.h" -#include -#include -#include -#include -#include "darwin_errno_codes.h" - -static Darling::MappedFlag g_sigactionFlags[] = { - { DARWIN_SA_ONSTACK, SA_ONSTACK }, - { DARWIN_SA_RESTART, SA_RESTART }, - { DARWIN_SA_RESETHAND, int(SA_RESETHAND) }, - { DARWIN_SA_NOCLDSTOP, SA_NOCLDSTOP }, - { DARWIN_SA_NODEFER, SA_NODEFER }, - { DARWIN_SA_NOCLDWAIT, SA_NOCLDWAIT }, - { DARWIN_SA_SIGINFO, SA_SIGINFO } -}; - -typedef void(*HandlerType)(int,siginfo_t*,void*); -static int g_sigLinuxToDarwin[33], g_sigDarwinToLinux[33]; -static const int SIGNAL_MAX = 31; -static HandlerType g_darwinHandlers[32]; - -__attribute__((constructor)) -static void initializeSignalMaps() -{ - Darling::Bidimap map(g_sigLinuxToDarwin, g_sigDarwinToLinux); - map.put(SIGHUP, DARWIN_SIGHUP); - map.put(SIGINT, DARWIN_SIGINT); - map.put(SIGQUIT, DARWIN_SIGQUIT); - map.put(SIGILL, DARWIN_SIGILL); - map.put(SIGTRAP, DARWIN_SIGTRAP); - map.put(SIGABRT, DARWIN_SIGABRT); - map.put(SIGPOLL, DARWIN_SIGPOLL); - map.put(SIGFPE, DARWIN_SIGFPE); - map.put(SIGKILL, DARWIN_SIGKILL); - map.put(SIGBUS, DARWIN_SIGBUS); - map.put(SIGSEGV, DARWIN_SIGSEGV); - map.put(SIGSYS, DARWIN_SIGSYS); - map.put(SIGPIPE, DARWIN_SIGPIPE); - map.put(SIGALRM, DARWIN_SIGALRM); - map.put(SIGTERM, DARWIN_SIGTERM); - map.put(SIGURG, DARWIN_SIGURG); - map.put(SIGSTOP, DARWIN_SIGSTOP); - map.put(SIGTSTP, DARWIN_SIGTSTP); - map.put(SIGCONT, DARWIN_SIGCONT); - map.put(SIGCHLD, DARWIN_SIGCHLD); - map.put(SIGTTIN, DARWIN_SIGTTIN); - map.put(SIGTTOU, DARWIN_SIGTTOU); - map.put(SIGIO, DARWIN_SIGIO); - map.put(SIGXCPU, DARWIN_SIGXCPU); - map.put(SIGXFSZ, DARWIN_SIGXFSZ); - map.put(SIGVTALRM, DARWIN_SIGVTALRM); - map.put(SIGPROF, DARWIN_SIGPROF); - map.put(SIGWINCH, DARWIN_SIGWINCH); - //map.put(SIGINFO, DARWIN_SIGINFO); // N/A on Linux - map.put(SIGUSR1, DARWIN_SIGUSR1); - map.put(SIGUSR2, DARWIN_SIGUSR2); - - std::fill(g_darwinHandlers, g_darwinHandlers+32, reinterpret_cast(SIG_DFL)); -} - -int Darling::signalLinuxToDarwin(int sig) -{ - return g_sigLinuxToDarwin[sig]; -} - -int Darling::signalDarwinToLinux(int sig) -{ - return g_sigDarwinToLinux[sig]; -} - -static void GenericHandler(int sig, siginfo_t* p, void* p2) -{ - int dsig = g_sigLinuxToDarwin[sig]; - //std::cout << "GenericHandler invoking " << (void*)g_darwinHandlers[sig] << " for sig " << dsig << std::endl; - g_darwinHandlers[sig](dsig, p, p2); - //std::cout << "Handler exited\n"; -} - -sighandler_t __darwin_signal(int signum, sighandler_t handler) -{ - signum = g_sigDarwinToLinux[signum]; - g_darwinHandlers[signum] = reinterpret_cast(handler); - - if (handler != SIG_DFL && handler != SIG_IGN && handler) - handler = reinterpret_cast(GenericHandler); - - return signal(signum, handler); -} - -sigset_t Darling::sigsetDarwinToLinux(const __darwin_sigset_t* set) -{ - sigset_t rv; - - sigemptyset(&rv); - - for (int i = 0; i <= SIGNAL_MAX; i++) - { - if (*set & (1 << i)) - sigaddset(&rv, g_sigDarwinToLinux[i+1]); - } - - return rv; -} - -__darwin_sigset_t Darling::sigsetLinuxToDarwin(const sigset_t* set) -{ - __darwin_sigset_t rv = 0; - - for (int i = 0; i <= SIGNAL_MAX; i++) - { - if (sigismember(set, i+1) > 0) - rv |= (1 << g_sigLinuxToDarwin[i+1]); - } - - return rv; -} - -// TODO: check siginfo compatibility -// TODO: map signal numbers for -int __darwin_sigaction(int signum, const struct __darwin_sigaction* act, struct __darwin_sigaction* oldact) -{ - std::unique_ptr nact; - std::unique_ptr noldact; - HandlerType oldhdl = 0; - - signum = g_sigDarwinToLinux[signum]; - - if (oldact) - noldact.reset(new struct sigaction); - - if (act) - { - nact.reset(new struct sigaction); - nact->sa_flags = Darling::flagsDarwinToNative(g_sigactionFlags, sizeof(g_sigactionFlags)/sizeof(g_sigactionFlags[0]), act->sa_flags); - nact->sa_flags |= SA_SIGINFO; - nact->sa_handler = act->xsa_handler; - nact->sa_sigaction = act->xsa_sigaction; - nact->sa_mask = Darling::sigsetDarwinToLinux(&act->sa_mask); - oldhdl = g_darwinHandlers[signum]; - - // defer a user-supplied function to a wrapper that will translate the signal number - if (act->xsa_handler != SIG_IGN && act->xsa_handler != SIG_DFL) - { - assert(act->xsa_handler != SIG_IGN); - assert(act->xsa_handler != ((void (*)(int))1)); - //std::cout << "Setting GenericHandler for " << signum << " (orig handler: " << ((void*)act->xsa_handler) << "!= " << (void*)SIG_IGN << ")" << std::endl; - nact->sa_sigaction = GenericHandler; - } - g_darwinHandlers[signum] = act->xsa_sigaction; - } - - int rv = sigaction(signum, nact.get(), noldact.get()); - - if (rv != -1 && noldact) - { - oldact->sa_flags = Darling::flagsNativeToDarwin(g_sigactionFlags, sizeof(g_sigactionFlags)/sizeof(g_sigactionFlags[0]), noldact->sa_flags); - - if (noldact->sa_flags & SA_SIGINFO) - oldact->xsa_sigaction = noldact->sa_sigaction; - else - oldact->xsa_handler = noldact->sa_handler; - oldact->xsa_sigaction = oldhdl; - oldact->sa_mask = Darling::sigsetLinuxToDarwin(&noldact->sa_mask); - - //std::cout << "Old handler for " << signum << ": " << (void*)oldhdl << std::endl; - } - if (rv == -1) - errnoOut(); - - return rv; -} - -int __darwin_sigemptyset(__darwin_sigset_t *set) -{ - *set = 0; - return 0; -} - -int __darwin_sigfillset(__darwin_sigset_t *set) -{ - *set = 0xffffffff; - return 0; -} - -int __darwin_sigaddset(__darwin_sigset_t *set, int signum) -{ - if (signum >= SIGNAL_MAX) - { - errno = DARWIN_EINVAL; - return -1; - } - else - { - *set |= (1 << (signum-1)); - return 0; - } -} - -int __darwin_sigdelset(__darwin_sigset_t *set, int signum) -{ - if (signum >= SIGNAL_MAX) - { - errno = DARWIN_EINVAL; - return -1; - } - else - { - *set &= ~(1 << (signum-1)); - return 0; - } -} - -int __darwin_sigismember(__darwin_sigset_t *set, int signum) -{ - if (signum >= SIGNAL_MAX) - { - errno = DARWIN_EINVAL; - return -1; - } - else - { - return (*set & (1 << (signum-1))) ? 1 : 0; - } -} - -int __darwin_sigprocmask(int how, const __darwin_sigset_t *set, __darwin_sigset_t *oldset) -{ - std::unique_ptr nset; - std::unique_ptr noldset; - - if (set) - { - nset.reset(new sigset_t); - *nset = Darling::sigsetDarwinToLinux(set); - } - if (oldset) - noldset.reset(new sigset_t); - - // -1 -> conversion from Darwin to Linux - int rv = sigprocmask(how - 1, nset.get(), noldset.get()); - - if (rv == -1) - errnoOut(); - else if (oldset) - *oldset = Darling::sigsetLinuxToDarwin(noldset.get()); - - return rv; -} - -int __darwin_sigsuspend(const __darwin_sigset_t *mask) -{ - sigset_t set = Darling::sigsetDarwinToLinux(mask); - int rv = sigsuspend(&set); - if (rv == -1) - errnoOut(); - return rv; -} - -int __darwin_sigwait(const __darwin_sigset_t *set, int *sig) -{ - sigset_t nset = Darling::sigsetDarwinToLinux(set); - int rv = sigwait(&nset, sig); - if (rv == -1) - errnoOut(); - *sig = g_sigLinuxToDarwin[*sig]; - return rv; -} - -int __darwin_sigpending(__darwin_sigset_t *set) -{ - sigset_t nset; - int rv = sigpending(&nset); - - if (rv == -1) - errnoOut(); - else - *set = Darling::sigsetLinuxToDarwin(&nset); - return rv; -} - - diff --git a/src/libSystem/libc/signals.h b/src/libSystem/libc/signals.h deleted file mode 100644 index 54d2bb29f..000000000 --- a/src/libSystem/libc/signals.h +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef SIGNALS_H -#define SIGNALS_H -#include - -#define DARWIN_SA_ONSTACK 0x0001 -#define DARWIN_SA_RESTART 0x0002 -#define DARWIN_SA_RESETHAND 0x0004 -#define DARWIN_SA_NOCLDSTOP 0x0008 -#define DARWIN_SA_NODEFER 0x0010 -#define DARWIN_SA_NOCLDWAIT 0x0020 -#define DARWIN_SA_SIGINFO 0x0040 - -#define DARWIN_SIGHUP 1 -#define DARWIN_SIGINT 2 -#define DARWIN_SIGQUIT 3 -#define DARWIN_SIGILL 4 -#define DARWIN_SIGTRAP 5 -#define DARWIN_SIGABRT 6 -#define DARWIN_SIGPOLL 7 -#define DARWIN_SIGFPE 8 -#define DARWIN_SIGKILL 9 -#define DARWIN_SIGBUS 10 -#define DARWIN_SIGSEGV 11 -#define DARWIN_SIGSYS 12 -#define DARWIN_SIGPIPE 13 -#define DARWIN_SIGALRM 14 -#define DARWIN_SIGTERM 15 -#define DARWIN_SIGURG 16 -#define DARWIN_SIGSTOP 17 -#define DARWIN_SIGTSTP 18 -#define DARWIN_SIGCONT 19 -#define DARWIN_SIGCHLD 20 -#define DARWIN_SIGTTIN 21 -#define DARWIN_SIGTTOU 22 -#define DARWIN_SIGIO 23 -#define DARWIN_SIGXCPU 24 -#define DARWIN_SIGXFSZ 25 -#define DARWIN_SIGVTALRM 26 -#define DARWIN_SIGPROF 27 -#define DARWIN_SIGWINCH 28 -#define DARWIN_SIGINFO 29 -#define DARWIN_SIGUSR1 30 -#define DARWIN_SIGUSR2 31 - -typedef int __darwin_sigset_t; -struct __darwin_sigaction -{ - union - { - void (*xsa_handler)(int); // sa_handler is often broken due to macro pollution - void (*xsa_sigaction)(int, siginfo_t *, void*); - }; - __darwin_sigset_t sa_mask; - int sa_flags; -}; - -extern "C" -{ - -sighandler_t __darwin_signal(int signum, sighandler_t handler); -int __darwin_sigaction(int signum, const struct __darwin_sigaction* act, struct __darwin_sigaction* oldact); -int __darwin_sigprocmask(int how, const __darwin_sigset_t *set, __darwin_sigset_t *oldset); - -int __darwin_sigemptyset(__darwin_sigset_t *set); -int __darwin_sigfillset(__darwin_sigset_t *set); -int __darwin_sigaddset(__darwin_sigset_t *set, int signum); -int __darwin_sigdelset(__darwin_sigset_t *set, int signum); -int __darwin_sigismember(__darwin_sigset_t *set, int signum); - -int __darwin_sigsuspend(const __darwin_sigset_t *mask); -int __darwin_sigwait(const __darwin_sigset_t *set, int *sig); -int __darwin_sigpending(__darwin_sigset_t *set); - -} - -namespace Darling -{ - int signalLinuxToDarwin(int sig); - int signalDarwinToLinux(int sig); - - sigset_t sigsetDarwinToLinux(const __darwin_sigset_t* set); - __darwin_sigset_t sigsetLinuxToDarwin(const sigset_t* set); -} - -#endif - diff --git a/src/libSystem/libc/sigsetjmp.cpp b/src/libSystem/libc/sigsetjmp.cpp deleted file mode 100644 index eebf4b89f..000000000 --- a/src/libSystem/libc/sigsetjmp.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "setjmp.h" -#include -#include -#include - -void __darwin_savesigs(darwin_sigjmp_buf env) -{ - __darwin_sigprocmask(SIG_BLOCK, nullptr, &env->sigset); -#ifdef JMP_BUF_HAS_STACK - sigaltstack(nullptr, &env->stack); -#endif -} - -void __darwin_restoresigs(darwin_sigjmp_buf env) -{ -#ifdef JMP_BUF_HAS_STACK - if (env->stack.ss_flags != 0) - { - __darwin_sigprocmask(SIG_SETMASK, &env->sigset, nullptr); - sigaltstack(&env->stack, nullptr); - } -#else - __darwin_sigprocmask(SIG_SETMASK, &env->sigset, nullptr); -#endif -} - diff --git a/src/libSystem/libc/spawn.cpp b/src/libSystem/libc/spawn.cpp deleted file mode 100644 index ddc0aaff1..000000000 --- a/src/libSystem/libc/spawn.cpp +++ /dev/null @@ -1,203 +0,0 @@ -#include "config.h" -#include "spawn.h" -#include "errno.h" -#include "../common/auto.h" -#include "../kernel-bsd/io.h" -#include "darwin_errno_codes.h" -#include "exec.h" -#include -#include "MachO.h" -#include "trace.h" - -template int GenericInit(T* t, NativeInit nativeInit) -{ - int err; - - if (!t) - return DARWIN_EINVAL; - - t->native = new typename std::remove_referencenative)>::type; - err = AutoErrnoPosix(nativeInit, t->native); - - if (err) - delete t->native; - return err; -} - -template int GenericDestroy(T* t, NativeDestroy nativeDestroy) -{ - if (t != nullptr) - { - int err = AutoErrnoPosix(nativeDestroy, t->native); - delete t->native; - return err; - } - else - return DARWIN_EINVAL; -} - -int __darwin_posix_spawn_file_actions_destroy(__darwin_posix_spawn_file_actions_t* file_actions) -{ - return GenericDestroy(file_actions, posix_spawn_file_actions_destroy); -} - -int __darwin_posix_spawn_file_actions_init(__darwin_posix_spawn_file_actions_t* file_actions) -{ - return GenericInit(file_actions, posix_spawn_file_actions_init); -} - -int __darwin_posix_spawn_file_actions_addclose(__darwin_posix_spawn_file_actions_t* file_actions, int filedes) -{ - return AutoErrnoPosix(posix_spawn_file_actions_addclose, file_actions ? file_actions->native : nullptr, filedes); -} - -int __darwin_posix_spawn_file_actions_addopen(__darwin_posix_spawn_file_actions_t* file_actions, int filedes, const char* path, int oflag, mode_t mode) -{ - return AutoErrnoPosix(posix_spawn_file_actions_addopen, file_actions ? file_actions->native : nullptr, - filedes, translatePathCI(path), Darling::openflagsDarwinToNative(oflag), mode); -} - -int __darwin_posix_spawn_file_actions_adddup2(__darwin_posix_spawn_file_actions_t* file_actions, int filedes, int newfiledes) -{ - return AutoErrnoPosix(posix_spawn_file_actions_adddup2, file_actions ? file_actions->native : nullptr, filedes, newfiledes); -} - -int __darwin_posix_spawn_file_actions_addinherit_np(__darwin_posix_spawn_file_actions_t* file_actions, int filedes) -{ - return DARWIN_ENOTSUP; -} - -int __darwin_posix_spawnattr_destroy(__darwin_posix_spawnattr_t* attr) -{ - return GenericDestroy(attr, posix_spawnattr_destroy); -} - -int __darwin_posix_spawnattr_init(__darwin_posix_spawnattr_t* attr) -{ - return GenericInit(attr, posix_spawnattr_init); -} - -int __darwin_posix_spawnattr_getsigdefault(const __darwin_posix_spawnattr_t* attr, __darwin_sigset_t* sigdefault) -{ - sigset_t ns; - int err = AutoErrnoPosix(posix_spawnattr_getsigdefault, attr ? attr->native : nullptr, &ns); - - if (!err) - *sigdefault = Darling::sigsetLinuxToDarwin(&ns); - - return err; -} - -int __darwin_posix_spawnattr_setsigdefault(__darwin_posix_spawnattr_t* attr, const __darwin_sigset_t* sigdefault) -{ - sigset_t ns; - ns = Darling::sigsetDarwinToLinux(sigdefault); - - return AutoErrnoPosix(posix_spawnattr_setsigdefault, attr ? attr->native : nullptr, &ns); -} - -int __darwin_posix_spawnattr_getsigmask(const __darwin_posix_spawnattr_t* attr, __darwin_sigset_t* sigmask) -{ - sigset_t ns; - int err = AutoErrnoPosix(posix_spawnattr_getsigmask, attr ? attr->native : nullptr, &ns); - - if (!err) - *sigmask = Darling::sigsetLinuxToDarwin(&ns); - - return err; -} - -int __darwin_posix_spawnattr_setsigmask(__darwin_posix_spawnattr_t* attr, const __darwin_sigset_t* sigmask) -{ - sigset_t ns; - ns = Darling::sigsetDarwinToLinux(sigmask); - - return AutoErrnoPosix(posix_spawnattr_setsigmask, attr ? attr->native : nullptr, &ns); -} - - -// flag values are compatible -int __darwin_posix_spawnattr_getflags(const __darwin_posix_spawnattr_t* attr, short* flags) -{ - return AutoErrnoPosix(posix_spawnattr_getflags, attr ? attr->native : nullptr, flags); -} - -int __darwin_posix_spawnattr_setflags(__darwin_posix_spawnattr_t* attr, short flags) -{ - return AutoErrnoPosix(posix_spawnattr_setflags, attr ? attr->native : nullptr, flags); -} - -int __darwin_posix_spawnattr_getpgroup(const __darwin_posix_spawnattr_t* attr, pid_t* pgroup) -{ - return AutoErrnoPosix(posix_spawnattr_getpgroup, attr ? attr->native : nullptr, pgroup); -} - -int __darwin_posix_spawnattr_setpgroup(__darwin_posix_spawnattr_t *attr, pid_t pgroup) -{ - return AutoErrnoPosix(posix_spawnattr_setpgroup, attr ? attr->native : nullptr, pgroup); -} - -int __darwin_posix_spawnattr_getschedparam(const __darwin_posix_spawnattr_t* attr, struct sched_param* schedparam) -{ - return AutoErrnoPosix(posix_spawnattr_getschedparam, attr ? attr->native : nullptr, schedparam); -} - -int __darwin_posix_spawnattr_setschedparam(__darwin_posix_spawnattr_t* attr, const struct sched_param* schedparam) -{ - return AutoErrnoPosix(posix_spawnattr_setschedparam, attr ? attr->native : nullptr, schedparam); -} - -int __darwin_posix_spawnattr_getschedpolicy(const __darwin_posix_spawnattr_t* attr, int* schedpolicy) -{ - return AutoErrnoPosix(posix_spawnattr_getschedpolicy, attr ? attr->native : nullptr, schedpolicy); -} - -int __darwin_posix_spawnattr_setschedpolicy(__darwin_posix_spawnattr_t *attr, int schedpolicy) -{ - return AutoErrnoPosix(posix_spawnattr_setschedpolicy, attr ? attr->native : nullptr, schedpolicy); -} - -int __darwin_posix_spawn(pid_t* pid, const char* path, const __darwin_posix_spawn_file_actions_t* file_actions, const __darwin_posix_spawnattr_t* attrp, - char* const argv[], char* const envp[]) -{ - TRACE6(pid, path, file_actions, attrp, argv, envp); - char* const* argv_copy = nullptr; - int err; - - path = translatePathCI(path); - - if (MachO::isMachO(path)) - { - argv = argv_copy = Darling::prependLoaderPath(argv, path); - path = argv[0]; - } - - err = AutoErrnoPosix(posix_spawn, pid, path, file_actions ? file_actions->native : nullptr, - attrp ? attrp->native : nullptr, argv, envp); - - delete [] argv_copy; - return err; -} - -int __darwin_posix_spawnp(pid_t* pid, const char* file, const __darwin_posix_spawn_file_actions_t* file_actions,const __darwin_posix_spawnattr_t* attrp, - char* const argv[], char* const envp[]) -{ - TRACE6(pid, file, file_actions, attrp, argv, envp); - char* const* argv_copy = nullptr; - int err; - - const char* path = Darling::findInPath(file); - if (!path) - return DARWIN_ENOENT; - - if (MachO::isMachO(path)) - argv = argv_copy = Darling::prependLoaderPath(argv, path); - - err = AutoErrnoPosix(posix_spawn, pid, path, file_actions ? file_actions->native : nullptr, - attrp ? attrp->native : nullptr, argv, envp); - - delete [] argv_copy; - return err; -} - - diff --git a/src/libSystem/libc/spawn.h b/src/libSystem/libc/spawn.h deleted file mode 100644 index 5bf061a23..000000000 --- a/src/libSystem/libc/spawn.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef LIBC_SPAWN_H -#define LIBC_SPAWN_H -#include -#include "signals.h" - -extern "C" { - -// sizeof on Darwin: ptr size -// sizeof on Linux (x86-64): 80 bytes -struct __darwin_posix_spawn_file_actions_t -{ - posix_spawn_file_actions_t* native; -}; - -struct __darwin_posix_spawnattr_t -{ - posix_spawnattr_t* native; -}; - -int __darwin_posix_spawn_file_actions_destroy(__darwin_posix_spawn_file_actions_t* file_actions); -int __darwin_posix_spawn_file_actions_init(__darwin_posix_spawn_file_actions_t* file_actions); - -int __darwin_posix_spawn_file_actions_addclose(__darwin_posix_spawn_file_actions_t* file_actions, int filedes); -int __darwin_posix_spawn_file_actions_addopen(__darwin_posix_spawn_file_actions_t* file_actions, int filedes, const char* path, int oflag, mode_t mode); -int __darwin_posix_spawn_file_actions_adddup2(__darwin_posix_spawn_file_actions_t* file_actions, int filedes, int newfiledes); -int __darwin_posix_spawn_file_actions_addinherit_np(__darwin_posix_spawn_file_actions_t* file_actions, int filedes); - -int __darwin_posix_spawnattr_destroy(__darwin_posix_spawnattr_t* attr); -int __darwin_posix_spawnattr_init(__darwin_posix_spawnattr_t* attr); - -int __darwin_posix_spawnattr_getsigdefault(const __darwin_posix_spawnattr_t* attr, __darwin_sigset_t* sigdefault); -int __darwin_posix_spawnattr_setsigdefault(__darwin_posix_spawnattr_t* attr, const __darwin_sigset_t* sigdefault); -int __darwin_posix_spawnattr_getsigmask(const __darwin_posix_spawnattr_t* attr, __darwin_sigset_t* sigmask); -int __darwin_posix_spawnattr_setsigmask(__darwin_posix_spawnattr_t* attr, const __darwin_sigset_t* sigmask); -int __darwin_posix_spawnattr_getflags(const __darwin_posix_spawnattr_t* attr, short* flags); -int __darwin_posix_spawnattr_setflags(__darwin_posix_spawnattr_t* attr, short flags); -int __darwin_posix_spawnattr_getpgroup(const __darwin_posix_spawnattr_t* attr, pid_t* pgroup); -int __darwin_posix_spawnattr_setpgroup(__darwin_posix_spawnattr_t *attr, pid_t pgroup); -int __darwin_posix_spawnattr_getschedparam(const __darwin_posix_spawnattr_t* attr, struct sched_param* schedparam); -int __darwin_posix_spawnattr_setschedparam(__darwin_posix_spawnattr_t* attr, const struct sched_param* schedparam); -int __darwin_posix_spawnattr_getschedpolicy(const __darwin_posix_spawnattr_t* attr, int* schedpolicy); -int __darwin_posix_spawnattr_setschedpolicy(__darwin_posix_spawnattr_t *attr, int schedpolicy); - -int __darwin_posix_spawn(pid_t* pid, const char* path, const __darwin_posix_spawn_file_actions_t* file_actions, const __darwin_posix_spawnattr_t* attrp, - char* const argv[], char* const envp[]); -int __darwin_posix_spawnp(pid_t* pid, const char* file, const __darwin_posix_spawn_file_actions_t* file_actions,const __darwin_posix_spawnattr_t* attrp, - char* const argv[], char* const envp[]); - -} - -#endif - diff --git a/src/libSystem/libc/stack_protector-obsd.c b/src/libSystem/libc/stack_protector-obsd.c deleted file mode 100644 index 8ef38b426..000000000 --- a/src/libSystem/libc/stack_protector-obsd.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2002 Hiroaki Etoh, Federico G. Schwindt, and Miodrag Vallat. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -#if defined(LIBC_SCCS) && !defined(list) -static char rcsid[] = "$OpenBSD: stack_protector.c,v 1.3 2002/12/10 08:53:42 etoh Exp $"; -#endif - -#include "config.h" -#include -#include -#include -#include -#include -#include -#include - -long __stack_chk_guard[8] = {0, 0, 0, 0, 0, 0, 0, 0}; -void __guard_setup(void) __attribute__ ((visibility ("hidden"))); -void __stack_chk_fail(void); - -void -__guard_setup(void) -{ - int fd; - if (__stack_chk_guard[0]!=0) return; - fd = open ("/dev/urandom", 0); - if (fd != -1) { - ssize_t size = read (fd, (char*)&__stack_chk_guard, - sizeof(__stack_chk_guard)); - close (fd) ; - if (size == sizeof(__stack_chk_guard) - && *__stack_chk_guard != 0) return; - } - /* If a random generator can't be used, the protector switches the guard - to the "terminator canary" */ - ((char*)__stack_chk_guard)[0] = 0; ((char*)__stack_chk_guard)[1] = 0; - ((char*)__stack_chk_guard)[2] = '\n'; ((char*)__stack_chk_guard)[3] = 255; -} - -void -__stack_chk_fail() -{ - const char message[] = "[%d] stack overflow"; - - /* this may fail on a chroot jail, though luck */ - syslog(LOG_CRIT, message, getpid()); - - abort(); -} diff --git a/src/libSystem/libc/stdio.cpp b/src/libSystem/libc/stdio.cpp deleted file mode 100644 index acf4652aa..000000000 --- a/src/libSystem/libc/stdio.cpp +++ /dev/null @@ -1,480 +0,0 @@ -#include -#include "libsystem-config.h" -#include "stdio.h" -#include "errno.h" -#include "common/path.h" -#include "common/auto.h" -#include "trace.h" -#include "darwin_errno_codes.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "log.h" -#include -#include - -#ifdef HAS_BSD_WCHAR_H -# include -#endif - -template class __gnu_cxx::stdio_filebuf >; -template class std::basic_filebuf >; - -//extern "C" -//{ - -__darwin_FILE __sF[3] asm("__sF"); - -__darwin_FILE* __stdinp asm("__stdinp") = &__sF[0]; -__darwin_FILE* __stdoutp asm("__stdoutp") = &__sF[1]; -__darwin_FILE* __stderrp asm("__stderrp") = &__sF[2]; -//} - -static __darwin_FILE* InitDarwinFILE(FILE* linux_fp, __darwin_FILE* fp) -{ - fp->_p = NULL; - fp->_r = -1; - fp->_w = -1; - fp->_flags = 0; - fp->_file = fileno(linux_fp); - fp->_lbfsize = 0; - fp->linux_fp = linux_fp; - - return fp; -} - -static __darwin_FILE* InitDarwinFILE(FILE* linux_fp) -{ - if (!linux_fp) - return 0; - - __darwin_FILE* fp = new __darwin_FILE; - return InitDarwinFILE(linux_fp, fp); -} - - -template RetVal AutoFileErrno(Func f, __darwin_FILE* file, Params... params) -{ - RetVal rv = f(params..., file ? file->linux_fp : nullptr); - if (!retvalOK(rv)) - errnoOut(); - return rv; -} - -__darwin_FILE* __darwin_fopen(const char* path, const char* mode) -{ - TRACE2(path, mode); - if (!strchr(mode, 'w') && Darling::MachOMgr::instance()->hasSysRoot()) - { - const char* prefixed; - std::string lpath = Darling::MachOMgr::instance()->sysRoot(); - lpath += '/'; - lpath += path; - - prefixed = translatePathCI(lpath.c_str()); - if (::access(prefixed, F_OK) == 0) - path = prefixed; - else - path = translatePathCI(path); - } - else - path = translatePathCI(path); - - if (!strchr(mode, 'x')) - return InitDarwinFILE(fopen(path, mode)); - else // DARWIN_EXTSN - { - std::string m = mode; - size_t pos = m.find('x'); - m.erase(pos, 1); - - int flags = O_CREAT | O_EXCL; - if (m.find('a') != std::string::npos) - flags |= O_APPEND; - if (m.find('+') != std::string::npos) - flags |= O_RDWR; - else - flags |= O_WRONLY; - - int fd = ::open(path, flags, 0666); - if (fd == -1) - return 0; - else - return __darwin_fdopen(fd, m.c_str()); - } -} - -__darwin_FILE* __darwin_popen(const char* command, const char* type) -{ - return InitDarwinFILE(popen(command, type)); // translatePathCI? -} - -int __darwin_pclose(__darwin_FILE* stream) -{ - int r = pclose(stream->linux_fp); - delete stream; - if (r == -1) - errnoOut(); - return r; -} - -__darwin_FILE* __darwin_fdopen(int fd, const char* mode) -{ - return InitDarwinFILE(fdopen(fd, mode)); -} - -__darwin_FILE* __darwin_freopen(const char* path, const char* mode, __darwin_FILE* fp) -{ - return InitDarwinFILE(freopen(translatePathCI(path), mode, fp->linux_fp)); -} - -int __darwin_fclose(__darwin_FILE* fp) -{ - int r = fclose(fp->linux_fp); - - if (fp != __stdinp && fp != __stdoutp && fp != __stderrp) - delete fp; - - if (r == -1) - errnoOut(); - - return r; -} - -size_t __darwin_fread(void* ptr, size_t size, size_t nmemb, __darwin_FILE* fp) -{ - return fread(ptr, size, nmemb, fp->linux_fp); -} - -size_t __darwin_fwrite(void* ptr, size_t size, size_t nmemb, __darwin_FILE* fp) -{ - return fwrite(ptr, size, nmemb, fp->linux_fp); -} - -int __darwin_fseek(__darwin_FILE* fp, long offset, int whence) -{ - return fseek(fp->linux_fp, offset, whence); -} - -int __darwin_fseeko(__darwin_FILE* fp, off_t offset, int whence) -{ - return fseeko(fp->linux_fp, offset, whence); -} - -long __darwin_ftell(__darwin_FILE* fp) -{ - return ftell(fp->linux_fp); -} - -off_t __darwin_ftello(__darwin_FILE* fp) -{ - return ftello(fp->linux_fp); -} - -void __darwin_rewind(__darwin_FILE* fp) -{ - return rewind(fp->linux_fp); -} - -int __darwin_getc(__darwin_FILE* fp) -{ - return getc(fp->linux_fp); -} - -int __darwin_fgetc(__darwin_FILE* fp) -{ - return fgetc(fp->linux_fp); -} - -int __darwin_ungetc(int c, __darwin_FILE* fp) -{ - return ungetc(c, fp->linux_fp); -} - -char* __darwin_fgets(char* s, int size, __darwin_FILE* fp) -{ - return fgets(s, size, fp->linux_fp); -} - -int __darwin_putc(int c, __darwin_FILE* fp) -{ - return putc(c, fp->linux_fp); -} - -int __darwin_fputc(int c, __darwin_FILE* fp) -{ - return fputc(c, fp->linux_fp); -} - -int __darwin_fputs(const char* s, __darwin_FILE* fp) -{ - return fputs(s, fp->linux_fp); -} - -int __darwin___srget(__darwin_FILE* f) -{ - return getc_unlocked(f->linux_fp); -} - -int __darwin___swbuf(int c, __darwin_FILE* f) -{ - return putc_unlocked(c, f->linux_fp); -} - -int __darwin___svfscanf(__darwin_FILE* f, const char* fmt, va_list va) -{ - return vfscanf(f->linux_fp, fmt, va); -} - -int __darwin_fprintf(__darwin_FILE* fp, const char* fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - int r = vfprintf(fp->linux_fp, fmt, ap); - va_end(ap); - return r; -} - -int __darwin_vfscanf(__darwin_FILE* fp, const char* fmt, va_list ap) -{ - return vfscanf(fp->linux_fp, fmt, ap); -} - -int __darwin_fscanf(__darwin_FILE* fp, const char* fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - int r = vfscanf(fp->linux_fp, fmt, ap); - va_end(ap); - return r; -} - -int __darwin_vfprintf(__darwin_FILE* fp, const char* fmt, va_list ap) -{ - return vfprintf(fp->linux_fp, fmt, ap); -} - -int __darwin_fflush(__darwin_FILE* fp) -{ - if (!fp) - return fflush(NULL); - return fflush(fp->linux_fp); -} - -void __darwin_setbuf(__darwin_FILE* fp, char* buf) -{ - setbuf(fp ? fp->linux_fp : NULL, buf); -} - -void __darwin_setbuffer(__darwin_FILE* fp, char* buf, size_t size) -{ - setbuffer(fp->linux_fp, buf, size); -} - -int __darwin_ferror(__darwin_FILE* fp) -{ - return ferror(fp ? fp->linux_fp : nullptr); -} - -int __darwin_fileno(__darwin_FILE* fp) -{ - return fileno(fp ? fp->linux_fp : nullptr); -} - -__darwin_FILE* __darwin_tmpfile() -{ - return InitDarwinFILE(tmpfile()); -} - -int __darwin_feof(__darwin_FILE *stream) -{ - if (!stream) - { - errno = DARWIN_EINVAL; - return -1; - } - else - { - int rv = feof(stream->linux_fp); - if (rv == -1) - errnoOut(); - return rv; - } -} - -void __darwin_clearerr(__darwin_FILE *stream) -{ - if (stream) - clearerr(stream->linux_fp); -} - -int __darwin_fgetpos(__darwin_FILE *stream, fpos_t *pos) -{ - if (!stream) - { - errno = DARWIN_EINVAL; - return -1; - } - else - { - int rv = fgetpos(stream->linux_fp, pos); - if (rv == -1) - errnoOut(); - return rv; - } -} - -int __darwin_fsetpos(__darwin_FILE *stream, fpos_t *pos) -{ - if (!stream) - { - errno = DARWIN_EINVAL; - return -1; - } - else - { - int rv = fsetpos(stream->linux_fp, pos); - if (rv == -1) - errnoOut(); - return rv; - } -} - -int __darwin_getw(__darwin_FILE *stream) -{ - return AutoFileErrno(getw, stream); -} - -int __darwin_putw(int w, __darwin_FILE *stream) -{ - return AutoFileErrno(putw, stream, w); -} - -wint_t __darwin_fgetwc(__darwin_FILE *stream) -{ - return AutoFileErrno(fgetwc, stream); -} - -wint_t __darwin_getwc(__darwin_FILE *stream) -{ - return AutoFileErrno(getwc, stream); -} - -wint_t __darwin_fputwc(wchar_t wc, __darwin_FILE *stream) -{ - return AutoFileErrno(fputwc, stream, wc); -} - -wint_t __darwin_putwc(wchar_t wc, __darwin_FILE *stream) -{ - return AutoFileErrno(putwc, stream, wc); -} - -int __darwin_fputws(const wchar_t *ws, __darwin_FILE *stream) -{ - return AutoFileErrno(fputws, stream, ws); -} - -wchar_t *__darwin_fgetws(wchar_t *ws, int n, __darwin_FILE *stream) -{ - return AutoFileErrno(fgetws, stream, ws, n); -} - -wint_t __darwin_ungetwc(wint_t wc, __darwin_FILE *stream) -{ - return AutoFileErrno(ungetwc, stream, wc); -} - -int __darwin_setvbuf(__darwin_FILE* stream, char* buffer, int mode, size_t size) -{ - return setvbuf(stream->linux_fp, buffer, mode, size); -} - -__attribute__((constructor)) static void initStdio() -{ - InitDarwinFILE(stderr, __stderrp); - InitDarwinFILE(stdout, __stdoutp); - InitDarwinFILE(stdin, __stdinp); -} - -int __darwin_remove(const char* path) -{ - return AutoPathErrno(remove, path); -} - -char* __darwin_fgetln(__darwin_FILE* f, size_t* lenp) -{ - return ::fgetln(f ? f->linux_fp : nullptr, lenp); -} - -int __darwin_fpurge(__darwin_FILE *stream) -{ - if (!stream) - { - errno = DARWIN_EINVAL; - return -1; - } - else - { - __fpurge(stream->linux_fp); - return 0; - } -} - -#ifdef HAS_BSD_WCHAR_H -// bsd/libutil.h -char* __darwin_fparseln(__darwin_FILE* f, size_t* a2, size_t* a3, const char* a4, int a5) -{ - return fparseln(f ? f->linux_fp : nullptr, a2, a3, a4, a5); -} - -// bsd/wchar.h -wchar_t* __darwin_fgetwln(__darwin_FILE* f, size_t* len) -{ - return fgetwln(f ? f->linux_fp : nullptr, len); -} -#endif - -//std::__basic_file* _ZNSt12__basic_fileIcE8sys_openEP7__sFILESt13_Ios_Openmode(std::__basic_file* pThis, __darwin_FILE* f, std::ios_base::openmode mode) -//{ -// return pThis->sys_open(f->linux_fp, mode); -//} - -#ifdef __x86_64__ - -extern "C" void _ZN9__gnu_cxx13stdio_filebufIcSt11char_traitsIcEEC1EP8_IO_FILESt13_Ios_Openmodem(__gnu_cxx::stdio_filebuf >* pThis, FILE* f, std::_Ios_Openmode m, unsigned long l); -void _ZN9__gnu_cxx13stdio_filebufIcSt11char_traitsIcEEC1EP7__sFILESt13_Ios_Openmodem(__gnu_cxx::stdio_filebuf >* pThis, __darwin_FILE* f, std::_Ios_Openmode m, unsigned long l) -{ - _ZN9__gnu_cxx13stdio_filebufIcSt11char_traitsIcEEC1EP8_IO_FILESt13_Ios_Openmodem(pThis, f->linux_fp, m, l); -} - -void _ZN9__gnu_cxx13stdio_filebufIcSt11char_traitsIcEEC2EP7__sFILESt13_Ios_Openmodem(__gnu_cxx::stdio_filebuf >* pThis, __darwin_FILE* f, std::_Ios_Openmode m, unsigned long l) -{ - _ZN9__gnu_cxx13stdio_filebufIcSt11char_traitsIcEEC1EP8_IO_FILESt13_Ios_Openmodem(pThis, f->linux_fp, m, l); -} - -#elif defined(__i386__) - -// TODO: x86 - -#endif - -char* ctermid_r(char* p) -{ - static __thread char buf[PATH_MAX]; - - if (p) - return ctermid(p); - else - return ctermid(buf); -} - diff --git a/src/libSystem/libc/stdio.h b/src/libSystem/libc/stdio.h deleted file mode 100644 index cc98650fe..000000000 --- a/src/libSystem/libc/stdio.h +++ /dev/null @@ -1,147 +0,0 @@ -#ifndef LIBC_STDIO_H -#define LIBC_STDIO_H -#include -#include -#include -#include -#include - -/* stdio buffers */ -struct __darwin_sbuf -{ - unsigned char *_base; - int _size; -}; - -// Unfortunately, putc_nolock depends on FILE's layout, -// so we need to wrap linux's FILE with darwin's layout. -typedef struct __darwin_sFILE -{ - union - { -#if defined(__x86_64__) || defined(__ppc64__) - char __identical_size[152]; -#else - char __identical_size[88]; -#endif - - struct - { - unsigned char *_p; /* current position in (some) buffer */ - int _r; /* read space left for getc() */ - int _w; /* write space left for putc() */ - // TODO(hamaji): we need to modify this value with ferror and feof... - short _flags; /* flags, below; this FILE is free if 0 */ - short _file; /* fileno, if Unix descriptor, else -1 */ - struct __darwin_sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */ - int _lbfsize; /* 0 or -_bf._size, for inline putc */ - -#if 0 - /* operations */ - void *_cookie; /* cookie passed to io functions */ - int (*_close)(void *); - int (*_read) (void *, char *, int); - fpos_t (*_seek) (void *, fpos_t, int); - int (*_write)(void *, const char *, int); - - /* separate buffer for long sequences of ungetc() */ - struct __sbuf _ub; /* ungetc buffer */ - struct __sFILEX *_extra; /* additions to FILE to not break ABI */ - int _ur; /* saved _r when _r is counting ungetc data */ - - /* tricks to meet minimum requirements even when malloc() fails */ - unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */ - unsigned char _nbuf[1]; /* guarantee a getc() buffer */ - - /* separate buffer for fgetln() when line crosses buffer boundary */ - struct __sbuf _lb; /* buffer for fgetln() */ - - /* Unix stdio files get aligned to block boundaries on fseek() */ - int _blksize; /* stat.st_blksize (may be != _bf._size) */ - fpos_t _offset; /* current lseek offset (see WARNING) */ - -#endif - - FILE* linux_fp; - }; - }; -} __darwin_FILE; - -extern "C" -{ - -__darwin_FILE* __darwin_fopen(const char* path, const char* mode); -__darwin_FILE* __darwin_fdopen(int fd, const char* mode); -__darwin_FILE* __darwin_freopen(const char* path, const char* mode, __darwin_FILE* fp); -int __darwin_fclose(__darwin_FILE* fp); -size_t __darwin_fread(void* ptr, size_t size, size_t nmemb, __darwin_FILE* fp); -size_t __darwin_fwrite(void* ptr, size_t size, size_t nmemb, __darwin_FILE* fp); -int __darwin_fseek(__darwin_FILE* fp, long offset, int whence); -int __darwin_fseeko(__darwin_FILE* fp, off_t offset, int whence); -long __darwin_ftell(__darwin_FILE* fp); -off_t __darwin_ftello(__darwin_FILE* fp); -void __darwin_rewind(__darwin_FILE* fp); -int __darwin_getc(__darwin_FILE* fp); -int __darwin_fgetc(__darwin_FILE* fp); -int __darwin_ungetc(int c, __darwin_FILE* fp); -char* __darwin_fgets(char* s, int size, __darwin_FILE* fp); -int __darwin_putc(int c, __darwin_FILE* fp); -int __darwin_fputc(int c, __darwin_FILE* fp); -int __darwin_fputs(const char* s, __darwin_FILE* fp); -int __darwin_fprintf(__darwin_FILE* fp, const char* fmt, ...); -int __darwin_vfscanf(__darwin_FILE* fp, const char* fmt, va_list ap); -int __darwin_fscanf(__darwin_FILE* fp, const char* fmt, ...); -int __darwin_vfprintf(__darwin_FILE* fp, const char* fmt, va_list ap); -int __darwin_fflush(__darwin_FILE* fp); -int __darwin_setvbuf(__darwin_FILE* stream, char* buffer, int mode, size_t size); -void __darwin_setbuf(__darwin_FILE* stream, char* buffer); -void __darwin_setbuffer(__darwin_FILE* fp, char* buf, size_t size); -int __darwin_ferror(__darwin_FILE* fp); -int __darwin_fileno(__darwin_FILE* fp); -__darwin_FILE* __darwin_tmpfile(); - -int __darwin_feof(__darwin_FILE *stream); -void __darwin_clearerr(__darwin_FILE *stream); - -// pipes -__darwin_FILE* __darwin_popen(const char* command, const char* type); -int __darwin_pclose(__darwin_FILE* stream); - -int __darwin_fgetpos(__darwin_FILE *stream, fpos_t *pos); -int __darwin_fsetpos(__darwin_FILE *stream, fpos_t *pos); -int __darwin_fpurge(__darwin_FILE *stream); -int __darwin_getw(__darwin_FILE *stream); -int __darwin_putw(int w, __darwin_FILE *stream); -wint_t __darwin_fgetwc(__darwin_FILE *stream); -wint_t __darwin_getwc(__darwin_FILE *stream); -wint_t __darwin_fputwc(wchar_t wc, __darwin_FILE *stream); -wint_t __darwin_putwc(wchar_t wc, __darwin_FILE *stream); -int __darwin_fputws(const wchar_t *ws, __darwin_FILE *stream); -wchar_t *__darwin_fgetws(wchar_t *ws, int n, __darwin_FILE *stream); -wint_t __darwin_ungetwc(wint_t wc, __darwin_FILE *stream); - -// Internal Darwin Libc functions -int __darwin___srget(__darwin_FILE* f); -int __darwin___swbuf(int c, __darwin_FILE* f); -int __darwin___svfscanf(__darwin_FILE* f, const char* fmt, va_list va); - -int __darwin_remove(const char* path); - -// bsd/stdio.h -char* __darwin_fgetln(__darwin_FILE* f, size_t* lenp); - -// bsd/libutil.h -char* __darwin_fparseln(__darwin_FILE* f, size_t* a2, size_t* a3, const char* a4, int a5); - -// bsd/wchar.h -wchar_t* __darwin_fgetwln(__darwin_FILE* f, size_t* len); - -char* ctermid_r(char* p); - -std::__basic_file* _ZNSt12__basic_fileIcE8sys_openEP7__sFILESt13_Ios_Openmode(std::__basic_file* pThis, __darwin_FILE* f, std::ios_base::openmode mode); -void _ZN9__gnu_cxx13stdio_filebufIcSt11char_traitsIcEEC1EP7__sFILESt13_Ios_Openmodem(__gnu_cxx::stdio_filebuf >* pThis, __darwin_FILE* f, std::_Ios_Openmode m, unsigned long l); -void _ZN9__gnu_cxx13stdio_filebufIcSt11char_traitsIcEEC2EP7__sFILESt13_Ios_Openmodem(__gnu_cxx::stdio_filebuf >* pThis, __darwin_FILE* f, std::_Ios_Openmode m, unsigned long l); - -} - -#endif diff --git a/src/libSystem/libc/string.cpp b/src/libSystem/libc/string.cpp deleted file mode 100644 index c55e2b93b..000000000 --- a/src/libSystem/libc/string.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "string.h" -#include -#include - -// The following three functions are slow. -// But they're no faster on Darwin either. - -void memset_pattern4(char* b, const char* pattern4, size_t len) -{ - for (size_t i = 0; i < len; i++) - b[i] = pattern4[i % 4]; -} - -void memset_pattern8(char* b, const char* pattern4, size_t len) -{ - for (size_t i = 0; i < len; i++) - b[i] = pattern4[i % 8]; -} - -void memset_pattern16(char* b, const char* pattern4, size_t len) -{ - for (size_t i = 0; i < len; i++) - b[i] = pattern4[i % 16]; -} - -int __mb_cur_max() -{ - return MB_CUR_MAX; -} - -int __toupper(int c) -{ - return toupper(c); -} - -int __tolower(int c) -{ - return tolower(c); -} - diff --git a/src/libSystem/libc/string.h b/src/libSystem/libc/string.h deleted file mode 100644 index 1c300c268..000000000 --- a/src/libSystem/libc/string.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef LIBC_STRING_H -#define LIBC_STRING_H -#include - -extern "C" -{ - -// size_t strlcpy(char* dst, const char* src, size_t size); // in libbsd -// size_t strlcat(char* dst, const char* src, size_t size); -void memset_pattern4(char* b, const char* pattern4, size_t len); -void memset_pattern8(char* b, const char* pattern4, size_t len); -void memset_pattern16(char* b, const char* pattern4, size_t len); - -int __mb_cur_max(); -int ___mb_cur_max(); -int __toupper(int c); -int __tolower(int c); - - -} - -#endif diff --git a/src/libSystem/libc/strmode.c b/src/libSystem/libc/strmode.c deleted file mode 100644 index 7af8f573c..000000000 --- a/src/libSystem/libc/strmode.c +++ /dev/null @@ -1,169 +0,0 @@ -/* $NetBSD: strmode.c,v 1.5 2004/08/23 03:32:12 jlam Exp $ */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "config.h" -#include -#include - -#include -#include - -void -strmode(mode, p) - mode_t mode; - char *p; -{ - - assert(p != NULL); - - /* print type */ - switch (mode & S_IFMT) { - case S_IFDIR: /* directory */ - *p++ = 'd'; - break; - case S_IFCHR: /* character special */ - *p++ = 'c'; - break; - case S_IFBLK: /* block special */ - *p++ = 'b'; - break; - case S_IFREG: /* regular */ -#ifdef S_ARCH2 - if ((mode & S_ARCH2) != 0) { - *p++ = 'A'; - } else if ((mode & S_ARCH1) != 0) { - *p++ = 'a'; - } else { -#endif - *p++ = '-'; -#ifdef S_ARCH2 - } -#endif - break; - case S_IFLNK: /* symbolic link */ - *p++ = 'l'; - break; -#ifdef S_IFSOCK - case S_IFSOCK: /* socket */ - *p++ = 's'; - break; -#endif -#ifdef S_IFIFO - case S_IFIFO: /* fifo */ - *p++ = 'p'; - break; -#endif -#ifdef S_IFWHT - case S_IFWHT: /* whiteout */ - *p++ = 'w'; - break; -#endif -#ifdef S_IFDOOR - case S_IFDOOR: /* door */ - *p++ = 'D'; - break; -#endif - default: /* unknown */ - *p++ = '?'; - break; - } - /* usr */ - if (mode & S_IRUSR) - *p++ = 'r'; - else - *p++ = '-'; - if (mode & S_IWUSR) - *p++ = 'w'; - else - *p++ = '-'; - switch (mode & (S_IXUSR | S_ISUID)) { - case 0: - *p++ = '-'; - break; - case S_IXUSR: - *p++ = 'x'; - break; - case S_ISUID: - *p++ = 'S'; - break; - case S_IXUSR | S_ISUID: - *p++ = 's'; - break; - } - /* group */ - if (mode & S_IRGRP) - *p++ = 'r'; - else - *p++ = '-'; - if (mode & S_IWGRP) - *p++ = 'w'; - else - *p++ = '-'; - switch (mode & (S_IXGRP | S_ISGID)) { - case 0: - *p++ = '-'; - break; - case S_IXGRP: - *p++ = 'x'; - break; - case S_ISGID: - *p++ = 'S'; - break; - case S_IXGRP | S_ISGID: - *p++ = 's'; - break; - } - /* other */ - if (mode & S_IROTH) - *p++ = 'r'; - else - *p++ = '-'; - if (mode & S_IWOTH) - *p++ = 'w'; - else - *p++ = '-'; - switch (mode & (S_IXOTH | S_ISVTX)) { - case 0: - *p++ = '-'; - break; - case S_IXOTH: - *p++ = 'x'; - break; - case S_ISVTX: - *p++ = 'T'; - break; - case S_IXOTH | S_ISVTX: - *p++ = 't'; - break; - } - *p++ = ' '; /* will be a '+' if ACL's implemented */ - *p = '\0'; -} diff --git a/src/libSystem/libc/sysconf.cpp b/src/libSystem/libc/sysconf.cpp deleted file mode 100644 index 4683c2148..000000000 --- a/src/libSystem/libc/sysconf.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "config.h" -#include "sysconf.h" -#include "trace.h" -#include - -long __darwin_sysconf(int name) -{ - TRACE1(name); - switch (name) - { - case DARWIN_SC_PAGESIZE: - name = _SC_PAGESIZE; - break; - case DARWIN_SC_GETPW_R_SIZE_MAX: - name = _SC_GETPW_R_SIZE_MAX; - break; - default: - break; - } - - return sysconf(name); -} - diff --git a/src/libSystem/libc/sysconf.h b/src/libSystem/libc/sysconf.h deleted file mode 100644 index 33df2af1d..000000000 --- a/src/libSystem/libc/sysconf.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef LIBC_SYSCONF_H -#define LIBC_SYSCONF_H - -enum { - DARWIN_SC_PAGESIZE = 29, - DARWIN_SC_GETPW_R_SIZE_MAX = 71 -}; - -extern "C" long __darwin_sysconf(int name); - -#endif - diff --git a/src/libSystem/libc/sysctl.cpp b/src/libSystem/libc/sysctl.cpp deleted file mode 100644 index bb51000d8..000000000 --- a/src/libSystem/libc/sysctl.cpp +++ /dev/null @@ -1,209 +0,0 @@ -#include "config.h" -#include "sysctl.h" -#include "log.h" -#include "trace.h" -#include "darwin_errno_codes.h" -#include -#include -#include -#include -#include - -#define CTL_KERN 1 -#define CTL_HW 6 - -#define HW_NCPU 3 -#define HW_PHYSMEM 5 -#define HW_USERMEM 6 -#define HW_MEMSIZE 24 -#define HW_AVAILCPU 25 - -int __darwin_sysctlbyname(const char* name, void* oldp, size_t* oldlenp, void* newp, size_t newlen) -{ - TRACE5(name, oldp, oldlenp, newp, newlen); - - uint64_t val; - - if (newp) - { - LOG << "sysctl with newp isn't supported yet.\n"; - errno = DARWIN_EINVAL; - return -1; - } - - /* - if (*oldlenp != 4 && *oldlenp != 8) - { - LOG << "sysctl(HW) with oldlenp=" << *oldlenp << " isn't supported yet.\n"; - errno = DARWIN_EINVAL; - return -1; - } - */ - - if (!strcmp(name, "hw.physicalcpu") || !strcmp(name, "hw.logicalcpu") || !strcmp(name, "hw.ncpu")) - val = ::sysconf(_SC_NPROCESSORS_ONLN); - else if (!strcmp(name, "hw.physicalcpu_max") || !strcmp(name, "hw.logicalcpu_max")) - val = ::sysconf(_SC_NPROCESSORS_CONF); - else if (!strcmp(name, "kern.boottime")) - { - struct timeval tv; - struct sysinfo si; - - if (*oldlenp < sizeof(struct timeval)) - { - errno = DARWIN_ENOMEM; - return -1; - } - - sysinfo(&si); - gettimeofday(&tv, nullptr); - tv.tv_sec -= si.uptime; - - *oldlenp = sizeof(struct timeval); - memcpy(oldp, &tv, sizeof(tv)); - return 0; - } - else - { - errno = DARWIN_EINVAL; - return -1; - } - - if (oldp) - { - if (*oldlenp == 4) - *reinterpret_cast(oldp) = val; - else if (*oldlenp == 8) - *reinterpret_cast(oldp) = val; - } - else - *oldlenp = sizeof(long); - return 0; -} - -int __darwin_sysctl(int* name, unsigned int namelen, - void* oldp, size_t* oldlenp, - void* newp, size_t newlen) -{ - TRACE6(name, namelen, oldp, oldlenp, newp, newlen); - - LOG << "sysctl: namelen=" << namelen; - for (int i = 0; i < namelen; i++) - LOG << " name[" << i << "]=" << name[i]; - LOG << " newp=" << newp << std::endl; - - if (newp) - { - LOG << "sysctl with newp isn't supported yet.\n"; - errno = DARWIN_EINVAL; - return -1; - } - - if (namelen != 2) - { - LOG << "sysctl with namelen=" << namelen << " isn't supported yet.\n"; - errno = DARWIN_EINVAL; - return -1; - } - - switch (name[0]) - { - case CTL_HW: - { - if (*oldlenp != 4 && *oldlenp != 8) - { - LOG << "sysctl(HW) with oldlenp=" << *oldlenp << " isn't supported yet.\n"; - errno = DARWIN_EINVAL; - return -1; - } - - uint64_t val = 0; - switch (name[1]) - { - case HW_NCPU: - val = ::sysconf(_SC_NPROCESSORS_CONF); - break; - case HW_AVAILCPU: - val = ::sysconf(_SC_NPROCESSORS_ONLN); - break; - case HW_PHYSMEM: - case HW_USERMEM: - case HW_MEMSIZE: - { - long pages = ::sysconf(_SC_PHYS_PAGES); - long page_size = ::sysconf(_SC_PAGE_SIZE); - val = pages * page_size; - break; - } - - default: - LOG << "sysctl(HW) with name[1]=" << name[1] << " isn't supported yet.\n"; - - errno = DARWIN_EINVAL; - return -1; - } - - if (oldp) - { - if (*oldlenp == 4) - *reinterpret_cast(oldp) = val; - else if (*oldlenp == 8) - *reinterpret_cast(oldp) = val; - } - else - *oldlenp = sizeof(long); - return 0; - } - - case CTL_KERN: - { - switch (name[1]) - { - case KERN_OSRELEASE: - - // TODO: use real uname? - if (oldp) - strcpy((char*)oldp, "10.7.0"); - *oldlenp = 7; - break; - - case KERN_OSVERSION: - if (oldp) - strcpy((char*)oldp, "10J869"); - *oldlenp = 7; - break; - - case KERN_BOOTTIME: - { - struct timeval tv; - struct sysinfo si; - - if (*oldlenp < sizeof(struct timeval)) - { - errno = DARWIN_ENOMEM; - return -1; - } - - sysinfo(&si); - gettimeofday(&tv, nullptr); - tv.tv_sec -= si.uptime; - - *oldlenp = sizeof(struct timeval); - memcpy(oldp, &tv, sizeof(tv)); - return 0; - } - - default: - LOG << "sysctl(KERN) with name[1]=" << name[1] << " isn't supported yet.\n"; - errno = DARWIN_EINVAL; - return -1; - } - return 0; - } - - default: - LOG << "sysctl with name[0]=" << name[0] << " isn't supported yet.\n"; - errno = DARWIN_EINVAL; - return -1; - } -} diff --git a/src/libSystem/libc/sysctl.h b/src/libSystem/libc/sysctl.h deleted file mode 100644 index 59c6e1259..000000000 --- a/src/libSystem/libc/sysctl.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef DARWIN_SYSCTL_H -#define DARWIN_SYSCTL_H -#include -#include - -// http://fxr.watson.org/fxr/source/bsd/sys/sysctl.h?v=xnu-1228#L373 - -#define CTL_KERN 1 -#define CTL_HW 6 -#define KERN_OSRELEASE 2 -#define KERN_OSVERSION 65 -#define KERN_BOOTTIME 21 - -extern "C" { - -int __darwin_sysctl(int* name, unsigned int namelen, void* oldp, size_t* oldlenp, void* newp, size_t newlen); - -int __darwin_sysctlbyname(const char* name, void* oldp, size_t* oldlenp, void* newp, size_t newlen); - -} - -#endif diff --git a/src/libSystem/libc/termios.cpp b/src/libSystem/libc/termios.cpp deleted file mode 100644 index 927bee28e..000000000 --- a/src/libSystem/libc/termios.cpp +++ /dev/null @@ -1,150 +0,0 @@ -#include "termios.h" -#include "errno.h" -#include "common/auto.h" -#include -#include - -const static uint8_t g_ccIndices[][2] = { - {DARWIN_VEOF, VEOF}, {DARWIN_VEOL, VEOL}, {DARWIN_VEOL2, VEOL2}, {DARWIN_VERASE, VERASE}, {DARWIN_VWERASE, VWERASE}, - {DARWIN_VKILL, VKILL}, {DARWIN_VREPRINT, VREPRINT}, {DARWIN_VINTR,VINTR}, {DARWIN_VQUIT, VQUIT}, {DARWIN_VSUSP, VSUSP}, - {DARWIN_VSTART, VSTART}, {DARWIN_VSTOP, VSTOP}, {DARWIN_VLNEXT, VLNEXT}, {DARWIN_VDISCARD, VDISCARD}, {DARWIN_VMIN, VMIN}, - {DARWIN_VTIME, VTIME} -}; - -const static Darling::MappedFlag g_inputFlags[] = { - {DARWIN_IGNBRK, IGNBRK}, {DARWIN_BRKINT, BRKINT}, {DARWIN_IGNPAR, IGNPAR}, {DARWIN_PARMRK, PARMRK}, - /*{DARWIN_INPCL, INPCL},*/ {DARWIN_ISTRIP, ISTRIP}, {DARWIN_INLCR, INLCR}, {DARWIN_ICRNL, ICRNL}, {DARWIN_IXON, IXON}, - {DARWIN_IXOFF, IXOFF}, /*{DARWIN_IXANZ, IXANZ},*/ {DARWIN_IMAXBEL, IMAXBEL}, {DARWIN_IUTF8, IUTF8} -}; - -const static Darling::MappedFlag g_outputFlags[] = { - {DARWIN_OPOST, OPOST}, {DARWIN_ONLCR, ONLCR}, /*{DARWIN_OXTABS, OXTABS},*/ /*{DARWIN_ONOEOT, ONOEOT} */ -}; - -const static Darling::MappedFlag g_controlFlags[] = { - /*{DARWIN_XIGNORE, XIGNORE}, */ {DARWIN_CSIZE, CSIZE}, {DARWIN_CS5, CS5}, {DARWIN_CS6, CS6}, {DARWIN_CS7, CS7}, - {DARWIN_CS8, CS8}, {DARWIN_CSTOPB, CSTOPB}, {DARWIN_CREAD, CREAD}, {DARWIN_PARENB, PARENB}, {DARWIN_PARODD, PARODD}, - {DARWIN_HUPCL, HUPCL}, {DARWIN_CLOCAL, CLOCAL}, /*{DARWIN_CCTS_OFLOW, CCTS_OFLOW}, {DARWIN_CRTS_IFLOW, CRTS_IFLOW}, - {DARWIN_CDTR_IFLOW, CDTR_IFLOW}, {DARWIN_CDSR_OFLOW, CDSR_OFLOW}, {DARWIN_CCAR_OFLOW, CCAR_OFLOW}*/ -}; - -const static Darling::MappedFlag g_localFlags[] = { - {DARWIN_ECHOKE, ECHOKE}, {DARWIN_ECHOE, ECHOE}, {DARWIN_ECHOK, ECHOK}, {DARWIN_ECHO, ECHO}, {DARWIN_ECHONL, ECHONL}, - /* {DARWIN_ECHOPTR, ECHOPTR}, */ {DARWIN_ECHOCTL, ECHOCTL}, {DARWIN_ISIG, ISIG}, {DARWIN_ICANON, ICANON}, - /* {DARWIN_ALTWERASE, ALTWERASE}, */ {DARWIN_IEXTEN, IEXTEN}, {DARWIN_EXTPROC, EXTPROC}, {DARWIN_TOSTOP, TOSTOP}, - {DARWIN_FLUSHO, FLUSHO}, {DARWIN_PENDIN, PENDIN}, {int(DARWIN_NOFLSH), NOFLSH} -}; - -static void termiosDarwinToLinux(const struct __darwin_termios* p, struct termios* n) -{ - memset(n, 0, sizeof(*n)); - cfsetispeed(n, p->c_ispeed); - cfsetospeed(n, p->c_ospeed); - //n->c_line = p->c_line; - - memset(n->c_cc, 0, sizeof(n->c_cc)); - - for (int i = 0; i < sizeof(g_ccIndices) / sizeof(g_ccIndices[0]); i++) - n->c_cc[g_ccIndices[i][1]] = p->c_cc[g_ccIndices[i][0]]; - - n->c_oflag = Darling::flagsDarwinToNative(g_outputFlags, sizeof(g_outputFlags)/sizeof(g_outputFlags[0]), p->c_oflag); - n->c_iflag = Darling::flagsDarwinToNative(g_inputFlags, sizeof(g_inputFlags)/sizeof(g_inputFlags[0]), p->c_iflag); - n->c_cflag = Darling::flagsDarwinToNative(g_controlFlags, sizeof(g_controlFlags)/sizeof(g_controlFlags[0]), p->c_cflag); - n->c_lflag = Darling::flagsDarwinToNative(g_localFlags, sizeof(g_localFlags)/sizeof(g_localFlags[0]), p->c_lflag); -} - -static void termiosLinuxToDarwin(const struct termios* p, struct __darwin_termios* d) -{ - memset(d, 0, sizeof(*d)); - d->c_ispeed = cfgetispeed(p); - d->c_ospeed = cfgetospeed(p); - //d->c_line = p->c_line; - - memset(d->c_cc, 0, sizeof(d->c_cc)); - - for (int i = 0; i < sizeof(g_ccIndices) / sizeof(g_ccIndices[0]); i++) - d->c_cc[g_ccIndices[i][0]] = p->c_cc[g_ccIndices[i][1]]; - - d->c_oflag = Darling::flagsNativeToDarwin(g_outputFlags, sizeof(g_outputFlags)/sizeof(g_outputFlags[0]), p->c_oflag); - d->c_iflag = Darling::flagsNativeToDarwin(g_inputFlags, sizeof(g_inputFlags)/sizeof(g_inputFlags[0]), p->c_iflag); - d->c_cflag = Darling::flagsNativeToDarwin(g_controlFlags, sizeof(g_controlFlags)/sizeof(g_controlFlags[0]), p->c_cflag); - d->c_lflag = Darling::flagsNativeToDarwin(g_localFlags, sizeof(g_localFlags)/sizeof(g_localFlags[0]), p->c_lflag); -} - -int __darwin_tcgetattr(int fd, struct __darwin_termios *termios_p) -{ - struct termios n; - int rv = tcgetattr(fd, &n); - - if (rv == -1) - errnoOut(); - else - termiosLinuxToDarwin(&n, termios_p); - return rv; -} - -int __darwin_tcsetattr(int fd, int optional_actions, const struct __darwin_termios *termios_p) -{ - struct termios n; - termiosDarwinToLinux(termios_p, &n); - - int rv = tcsetattr(fd, optional_actions, &n); - if (rv == -1) - errnoOut(); - return rv; -} - -void __darwin_cfmakeraw(struct __darwin_termios *termios_p) -{ - // from man termios(3) - termios_p->c_iflag &= ~(DARWIN_IGNBRK | DARWIN_BRKINT | DARWIN_PARMRK | DARWIN_ISTRIP | DARWIN_INLCR | /*DARWIN_IGNCR |*/ DARWIN_ICRNL | DARWIN_IXON); - termios_p->c_oflag &= ~DARWIN_OPOST; - termios_p->c_lflag &= ~(DARWIN_ECHO | DARWIN_ECHONL | DARWIN_ICANON | DARWIN_ISIG | DARWIN_IEXTEN); - termios_p->c_cflag &= ~(DARWIN_CSIZE | DARWIN_PARENB); - termios_p->c_cflag |= DARWIN_CS8; -} - -long __darwin_cfgetispeed(const struct __darwin_termios *termios_p) -{ - return termios_p->c_ispeed; -} - -long __darwin_cfgetospeed(const struct __darwin_termios *termios_p) -{ - return termios_p->c_ospeed; -} - -int __darwin_cfsetispeed(struct __darwin_termios *termios_p, long speed) -{ - termios_p->c_ispeed = speed; - return 0; -} - -int __darwin_cfsetospeed(struct __darwin_termios *termios_p, long speed) -{ - termios_p->c_ospeed = speed; - return 0; -} - -int __darwin_cfsetspeed(struct __darwin_termios *termios_p, long speed) -{ - termios_p->c_ospeed = termios_p->c_ispeed = speed; - return 0; -} - -int __darwin_tcflush(int fd, int queue_selector) -{ - int rv = tcflush(fd, queue_selector-1); - if (rv == -1) - errnoOut(); - return rv; -} - -int __darwin_tcflow(int fd, int action) -{ - int rv = tcflow(fd, action-1); - if (rv == -1) - errnoOut(); - return rv; -} - diff --git a/src/libSystem/libc/termios.h b/src/libSystem/libc/termios.h deleted file mode 100644 index d395db55d..000000000 --- a/src/libSystem/libc/termios.h +++ /dev/null @@ -1,116 +0,0 @@ -#ifndef LIBC_TERMIOS_H -#define LIBC_TERMIOS_H -#include - -extern "C" -{ - -#define DARWIN_NCCS 20 -struct __darwin_termios -{ - unsigned long c_iflag; // 4 on Linux, 4/8 on BSD - unsigned long c_oflag; - unsigned long c_cflag; - unsigned long c_lflag; - //cc_t c_line; // 1 - cc_t c_cc[DARWIN_NCCS]; // 32 on Linux, 20 on BSD - unsigned long c_ispeed; // 4 on Linux, 4/8 on BSD - unsigned long c_ospeed; -}; - -int __darwin_tcgetattr(int fd, struct __darwin_termios *termios_p); -int __darwin_tcsetattr(int fd, int optional_actions, const struct __darwin_termios *termios_p); -void __darwin_cfmakeraw(struct __darwin_termios *termios_p); -long __darwin_cfgetispeed(const struct __darwin_termios *termios_p); -long __darwin_cfgetospeed(const struct __darwin_termios *termios_p); -int __darwin_cfsetispeed(struct __darwin_termios *termios_p, long speed); -int __darwin_cfsetospeed(struct __darwin_termios *termios_p, long speed); -int __darwin_cfsetspeed(struct __darwin_termios *termios_p, long speed); - -int __darwin_tcflush(int fd, int queue_selector); -int __darwin_tcflow(int fd, int action); - -// cc_t -#define DARWIN_VEOF 0 -#define DARWIN_VEOL 1 -#define DARWIN_VEOL2 2 -#define DARWIN_VERASE 3 -#define DARWIN_VWERASE 4 -#define DARWIN_VKILL 5 -#define DARWIN_VREPRINT 6 -#define DARWIN_VINTR 8 -#define DARWIN_VQUIT 9 -#define DARWIN_VSUSP 10 -// #define DARWIN_VDSUSP 11 -#define DARWIN_VSTART 12 -#define DARWIN_VSTOP 13 -#define DARWIN_VLNEXT 14 -#define DARWIN_VDISCARD 15 -#define DARWIN_VMIN 16 -#define DARWIN_VTIME 17 -// #define DARWIN_VSTATUS 19 -// #define DARWIN_NCCS 20 - -// input flags -#define DARWIN_IGNBRK 0x1 -#define DARWIN_BRKINT 0x2 -#define DARWIN_IGNPAR 0x4 -#define DARWIN_PARMRK 0x8 -#define DARWIN_INPCL 0x10 -#define DARWIN_ISTRIP 0x20 -#define DARWIN_INLCR 0x80 -#define DARWIN_ICRNL 0x100 -#define DARWIN_IXON 0x200 -#define DARWIN_IXOFF 0x400 -#define DARWIN_IXANZ 0x800 -#define DARWIN_IMAXBEL 0x2000 -#define DARWIN_IUTF8 0x4000 - -// output flags -#define DARWIN_OPOST 0x1 -#define DARWIN_ONLCR 0x2 -#define DARWIN_OXTABS 0x4 -#define DARWIN_ONOEOT 0x8 - -// control flags -#define DARWIN_XIGNORE 0x1 -#define DARWIN_CSIZE 0x300 -#define DARWIN_CS5 0 -#define DARWIN_CS6 0x100 -#define DARWIN_CS7 0x200 -#define DARWIN_CS8 0x300 -#define DARWIN_CSTOPB 0x400 -#define DARWIN_CREAD 0x800 -#define DARWIN_PARENB 0x1000 -#define DARWIN_PARODD 0x2000 -#define DARWIN_HUPCL 0x4000 -#define DARWIN_CLOCAL 0x8000 -#define DARWIN_CCTS_OFLOW 0x10000 -#define DARWIN_CRTS_IFLOW 0x20000 -#define DARWIN_CDTR_IFLOW 0x40000 -#define DARWIN_CDSR_OFLOW 0x80000 -#define DARWIN_CCAR_OFLOW 0x100000 - -// local flags -#define DARWIN_ECHOKE 0x1 -#define DARWIN_ECHOE 0x2 -#define DARWIN_ECHOK 0x4 -#define DARWIN_ECHO 0x8 -#define DARWIN_ECHONL 0x10 -#define DARWIN_ECHOPTR 0x20 -#define DARWIN_ECHOCTL 0x40 -#define DARWIN_ISIG 0x80 -#define DARWIN_ICANON 0x100 -#define DARWIN_ALTWERASE 0x200 -#define DARWIN_IEXTEN 0x400 -#define DARWIN_EXTPROC 0x800 -#define DARWIN_TOSTOP 0x400000 -#define DARWIN_FLUSHO 0x800000 -//#define DARWIN_NOKERNINFO 0x2000000 -#define DARWIN_PENDIN 0x20000000 -#define DARWIN_NOFLSH 0x80000000 - -} - -#endif - diff --git a/src/libSystem/libc/uname.cpp b/src/libSystem/libc/uname.cpp deleted file mode 100644 index 63b893a1f..000000000 --- a/src/libSystem/libc/uname.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include "../../config.h" -#include "uname.h" -#include "errno.h" -#include -#include -#include "darwin_errno_codes.h" -#include -#ifndef NO_DARWIN_UNAME -# include "IniConfig.h" -#endif -#include - -int __darwin_uname(__darwin_utsname* buf) -{ - if (!buf) - { - errno = DARWIN_EINVAL; - return -1; - } - - struct utsname nbuf; - int rv = uname(&nbuf); - - if (rv == -1) - { - errnoOut(); - return rv; - } - - strcpy(buf->nodename, nbuf.nodename); - strcpy(buf->machine, nbuf.machine); - -#ifdef NO_DARWIN_UNAME - strcpy(buf->sysname, nbuf.sysname); - strcpy(buf->release, nbuf.release); - strcpy(buf->version, nbuf.version); -#else - static IniConfig iniConfig(ETC_DARLING_PATH "/version.conf", true); - const char *sysname = nullptr, *release = nullptr, *version = nullptr; - - if (iniConfig.hasSection("uname")) - { - const IniConfig::ValueMap* map = iniConfig.getSection("uname"); - sysname = map->find("sysname")->second.c_str(); - release = map->find("release")->second.c_str(); - version = map->find("version")->second.c_str(); - } - - if (!sysname || !*sysname) - strcpy(buf->sysname, "Darwin"); - else - strlcpy(buf->sysname, sysname, __DARWIN_SYS_NAMELEN); - - if (!release || !*release) - strcpy(buf->release, "12.0.0"); - else - strlcpy(buf->release, release, __DARWIN_SYS_NAMELEN); - - if (!version || !*version) - strcpy(buf->version, "Darwin Kernel Version 12.0.0"); - else - strlcpy(buf->version, version, __DARWIN_SYS_NAMELEN); -#endif - - return 0; -} - - diff --git a/src/libSystem/libc/uname.h b/src/libSystem/libc/uname.h deleted file mode 100644 index 6041e30b9..000000000 --- a/src/libSystem/libc/uname.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef LIBC_UNAME_H -#define LIBC_UNAME_H - -#define __DARWIN_SYS_NAMELEN 256 - -struct __darwin_utsname -{ - char sysname[__DARWIN_SYS_NAMELEN]; - char nodename[__DARWIN_SYS_NAMELEN]; - char release[__DARWIN_SYS_NAMELEN]; - char version[__DARWIN_SYS_NAMELEN]; - char machine[__DARWIN_SYS_NAMELEN]; -}; - - -extern "C" int __darwin_uname(__darwin_utsname* buf); - -#endif - diff --git a/src/libSystem/libc/unvis.c b/src/libSystem/libc/unvis.c deleted file mode 100644 index 1a020c4d9..000000000 --- a/src/libSystem/libc/unvis.c +++ /dev/null @@ -1,297 +0,0 @@ -/*- - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)unvis.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ -#include -//__FBSDID("$FreeBSD: src/lib/libc/gen/unvis.c,v 1.9 2004/08/02 08:46:23 stefanf Exp $"); - -#include -#include -#include "vis.h" - -/* - * decode driven by state machine - */ -#define S_GROUND 0 /* haven't seen escape char */ -#define S_START 1 /* start decoding special sequence */ -#define S_META 2 /* metachar started (M) */ -#define S_META1 3 /* metachar more, regular char (-) */ -#define S_CTRL 4 /* control char started (^) */ -#define S_OCTAL2 5 /* octal digit 2 */ -#define S_OCTAL3 6 /* octal digit 3 */ -#define S_HEX2 7 /* hex digit 2 */ - -#define S_HTTP 0x080 /* %HEXHEX escape */ - -#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7') -#define ishex(c) ((((u_char)(c)) >= '0' && ((u_char)(c)) <= '9') || (((u_char)(c)) >= 'a' && ((u_char)(c)) <= 'f')) - -/* - * unvis - decode characters previously encoded by vis - */ -int -unvis(char *cp, int c, int *astate, int flag) -{ - - if (flag & UNVIS_END) { - if (*astate == S_OCTAL2 || *astate == S_OCTAL3) { - *astate = S_GROUND; - return (UNVIS_VALID); - } - return (*astate == S_GROUND ? UNVIS_NOCHAR : UNVIS_SYNBAD); - } - - switch (*astate & ~S_HTTP) { - - case S_GROUND: - *cp = 0; - if (c == '\\') { - *astate = S_START; - return (0); - } - if (flag & VIS_HTTPSTYLE && c == '%') { - *astate = S_START | S_HTTP; - return (0); - } - *cp = c; - return (UNVIS_VALID); - - case S_START: - if (*astate & S_HTTP) { - if (ishex(tolower(c))) { - *cp = isdigit(c) ? (c - '0') : (tolower(c) - 'a'); - *astate = S_HEX2; - return (0); - } - } - switch(c) { - case '\\': - *cp = c; - *astate = S_GROUND; - return (UNVIS_VALID); - case '0': case '1': case '2': case '3': - case '4': case '5': case '6': case '7': - *cp = (c - '0'); - *astate = S_OCTAL2; - return (0); - case 'M': - *cp = 0200; - *astate = S_META; - return (0); - case '^': - *astate = S_CTRL; - return (0); - case 'n': - *cp = '\n'; - *astate = S_GROUND; - return (UNVIS_VALID); - case 'r': - *cp = '\r'; - *astate = S_GROUND; - return (UNVIS_VALID); - case 'b': - *cp = '\b'; - *astate = S_GROUND; - return (UNVIS_VALID); - case 'a': - *cp = '\007'; - *astate = S_GROUND; - return (UNVIS_VALID); - case 'v': - *cp = '\v'; - *astate = S_GROUND; - return (UNVIS_VALID); - case 't': - *cp = '\t'; - *astate = S_GROUND; - return (UNVIS_VALID); - case 'f': - *cp = '\f'; - *astate = S_GROUND; - return (UNVIS_VALID); - case 's': - *cp = ' '; - *astate = S_GROUND; - return (UNVIS_VALID); - case 'E': - *cp = '\033'; - *astate = S_GROUND; - return (UNVIS_VALID); - case '\n': - /* - * hidden newline - */ - *astate = S_GROUND; - return (UNVIS_NOCHAR); - case '$': - /* - * hidden marker - */ - *astate = S_GROUND; - return (UNVIS_NOCHAR); - } - *astate = S_GROUND; - return (UNVIS_SYNBAD); - - case S_META: - if (c == '-') - *astate = S_META1; - else if (c == '^') - *astate = S_CTRL; - else { - *astate = S_GROUND; - return (UNVIS_SYNBAD); - } - return (0); - - case S_META1: - *astate = S_GROUND; - *cp |= c; - return (UNVIS_VALID); - - case S_CTRL: - if (c == '?') - *cp |= 0177; - else - *cp |= c & 037; - *astate = S_GROUND; - return (UNVIS_VALID); - - case S_OCTAL2: /* second possible octal digit */ - if (isoctal(c)) { - /* - * yes - and maybe a third - */ - *cp = (*cp << 3) + (c - '0'); - *astate = S_OCTAL3; - return (0); - } - /* - * no - done with current sequence, push back passed char - */ - *astate = S_GROUND; - return (UNVIS_VALIDPUSH); - - case S_OCTAL3: /* third possible octal digit */ - *astate = S_GROUND; - if (isoctal(c)) { - *cp = (*cp << 3) + (c - '0'); - return (UNVIS_VALID); - } - /* - * we were done, push back passed char - */ - return (UNVIS_VALIDPUSH); - - case S_HEX2: /* second mandatory hex digit */ - if (ishex(tolower(c))) { - *cp = (isdigit(c) ? (*cp << 4) + (c - '0') : (*cp << 4) + (tolower(c) - 'a' + 10)); - } - *astate = S_GROUND; - return (UNVIS_VALID); - - default: - /* - * decoder in unknown state - (probably uninitialized) - */ - *astate = S_GROUND; - return (UNVIS_SYNBAD); - } -} - -/* - * strunvis - decode src into dst - * - * Number of chars decoded into dst is returned, -1 on error. - * Dst is null terminated. - */ - -int -strunvis(char *dst, const char *src) -{ - char c; - char *start = dst; - int state = 0; - - while ( (c = *src++) ) { - again: - switch (unvis(dst, c, &state, 0)) { - case UNVIS_VALID: - dst++; - break; - case UNVIS_VALIDPUSH: - dst++; - goto again; - case 0: - case UNVIS_NOCHAR: - break; - default: - return (-1); - } - } - if (unvis(dst, c, &state, UNVIS_END) == UNVIS_VALID) - dst++; - *dst = '\0'; - return (dst - start); -} - -int -strunvisx(char *dst, const char *src, int flag) -{ - char c; - char *start = dst; - int state = 0; - - while ( (c = *src++) ) { - again: - switch (unvis(dst, c, &state, flag)) { - case UNVIS_VALID: - dst++; - break; - case UNVIS_VALIDPUSH: - dst++; - goto again; - case 0: - case UNVIS_NOCHAR: - break; - default: - return (-1); - } - } - if (unvis(dst, c, &state, UNVIS_END) == UNVIS_VALID) - dst++; - *dst = '\0'; - return (dst - start); -} diff --git a/src/libSystem/libc/vis.c b/src/libSystem/libc/vis.c deleted file mode 100644 index 7306868d4..000000000 --- a/src/libSystem/libc/vis.c +++ /dev/null @@ -1,205 +0,0 @@ -/*- - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)vis.c 8.1 (Berkeley) 7/19/93"; -#endif /* LIBC_SCCS and not lint */ -#include -//__FBSDID("$FreeBSD: src/lib/libc/gen/vis.c,v 1.13 2003/10/30 12:41:50 phk Exp $"); - -#include -#include -#include -#include -#include "vis.h" - -#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7') - -/* - * vis - visually encode characters - */ -char * -vis(dst, c, flag, nextc) - char *dst; - int c, nextc; - int flag; -{ - c = (unsigned char)c; - - if (flag & VIS_HTTPSTYLE) { - /* Described in RFC 1808 */ - if (!(isalnum(c) /* alpha-numeric */ - /* safe */ - || c == '$' || c == '-' || c == '_' || c == '.' || c == '+' - /* extra */ - || c == '!' || c == '*' || c == '\'' || c == '(' - || c == ')' || c == ',')) { - *dst++ = '%'; - snprintf(dst, 4, (c < 16 ? "0%X" : "%X"), c); - dst += 2; - goto done; - } - } - - if ((flag & VIS_GLOB) && - (c == '*' || c == '?' || c == '[' || c == '#')) - ; - else if (isgraph(c) || - ((flag & VIS_SP) == 0 && c == ' ') || - ((flag & VIS_TAB) == 0 && c == '\t') || - ((flag & VIS_NL) == 0 && c == '\n') || - ((flag & VIS_SAFE) && (c == '\b' || c == '\007' || c == '\r'))) { - *dst++ = c; - if (c == '\\' && (flag & VIS_NOSLASH) == 0) - *dst++ = '\\'; - *dst = '\0'; - return (dst); - } - - if (flag & VIS_CSTYLE) { - switch(c) { - case '\n': - *dst++ = '\\'; - *dst++ = 'n'; - goto done; - case '\r': - *dst++ = '\\'; - *dst++ = 'r'; - goto done; - case '\b': - *dst++ = '\\'; - *dst++ = 'b'; - goto done; - case '\a': - *dst++ = '\\'; - *dst++ = 'a'; - goto done; - case '\v': - *dst++ = '\\'; - *dst++ = 'v'; - goto done; - case '\t': - *dst++ = '\\'; - *dst++ = 't'; - goto done; - case '\f': - *dst++ = '\\'; - *dst++ = 'f'; - goto done; - case ' ': - *dst++ = '\\'; - *dst++ = 's'; - goto done; - case '\0': - *dst++ = '\\'; - *dst++ = '0'; - if (isoctal(nextc)) { - *dst++ = '0'; - *dst++ = '0'; - } - goto done; - } - } - if (((c & 0177) == ' ') || isgraph(c) || (flag & VIS_OCTAL)) { - *dst++ = '\\'; - *dst++ = ((u_char)c >> 6 & 07) + '0'; - *dst++ = ((u_char)c >> 3 & 07) + '0'; - *dst++ = ((u_char)c & 07) + '0'; - goto done; - } - if ((flag & VIS_NOSLASH) == 0) - *dst++ = '\\'; - if (c & 0200) { - c &= 0177; - *dst++ = 'M'; - } - if (iscntrl(c)) { - *dst++ = '^'; - if (c == 0177) - *dst++ = '?'; - else - *dst++ = c + '@'; - } else { - *dst++ = '-'; - *dst++ = c; - } -done: - *dst = '\0'; - return (dst); -} - -/* - * strvis, strvisx - visually encode characters from src into dst - * - * Dst must be 4 times the size of src to account for possible - * expansion. The length of dst, not including the trailing NUL, - * is returned. - * - * Strvisx encodes exactly len bytes from src into dst. - * This is useful for encoding a block of data. - */ -int -strvis(dst, src, flag) - char *dst; - const char *src; - int flag; -{ - char c; - char *start; - - for (start = dst; (c = *src); ) - dst = vis(dst, c, flag, *++src); - *dst = '\0'; - return (dst - start); -} - -int -strvisx(dst, src, len, flag) - char *dst; - const char *src; - size_t len; - int flag; -{ - int c; - char *start; - - for (start = dst; len > 1; len--) { - c = *src; - dst = vis(dst, c, flag, *++src); - } - if (len) - dst = vis(dst, *src, flag, '\0'); - *dst = '\0'; - - return (dst - start); -} diff --git a/src/libSystem/libc/vis.h b/src/libSystem/libc/vis.h deleted file mode 100644 index b381c7cd5..000000000 --- a/src/libSystem/libc/vis.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef STRVIS_H -#define STRVIS_H -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define VIS_OCTAL 0x01 /* use octal \ddd format */ -#define VIS_CSTYLE 0x02 /* use \[nrft0..] where appropriate */ - -/* - * to alter set of characters encoded (default is to encode all - * non-graphic except space, tab, and newline). - */ -#define VIS_SP 0x04 /* also encode space */ -#define VIS_TAB 0x08 /* also encode tab */ -#define VIS_NL 0x10 /* also encode newline */ -#define VIS_WHITE (VIS_SP | VIS_TAB | VIS_NL) -#define VIS_SAFE 0x20 /* only encode "unsafe" characters */ - -/* - * other - */ -#define VIS_NOSLASH 0x40 /* inhibit printing '\' */ -#define VIS_HTTPSTYLE 0x80 /* http-style escape % HEX HEX */ -#define VIS_GLOB 0x100 /* encode glob(3) magics and '#' */ - -/* - * unvis return codes - */ -#define UNVIS_VALID 1 /* character valid */ -#define UNVIS_VALIDPUSH 2 /* character valid, push back passed char */ -#define UNVIS_NOCHAR 3 /* valid sequence, no character produced */ -#define UNVIS_SYNBAD -1 /* unrecognized escape sequence */ -#define UNVIS_ERROR -2 /* decoder in unknown state (unrecoverable) */ - -/* - * unvis flags - */ -#define UNVIS_END 1 /* no more characters */ - - -char* vis(char *dst, int c, int flag, int nextc); -int strvis(char *dst, const char *src, int flag); -int strnvis(char *dst, const char *src, size_t siz, int flag); -int strvisx(char *dst, const char *src, size_t len, int flag); -int strunvis(char *, const char *); -int strunvisx(char *, const char *, int); -int unvis(char *, int, int *, int); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/src/libSystem/libc/xlocale.cpp b/src/libSystem/libc/xlocale.cpp deleted file mode 100644 index dff55caa6..000000000 --- a/src/libSystem/libc/xlocale.cpp +++ /dev/null @@ -1,89 +0,0 @@ -#include "xlocale.h" - -#define WRAP_TRIVIAL(name, type) int name ## _l (wint_t wc, locale_t l) throw() { return UseLocale(name, l, wc); } - -template T UseLocale(Func func, locale_t l, Params... params) -{ - locale_t oldLoc = uselocale(l); - - T rv = func(params...); - - uselocale(oldLoc); - return rv; -} - -size_t mbstowcs_l(wchar_t* pwcs, const char* s, size_t n, locale_t l) -{ - return UseLocale(mbstowcs, l, pwcs, s, n); -} - -size_t wcswidth_l(wchar_t* pwcs, size_t n, locale_t l) -{ - return UseLocale(wcswidth, l, pwcs, n); -} - -int mbtowc_l(wchar_t* pwc, const char* s, size_t n, locale_t l) -{ - return UseLocale(mbtowc, l, pwc, s, n); -} - -size_t mbrtowc_l(wchar_t * pwc, const char * s, size_t n, mbstate_t * ps, locale_t l) -{ - return UseLocale(mbrtowc, l, pwc, s, n, ps); -} - -int mblen_l(const char *s, size_t n, locale_t l) -{ - return UseLocale(mblen, l, s, n); -} - -size_t wcrtomb_l(char * s, wchar_t wc, mbstate_t * ps, locale_t l) -{ - return UseLocale(wcrtomb, l, s, wc, ps); -} - -int iswnumber(wint_t wc) throw() -{ - return iswdigit(wc); -} - -WRAP_TRIVIAL(iswalnum, WCTYPE_ALNUM); -WRAP_TRIVIAL(iswalpha, WCTYPE_ALPHA); -// WRAP_TRIVIAL(iswascii); -WRAP_TRIVIAL(iswblank, WCTYPE_BLANK); -WRAP_TRIVIAL(iswcntrl, WCTYPE_CNTRL); -WRAP_TRIVIAL(iswdigit, WCTYPE_DIGIT); -WRAP_TRIVIAL(iswgraph, WCTYPE_GRAPH); -// WRAP_TRIVIAL(iswhexnumber); -// WRAP_TRIVIAL(iswideogram); -WRAP_TRIVIAL(iswlower, WCTYPE_LOWER); -WRAP_TRIVIAL(iswnumber, WCTYPE_DIGIT); -// WRAP_TRIVIAL(iswphonogram); -WRAP_TRIVIAL(iswprint, WCTYPE_PRINT); -WRAP_TRIVIAL(iswpunct, WCTYPE_PUNCT); -// WRAP_TRIVIAL(iswrune); -WRAP_TRIVIAL(iswspace, WCTYPE_SPACE); -// WRAP_TRIVIAL(iswspecial); -WRAP_TRIVIAL(iswupper, WCTYPE_UPPER); -WRAP_TRIVIAL(iswxdigit, WCTYPE_XDIGIT); - -int iswctype_l(wint_t wc, wctype_t charclass, locale_t loc) throw() -{ - return UseLocale(iswctype, loc, wc, charclass); -} - -wctype_t wctype_l(const char *property, locale_t loc) throw() -{ - return UseLocale(wctype, loc, property); -} - -int ___mb_cur_max_l(locale_t loc) -{ - return UseLocale(___mb_cur_max, loc); -} - -int ___mb_cur_max(void) -{ - return MB_CUR_MAX; -} - diff --git a/src/libSystem/libc/xlocale.h b/src/libSystem/libc/xlocale.h deleted file mode 100644 index 4e2aac15c..000000000 --- a/src/libSystem/libc/xlocale.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef LIBC_MULTIBYTE_H -#define LIBC_MULTIBYTE_H -#include -#include -#include -#include - -extern "C" { - -size_t mbstowcs_l(wchar_t* pwcs, const char* s, size_t n, locale_t l); -size_t wcswidth_l(wchar_t* pwcs, size_t n, locale_t l); -int mbtowc_l(wchar_t * pwc, const char * s, size_t n, locale_t l); -size_t mbrtowc_l(wchar_t * pwc, const char * s, size_t n, mbstate_t * ps, locale_t l); -int mblen_l(const char *s, size_t n, locale_t l); -size_t wcrtomb_l(char * s, wchar_t wc, mbstate_t * ps, locale_t l); - -int iswalnum_l(wint_t wc, locale_t loc) throw(); -int iswalpha_l(wint_t wc, locale_t loc) throw(); -int iswascii_l(wint_t wc, locale_t loc) throw(); -int iswblank_l(wint_t wc, locale_t loc) throw(); -int iswcntrl_l(wint_t wc, locale_t loc) throw(); -int iswdigit_l(wint_t wc, locale_t loc) throw(); -int iswgraph_l(wint_t wc, locale_t loc) throw(); -int iswhexnumber_l(wint_t wc, locale_t loc) throw(); -int iswideogram_l(wint_t wc, locale_t loc) throw(); -int iswlower_l(wint_t wc, locale_t loc) throw(); -int iswnumber_l(wint_t wc, locale_t loc) throw(); -int iswphonogram_l(wint_t wc, locale_t loc) throw(); -int iswprint_l(wint_t wc, locale_t loc) throw(); -int iswpunct_l(wint_t wc, locale_t loc) throw(); -int iswrune_l(wint_t wc, locale_t loc) throw(); -int iswspace_l(wint_t wc, locale_t loc) throw(); -int iswspecial_l(wint_t wc, locale_t loc) throw(); -int iswupper_l(wint_t wc, locale_t loc) throw(); -int iswxdigit_l(wint_t wc, locale_t loc) throw(); -int iswnumber(wint_t wc) throw(); - -int iswctype_l(wint_t wc, wctype_t charclass, locale_t loc) throw(); -wctype_t wctype_l(const char *property, locale_t loc) throw(); - -int ___mb_cur_max_l(locale_t loc); -int ___mb_cur_max(void); - - -/* -TODO: - - digittoint_l(3), isalnum_l(3), isalpha_l(3), isblank_l(3), iscntrl_l(3), isdigit_l(3), isgraph_l(3), ishexnumber_l(3), isideogram_l(3), islower_l(3), isnumber_l(3), - isphonogram_l(3), isprint_l(3), ispunct_l(3), isrune_l(3), isspace_l(3), isspecial_l(3), isupper_l(3), isxdigit_l(3), tolower_l(3), toupper_l(3) - - - strtoimax_l(3), strtoumax_l(3), wcstoimax_l(3), wcstoumax_l(3) - - - nl_langinfo_l(3) - - - strfmon_l(3) - - asprintf_l(3), fprintf_l(3), fscanf_l(3), printf_l(3), scanf_l(3), snprintf_l(3), sprintf_l(3), sscanf_l(3), vasprintf_l(3), vfprintf_l(3), vfscanf_l(3), vprintf_l(3), - vscanf_l(3), vsnprintf_l(3), vsprintf_l(3), vsscanf_l(3) - - atof_l(3), atoi_l(3), atol_l(3), atoll_l(3), strtod_l(3), strtof_l(3), strtol_l(3), strtold_l(3), strtoll_l(3), strtoq_l(3), - strtoul_l(3), strtoull_l(3), strtouq_l(3), wcstombs_l(3), wctomb_l(3) - - strcoll_l(3), strxfrm_l(3), strcasecmp_l(3), strcasestr_l(3), strncasecmp_l(3) - - strftime_l(3), strptime_l(3) - - btowc_l(3), fgetwc_l(3), *fgetws_l(3), fputwc_l(3), fputws_l(3), fwprintf_l(3), fwscanf_l(3), getwc_l(3), getwchar_l(3), mbrlen_l(3), mbsinit_l(3), - mbsnrtowcs_l(3), mbsrtowcs_l(3), putwc_l(3), putwchar_l(3), swprintf_l(3), swscanf_l(3), ungetwc_l(3), vfwprintf_l(3), vfwscanf_l(3), vswprintf_l(3), vswscanf_l(3), - vwprintf_l(3), vwscanf_l(3), wcscoll_l(3), wcsftime_l(3), wcsnrtombs_l(3), wcsrtombs_l(3), wcstod_l(3), wcstof_l(3), wcstol_l(3), wcstold_l(3), - wcstoll_l(3), wcstoul_l(3), wcstoull_l(3), wcswidth_l(3), wcsxfrm_l(3), wctob_l(3), wcwidth_l(3), wprintf_l(3), wscanf_l(3) - - iswblank_l(3), iswhexnumber_l(3), iswideogram_l(3), iswnumber_l(3), iswphonogram_l(3), iswrune_l(3), iswspecial_l(3), nextwctype_l(3), towctrans_l(3), wctrans_l(3) - - - localeconv_l(3) - -*/ - -} - -#endif - diff --git a/src/libdyld/CMakeLists.txt b/src/libdyld/CMakeLists.txt index 8562a1326..f414c978e 100644 --- a/src/libdyld/CMakeLists.txt +++ b/src/libdyld/CMakeLists.txt @@ -2,12 +2,18 @@ project(libdyld) cmake_minimum_required(VERSION 2.4.0) +# set(CMAKE_ASM_NASM_OBJECT_FORMAT "elf") # TODO: for 32bit +# enable_language(ASM_NASM) + if(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) endif(COMMAND cmake_policy) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../util) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../libmach-o) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../include/darwin) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../include/xnu) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../include/xnu/bsd) diff --git a/src/libdyld/DylibSearch.cpp b/src/libdyld/DylibSearch.cpp index 942efa4b6..576eb28cc 100644 --- a/src/libdyld/DylibSearch.cpp +++ b/src/libdyld/DylibSearch.cpp @@ -1,5 +1,5 @@ #include "DylibSearch.h" -#include "config.h" +#include "darling-config.h" #include #include #include "MachOObject.h" diff --git a/src/libdyld/MachOMgr.cpp b/src/libdyld/MachOMgr.cpp index 76ce869f4..622047403 100644 --- a/src/libdyld/MachOMgr.cpp +++ b/src/libdyld/MachOMgr.cpp @@ -114,11 +114,11 @@ void MachOMgr::deregisterUnloadHook(LoaderHookFunc* func) void MachOMgr::addDefaultLoader() { - if (!m_addedDefaultLoader) - { - add(new NativeObject(RTLD_DEFAULT, "")); - m_addedDefaultLoader = true; - } +// if (!m_addedDefaultLoader) +// { +// add(new NativeObject(RTLD_DEFAULT, "")); +// m_addedDefaultLoader = true; +// } } void MachOMgr::add(MachOObject* obj, bool mainModule) diff --git a/src/libdyld/NativeObject.cpp b/src/libdyld/NativeObject.cpp index 21d5dcf3b..837df8b50 100644 --- a/src/libdyld/NativeObject.cpp +++ b/src/libdyld/NativeObject.cpp @@ -24,7 +24,8 @@ void NativeObject::load() int flags = 0; flags |= globalExports() ? RTLD_GLOBAL : RTLD_LOCAL; - flags |= bindAllAtLoad() ? RTLD_NOW : RTLD_LAZY; + //flags |= bindAllAtLoad() ? RTLD_NOW : RTLD_LAZY; + flags |= RTLD_LAZY; m_nativeRef = ::dlopen(m_path.c_str(), flags); if (!m_nativeRef) @@ -85,20 +86,11 @@ void NativeObject::updateName() void* NativeObject::getExportedSymbol(const std::string& symbolName, bool nonWeakOnly) const { void* addr; - std::string prefixed = "__darwin_" + symbolName; if (symbolName == "main") return nullptr; // Don't return main() from Darling itself - addr = ::dlsym(m_nativeRef, prefixed.c_str()); - - if (!addr) - addr = ::dlvsym(m_nativeRef, symbolName.c_str(), "DARLING"); - - if (!addr) - addr = ::dlsym(m_nativeRef, symbolName.c_str()); - - return addr; + return ::dlvsym(m_nativeRef, symbolName.c_str(), "DARWIN"); } bool NativeObject::findSymbolInfo(const void* addr, Dl_info* p) const diff --git a/src/libdyld/dl_public.cpp b/src/libdyld/dl_public.cpp index 94e1f57dd..a07b23732 100644 --- a/src/libdyld/dl_public.cpp +++ b/src/libdyld/dl_public.cpp @@ -149,10 +149,6 @@ void* __darwin_dlsym(void* handle, const char* symbol) LOG << "__darwin_dlsym(): " << symbol << std::endl; - removeSuffix(name, "$UNIX2003"); - removeSuffix(name, "$DARWIN_EXTSN"); - removeSuffix(name, "$NOCANCEL"); - translated = processSymbolViaHooks(name); if (handle == DARWIN_RTLD_DEFAULT) diff --git a/src/libdyld/dyld_public.cpp b/src/libdyld/dyld_public.cpp index d76a0edfa..8c82f5bcb 100644 --- a/src/libdyld/dyld_public.cpp +++ b/src/libdyld/dyld_public.cpp @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with Darling. If not, see . */ -#include "config.h" +#include "darling-config.h" #include "dyld_public.h" #include "MachOMgr.h" #include "MachOObject.h" diff --git a/src/libmach-o/CMakeLists.txt b/src/libmach-o/CMakeLists.txt index af94c9946..0617164ac 100644 --- a/src/libmach-o/CMakeLists.txt +++ b/src/libmach-o/CMakeLists.txt @@ -6,13 +6,11 @@ if(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) endif(COMMAND cmake_policy) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_BSD_I386__TYPES_H_ -D__darwin_natural_t=int") +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../util) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../include/darwin) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../include/xnu) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../include/xnu/bsd) set(mach-o_SRCS MachO.cpp diff --git a/src/libmach-o/FatMachO.cpp b/src/libmach-o/FatMachO.cpp index a02b29f8d..99c9f2db1 100644 --- a/src/libmach-o/FatMachO.cpp +++ b/src/libmach-o/FatMachO.cpp @@ -26,6 +26,7 @@ // SUCH DAMAGE. #include "FatMachO.h" +#include "cpu_types.h" #ifndef _LARGEFILE64_SOURCE # define _LARGEFILE64_SOURCE diff --git a/src/libmach-o/FatMachO.h b/src/libmach-o/FatMachO.h index 6069082d9..035fe8050 100644 --- a/src/libmach-o/FatMachO.h +++ b/src/libmach-o/FatMachO.h @@ -31,7 +31,6 @@ #include #include -#include #include namespace FatMachO diff --git a/src/libmach-o/MachO.cpp b/src/libmach-o/MachO.cpp index a579937bc..5f7610758 100644 --- a/src/libmach-o/MachO.cpp +++ b/src/libmach-o/MachO.cpp @@ -31,6 +31,9 @@ along with Darling. If not, see . #include #include #include +#include +#include "cpu_types.h" + MachO* MachO::readFile(std::string path, const char* arch, bool need_exports, bool loadAny) { diff --git a/src/libmach-o/MachO.h b/src/libmach-o/MachO.h index b1b677534..57d2c1a08 100644 --- a/src/libmach-o/MachO.h +++ b/src/libmach-o/MachO.h @@ -29,8 +29,8 @@ along with Darling. If not, see . #include #include -#include -#include + //#include +#include "mach-o/loader.h" class MachO { diff --git a/src/libmach-o/MachOImpl.cpp b/src/libmach-o/MachOImpl.cpp index 9acba276e..38d8927d1 100644 --- a/src/libmach-o/MachOImpl.cpp +++ b/src/libmach-o/MachOImpl.cpp @@ -23,6 +23,7 @@ along with Darling. If not, see . #include "RebaseState.h" #include "BindState.h" #include "leb.h" +#include "cpu_types.h" #include #include @@ -289,7 +290,7 @@ void MachOImpl::readExport(const uint8_t* start, const uint8_t* p, const uint8_t m_exports.push_back(exp); - assert(expected_term_end == p); + assert(expected_term_end == p); // FIXME: This assert fails with dylibs in OS X SDK } const uint8_t num_children = *p++; diff --git a/src/libmach-o/cpu_types.h b/src/libmach-o/cpu_types.h new file mode 100644 index 000000000..84680abe4 --- /dev/null +++ b/src/libmach-o/cpu_types.h @@ -0,0 +1,22 @@ +#ifndef CPU_TYPES_H +#define CPU_TYPES_H + +#define CPU_ARCH_ABI64 0x01000000 /* 64 bit ABI */ +#define CPU_TYPE_ANY ((cpu_type_t) -1) +#define CPU_TYPE_VAX ((cpu_type_t) 1) +#define CPU_TYPE_MC680x0 ((cpu_type_t) 6) +#define CPU_TYPE_X86 ((cpu_type_t) 7) +#define CPU_TYPE_I386 CPU_TYPE_X86 /* compatibility */ +#define CPU_TYPE_X86_64 (CPU_TYPE_X86 | CPU_ARCH_ABI64) +#define CPU_TYPE_MC98000 ((cpu_type_t) 10) +#define CPU_TYPE_HPPA ((cpu_type_t) 11) +#define CPU_TYPE_ARM ((cpu_type_t) 12) +#define CPU_TYPE_ARM64 (CPU_TYPE_ARM | CPU_ARCH_ABI64) +#define CPU_TYPE_MC88000 ((cpu_type_t) 13) +#define CPU_TYPE_SPARC ((cpu_type_t) 14) +#define CPU_TYPE_I860 ((cpu_type_t) 15) +#define CPU_TYPE_POWERPC ((cpu_type_t) 18) +#define CPU_TYPE_POWERPC64 (CPU_TYPE_POWERPC | CPU_ARCH_ABI64) + +#endif + diff --git a/src/libmach-o/mach b/src/libmach-o/mach new file mode 120000 index 000000000..0f38a22c3 --- /dev/null +++ b/src/libmach-o/mach @@ -0,0 +1 @@ +../../platform-include/mach \ No newline at end of file diff --git a/src/libmach-o/mach-o b/src/libmach-o/mach-o new file mode 120000 index 000000000..28a41841a --- /dev/null +++ b/src/libmach-o/mach-o @@ -0,0 +1 @@ +../../platform-include/mach-o \ No newline at end of file diff --git a/src/libmach-o/sys/_types b/src/libmach-o/sys/_types new file mode 120000 index 000000000..774a62d95 --- /dev/null +++ b/src/libmach-o/sys/_types @@ -0,0 +1 @@ +../../../platform-include/sys/_types \ No newline at end of file diff --git a/src/libmach-o/sys/_types.h b/src/libmach-o/sys/_types.h new file mode 100644 index 000000000..e69de29bb diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index 4259ea88d..b50ad237f 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -2,6 +2,8 @@ project(util) cmake_minimum_required(VERSION 2.4.0) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + if(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) endif(COMMAND cmake_policy)