Unnamed: 0
int64
0
0
repo_id
stringlengths
5
186
file_path
stringlengths
15
223
content
stringlengths
1
32.8M
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/task.h
/* * Copyright (c) 2000-2019 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_FREE_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 [email protected] * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 * * any improvements or extensions that they make and grant Carnegie Mellon * the rights to redistribute these changes. */ /* */ /* * File: task.h * Author: Avadis Tevanian, Jr. * * This file contains the structure definitions for tasks. * */ /* * 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 [email protected] any * improvements that they make and grant CSL redistribution rights. * */ /* * 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. */ #ifndef _KERN_TASK_H_ #define _KERN_TASK_H_ #include <kern/btlog.h> #include <kern/kern_types.h> #include <kern/task_ref.h> #include <mach/mach_types.h> #include <sys/cdefs.h> __BEGIN_DECLS extern task_t current_task(void); extern bool task_is_driver(task_t task); #define TF_NONE 0 #define TWF_NONE 0 #define TRW_LRETURNWAIT 0x01 /* task is waiting for fork/posix_spawn/exec to complete */ #define TRW_LRETURNWAITER 0x02 /* task is waiting for TRW_LRETURNWAIT to get cleared */ /* task clear return wait flags */ #define TCRW_CLEAR_INITIAL_WAIT 0x1 #define TCRW_CLEAR_FINAL_WAIT 0x2 #define TCRW_CLEAR_ALL_WAIT (TCRW_CLEAR_INITIAL_WAIT | TCRW_CLEAR_FINAL_WAIT) #define TPF_NONE 0 #define TPF_EXEC_COPY 0x00000002 /* task is the new copy of an exec */ __END_DECLS __BEGIN_DECLS extern task_t kernel_task; extern void task_name_deallocate_mig( task_name_t task_name); extern void task_policy_set_deallocate_mig( task_policy_set_t task_policy_set); extern void task_policy_get_deallocate_mig( task_policy_get_t task_policy_get); extern void task_inspect_deallocate_mig( task_inspect_t task_inspect); extern void task_read_deallocate_mig( task_read_t task_read); extern void task_suspension_token_deallocate( task_suspension_token_t token); extern boolean_t task_self_region_footprint(void); extern void task_self_region_footprint_set(boolean_t newval); extern void task_ledgers_footprint(ledger_t ledger, ledger_amount_t *ledger_resident, ledger_amount_t *ledger_compressed); extern void task_set_memory_ownership_transfer( task_t task, boolean_t value); #if DEVELOPMENT || DEBUG extern void task_set_no_footprint_for_debug( task_t task, boolean_t value); extern int task_get_no_footprint_for_debug( task_t task); #endif /* DEVELOPMENT || DEBUG */ #if CONFIG_X86_64_COMPAT extern boolean_t task_is_translated(task_t task); #endif __END_DECLS #endif /* _KERN_TASK_H_ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/macro_help.h
/* * 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 [email protected] * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 * * any improvements or extensions that they make and grant Carnegie Mellon * the rights to redistribute these changes. */ /* */ /* * File: kern/macro_help.h * * Provide help in making lint-free macro routines * */ #ifndef _KERN_MACRO_HELP_H_ #define _KERN_MACRO_HELP_H_ #if DRIVERKIT_FRAMEWORK_INCLUDE #define NEVER false #define ALWAYS true #else #include <mach/boolean.h> #ifdef lint boolean_t NEVER; boolean_t ALWAYS; #else /* lint */ #define NEVER FALSE #define ALWAYS TRUE #endif /* lint */ #endif /* DRIVERKIT_FRAMEWORK_INCLUDE */ #define MACRO_BEGIN do { #define MACRO_END } while (NEVER) #define MACRO_RETURN if (ALWAYS) return #endif /* _KERN_MACRO_HELP_H_ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/hv_support_kern.h
/* * Copyright (c) 2019 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@ */ /* hv_support_kern.h: machine-independent hypervisor helpers for kernel use */ #pragma once #include <kern/kern_types.h> extern int hv_support_available; /*! * @function hv_support_init * @abstract Initialize hypervisor facility during kernel bootstrap */ extern void hv_support_init(void); /*! * @function hv_get_support * @abstract Indicates whether the hypervisor facility is supported on this platform * @return 0 if not supported, non-zero otherwise */ extern int hv_get_support(void); /*! * @function hv_set_task_target * @abstract Associate an opaque hypervisor object with the current OS task * @param target The opaque object to be associated */ extern void hv_set_task_target(void *target); /*! * @function hv_set_thread_target * @abstract Associate an opaque hypervisor object with the current OS thread * @param target The opaque object to be associated */ extern void hv_set_thread_target(void *target); /*! * @function hv_get_task_target * @abstract Retrieve an opaque hypervisor object associated with the current OS task * @return The associated object, or NULL if no object is associated */ extern void * hv_get_task_target(void); /*! * @function hv_get_thread_target * @abstract Retrieve an opaque hypervisor object associated with the current OS thread * @return The associated object, or NULL if no object is associated */ extern void * hv_get_thread_target(void);
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/kern_cdata.h
/* * Copyright (c) 2015 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 _KERN_CDATA_H_ #define _KERN_CDATA_H_ #include <kern/kcdata.h> #include <mach/mach_types.h> /* * Do not use these macros! * * Instead, you should use kcdata_iter_* functions defined in kcdata.h. These * macoros have no idea where the kcdata buffer ends, so they are all unsafe. */ #define KCDATA_ITEM_HEADER_SIZE (sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint64_t)) #define KCDATA_ITEM_ITER(item) kcdata_iter_unsafe((void*)(item)) #define KCDATA_ITEM_TYPE(item) kcdata_iter_type(KCDATA_ITEM_ITER(item)) #define KCDATA_ITEM_SIZE(item) kcdata_iter_size(KCDATA_ITEM_ITER(item)) #define KCDATA_ITEM_FLAGS(item) kcdata_iter_flags(KCDATA_ITEM_ITER(item)) #define KCDATA_ITEM_ARRAY_GET_EL_TYPE(item) kcdata_iter_array_elem_type(KCDATA_ITEM_ITER(item)) #define KCDATA_ITEM_ARRAY_GET_EL_COUNT(item) kcdata_iter_array_elem_count(KCDATA_ITEM_ITER(item)) #define KCDATA_ITEM_ARRAY_GET_EL_SIZE(item) kcdata_iter_array_elem_size(KCDATA_ITEM_ITER(item)) #define KCDATA_CONTAINER_ID(item) kcdata_iter_container_id(KCDATA_ITEM_ITER(item)) #define KCDATA_ITEM_NEXT_HEADER(itemx) (kcdata_iter_next(KCDATA_ITEM_ITER(itemx)).item) #define KCDATA_ITEM_FOREACH(head) for (; KCDATA_ITEM_TYPE(head) != KCDATA_TYPE_BUFFER_END; (head) = KCDATA_ITEM_NEXT_HEADER(head)) #define KCDATA_ITEM_DATA_PTR(item) kcdata_iter_payload(KCDATA_ITEM_ITER(item)) #define KCDATA_ITEM_FIND_TYPE(itemx, type) (kcdata_iter_find_type(KCDATA_ITEM_ITER(itemx), type).item) #define kcdata_get_container_type(buffer) kcdata_iter_container_type(KCDATA_ITEM_ITER(buffer)) #define kcdata_get_data_with_desc(buf, desc, data) kcdata_iter_get_data_with_desc(KCDATA_ITEM_ITER(buf),desc,data,NULL) /* Do not use these macros! */ __options_decl(kcd_compression_type_t, uint64_t, { KCDCT_NONE = 0x00, KCDCT_ZLIB = 0x01, }); typedef void * kcdata_descriptor_t; uint32_t kcdata_estimate_required_buffer_size(uint32_t num_items, uint32_t payload_size); uint64_t kcdata_memory_get_used_bytes(kcdata_descriptor_t kcd); uint64_t kcdata_memory_get_uncompressed_bytes(kcdata_descriptor_t kcd); kern_return_t kcdata_memcpy(kcdata_descriptor_t data, mach_vm_address_t dst_addr, const void * src_addr, uint32_t size); kern_return_t kcdata_bzero(kcdata_descriptor_t data, mach_vm_address_t dst_addr, uint32_t size); kern_return_t kcdata_get_memory_addr(kcdata_descriptor_t data, uint32_t type, uint32_t size, mach_vm_address_t * user_addr); kern_return_t kcdata_get_memory_addr_for_array( kcdata_descriptor_t data, uint32_t type_of_element, uint32_t size_of_element, uint32_t count, mach_vm_address_t * user_addr); #endif /* _KERN_CDATA_H_ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/mpsc_queue.h
/* * Copyright (c) 2018 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 _KERN_MPSC_QUEUE_H_ #define _KERN_MPSC_QUEUE_H_ #include <sys/cdefs.h> __BEGIN_DECLS /*! * @typedef struct mpsc_queue_chain * * @brief * Type for the intrusive linkage used by MPSC queues. */ typedef struct mpsc_queue_chain { struct mpsc_queue_chain *_Atomic mpqc_next; } *mpsc_queue_chain_t; /*! * @typedef struct mpsc_queue_head * * @brief * The type for a multi-producer single-consumer queue. * * @discussion * MPSC queues allow for producers to not be affected by other producers or the * consumer. Which means in turn that having producers in interrupt context * does not require that other producers disable interrupts like a traditional * spinlock based approach would require. * * These queues shine when data is produced from the entire system and is * consumed from a single serial context (logging, tracing, ...). * mpsc_daemon_queue_t is provided as a fully ready/easy-to-use pre-packaged * solution for these common use cases. * * - mpsc_queue_append() can be used to append a single item * - mpsc_queue_append_list() can be used to append a batch of items at once. * * Functions for the consumer side assume proper serialization that is not * provided by the MPSC queue itself. Dequeuing doesn't require preemption * to be disabled. * * <h2>Algorithm</h2> * * The base of the enqueue algorithm is a single atomic exchange (first half, * called __mpsc_queue_append_update_tail) and a list fixup (2nd half, called * __mpsc_queue_append_update_prev). * * Graphically, enqueuing `X` looks like this, with each step being done * atomically (for the empty queue case, `tail` points to `head`): * * | orig state | update_tail | update_prev | * +---------------------+---------------------+---------------------+ * | | | | * | head -> e1 -> e2 -. | head -> e1 -> e2 -. | head -> e1 -> e2 -. | * | | | | | | | * | ,- ... <--' | ,- ... <--' | ,- ... <--' | * | | | | | | | * | v | v | v | * | tail -> eN -> NULL | tail eN -> NULL | tail eN | * | | | | | | | * | | | | | v | * | X -> NULL | `---> X -> NULL | '---> X -> NULL | * | | | | * +---------------------+---------------------+---------------------+ * * * There is a small 1-instruction gap of inconsistency which makes the chosen * algorithm non linearizable, and requires enqueuers to disable preemption * during the enqueue so as not to starve the consumer forever. * * As far as memory visibility is concerned, enqueuing uses a release fence in * update_tail which pairs with memory fences in mpsc_queue_dequeue_batch(). * * Note: as far as the data structure in memory, its layout is equivalent to * a BSD <sys/queue.h> STAILQ. However because of this inconsistency * window and memory ordering concerns, it is incorrect to use STAILQ * macros on an MPSC queue. */ typedef struct mpsc_queue_head { struct mpsc_queue_chain mpqh_head; struct mpsc_queue_chain *_Atomic mpqh_tail; } *mpsc_queue_head_t; /*! * @macro MPSC_QUEUE_INITIALIZER * * @brief * Macro to use in static initializers for mpsc queues. * * @param head * The name of the variable to initialize. */ #define MPSC_QUEUE_INITIALIZER(head) { .mpqh_tail = &(head).mpqh_head } __END_DECLS #endif /* _KERN_MPSC_QUEUE_H_ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/corpses/task_corpse.h
/* * Copyright (c) 2012-2013, 2015 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 _TASK_CORPSE_H_ #define _TASK_CORPSE_H_ #include <stdint.h> #include <mach/mach_types.h> #include <kern/kern_cdata.h> #include <kern/kcdata.h> typedef struct kcdata_item *task_crashinfo_item_t; /* Deprecated: use the KCDATA_* macros for all future use */ #define CRASHINFO_ITEM_TYPE(item) KCDATA_ITEM_TYPE(item) #define CRASHINFO_ITEM_SIZE(item) KCDATA_ITEM_SIZE(item) #define CRASHINFO_ITEM_DATA_PTR(item) KCDATA_ITEM_DATA_PTR(item) #define CRASHINFO_ITEM_NEXT_HEADER(item) KCDATA_ITEM_NEXT_HEADER(item) #define CRASHINFO_ITEM_FOREACH(head) KCDATA_ITEM_FOREACH(head) #endif /* _TASK_CORPSE_H_ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/netkey/keysock.h
/* $KAME: keysock.h,v 1.7 2000/03/25 07:24:14 sumikawa Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * 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 project 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 PROJECT 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 PROJECT 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 _NETKEY_KEYSOCK_H_ #define _NETKEY_KEYSOCK_H_ #include <sys/appleapiopts.h> /* statistics for pfkey socket */ struct pfkeystat { /* kernel -> userland */ u_quad_t out_total; /* # of total calls */ u_quad_t out_bytes; /* total bytecount */ u_quad_t out_msgtype[256]; /* message type histogram */ u_quad_t out_invlen; /* invalid length field */ u_quad_t out_invver; /* invalid version field */ u_quad_t out_invmsgtype; /* invalid message type field */ u_quad_t out_tooshort; /* msg too short */ u_quad_t out_nomem; /* memory allocation failure */ u_quad_t out_dupext; /* duplicate extension */ u_quad_t out_invexttype; /* invalid extension type */ u_quad_t out_invsatype; /* invalid sa type */ u_quad_t out_invaddr; /* invalid address extension */ /* userland -> kernel */ u_quad_t in_total; /* # of total calls */ u_quad_t in_bytes; /* total bytecount */ u_quad_t in_msgtype[256]; /* message type histogram */ u_quad_t in_msgtarget[3]; /* one/all/registered */ u_quad_t in_nomem; /* memory allocation failure */ /* others */ u_quad_t sockerr; /* # of socket related errors */ }; #define KEY_SENDUP_ONE 0 #define KEY_SENDUP_ALL 1 #define KEY_SENDUP_REGISTERED 2 #endif /*_NETKEY_KEYSOCK_H_*/
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/os/atomic.h
/* * Copyright (c) 2019 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 __OS_ATOMIC_H__ #define __OS_ATOMIC_H__ /*! * @file <os/atomic.h> * * @brief * Small header that helps write code that works with both C11 and C++11, * or pre-C11 type declarations. * * @discussion * The macros below allow to write code like this, that can be put in a header * and will work with both C11 and C++11: * * <code> * struct old_type { * int atomic_field; * } old_variable; * * os_atomic_std(atomic_fetch_add_explicit)( * os_cast_to_atomic_pointer(&old_variable), 1, * os_atomic_std(memory_order_relaxed)); * </code> */ #include <os/base.h> #ifndef OS_ATOMIC_USES_CXX #define OS_ATOMIC_USES_CXX 0 #endif #if OS_ATOMIC_USES_CXX #include <atomic> #define OS_ATOMIC_STD std:: #define os_atomic_std(op) std::op #define os_atomic(type) std::atomic<type> volatile #define os_cast_to_atomic_pointer(p) os::cast_to_atomic_pointer(p) #define os_atomic_basetypeof(p) decltype(os_cast_to_atomic_pointer(p)->load()) #define os_cast_to_nonatomic_pointer(p) os::cast_to_nonatomic_pointer(p) #else /* !OS_ATOMIC_USES_CXX */ #include <stdatomic.h> #define OS_ATOMIC_STD #define os_atomic_std(op) op #define os_atomic(type) type volatile _Atomic #define os_cast_to_atomic_pointer(p) (__typeof__(*(p)) volatile _Atomic *)(uintptr_t)(p) #define os_atomic_basetypeof(p) __typeof__(atomic_load(os_cast_to_atomic_pointer(p))) #define os_cast_to_nonatomic_pointer(p) (os_atomic_basetypeof(p) *)(uintptr_t)(p) #endif /* !OS_ATOMIC_USES_CXX */ /*! * @group Internal implementation details * * @discussion The functions below are not intended to be used directly. */ #if OS_ATOMIC_USES_CXX #include <type_traits> namespace os { template <class T> using add_volatile_t = typename std::add_volatile<T>::type; template <class T> using remove_volatile_t = typename std::remove_volatile<T>::type; template <class T> inline add_volatile_t<std::atomic<remove_volatile_t<T> > > * cast_to_atomic_pointer(T *v) { return reinterpret_cast<add_volatile_t<std::atomic<remove_volatile_t<T> > > *>(v); } template <class T> inline add_volatile_t<std::atomic<remove_volatile_t<T> > > * cast_to_atomic_pointer(std::atomic<T> *v) { return reinterpret_cast<add_volatile_t<std::atomic<remove_volatile_t<T> > > *>(v); } template <class T> inline remove_volatile_t<T> * cast_to_nonatomic_pointer(T *v) { return const_cast<remove_volatile_t<T> *>(v); } template <class T> inline remove_volatile_t<T> * cast_to_nonatomic_pointer(std::atomic<T> *v) { return reinterpret_cast<remove_volatile_t<T> *>(v); } template <class T> inline remove_volatile_t<T> * cast_to_nonatomic_pointer(volatile std::atomic<T> *v) { auto _v = const_cast<std::atomic<T> *>(v); return reinterpret_cast<remove_volatile_t<T> *>(_v); } }; #endif /* OS_ATOMIC_USES_CXX */ #endif /* __OS_ATOMIC_H__ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/bsm/audit.h
/*- * Copyright (c) 2005-2009 Apple Inc. * 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 Apple Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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. * * $P4: //depot/projects/trustedbsd/openbsm/sys/bsm/audit.h#10 $ */ #ifndef _BSM_AUDIT_H #define _BSM_AUDIT_H #include <sys/param.h> #include <sys/types.h> #define AUDIT_RECORD_MAGIC 0x828a0f1b #define MAX_AUDIT_RECORDS 20 #define MAXAUDITDATA (0x8000 - 1) #define MAX_AUDIT_RECORD_SIZE MAXAUDITDATA #define MIN_AUDIT_FILE_SIZE (512 * 1024) /* * Minimum noumber of free blocks on the filesystem containing the audit * log necessary to avoid a hard log rotation. DO NOT SET THIS VALUE TO 0 * as the kernel does an unsigned compare, plus we want to leave a few blocks * free so userspace can terminate the log, etc. */ #define AUDIT_HARD_LIMIT_FREE_BLOCKS 4 /* * Triggers for the audit daemon. */ #define AUDIT_TRIGGER_MIN 1 #define AUDIT_TRIGGER_LOW_SPACE 1 /* Below low watermark. */ #define AUDIT_TRIGGER_ROTATE_KERNEL 2 /* Kernel requests rotate. */ #define AUDIT_TRIGGER_READ_FILE 3 /* Re-read config file. */ #define AUDIT_TRIGGER_CLOSE_AND_DIE 4 /* Terminate audit. */ #define AUDIT_TRIGGER_NO_SPACE 5 /* Below min free space. */ #define AUDIT_TRIGGER_ROTATE_USER 6 /* User requests rotate. */ #define AUDIT_TRIGGER_INITIALIZE 7 /* User initialize of auditd. */ #define AUDIT_TRIGGER_EXPIRE_TRAILS 8 /* User expiration of trails. */ #define AUDIT_TRIGGER_MAX 8 /* * The special device filename (FreeBSD). */ #define AUDITDEV_FILENAME "audit" #define AUDIT_TRIGGER_FILE ("/dev/" AUDITDEV_FILENAME) /* * Pre-defined audit IDs */ #define AU_DEFAUDITID (uid_t)(-1) #define AU_DEFAUDITSID 0 #define AU_ASSIGN_ASID -1 /* * IPC types. */ #define AT_IPC_MSG ((unsigned char)1) /* Message IPC id. */ #define AT_IPC_SEM ((unsigned char)2) /* Semaphore IPC id. */ #define AT_IPC_SHM ((unsigned char)3) /* Shared mem IPC id. */ /* * Audit conditions. */ #define AUC_UNSET 0 #define AUC_AUDITING 1 #define AUC_NOAUDIT 2 #define AUC_DISABLED -1 /* * auditon(2) commands. */ #define A_OLDGETPOLICY 2 #define A_OLDSETPOLICY 3 #define A_GETKMASK 4 #define A_SETKMASK 5 #define A_OLDGETQCTRL 6 #define A_OLDSETQCTRL 7 #define A_GETCWD 8 #define A_GETCAR 9 #define A_GETSTAT 12 #define A_SETSTAT 13 #define A_SETUMASK 14 #define A_SETSMASK 15 #define A_OLDGETCOND 20 #define A_OLDSETCOND 21 #define A_GETCLASS 22 #define A_SETCLASS 23 #define A_GETPINFO 24 #define A_SETPMASK 25 #define A_SETFSIZE 26 #define A_GETFSIZE 27 #define A_GETPINFO_ADDR 28 #define A_GETKAUDIT 29 #define A_SETKAUDIT 30 #define A_SENDTRIGGER 31 #define A_GETSINFO_ADDR 32 #define A_GETPOLICY 33 #define A_SETPOLICY 34 #define A_GETQCTRL 35 #define A_SETQCTRL 36 #define A_GETCOND 37 #define A_SETCOND 38 #define A_GETSFLAGS 39 #define A_SETSFLAGS 40 #define A_GETCTLMODE 41 #define A_SETCTLMODE 42 #define A_GETEXPAFTER 43 #define A_SETEXPAFTER 44 /* * Audit policy controls. */ #define AUDIT_CNT 0x0001 #define AUDIT_AHLT 0x0002 #define AUDIT_ARGV 0x0004 #define AUDIT_ARGE 0x0008 #define AUDIT_SEQ 0x0010 #define AUDIT_WINDATA 0x0020 #define AUDIT_USER 0x0040 #define AUDIT_GROUP 0x0080 #define AUDIT_TRAIL 0x0100 #define AUDIT_PATH 0x0200 #define AUDIT_SCNT 0x0400 #define AUDIT_PUBLIC 0x0800 #define AUDIT_ZONENAME 0x1000 #define AUDIT_PERZONE 0x2000 /* * Default audit queue control parameters. */ #define AQ_HIWATER 100 #define AQ_MAXHIGH 10000 #define AQ_LOWATER 10 #define AQ_BUFSZ MAXAUDITDATA #define AQ_MAXBUFSZ 1048576 /* * Default minimum percentage free space on file system. */ #define AU_FS_MINFREE 20 /* * Type definitions used indicating the length of variable length addresses * in tokens containing addresses, such as header fields. */ #define AU_IPv4 4 #define AU_IPv6 16 /* * Reserved audit class mask indicating which classes are unable to have * events added or removed by unentitled processes. */ #define AU_CLASS_MASK_RESERVED 0x10000000 /* * Audit control modes */ #define AUDIT_CTLMODE_NORMAL ((unsigned char)1) #define AUDIT_CTLMODE_EXTERNAL ((unsigned char)2) /* * Audit file expire_after op modes */ #define AUDIT_EXPIRE_OP_AND ((unsigned char)0) #define AUDIT_EXPIRE_OP_OR ((unsigned char)1) __BEGIN_DECLS typedef uid_t au_id_t; typedef pid_t au_asid_t; typedef u_int16_t au_event_t; typedef u_int16_t au_emod_t; typedef u_int32_t au_class_t; typedef u_int64_t au_asflgs_t __attribute__ ((aligned(8))); typedef unsigned char au_ctlmode_t; struct au_tid { dev_t port; u_int32_t machine; }; typedef struct au_tid au_tid_t; struct au_tid_addr { dev_t at_port; u_int32_t at_type; u_int32_t at_addr[4]; }; typedef struct au_tid_addr au_tid_addr_t; struct au_mask { unsigned int am_success; /* Success bits. */ unsigned int am_failure; /* Failure bits. */ }; typedef struct au_mask au_mask_t; struct auditinfo { au_id_t ai_auid; /* Audit user ID. */ au_mask_t ai_mask; /* Audit masks. */ au_tid_t ai_termid; /* Terminal ID. */ au_asid_t ai_asid; /* Audit session ID. */ }; typedef struct auditinfo auditinfo_t; struct auditinfo_addr { au_id_t ai_auid; /* Audit user ID. */ au_mask_t ai_mask; /* Audit masks. */ au_tid_addr_t ai_termid; /* Terminal ID. */ au_asid_t ai_asid; /* Audit session ID. */ au_asflgs_t ai_flags; /* Audit session flags. */ }; typedef struct auditinfo_addr auditinfo_addr_t; struct auditpinfo { pid_t ap_pid; /* ID of target process. */ au_id_t ap_auid; /* Audit user ID. */ au_mask_t ap_mask; /* Audit masks. */ au_tid_t ap_termid; /* Terminal ID. */ au_asid_t ap_asid; /* Audit session ID. */ }; typedef struct auditpinfo auditpinfo_t; struct auditpinfo_addr { pid_t ap_pid; /* ID of target process. */ au_id_t ap_auid; /* Audit user ID. */ au_mask_t ap_mask; /* Audit masks. */ au_tid_addr_t ap_termid; /* Terminal ID. */ au_asid_t ap_asid; /* Audit session ID. */ au_asflgs_t ap_flags; /* Audit session flags. */ }; typedef struct auditpinfo_addr auditpinfo_addr_t; struct au_session { auditinfo_addr_t *as_aia_p; /* Ptr to full audit info. */ au_mask_t as_mask; /* Process Audit Masks. */ }; typedef struct au_session au_session_t; struct au_expire_after { time_t age; /* Age after which trail files should be expired */ size_t size; /* Aggregate trail size when files should be expired */ unsigned char op_type; /* Operator used with the above values to determine when files should be expired */ }; typedef struct au_expire_after au_expire_after_t; /* * Contents of token_t are opaque outside of libbsm. */ typedef struct au_token token_t; /* * Kernel audit queue control parameters: * Default: Maximum: * aq_hiwater: AQ_HIWATER (100) AQ_MAXHIGH (10000) * aq_lowater: AQ_LOWATER (10) <aq_hiwater * aq_bufsz: AQ_BUFSZ (32767) AQ_MAXBUFSZ (1048576) * aq_delay: 20 20000 (not used) */ struct au_qctrl { int aq_hiwater; /* Max # of audit recs in queue when */ /* threads with new ARs get blocked. */ int aq_lowater; /* # of audit recs in queue when */ /* blocked threads get unblocked. */ int aq_bufsz; /* Max size of audit record for audit(2). */ int aq_delay; /* Queue delay (not used). */ int aq_minfree; /* Minimum filesystem percent free space. */ }; typedef struct au_qctrl au_qctrl_t; /* * Structure for the audit statistics. */ struct audit_stat { unsigned int as_version; unsigned int as_numevent; int as_generated; int as_nonattrib; int as_kernel; int as_audit; int as_auditctl; int as_enqueue; int as_written; int as_wblocked; int as_rblocked; int as_dropped; int as_totalsize; unsigned int as_memused; }; typedef struct audit_stat au_stat_t; /* * Structure for the audit file statistics. */ struct audit_fstat { u_int64_t af_filesz; u_int64_t af_currsz; }; typedef struct audit_fstat au_fstat_t; /* * Audit to event class mapping. */ struct au_evclass_map { au_event_t ec_number; au_class_t ec_class; }; typedef struct au_evclass_map au_evclass_map_t; #define __AUDIT_API_DEPRECATED /* * Audit system calls. */ __END_DECLS #endif /* !_BSM_AUDIT_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/gssd/gssd_mach_types.h
/* * Copyright (c) 2006, 2008, 2010 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 _GSSD_MACH_TYPES_H_ #define _GSSD_MACH_TYPES_H_ #define MAX_DISPLAY_STR 128 #define MAX_PRINC_STR 1024 typedef enum gssd_mechtype { GSSD_NO_MECH = -1, GSSD_KRB5_MECH = 0, GSSD_SPNEGO_MECH, GSSD_NTLM_MECH, GSSD_IAKERB_MECH } gssd_mechtype; typedef enum gssd_nametype { GSSD_STRING_NAME = 0, GSSD_EXPORT, GSSD_ANONYMOUS, GSSD_HOSTBASED, GSSD_USER, GSSD_MACHINE_UID, GSSD_STRING_UID, GSSD_KRB5_PRINCIPAL, GSSD_KRB5_REFERRAL, GSSD_NTLM_PRINCIPAL, GSSD_NTLM_BLOB, GSSD_UUID } gssd_nametype; typedef char *gssd_string; typedef char *gssd_dstring; typedef uint8_t *gssd_byte_buffer; typedef uint32_t *gssd_gid_list; typedef uint64_t gssd_ctx; typedef uint64_t gssd_cred; typedef int32_t *gssd_etype_list; /* The following need to correspond to GSS_C_*_FLAG in gssapi.h */ #define GSSD_DELEG_FLAG 1 #define GSSD_MUTUAL_FLAG 2 #define GSSD_REPLAY_FLAG 4 #define GSSD_SEQUENCE_FLAG 8 #define GSSD_CONF_FLAG 16 #define GSSD_INTEG_FLAG 32 #define GSSD_ANON_FLAG 64 #define GSSD_PROT_FLAG 128 #define GSSD_TRANS_FLAG 256 #define GSSD_DELEG_POLICY_FLAG 32768 #define GSSD_NO_DEFAULT 1 // Only use the supplied principal, do not fallback to the default. #define GSSD_NO_CANON 2 // Don't canononicalize host names #define GSSD_HOME_ACCESS_OK 4 // OK to access home directory #define GSSD_GUEST_ONLY 8 // NTLM Server is forcing guest access #define GSSD_RESTART 16 // Destroy the supplied context and start over #define GSSD_NFS_1DES 64 // Only get single DES session keys #define GSSD_WIN2K_HACK 128 // Hack for Win2K #define GSSD_LUCID_CONTEXT 256 // Export Lucid context #endif /* _GSSD_MACH_TYPES_H_ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/gssd/gssd_mach.h
#ifndef _gssd_mach_user_ #define _gssd_mach_user_ /* Module gssd_mach */ #include <string.h> #include <mach/ndr.h> #include <mach/boolean.h> #include <mach/kern_return.h> #include <mach/notify.h> #include <mach/mach_types.h> #include <mach/message.h> #include <mach/mig_errors.h> #include <mach/port.h> /* BEGIN MIG_STRNCPY_ZEROFILL CODE */ #if defined(__has_include) #if __has_include(<mach/mig_strncpy_zerofill_support.h>) #ifndef USING_MIG_STRNCPY_ZEROFILL #define USING_MIG_STRNCPY_ZEROFILL #endif #ifndef __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ #define __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ #ifdef __cplusplus extern "C" { #endif extern int mig_strncpy_zerofill(char *dest, const char *src, int len) __attribute__((weak_import)); #ifdef __cplusplus } #endif #endif /* __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ */ #endif /* __has_include(<mach/mig_strncpy_zerofill_support.h>) */ #endif /* __has_include */ /* END MIG_STRNCPY_ZEROFILL CODE */ #if (__MigKernelSpecificCode) || (_MIG_KERNEL_SPECIFIC_CODE_) #include <kern/ipc_mig.h> #endif /* __MigKernelSpecificCode */ #ifdef AUTOTEST #ifndef FUNCTION_PTR_T #define FUNCTION_PTR_T typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); typedef struct { char *name; function_ptr_t function; } function_table_entry; typedef function_table_entry *function_table_t; #endif /* FUNCTION_PTR_T */ #endif /* AUTOTEST */ #ifndef gssd_mach_MSG_COUNT #define gssd_mach_MSG_COUNT 9 #endif /* gssd_mach_MSG_COUNT */ #include <Availability.h> #include <mach/std_types.h> #include <mach/mig.h> #include <mach/mig.h> #include <mach/mach_types.h> #include <gssd/gssd_mach_types.h> #ifdef __BeforeMigUserHeader __BeforeMigUserHeader #endif /* __BeforeMigUserHeader */ #include <sys/cdefs.h> __BEGIN_DECLS /* Routine mach_gss_init_sec_context */ #ifdef mig_external mig_external #else extern #endif /* mig_external */ kern_return_t mach_gss_init_sec_context ( mach_port_t server, gssd_mechtype mech, gssd_byte_buffer intoken, mach_msg_type_number_t intokenCnt, uint32_t uid, gssd_string princ_namestr, gssd_string svc_namestr, uint32_t flags, uint32_t gssd_flags, gssd_ctx *context, gssd_cred *cred_handle, uint32_t *ret_flags, gssd_byte_buffer *key, mach_msg_type_number_t *keyCnt, gssd_byte_buffer *outtoken, mach_msg_type_number_t *outtokenCnt, uint32_t *major_stat, uint32_t *minor_stat ); /* Routine mach_gss_accept_sec_context */ #ifdef mig_external mig_external #else extern #endif /* mig_external */ kern_return_t mach_gss_accept_sec_context ( mach_port_t server, gssd_byte_buffer intoken, mach_msg_type_number_t intokenCnt, gssd_string svc_namestr, uint32_t gssd_flags, gssd_ctx *context, gssd_cred *cred_handle, uint32_t *flags, uint32_t *uid, gssd_gid_list gids, mach_msg_type_number_t *gidsCnt, gssd_byte_buffer *key, mach_msg_type_number_t *keyCnt, gssd_byte_buffer *outtoken, mach_msg_type_number_t *outtokenCnt, uint32_t *major_stat, uint32_t *minor_stat ); /* SimpleRoutine mach_gss_log_error */ #ifdef mig_external mig_external #else extern #endif /* mig_external */ kern_return_t mach_gss_log_error ( mach_port_t server, gssd_string mnt, uint32_t uid, gssd_string source, uint32_t major_stat, uint32_t minor_stat ); /* Routine mach_gss_init_sec_context_v2 */ #ifdef mig_external mig_external #else extern #endif /* mig_external */ kern_return_t mach_gss_init_sec_context_v2 ( mach_port_t server, gssd_mechtype mech, gssd_byte_buffer intoken, mach_msg_type_number_t intokenCnt, uint32_t uid, gssd_nametype clnt_nt, gssd_byte_buffer clnt_princ, mach_msg_type_number_t clnt_princCnt, gssd_nametype svc_nt, gssd_byte_buffer svc_princ, mach_msg_type_number_t svc_princCnt, uint32_t flags, uint32_t *gssd_flags, gssd_ctx *context, gssd_cred *cred_handle, uint32_t *ret_flags, gssd_byte_buffer *key, mach_msg_type_number_t *keyCnt, gssd_byte_buffer *outtoken, mach_msg_type_number_t *outtokenCnt, gssd_dstring displayname, uint32_t *major_stat, uint32_t *minor_stat ); /* Routine mach_gss_accept_sec_context_v2 */ #ifdef mig_external mig_external #else extern #endif /* mig_external */ kern_return_t mach_gss_accept_sec_context_v2 ( mach_port_t server, gssd_byte_buffer intoken, mach_msg_type_number_t intokenCnt, gssd_nametype svc_nt, gssd_byte_buffer svc_princ, mach_msg_type_number_t svc_princCnt, uint32_t *gssd_flags, gssd_ctx *context, gssd_cred *cred_handle, uint32_t *flags, uint32_t *uid, gssd_gid_list gids, mach_msg_type_number_t *gidsCnt, gssd_byte_buffer *key, mach_msg_type_number_t *keyCnt, gssd_byte_buffer *outtoken, mach_msg_type_number_t *outtokenCnt, uint32_t *major_stat, uint32_t *minor_stat ); /* Routine mach_gss_init_sec_context_v3 */ #ifdef mig_external mig_external #else extern #endif /* mig_external */ kern_return_t mach_gss_init_sec_context_v3 ( mach_port_t server, gssd_mechtype mech, gssd_byte_buffer intoken, mach_msg_type_number_t intokenCnt, uint32_t uid, gssd_nametype clnt_nt, gssd_byte_buffer clnt_princ, mach_msg_type_number_t clnt_princCnt, gssd_nametype svc_nt, gssd_byte_buffer svc_princ, mach_msg_type_number_t svc_princCnt, uint32_t flags, gssd_etype_list etypes, mach_msg_type_number_t etypesCnt, uint32_t *gssd_flags, gssd_ctx *context, gssd_cred *cred_handle, uint32_t *ret_flags, gssd_byte_buffer *key, mach_msg_type_number_t *keyCnt, gssd_byte_buffer *outtoken, mach_msg_type_number_t *outtokenCnt, gssd_dstring displayname, uint32_t *major_stat, uint32_t *minor_stat ); /* Routine mach_gss_hold_cred */ #ifdef mig_external mig_external #else extern #endif /* mig_external */ kern_return_t mach_gss_hold_cred ( mach_port_t server, gssd_mechtype mech, gssd_nametype nt, gssd_byte_buffer princ, mach_msg_type_number_t princCnt, uint32_t *major_stat, uint32_t *minor_stat ); /* Routine mach_gss_unhold_cred */ #ifdef mig_external mig_external #else extern #endif /* mig_external */ kern_return_t mach_gss_unhold_cred ( mach_port_t server, gssd_mechtype mech, gssd_nametype nt, gssd_byte_buffer princ, mach_msg_type_number_t princCnt, uint32_t *major_stat, uint32_t *minor_stat ); /* Routine mach_gss_lookup */ #ifdef mig_external mig_external #else extern #endif /* mig_external */ kern_return_t mach_gss_lookup ( mach_port_t server, uint32_t uid, int32_t asid, mach_port_t *gssd_session_port ); __END_DECLS /********************** Caution **************************/ /* The following data types should be used to calculate */ /* maximum message sizes only. The actual message may be */ /* smaller, and the position of the arguments within the */ /* message layout may vary from what is presented here. */ /* For example, if any of the arguments are variable- */ /* sized, and less than the maximum is sent, the data */ /* will be packed tight in the actual message to reduce */ /* the presence of holes. */ /********************** Caution **************************/ /* typedefs for all requests */ #ifndef __Request__gssd_mach_subsystem__defined #define __Request__gssd_mach_subsystem__defined #ifdef __MigPackStructs #pragma pack(push, 4) #endif typedef struct { mach_msg_header_t Head; /* start of the kernel processed data */ mach_msg_body_t msgh_body; mach_msg_ool_descriptor_t intoken; /* end of the kernel processed data */ NDR_record_t NDR; gssd_mechtype mech; mach_msg_type_number_t intokenCnt; uint32_t uid; mach_msg_type_number_t princ_namestrOffset; /* MiG doesn't use it */ mach_msg_type_number_t princ_namestrCnt; char princ_namestr[1024]; mach_msg_type_number_t svc_namestrOffset; /* MiG doesn't use it */ mach_msg_type_number_t svc_namestrCnt; char svc_namestr[1024]; uint32_t flags; uint32_t gssd_flags; gssd_ctx context; gssd_cred cred_handle; } __Request__mach_gss_init_sec_context_t __attribute__((unused)); #ifdef __MigPackStructs #pragma pack(pop) #endif #ifdef __MigPackStructs #pragma pack(push, 4) #endif typedef struct { mach_msg_header_t Head; /* start of the kernel processed data */ mach_msg_body_t msgh_body; mach_msg_ool_descriptor_t intoken; /* end of the kernel processed data */ NDR_record_t NDR; mach_msg_type_number_t intokenCnt; mach_msg_type_number_t svc_namestrOffset; /* MiG doesn't use it */ mach_msg_type_number_t svc_namestrCnt; char svc_namestr[1024]; uint32_t gssd_flags; gssd_ctx context; gssd_cred cred_handle; } __Request__mach_gss_accept_sec_context_t __attribute__((unused)); #ifdef __MigPackStructs #pragma pack(pop) #endif #ifdef __MigPackStructs #pragma pack(push, 4) #endif typedef struct { mach_msg_header_t Head; NDR_record_t NDR; mach_msg_type_number_t mntOffset; /* MiG doesn't use it */ mach_msg_type_number_t mntCnt; char mnt[1024]; uint32_t uid; mach_msg_type_number_t sourceOffset; /* MiG doesn't use it */ mach_msg_type_number_t sourceCnt; char source[1024]; uint32_t major_stat; uint32_t minor_stat; } __Request__mach_gss_log_error_t __attribute__((unused)); #ifdef __MigPackStructs #pragma pack(pop) #endif #ifdef __MigPackStructs #pragma pack(push, 4) #endif typedef struct { mach_msg_header_t Head; /* start of the kernel processed data */ mach_msg_body_t msgh_body; mach_msg_ool_descriptor_t intoken; mach_msg_ool_descriptor_t clnt_princ; mach_msg_ool_descriptor_t svc_princ; /* end of the kernel processed data */ NDR_record_t NDR; gssd_mechtype mech; mach_msg_type_number_t intokenCnt; uint32_t uid; gssd_nametype clnt_nt; mach_msg_type_number_t clnt_princCnt; gssd_nametype svc_nt; mach_msg_type_number_t svc_princCnt; uint32_t flags; uint32_t gssd_flags; gssd_ctx context; gssd_cred cred_handle; } __Request__mach_gss_init_sec_context_v2_t __attribute__((unused)); #ifdef __MigPackStructs #pragma pack(pop) #endif #ifdef __MigPackStructs #pragma pack(push, 4) #endif typedef struct { mach_msg_header_t Head; /* start of the kernel processed data */ mach_msg_body_t msgh_body; mach_msg_ool_descriptor_t intoken; mach_msg_ool_descriptor_t svc_princ; /* end of the kernel processed data */ NDR_record_t NDR; mach_msg_type_number_t intokenCnt; gssd_nametype svc_nt; mach_msg_type_number_t svc_princCnt; uint32_t gssd_flags; gssd_ctx context; gssd_cred cred_handle; } __Request__mach_gss_accept_sec_context_v2_t __attribute__((unused)); #ifdef __MigPackStructs #pragma pack(pop) #endif #ifdef __MigPackStructs #pragma pack(push, 4) #endif typedef struct { mach_msg_header_t Head; /* start of the kernel processed data */ mach_msg_body_t msgh_body; mach_msg_ool_descriptor_t intoken; mach_msg_ool_descriptor_t clnt_princ; mach_msg_ool_descriptor_t svc_princ; /* end of the kernel processed data */ NDR_record_t NDR; gssd_mechtype mech; mach_msg_type_number_t intokenCnt; uint32_t uid; gssd_nametype clnt_nt; mach_msg_type_number_t clnt_princCnt; gssd_nametype svc_nt; mach_msg_type_number_t svc_princCnt; uint32_t flags; mach_msg_type_number_t etypesCnt; int32_t etypes[64]; uint32_t gssd_flags; gssd_ctx context; gssd_cred cred_handle; } __Request__mach_gss_init_sec_context_v3_t __attribute__((unused)); #ifdef __MigPackStructs #pragma pack(pop) #endif #ifdef __MigPackStructs #pragma pack(push, 4) #endif typedef struct { mach_msg_header_t Head; /* start of the kernel processed data */ mach_msg_body_t msgh_body; mach_msg_ool_descriptor_t princ; /* end of the kernel processed data */ NDR_record_t NDR; gssd_mechtype mech; gssd_nametype nt; mach_msg_type_number_t princCnt; } __Request__mach_gss_hold_cred_t __attribute__((unused)); #ifdef __MigPackStructs #pragma pack(pop) #endif #ifdef __MigPackStructs #pragma pack(push, 4) #endif typedef struct { mach_msg_header_t Head; /* start of the kernel processed data */ mach_msg_body_t msgh_body; mach_msg_ool_descriptor_t princ; /* end of the kernel processed data */ NDR_record_t NDR; gssd_mechtype mech; gssd_nametype nt; mach_msg_type_number_t princCnt; } __Request__mach_gss_unhold_cred_t __attribute__((unused)); #ifdef __MigPackStructs #pragma pack(pop) #endif #ifdef __MigPackStructs #pragma pack(push, 4) #endif typedef struct { mach_msg_header_t Head; NDR_record_t NDR; uint32_t uid; int32_t asid; } __Request__mach_gss_lookup_t __attribute__((unused)); #ifdef __MigPackStructs #pragma pack(pop) #endif #endif /* !__Request__gssd_mach_subsystem__defined */ /* union of all requests */ #ifndef __RequestUnion__gssd_mach_subsystem__defined #define __RequestUnion__gssd_mach_subsystem__defined union __RequestUnion__gssd_mach_subsystem { __Request__mach_gss_init_sec_context_t Request_mach_gss_init_sec_context; __Request__mach_gss_accept_sec_context_t Request_mach_gss_accept_sec_context; __Request__mach_gss_log_error_t Request_mach_gss_log_error; __Request__mach_gss_init_sec_context_v2_t Request_mach_gss_init_sec_context_v2; __Request__mach_gss_accept_sec_context_v2_t Request_mach_gss_accept_sec_context_v2; __Request__mach_gss_init_sec_context_v3_t Request_mach_gss_init_sec_context_v3; __Request__mach_gss_hold_cred_t Request_mach_gss_hold_cred; __Request__mach_gss_unhold_cred_t Request_mach_gss_unhold_cred; __Request__mach_gss_lookup_t Request_mach_gss_lookup; }; #endif /* !__RequestUnion__gssd_mach_subsystem__defined */ /* typedefs for all replies */ #ifndef __Reply__gssd_mach_subsystem__defined #define __Reply__gssd_mach_subsystem__defined #ifdef __MigPackStructs #pragma pack(push, 4) #endif typedef struct { mach_msg_header_t Head; /* start of the kernel processed data */ mach_msg_body_t msgh_body; mach_msg_ool_descriptor_t key; mach_msg_ool_descriptor_t outtoken; /* end of the kernel processed data */ NDR_record_t NDR; gssd_ctx context; gssd_cred cred_handle; uint32_t ret_flags; mach_msg_type_number_t keyCnt; mach_msg_type_number_t outtokenCnt; uint32_t major_stat; uint32_t minor_stat; } __Reply__mach_gss_init_sec_context_t __attribute__((unused)); #ifdef __MigPackStructs #pragma pack(pop) #endif #ifdef __MigPackStructs #pragma pack(push, 4) #endif typedef struct { mach_msg_header_t Head; /* start of the kernel processed data */ mach_msg_body_t msgh_body; mach_msg_ool_descriptor_t key; mach_msg_ool_descriptor_t outtoken; /* end of the kernel processed data */ NDR_record_t NDR; gssd_ctx context; gssd_cred cred_handle; uint32_t flags; uint32_t uid; mach_msg_type_number_t gidsCnt; uint32_t gids[16]; mach_msg_type_number_t keyCnt; mach_msg_type_number_t outtokenCnt; uint32_t major_stat; uint32_t minor_stat; } __Reply__mach_gss_accept_sec_context_t __attribute__((unused)); #ifdef __MigPackStructs #pragma pack(pop) #endif #ifdef __MigPackStructs #pragma pack(push, 4) #endif typedef struct { mach_msg_header_t Head; NDR_record_t NDR; kern_return_t RetCode; } __Reply__mach_gss_log_error_t __attribute__((unused)); #ifdef __MigPackStructs #pragma pack(pop) #endif #ifdef __MigPackStructs #pragma pack(push, 4) #endif typedef struct { mach_msg_header_t Head; /* start of the kernel processed data */ mach_msg_body_t msgh_body; mach_msg_ool_descriptor_t key; mach_msg_ool_descriptor_t outtoken; /* end of the kernel processed data */ NDR_record_t NDR; uint32_t gssd_flags; gssd_ctx context; gssd_cred cred_handle; uint32_t ret_flags; mach_msg_type_number_t keyCnt; mach_msg_type_number_t outtokenCnt; mach_msg_type_number_t displaynameOffset; /* MiG doesn't use it */ mach_msg_type_number_t displaynameCnt; char displayname[128]; uint32_t major_stat; uint32_t minor_stat; } __Reply__mach_gss_init_sec_context_v2_t __attribute__((unused)); #ifdef __MigPackStructs #pragma pack(pop) #endif #ifdef __MigPackStructs #pragma pack(push, 4) #endif typedef struct { mach_msg_header_t Head; /* start of the kernel processed data */ mach_msg_body_t msgh_body; mach_msg_ool_descriptor_t key; mach_msg_ool_descriptor_t outtoken; /* end of the kernel processed data */ NDR_record_t NDR; uint32_t gssd_flags; gssd_ctx context; gssd_cred cred_handle; uint32_t flags; uint32_t uid; mach_msg_type_number_t gidsCnt; uint32_t gids[16]; mach_msg_type_number_t keyCnt; mach_msg_type_number_t outtokenCnt; uint32_t major_stat; uint32_t minor_stat; } __Reply__mach_gss_accept_sec_context_v2_t __attribute__((unused)); #ifdef __MigPackStructs #pragma pack(pop) #endif #ifdef __MigPackStructs #pragma pack(push, 4) #endif typedef struct { mach_msg_header_t Head; /* start of the kernel processed data */ mach_msg_body_t msgh_body; mach_msg_ool_descriptor_t key; mach_msg_ool_descriptor_t outtoken; /* end of the kernel processed data */ NDR_record_t NDR; uint32_t gssd_flags; gssd_ctx context; gssd_cred cred_handle; uint32_t ret_flags; mach_msg_type_number_t keyCnt; mach_msg_type_number_t outtokenCnt; mach_msg_type_number_t displaynameOffset; /* MiG doesn't use it */ mach_msg_type_number_t displaynameCnt; char displayname[128]; uint32_t major_stat; uint32_t minor_stat; } __Reply__mach_gss_init_sec_context_v3_t __attribute__((unused)); #ifdef __MigPackStructs #pragma pack(pop) #endif #ifdef __MigPackStructs #pragma pack(push, 4) #endif typedef struct { mach_msg_header_t Head; NDR_record_t NDR; kern_return_t RetCode; uint32_t major_stat; uint32_t minor_stat; } __Reply__mach_gss_hold_cred_t __attribute__((unused)); #ifdef __MigPackStructs #pragma pack(pop) #endif #ifdef __MigPackStructs #pragma pack(push, 4) #endif typedef struct { mach_msg_header_t Head; NDR_record_t NDR; kern_return_t RetCode; uint32_t major_stat; uint32_t minor_stat; } __Reply__mach_gss_unhold_cred_t __attribute__((unused)); #ifdef __MigPackStructs #pragma pack(pop) #endif #ifdef __MigPackStructs #pragma pack(push, 4) #endif typedef struct { mach_msg_header_t Head; /* start of the kernel processed data */ mach_msg_body_t msgh_body; mach_msg_port_descriptor_t gssd_session_port; /* end of the kernel processed data */ } __Reply__mach_gss_lookup_t __attribute__((unused)); #ifdef __MigPackStructs #pragma pack(pop) #endif #endif /* !__Reply__gssd_mach_subsystem__defined */ /* union of all replies */ #ifndef __ReplyUnion__gssd_mach_subsystem__defined #define __ReplyUnion__gssd_mach_subsystem__defined union __ReplyUnion__gssd_mach_subsystem { __Reply__mach_gss_init_sec_context_t Reply_mach_gss_init_sec_context; __Reply__mach_gss_accept_sec_context_t Reply_mach_gss_accept_sec_context; __Reply__mach_gss_log_error_t Reply_mach_gss_log_error; __Reply__mach_gss_init_sec_context_v2_t Reply_mach_gss_init_sec_context_v2; __Reply__mach_gss_accept_sec_context_v2_t Reply_mach_gss_accept_sec_context_v2; __Reply__mach_gss_init_sec_context_v3_t Reply_mach_gss_init_sec_context_v3; __Reply__mach_gss_hold_cred_t Reply_mach_gss_hold_cred; __Reply__mach_gss_unhold_cred_t Reply_mach_gss_unhold_cred; __Reply__mach_gss_lookup_t Reply_mach_gss_lookup; }; #endif /* !__RequestUnion__gssd_mach_subsystem__defined */ #ifndef subsystem_to_name_map_gssd_mach #define subsystem_to_name_map_gssd_mach \ { "mach_gss_init_sec_context", 999 },\ { "mach_gss_accept_sec_context", 1000 },\ { "mach_gss_log_error", 1001 },\ { "mach_gss_init_sec_context_v2", 1002 },\ { "mach_gss_accept_sec_context_v2", 1003 },\ { "mach_gss_init_sec_context_v3", 1004 },\ { "mach_gss_hold_cred", 1005 },\ { "mach_gss_unhold_cred", 1006 },\ { "mach_gss_lookup", 1007 } #endif #ifdef __AfterMigUserHeader __AfterMigUserHeader #endif /* __AfterMigUserHeader */ #endif /* _gssd_mach_user_ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/atm/atm_types.h
/* * Copyright (c) 2012-2013 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 _ATM_ATM_TYPES_H_ #define _ATM_ATM_TYPES_H_ #include <stdint.h> #include <mach/mach_types.h> /* Everything here is Deprecated. will be removed soon */ #define MACH_VOUCHER_ATTR_ATM_NULL ((mach_voucher_attr_recipe_command_t)501) #define MACH_VOUCHER_ATTR_ATM_CREATE ((mach_voucher_attr_recipe_command_t)510) #define MACH_VOUCHER_ATTR_ATM_REGISTER ((mach_voucher_attr_recipe_command_t)511) typedef uint32_t atm_action_t; #define ATM_ACTION_DISCARD 0x1 #define ATM_ACTION_COLLECT 0x2 #define ATM_ACTION_LOGFAIL 0x3 #define ATM_FIND_MIN_SUB_AID 0x4 #define ATM_ACTION_UNREGISTER 0x5 #define ATM_ACTION_REGISTER 0x6 #define ATM_ACTION_GETSUBAID 0x7 typedef uint64_t atm_guard_t; typedef uint64_t aid_t; typedef uint64_t subaid_t; typedef uint64_t mailbox_offset_t; #define SUB_AID_MAX (UINT64_MAX) typedef uint64_t atm_aid_t; typedef uint32_t atm_subaid32_t; typedef uint64_t mach_atm_subaid_t; /* Used for mach based apis. */ typedef uint64_t atm_mailbox_offset_t; typedef mach_port_t atm_memory_descriptor_t; typedef atm_memory_descriptor_t *atm_memory_descriptor_array_t; typedef uint64_t *atm_memory_size_array_t; #define ATM_SUBAID32_MAX (UINT32_MAX) #define ATM_TRACE_DISABLE (0x0100) /* OS_TRACE_MODE_DISABLE - Do not initialize the new logging*/ #define ATM_TRACE_OFF (0x0400) /* OS_TRACE_MODE_OFF - Don't drop log messages to new log buffers */ #define ATM_ENABLE_LEGACY_LOGGING (0x20000000) /* OS_TRACE_SYSTEMMODE_LEGACY_LOGGING - Enable legacy logging */ #endif /* _ATM_ATM_TYPES_H_ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kdp/kdp_callout.h
/* * Copyright (c) 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@ */ #include <sys/cdefs.h> typedef enum { KDP_EVENT_ENTER, KDP_EVENT_EXIT, KDP_EVENT_PANICLOG } kdp_event_t; __BEGIN_DECLS typedef void (*kdp_callout_fn_t)(void *arg, kdp_event_t event); /* * Register fn(arg, event) to be called at kdp entry/exit. * The callouts are made in a single-threaded environment, interrupts are * disabled and processors other than the callout processor quiesced. * N.B. callouts are strictly limited in what they can do: they must execute * with interrupts disabled and they can't call back into the kernel for any * non-trivial service. */ extern void kdp_register_callout(kdp_callout_fn_t fn, void *arg); __END_DECLS
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kdp/kdp_en_debugger.h
/* * 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@ */ #include <sys/cdefs.h> /* * Ethernet debugger header file */ __BEGIN_DECLS typedef void (*kdp_send_t)(void * pkt, unsigned int pkt_len); typedef void (*kdp_receive_t)(void * pkt, unsigned int * pkt_len, unsigned int timeout); void kdp_register_send_receive(kdp_send_t send, kdp_receive_t receive); void kdp_unregister_send_receive(kdp_send_t send, kdp_receive_t receive); __END_DECLS
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/console/serial_protos.h
/* * Copyright (c) 2005-2020 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@ */ /* * @APPLE_FREE_COPYRIGHT@ */ #ifndef _CONSOLE_SERIAL_PROTOS_H_ #define _CONSOLE_SERIAL_PROTOS_H_ #ifdef __cplusplus extern "C" { #endif #include <stdbool.h> void serial_keyboard_init(void); void serial_keyboard_start(void) __dead2; void serial_keyboard_poll(void) __dead2; extern uint32_t serialmode; #define SERIALMODE_OUTPUT 0x01 #define SERIALMODE_INPUT 0x02 #define SERIALMODE_SYNCDRAIN 0x04 #define SERIALMODE_BASE_TTY 0x08 /* Load Base/Recovery/FVUnlock TTY */ #define SERIALMODE_NO_IOLOG 0x10 /* prevent IOLogs writing to serial */ extern uint32_t cons_ops_index; extern const uint32_t nconsops; extern bool disable_serial_output; extern bool disable_iolog_serial_output; void console_init(void); int _serial_getc(bool wait); int _vcgetc(bool wait); struct console_ops { void (*putc)(char, bool); int (*getc)(bool); }; boolean_t console_is_serial(void); int switch_to_serial_console(void); int switch_to_video_console(void); void switch_to_old_console(int old_console); #define SERIAL_CONS_OPS 0 #define VC_CONS_OPS 1 #ifdef __cplusplus } #endif #endif /* _CONSOLE_SERIAL_PROTOS_H_ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/console/video_console.h
/* * 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@ */ /* * @APPLE_FREE_COPYRIGHT@ */ #ifndef _VIDEO_CONSOLE_H_ #define _VIDEO_CONSOLE_H_ #include <device/device_types.h> #ifdef __cplusplus extern "C" { #endif #define kVCSysctlProgressOptions "kern.progressoptions" #define kVCSysctlConsoleOptions "kern.consoleoptions" #define kVCSysctlProgressMeterEnable "kern.progressmeterenable" #define kVCSysctlProgressMeter "kern.progressmeter" enum{ kVCDarkReboot = 0x00000001, kVCAcquireImmediate = 0x00000002, kVCUsePosition = 0x00000004, kVCDarkBackground = 0x00000008, kVCLightBackground = 0x00000010, }; enum { kDataRotate0 = 0, kDataRotate90 = 1, kDataRotate180 = 2, kDataRotate270 = 3 }; struct vc_progress_user_options { uint32_t options; // fractional position of middle of spinner 0 (0.0) - 0xFFFFFFFF (1.0) uint32_t x_pos; uint32_t y_pos; uint32_t resv[8]; }; typedef struct vc_progress_user_options vc_progress_user_options; #ifdef __cplusplus } #endif #endif /* _VIDEO_CONSOLE_H_ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/mach_debug/vm_info.h
/* * 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 Carnegie Mellon University * All Rights Reserved. * * Permission to use, copy, modify and distribute this software and its * documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. * * Carnegie Mellon requests users of this software to return to * * Software Distribution Coordinator or [email protected] * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 * * any improvements or extensions that they make and grant Carnegie Mellon * the rights to redistribute these changes. */ /* * File: mach_debug/vm_info.h * Author: Rich Draves * Date: March, 1990 * * Definitions for the VM debugging interface. */ #ifndef _MACH_DEBUG_VM_INFO_H_ #define _MACH_DEBUG_VM_INFO_H_ #include <mach/boolean.h> #include <mach/machine/vm_types.h> #include <mach/vm_inherit.h> #include <mach/vm_prot.h> #include <mach/memory_object_types.h> #pragma pack(4) /* * Remember to update the mig type definitions * in mach_debug_types.defs when adding/removing fields. */ typedef struct mach_vm_info_region { mach_vm_offset_t vir_start; /* start of region */ mach_vm_offset_t vir_end; /* end of region */ mach_vm_offset_t vir_object; /* the mapped object(kernal addr) */ memory_object_offset_t vir_offset; /* offset into object */ boolean_t vir_needs_copy; /* does object need to be copied? */ vm_prot_t vir_protection; /* protection code */ vm_prot_t vir_max_protection; /* maximum protection */ vm_inherit_t vir_inheritance; /* inheritance */ natural_t vir_wired_count; /* number of times wired */ natural_t vir_user_wired_count; /* number of times user has wired */ } mach_vm_info_region_t; typedef struct vm_info_region_64 { natural_t vir_start; /* start of region */ natural_t vir_end; /* end of region */ natural_t vir_object; /* the mapped object */ memory_object_offset_t vir_offset; /* offset into object */ boolean_t vir_needs_copy; /* does object need to be copied? */ vm_prot_t vir_protection; /* protection code */ vm_prot_t vir_max_protection; /* maximum protection */ vm_inherit_t vir_inheritance; /* inheritance */ natural_t vir_wired_count; /* number of times wired */ natural_t vir_user_wired_count; /* number of times user has wired */ } vm_info_region_64_t; typedef struct vm_info_region { natural_t vir_start; /* start of region */ natural_t vir_end; /* end of region */ natural_t vir_object; /* the mapped object */ natural_t vir_offset; /* offset into object */ boolean_t vir_needs_copy; /* does object need to be copied? */ vm_prot_t vir_protection; /* protection code */ vm_prot_t vir_max_protection; /* maximum protection */ vm_inherit_t vir_inheritance; /* inheritance */ natural_t vir_wired_count; /* number of times wired */ natural_t vir_user_wired_count; /* number of times user has wired */ } vm_info_region_t; typedef struct vm_info_object { natural_t vio_object; /* this object */ natural_t vio_size; /* object size (valid if internal - but too small) */ unsigned int vio_ref_count; /* number of references */ unsigned int vio_resident_page_count; /* number of resident pages */ unsigned int vio_absent_count; /* number requested but not filled */ natural_t vio_copy; /* copy object */ natural_t vio_shadow; /* shadow object */ natural_t vio_shadow_offset; /* offset into shadow object */ natural_t vio_paging_offset; /* offset into memory object */ memory_object_copy_strategy_t vio_copy_strategy; /* how to handle data copy */ vm_offset_t vio_last_alloc; /* offset of last allocation */ /* many random attributes */ unsigned int vio_paging_in_progress; boolean_t vio_pager_created; boolean_t vio_pager_initialized; boolean_t vio_pager_ready; boolean_t vio_can_persist; boolean_t vio_internal; boolean_t vio_temporary; boolean_t vio_alive; boolean_t vio_purgable; boolean_t vio_purgable_volatile; } vm_info_object_t; typedef vm_info_object_t *vm_info_object_array_t; #pragma pack() #endif /* _MACH_DEBUG_VM_INFO_H_ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/mach_debug/zone_info.h
/* * 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 [email protected] * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 * * any improvements or extensions that they make and grant Carnegie Mellon * the rights to redistribute these changes. */ /* */ #ifndef _MACH_DEBUG_ZONE_INFO_H_ #define _MACH_DEBUG_ZONE_INFO_H_ #include <mach/boolean.h> #include <mach/machine/vm_types.h> /* * Legacy definitions for host_zone_info(). This interface, and * these definitions have been deprecated in favor of the new * mach_zone_info() inteface and types below. */ #define ZONE_NAME_MAX_LEN 80 typedef struct zone_name { char zn_name[ZONE_NAME_MAX_LEN]; } zone_name_t; typedef zone_name_t *zone_name_array_t; typedef struct zone_info { integer_t zi_count; /* Number of elements used now */ vm_size_t zi_cur_size; /* current memory utilization */ vm_size_t zi_max_size; /* how large can this zone grow */ vm_size_t zi_elem_size; /* size of an element */ vm_size_t zi_alloc_size; /* size used for more memory */ integer_t zi_pageable; /* zone pageable? */ integer_t zi_sleepable; /* sleep if empty? */ integer_t zi_exhaustible; /* merely return if empty? */ integer_t zi_collectable; /* garbage collect elements? */ } zone_info_t; typedef zone_info_t *zone_info_array_t; /* * Remember to update the mig type definitions * in mach_debug_types.defs when adding/removing fields. */ #define MACH_ZONE_NAME_MAX_LEN 80 typedef struct mach_zone_name { char mzn_name[ZONE_NAME_MAX_LEN]; } mach_zone_name_t; typedef mach_zone_name_t *mach_zone_name_array_t; typedef struct mach_zone_info_data { uint64_t mzi_count; /* count of elements in use */ uint64_t mzi_cur_size; /* current memory utilization */ uint64_t mzi_max_size; /* how large can this zone grow */ uint64_t mzi_elem_size; /* size of an element */ uint64_t mzi_alloc_size; /* size used for more memory */ uint64_t mzi_sum_size; /* sum of all allocs (life of zone) */ uint64_t mzi_exhaustible; /* merely return if empty? */ uint64_t mzi_collectable; /* garbage collect elements? and how much? */ } mach_zone_info_t; typedef mach_zone_info_t *mach_zone_info_array_t; /* * The lowest bit of mzi_collectable indicates whether or not the zone * is collectable by zone_gc(). The higher bits contain the size in bytes * that can be collected. */ #define GET_MZI_COLLECTABLE_BYTES(val) ((val) >> 1) #define GET_MZI_COLLECTABLE_FLAG(val) ((val) & 1) #define SET_MZI_COLLECTABLE_BYTES(val, size) \ (val) = ((val) & 1) | ((size) << 1) #define SET_MZI_COLLECTABLE_FLAG(val, flag) \ (val) = (flag) ? ((val) | 1) : (val) typedef struct task_zone_info_data { uint64_t tzi_count; /* count of elements in use */ uint64_t tzi_cur_size; /* current memory utilization */ uint64_t tzi_max_size; /* how large can this zone grow */ uint64_t tzi_elem_size; /* size of an element */ uint64_t tzi_alloc_size; /* size used for more memory */ uint64_t tzi_sum_size; /* sum of all allocs (life of zone) */ uint64_t tzi_exhaustible; /* merely return if empty? */ uint64_t tzi_collectable; /* garbage collect elements? */ uint64_t tzi_caller_acct; /* charged to caller (or kernel) */ uint64_t tzi_task_alloc; /* sum of all allocs by this task */ uint64_t tzi_task_free; /* sum of all frees by this task */ } task_zone_info_t; typedef task_zone_info_t *task_zone_info_array_t; #define MACH_MEMORY_INFO_NAME_MAX_LEN 80 typedef struct mach_memory_info { uint64_t flags; uint64_t site; uint64_t size; uint64_t free; uint64_t largest; uint64_t collectable_bytes; uint64_t mapped; uint64_t peak; uint16_t tag; uint16_t zone; uint16_t _resvA[2]; uint64_t _resv[3]; char name[MACH_MEMORY_INFO_NAME_MAX_LEN]; } mach_memory_info_t; typedef mach_memory_info_t *mach_memory_info_array_t; /* * MAX_ZTRACE_DEPTH configures how deep of a stack trace is taken on each zalloc in the zone of interest. 15 * levels is usually enough to get past all the layers of code in kalloc and IOKit and see who the actual * caller is up above these lower levels. * * This is used both for the zone leak detector and the zone corruption log. Make sure this isn't greater than * BTLOG_MAX_DEPTH defined in btlog.h. Also make sure to update the definition of zone_btrecord_t in * mach_debug_types.defs if this changes. */ #define MAX_ZTRACE_DEPTH 15 /* * Opcodes for the btlog operation field: */ #define ZOP_ALLOC 1 #define ZOP_FREE 0 /* * Structure used to copy out btlog records to userspace, via the MIG call * mach_zone_get_btlog_records(). */ typedef struct zone_btrecord { uint32_t ref_count; /* no. of active references on the record */ uint32_t operation_type; /* operation type (alloc/free) */ uint64_t bt[MAX_ZTRACE_DEPTH]; /* backtrace */ } zone_btrecord_t; typedef zone_btrecord_t *zone_btrecord_array_t; #endif /* _MACH_DEBUG_ZONE_INFO_H_ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/mach_debug/mach_debug.h
/* * 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) Apple Computer 1998 * ALL Rights Reserved */ /* * This file represents the interfaces that used to come * from creating the user headers from the mach_debug.defs file. * Because mach_debug.defs was decomposed, this file now just * wraps up all the new interface headers generated from * each of the new .defs resulting from that decomposition. */ #ifndef _MACH_DEBUG_MACH_DEBUG_H_ #define _MACH_DEBUG_MACH_DEBUG_H_ #include <mach_debug/mach_debug_types.h> #include <mach/mach_host.h> #include <mach/mach_port.h> #include <mach/mach_interface.h> #endif /* _MACH_DEBUG_MACH_DEBUG_H_ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/mach_debug/mach_debug_types.h
/* * 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 [email protected] * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 * * any improvements or extensions that they make and grant Carnegie Mellon * the rights to redistribute these changes. */ /* */ /* * Mach kernel debugging interface type declarations */ #ifndef _MACH_DEBUG_MACH_DEBUG_TYPES_H_ #define _MACH_DEBUG_MACH_DEBUG_TYPES_H_ #include <mach_debug/ipc_info.h> #include <mach_debug/vm_info.h> #include <mach_debug/zone_info.h> #include <mach_debug/page_info.h> #include <mach_debug/hash_info.h> #include <mach_debug/lockgroup_info.h> #define MACH_CORE_FILEHEADER_SIGNATURE 0x0063614d20646152ULL #define MACH_CORE_FILEHEADER_V2_SIGNATURE 0x63614d2073736f42ULL #define MACH_CORE_FILEHEADER_MAXFILES 16 #define MACH_CORE_FILEHEADER_NAMELEN 16 /* The following are defined for mach_core_fileheader_v2 */ #define MACH_CORE_FILEHEADER_V2_FLAG_LOG_ENCRYPTED_AEA (1ULL << 0) /* The log is encrypted using AEA */ #define MACH_CORE_FILEHEADER_V2_FLAG_EXISTING_COREFILE_KEY_FORMAT_NIST_P256 (1ULL << 8) /* The public key is an NIST-P256 ECC key */ #define MACH_CORE_FILEHEADER_V2_FLAG_NEXT_COREFILE_KEY_FORMAT_NIST_P256 (1ULL << 16) /* The next public key is an NIST-P256 ECC key */ #define MACH_CORE_FILEHEADER_V2_FLAGS_EXISTING_COREFILE_KEY_FORMAT_MASK (0x1ULL << 8) /* A bit-mask for all supported key formats */ #define MACH_CORE_FILEHEADER_V2_FLAGS_NEXT_COREFILE_KEY_FORMAT_MASK (0x1ULL << 16) /* A bit-mask for all supported next key formats */ #define MACH_CORE_FILEHEADER_V2_FLAGS_NEXT_KEY_FORMAT_TO_KEY_FORMAT(x) (((x) >> 8) & MACH_CORE_FILEHEADER_V2_FLAGS_EXISTING_COREFILE_KEY_FORMAT_MASK) /* The following are defined for mach_core_details_v2 */ #define MACH_CORE_DETAILS_V2_FLAG_ENCRYPTED_AEA (1ULL << 0) /* This core is encrypted using AEA */ #define MACH_CORE_DETAILS_V2_FLAG_COMPRESSED_ZLIB (1ULL << 8) /* This core is compressed using ZLib */ typedef char symtab_name_t[32]; /* *********************** * * Mach corefile layout * *********************** * * uint64_t signature * uint64_t log_offset >---+ * uint64_t log_length | * mach_core_details files[MACH_CORE_FILEHEADER_MAXFILES] | * |--> uint64_t gzip_offset >---+ | * | uint64_t gzip_length | | * | char core_name[] | | * |--> uint64_t gzip_offset >---+ | | * | uint64_t gzip_length | | | * | char core_name[] | | | * |--> [...] | | | * [log data. Plain-text] | | <---+ * [core #1 data. Zlib compressed] | <---+ * [core #2 data. Zlib compressed] <---+ * [core #x data...] */ struct mach_core_details { uint64_t gzip_offset; uint64_t gzip_length; char core_name[MACH_CORE_FILEHEADER_NAMELEN]; }; struct mach_core_fileheader { uint64_t signature; /* MACH_CORE_FILEHEADER_SIGNATURE */ uint64_t log_offset; uint64_t log_length; uint64_t num_files; struct mach_core_details files[MACH_CORE_FILEHEADER_MAXFILES]; }; /* * Mach corefile V2 headers are denoted with MACH_CORE_FILEHEADER_V2_SIGNATURE. * Note that the V2 headers contain a version field that further indicates the version of the * header's contents. For example, if a V2 header's 'version' field indicates version 5, then * the header follows the format of the 'mach_core_fileheader_v5' structure. * * Further note that 'mach_core_details_' structures are not bound to the same versioning scheme * as the header itself. This means that it's perfectly acceptable for a 'mach_core_fileheader_v5' header * to make use of 'mach_core_details_v2' * ************************** * * Mach corefile layout V2 (using a version 2 header struct as an example) * ************************** * * uint64_t signature * uint32_t version * uint64_t flags * uint64_t pub_key_offset >---+ * uint16_t pub_key_length | * uint64_t log_offset >---+ | * uint64_t log_length | | * uint64_t num_files | | * mach_core_details_v2 files[] | | * |--> uint64_t flags | | * | uint64_t offset >---+ | | * | uint64_t length | | | * | char core_name[] | | | * |--> uint64_t flags | | | * | uint64_t offset >---+ | | | * | uint64_t length | | | | * | char core_name[] | | | | * |--> [...] | | | | * [public key data] | | | <---+ * [log data. Plain-text or an AEA container] | | <---+ * [core #1 data. Zlib compressed. Possibly in an AEA container] | <---+ * [core #2 data. Zlib compressed. Possibly in an AEA container] <---+ * [core #x data...] */ struct mach_core_details_v2 { uint64_t flags; /* See the MACH_CORE_DETAILS_V2_FLAG_* definitions */ uint64_t offset; uint64_t length; char core_name[MACH_CORE_FILEHEADER_NAMELEN]; }; struct mach_core_fileheader_base { uint64_t signature; /* MACH_CORE_FILEHEADER_V2_SIGNATURE */ uint32_t version; }; struct mach_core_fileheader_v2 { uint64_t signature; /* MACH_CORE_FILEHEADER_V2_SIGNATURE */ uint32_t version; /* 2 */ uint64_t flags; /* See the MACH_CORE_FILEHEADER_V2_FLAG_* definitions */ uint64_t pub_key_offset; /* Offset of the public key */ uint16_t pub_key_length; /* Length of the public key */ uint64_t log_offset; uint64_t log_length; uint64_t num_files; struct mach_core_details_v2 files[]; }; #define KOBJECT_DESCRIPTION_LENGTH 512 typedef char kobject_description_t[KOBJECT_DESCRIPTION_LENGTH]; #endif /* _MACH_DEBUG_MACH_DEBUG_TYPES_H_ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/mach_debug/lockgroup_info.h
/* * Copyright (c) 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@ */ /* * File: mach/lockgroup_info.h * * Definitions for host_lockgroup_info call. */ #ifndef _MACH_DEBUG_LOCKGROUP_INFO_H_ #define _MACH_DEBUG_LOCKGROUP_INFO_H_ #include <mach/mach_types.h> #define LOCKGROUP_MAX_NAME 64 #define LOCKGROUP_ATTR_STAT 0x01ULL typedef struct lockgroup_info { char lockgroup_name[LOCKGROUP_MAX_NAME]; uint64_t lockgroup_attr; uint64_t lock_spin_cnt; uint64_t lock_spin_util_cnt; uint64_t lock_spin_held_cnt; uint64_t lock_spin_miss_cnt; uint64_t lock_spin_held_max; uint64_t lock_spin_held_cum; uint64_t lock_mtx_cnt; uint64_t lock_mtx_util_cnt; uint64_t lock_mtx_held_cnt; uint64_t lock_mtx_miss_cnt; uint64_t lock_mtx_wait_cnt; uint64_t lock_mtx_held_max; uint64_t lock_mtx_held_cum; uint64_t lock_mtx_wait_max; uint64_t lock_mtx_wait_cum; uint64_t lock_rw_cnt; uint64_t lock_rw_util_cnt; uint64_t lock_rw_held_cnt; uint64_t lock_rw_miss_cnt; uint64_t lock_rw_wait_cnt; uint64_t lock_rw_held_max; uint64_t lock_rw_held_cum; uint64_t lock_rw_wait_max; uint64_t lock_rw_wait_cum; } lockgroup_info_t; typedef lockgroup_info_t *lockgroup_info_array_t; #endif /* _MACH_DEBUG_LOCKGROUP_INFO_H_ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/mach_debug/page_info.h
/* * 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 Carnegie Mellon University * All Rights Reserved. * * Permission to use, copy, modify and distribute this software and its * documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. * * Carnegie Mellon requests users of this software to return to * * Software Distribution Coordinator or [email protected] * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 * * any improvements or extensions that they make and grant Carnegie Mellon * the rights to redistribute these changes. */ /* */ #ifndef MACH_DEBUG_PAGE_INFO_H #define MACH_DEBUG_PAGE_INFO_H #include <mach/machine/vm_types.h> typedef vm_offset_t *page_address_array_t; #endif /* MACH_DEBUG_PAGE_INFO_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/mach_debug/ipc_info.h
/* * 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 Carnegie Mellon University * All Rights Reserved. * * Permission to use, copy, modify and distribute this software and its * documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. * * Carnegie Mellon requests users of this software to return to * * Software Distribution Coordinator or [email protected] * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 * * any improvements or extensions that they make and grant Carnegie Mellon * the rights to redistribute these changes. */ /* */ /* * File: mach_debug/ipc_info.h * Author: Rich Draves * Date: March, 1990 * * Definitions for the IPC debugging interface. */ #ifndef _MACH_DEBUG_IPC_INFO_H_ #define _MACH_DEBUG_IPC_INFO_H_ #include <mach/boolean.h> #include <mach/port.h> #include <mach/machine/vm_types.h> /* * Remember to update the mig type definitions * in mach_debug_types.defs when adding/removing fields. */ typedef struct ipc_info_space { natural_t iis_genno_mask; /* generation number mask */ natural_t iis_table_size; /* size of table */ natural_t iis_table_next; /* next possible size of table */ natural_t iis_tree_size; /* size of tree (UNUSED) */ natural_t iis_tree_small; /* # of small entries in tree (UNUSED) */ natural_t iis_tree_hash; /* # of hashed entries in tree (UNUSED) */ } ipc_info_space_t; typedef struct ipc_info_space_basic { natural_t iisb_genno_mask; /* generation number mask */ natural_t iisb_table_size; /* size of table */ natural_t iisb_table_next; /* next possible size of table */ natural_t iisb_table_inuse; /* number of entries in use */ natural_t iisb_reserved[2]; /* future expansion */ } ipc_info_space_basic_t; typedef struct ipc_info_name { mach_port_name_t iin_name; /* port name, including gen number */ /*boolean_t*/ integer_t iin_collision; /* collision at this entry? */ mach_port_type_t iin_type; /* straight port type */ mach_port_urefs_t iin_urefs; /* user-references */ natural_t iin_object; /* object pointer/identifier */ natural_t iin_next; /* marequest/next in free list */ natural_t iin_hash; /* hash index */ } ipc_info_name_t; typedef ipc_info_name_t *ipc_info_name_array_t; /* UNUSED */ typedef struct ipc_info_tree_name { ipc_info_name_t iitn_name; mach_port_name_t iitn_lchild; /* name of left child */ mach_port_name_t iitn_rchild; /* name of right child */ } ipc_info_tree_name_t; typedef ipc_info_tree_name_t *ipc_info_tree_name_array_t; typedef struct ipc_info_port { natural_t iip_port_object; /* port object identifier */ natural_t iip_receiver_object; /* receiver task identifier (if any) */ } ipc_info_port_t; typedef ipc_info_port_t *exception_handler_info_array_t; #endif /* _MACH_DEBUG_IPC_INFO_H_ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/mach_debug/hash_info.h
/* * 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 Carnegie Mellon University * All Rights Reserved. * * Permission to use, copy, modify and distribute this software and its * documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. * * Carnegie Mellon requests users of this software to return to * * Software Distribution Coordinator or [email protected] * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 * * any improvements or extensions that they make and grant Carnegie Mellon * the rights to redistribute these changes. */ /* */ #ifndef _MACH_DEBUG_HASH_INFO_H_ #define _MACH_DEBUG_HASH_INFO_H_ #include <mach/machine/vm_types.h> /* natural_t */ /* * Remember to update the mig type definitions * in mach_debug_types.defs when adding/removing fields. */ typedef struct hash_info_bucket { natural_t hib_count; /* number of records in bucket */ } hash_info_bucket_t; typedef hash_info_bucket_t *hash_info_bucket_array_t; #endif /* _MACH_DEBUG_HASH_INFO_H_ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/hfs/hfs_encodings.h
/* * Copyright (c) 2000-2015 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@ */ /* * Copyright (c) 1997-2000 Apple Inc. All Rights Reserved */ #ifndef _HFS_ENCODINGS_H_ #define _HFS_ENCODINGS_H_ #if !TARGET_OS_IPHONE #include <sys/appleapiopts.h> #ifdef __APPLE_API_UNSTABLE #define CTL_HFS_NAMES { \ { 0, 0 }, \ { "encodingbias", CTLTYPE_INT }, \ } __BEGIN_DECLS /* * HFS Filename Encoding Converters Interface * * Private Interface for adding hfs filename * encoding converters. These are not needed * for HFS Plus volumes (since they already * have Unicode filenames). * * Used by HFS Encoding Converter Kernel Modules * to register their encoding conversion routines. */ typedef int (* hfs_to_unicode_func_t)(const uint8_t hfs_str[32], uint16_t *uni_str, u_int32_t maxCharLen, u_int32_t *usedCharLen); typedef int (* unicode_to_hfs_func_t)(uint16_t *uni_str, u_int32_t unicodeChars, uint8_t hfs_str[32]); int hfs_relconverter (u_int32_t encoding); int hfs_getconverter(u_int32_t encoding, hfs_to_unicode_func_t *get_unicode, unicode_to_hfs_func_t *get_hfsname); int hfs_addconverter(int kmod_id, u_int32_t encoding, hfs_to_unicode_func_t get_unicode, unicode_to_hfs_func_t get_hfsname); int hfs_remconverter(int kmod_id, u_int32_t encoding); u_int32_t hfs_pickencoding(const u_int16_t *src, int len); u_int32_t hfs_getencodingbias(void); void hfs_setencodingbias(u_int32_t bias); int mac_roman_to_utf8(const uint8_t hfs_str[32], uint32_t maxDstLen, uint32_t *actualDstLen, unsigned char* dstStr); int utf8_to_mac_roman(uint32_t srcLen, const unsigned char* srcStr, uint8_t dstStr[32]); int mac_roman_to_unicode(const uint8_t hfs_str[32], uint16_t *uni_str, u_int32_t maxCharLen, u_int32_t *usedCharLen); int unicode_to_mac_roman(uint16_t *uni_str, u_int32_t unicodeChars, uint8_t hfs_str[32]); __END_DECLS #endif /* __APPLE_API_UNSTABLE */ #endif // !TARGET_OS_IPHONE #endif /* ! _HFS_ENCODINGS_H_ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/hfs/hfs_format.h
/* * Copyright (c) 2000-2015 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 __HFS_FORMAT__ #define __HFS_FORMAT__ #include <sys/types.h> #include <sys/appleapiopts.h> #include "hfs_unistr.h" /* * hfs_format.h * * This file describes the on-disk format for HFS and HFS Plus volumes. * * Note: Starting 10.9, definition of struct HFSUniStr255 exists in hfs_unitstr.h * */ #ifdef __cplusplus extern "C" { #endif /* some on-disk hfs structures have 68K alignment (misaligned) */ /* Signatures used to differentiate between HFS and HFS Plus volumes */ enum { kHFSSigWord = 0x4244, /* 'BD' in ASCII */ kHFSPlusSigWord = 0x482B, /* 'H+' in ASCII */ kHFSXSigWord = 0x4858, /* 'HX' in ASCII */ kHFSPlusVersion = 0x0004, /* 'H+' volumes are version 4 only */ kHFSXVersion = 0x0005, /* 'HX' volumes start with version 5 */ kHFSPlusMountVersion = 0x31302E30, /* '10.0' for Mac OS X */ kHFSJMountVersion = 0x4846534a, /* 'HFSJ' for journaled HFS+ on OS X */ kFSKMountVersion = 0x46534b21 /* 'FSK!' for failed journal replay */ }; #ifdef __APPLE_API_PRIVATE /* * Mac OS X has two special directories on HFS+ volumes for hardlinked files * and hardlinked directories as well as for open-unlinked files. * * These directories and their contents are not exported from the filesystem * under Mac OS X. */ #define HFSPLUSMETADATAFOLDER "\xE2\x90\x80\xE2\x90\x80\xE2\x90\x80\xE2\x90\x80HFS+ Private Data" #define HFSPLUS_DIR_METADATA_FOLDER ".HFS+ Private Directory Data\xd" /* * Files in the "HFS+ Private Data" folder have one of the following prefixes * followed by a decimal number (no leading zeros) for the file ID. * * Note: Earlier version of Mac OS X used a 32 bit random number for the link * ref number instead of the file id. * * e.g. iNode7182000 and temp3296 */ #define HFS_INODE_PREFIX "iNode" #define HFS_DELETE_PREFIX "temp" /* * Files in the ".HFS+ Private Directory Data" folder have the following * prefix followed by a decimal number (no leading zeros) for the file ID. * * e.g. dir_555 */ #define HFS_DIRINODE_PREFIX "dir_" /* * Hardlink inodes save the head of the link chain in * an extended attribute named FIRST_LINK_XATTR_NAME. * The attribute data is the decimal value in ASCII * of the cnid for the first link in the chain. * * This extended attribute is private (i.e. its not * exported in the getxattr/listxattr POSIX APIs). */ #define FIRST_LINK_XATTR_NAME "com.apple.system.hfs.firstlink" #define FIRST_LINK_XATTR_REC_SIZE (sizeof(HFSPlusAttrData) - 2 + 12) /* * The name space ID for generating an HFS volume UUID * * B3E20F39-F292-11D6-97A4-00306543ECAC */ #define HFS_UUID_NAMESPACE_ID "\xB3\xE2\x0F\x39\xF2\x92\x11\xD6\x97\xA4\x00\x30\x65\x43\xEC\xAC" #endif /* __APPLE_API_PRIVATE */ /* * Indirect link files (hard links) have the following type/creator. */ enum { kHardLinkFileType = 0x686C6E6B, /* 'hlnk' */ kHFSPlusCreator = 0x6866732B /* 'hfs+' */ }; /* * File type and creator for symbolic links */ enum { kSymLinkFileType = 0x736C6E6B, /* 'slnk' */ kSymLinkCreator = 0x72686170 /* 'rhap' */ }; enum { kHFSMaxVolumeNameChars = 27, kHFSMaxFileNameChars = 31, kHFSPlusMaxFileNameChars = 255 }; /* Extent overflow file data structures */ /* HFS Extent key */ struct HFSExtentKey { u_int8_t keyLength; /* length of key, excluding this field */ u_int8_t forkType; /* 0 = data fork, FF = resource fork */ u_int32_t fileID; /* file ID */ u_int16_t startBlock; /* first file allocation block number in this extent */ } __attribute__((aligned(2), packed)); typedef struct HFSExtentKey HFSExtentKey; /* HFS Plus Extent key */ struct HFSPlusExtentKey { u_int16_t keyLength; /* length of key, excluding this field */ u_int8_t forkType; /* 0 = data fork, FF = resource fork */ u_int8_t pad; /* make the other fields align on 32-bit boundary */ u_int32_t fileID; /* file ID */ u_int32_t startBlock; /* first file allocation block number in this extent */ } __attribute__((aligned(2), packed)); typedef struct HFSPlusExtentKey HFSPlusExtentKey; /* Number of extent descriptors per extent record */ enum { kHFSExtentDensity = 3, kHFSPlusExtentDensity = 8 }; /* HFS extent descriptor */ struct HFSExtentDescriptor { u_int16_t startBlock; /* first allocation block */ u_int16_t blockCount; /* number of allocation blocks */ } __attribute__((aligned(2), packed)); typedef struct HFSExtentDescriptor HFSExtentDescriptor; /* HFS Plus extent descriptor */ struct HFSPlusExtentDescriptor { u_int32_t startBlock; /* first allocation block */ u_int32_t blockCount; /* number of allocation blocks */ } __attribute__((aligned(2), packed)); typedef struct HFSPlusExtentDescriptor HFSPlusExtentDescriptor; /* HFS extent record */ typedef HFSExtentDescriptor HFSExtentRecord[3]; /* HFS Plus extent record */ typedef HFSPlusExtentDescriptor HFSPlusExtentRecord[8]; /* Finder information */ struct FndrFileInfo { u_int32_t fdType; /* file type */ u_int32_t fdCreator; /* file creator */ u_int16_t fdFlags; /* Finder flags */ struct { int16_t v; /* file's location */ int16_t h; } fdLocation; int16_t opaque; } __attribute__((aligned(2), packed)); typedef struct FndrFileInfo FndrFileInfo; struct FndrDirInfo { struct { /* folder's window rectangle */ int16_t top; int16_t left; int16_t bottom; int16_t right; } frRect; unsigned short frFlags; /* Finder flags */ struct { u_int16_t v; /* folder's location */ u_int16_t h; } frLocation; int16_t opaque; } __attribute__((aligned(2), packed)); typedef struct FndrDirInfo FndrDirInfo; struct FndrOpaqueInfo { int8_t opaque[16]; } __attribute__((aligned(2), packed)); typedef struct FndrOpaqueInfo FndrOpaqueInfo; struct FndrExtendedDirInfo { u_int32_t document_id; u_int32_t date_added; u_int16_t extended_flags; u_int16_t reserved3; u_int32_t write_gen_counter; } __attribute__((aligned(2), packed)); struct FndrExtendedFileInfo { u_int32_t document_id; u_int32_t date_added; u_int16_t extended_flags; u_int16_t reserved2; u_int32_t write_gen_counter; } __attribute__((aligned(2), packed)); /* HFS Plus Fork data info - 80 bytes */ struct HFSPlusForkData { u_int64_t logicalSize; /* fork's logical size in bytes */ u_int32_t clumpSize; /* fork's clump size in bytes */ u_int32_t totalBlocks; /* total blocks used by this fork */ HFSPlusExtentRecord extents; /* initial set of extents */ } __attribute__((aligned(2), packed)); typedef struct HFSPlusForkData HFSPlusForkData; /* Mac OS X has 16 bytes worth of "BSD" info. * * Note: Mac OS 9 implementations and applications * should preserve, but not change, this information. */ struct HFSPlusBSDInfo { u_int32_t ownerID; /* user-id of owner or hard link chain previous link */ u_int32_t groupID; /* group-id of owner or hard link chain next link */ u_int8_t adminFlags; /* super-user changeable flags */ u_int8_t ownerFlags; /* owner changeable flags */ u_int16_t fileMode; /* file type and permission bits */ union { u_int32_t iNodeNum; /* indirect node number (hard links only) */ u_int32_t linkCount; /* links that refer to this indirect node */ u_int32_t rawDevice; /* special file device (FBLK and FCHR only) */ } special; } __attribute__((aligned(2), packed)); typedef struct HFSPlusBSDInfo HFSPlusBSDInfo; /* * Hardlink "links" resolve to an inode * and the actual uid/gid comes from that * inode. * * We repurpose the links's uid/gid fields * for the hardlink link chain. The chain * consists of a doubly linked list of file * ids. */ #define hl_firstLinkID reserved1 /* Valid only if HasLinkChain flag is set (indirect nodes only) */ #define hl_prevLinkID bsdInfo.ownerID /* Valid only if HasLinkChain flag is set */ #define hl_nextLinkID bsdInfo.groupID /* Valid only if HasLinkChain flag is set */ #define hl_linkReference bsdInfo.special.iNodeNum #define hl_linkCount bsdInfo.special.linkCount /* Catalog file data structures */ enum { kHFSRootParentID = 1, /* Parent ID of the root folder */ kHFSRootFolderID = 2, /* Folder ID of the root folder */ kHFSExtentsFileID = 3, /* File ID of the extents file */ kHFSCatalogFileID = 4, /* File ID of the catalog file */ kHFSBadBlockFileID = 5, /* File ID of the bad allocation block file */ kHFSAllocationFileID = 6, /* File ID of the allocation file (HFS Plus only) */ kHFSStartupFileID = 7, /* File ID of the startup file (HFS Plus only) */ kHFSAttributesFileID = 8, /* File ID of the attribute file (HFS Plus only) */ kHFSAttributeDataFileID = 13, /* Used in Mac OS X runtime for extent based attributes */ /* kHFSAttributeDataFileID is never stored on disk. */ kHFSRepairCatalogFileID = 14, /* Used when rebuilding Catalog B-tree */ kHFSBogusExtentFileID = 15, /* Used for exchanging extents in extents file */ kHFSFirstUserCatalogNodeID = 16 }; /* HFS catalog key */ struct HFSCatalogKey { u_int8_t keyLength; /* key length (in bytes) */ u_int8_t reserved; /* reserved (set to zero) */ u_int32_t parentID; /* parent folder ID */ u_int8_t nodeName[kHFSMaxFileNameChars + 1]; /* catalog node name */ } __attribute__((aligned(2), packed)); typedef struct HFSCatalogKey HFSCatalogKey; /* HFS Plus catalog key */ struct HFSPlusCatalogKey { u_int16_t keyLength; /* key length (in bytes) */ u_int32_t parentID; /* parent folder ID */ HFSUniStr255 nodeName; /* catalog node name */ } __attribute__((aligned(2), packed)); typedef struct HFSPlusCatalogKey HFSPlusCatalogKey; /* Catalog record types */ enum { /* HFS Catalog Records */ kHFSFolderRecord = 0x0100, /* Folder record */ kHFSFileRecord = 0x0200, /* File record */ kHFSFolderThreadRecord = 0x0300, /* Folder thread record */ kHFSFileThreadRecord = 0x0400, /* File thread record */ /* HFS Plus Catalog Records */ kHFSPlusFolderRecord = 1, /* Folder record */ kHFSPlusFileRecord = 2, /* File record */ kHFSPlusFolderThreadRecord = 3, /* Folder thread record */ kHFSPlusFileThreadRecord = 4 /* File thread record */ }; /* Catalog file record flags */ enum { kHFSFileLockedBit = 0x0000, /* file is locked and cannot be written to */ kHFSFileLockedMask = 0x0001, kHFSThreadExistsBit = 0x0001, /* a file thread record exists for this file */ kHFSThreadExistsMask = 0x0002, kHFSHasAttributesBit = 0x0002, /* object has extended attributes */ kHFSHasAttributesMask = 0x0004, kHFSHasSecurityBit = 0x0003, /* object has security data (ACLs) */ kHFSHasSecurityMask = 0x0008, kHFSHasFolderCountBit = 0x0004, /* only for HFSX, folder maintains a separate sub-folder count */ kHFSHasFolderCountMask = 0x0010, /* (sum of folder records and directory hard links) */ kHFSHasLinkChainBit = 0x0005, /* has hardlink chain (inode or link) */ kHFSHasLinkChainMask = 0x0020, kHFSHasChildLinkBit = 0x0006, /* folder has a child that's a dir link */ kHFSHasChildLinkMask = 0x0040, kHFSHasDateAddedBit = 0x0007, /* File/Folder has the date-added stored in the finder info. */ kHFSHasDateAddedMask = 0x0080, kHFSFastDevPinnedBit = 0x0008, /* this file has been pinned to the fast-device by the hot-file code on cooperative fusion */ kHFSFastDevPinnedMask = 0x0100, kHFSDoNotFastDevPinBit = 0x0009, /* this file can not be pinned to the fast-device */ kHFSDoNotFastDevPinMask = 0x0200, kHFSFastDevCandidateBit = 0x000a, /* this item is a potential candidate for fast-dev pinning (as are any of its descendents */ kHFSFastDevCandidateMask = 0x0400, kHFSAutoCandidateBit = 0x000b, /* this item was automatically marked as a fast-dev candidate by the kernel */ kHFSAutoCandidateMask = 0x0800 // There are only 4 flag bits remaining: 0x1000, 0x2000, 0x4000, 0x8000 }; /* HFS catalog folder record - 70 bytes */ struct HFSCatalogFolder { int16_t recordType; /* == kHFSFolderRecord */ u_int16_t flags; /* folder flags */ u_int16_t valence; /* folder valence */ u_int32_t folderID; /* folder ID */ u_int32_t createDate; /* date and time of creation */ u_int32_t modifyDate; /* date and time of last modification */ u_int32_t backupDate; /* date and time of last backup */ FndrDirInfo userInfo; /* Finder information */ FndrOpaqueInfo finderInfo; /* additional Finder information */ u_int32_t reserved[4]; /* reserved - initialized as zero */ } __attribute__((aligned(2), packed)); typedef struct HFSCatalogFolder HFSCatalogFolder; /* HFS Plus catalog folder record - 88 bytes */ struct HFSPlusCatalogFolder { int16_t recordType; /* == kHFSPlusFolderRecord */ u_int16_t flags; /* file flags */ u_int32_t valence; /* folder's item count */ u_int32_t folderID; /* folder ID */ u_int32_t createDate; /* date and time of creation */ u_int32_t contentModDate; /* date and time of last content modification */ u_int32_t attributeModDate; /* date and time of last attribute modification */ u_int32_t accessDate; /* date and time of last access (MacOS X only) */ u_int32_t backupDate; /* date and time of last backup */ HFSPlusBSDInfo bsdInfo; /* permissions (for MacOS X) */ FndrDirInfo userInfo; /* Finder information */ FndrOpaqueInfo finderInfo; /* additional Finder information */ u_int32_t textEncoding; /* hint for name conversions */ u_int32_t folderCount; /* number of enclosed folders, active when HasFolderCount is set */ } __attribute__((aligned(2), packed)); typedef struct HFSPlusCatalogFolder HFSPlusCatalogFolder; /* HFS catalog file record - 102 bytes */ struct HFSCatalogFile { int16_t recordType; /* == kHFSFileRecord */ u_int8_t flags; /* file flags */ int8_t fileType; /* file type (unused ?) */ FndrFileInfo userInfo; /* Finder information */ u_int32_t fileID; /* file ID */ u_int16_t dataStartBlock; /* not used - set to zero */ int32_t dataLogicalSize; /* logical EOF of data fork */ int32_t dataPhysicalSize; /* physical EOF of data fork */ u_int16_t rsrcStartBlock; /* not used - set to zero */ int32_t rsrcLogicalSize; /* logical EOF of resource fork */ int32_t rsrcPhysicalSize; /* physical EOF of resource fork */ u_int32_t createDate; /* date and time of creation */ u_int32_t modifyDate; /* date and time of last modification */ u_int32_t backupDate; /* date and time of last backup */ FndrOpaqueInfo finderInfo; /* additional Finder information */ u_int16_t clumpSize; /* file clump size (not used) */ HFSExtentRecord dataExtents; /* first data fork extent record */ HFSExtentRecord rsrcExtents; /* first resource fork extent record */ u_int32_t reserved; /* reserved - initialized as zero */ } __attribute__((aligned(2), packed)); typedef struct HFSCatalogFile HFSCatalogFile; /* HFS Plus catalog file record - 248 bytes */ struct HFSPlusCatalogFile { int16_t recordType; /* == kHFSPlusFileRecord */ u_int16_t flags; /* file flags */ u_int32_t reserved1; /* reserved - initialized as zero */ u_int32_t fileID; /* file ID */ u_int32_t createDate; /* date and time of creation */ u_int32_t contentModDate; /* date and time of last content modification */ u_int32_t attributeModDate; /* date and time of last attribute modification */ u_int32_t accessDate; /* date and time of last access (MacOS X only) */ u_int32_t backupDate; /* date and time of last backup */ HFSPlusBSDInfo bsdInfo; /* permissions (for MacOS X) */ FndrFileInfo userInfo; /* Finder information */ FndrOpaqueInfo finderInfo; /* additional Finder information */ u_int32_t textEncoding; /* hint for name conversions */ u_int32_t reserved2; /* reserved - initialized as zero */ /* Note: these start on double long (64 bit) boundary */ HFSPlusForkData dataFork; /* size and block data for data fork */ HFSPlusForkData resourceFork; /* size and block data for resource fork */ } __attribute__((aligned(2), packed)); typedef struct HFSPlusCatalogFile HFSPlusCatalogFile; /* HFS catalog thread record - 46 bytes */ struct HFSCatalogThread { int16_t recordType; /* == kHFSFolderThreadRecord or kHFSFileThreadRecord */ int32_t reserved[2]; /* reserved - initialized as zero */ u_int32_t parentID; /* parent ID for this catalog node */ u_int8_t nodeName[kHFSMaxFileNameChars + 1]; /* name of this catalog node */ } __attribute__((aligned(2), packed)); typedef struct HFSCatalogThread HFSCatalogThread; /* HFS Plus catalog thread record -- 264 bytes */ struct HFSPlusCatalogThread { int16_t recordType; /* == kHFSPlusFolderThreadRecord or kHFSPlusFileThreadRecord */ int16_t reserved; /* reserved - initialized as zero */ u_int32_t parentID; /* parent ID for this catalog node */ HFSUniStr255 nodeName; /* name of this catalog node (variable length) */ } __attribute__((aligned(2), packed)); typedef struct HFSPlusCatalogThread HFSPlusCatalogThread; #ifdef __APPLE_API_UNSTABLE /* * These are the types of records in the attribute B-tree. The values were * chosen so that they wouldn't conflict with the catalog record types. */ enum { kHFSPlusAttrInlineData = 0x10, /* attributes whose data fits in a b-tree node */ kHFSPlusAttrForkData = 0x20, /* extent based attributes (data lives in extents) */ kHFSPlusAttrExtents = 0x30 /* overflow extents for large attributes */ }; /* * HFSPlusAttrForkData * For larger attributes, whose value is stored in allocation blocks. * If the attribute has more than 8 extents, there will be additional * records (of type HFSPlusAttrExtents) for this attribute. */ struct HFSPlusAttrForkData { u_int32_t recordType; /* == kHFSPlusAttrForkData*/ u_int32_t reserved; HFSPlusForkData theFork; /* size and first extents of value*/ } __attribute__((aligned(2), packed)); typedef struct HFSPlusAttrForkData HFSPlusAttrForkData; /* * HFSPlusAttrExtents * This record contains information about overflow extents for large, * fragmented attributes. */ struct HFSPlusAttrExtents { u_int32_t recordType; /* == kHFSPlusAttrExtents*/ u_int32_t reserved; HFSPlusExtentRecord extents; /* additional extents*/ } __attribute__((aligned(2), packed)); typedef struct HFSPlusAttrExtents HFSPlusAttrExtents; /* * Atrributes B-tree Data Record * * For small attributes, whose entire value is stored * within a single B-tree record. */ struct HFSPlusAttrData { u_int32_t recordType; /* == kHFSPlusAttrInlineData */ u_int32_t reserved[2]; u_int32_t attrSize; /* size of attribute data in bytes */ u_int8_t attrData[2]; /* variable length */ } __attribute__((aligned(2), packed)); typedef struct HFSPlusAttrData HFSPlusAttrData; /* HFSPlusAttrInlineData is obsolete use HFSPlusAttrData instead */ struct HFSPlusAttrInlineData { u_int32_t recordType; u_int32_t reserved; u_int32_t logicalSize; u_int8_t userData[2]; } __attribute__((aligned(2), packed)); typedef struct HFSPlusAttrInlineData HFSPlusAttrInlineData; /* A generic Attribute Record */ union HFSPlusAttrRecord { u_int32_t recordType; HFSPlusAttrInlineData inlineData; /* NOT USED */ HFSPlusAttrData attrData; HFSPlusAttrForkData forkData; HFSPlusAttrExtents overflowExtents; }; typedef union HFSPlusAttrRecord HFSPlusAttrRecord; /* Attribute key */ enum { kHFSMaxAttrNameLen = 127 }; struct HFSPlusAttrKey { u_int16_t keyLength; /* key length (in bytes) */ u_int16_t pad; /* set to zero */ u_int32_t fileID; /* file associated with attribute */ u_int32_t startBlock; /* first allocation block number for extents */ u_int16_t attrNameLen; /* number of unicode characters */ u_int16_t attrName[kHFSMaxAttrNameLen]; /* attribute name (Unicode) */ } __attribute__((aligned(2), packed)); typedef struct HFSPlusAttrKey HFSPlusAttrKey; #define kHFSPlusAttrKeyMaximumLength (sizeof(HFSPlusAttrKey) - sizeof(u_int16_t)) #define kHFSPlusAttrKeyMinimumLength (kHFSPlusAttrKeyMaximumLength - kHFSMaxAttrNameLen*sizeof(u_int16_t)) #endif /* __APPLE_API_UNSTABLE */ /* Key and node lengths */ enum { kHFSPlusExtentKeyMaximumLength = sizeof(HFSPlusExtentKey) - sizeof(u_int16_t), kHFSExtentKeyMaximumLength = sizeof(HFSExtentKey) - sizeof(u_int8_t), kHFSPlusCatalogKeyMaximumLength = sizeof(HFSPlusCatalogKey) - sizeof(u_int16_t), kHFSPlusCatalogKeyMinimumLength = kHFSPlusCatalogKeyMaximumLength - sizeof(HFSUniStr255) + sizeof(u_int16_t), kHFSCatalogKeyMaximumLength = sizeof(HFSCatalogKey) - sizeof(u_int8_t), kHFSCatalogKeyMinimumLength = kHFSCatalogKeyMaximumLength - (kHFSMaxFileNameChars + 1) + sizeof(u_int8_t), kHFSPlusCatalogMinNodeSize = 4096, kHFSPlusExtentMinNodeSize = 512, kHFSPlusAttrMinNodeSize = 4096 }; /* HFS and HFS Plus volume attribute bits */ enum { /* Bits 0-6 are reserved (always cleared by MountVol call) */ kHFSVolumeHardwareLockBit = 7, /* volume is locked by hardware */ kHFSVolumeUnmountedBit = 8, /* volume was successfully unmounted */ kHFSVolumeSparedBlocksBit = 9, /* volume has bad blocks spared */ kHFSVolumeNoCacheRequiredBit = 10, /* don't cache volume blocks (i.e. RAM or ROM disk) */ kHFSBootVolumeInconsistentBit = 11, /* boot volume is inconsistent (System 7.6 and later) */ kHFSCatalogNodeIDsReusedBit = 12, kHFSVolumeJournaledBit = 13, /* this volume has a journal on it */ kHFSVolumeInconsistentBit = 14, /* serious inconsistencies detected at runtime */ kHFSVolumeSoftwareLockBit = 15, /* volume is locked by software */ /* * HFS only has 16 bits of attributes in the MDB, but HFS Plus has 32 bits. * Therefore, bits 16-31 can only be used on HFS Plus. */ kHFSUnusedNodeFixBit = 31, /* Unused nodes in the Catalog B-tree have been zero-filled. See Radar #6947811. */ kHFSContentProtectionBit = 30, /* Volume has per-file content protection */ /*** Keep these in sync with the bits above ! ****/ kHFSVolumeHardwareLockMask = 0x00000080, kHFSVolumeUnmountedMask = 0x00000100, kHFSVolumeSparedBlocksMask = 0x00000200, kHFSVolumeNoCacheRequiredMask = 0x00000400, kHFSBootVolumeInconsistentMask = 0x00000800, kHFSCatalogNodeIDsReusedMask = 0x00001000, kHFSVolumeJournaledMask = 0x00002000, kHFSVolumeInconsistentMask = 0x00004000, kHFSVolumeSoftwareLockMask = 0x00008000, /* Bits 16-31 are allocated from high to low */ kHFSContentProtectionMask = 0x40000000, kHFSUnusedNodeFixMask = 0x80000000, kHFSMDBAttributesMask = 0x8380 }; enum { kHFSUnusedNodesFixDate = 0xc5ef2480 /* March 25, 2009 */ }; /* HFS Master Directory Block - 162 bytes */ /* Stored at sector #2 (3rd sector) and second-to-last sector. */ struct HFSMasterDirectoryBlock { u_int16_t drSigWord; /* == kHFSSigWord */ u_int32_t drCrDate; /* date and time of volume creation */ u_int32_t drLsMod; /* date and time of last modification */ u_int16_t drAtrb; /* volume attributes */ u_int16_t drNmFls; /* number of files in root folder */ u_int16_t drVBMSt; /* first block of volume bitmap */ u_int16_t drAllocPtr; /* start of next allocation search */ u_int16_t drNmAlBlks; /* number of allocation blocks in volume */ u_int32_t drAlBlkSiz; /* size (in bytes) of allocation blocks */ u_int32_t drClpSiz; /* default clump size */ u_int16_t drAlBlSt; /* first allocation block in volume */ u_int32_t drNxtCNID; /* next unused catalog node ID */ u_int16_t drFreeBks; /* number of unused allocation blocks */ u_int8_t drVN[kHFSMaxVolumeNameChars + 1]; /* volume name */ u_int32_t drVolBkUp; /* date and time of last backup */ u_int16_t drVSeqNum; /* volume backup sequence number */ u_int32_t drWrCnt; /* volume write count */ u_int32_t drXTClpSiz; /* clump size for extents overflow file */ u_int32_t drCTClpSiz; /* clump size for catalog file */ u_int16_t drNmRtDirs; /* number of directories in root folder */ u_int32_t drFilCnt; /* number of files in volume */ u_int32_t drDirCnt; /* number of directories in volume */ u_int32_t drFndrInfo[8]; /* information used by the Finder */ u_int16_t drEmbedSigWord; /* embedded volume signature (formerly drVCSize) */ HFSExtentDescriptor drEmbedExtent; /* embedded volume location and size (formerly drVBMCSize and drCtlCSize) */ u_int32_t drXTFlSize; /* size of extents overflow file */ HFSExtentRecord drXTExtRec; /* extent record for extents overflow file */ u_int32_t drCTFlSize; /* size of catalog file */ HFSExtentRecord drCTExtRec; /* extent record for catalog file */ } __attribute__((aligned(2), packed)); typedef struct HFSMasterDirectoryBlock HFSMasterDirectoryBlock; #ifdef __APPLE_API_UNSTABLE #define SET_HFS_TEXT_ENCODING(hint) \ (0x656e6300 | ((hint) & 0xff)) #define GET_HFS_TEXT_ENCODING(hint) \ (((hint) & 0xffffff00) == 0x656e6300 ? (hint) & 0x000000ff : 0xffffffffU) #endif /* __APPLE_API_UNSTABLE */ /* HFS Plus Volume Header - 512 bytes */ /* Stored at sector #2 (3rd sector) and second-to-last sector. */ struct HFSPlusVolumeHeader { u_int16_t signature; /* == kHFSPlusSigWord */ u_int16_t version; /* == kHFSPlusVersion */ u_int32_t attributes; /* volume attributes */ u_int32_t lastMountedVersion; /* implementation version which last mounted volume */ u_int32_t journalInfoBlock; /* block addr of journal info (if volume is journaled, zero otherwise) */ u_int32_t createDate; /* date and time of volume creation */ u_int32_t modifyDate; /* date and time of last modification */ u_int32_t backupDate; /* date and time of last backup */ u_int32_t checkedDate; /* date and time of last disk check */ u_int32_t fileCount; /* number of files in volume */ u_int32_t folderCount; /* number of directories in volume */ u_int32_t blockSize; /* size (in bytes) of allocation blocks */ u_int32_t totalBlocks; /* number of allocation blocks in volume (includes this header and VBM*/ u_int32_t freeBlocks; /* number of unused allocation blocks */ u_int32_t nextAllocation; /* start of next allocation search */ u_int32_t rsrcClumpSize; /* default resource fork clump size */ u_int32_t dataClumpSize; /* default data fork clump size */ u_int32_t nextCatalogID; /* next unused catalog node ID */ u_int32_t writeCount; /* volume write count */ u_int64_t encodingsBitmap; /* which encodings have been use on this volume */ u_int8_t finderInfo[32]; /* information used by the Finder */ HFSPlusForkData allocationFile; /* allocation bitmap file */ HFSPlusForkData extentsFile; /* extents B-tree file */ HFSPlusForkData catalogFile; /* catalog B-tree file */ HFSPlusForkData attributesFile; /* extended attributes B-tree file */ HFSPlusForkData startupFile; /* boot file (secondary loader) */ } __attribute__((aligned(2), packed)); typedef struct HFSPlusVolumeHeader HFSPlusVolumeHeader; /* B-tree structures */ enum BTreeKeyLimits{ kMaxKeyLength = 520 }; union BTreeKey{ u_int8_t length8; u_int16_t length16; u_int8_t rawData [kMaxKeyLength+2]; }; typedef union BTreeKey BTreeKey; /* BTNodeDescriptor -- Every B-tree node starts with these fields. */ struct BTNodeDescriptor { u_int32_t fLink; /* next node at this level*/ u_int32_t bLink; /* previous node at this level*/ int8_t kind; /* kind of node (leaf, index, header, map)*/ u_int8_t height; /* zero for header, map; child is one more than parent*/ u_int16_t numRecords; /* number of records in this node*/ u_int16_t reserved; /* reserved - initialized as zero */ } __attribute__((aligned(2), packed)); typedef struct BTNodeDescriptor BTNodeDescriptor; /* Constants for BTNodeDescriptor kind */ enum { kBTLeafNode = -1, kBTIndexNode = 0, kBTHeaderNode = 1, kBTMapNode = 2 }; /* BTHeaderRec -- The first record of a B-tree header node */ struct BTHeaderRec { u_int16_t treeDepth; /* maximum height (usually leaf nodes) */ u_int32_t rootNode; /* node number of root node */ u_int32_t leafRecords; /* number of leaf records in all leaf nodes */ u_int32_t firstLeafNode; /* node number of first leaf node */ u_int32_t lastLeafNode; /* node number of last leaf node */ u_int16_t nodeSize; /* size of a node, in bytes */ u_int16_t maxKeyLength; /* reserved */ u_int32_t totalNodes; /* total number of nodes in tree */ u_int32_t freeNodes; /* number of unused (free) nodes in tree */ u_int16_t reserved1; /* unused */ u_int32_t clumpSize; /* reserved */ u_int8_t btreeType; /* reserved */ u_int8_t keyCompareType; /* Key string Comparison Type */ u_int32_t attributes; /* persistent attributes about the tree */ u_int32_t reserved3[16]; /* reserved */ } __attribute__((aligned(2), packed)); typedef struct BTHeaderRec BTHeaderRec; /* Constants for BTHeaderRec attributes */ enum { kBTBadCloseMask = 0x00000001, /* reserved */ kBTBigKeysMask = 0x00000002, /* key length field is 16 bits */ kBTVariableIndexKeysMask = 0x00000004 /* keys in index nodes are variable length */ }; /* Catalog Key Name Comparison Type */ enum { kHFSCaseFolding = 0xCF, /* case folding (case-insensitive) */ kHFSBinaryCompare = 0xBC /* binary compare (case-sensitive) */ }; #include <uuid/uuid.h> /* JournalInfoBlock - Structure that describes where our journal lives */ // the original size of the reserved field in the JournalInfoBlock was // 32*sizeof(u_int32_t). To keep the total size of the structure the // same we subtract the size of new fields (currently: ext_jnl_uuid and // machine_uuid). If you add additional fields, place them before the // reserved field and subtract their size in this macro. // #define JIB_RESERVED_SIZE ((32*sizeof(u_int32_t)) - sizeof(uuid_string_t) - 48) struct JournalInfoBlock { u_int32_t flags; u_int32_t device_signature[8]; // signature used to locate our device. u_int64_t offset; // byte offset to the journal on the device u_int64_t size; // size in bytes of the journal uuid_string_t ext_jnl_uuid; char machine_serial_num[48]; char reserved[JIB_RESERVED_SIZE]; } __attribute__((aligned(2), packed)); typedef struct JournalInfoBlock JournalInfoBlock; enum { kJIJournalInFSMask = 0x00000001, kJIJournalOnOtherDeviceMask = 0x00000002, kJIJournalNeedInitMask = 0x00000004 }; // // This the content type uuid for "external journal" GPT // partitions. Each instance of a partition also has a // uuid that uniquely identifies that instance. // #define EXTJNL_CONTENT_TYPE_UUID "4A6F7572-6E61-11AA-AA11-00306543ECAC" #ifdef __cplusplus } #endif #endif /* __HFS_FORMAT__ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/hfs/hfs_unistr.h
/* * Copyright (c) 2013 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 __HFS_UNISTR__ #define __HFS_UNISTR__ #include <sys/types.h> /* * hfs_unitstr.h * * This file contains definition of the unicode string used for HFS Plus * files and folder names, as described by the on-disk format. * */ #ifdef __cplusplus extern "C" { #endif #ifndef _HFSUNISTR255_DEFINED_ #define _HFSUNISTR255_DEFINED_ /* Unicode strings are used for HFS Plus file and folder names */ struct HFSUniStr255 { u_int16_t length; /* number of unicode characters */ u_int16_t unicode[255]; /* unicode characters */ } __attribute__((aligned(2), packed)); typedef struct HFSUniStr255 HFSUniStr255; typedef const HFSUniStr255 *ConstHFSUniStr255Param; #endif /* _HFSUNISTR255_DEFINED_ */ #ifdef __cplusplus } #endif #endif /* __HFS_UNISTR__ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/hfs/hfs_mount.h
/* * Copyright (c) 2000-2015 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@ */ /* * Copyright (c) 1997-2002 Apple Inc. All Rights Reserved * */ #ifndef _HFS_MOUNT_H_ #define _HFS_MOUNT_H_ #include <sys/appleapiopts.h> #include <sys/mount.h> #include <sys/time.h> /* * Arguments to mount HFS-based filesystems */ #define OVERRIDE_UNKNOWN_PERMISSIONS 0 #define UNKNOWNUID ((uid_t)99) #define UNKNOWNGID ((gid_t)99) #define UNKNOWNPERMISSIONS (S_IRWXU | S_IROTH | S_IXOTH) /* 705 */ #ifdef __APPLE_API_UNSTABLE struct hfs_mount_args { uid_t hfs_uid; /* uid that owns hfs files (standard HFS only) */ gid_t hfs_gid; /* gid that owns hfs files (standard HFS only) */ mode_t hfs_mask; /* mask to be applied for hfs perms (standard HFS only) */ u_int32_t hfs_encoding; /* encoding for this volume (standard HFS only) */ struct timezone hfs_timezone; /* user time zone info (standard HFS only) */ int flags; /* mounting flags, see below */ int journal_tbuffer_size; /* size in bytes of the journal transaction buffer */ int journal_flags; /* flags to pass to journal_open/create */ int journal_disable; /* don't use journaling (potentially dangerous) */ }; #define HFSFSMNT_NOXONFILES 0x1 /* disable execute permissions for files */ #define HFSFSMNT_WRAPPER 0x2 /* mount HFS wrapper (if it exists) */ #define HFSFSMNT_EXTENDED_ARGS 0x4 /* indicates new fields after "flags" are valid */ /* * Sysctl values for HFS */ #define HFS_ENCODINGBIAS 1 /* encoding matching CJK bias */ #define HFS_EXTEND_FS 2 #define HFS_ENABLE_JOURNALING 0x082969 #define HFS_DISABLE_JOURNALING 0x031272 #define HFS_REPLAY_JOURNAL 0x6a6e6c72 #define HFS_ENABLE_RESIZE_DEBUG 4 /* enable debug code for volume resizing */ #endif /* __APPLE_API_UNSTABLE */ #endif /* ! _HFS_MOUNT_H_ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/arm64/machine_machdep.h
/* * Copyright (c) 2017 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 _MACHDEP_INTERNAL_H_ #define _MACHDEP_INTERNAL_H_ /* We cache the current cthread pointer in TPIDRRO_EL0 and * the current CPU number in the low 12 bits of TPIDR_EL0. * * The cthread pointer must be aligned * sufficiently that the maximum CPU number will fit. * * NOTE: Keep this in sync with libsyscall/os/tsd.h, specifically _os_cpu_number() */ #define MACHDEP_TPIDR_CPUNUM_MASK (0x0000000000000fff) #endif /* _MACHDEP_INTERNAL_H_ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/arm64/machine_cpuid.h
/* * Copyright (c) 2017 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 _ARM64_MACHINE_CPUID_H_ #define _ARM64_MACHINE_CPUID_H_ typedef struct { uint64_t el0_not_implemented : 1, el0_aarch64_only : 1, el0_aarch32_and_64 : 1, el1_not_implemented : 1, el1_aarch64_only : 1, el1_aarch32_and_64 : 1, el2_not_implemented : 1, el2_aarch64_only : 1, el2_aarch32_and_64 : 1, el3_not_implemented : 1, el3_aarch64_only : 1, el3_aarch32_and_64 : 1, reserved : 52; } arm_feature_bits_t; /* Debug identification */ /* ID_AA64DFR0_EL1 */ typedef union { struct { uint64_t debug_arch_version : 4, trace_extn_version : 4, perf_extn_version : 4, brps : 4, reserved0 : 4, wrps : 4, reserved1 : 4, ctx_cmps : 4, reserved32 : 32; } debug_feature; uint64_t value; } arm_cpuid_id_aa64dfr0_el1; typedef struct { uint32_t num_watchpoint_pairs; uint32_t num_breakpoint_pairs; } arm_debug_info_t; #endif /* _MACHINE_CPUID_H_ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/HIDDriverKit/IOHIDInterface.h
/* iig(DriverKit-191.30.2) generated from IOHIDInterface.iig */ /* IOHIDInterface.iig:1-46 */ /* * Copyright (c) 2018-2019 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@ */ #if !__IIG #if KERNEL #include <IOKit/hid/IOHIDInterface.h> #endif #endif #ifndef _HIDDRIVERKIT_IOHIDINTERFACE_H #define _HIDDRIVERKIT_IOHIDINTERFACE_H #include <DriverKit/OSAction.h> /* .iig include */ #include <DriverKit/IOService.h> /* .iig include */ #include <DriverKit/IOMemoryDescriptor.h> /* .iig include */ #include <DriverKit/IOBufferMemoryDescriptor.h> /* .iig include */ #include <HIDDriverKit/IOHIDDeviceTypes.h> #include <DriverKit/IOTypes.h> class OSArray; /* source class IOHIDInterface IOHIDInterface.iig:47-285 */ #if __DOCUMENTATION__ #define KERNEL IIG_KERNEL /*! * @class IOHIDInterface * @abstract Abstract interface to HID device functionality * @discussion Following object properties can be used to identify/match interface and its characteristics (see IOHIDDeviceKeys.h ) * kIOHIDReportIntervalKey * kIOHIDVendorIDKey * kIOHIDProductIDKey * kIOHIDTransportKey * kIOHIDVersionNumberKey * kIOHIDCountryCodeKey * kIOHIDLocationIDKey * kIOHIDManufacturerKey * kIOHIDProductKey * kIOHIDSerialNumberKey * kIOHIDRequestTimeoutKey */ class KERNEL IOHIDInterface : public IOService { public: /*! * @function init * * @abstract * Initializes IOHIDInterface object. * * @return * true on success. */ virtual bool init() override; /*! * @function free * * @abstract * frees the IOHIDInterface object. */ virtual void free() override; /*! * @function ReportAvailable * * @abstract * Callback invoked when an input report is received from the device. * * @param timestamp * The timestamp of the report. * * @param reportID * The report ID. * * @param reportLength * The length of the report. * * @param type * The report type. * * @param report * A memory descriptor that describes the report. * * @param action * The OSAction object that will handle the asynchronous report callback. */ virtual void ReportAvailable(uint64_t timestamp, uint32_t reportID, uint32_t reportLength, IOHIDReportType type, IOMemoryDescriptor *report, OSAction *action TARGET) LOCAL = 0; /*! * @function AddReportToPool * * @abstract * Adds a memory descriptor to the report pool. * * @param report * A memory descriptor large enough to hold input reports. * * @return * Returns kIOReturnSuccess on success. */ virtual kern_return_t AddReportToPool(IOBufferMemoryDescriptor *report); /*! * @function Open * * @abstract * Opens the interface in order to receive input reports. * * @param forClient * The client opening the IOHIDInterface. * * @param options * Options to pass to the interface. * * @param action * The OSAction object that will handle the asynchronous report callback. * * @return * Returns kIOReturnSuccess on success. */ virtual kern_return_t Open(IOService *forClient, IOOptionBits options, OSAction *action TYPE(ReportAvailable)); /*! * @function Close * * @abstract * Closes the IOHIDInterface, stopping invocation of report callbacks. * * @param forClient * The client closing the IOHIDInterface. * * @param options * Options to pass to the interface. * * @return * Returns kIOReturnSuccess on success. */ virtual kern_return_t Close(IOService *forClient, IOOptionBits options); /*! * @function SetReport * * @abstract * Send a report to the HID device. * * @param report * A memory descriptor that describes the report to send * to the HID device. * * @param reportType * The report type. * * @param reportID * the report ID. * * @param options * The lower 8 bits will represent the Report ID. The other 24 bits are * options to specify the request. * * @return * Returns kIOReturnSuccess on success. */ virtual kern_return_t SetReport (IOMemoryDescriptor * report, IOHIDReportType reportType, uint32_t reportID = 0, IOOptionBits options = 0); /*! * @function GetReport * * @abstract * Get a report from the HID device. * * @param report * A memory descriptor that describes the memory to store the report read * from the HID device. * * @param reportType * The report type. * * @param reportID * The report ID. * * @param options * The lower 8 bits will represent the Report ID. The other 24 bits are * options to specify the request. * * @return * Returns kIOReturnSuccess on success. */ virtual kern_return_t GetReport (IOMemoryDescriptor * report, IOHIDReportType reportType, uint32_t reportID = 0, IOOptionBits options = 0); /*! * @function processReport * * @abstract * Processes the report received from the HandleReportCallback function. * Will update all element values (returned from the getElements function) * from the new report data. * * @param timestamp * The timestamp of the report. * * @param report * Bytes that describes the report. * * @param reportLength * The length of the report. * * @param type * The report type. * * @param reportID * The report ID. */ virtual void processReport(uint64_t timestamp, uint8_t *report, uint32_t reportLength, IOHIDReportType type, uint32_t reportID) LOCALONLY; /*! * @function getElements * * @abstract * Returns an array of IOHIDElement objects. The element values will be * updates on calls to the processReport() function. * * @return * Returns an array of IOHIDElement objects. */ virtual OSArray *getElements() LOCALONLY; /*! * @function commitElements * * @abstract * Commits an array of IOHIDElements to/from the device. * * @param elements * An array of IOHIDElement objects. * * @param direction * The direction to commit the elements. Directions are defined in the * IOHIDElementCommitDirection enumerator in <IOKit/hid/IOHIDKeys.h>. * * @result * Returns kIOReturnSuccess on success. */ virtual kern_return_t commitElements(OSArray *elements, IOHIDElementCommitDirection direction) LOCALONLY; }; #undef KERNEL #else /* __DOCUMENTATION__ */ /* generated class IOHIDInterface IOHIDInterface.iig:47-285 */ #define IOHIDInterface_SendDebugBuffer_ID 0x9cd93af0504ec45dULL #define IOHIDInterface_GetElementValues_ID 0xc4a89d6fd6fd065cULL #define IOHIDInterface_SetElementValues_ID 0xf964ed7a299eb3a5ULL #define IOHIDInterface_GetSupportedCookies_ID 0xec13cf336ecceaccULL #define IOHIDInterface_ReportAvailable_ID 0xd46e690536704302ULL #define IOHIDInterface_AddReportToPool_ID 0xbe04e3d42572fd53ULL #define IOHIDInterface_Open_ID 0x9f3263b463025b4fULL #define IOHIDInterface_Close_ID 0x9bcf029fa80af1b5ULL #define IOHIDInterface_SetReport_ID 0xca9744a1af98f7dfULL #define IOHIDInterface_GetReport_ID 0xa8ccbd83dbbed4cdULL #define IOHIDInterface_SendDebugBuffer_Args \ IOMemoryDescriptor * debug #define IOHIDInterface_GetElementValues_Args \ uint32_t count, \ IOMemoryDescriptor * elementValues #define IOHIDInterface_SetElementValues_Args \ uint32_t count, \ IOMemoryDescriptor * elementValues #define IOHIDInterface_GetSupportedCookies_Args \ IOBufferMemoryDescriptor ** cookies #define IOHIDInterface_ReportAvailable_Args \ uint64_t timestamp, \ uint32_t reportID, \ uint32_t reportLength, \ IOHIDReportType type, \ IOMemoryDescriptor * report, \ OSAction * action #define IOHIDInterface_AddReportToPool_Args \ IOBufferMemoryDescriptor * report #define IOHIDInterface_Open_Args \ IOService * forClient, \ IOOptionBits options, \ OSAction * action #define IOHIDInterface_Close_Args \ IOService * forClient, \ IOOptionBits options #define IOHIDInterface_SetReport_Args \ IOMemoryDescriptor * report, \ IOHIDReportType reportType, \ uint32_t reportID, \ IOOptionBits options #define IOHIDInterface_GetReport_Args \ IOMemoryDescriptor * report, \ IOHIDReportType reportType, \ uint32_t reportID, \ IOOptionBits options #define IOHIDInterface_Methods \ \ public:\ \ virtual kern_return_t\ Dispatch(const IORPC rpc) APPLE_KEXT_OVERRIDE;\ \ static kern_return_t\ _Dispatch(IOHIDInterface * self, const IORPC rpc);\ \ kern_return_t\ SendDebugBuffer(\ IOMemoryDescriptor * debug,\ OSDispatchMethod supermethod = NULL);\ \ kern_return_t\ GetElementValues(\ uint32_t count,\ IOMemoryDescriptor * elementValues,\ OSDispatchMethod supermethod = NULL);\ \ kern_return_t\ SetElementValues(\ uint32_t count,\ IOMemoryDescriptor * elementValues,\ OSDispatchMethod supermethod = NULL);\ \ kern_return_t\ GetSupportedCookies(\ __attribute__((os_returns_retained)) IOBufferMemoryDescriptor ** cookies,\ OSDispatchMethod supermethod = NULL);\ \ bool\ createElements(\ );\ \ void\ ReportAvailable(\ uint64_t timestamp,\ uint32_t reportID,\ uint32_t reportLength,\ IOHIDReportType type,\ IOMemoryDescriptor * report,\ OSAction * action,\ OSDispatchMethod supermethod = NULL);\ \ kern_return_t\ AddReportToPool(\ IOBufferMemoryDescriptor * report,\ OSDispatchMethod supermethod = NULL);\ \ kern_return_t\ Open(\ IOService * forClient,\ IOOptionBits options,\ OSAction * action,\ OSDispatchMethod supermethod = NULL);\ \ kern_return_t\ Close(\ IOService * forClient,\ IOOptionBits options,\ OSDispatchMethod supermethod = NULL);\ \ kern_return_t\ SetReport(\ IOMemoryDescriptor * report,\ IOHIDReportType reportType,\ uint32_t reportID = 0,\ IOOptionBits options = 0,\ OSDispatchMethod supermethod = NULL);\ \ kern_return_t\ GetReport(\ IOMemoryDescriptor * report,\ IOHIDReportType reportType,\ uint32_t reportID = 0,\ IOOptionBits options = 0,\ OSDispatchMethod supermethod = NULL);\ \ \ protected:\ /* _Impl methods */\ \ \ public:\ /* _Invoke methods */\ \ typedef kern_return_t (*SendDebugBuffer_Handler)(OSMetaClassBase * target, IOHIDInterface_SendDebugBuffer_Args);\ static kern_return_t\ SendDebugBuffer_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ SendDebugBuffer_Handler func);\ \ typedef kern_return_t (*GetElementValues_Handler)(OSMetaClassBase * target, IOHIDInterface_GetElementValues_Args);\ static kern_return_t\ GetElementValues_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ GetElementValues_Handler func);\ \ typedef kern_return_t (*SetElementValues_Handler)(OSMetaClassBase * target, IOHIDInterface_SetElementValues_Args);\ static kern_return_t\ SetElementValues_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ SetElementValues_Handler func);\ \ typedef kern_return_t (*GetSupportedCookies_Handler)(OSMetaClassBase * target, IOHIDInterface_GetSupportedCookies_Args);\ static kern_return_t\ GetSupportedCookies_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ GetSupportedCookies_Handler func);\ \ typedef void (*ReportAvailable_Handler)(OSMetaClassBase * target, IOHIDInterface_ReportAvailable_Args);\ static kern_return_t\ ReportAvailable_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ ReportAvailable_Handler func,\ const OSMetaClass * targetActionClass);\ \ static kern_return_t\ ReportAvailable_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ ReportAvailable_Handler func);\ \ typedef kern_return_t (*AddReportToPool_Handler)(OSMetaClassBase * target, IOHIDInterface_AddReportToPool_Args);\ static kern_return_t\ AddReportToPool_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ AddReportToPool_Handler func);\ \ typedef kern_return_t (*Open_Handler)(OSMetaClassBase * target, IOHIDInterface_Open_Args);\ static kern_return_t\ Open_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ Open_Handler func);\ \ typedef kern_return_t (*Close_Handler)(OSMetaClassBase * target, IOHIDInterface_Close_Args);\ static kern_return_t\ Close_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ Close_Handler func);\ \ typedef kern_return_t (*SetReport_Handler)(OSMetaClassBase * target, IOHIDInterface_SetReport_Args);\ static kern_return_t\ SetReport_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ SetReport_Handler func);\ \ typedef kern_return_t (*GetReport_Handler)(OSMetaClassBase * target, IOHIDInterface_GetReport_Args);\ static kern_return_t\ GetReport_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ GetReport_Handler func);\ \ #define IOHIDInterface_KernelMethods \ \ protected:\ /* _Impl methods */\ \ kern_return_t\ SendDebugBuffer_Impl(IOHIDInterface_SendDebugBuffer_Args);\ \ kern_return_t\ GetElementValues_Impl(IOHIDInterface_GetElementValues_Args);\ \ kern_return_t\ SetElementValues_Impl(IOHIDInterface_SetElementValues_Args);\ \ kern_return_t\ GetSupportedCookies_Impl(IOHIDInterface_GetSupportedCookies_Args);\ \ kern_return_t\ AddReportToPool_Impl(IOHIDInterface_AddReportToPool_Args);\ \ kern_return_t\ Open_Impl(IOHIDInterface_Open_Args);\ \ kern_return_t\ Close_Impl(IOHIDInterface_Close_Args);\ \ kern_return_t\ SetReport_Impl(IOHIDInterface_SetReport_Args);\ \ kern_return_t\ GetReport_Impl(IOHIDInterface_GetReport_Args);\ \ #define IOHIDInterface_VirtualMethods \ \ public:\ \ virtual kern_return_t\ getElementValues(\ OSArray * elements) APPLE_KEXT_OVERRIDE;\ \ virtual kern_return_t\ setElementValues(\ OSArray * elements) APPLE_KEXT_OVERRIDE;\ \ virtual bool\ init(\ ) APPLE_KEXT_OVERRIDE;\ \ virtual void\ free(\ ) APPLE_KEXT_OVERRIDE;\ \ virtual void\ processReport(\ uint64_t timestamp,\ uint8_t * report,\ uint32_t reportLength,\ IOHIDReportType type,\ uint32_t reportID) APPLE_KEXT_OVERRIDE;\ \ virtual OSArray *\ getElements(\ ) APPLE_KEXT_OVERRIDE;\ \ virtual kern_return_t\ commitElements(\ OSArray * elements,\ IOHIDElementCommitDirection direction) APPLE_KEXT_OVERRIDE;\ \ #if !KERNEL extern OSMetaClass * gIOHIDInterfaceMetaClass; extern const OSClassLoadInformation IOHIDInterface_Class; class IOHIDInterfaceMetaClass : public OSMetaClass { public: virtual kern_return_t New(OSObject * instance) override; virtual kern_return_t Dispatch(const IORPC rpc) override; }; #endif /* !KERNEL */ #if !KERNEL class IOHIDInterfaceInterface : public OSInterface { public: virtual kern_return_t getElementValues(OSArray * elements) = 0; virtual kern_return_t setElementValues(OSArray * elements) = 0; virtual void processReport(uint64_t timestamp, uint8_t * report, uint32_t reportLength, IOHIDReportType type, uint32_t reportID) = 0; virtual OSArray * getElements() = 0; virtual kern_return_t commitElements(OSArray * elements, IOHIDElementCommitDirection direction) = 0; kern_return_t getElementValues_Call(OSArray * elements) { return getElementValues(elements); };\ kern_return_t setElementValues_Call(OSArray * elements) { return setElementValues(elements); };\ void processReport_Call(uint64_t timestamp, uint8_t * report, uint32_t reportLength, IOHIDReportType type, uint32_t reportID) { return processReport(timestamp, report, reportLength, type, reportID); };\ OSArray * getElements_Call() { return getElements(); };\ kern_return_t commitElements_Call(OSArray * elements, IOHIDElementCommitDirection direction) { return commitElements(elements, direction); };\ }; struct IOHIDInterface_IVars; struct IOHIDInterface_LocalIVars; class IOHIDInterface : public IOService, public IOHIDInterfaceInterface { #if !KERNEL friend class IOHIDInterfaceMetaClass; #endif /* !KERNEL */ #if !KERNEL public: #ifdef IOHIDInterface_DECLARE_IVARS IOHIDInterface_DECLARE_IVARS #else /* IOHIDInterface_DECLARE_IVARS */ union { IOHIDInterface_IVars * ivars; IOHIDInterface_LocalIVars * lvars; }; #endif /* IOHIDInterface_DECLARE_IVARS */ #endif /* !KERNEL */ #if !KERNEL static OSMetaClass * sGetMetaClass() { return gIOHIDInterfaceMetaClass; }; #endif /* KERNEL */ using super = IOService; #if !KERNEL IOHIDInterface_Methods IOHIDInterface_VirtualMethods #endif /* !KERNEL */ }; #endif /* !KERNEL */ #endif /* !__DOCUMENTATION__ */ /* IOHIDInterface.iig:304- */ #endif /* ! _HIDDRIVERKIT_IOHIDINTERFACE_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/HIDDriverKit/IOHIDDevice.h
/* iig(DriverKit-191.30.2) generated from IOHIDDevice.iig */ /* IOHIDDevice.iig:1-44 */ /* * Copyright (c) 2018-2019 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@ */ #if !__IIG #if KERNEL #include <IOKit/hid/IOHIDDevice.h> #endif #endif #ifndef _HIDDRIVERKIT_IOHIDDEVICE_H #define _HIDDRIVERKIT_IOHIDDEVICE_H #include <DriverKit/OSAction.h> /* .iig include */ #include <DriverKit/IOService.h> /* .iig include */ #include <HIDDriverKit/IOHIDDeviceTypes.h> #include <DriverKit/IOTypes.h> class IOMemoryDescriptor; /* source class IOHIDDevice IOHIDDevice.iig:45-131 */ #if __DOCUMENTATION__ #define KERNEL IIG_KERNEL class KERNEL IOHIDDevice : public IOService { public: /*! * @function handleReport * @abstract Handle an asynchronous report received from the HID device. * @param report A memory descriptor that describes the report. * @param reportType The type of report. * @param options Options to specify the request. No options are * currently defined, and the default value is 0. * @result kIOReturnSuccess on success, or an error return otherwise. */ virtual kern_return_t handleReport(uint64_t timestamp, IOMemoryDescriptor *report, uint32_t reportLength, IOHIDReportType reportType = kIOHIDReportTypeInput, IOOptionBits options = 0) LOCALONLY; /*! * @function getReport * @abstract Get a report from the HID device. * @param report A memory descriptor that describes the memory to store * the report read from the HID device. * @param reportType The report type. * @param options The lower 8 bits will represent the Report ID. The * other 24 bits are options to specify the request. * @param completionTimeout Specifies an amount of time (in ms) after which * the command will be aborted if the entire command has not been completed. * @param action OSAction to call CompleteReport when request completes. * @result kIOReturnSuccess on success, or an error return otherwise. */ virtual kern_return_t getReport(IOMemoryDescriptor * report, IOHIDReportType reportType, IOOptionBits options, uint32_t completionTimeout, OSAction * action) LOCALONLY; /*! * @function setReport * @abstract Send a report to the HID device. * @param report A memory descriptor that describes the report to send * to the HID device. * @param reportType The report type. * @param options The lower 8 bits will represent the Report ID. The * other 24 bits are options to specify the request. * @param completionTimeout Specifies an amount of time (in ms) after which * the command will be aborted if the entire command has not been completed. * @param action OSAction to call CompleteReport when request completes. * @result kIOReturnSuccess on success, or an error return otherwise. */ virtual kern_return_t setReport(IOMemoryDescriptor * report, IOHIDReportType reportType, IOOptionBits options, uint32_t completionTimeout, OSAction * action) LOCALONLY; protected: /*! * @brief Complete async requests made with GetReport/SetReport * @discussion method should be called upon completion of GetReport/SetReport. * @param action passed to GetReport/SetReport. * @param status status of the completion. * @param actualByteCount used buffer size of the buffer submitted with SetReport/GetReport. * @return none */ virtual void CompleteReport (OSAction * action TARGET, IOReturn status, uint32_t actualByteCount) LOCAL = 0; virtual void setProperty (OSObject * key, OSObject * value) LOCALONLY; public: }; #undef KERNEL #else /* __DOCUMENTATION__ */ /* generated class IOHIDDevice IOHIDDevice.iig:45-131 */ #define IOHIDDevice__Start_ID 0xd844e4e02f7103bbULL #define IOHIDDevice__CompleteReport_ID 0xdc4ef5129e3a9d08ULL #define IOHIDDevice__ProcessReport_ID 0xd539b835ea14880fULL #define IOHIDDevice__HandleReport_ID 0xad138a788e1f3247ULL #define IOHIDDevice__SetProperty_ID 0xa6ee936a6065f6baULL #define IOHIDDevice_CompleteReport_ID 0xf2d80ecf6d8c6cb5ULL #define IOHIDDevice__Start_Args \ IOService * provider #define IOHIDDevice__CompleteReport_Args \ OSAction * action, \ IOReturn status, \ uint32_t actualByteCount #define IOHIDDevice__ProcessReport_Args \ HIDReportCommandType command, \ IOMemoryDescriptor * report, \ IOHIDReportType reportType, \ IOOptionBits options, \ uint32_t completionTimeout, \ OSAction * action #define IOHIDDevice__HandleReport_Args \ uint64_t timestamp, \ IOMemoryDescriptor * report, \ uint32_t reportLength, \ IOHIDReportType reportType, \ IOOptionBits options #define IOHIDDevice__SetProperty_Args \ IOBufferMemoryDescriptor * serialization #define IOHIDDevice_CompleteReport_Args \ OSAction * action, \ IOReturn status, \ uint32_t actualByteCount #define IOHIDDevice_Methods \ \ public:\ \ virtual kern_return_t\ Dispatch(const IORPC rpc) APPLE_KEXT_OVERRIDE;\ \ static kern_return_t\ _Dispatch(IOHIDDevice * self, const IORPC rpc);\ \ kern_return_t\ _Start(\ IOService * provider,\ OSDispatchMethod supermethod = NULL);\ \ kern_return_t\ CreateAction_CompleteReport(size_t referenceSize, OSAction ** action);\ \ void\ _ProcessReport(\ HIDReportCommandType command,\ IOMemoryDescriptor * report,\ IOHIDReportType reportType,\ IOOptionBits options,\ uint32_t completionTimeout,\ OSAction * action,\ OSDispatchMethod supermethod = NULL);\ \ kern_return_t\ _HandleReport(\ uint64_t timestamp,\ IOMemoryDescriptor * report,\ uint32_t reportLength,\ IOHIDReportType reportType = kIOHIDReportTypeInput,\ IOOptionBits options = 0,\ OSDispatchMethod supermethod = NULL);\ \ void\ _SetProperty(\ IOBufferMemoryDescriptor * serialization,\ OSDispatchMethod supermethod = NULL);\ \ void\ CompleteReport(\ OSAction * action,\ IOReturn status,\ uint32_t actualByteCount,\ OSDispatchMethod supermethod = NULL);\ \ \ protected:\ /* _Impl methods */\ \ void\ _ProcessReport_Impl(IOHIDDevice__ProcessReport_Args);\ \ void\ _SetProperty_Impl(IOHIDDevice__SetProperty_Args);\ \ \ public:\ /* _Invoke methods */\ \ typedef kern_return_t (*_Start_Handler)(OSMetaClassBase * target, IOHIDDevice__Start_Args);\ static kern_return_t\ _Start_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ _Start_Handler func);\ \ typedef void (*_ProcessReport_Handler)(OSMetaClassBase * target, IOHIDDevice__ProcessReport_Args);\ static kern_return_t\ _ProcessReport_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ _ProcessReport_Handler func);\ \ typedef kern_return_t (*_HandleReport_Handler)(OSMetaClassBase * target, IOHIDDevice__HandleReport_Args);\ static kern_return_t\ _HandleReport_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ _HandleReport_Handler func);\ \ typedef void (*_SetProperty_Handler)(OSMetaClassBase * target, IOHIDDevice__SetProperty_Args);\ static kern_return_t\ _SetProperty_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ _SetProperty_Handler func);\ \ typedef void (*CompleteReport_Handler)(OSMetaClassBase * target, IOHIDDevice_CompleteReport_Args);\ static kern_return_t\ CompleteReport_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ CompleteReport_Handler func,\ const OSMetaClass * targetActionClass);\ \ static kern_return_t\ CompleteReport_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ CompleteReport_Handler func);\ \ #define IOHIDDevice_KernelMethods \ \ protected:\ /* _Impl methods */\ \ kern_return_t\ _Start_Impl(IOHIDDevice__Start_Args);\ \ void\ _CompleteReport_Impl(IOHIDDevice__CompleteReport_Args);\ \ kern_return_t\ _HandleReport_Impl(IOHIDDevice__HandleReport_Args);\ \ #define IOHIDDevice_VirtualMethods \ \ public:\ \ virtual kern_return_t\ handleReport(\ uint64_t timestamp,\ IOMemoryDescriptor * report,\ uint32_t reportLength,\ IOHIDReportType reportType = kIOHIDReportTypeInput,\ IOOptionBits options = 0) APPLE_KEXT_OVERRIDE;\ \ virtual kern_return_t\ getReport(\ IOMemoryDescriptor * report,\ IOHIDReportType reportType,\ IOOptionBits options,\ uint32_t completionTimeout,\ OSAction * action) APPLE_KEXT_OVERRIDE;\ \ virtual kern_return_t\ setReport(\ IOMemoryDescriptor * report,\ IOHIDReportType reportType,\ IOOptionBits options,\ uint32_t completionTimeout,\ OSAction * action) APPLE_KEXT_OVERRIDE;\ \ virtual void\ setProperty(\ OSObject * key,\ OSObject * value) APPLE_KEXT_OVERRIDE;\ \ #if !KERNEL extern OSMetaClass * gIOHIDDeviceMetaClass; extern const OSClassLoadInformation IOHIDDevice_Class; class IOHIDDeviceMetaClass : public OSMetaClass { public: virtual kern_return_t New(OSObject * instance) override; virtual kern_return_t Dispatch(const IORPC rpc) override; }; #endif /* !KERNEL */ #if !KERNEL class IOHIDDeviceInterface : public OSInterface { public: virtual kern_return_t handleReport(uint64_t timestamp, IOMemoryDescriptor * report, uint32_t reportLength, IOHIDReportType reportType, IOOptionBits options) = 0; virtual kern_return_t getReport(IOMemoryDescriptor * report, IOHIDReportType reportType, IOOptionBits options, uint32_t completionTimeout, OSAction * action) = 0; virtual kern_return_t setReport(IOMemoryDescriptor * report, IOHIDReportType reportType, IOOptionBits options, uint32_t completionTimeout, OSAction * action) = 0; virtual void setProperty(OSObject * key, OSObject * value) = 0; kern_return_t handleReport_Call(uint64_t timestamp, IOMemoryDescriptor * report, uint32_t reportLength, IOHIDReportType reportType, IOOptionBits options) { return handleReport(timestamp, report, reportLength, reportType, options); };\ kern_return_t getReport_Call(IOMemoryDescriptor * report, IOHIDReportType reportType, IOOptionBits options, uint32_t completionTimeout, OSAction * action) { return getReport(report, reportType, options, completionTimeout, action); };\ kern_return_t setReport_Call(IOMemoryDescriptor * report, IOHIDReportType reportType, IOOptionBits options, uint32_t completionTimeout, OSAction * action) { return setReport(report, reportType, options, completionTimeout, action); };\ void setProperty_Call(OSObject * key, OSObject * value) { return setProperty(key, value); };\ }; struct IOHIDDevice_IVars; struct IOHIDDevice_LocalIVars; class IOHIDDevice : public IOService, public IOHIDDeviceInterface { #if !KERNEL friend class IOHIDDeviceMetaClass; #endif /* !KERNEL */ #if !KERNEL public: #ifdef IOHIDDevice_DECLARE_IVARS IOHIDDevice_DECLARE_IVARS #else /* IOHIDDevice_DECLARE_IVARS */ union { IOHIDDevice_IVars * ivars; IOHIDDevice_LocalIVars * lvars; }; #endif /* IOHIDDevice_DECLARE_IVARS */ #endif /* !KERNEL */ #if !KERNEL static OSMetaClass * sGetMetaClass() { return gIOHIDDeviceMetaClass; }; #endif /* KERNEL */ using super = IOService; #if !KERNEL IOHIDDevice_Methods IOHIDDevice_VirtualMethods #endif /* !KERNEL */ }; #endif /* !KERNEL */ #define OSAction_IOHIDDevice__CompleteReport_Methods \ \ public:\ \ virtual kern_return_t\ Dispatch(const IORPC rpc) APPLE_KEXT_OVERRIDE;\ \ static kern_return_t\ _Dispatch(OSAction_IOHIDDevice__CompleteReport * self, const IORPC rpc);\ \ \ protected:\ /* _Impl methods */\ \ \ public:\ /* _Invoke methods */\ \ #define OSAction_IOHIDDevice__CompleteReport_KernelMethods \ \ protected:\ /* _Impl methods */\ \ #define OSAction_IOHIDDevice__CompleteReport_VirtualMethods \ \ public:\ \ #if !KERNEL extern OSMetaClass * gOSAction_IOHIDDevice__CompleteReportMetaClass; extern const OSClassLoadInformation OSAction_IOHIDDevice__CompleteReport_Class; class OSAction_IOHIDDevice__CompleteReportMetaClass : public OSMetaClass { public: virtual kern_return_t New(OSObject * instance) override; virtual kern_return_t Dispatch(const IORPC rpc) override; }; #endif /* !KERNEL */ class OSAction_IOHIDDevice__CompleteReportInterface : public OSInterface { public: }; struct OSAction_IOHIDDevice__CompleteReport_IVars; struct OSAction_IOHIDDevice__CompleteReport_LocalIVars; class __attribute__((availability(driverkit,introduced=20,message="Type-safe OSAction factory methods are available in DriverKit 20 and newer"))) OSAction_IOHIDDevice__CompleteReport : public OSAction, public OSAction_IOHIDDevice__CompleteReportInterface { #if KERNEL OSDeclareDefaultStructorsWithDispatch(OSAction_IOHIDDevice__CompleteReport); #endif /* KERNEL */ #if !KERNEL friend class OSAction_IOHIDDevice__CompleteReportMetaClass; #endif /* !KERNEL */ public: #ifdef OSAction_IOHIDDevice__CompleteReport_DECLARE_IVARS OSAction_IOHIDDevice__CompleteReport_DECLARE_IVARS #else /* OSAction_IOHIDDevice__CompleteReport_DECLARE_IVARS */ union { OSAction_IOHIDDevice__CompleteReport_IVars * ivars; OSAction_IOHIDDevice__CompleteReport_LocalIVars * lvars; }; #endif /* OSAction_IOHIDDevice__CompleteReport_DECLARE_IVARS */ #if !KERNEL static OSMetaClass * sGetMetaClass() { return gOSAction_IOHIDDevice__CompleteReportMetaClass; }; virtual const OSMetaClass * getMetaClass() const APPLE_KEXT_OVERRIDE { return gOSAction_IOHIDDevice__CompleteReportMetaClass; }; #endif /* KERNEL */ using super = OSAction; #if !KERNEL OSAction_IOHIDDevice__CompleteReport_Methods #endif /* !KERNEL */ OSAction_IOHIDDevice__CompleteReport_VirtualMethods }; #endif /* !__DOCUMENTATION__ */ /* IOHIDDevice.iig:188- */ #endif /* ! _HIDDRIVERKIT_IOHIDDEVICE_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/HIDDriverKit/IOHIDEventService.h
/* iig(DriverKit-191.30.2) generated from IOHIDEventService.iig */ /* IOHIDEventService.iig:1-48 */ /* * Copyright (c) 2018-2020 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@ */ #if !__IIG #if KERNEL #include <IOKit/hidevent/IOHIDEventService.h> #endif #endif #ifndef _HIDDRIVERKIT_IOHIDEVENTSERVICE_H #define _HIDDRIVERKIT_IOHIDEVENTSERVICE_H #include <DriverKit/OSAction.h> /* .iig include */ #include <DriverKit/IOService.h> /* .iig include */ #include <DriverKit/IOTypes.h> class IOBufferMemoryDescriptor; class IOHIDEvent; typedef struct IOHIDDigitizerStylusData IOHIDDigitizerStylusData; typedef struct IOHIDDigitizerTouchData IOHIDDigitizerTouchData; /* source class IOHIDEventService IOHIDEventService.iig:49-381 */ #if __DOCUMENTATION__ #define KERNEL IIG_KERNEL class KERNEL IOHIDEventService : public IOService { public: /*! * @function init * * @abstract * Initializes IOHIDEventService object. * * @return * true on success. */ virtual bool init() override; /*! * @function free * * @abstract * frees the object. */ virtual void free() override; /*! * @function Start * * @abstract * Function called after initialization to start the IOService. * * @discussion * Override this function to perform any needed driver initialization before * main functionality begins. Calling the parent's Start in a child's Start is required. * If the parent's Start returns an error or the child encounters an error in Start after * the parent's Start has been called, Stop must immediately be called. * * @param provider * The IOService that is provider for this object. * * @return * returns kIOReturnSuccess on success. */ virtual kern_return_t Start(IOService * provider) override; /*! * @function Stop * * @abstract * Function called during termination to stop the IOService. * * @discussion * Override this function to perform any needed driver teardown before * the process exits. Calling the parent's Stop in a child's Stop is required. * Do not call Stop if the parent's Start has not yet been called. * Stop should only be called once. * * @param provider * The IOService that is provider for this object. * * @return * returns kIOReturnSuccess on success. */ virtual kern_return_t Stop(IOService * provider) override; /*! * @function DispatchKeyboardEvent * * @abstract * Dispatches a keyboard event with the provided usage page, usage, and * value. * * @param timestamp * The timestamp of the event. * * @param usagePage * The usage page. Usage pages are defined in * <IOKit/hid/IOHIDUsageTables.h>. * * @param usage * The usage. Usages are defined in <IOKit/hid/IOHIDUsageTables.h>. * * @param value * The value. * * @param options * Optional option bits. Options are defined in the IOHIDKeyboardEventOptions * enumerator in <IOKit/hid/IOHIDKeys.h> * * @param repeat * Default behavior for keyboard events is to repeat keys if the key has been * held down for a certain amount of time defined in system preferences. Pass * in false to not apply key repeat logic to this event. */ virtual kern_return_t dispatchKeyboardEvent(uint64_t timeStamp, uint32_t usagePage, uint32_t usage, uint32_t value, IOOptionBits options, bool repeat = true) LOCALONLY; /*! * @function DispatchRelativePointerEvent * * @abstract * Dispatches a relative pointer event. * * @param timestamp * The timestamp of the event. * * @param dx * The delta X value. * * @param dy * The delta Y value. * * @param buttonState * Current state of the buttons, if any. * * @param options * Optional option bits. * * @param accelerate * Pointer events are subject to an acceleration algorithm. Pass in false * if you do not wish to have acceleration logic applied to the pointer event. */ virtual kern_return_t dispatchRelativePointerEvent(uint64_t timeStamp, IOFixed dx, IOFixed dy, uint32_t buttonState, IOOptionBits options, bool accelerate = true) LOCALONLY; /*! * @function DispatchAbsolutePointerEvent * * @abstract * Dispatches an absolute pointer event. * * @param timeStamp * The timestamp of the event. * * @param x * An X value between 0 and 1. * * @param dy * A Y value between 0 and 1. * * @param buttonState * Current state of the buttons, if any. * * @param options * Optional option bits. * * @param accelerate * Pointer events are subject to an acceleration algorithm. Pass in false * if you do not wish to have acceleration logic applied to the pointer event. */ virtual kern_return_t dispatchAbsolutePointerEvent(uint64_t timeStamp, IOFixed x, IOFixed y, uint32_t buttonState, IOOptionBits options, bool accelerate = true) LOCALONLY; /*! * @function DispatchRelativeScrollWheelEvent * * @abstract * Dispatches a relative scroll wheel event. * * @param timestamp * The timestamp of the event. * * @param dx * The delta X value. * * @param dy * The delta Y value. * * @param dz * The delta Z value. * * @param options * Optional option bits. * * @param accelerate * Scroll events are subject to an acceleration algorithm. Pass in false * if you do not wish to have acceleration logic applied to the scroll event. */ virtual kern_return_t dispatchRelativeScrollWheelEvent(uint64_t timeStamp, IOFixed dx, IOFixed dy, IOFixed dz, IOOptionBits options, bool accelerate = true) LOCALONLY; /*! * @function dispatchDigitizerStylusEvent * * @abstract * Dispatches a digitizer stylus event. * * @param timestamp * The timestamp of the event. * * @param stylusData * A struct containing the stylus data. See IOHIDDigtizerStructs.h for more * info. */ virtual kern_return_t dispatchDigitizerStylusEvent( uint64_t timeStamp, IOHIDDigitizerStylusData *stylusData) LOCALONLY; /*! * @function dispatchDigitizerTouchEvent * * @abstract * Dispatches a digitizer touch pad event. * * @param timestamp * The timestamp of the event. * * @param touchData * An array of touch data, where each struct represents a surface contact. * See IOHIDDigtizerStructs.h for more info. * * @param touchDataCount * The touchData array count. */ virtual kern_return_t dispatchDigitizerTouchEvent( uint64_t timeStamp, IOHIDDigitizerTouchData *touchData, uint32_t touchDataCount) LOCALONLY; protected: /*! * @function SetLED * * @abstract * DEPRECATED. Prefer SetLEDState instead. * Sets an LED on the service. * * @discussion * By default if no implementation of SetLEDState is provided by * the DriverKit Driver, SetLED will be called instead by a * default implementation in IOUserHIDEventService. The * IOUserHIDEventService implementation always returns * kIOReturnSuccess if the usagePage for SetLEDState is @{kHIDPage_LEDs}. * * @param usage * The LED usage to set. LED usages can be found in * <IOKit/hid/IOHIDUsageTables.h>. * * @param on * Turn on or off the LED. */ virtual void SetLED(uint32_t usage, bool on) LOCAL; /*! * @function SetLEDState * * @abstract * Sets an LED on the service. * * @discussion * If there is no matching LED, then kIOReturnUnsupported should be returned, so that the UserClient * can be signaled that the usage requested doesn't exist. If the LED exists it should return * kIOReturnSuccess. * * @param usagePage * The usage page of the LED requested to set. * * @param usage * The LED usage to set. LED usages can be found in * <IOKit/hid/IOHIDUsageTables.h>. * * @param on * Turn on or off the LED. */ virtual kern_return_t SetLEDState(uint32_t usagePage, uint32_t usage, bool on) LOCAL; /*! * @function dispatchEvent * * @abstract * Dispatches an event. * * @param event * The IOHIDEvent to dispatch. */ virtual void dispatchEvent(IOHIDEvent *event) LOCALONLY; /*! * @function handleCopyMatchingEvent * * @abstract * copy event that match parameters * * @param matching * Dictionary with matching key/values. Supported keys (see IOHIDEventServiceKeys_Private.h): * kIOHIDEventTypeKey * kIOHIDUsagePageKey * kIOHIDUsageKey * * @param event * Event copy. Caller must release event. * * @return * Returns kIOReturnSuccess on success. */ virtual kern_return_t handleCopyMatchingEvent(OSDictionary * matching, IOHIDEvent **event) LOCAL; /*! * @function SetProperties * * @abstract * set properties on the event service * * @discussion * This method should be overridden by the DriverKit class if it needs to respond to setProperties calls. * Calling SetProperties(properties, SUPERDISPATCH) from the DriverKit class will get the properties added to a dictionary in IOReg * that HID Event System Clients will be able to see. * * @param properties * Dictionary with property key/values. Supported keys (see IOHIDEventServiceKeys.h and IOHIDEventServiceKeys_Private.h): * kIOHIDEventTypeKey * kIOHIDUsagePageKey * kIOHIDUsageKey * * @return * Returns kIOReturnSuccess on success. */ virtual kern_return_t SetProperties(OSDictionary *properties) override; }; #undef KERNEL #else /* __DOCUMENTATION__ */ /* generated class IOHIDEventService IOHIDEventService.iig:49-381 */ #define IOHIDEventService__CompleteSetLED_ID 0x89830a8035210708ULL #define IOHIDEventService_SetLEDAction_ID 0xa095dc2c466d441dULL #define IOHIDEventService__SetLED_ID 0xecb4f77e69022d2dULL #define IOHIDEventService__CompleteSetProperties_ID 0xe1490a1f685db486ULL #define IOHIDEventService__SetUserProperties_ID 0xefd8a550b2092d2dULL #define IOHIDEventService_SetUserProperties_ID 0xe86319b882a5ed35ULL #define IOHIDEventService__CompleteCopyEvent_ID 0xfe4c1f0658fc9a16ULL #define IOHIDEventService__CopyEvent_ID 0xc3450c2606d5f0e6ULL #define IOHIDEventService_CopyEvent_ID 0xf17de3a9be12ffedULL #define IOHIDEventService__Start_ID 0xb7aeaf00ae079615ULL #define IOHIDEventService_EventAvailable_ID 0xb6d3212b1068148aULL #define IOHIDEventService_SetEventMemory_ID 0xed62c58e8d2f64e7ULL #define IOHIDEventService__DispatchRelativeScrollWheelEvent_ID 0xe5902a0b51ed22ffULL #define IOHIDEventService__DispatchAbsolutePointerEvent_ID 0xa89e9153d54a8eb1ULL #define IOHIDEventService__DispatchRelativePointerEvent_ID 0xdfb3b21fdb3ea3b4ULL #define IOHIDEventService__DispatchKeyboardEvent_ID 0xd8dc8ce69e15f7d3ULL #define IOHIDEventService_SetLED_ID 0xfee475ac1384bab8ULL #define IOHIDEventService_SetLEDState_ID 0xa871aa31861269baULL #define IOHIDEventService_handleCopyMatchingEvent_ID 0xc7c97c024faede2dULL #define IOHIDEventService__CompleteSetLED_Args \ OSAction * action, \ IOReturn result, \ uint64_t context #define IOHIDEventService_SetLEDAction_Args \ uint32_t usagePage, \ uint32_t usage, \ bool on, \ uint64_t context, \ OSAction * action #define IOHIDEventService__SetLED_Args \ uint32_t usagePage, \ uint32_t usage, \ bool on, \ uint64_t context, \ OSAction * action #define IOHIDEventService__CompleteSetProperties_Args \ OSAction * action, \ IOReturn result, \ uint64_t context #define IOHIDEventService__SetUserProperties_Args \ OSDictionary * properties, \ uint64_t context, \ OSAction * action #define IOHIDEventService_SetUserProperties_Args \ OSDictionary * properties, \ uint64_t context, \ OSAction * action #define IOHIDEventService__CompleteCopyEvent_Args \ OSAction * action, \ IOBufferMemoryDescriptor * eventBuffer, \ uint64_t context #define IOHIDEventService__CopyEvent_Args \ OSDictionary * matching, \ uint64_t context, \ OSAction * action #define IOHIDEventService_CopyEvent_Args \ OSDictionary * matching, \ uint64_t context, \ OSAction * action #define IOHIDEventService__Start_Args \ IOService * provider #define IOHIDEventService_EventAvailable_Args \ uint32_t length #define IOHIDEventService_SetEventMemory_Args \ IOBufferMemoryDescriptor * memory #define IOHIDEventService__DispatchRelativeScrollWheelEvent_Args \ uint64_t timeStamp, \ IOFixed dx, \ IOFixed dy, \ IOFixed dz, \ IOOptionBits options, \ bool accelerate #define IOHIDEventService__DispatchAbsolutePointerEvent_Args \ uint64_t timeStamp, \ IOFixed x, \ IOFixed y, \ uint32_t buttonState, \ IOOptionBits options, \ bool accelerate #define IOHIDEventService__DispatchRelativePointerEvent_Args \ uint64_t timeStamp, \ IOFixed dx, \ IOFixed dy, \ uint32_t buttonState, \ IOOptionBits options, \ bool accelerate #define IOHIDEventService__DispatchKeyboardEvent_Args \ uint64_t timeStamp, \ uint32_t usagePage, \ uint32_t usage, \ uint32_t value, \ IOOptionBits options, \ bool repeat #define IOHIDEventService_Start_Args \ IOService * provider #define IOHIDEventService_Stop_Args \ IOService * provider #define IOHIDEventService_SetLED_Args \ uint32_t usage, \ bool on #define IOHIDEventService_SetLEDState_Args \ uint32_t usagePage, \ uint32_t usage, \ bool on #define IOHIDEventService_handleCopyMatchingEvent_Args \ OSDictionary * matching, \ IOHIDEvent ** event #define IOHIDEventService_SetProperties_Args \ OSDictionary * properties #define IOHIDEventService_Methods \ \ public:\ \ virtual kern_return_t\ Dispatch(const IORPC rpc) APPLE_KEXT_OVERRIDE;\ \ static kern_return_t\ _Dispatch(IOHIDEventService * self, const IORPC rpc);\ \ void\ _CompleteSetLED(\ OSAction * action,\ IOReturn result,\ uint64_t context,\ OSDispatchMethod supermethod = NULL);\ \ void\ SetLEDAction(\ uint32_t usagePage,\ uint32_t usage,\ bool on,\ uint64_t context,\ OSAction * action,\ OSDispatchMethod supermethod = NULL);\ \ kern_return_t\ CreateAction_SetLED(size_t referenceSize, OSAction ** action);\ \ void\ _CompleteSetProperties(\ OSAction * action,\ IOReturn result,\ uint64_t context,\ OSDispatchMethod supermethod = NULL);\ \ kern_return_t\ CreateAction_SetUserProperties(size_t referenceSize, OSAction ** action);\ \ void\ SetUserProperties(\ OSDictionary * properties,\ uint64_t context,\ OSAction * action,\ OSDispatchMethod supermethod = NULL);\ \ void\ _CompleteCopyEvent(\ OSAction * action,\ IOBufferMemoryDescriptor * eventBuffer,\ uint64_t context,\ OSDispatchMethod supermethod = NULL);\ \ kern_return_t\ CreateAction_CopyEvent(size_t referenceSize, OSAction ** action);\ \ void\ CopyEvent(\ OSDictionary * matching,\ uint64_t context,\ OSAction * action,\ OSDispatchMethod supermethod = NULL);\ \ kern_return_t\ _Start(\ IOService * provider,\ OSDispatchMethod supermethod = NULL);\ \ kern_return_t\ EventAvailable(\ uint32_t length,\ OSDispatchMethod supermethod = NULL);\ \ kern_return_t\ SetEventMemory(\ IOBufferMemoryDescriptor * memory,\ OSDispatchMethod supermethod = NULL);\ \ kern_return_t\ _DispatchRelativeScrollWheelEvent(\ uint64_t timeStamp,\ IOFixed dx,\ IOFixed dy,\ IOFixed dz,\ IOOptionBits options,\ bool accelerate = true,\ OSDispatchMethod supermethod = NULL);\ \ kern_return_t\ _DispatchAbsolutePointerEvent(\ uint64_t timeStamp,\ IOFixed x,\ IOFixed y,\ uint32_t buttonState,\ IOOptionBits options,\ bool accelerate = true,\ OSDispatchMethod supermethod = NULL);\ \ kern_return_t\ _DispatchRelativePointerEvent(\ uint64_t timeStamp,\ IOFixed dx,\ IOFixed dy,\ uint32_t buttonState,\ IOOptionBits options,\ bool accelerate = true,\ OSDispatchMethod supermethod = NULL);\ \ kern_return_t\ _DispatchKeyboardEvent(\ uint64_t timeStamp,\ uint32_t usagePage,\ uint32_t usage,\ uint32_t value,\ IOOptionBits options,\ bool repeat = true,\ OSDispatchMethod supermethod = NULL);\ \ void\ SetLED(\ uint32_t usage,\ bool on,\ OSDispatchMethod supermethod = NULL);\ \ kern_return_t\ SetLEDState(\ uint32_t usagePage,\ uint32_t usage,\ bool on,\ OSDispatchMethod supermethod = NULL);\ \ kern_return_t\ handleCopyMatchingEvent(\ OSDictionary * matching,\ IOHIDEvent ** event,\ OSDispatchMethod supermethod = NULL);\ \ \ protected:\ /* _Impl methods */\ \ void\ _SetLED_Impl(IOHIDEventService__SetLED_Args);\ \ void\ _SetUserProperties_Impl(IOHIDEventService__SetUserProperties_Args);\ \ void\ _CopyEvent_Impl(IOHIDEventService__CopyEvent_Args);\ \ kern_return_t\ Start_Impl(IOService_Start_Args);\ \ kern_return_t\ Stop_Impl(IOService_Stop_Args);\ \ void\ SetLED_Impl(IOHIDEventService_SetLED_Args);\ \ kern_return_t\ SetLEDState_Impl(IOHIDEventService_SetLEDState_Args);\ \ kern_return_t\ handleCopyMatchingEvent_Impl(IOHIDEventService_handleCopyMatchingEvent_Args);\ \ \ public:\ /* _Invoke methods */\ \ typedef void (*_CompleteSetLED_Handler)(OSMetaClassBase * target, IOHIDEventService__CompleteSetLED_Args);\ static kern_return_t\ _CompleteSetLED_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ _CompleteSetLED_Handler func);\ \ typedef void (*SetLEDAction_Handler)(OSMetaClassBase * target, IOHIDEventService_SetLEDAction_Args);\ static kern_return_t\ SetLEDAction_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ SetLEDAction_Handler func,\ const OSMetaClass * targetActionClass);\ \ static kern_return_t\ SetLEDAction_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ SetLEDAction_Handler func);\ \ typedef void (*_CompleteSetProperties_Handler)(OSMetaClassBase * target, IOHIDEventService__CompleteSetProperties_Args);\ static kern_return_t\ _CompleteSetProperties_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ _CompleteSetProperties_Handler func);\ \ typedef void (*SetUserProperties_Handler)(OSMetaClassBase * target, IOHIDEventService_SetUserProperties_Args);\ static kern_return_t\ SetUserProperties_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ SetUserProperties_Handler func,\ const OSMetaClass * targetActionClass);\ \ static kern_return_t\ SetUserProperties_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ SetUserProperties_Handler func);\ \ typedef void (*_CompleteCopyEvent_Handler)(OSMetaClassBase * target, IOHIDEventService__CompleteCopyEvent_Args);\ static kern_return_t\ _CompleteCopyEvent_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ _CompleteCopyEvent_Handler func);\ \ typedef void (*CopyEvent_Handler)(OSMetaClassBase * target, IOHIDEventService_CopyEvent_Args);\ static kern_return_t\ CopyEvent_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ CopyEvent_Handler func,\ const OSMetaClass * targetActionClass);\ \ static kern_return_t\ CopyEvent_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ CopyEvent_Handler func);\ \ typedef kern_return_t (*_Start_Handler)(OSMetaClassBase * target, IOHIDEventService__Start_Args);\ static kern_return_t\ _Start_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ _Start_Handler func);\ \ typedef kern_return_t (*EventAvailable_Handler)(OSMetaClassBase * target, IOHIDEventService_EventAvailable_Args);\ static kern_return_t\ EventAvailable_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ EventAvailable_Handler func);\ \ typedef kern_return_t (*SetEventMemory_Handler)(OSMetaClassBase * target, IOHIDEventService_SetEventMemory_Args);\ static kern_return_t\ SetEventMemory_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ SetEventMemory_Handler func);\ \ typedef kern_return_t (*_DispatchRelativeScrollWheelEvent_Handler)(OSMetaClassBase * target, IOHIDEventService__DispatchRelativeScrollWheelEvent_Args);\ static kern_return_t\ _DispatchRelativeScrollWheelEvent_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ _DispatchRelativeScrollWheelEvent_Handler func);\ \ typedef kern_return_t (*_DispatchAbsolutePointerEvent_Handler)(OSMetaClassBase * target, IOHIDEventService__DispatchAbsolutePointerEvent_Args);\ static kern_return_t\ _DispatchAbsolutePointerEvent_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ _DispatchAbsolutePointerEvent_Handler func);\ \ typedef kern_return_t (*_DispatchRelativePointerEvent_Handler)(OSMetaClassBase * target, IOHIDEventService__DispatchRelativePointerEvent_Args);\ static kern_return_t\ _DispatchRelativePointerEvent_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ _DispatchRelativePointerEvent_Handler func);\ \ typedef kern_return_t (*_DispatchKeyboardEvent_Handler)(OSMetaClassBase * target, IOHIDEventService__DispatchKeyboardEvent_Args);\ static kern_return_t\ _DispatchKeyboardEvent_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ _DispatchKeyboardEvent_Handler func);\ \ typedef void (*SetLED_Handler)(OSMetaClassBase * target, IOHIDEventService_SetLED_Args);\ static kern_return_t\ SetLED_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ SetLED_Handler func);\ \ typedef kern_return_t (*SetLEDState_Handler)(OSMetaClassBase * target, IOHIDEventService_SetLEDState_Args);\ static kern_return_t\ SetLEDState_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ SetLEDState_Handler func);\ \ typedef kern_return_t (*handleCopyMatchingEvent_Handler)(OSMetaClassBase * target, IOHIDEventService_handleCopyMatchingEvent_Args);\ static kern_return_t\ handleCopyMatchingEvent_Invoke(const IORPC rpc,\ OSMetaClassBase * target,\ handleCopyMatchingEvent_Handler func);\ \ #define IOHIDEventService_KernelMethods \ \ protected:\ /* _Impl methods */\ \ void\ _CompleteSetLED_Impl(IOHIDEventService__CompleteSetLED_Args);\ \ void\ _CompleteSetProperties_Impl(IOHIDEventService__CompleteSetProperties_Args);\ \ void\ _CompleteCopyEvent_Impl(IOHIDEventService__CompleteCopyEvent_Args);\ \ kern_return_t\ _Start_Impl(IOHIDEventService__Start_Args);\ \ kern_return_t\ EventAvailable_Impl(IOHIDEventService_EventAvailable_Args);\ \ kern_return_t\ SetEventMemory_Impl(IOHIDEventService_SetEventMemory_Args);\ \ kern_return_t\ _DispatchRelativeScrollWheelEvent_Impl(IOHIDEventService__DispatchRelativeScrollWheelEvent_Args);\ \ kern_return_t\ _DispatchAbsolutePointerEvent_Impl(IOHIDEventService__DispatchAbsolutePointerEvent_Args);\ \ kern_return_t\ _DispatchRelativePointerEvent_Impl(IOHIDEventService__DispatchRelativePointerEvent_Args);\ \ kern_return_t\ _DispatchKeyboardEvent_Impl(IOHIDEventService__DispatchKeyboardEvent_Args);\ \ kern_return_t\ SetProperties_Impl(IOService_SetProperties_Args);\ \ #define IOHIDEventService_VirtualMethods \ \ public:\ \ virtual bool\ init(\ ) APPLE_KEXT_OVERRIDE;\ \ virtual void\ free(\ ) APPLE_KEXT_OVERRIDE;\ \ virtual kern_return_t\ dispatchKeyboardEvent(\ uint64_t timeStamp,\ uint32_t usagePage,\ uint32_t usage,\ uint32_t value,\ IOOptionBits options,\ bool repeat = true) APPLE_KEXT_OVERRIDE;\ \ virtual kern_return_t\ dispatchRelativePointerEvent(\ uint64_t timeStamp,\ IOFixed dx,\ IOFixed dy,\ uint32_t buttonState,\ IOOptionBits options,\ bool accelerate = true) APPLE_KEXT_OVERRIDE;\ \ virtual kern_return_t\ dispatchAbsolutePointerEvent(\ uint64_t timeStamp,\ IOFixed x,\ IOFixed y,\ uint32_t buttonState,\ IOOptionBits options,\ bool accelerate = true) APPLE_KEXT_OVERRIDE;\ \ virtual kern_return_t\ dispatchRelativeScrollWheelEvent(\ uint64_t timeStamp,\ IOFixed dx,\ IOFixed dy,\ IOFixed dz,\ IOOptionBits options,\ bool accelerate = true) APPLE_KEXT_OVERRIDE;\ \ virtual kern_return_t\ dispatchDigitizerStylusEvent(\ uint64_t timeStamp,\ IOHIDDigitizerStylusData * stylusData) APPLE_KEXT_OVERRIDE;\ \ virtual kern_return_t\ dispatchDigitizerTouchEvent(\ uint64_t timeStamp,\ IOHIDDigitizerTouchData * touchData,\ uint32_t touchDataCount) APPLE_KEXT_OVERRIDE;\ \ virtual void\ dispatchEvent(\ IOHIDEvent * event) APPLE_KEXT_OVERRIDE;\ \ #if !KERNEL extern OSMetaClass * gIOHIDEventServiceMetaClass; extern const OSClassLoadInformation IOHIDEventService_Class; class IOHIDEventServiceMetaClass : public OSMetaClass { public: virtual kern_return_t New(OSObject * instance) override; virtual kern_return_t Dispatch(const IORPC rpc) override; }; #endif /* !KERNEL */ #if !KERNEL class IOHIDEventServiceInterface : public OSInterface { public: virtual kern_return_t dispatchKeyboardEvent(uint64_t timeStamp, uint32_t usagePage, uint32_t usage, uint32_t value, IOOptionBits options, bool repeat) = 0; virtual kern_return_t dispatchRelativePointerEvent(uint64_t timeStamp, IOFixed dx, IOFixed dy, uint32_t buttonState, IOOptionBits options, bool accelerate) = 0; virtual kern_return_t dispatchAbsolutePointerEvent(uint64_t timeStamp, IOFixed x, IOFixed y, uint32_t buttonState, IOOptionBits options, bool accelerate) = 0; virtual kern_return_t dispatchRelativeScrollWheelEvent(uint64_t timeStamp, IOFixed dx, IOFixed dy, IOFixed dz, IOOptionBits options, bool accelerate) = 0; virtual kern_return_t dispatchDigitizerStylusEvent(uint64_t timeStamp, IOHIDDigitizerStylusData * stylusData) = 0; virtual kern_return_t dispatchDigitizerTouchEvent(uint64_t timeStamp, IOHIDDigitizerTouchData * touchData, uint32_t touchDataCount) = 0; virtual void dispatchEvent(IOHIDEvent * event) = 0; kern_return_t dispatchKeyboardEvent_Call(uint64_t timeStamp, uint32_t usagePage, uint32_t usage, uint32_t value, IOOptionBits options, bool repeat) { return dispatchKeyboardEvent(timeStamp, usagePage, usage, value, options, repeat); };\ kern_return_t dispatchRelativePointerEvent_Call(uint64_t timeStamp, IOFixed dx, IOFixed dy, uint32_t buttonState, IOOptionBits options, bool accelerate) { return dispatchRelativePointerEvent(timeStamp, dx, dy, buttonState, options, accelerate); };\ kern_return_t dispatchAbsolutePointerEvent_Call(uint64_t timeStamp, IOFixed x, IOFixed y, uint32_t buttonState, IOOptionBits options, bool accelerate) { return dispatchAbsolutePointerEvent(timeStamp, x, y, buttonState, options, accelerate); };\ kern_return_t dispatchRelativeScrollWheelEvent_Call(uint64_t timeStamp, IOFixed dx, IOFixed dy, IOFixed dz, IOOptionBits options, bool accelerate) { return dispatchRelativeScrollWheelEvent(timeStamp, dx, dy, dz, options, accelerate); };\ kern_return_t dispatchDigitizerStylusEvent_Call(uint64_t timeStamp, IOHIDDigitizerStylusData * stylusData) { return dispatchDigitizerStylusEvent(timeStamp, stylusData); };\ kern_return_t dispatchDigitizerTouchEvent_Call(uint64_t timeStamp, IOHIDDigitizerTouchData * touchData, uint32_t touchDataCount) { return dispatchDigitizerTouchEvent(timeStamp, touchData, touchDataCount); };\ void dispatchEvent_Call(IOHIDEvent * event) { return dispatchEvent(event); };\ }; struct IOHIDEventService_IVars; struct IOHIDEventService_LocalIVars; class IOHIDEventService : public IOService, public IOHIDEventServiceInterface { #if !KERNEL friend class IOHIDEventServiceMetaClass; #endif /* !KERNEL */ #if !KERNEL public: #ifdef IOHIDEventService_DECLARE_IVARS IOHIDEventService_DECLARE_IVARS #else /* IOHIDEventService_DECLARE_IVARS */ union { IOHIDEventService_IVars * ivars; IOHIDEventService_LocalIVars * lvars; }; #endif /* IOHIDEventService_DECLARE_IVARS */ #endif /* !KERNEL */ #if !KERNEL static OSMetaClass * sGetMetaClass() { return gIOHIDEventServiceMetaClass; }; #endif /* KERNEL */ using super = IOService; #if !KERNEL IOHIDEventService_Methods IOHIDEventService_VirtualMethods #endif /* !KERNEL */ }; #endif /* !KERNEL */ #define OSAction_IOHIDEventService__SetLED_Methods \ \ public:\ \ virtual kern_return_t\ Dispatch(const IORPC rpc) APPLE_KEXT_OVERRIDE;\ \ static kern_return_t\ _Dispatch(OSAction_IOHIDEventService__SetLED * self, const IORPC rpc);\ \ \ protected:\ /* _Impl methods */\ \ \ public:\ /* _Invoke methods */\ \ #define OSAction_IOHIDEventService__SetLED_KernelMethods \ \ protected:\ /* _Impl methods */\ \ #define OSAction_IOHIDEventService__SetLED_VirtualMethods \ \ public:\ \ #if !KERNEL extern OSMetaClass * gOSAction_IOHIDEventService__SetLEDMetaClass; extern const OSClassLoadInformation OSAction_IOHIDEventService__SetLED_Class; class OSAction_IOHIDEventService__SetLEDMetaClass : public OSMetaClass { public: virtual kern_return_t New(OSObject * instance) override; virtual kern_return_t Dispatch(const IORPC rpc) override; }; #endif /* !KERNEL */ class OSAction_IOHIDEventService__SetLEDInterface : public OSInterface { public: }; struct OSAction_IOHIDEventService__SetLED_IVars; struct OSAction_IOHIDEventService__SetLED_LocalIVars; class __attribute__((availability(driverkit,introduced=20,message="Type-safe OSAction factory methods are available in DriverKit 20 and newer"))) OSAction_IOHIDEventService__SetLED : public OSAction, public OSAction_IOHIDEventService__SetLEDInterface { #if KERNEL OSDeclareDefaultStructorsWithDispatch(OSAction_IOHIDEventService__SetLED); #endif /* KERNEL */ #if !KERNEL friend class OSAction_IOHIDEventService__SetLEDMetaClass; #endif /* !KERNEL */ public: #ifdef OSAction_IOHIDEventService__SetLED_DECLARE_IVARS OSAction_IOHIDEventService__SetLED_DECLARE_IVARS #else /* OSAction_IOHIDEventService__SetLED_DECLARE_IVARS */ union { OSAction_IOHIDEventService__SetLED_IVars * ivars; OSAction_IOHIDEventService__SetLED_LocalIVars * lvars; }; #endif /* OSAction_IOHIDEventService__SetLED_DECLARE_IVARS */ #if !KERNEL static OSMetaClass * sGetMetaClass() { return gOSAction_IOHIDEventService__SetLEDMetaClass; }; virtual const OSMetaClass * getMetaClass() const APPLE_KEXT_OVERRIDE { return gOSAction_IOHIDEventService__SetLEDMetaClass; }; #endif /* KERNEL */ using super = OSAction; #if !KERNEL OSAction_IOHIDEventService__SetLED_Methods #endif /* !KERNEL */ OSAction_IOHIDEventService__SetLED_VirtualMethods }; #define OSAction_IOHIDEventService__SetUserProperties_Methods \ \ public:\ \ virtual kern_return_t\ Dispatch(const IORPC rpc) APPLE_KEXT_OVERRIDE;\ \ static kern_return_t\ _Dispatch(OSAction_IOHIDEventService__SetUserProperties * self, const IORPC rpc);\ \ \ protected:\ /* _Impl methods */\ \ \ public:\ /* _Invoke methods */\ \ #define OSAction_IOHIDEventService__SetUserProperties_KernelMethods \ \ protected:\ /* _Impl methods */\ \ #define OSAction_IOHIDEventService__SetUserProperties_VirtualMethods \ \ public:\ \ #if !KERNEL extern OSMetaClass * gOSAction_IOHIDEventService__SetUserPropertiesMetaClass; extern const OSClassLoadInformation OSAction_IOHIDEventService__SetUserProperties_Class; class OSAction_IOHIDEventService__SetUserPropertiesMetaClass : public OSMetaClass { public: virtual kern_return_t New(OSObject * instance) override; virtual kern_return_t Dispatch(const IORPC rpc) override; }; #endif /* !KERNEL */ class OSAction_IOHIDEventService__SetUserPropertiesInterface : public OSInterface { public: }; struct OSAction_IOHIDEventService__SetUserProperties_IVars; struct OSAction_IOHIDEventService__SetUserProperties_LocalIVars; class __attribute__((availability(driverkit,introduced=20,message="Type-safe OSAction factory methods are available in DriverKit 20 and newer"))) OSAction_IOHIDEventService__SetUserProperties : public OSAction, public OSAction_IOHIDEventService__SetUserPropertiesInterface { #if KERNEL OSDeclareDefaultStructorsWithDispatch(OSAction_IOHIDEventService__SetUserProperties); #endif /* KERNEL */ #if !KERNEL friend class OSAction_IOHIDEventService__SetUserPropertiesMetaClass; #endif /* !KERNEL */ public: #ifdef OSAction_IOHIDEventService__SetUserProperties_DECLARE_IVARS OSAction_IOHIDEventService__SetUserProperties_DECLARE_IVARS #else /* OSAction_IOHIDEventService__SetUserProperties_DECLARE_IVARS */ union { OSAction_IOHIDEventService__SetUserProperties_IVars * ivars; OSAction_IOHIDEventService__SetUserProperties_LocalIVars * lvars; }; #endif /* OSAction_IOHIDEventService__SetUserProperties_DECLARE_IVARS */ #if !KERNEL static OSMetaClass * sGetMetaClass() { return gOSAction_IOHIDEventService__SetUserPropertiesMetaClass; }; virtual const OSMetaClass * getMetaClass() const APPLE_KEXT_OVERRIDE { return gOSAction_IOHIDEventService__SetUserPropertiesMetaClass; }; #endif /* KERNEL */ using super = OSAction; #if !KERNEL OSAction_IOHIDEventService__SetUserProperties_Methods #endif /* !KERNEL */ OSAction_IOHIDEventService__SetUserProperties_VirtualMethods }; #define OSAction_IOHIDEventService__CopyEvent_Methods \ \ public:\ \ virtual kern_return_t\ Dispatch(const IORPC rpc) APPLE_KEXT_OVERRIDE;\ \ static kern_return_t\ _Dispatch(OSAction_IOHIDEventService__CopyEvent * self, const IORPC rpc);\ \ \ protected:\ /* _Impl methods */\ \ \ public:\ /* _Invoke methods */\ \ #define OSAction_IOHIDEventService__CopyEvent_KernelMethods \ \ protected:\ /* _Impl methods */\ \ #define OSAction_IOHIDEventService__CopyEvent_VirtualMethods \ \ public:\ \ #if !KERNEL extern OSMetaClass * gOSAction_IOHIDEventService__CopyEventMetaClass; extern const OSClassLoadInformation OSAction_IOHIDEventService__CopyEvent_Class; class OSAction_IOHIDEventService__CopyEventMetaClass : public OSMetaClass { public: virtual kern_return_t New(OSObject * instance) override; virtual kern_return_t Dispatch(const IORPC rpc) override; }; #endif /* !KERNEL */ class OSAction_IOHIDEventService__CopyEventInterface : public OSInterface { public: }; struct OSAction_IOHIDEventService__CopyEvent_IVars; struct OSAction_IOHIDEventService__CopyEvent_LocalIVars; class __attribute__((availability(driverkit,introduced=20,message="Type-safe OSAction factory methods are available in DriverKit 20 and newer"))) OSAction_IOHIDEventService__CopyEvent : public OSAction, public OSAction_IOHIDEventService__CopyEventInterface { #if KERNEL OSDeclareDefaultStructorsWithDispatch(OSAction_IOHIDEventService__CopyEvent); #endif /* KERNEL */ #if !KERNEL friend class OSAction_IOHIDEventService__CopyEventMetaClass; #endif /* !KERNEL */ public: #ifdef OSAction_IOHIDEventService__CopyEvent_DECLARE_IVARS OSAction_IOHIDEventService__CopyEvent_DECLARE_IVARS #else /* OSAction_IOHIDEventService__CopyEvent_DECLARE_IVARS */ union { OSAction_IOHIDEventService__CopyEvent_IVars * ivars; OSAction_IOHIDEventService__CopyEvent_LocalIVars * lvars; }; #endif /* OSAction_IOHIDEventService__CopyEvent_DECLARE_IVARS */ #if !KERNEL static OSMetaClass * sGetMetaClass() { return gOSAction_IOHIDEventService__CopyEventMetaClass; }; virtual const OSMetaClass * getMetaClass() const APPLE_KEXT_OVERRIDE { return gOSAction_IOHIDEventService__CopyEventMetaClass; }; #endif /* KERNEL */ using super = OSAction; #if !KERNEL OSAction_IOHIDEventService__CopyEvent_Methods #endif /* !KERNEL */ OSAction_IOHIDEventService__CopyEvent_VirtualMethods }; #endif /* !__DOCUMENTATION__ */ /* IOHIDEventService.iig:630- */ #endif /* ! _HIDDRIVERKIT_IOHIDEVENTSERVICE_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/HIDDriverKit/IOHIDDeviceTypes.h
/* * * @APPLE_LICENSE_HEADER_START@ * * Copyright (c) 2019 Apple Computer, Inc. All Rights Reserved. * * 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 IOHIDDeviceTypes_h #define IOHIDDeviceTypes_h #include <TargetConditionals.h> #if TARGET_OS_DRIVERKIT #include <DriverKit/IOTypes.h> #include <DriverKit/IOReturn.h> #else #include <IOKit/IOReturn.h> #include <IOKit/IOTypes.h> #endif // TARGET_OS_DRIVERKIT /*! * @typedef IOHIDReportType * * @abstract * Describes different type of HID reports. */ enum IOHIDReportType { kIOHIDReportTypeInput = 0, kIOHIDReportTypeOutput, kIOHIDReportTypeFeature, kIOHIDReportTypeCount }; typedef enum IOHIDReportType IOHIDReportType; /*! * @typedef IOHIDElementCommitDirection * * @abstract * Commit direction passed in to the commit() function of an IOHIDElement. * * @field kIOHIDElementCommitDirectionIn * Passing in kIOHIDElementCommitDirectionIn will issue a getReport call to the * device, and the element will be updated with the value retrieved by the * device. The value can be accessed via the getValue() or getDataValue() * functions. * * @field kIOHIDElementCommitDirectionOut * Passing in kIOHIDElementCommitDirectionOut will issue a setReport call to the * device. Before issuing this call, the desired value should be set on the * element with the setValue() or setDataValue() functions. */ typedef enum { kIOHIDElementCommitDirectionIn, kIOHIDElementCommitDirectionOut } IOHIDElementCommitDirection; /*! * @typedef IOHIDElementCookie * * @abstract * Abstract data type used as a unique identifier for an element. */ #if TARGET_OS_DRIVERKIT || defined(__LP64__) typedef uint32_t IOHIDElementCookie; #else typedef void * IOHIDElementCookie; #endif /*! * @typedef IOHIDElementType * * @abstract * Describes different types of HID elements. * * @discussion * Used by the IOHIDFamily to identify the type of element processed. * Represented by the key kIOHIDElementTypeKey in the dictionary describing the * element. * * @field kIOHIDElementTypeInput_Misc * Misc input data field or varying size. * * @field kIOHIDElementTypeInput_Button * One bit input data field. * * @field kIOHIDElementTypeInput_Axis * Input data field used to represent an axis. * * @field kIOHIDElementTypeInput_ScanCodes * Input data field used to represent a scan code or usage selector. * * @field kIOHIDElementTypeInput_NULL * Input data field used to represent the end of an input report when receiving * input elements. * * @field kIOHIDElementTypeOutput * Used to represent an output data field in a report. * * @field kIOHIDElementTypeFeature * Describes input and output elements not intended for consumption by the end * user. * * @field kIOHIDElementTypeCollection * Element used to identify a relationship between two or more elements. */ enum IOHIDElementType { kIOHIDElementTypeInput_Misc = 1, kIOHIDElementTypeInput_Button = 2, kIOHIDElementTypeInput_Axis = 3, kIOHIDElementTypeInput_ScanCodes = 4, kIOHIDElementTypeInput_NULL = 5, kIOHIDElementTypeOutput = 129, kIOHIDElementTypeFeature = 257, kIOHIDElementTypeCollection = 513 }; typedef enum IOHIDElementType IOHIDElementType; enum { kIOHIDElementFlagsConstantMask = 0x0001, kIOHIDElementFlagsVariableMask = 0x0002, kIOHIDElementFlagsRelativeMask = 0x0004, kIOHIDElementFlagsWrapMask = 0x0008, kIOHIDElementFlagsNonLinearMask = 0x0010, kIOHIDElementFlagsNoPreferredMask = 0x0020, kIOHIDElementFlagsNullStateMask = 0x0040, kIOHIDElementFlagsVolativeMask = 0x0080, kIOHIDElementFlagsBufferedByteMask = 0x0100 }; typedef uint32_t IOHIDElementFlags; /*! * @typedef IOHIDElementCollectionType * * @abstract * Describes different types of HID collections. * * @discussion * Collections identify a relationship between two or more elements. * * @field kIOHIDElementCollectionTypePhysical * Used for a set of data items that represent data points collected at one * geometric point. * * @field kIOHIDElementCollectionTypeApplication * Identifies item groups serving different purposes in a single device. * * @field kIOHIDElementCollectionTypeLogical * Used when a set of data items form a composite data structure. * * @field kIOHIDElementCollectionTypeReport * Wraps all the fields in a report. * * @field kIOHIDElementCollectionTypeNamedArray * Contains an array of selector usages. * * @field kIOHIDElementCollectionTypeUsageSwitch * Modifies the meaning of the usage it contains. * * @field kIOHIDElementCollectionTypeUsageModifier * Modifies the meaning of the usage attached to the encompassing collection. */ enum IOHIDElementCollectionType{ kIOHIDElementCollectionTypePhysical = 0x00, kIOHIDElementCollectionTypeApplication, kIOHIDElementCollectionTypeLogical, kIOHIDElementCollectionTypeReport, kIOHIDElementCollectionTypeNamedArray, kIOHIDElementCollectionTypeUsageSwitch, kIOHIDElementCollectionTypeUsageModifier }; typedef enum IOHIDElementCollectionType IOHIDElementCollectionType; /*! * @typedef IOHIDValueScaleType * * @abstract * Describes different types of scaling that can be performed on element values. * * @field kIOHIDValueScaleTypeCalibrated * Type for value that is scaled with respect to the calibration properties. * * @field kIOHIDValueScaleTypePhysical * Type for value that is scaled with respect to the physical min and physical * max of the element. * * @field kIOHIDValueScaleTypeExponent * Type for value that is scaled with respect to the element's unit exponent. */ enum { kIOHIDValueScaleTypeCalibrated, kIOHIDValueScaleTypePhysical, kIOHIDValueScaleTypeExponent }; typedef uint32_t IOHIDValueScaleType; /*! * @typedef IOHIDValueOptions * * @abstract * Describes options for gathering element values. * * @field kIOHIDValueOptionsFlagRelativeSimple * Compares against previous value * * @field kIOHIDValueOptionsUpdateElementValues * Generates a get report before reading the element value when getting an element. * Generates a set report with the passed value, even if it did not change, to the device when setting a value. */ enum { kIOHIDValueOptionsFlagRelativeSimple = (1<<0), kIOHIDValueOptionsFlagPrevious = (1<<1), kIOHIDValueOptionsUpdateElementValues = (1<<2) }; typedef uint32_t IOHIDValueOptions; /*! * @typedef IOHIDCompletionAction * * @abstract Function called when set/get report completes * * @param target * The target specified in the IOHIDCompletion struct. * * @param parameter * The parameter specified in the IOHIDCompletion struct. * * @param status * Completion status */ typedef void (*IOHIDCompletionAction)(void *target, void *parameter, IOReturn status, uint32_t bufferSizeRemaining); /*! * @typedef IOHIDCompletion * * @abstract * Struct spefifying action to perform when set/get report completes. * * @var target * The target to pass to the action function. * * @var action * The function to call. * * @var parameter * The parameter to pass to the action function. */ typedef struct IOHIDCompletion { void *target; IOHIDCompletionAction action; void *parameter; } IOHIDCompletion; /*! * @abstract * Option bits for IOHIDDevice::handleReport, IOHIDDevice::getReport, and * IOHIDDevice::setReport * * @field kIOHIDReportOptionNotInterrupt * Tells method that the report passed was not interrupt driven. */ enum { kIOHIDReportOptionNotInterrupt = 0x100, kIOHIDReportOptionVariableSize = 0x200 }; /*! * @typedef HIDReportCommandType * * @abstract * Type of the report command for DriverKit driver */ typedef enum { kIOHIDReportCommandSetReport, kIOHIDReportCommandGetReport } HIDReportCommandType; #endif /* IOHIDDeviceTypes_h */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/lockd/lockd_mach.h
#ifndef _lockd_mach_user_ #define _lockd_mach_user_ /* Module lockd_mach */ #include <string.h> #include <mach/ndr.h> #include <mach/boolean.h> #include <mach/kern_return.h> #include <mach/notify.h> #include <mach/mach_types.h> #include <mach/message.h> #include <mach/mig_errors.h> #include <mach/port.h> /* BEGIN MIG_STRNCPY_ZEROFILL CODE */ #if defined(__has_include) #if __has_include(<mach/mig_strncpy_zerofill_support.h>) #ifndef USING_MIG_STRNCPY_ZEROFILL #define USING_MIG_STRNCPY_ZEROFILL #endif #ifndef __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ #define __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ #ifdef __cplusplus extern "C" { #endif extern int mig_strncpy_zerofill(char *dest, const char *src, int len) __attribute__((weak_import)); #ifdef __cplusplus } #endif #endif /* __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ */ #endif /* __has_include(<mach/mig_strncpy_zerofill_support.h>) */ #endif /* __has_include */ /* END MIG_STRNCPY_ZEROFILL CODE */ #if (__MigKernelSpecificCode) || (_MIG_KERNEL_SPECIFIC_CODE_) #include <kern/ipc_mig.h> #endif /* __MigKernelSpecificCode */ #ifdef AUTOTEST #ifndef FUNCTION_PTR_T #define FUNCTION_PTR_T typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); typedef struct { char *name; function_ptr_t function; } function_table_entry; typedef function_table_entry *function_table_t; #endif /* FUNCTION_PTR_T */ #endif /* AUTOTEST */ #ifndef lockd_mach_MSG_COUNT #define lockd_mach_MSG_COUNT 3 #endif /* lockd_mach_MSG_COUNT */ #include <Availability.h> #include <mach/std_types.h> #include <mach/mig.h> #include <mach/mig.h> #include <mach/mach_types.h> #include <lockd/lockd_mach_types.h> #ifdef __BeforeMigUserHeader __BeforeMigUserHeader #endif /* __BeforeMigUserHeader */ #include <sys/cdefs.h> __BEGIN_DECLS /* SimpleRoutine lockd_request */ #ifdef mig_external mig_external #else extern #endif /* mig_external */ kern_return_t lockd_request ( mach_port_t server, uint32_t vers, uint32_t flags, uint64_t xid, int64_t flk_start, int64_t flk_len, int32_t flk_pid, int32_t flk_type, int32_t flk_whence, sock_storage sock_address, xcred cred, uint32_t fh_len, nfs_handle fh ); /* Routine lockd_ping */ #ifdef mig_external mig_external #else extern #endif /* mig_external */ kern_return_t lockd_ping ( mach_port_t server ); /* SimpleRoutine lockd_shutdown */ #ifdef mig_external mig_external #else extern #endif /* mig_external */ kern_return_t lockd_shutdown ( mach_port_t server ); __END_DECLS /********************** Caution **************************/ /* The following data types should be used to calculate */ /* maximum message sizes only. The actual message may be */ /* smaller, and the position of the arguments within the */ /* message layout may vary from what is presented here. */ /* For example, if any of the arguments are variable- */ /* sized, and less than the maximum is sent, the data */ /* will be packed tight in the actual message to reduce */ /* the presence of holes. */ /********************** Caution **************************/ /* typedefs for all requests */ #ifndef __Request__lockd_mach_subsystem__defined #define __Request__lockd_mach_subsystem__defined #ifdef __MigPackStructs #pragma pack(push, 4) #endif typedef struct { mach_msg_header_t Head; NDR_record_t NDR; uint32_t vers; uint32_t flags; uint64_t xid; int64_t flk_start; int64_t flk_len; int32_t flk_pid; int32_t flk_type; int32_t flk_whence; sock_storage sock_address; xcred cred; uint32_t fh_len; nfs_handle fh; } __Request__lockd_request_t __attribute__((unused)); #ifdef __MigPackStructs #pragma pack(pop) #endif #ifdef __MigPackStructs #pragma pack(push, 4) #endif typedef struct { mach_msg_header_t Head; } __Request__lockd_ping_t __attribute__((unused)); #ifdef __MigPackStructs #pragma pack(pop) #endif #ifdef __MigPackStructs #pragma pack(push, 4) #endif typedef struct { mach_msg_header_t Head; } __Request__lockd_shutdown_t __attribute__((unused)); #ifdef __MigPackStructs #pragma pack(pop) #endif #endif /* !__Request__lockd_mach_subsystem__defined */ /* union of all requests */ #ifndef __RequestUnion__lockd_mach_subsystem__defined #define __RequestUnion__lockd_mach_subsystem__defined union __RequestUnion__lockd_mach_subsystem { __Request__lockd_request_t Request_lockd_request; __Request__lockd_ping_t Request_lockd_ping; __Request__lockd_shutdown_t Request_lockd_shutdown; }; #endif /* !__RequestUnion__lockd_mach_subsystem__defined */ /* typedefs for all replies */ #ifndef __Reply__lockd_mach_subsystem__defined #define __Reply__lockd_mach_subsystem__defined #ifdef __MigPackStructs #pragma pack(push, 4) #endif typedef struct { mach_msg_header_t Head; NDR_record_t NDR; kern_return_t RetCode; } __Reply__lockd_request_t __attribute__((unused)); #ifdef __MigPackStructs #pragma pack(pop) #endif #ifdef __MigPackStructs #pragma pack(push, 4) #endif typedef struct { mach_msg_header_t Head; NDR_record_t NDR; kern_return_t RetCode; } __Reply__lockd_ping_t __attribute__((unused)); #ifdef __MigPackStructs #pragma pack(pop) #endif #ifdef __MigPackStructs #pragma pack(push, 4) #endif typedef struct { mach_msg_header_t Head; NDR_record_t NDR; kern_return_t RetCode; } __Reply__lockd_shutdown_t __attribute__((unused)); #ifdef __MigPackStructs #pragma pack(pop) #endif #endif /* !__Reply__lockd_mach_subsystem__defined */ /* union of all replies */ #ifndef __ReplyUnion__lockd_mach_subsystem__defined #define __ReplyUnion__lockd_mach_subsystem__defined union __ReplyUnion__lockd_mach_subsystem { __Reply__lockd_request_t Reply_lockd_request; __Reply__lockd_ping_t Reply_lockd_ping; __Reply__lockd_shutdown_t Reply_lockd_shutdown; }; #endif /* !__RequestUnion__lockd_mach_subsystem__defined */ #ifndef subsystem_to_name_map_lockd_mach #define subsystem_to_name_map_lockd_mach \ { "lockd_request", 1023 },\ { "lockd_ping", 1024 },\ { "lockd_shutdown", 1025 } #endif #ifdef __AfterMigUserHeader __AfterMigUserHeader #endif /* __AfterMigUserHeader */ #endif /* _lockd_mach_user_ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/lockd/lockd_mach_types.h
/* * Copyright (c) 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@ */ #ifndef _LOCKD_MACH_TYPES_H_ #define _LOCKD_MACH_TYPES_H_ /* * XXX NFSV3_MAX_FH_SIZE is defined in sys/mount.h, but we can't include * that here. Osfmk includes libsa/types.h which causes massive conflicts * with sys/types.h that get indirectly included with sys/mount.h. In user * land below will work on a build that does not yet have the new macro * definition. */ #ifndef NFSV3_MAX_FH_SIZE #define NFSV3_MAX_FH_SIZE 64 #endif typedef uint32_t sock_storage[32]; typedef uint32_t xcred[19]; typedef uint8_t nfs_handle[NFSV3_MAX_FH_SIZE]; #endif
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/bank/bank_types.h
/* * Copyright (c) 2012-2013 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 _BANK_BANK_TYPES_H_ #define _BANK_BANK_TYPES_H_ #include <stdint.h> #include <mach/mach_types.h> #define MACH_VOUCHER_ATTR_BANK_NULL ((mach_voucher_attr_recipe_command_t)601) #define MACH_VOUCHER_ATTR_BANK_CREATE ((mach_voucher_attr_recipe_command_t)610) #define MACH_VOUCHER_ATTR_BANK_MODIFY_PERSONA ((mach_voucher_attr_recipe_command_t)611) #define MACH_VOUCHER_BANK_CONTENT_SIZE (500) typedef uint32_t bank_action_t; #define BANK_ORIGINATOR_PID 0x1 #define BANK_PERSONA_TOKEN 0x2 #define BANK_PERSONA_ID 0x3 #define BANK_PERSONA_ADOPT_ANY 0x4 struct proc_persona_info { uint64_t unique_pid; int32_t pid; uint32_t flags; uint32_t pidversion; uint32_t persona_id; uint32_t uid; uint32_t gid; uint8_t macho_uuid[16]; }; struct persona_token { struct proc_persona_info originator; struct proc_persona_info proximate; }; struct persona_modify_info { uint32_t persona_id; uint64_t unique_pid; }; #endif /* _BANK_BANK_TYPES_H_ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/OSAtomic.h
/* * Copyright (c) 2007-2012 Apple Inc. All rights reserved. * 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@ */ /* * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. * * HISTORY * */ #ifndef _OS_OSATOMIC_H #define _OS_OSATOMIC_H #include <libkern/OSBase.h> #include <string.h> #if defined(__cplusplus) extern "C" { #endif #define __SAFE_CAST_PTR(type, var) ((type)(var)) /*! * @header * * @abstract * This header declares the OSAtomic group of functions for atomic * reading and updating of values. */ /*! * @function OSCompareAndSwap64 * * @abstract * 64-bit compare and swap operation. * * @discussion * See OSCompareAndSwap. */ extern Boolean OSCompareAndSwap64( UInt64 oldValue, UInt64 newValue, volatile UInt64 * address); #define OSCompareAndSwap64(a, b, c) \ (OSCompareAndSwap64(a, b, __SAFE_CAST_PTR(volatile UInt64*,c))) /*! * @function OSAddAtomic64 * * @abstract * 64-bit atomic add operation. * * @discussion * See OSAddAtomic. */ extern SInt64 OSAddAtomic64( SInt64 theAmount, volatile SInt64 * address); #define OSAddAtomic64(a, b) \ (OSAddAtomic64(a, __SAFE_CAST_PTR(volatile SInt64*,b))) /*! * @function OSIncrementAtomic64 * * @abstract * 64-bit increment. * * @discussion * See OSIncrementAtomic. */ inline static SInt64 OSIncrementAtomic64(volatile SInt64 * address) { return OSAddAtomic64(1LL, address); } /*! * @function OSDecrementAtomic64 * * @abstract * 64-bit decrement. * * @discussion * See OSDecrementAtomic. */ inline static SInt64 OSDecrementAtomic64(volatile SInt64 * address) { return OSAddAtomic64(-1LL, address); } /*! * @function OSCompareAndSwap * * @abstract * Compare and swap operation, performed atomically with respect to all devices that participate in the coherency architecture of the platform. * * @discussion * The OSCompareAndSwap function compares the value at the specified address with oldVal. The value of newValue is written to the address only if oldValue and the value at the address are equal. OSCompareAndSwap returns true if newValue is written to the address; otherwise, it returns false. * * This function guarantees atomicity only with main system memory. It is specifically unsuitable for use on noncacheable memory such as that in devices; this function cannot guarantee atomicity, for example, on memory mapped from a PCI device. Additionally, this function incorporates a memory barrier on systems with weakly-ordered memory architectures. * * @param oldValue The value to compare at address. * @param newValue The value to write to address if oldValue compares true. * @param address The 4-byte aligned address of the data to update atomically. * @result true if newValue was written to the address. */ extern Boolean OSCompareAndSwap( UInt32 oldValue, UInt32 newValue, volatile UInt32 * address); #define OSCompareAndSwap(a, b, c) \ (OSCompareAndSwap(a, b, __SAFE_CAST_PTR(volatile UInt32*,c))) /*! * @function OSCompareAndSwapPtr * * @abstract * Compare and swap operation, performed atomically with respect to all devices that participate in the coherency architecture of the platform. * * @discussion * The OSCompareAndSwapPtr function compares the pointer-sized value at the specified address with oldVal. The value of newValue is written to the address only if oldValue and the value at the address are equal. OSCompareAndSwapPtr returns true if newValue is written to the address; otherwise, it returns false. * * This function guarantees atomicity only with main system memory. It is specifically unsuitable for use on noncacheable memory such as that in devices; this function cannot guarantee atomicity, for example, on memory mapped from a PCI device. Additionally, this function incorporates a memory barrier on systems with weakly-ordered memory architectures. * @param oldValue The pointer value to compare at address. * @param newValue The pointer value to write to address if oldValue compares true. * @param address The pointer-size aligned address of the data to update atomically. * @result true if newValue was written to the address. */ extern Boolean OSCompareAndSwapPtr( void * oldValue, void * newValue, void * volatile * address); #define OSCompareAndSwapPtr(a, b, c) \ (OSCompareAndSwapPtr(a, b, __SAFE_CAST_PTR(void * volatile *,c))) /*! * @function OSAddAtomic * * @abstract * 32-bit add operation, performed atomically with respect to all devices that participate in the coherency architecture of the platform. * * @discussion * The OSAddAtomic function adds the specified amount to the value at the specified address and returns the original value. * * This function guarantees atomicity only with main system memory. It is specifically unsuitable for use on noncacheable memory such as that in devices; this function cannot guarantee atomicity, for example, on memory mapped from a PCI device. Previous incarnations of this function incorporated a memory barrier on systems with weakly-ordered memory architectures, but current versions contain no barriers. * @param amount The amount to add. * @param address The 4-byte aligned address of the value to update atomically. * @result The value before the addition */ extern SInt32 OSAddAtomic( SInt32 amount, volatile SInt32 * address); #define OSAddAtomic(a, b) \ (OSAddAtomic(a, __SAFE_CAST_PTR(volatile SInt32*,b))) /*! * @function OSAddAtomic16 * * @abstract * 16-bit add operation, performed atomically with respect to all devices that participate in the coherency architecture of the platform. * * @discussion * The OSAddAtomic16 function adds the specified amount to the value at the specified address and returns the original value. * * This function guarantees atomicity only with main system memory. It is specifically unsuitable for use on noncacheable memory such as that in devices; this function cannot guarantee atomicity, for example, on memory mapped from a PCI device. Previous incarnations of this function incorporated a memory barrier on systems with weakly-ordered memory architectures, but current versions contain no barriers. * @param address The 2-byte aligned address of the value to update atomically. * @result The value before the addition */ extern SInt16 OSAddAtomic16( SInt32 amount, volatile SInt16 * address); /*! * @function OSAddAtomic8 * * @abstract * 8-bit add operation, performed atomically with respect to all devices that participate in the coherency architecture of the platform. * * @discussion * The OSAddAtomic8 function adds the specified amount to the value at the specified address and returns the original value. * * This function guarantees atomicity only with main system memory. It is specifically unsuitable for use on noncacheable memory such as that in devices; this function cannot guarantee atomicity, for example, on memory mapped from a PCI device. Previous incarnations of this function incorporated a memory barrier on systems with weakly-ordered memory architectures, but current versions contain no barriers. * @param amount The amount to add. * @param address The address of the value to update atomically. * @result The value before the addition. */ extern SInt8 OSAddAtomic8( SInt32 amount, volatile SInt8 * address); /*! * @function OSIncrementAtomic * * @abstract * 32-bit increment operation, performed atomically with respect to all devices that participate in the coherency architecture of the platform. * * @discussion * The OSIncrementAtomic function increments the value at the specified address by one and returns the original value. * * This function guarantees atomicity only with main system memory. It is specifically unsuitable for use on noncacheable memory such as that in devices; this function cannot guarantee atomicity, for example, on memory mapped from a PCI device. * @param address The 4-byte aligned address of the value to update atomically. * @result The value before the increment. */ extern SInt32 OSIncrementAtomic(volatile SInt32 * address); #define OSIncrementAtomic(a) \ (OSIncrementAtomic(__SAFE_CAST_PTR(volatile SInt32*,a))) /*! * @function OSIncrementAtomic16 * * @abstract * 16-bit increment operation, performed atomically with respect to all devices that participate in the coherency architecture of the platform. * * @discussion * The OSIncrementAtomic16 function increments the value at the specified address by one and returns the original value. * * This function guarantees atomicity only with main system memory. It is specifically unsuitable for use on noncacheable memory such as that in devices; this function cannot guarantee atomicity, for example, on memory mapped from a PCI device. Previous incarnations of this function incorporated a memory barrier on systems with weakly-ordered memory architectures, but current versions contain no barriers. * @param address The 2-byte aligned address of the value to update atomically. * @result The value before the increment. */ extern SInt16 OSIncrementAtomic16(volatile SInt16 * address); /*! * @function OSIncrementAtomic8 * * @abstract * 8-bit increment operation, performed atomically with respect to all devices that participate in the coherency architecture of the platform. * * @discussion * The OSIncrementAtomic8 function increments the value at the specified address by one and returns the original value. * * This function guarantees atomicity only with main system memory. It is specifically unsuitable for use on noncacheable memory such as that in devices; this function cannot guarantee atomicity, for example, on memory mapped from a PCI device. Previous incarnations of this function incorporated a memory barrier on systems with weakly-ordered memory architectures, but current versions contain no barriers. * @param address The address of the value to update atomically. * @result The value before the increment. */ extern SInt8 OSIncrementAtomic8(volatile SInt8 * address); /*! * @function OSDecrementAtomic * * @abstract * 32-bit decrement operation, performed atomically with respect to all devices that participate in the coherency architecture of the platform. * * @discussion * The OSDecrementAtomic function decrements the value at the specified address by one and returns the original value. * * This function guarantees atomicity only with main system memory. It is specifically unsuitable for use on noncacheable memory such as that in devices; this function cannot guarantee atomicity, for example, on memory mapped from a PCI device. Previous incarnations of this function incorporated a memory barrier on systems with weakly-ordered memory architectures, but current versions contain no barriers. * @param address The 4-byte aligned address of the value to update atomically. * @result The value before the decrement. */ extern SInt32 OSDecrementAtomic(volatile SInt32 * address); #define OSDecrementAtomic(a) \ (OSDecrementAtomic(__SAFE_CAST_PTR(volatile SInt32*,a))) /*! * @function OSDecrementAtomic16 * * @abstract * 16-bit decrement operation, performed atomically with respect to all devices that participate in the coherency architecture of the platform. * * @discussion * The OSDecrementAtomic16 function decrements the value at the specified address by one and returns the original value. * * This function guarantees atomicity only with main system memory. It is specifically unsuitable for use on noncacheable memory such as that in devices; this function cannot guarantee atomicity, for example, on memory mapped from a PCI device. Previous incarnations of this function incorporated a memory barrier on systems with weakly-ordered memory architectures, but current versions contain no barriers. * @param address The 2-byte aligned address of the value to update atomically. * @result The value before the decrement. */ extern SInt16 OSDecrementAtomic16(volatile SInt16 * address); /*! * @function OSDecrementAtomic8 * * @abstract * 8-bit decrement operation, performed atomically with respect to all devices that participate in the coherency architecture of the platform. * * @discussion * The OSDecrementAtomic8 function decrements the value at the specified address by one and returns the original value. * * This function guarantees atomicity only with main system memory. It is specifically unsuitable for use on noncacheable memory such as that in devices; this function cannot guarantee atomicity, for example, on memory mapped from a PCI device. Previous incarnations of this function incorporated a memory barrier on systems with weakly-ordered memory architectures, but current versions contain no barriers. * @param address The address of the value to update atomically. * @result The value before the decrement. */ extern SInt8 OSDecrementAtomic8(volatile SInt8 * address); /*! * @function OSBitAndAtomic * * @abstract * 32-bit logical and operation, performed atomically with respect to all devices that participate in the coherency architecture of the platform. * * @discussion * The OSBitAndAtomic function logically ands the bits of the specified mask into the value at the specified address and returns the original value. * * This function guarantees atomicity only with main system memory. It is specifically unsuitable for use on noncacheable memory such as that in devices; this function cannot guarantee atomicity, for example, on memory mapped from a PCI device. Previous incarnations of this function incorporated a memory barrier on systems with weakly-ordered memory architectures, but current versions contain no barriers.. * @param mask The mask to logically and with the value. * @param address The 4-byte aligned address of the value to update atomically. * @result The value before the bitwise operation */ extern UInt32 OSBitAndAtomic( UInt32 mask, volatile UInt32 * address); #define OSBitAndAtomic(a, b) \ (OSBitAndAtomic(a, __SAFE_CAST_PTR(volatile UInt32*,b))) /*! * @function OSBitAndAtomic16 * * @abstract * 16-bit logical and operation, performed atomically with respect to all devices that participate in the coherency architecture of the platform. * * @discussion * The OSBitAndAtomic16 function logically ands the bits of the specified mask into the value at the specified address and returns the original value. * * This function guarantees atomicity only with main system memory. It is specifically unsuitable for use on noncacheable memory such as that in devices; this function cannot guarantee atomicity, for example, on memory mapped from a PCI device. * @param mask The mask to logically and with the value. * @param address The 2-byte aligned address of the value to update atomically. * @result The value before the bitwise operation. */ extern UInt16 OSBitAndAtomic16( UInt32 mask, volatile UInt16 * address); /*! * @function OSBitAndAtomic8 * * @abstract * 8-bit logical and operation, performed atomically with respect to all devices that participate in the coherency architecture of the platform. * * @discussion * The OSBitAndAtomic8 function logically ands the bits of the specified mask into the value at the specified address and returns the original value. * * This function guarantees atomicity only with main system memory. It is specifically unsuitable for use on noncacheable memory such as that in devices; this function cannot guarantee atomicity, for example, on memory mapped from a PCI device. * @param mask The mask to logically and with the value. * @param address The address of the value to update atomically. * @result The value before the bitwise operation. */ extern UInt8 OSBitAndAtomic8( UInt32 mask, volatile UInt8 * address); /*! * @function OSBitOrAtomic * * @abstract * 32-bit logical or operation, performed atomically with respect to all devices that participate in the coherency architecture of the platform. * * @discussion * The OSBitOrAtomic function logically ors the bits of the specified mask into the value at the specified address and returns the original value. * * This function guarantees atomicity only with main system memory. It is specifically unsuitable for use on noncacheable memory such as that in devices; this function cannot guarantee atomicity, for example, on memory mapped from a PCI device. * @param mask The mask to logically or with the value. * @param address The 4-byte aligned address of the value to update atomically. * @result The value before the bitwise operation. */ extern UInt32 OSBitOrAtomic( UInt32 mask, volatile UInt32 * address); #define OSBitOrAtomic(a, b) \ (OSBitOrAtomic(a, __SAFE_CAST_PTR(volatile UInt32*,b))) /*! * @function OSBitOrAtomic16 * * @abstract * 16-bit logical or operation, performed atomically with respect to all devices that participate in the coherency architecture of the platform. * * @discussion * The OSBitOrAtomic16 function logically ors the bits of the specified mask into the value at the specified address and returns the original value. * * This function guarantees atomicity only with main system memory. It is specifically unsuitable for use on noncacheable memory such as that in devices; this function cannot guarantee atomicity, for example, on memory mapped from a PCI device. * @param mask The mask to logically or with the value. * @param address The 2-byte aligned address of the value to update atomically. * @result The value before the bitwise operation. */ extern UInt16 OSBitOrAtomic16( UInt32 mask, volatile UInt16 * address); /*! * @function OSBitOrAtomic8 * * @abstract * 8-bit logical or operation, performed atomically with respect to all devices that participate in the coherency architecture of the platform. * * This function guarantees atomicity only with main system memory. It is specifically unsuitable for use on noncacheable memory such as that in devices; this function cannot guarantee atomicity, for example, on memory mapped from a PCI device. * * @discussion * The OSBitOrAtomic8 function logically ors the bits of the specified mask into the value at the specified address and returns the original value. * @param mask The mask to logically or with the value. * @param address The address of the value to update atomically. * @result The value before the bitwise operation. */ extern UInt8 OSBitOrAtomic8( UInt32 mask, volatile UInt8 * address); /*! * @function OSBitXorAtomic * * @abstract * 32-bit logical xor operation, performed atomically with respect to all devices that participate in the coherency architecture of the platform. * * This function guarantees atomicity only with main system memory. It is specifically unsuitable for use on noncacheable memory such as that in devices; this function cannot guarantee atomicity, for example, on memory mapped from a PCI device. * * @discussion * The OSBitXorAtomic function logically xors the bits of the specified mask into the value at the specified address and returns the original value. * @param mask The mask to logically or with the value. * @param address The 4-byte aligned address of the value to update atomically. * @result The value before the bitwise operation. */ extern UInt32 OSBitXorAtomic( UInt32 mask, volatile UInt32 * address); #define OSBitXorAtomic(a, b) \ (OSBitXorAtomic(a, __SAFE_CAST_PTR(volatile UInt32*,b))) /*! * @function OSBitXorAtomic16 * * @abstract * 16-bit logical xor operation, performed atomically with respect to all devices that participate in the coherency architecture of the platform. * * @discussion * The OSBitXorAtomic16 function logically xors the bits of the specified mask into the value at the specified address and returns the original value. * * This function guarantees atomicity only with main system memory. It is specifically unsuitable for use on noncacheable memory such as that in devices; this function cannot guarantee atomicity, for example, on memory mapped from a PCI device. * @param mask The mask to logically or with the value. * @param address The 2-byte aligned address of the value to update atomically. * @result The value before the bitwise operation. */ extern UInt16 OSBitXorAtomic16( UInt32 mask, volatile UInt16 * address); /*! * @function OSBitXorAtomic8 * * @abstract * 8-bit logical xor operation, performed atomically with respect to all devices that participate in the coherency architecture of the platform. * * This function guarantees atomicity only with main system memory. It is specifically unsuitable for use on noncacheable memory such as that in devices; this function cannot guarantee atomicity, for example, on memory mapped from a PCI device. * * @discussion * The OSBitXorAtomic8 function logically xors the bits of the specified mask into the value at the specified address and returns the original value. * @param mask The mask to logically or with the value. * @param address The address of the value to update atomically. * @result The value before the bitwise operation. */ extern UInt8 OSBitXorAtomic8( UInt32 mask, volatile UInt8 * address); /*! * @function OSTestAndSet * * @abstract * Bit test and set operation, performed atomically with respect to all devices that participate in the coherency architecture of the platform. * * This function guarantees atomicity only with main system memory. It is specifically unsuitable for use on noncacheable memory such as that in devices; this function cannot guarantee atomicity, for example, on memory mapped from a PCI device. * * @discussion * The OSTestAndSet function sets a single bit in a byte at a specified address. It returns true if the bit was already set, false otherwise. * @param bit The bit number in the range 0 through 7. Bit 0 is the most significant. * @param startAddress The address of the byte to update atomically. * @result true if the bit was already set, false otherwise. */ extern Boolean OSTestAndSet( UInt32 bit, volatile UInt8 * startAddress); /*! * @function OSTestAndClear * * @abstract * Bit test and clear operation, performed atomically with respect to all devices that participate in the coherency architecture of the platform. * * @discussion * The OSTestAndClear function clears a single bit in a byte at a specified address. It returns true if the bit was already clear, false otherwise. * * This function guarantees atomicity only with main system memory. It is specifically unsuitable for use on noncacheable memory such as that in devices; this function cannot guarantee atomicity, for example, on memory mapped from a PCI device. * @param bit The bit number in the range 0 through 7. Bit 0 is the most significant. * @param startAddress The address of the byte to update atomically. * @result true if the bit was already clear, false otherwise. */ extern Boolean OSTestAndClear( UInt32 bit, volatile UInt8 * startAddress); /*! * @defined OS_SPINLOCK_INIT * * @abstract * The default value for an OSSpinLock. * * @discussion * The convention is that unlocked is zero, locked is nonzero. */ #define OS_SPINLOCK_INIT 0 /*! * @typedef OSSpinLock * * @abstract * Data type for a spinlock. * * @discussion * You should always initialize a spinlock to OS_SPINLOCK_INIT before using it. */ typedef SInt32 OSSpinLock; /*! * @function OSSynchronizeIO * * @abstract * The OSSynchronizeIO routine ensures orderly load and store operations to noncached memory mapped I/O devices. * * @discussion * The OSSynchronizeIO routine ensures orderly load and store operations to noncached memory mapped I/O devices. It executes the eieio instruction on PowerPC processors. */ #if defined(__arm__) || defined(__arm64__) extern void OSSynchronizeIO(void); #else static __inline__ void OSSynchronizeIO(void) { } #endif #if defined(__cplusplus) } #endif #endif /* ! _OS_OSATOMIC_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/sysctl.h
/* * Copyright (c) 2003-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@ */ #ifndef LIBKERN_SYSCTL_H #define LIBKERN_SYSCTL_H #include <sys/cdefs.h> __BEGIN_DECLS #include <sys/types.h> /* * These are the support HW selectors for sysctlbyname. Parameters that are byte counts or frequencies are 64 bit numbers. * All other parameters are 32 bit numbers. * * hw.memsize - The number of bytes of physical memory in the system. * * hw.ncpu - The maximum number of processors that could be available this boot. * Use this value for sizing of static per processor arrays; i.e. processor load statistics. * * hw.activecpu - The number of processors currently available for executing threads. * Use this number to determine the number threads to create in SMP aware applications. * This number can change when power management modes are changed. * * hw.physicalcpu - The number of physical processors available in the current power management mode. * hw.physicalcpu_max - The maximum number of physical processors that could be available this boot * * hw.logicalcpu - The number of logical processors available in the current power management mode. * hw.logicalcpu_max - The maximum number of logical processors that could be available this boot * * hw.tbfrequency - This gives the time base frequency used by the OS and is the basis of all timing services. * In general is is better to use mach's or higher level timing services, but this value * is needed to convert the PPC Time Base registers to real time. * * hw.cpufrequency - These values provide the current, min and max cpu frequency. The min and max are for * hw.cpufrequency_max - all power management modes. The current frequency is the max frequency in the current mode. * hw.cpufrequency_min - All frequencies are in Hz. * * hw.busfrequency - These values provide the current, min and max bus frequency. The min and max are for * hw.busfrequency_max - all power management modes. The current frequency is the max frequency in the current mode. * hw.busfrequency_min - All frequencies are in Hz. * * hw.cputype - These values provide the mach-o cpu type and subtype. A complete list is in <mach/machine.h> * hw.cpusubtype - These values should be used to determine what processor family the running cpu is from so that * the best binary can be chosen, or the best dynamic code generated. They should not be used * to determine if a given processor feature is available. * hw.cputhreadtype - This value will be present if the processor supports threads. Like hw.cpusubtype this selector * should not be used to infer features, and only used to name the processors thread architecture. * The values are defined in <mach/machine.h> * * hw.byteorder - Gives the byte order of the processor. 4321 for big endian, 1234 for little. * * hw.pagesize - Gives the size in bytes of the pages used by the processor and VM system. * * hw.cachelinesize - Gives the size in bytes of the processor's cache lines. * This value should be use to control the strides of loops that use cache control instructions * like dcbz, dcbt or dcbst. * * hw.l1dcachesize - These values provide the size in bytes of the L1, L2 and L3 caches. If a cache is not present * hw.l1icachesize - then the selector will return and error. * hw.l2cachesize - * hw.l3cachesize - * * * These are the selectors for optional processor features. Selectors that return errors are not support on the system. * Supported features will return 1 if they are recommended or 0 if they are supported but are not expected to help performance. * Future versions of these selectors may return larger values as necessary so it is best to test for non zero. * * hw.optional.floatingpoint - Floating Point Instructions * hw.optional.altivec - AltiVec Instructions * hw.optional.graphicsops - Graphics Operations * hw.optional.64bitops - 64-bit Instructions * hw.optional.fsqrt - HW Floating Point Square Root Instruction * hw.optional.stfiwx - Store Floating Point as Integer Word Indexed Instructions * hw.optional.dcba - Data Cache Block Allocate Instruction * hw.optional.datastreams - Data Streams Instructions * hw.optional.dcbtstreams - Data Cache Block Touch Steams Instruction Form * */ /* * Sysctl handling */ int sysctlbyname(const char *, void *, size_t *, void *, size_t); __END_DECLS #endif /* LIBKERN_SYSCTL_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/_OSByteOrder.h
/* * Copyright (c) 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@ */ #ifndef _OS__OSBYTEORDER_H #define _OS__OSBYTEORDER_H /* * This header is normally included from <libkern/OSByteOrder.h>. However, * <sys/_endian.h> also includes this in the case of little-endian * architectures, so that we can map OSByteOrder routines to the hton* and ntoh* * macros. This results in the asymmetry below; we only include * <libkern/arch/_OSByteOrder.h> for little-endian architectures. */ #include <sys/_types.h> /* Macros for swapping constant values in the preprocessing stage. */ #define __DARWIN_OSSwapConstInt16(x) \ ((__uint16_t)((((__uint16_t)(x) & 0xff00U) >> 8) | \ (((__uint16_t)(x) & 0x00ffU) << 8))) #define __DARWIN_OSSwapConstInt32(x) \ ((__uint32_t)((((__uint32_t)(x) & 0xff000000U) >> 24) | \ (((__uint32_t)(x) & 0x00ff0000U) >> 8) | \ (((__uint32_t)(x) & 0x0000ff00U) << 8) | \ (((__uint32_t)(x) & 0x000000ffU) << 24))) #define __DARWIN_OSSwapConstInt64(x) \ ((__uint64_t)((((__uint64_t)(x) & 0xff00000000000000ULL) >> 56) | \ (((__uint64_t)(x) & 0x00ff000000000000ULL) >> 40) | \ (((__uint64_t)(x) & 0x0000ff0000000000ULL) >> 24) | \ (((__uint64_t)(x) & 0x000000ff00000000ULL) >> 8) | \ (((__uint64_t)(x) & 0x00000000ff000000ULL) << 8) | \ (((__uint64_t)(x) & 0x0000000000ff0000ULL) << 24) | \ (((__uint64_t)(x) & 0x000000000000ff00ULL) << 40) | \ (((__uint64_t)(x) & 0x00000000000000ffULL) << 56))) #if defined(__GNUC__) #if !defined(__DARWIN_OS_INLINE) # if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L # define __DARWIN_OS_INLINE static inline # elif defined(__MWERKS__) || defined(__cplusplus) # define __DARWIN_OS_INLINE static inline # else # define __DARWIN_OS_INLINE static __inline__ # endif #endif #if defined(__i386__) || defined(__x86_64__) #include <libkern/i386/_OSByteOrder.h> #endif #if defined (__arm__) || defined(__arm64__) #include <libkern/arm/OSByteOrder.h> #endif #define __DARWIN_OSSwapInt16(x) \ ((__uint16_t)(__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt16(x) : _OSSwapInt16(x))) #define __DARWIN_OSSwapInt32(x) \ (__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt32(x) : _OSSwapInt32(x)) #define __DARWIN_OSSwapInt64(x) \ (__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt64(x) : _OSSwapInt64(x)) #else /* ! __GNUC__ */ #if defined(__i386__) || defined(__x86_64__) __DARWIN_OS_INLINE uint16_t _OSSwapInt16( uint16_t data ) { return __DARWIN_OSSwapConstInt16(data); } __DARWIN_OS_INLINE uint32_t _OSSwapInt32( uint32_t data ) { return __DARWIN_OSSwapConstInt32(data); } __DARWIN_OS_INLINE uint64_t _OSSwapInt64( uint64_t data ) { return __DARWIN_OSSwapConstInt64(data); } #endif #define __DARWIN_OSSwapInt16(x) _OSSwapInt16(x) #define __DARWIN_OSSwapInt32(x) _OSSwapInt32(x) #define __DARWIN_OSSwapInt64(x) _OSSwapInt64(x) #endif /* __GNUC__ */ #endif /* ! _OS__OSBYTEORDER_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/libkern.h
/* * Copyright (c) 2000-2012 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@ */ /*- * Copyright (c) 1992, 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. * * @(#)libkern.h 8.1 (Berkeley) 6/10/93 */ /* * 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 _LIBKERN_LIBKERN_H_ #define _LIBKERN_LIBKERN_H_ #include <sys/appleapiopts.h> #include <stdint.h> #include <stdarg.h> /* for platform-specific va_list */ #include <string.h> #include <machine/limits.h> #include <sys/cdefs.h> #include <sys/types.h> #include <mach/vm_param.h> #include <libkern/crc.h> #include <libkern/copyio.h> #if defined(__arm__) || defined(__arm64__) #include <arm/arch.h> /* for _ARM_ARCH_* */ #endif #ifdef __APPLE_API_OBSOLETE /* BCD conversions. */ extern u_char const bcd2bin_data[]; extern u_char const bin2bcd_data[]; #define bcd2bin(bcd) (bcd2bin_data[bcd]) #define bin2bcd(bin) (bin2bcd_data[bin]) #endif /* __APPLE_API_OBSOLETE */ #ifdef __APPLE_API_PRIVATE extern char const hex2ascii_data[]; #define hex2ascii(hex) (hex2ascii_data[hex]) #endif /* __APPLE_API_PRIVATE */ __BEGIN_DECLS static inline int imax(int a, int b) { return a > b ? a : b; } static inline int imin(int a, int b) { return a < b ? a : b; } static inline long lmax(long a, long b) { return a > b ? a : b; } static inline long lmin(long a, long b) { return a < b ? a : b; } static inline u_int max(u_int a, u_int b) { return a > b ? a : b; } static inline u_int min(u_int a, u_int b) { return a < b ? a : b; } static inline u_int32_t ulmax(u_int32_t a, u_int32_t b) { return a > b ? a : b; } static inline u_int32_t ulmin(u_int32_t a, u_int32_t b) { return a < b ? a : b; } /* Prototypes for non-quad routines. */ extern int ffs(unsigned int); extern int ffsll(unsigned long long); extern int fls(unsigned int); extern int flsll(unsigned long long); extern u_int32_t random(void); extern size_t scanc(size_t, u_char *, const u_char *, u_char); extern long strtol(const char*, char **, int); extern u_long strtoul(const char *, char **, int); extern quad_t strtoq(const char *, char **, int); extern u_quad_t strtouq(const char *, char **, int); extern char *strsep(char **, const char *); extern void *memchr(const void *, int, size_t); extern void url_decode(char *str); /* * NOTE: snprintf() returns the full length of the formatted string even if it * couldn't fit in the supplied buffer. * Use scnprintf() if you need the actual number of bytes (minus the \0) */ int snprintf(char *, size_t, const char *, ...) __printflike(3, 4); int scnprintf(char *, size_t, const char *, ...) __printflike(3, 4); /* sprintf() is being deprecated. Please use snprintf() instead. */ int sprintf(char *bufp, const char *, ...) __deprecated __printflike(2, 3); int sscanf(const char *, char const *, ...) __scanflike(2, 3); int printf(const char *, ...) __printflike(1, 2); #if CONFIG_NO_PRINTF_STRINGS #define printf(x, ...) do {} while (0) #endif uint16_t crc16(uint16_t crc, const void *bufp, size_t len); uint32_t crc32(uint32_t crc, const void *bufp, size_t len); int copystr(const void *kfaddr, void *kdaddr, size_t len, size_t *done); int copyinstr(const user_addr_t uaddr, void *kaddr, size_t len, size_t *done) OS_WARN_RESULT; int copyoutstr(const void *kaddr, user_addr_t udaddr, size_t len, size_t *done); int vsscanf(const char *, char const *, va_list); extern int vprintf(const char *, va_list) __printflike(1, 0); extern int vsnprintf(char *, size_t, const char *, va_list) __printflike(3, 0); extern int vscnprintf(char *, size_t, const char *, va_list) __printflike(3, 0); /* vsprintf() is being deprecated. Please use vsnprintf() instead. */ extern int vsprintf(char *bufp, const char *, va_list) __deprecated __printflike(2, 0); extern void invalidate_icache(vm_offset_t, unsigned, int); extern void flush_dcache(vm_offset_t, unsigned, int); extern void invalidate_icache64(addr64_t, unsigned, int); extern void flush_dcache64(addr64_t, unsigned, int); static inline int clz(unsigned int num) { #if (__arm__ || __arm64__) // On ARM, clz(0) is defined to return number of bits in the input type return __builtin_clz(num); #else // On Intel, clz(0) is undefined return num ? __builtin_clz(num) : sizeof(num) * CHAR_BIT; #endif } __END_DECLS #endif /* _LIBKERN_LIBKERN_H_ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/OSReturn.h
/* * Copyright (c) 2000 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@ */ /* * Copyright (c) 1998 Apple Inc. All rights reserved. * * HISTORY * */ /* * Core OSReturn values. */ #ifndef __LIBKERN_OSRETURN_H #define __LIBKERN_OSRETURN_H #include <sys/cdefs.h> __BEGIN_DECLS #include <mach/error.h> /*! * @header * * Declares functions, basic return values, and other constants * related to kernel extensions (kexts). */ #if PRAGMA_MARK #pragma mark Core OSReturn Values for Libkern #endif /********************************************************************* * Core OSReturn Values for Libkern *********************************************************************/ /*! * @group Core OSReturn Values for Libkern * Some kext and I/O Kit functions can return these values, * as well as other values of * <code>kern_return_t</code>. * * Many of these return values represent internal errors * in the Libkern C++ run-time typing information system * based on @link //apple_ref/doc/class/OSMetaClass OSMetaClass@/link; * you are unlikely to ever see them. * */ /*! * @typedef OSReturn * @abstract The return type for many Libkern functions. */ typedef kern_return_t OSReturn; #ifndef sys_libkern #define sys_libkern err_system(0x37) #endif /* sys_libkern */ #define sub_libkern_common err_sub(0) #define sub_libkern_metaclass err_sub(1) #define sub_libkern_reserved err_sub(-1) #define libkern_common_err(return ) (sys_libkern|sub_libkern_common|(return)) #define libkern_metaclass_err(return ) (sys_libkern|sub_libkern_metaclass|(return)) /* See OSKextLib.h for these * #define sub_libkern_kext err_sub(2) * #define libkern_kext_err(code) (sys_libkern|sub_libkern_kext|(code)) */ /*! * @define kOSReturnSuccess * @abstract Operation successful. * Equal to <code>@link //apple_ref/c/econst/KERN_SUCCESS * KERN_SUCCESS@/link</code>. */ #define kOSReturnSuccess KERN_SUCCESS /*! * @define kOSReturnError * @abstract Unspecified Libkern error. * <b>Not equal</b> to * <code>@link //apple_ref/c/econst/KERN_FAILURE * KERN_FAILURE@/link</code>. */ #define kOSReturnError libkern_common_err(1) /*! * @define kOSMetaClassInternal * @abstract Internal OSMetaClass run-time error. */ #define kOSMetaClassInternal libkern_metaclass_err(1) /*! * @define kOSMetaClassHasInstances * @abstract A kext cannot be unloaded because there are instances * derived from Libkern C++ classes that it defines. */ #define kOSMetaClassHasInstances libkern_metaclass_err(2) /*! * @define kOSMetaClassNoInit * @abstract Internal error: The Libkern C++ class registration system * was not properly initialized during kext loading. */ #define kOSMetaClassNoInit libkern_metaclass_err(3) // OSMetaClass::preModLoad wasn't called, runtime internal error /*! * @define kOSMetaClassNoTempData * @abstract Internal error: An allocation failure occurred * registering Libkern C++ classes during kext loading. */ #define kOSMetaClassNoTempData libkern_metaclass_err(4) // Allocation failure internal data /*! * @define kOSMetaClassNoDicts * @abstract Internal error: An allocation failure occurred * registering Libkern C++ classes during kext loading. */ #define kOSMetaClassNoDicts libkern_metaclass_err(5) // Allocation failure for Metaclass internal dictionaries /*! * @define kOSMetaClassNoKModSet * @abstract Internal error: An allocation failure occurred * registering Libkern C++ classes during kext loading. */ #define kOSMetaClassNoKModSet libkern_metaclass_err(6) // Allocation failure for internal kmodule set /*! * @define kOSMetaClassNoInsKModSet * @abstract Internal error: An error occurred registering * a specific Libkern C++ class during kext loading. */ #define kOSMetaClassNoInsKModSet libkern_metaclass_err(7) // Can't insert the KMod set into the module dictionary /*! * @define kOSMetaClassNoSuper * @abstract Internal error: No superclass can be found * for a specific Libkern C++ class during kext loading. */ #define kOSMetaClassNoSuper libkern_metaclass_err(8) /*! * @define kOSMetaClassInstNoSuper * @abstract Internal error: No superclass can be found when constructing * an instance of a Libkern C++ class. */ #define kOSMetaClassInstNoSuper libkern_metaclass_err(9) /*! * @define kOSMetaClassDuplicateClass * @abstract A duplicate Libkern C++ classname was encountered * during kext loading. */ #define kOSMetaClassDuplicateClass libkern_metaclass_err(10) /*! * @define kOSMetaClassNoKext * @abstract Internal error: The kext for a Libkern C++ class * can't be found during kext loading. */ #define kOSMetaClassNoKext libkern_metaclass_err(11) __END_DECLS #endif /* ! __LIBKERN_OSRETURN_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/copyio.h
/* * Copyright (c) 2017 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 _LIBKERN_COPYIO_H_ #define _LIBKERN_COPYIO_H_ #include <kern/debug.h> __BEGIN_DECLS int copyin(const user_addr_t uaddr, void *kaddr, size_t len) OS_WARN_RESULT; int copyout(const void *kaddr, user_addr_t udaddr, size_t len); #if defined (_FORTIFY_SOURCE) && _FORTIFY_SOURCE == 0 /* FORTIFY_SOURCE disabled */ #else OS_ALWAYS_INLINE OS_WARN_RESULT static inline int __copyin_chk(const user_addr_t uaddr, void *kaddr, size_t len, size_t chk_size) { if (chk_size < len) { panic("__copyin_chk object size check failed: uaddr %p, kaddr %p, (%zu < %zu)", (void*)uaddr, kaddr, len, chk_size); } return copyin(uaddr, kaddr, len); } OS_ALWAYS_INLINE static inline int __copyout_chk(const void *kaddr, user_addr_t uaddr, size_t len, size_t chk_size) { if (chk_size < len) { panic("__copyout_chk object size check failed: uaddr %p, kaddr %p, (%zu < %zu)", (void*)uaddr, kaddr, len, chk_size); } return copyout(kaddr, uaddr, len); } #define copyin(uaddr, kaddr, len) __copyin_chk(uaddr, kaddr, len, __builtin_object_size(kaddr, 0)) #define copyout(kaddr, uaddr, len) __copyout_chk(kaddr, uaddr, len, __builtin_object_size(kaddr, 0)) #endif __END_DECLS #endif /* _LIBKERN_COPYIO_H_ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/OSTypes.h
/* * Copyright (c) 1999-2012 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 _OS_OSTYPES_H #define _OS_OSTYPES_H #define OSTYPES_K64_REV 2 typedef unsigned int UInt; typedef signed int SInt; typedef unsigned char UInt8; typedef unsigned short UInt16; #if __LP64__ typedef unsigned int UInt32; #else typedef unsigned long UInt32; #endif typedef unsigned long long UInt64; #if defined(__BIG_ENDIAN__) typedef struct __attribute__((deprecated)) UnsignedWide { UInt32 hi; UInt32 lo; } UnsignedWide __attribute__((deprecated)); #elif defined(__LITTLE_ENDIAN__) typedef struct __attribute__((deprecated)) UnsignedWide { UInt32 lo; UInt32 hi; } UnsignedWide __attribute__((deprecated)); #else #error Unknown endianess. #endif typedef signed char SInt8; typedef signed short SInt16; #if __LP64__ typedef signed int SInt32; #else typedef signed long SInt32; #endif typedef signed long long SInt64; typedef SInt32 OSStatus; #ifndef ABSOLUTETIME_SCALAR_TYPE #define ABSOLUTETIME_SCALAR_TYPE 1 #endif typedef UInt64 AbsoluteTime; typedef UInt32 OptionBits __attribute__((deprecated)); #if defined(__LP64__) /* * Use intrinsic boolean types for the LP64 kernel, otherwise maintain * source and binary backward compatibility. This attempts to resolve * the "(x == true)" vs. "(x)" conditional issue. */ #ifdef __cplusplus typedef bool Boolean; #else /* !__cplusplus */ #if defined(__STDC_VERSION__) && ((__STDC_VERSION__ - 199901L) > 0L) /* only use this if we are sure we are using a c99 compiler */ typedef _Bool Boolean; #else /* !c99 */ /* Fall back to previous definition unless c99 */ typedef unsigned char Boolean; #endif /* !c99 */ #endif /* !__cplusplus */ #else /* !__LP64__ */ typedef unsigned char Boolean; #endif /* !__LP64__ */ #include <sys/_types/_os_inline.h> #endif /* _OS_OSTYPES_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/tree.h
/* * Copyright (c) 2009-2019 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@ */ /* $NetBSD: tree.h,v 1.13 2006/08/27 22:32:38 christos Exp $ */ /* $OpenBSD: tree.h,v 1.7 2002/10/17 21:51:54 art Exp $ */ /* * Copyright 2002 Niels Provos <[email protected]> * 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 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 _LIBKERN_TREE_H_ #define _LIBKERN_TREE_H_ /* * This file defines data structures for different types of trees: * splay trees and red-black trees. * * A splay tree is a self-organizing data structure. Every operation * on the tree causes a splay to happen. The splay moves the requested * node to the root of the tree and partly rebalances it. * * This has the benefit that request locality causes faster lookups as * the requested nodes move to the top of the tree. On the other hand, * every lookup causes memory writes. * * The Balance Theorem bounds the total access time for m operations * and n inserts on an initially empty tree as O((m + n)lg n). The * amortized cost for a sequence of m accesses to a splay tree is O(lg n); * * A red-black tree is a binary search tree with the node color as an * extra attribute. It fulfills a set of conditions: * - every search path from the root to a leaf consists of the * same number of black nodes, * - each red node (except for the root) has a black parent, * - each leaf node is black. * * Every operation on a red-black tree is bounded as O(lg n). * The maximum height of a red-black tree is 2lg (n+1). */ #define SPLAY_HEAD(name, type) \ struct name { \ struct type *sph_root; /* root of the tree */ \ } #define SPLAY_INITIALIZER(root) \ { NULL } #define SPLAY_INIT(root) do { \ (root)->sph_root = NULL; \ } while ( /*CONSTCOND*/ 0) #define SPLAY_ENTRY(type) \ struct { \ struct type *spe_left; /* left element */ \ struct type *spe_right; /* right element */ \ } #define SPLAY_LEFT(elm, field) (elm)->field.spe_left #define SPLAY_RIGHT(elm, field) (elm)->field.spe_right #define SPLAY_ROOT(head) (head)->sph_root #define SPLAY_EMPTY(head) (SPLAY_ROOT(head) == NULL) /* SPLAY_ROTATE_{LEFT,RIGHT} expect that tmp hold SPLAY_{RIGHT,LEFT} */ #define SPLAY_ROTATE_RIGHT(head, tmp, field) do { \ SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field); \ SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ (head)->sph_root = tmp; \ } while ( /*CONSTCOND*/ 0) #define SPLAY_ROTATE_LEFT(head, tmp, field) do { \ SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \ SPLAY_LEFT(tmp, field) = (head)->sph_root; \ (head)->sph_root = tmp; \ } while ( /*CONSTCOND*/ 0) #define SPLAY_LINKLEFT(head, tmp, field) do { \ SPLAY_LEFT(tmp, field) = (head)->sph_root; \ tmp = (head)->sph_root; \ (head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \ } while ( /*CONSTCOND*/ 0) #define SPLAY_LINKRIGHT(head, tmp, field) do { \ SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ tmp = (head)->sph_root; \ (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \ } while ( /*CONSTCOND*/ 0) #define SPLAY_ASSEMBLE(head, node, left, right, field) do { \ SPLAY_RIGHT(left, field) = SPLAY_LEFT((head)->sph_root, field); \ SPLAY_LEFT(right, field) = SPLAY_RIGHT((head)->sph_root, field);\ SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(node, field); \ SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(node, field); \ } while ( /*CONSTCOND*/ 0) /* Generates prototypes and inline functions */ #define SPLAY_PROTOTYPE(name, type, field, cmp) \ void name##_SPLAY(struct name *, struct type *); \ void name##_SPLAY_MINMAX(struct name *, int); \ struct type *name##_SPLAY_INSERT(struct name *, struct type *); \ struct type *name##_SPLAY_REMOVE(struct name *, struct type *); \ \ /* Finds the node with the same key as elm */ \ static __inline struct type * \ name##_SPLAY_FIND(struct name *head, struct type *elm) \ { \ if (SPLAY_EMPTY(head)) \ return(NULL); \ name##_SPLAY(head, elm); \ if ((cmp)(elm, (head)->sph_root) == 0) \ return (head->sph_root); \ return (NULL); \ } \ \ static __inline struct type * \ name##_SPLAY_NEXT(struct name *head, struct type *elm) \ { \ name##_SPLAY(head, elm); \ if (SPLAY_RIGHT(elm, field) != NULL) { \ elm = SPLAY_RIGHT(elm, field); \ while (SPLAY_LEFT(elm, field) != NULL) { \ elm = SPLAY_LEFT(elm, field); \ } \ } else \ elm = NULL; \ return (elm); \ } \ \ static __inline struct type * \ name##_SPLAY_MIN_MAX(struct name *head, int val) \ { \ name##_SPLAY_MINMAX(head, val); \ return (SPLAY_ROOT(head)); \ } /* Main splay operation. * Moves node close to the key of elm to top */ #define SPLAY_GENERATE(name, type, field, cmp) \ struct type * \ name##_SPLAY_INSERT(struct name *head, struct type *elm) \ { \ if (SPLAY_EMPTY(head)) { \ SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \ } else { \ int __comp; \ name##_SPLAY(head, elm); \ __comp = (cmp)(elm, (head)->sph_root); \ if(__comp < 0) { \ SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field);\ SPLAY_RIGHT(elm, field) = (head)->sph_root; \ SPLAY_LEFT((head)->sph_root, field) = NULL; \ } else if (__comp > 0) { \ SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field);\ SPLAY_LEFT(elm, field) = (head)->sph_root; \ SPLAY_RIGHT((head)->sph_root, field) = NULL; \ } else \ return ((head)->sph_root); \ } \ (head)->sph_root = (elm); \ return (NULL); \ } \ \ struct type * \ name##_SPLAY_REMOVE(struct name *head, struct type *elm) \ { \ struct type *__tmp; \ if (SPLAY_EMPTY(head)) \ return (NULL); \ name##_SPLAY(head, elm); \ if ((cmp)(elm, (head)->sph_root) == 0) { \ if (SPLAY_LEFT((head)->sph_root, field) == NULL) { \ (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field);\ } else { \ __tmp = SPLAY_RIGHT((head)->sph_root, field); \ (head)->sph_root = SPLAY_LEFT((head)->sph_root, field);\ name##_SPLAY(head, elm); \ SPLAY_RIGHT((head)->sph_root, field) = __tmp; \ } \ return (elm); \ } \ return (NULL); \ } \ \ void \ name##_SPLAY(struct name *head, struct type *elm) \ { \ struct type __node, *__left, *__right, *__tmp; \ int __comp; \ \ SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\ __left = __right = &__node; \ \ while ((__comp = (cmp)(elm, (head)->sph_root)) != 0) { \ if (__comp < 0) { \ __tmp = SPLAY_LEFT((head)->sph_root, field); \ if (__tmp == NULL) \ break; \ if ((cmp)(elm, __tmp) < 0){ \ SPLAY_ROTATE_RIGHT(head, __tmp, field); \ if (SPLAY_LEFT((head)->sph_root, field) == NULL)\ break; \ } \ SPLAY_LINKLEFT(head, __right, field); \ } else if (__comp > 0) { \ __tmp = SPLAY_RIGHT((head)->sph_root, field); \ if (__tmp == NULL) \ break; \ if ((cmp)(elm, __tmp) > 0){ \ SPLAY_ROTATE_LEFT(head, __tmp, field); \ if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\ break; \ } \ SPLAY_LINKRIGHT(head, __left, field); \ } \ } \ SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ } \ \ /* Searches for a matching entry without splaying */ \ static __inline struct type * \ name##_SPLAY_SEARCH(struct name *head, struct type *elm) \ { \ struct type *__tmp = NULL; \ int __comp; \ \ __tmp = (head)->sph_root; \ while ((__tmp != NULL) && ((__comp = (cmp)(elm, __tmp)) != 0)) { \ if (__comp < 0) { \ __tmp = SPLAY_LEFT(__tmp, field); \ } else { \ __tmp = SPLAY_RIGHT(__tmp, field); \ } \ } \ return __tmp; \ } \ \ /* Splay with either the minimum or the maximum element \ * Used to find minimum or maximum element in tree. \ */ \ void name##_SPLAY_MINMAX(struct name *head, int __comp) \ { \ struct type __node, *__left, *__right, *__tmp; \ \ SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\ __left = __right = &__node; \ \ while (1) { \ if (__comp < 0) { \ __tmp = SPLAY_LEFT((head)->sph_root, field); \ if (__tmp == NULL) \ break; \ if (__comp < 0){ \ SPLAY_ROTATE_RIGHT(head, __tmp, field); \ if (SPLAY_LEFT((head)->sph_root, field) == NULL)\ break; \ } \ SPLAY_LINKLEFT(head, __right, field); \ } else if (__comp > 0) { \ __tmp = SPLAY_RIGHT((head)->sph_root, field); \ if (__tmp == NULL) \ break; \ if (__comp > 0) { \ SPLAY_ROTATE_LEFT(head, __tmp, field); \ if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\ break; \ } \ SPLAY_LINKRIGHT(head, __left, field); \ } \ } \ SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ } #define SPLAY_NEGINF -1 #define SPLAY_INF 1 #define SPLAY_INSERT(name, x, y) name##_SPLAY_INSERT(x, y) #define SPLAY_REMOVE(name, x, y) name##_SPLAY_REMOVE(x, y) #define SPLAY_FIND(name, x, y) name##_SPLAY_FIND(x, y) #define SPLAY_SEARCH(name, x, y) name##_SPLAY_SEARCH(x, y) #define SPLAY_NEXT(name, x, y) name##_SPLAY_NEXT(x, y) #define SPLAY_MIN(name, x) (SPLAY_EMPTY(x) ? NULL \ : name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF)) #define SPLAY_MAX(name, x) (SPLAY_EMPTY(x) ? NULL \ : name##_SPLAY_MIN_MAX(x, SPLAY_INF)) #define SPLAY_FOREACH(x, name, head) \ for ((x) = SPLAY_MIN(name, head); \ (x) != NULL; \ (x) = SPLAY_NEXT(name, head, x)) /* Macros that define a red-black tree */ #define RB_HEAD(name, type) \ struct name { \ struct type *rbh_root; /* root of the tree */ \ } #define RB_INITIALIZER(root) \ { NULL } #define RB_INIT(root) do { \ (root)->rbh_root = NULL; \ } while ( /*CONSTCOND*/ 0) #define RB_BLACK 0 #define RB_RED 1 #define RB_PLACEHOLDER NULL #define RB_ENTRY(type) \ struct { \ struct type *rbe_left; /* left element */ \ struct type *rbe_right; /* right element */ \ struct type *rbe_parent; /* parent element */ \ } #define RB_COLOR_MASK (uintptr_t)0x1 #define RB_LEFT(elm, field) (elm)->field.rbe_left #define RB_RIGHT(elm, field) (elm)->field.rbe_right #define _RB_PARENT(elm, field) (elm)->field.rbe_parent #define RB_ROOT(head) (head)->rbh_root #define RB_EMPTY(head) (RB_ROOT(head) == NULL) #define RB_SET(name, elm, parent, field) do { \ name##_RB_SETPARENT(elm, parent); \ RB_LEFT(elm, field) = RB_RIGHT(elm, field) = NULL; \ name##_RB_SETCOLOR(elm, RB_RED); \ } while ( /*CONSTCOND*/ 0) #define RB_SET_BLACKRED(name, black, red, field) do { \ name##_RB_SETCOLOR(black, RB_BLACK); \ name##_RB_SETCOLOR(red, RB_RED); \ } while ( /*CONSTCOND*/ 0) #ifndef RB_AUGMENT #define RB_AUGMENT(x) (void)(x) #endif #define RB_ROTATE_LEFT(name, head, elm, tmp, field) do { \ (tmp) = RB_RIGHT(elm, field); \ if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field)) != NULL) { \ name##_RB_SETPARENT(RB_LEFT(tmp, field),(elm)); \ } \ RB_AUGMENT(elm); \ if (name##_RB_SETPARENT(tmp, name##_RB_GETPARENT(elm)) != NULL) { \ if ((elm) == RB_LEFT(name##_RB_GETPARENT(elm), field)) \ RB_LEFT(name##_RB_GETPARENT(elm), field) = (tmp); \ else \ RB_RIGHT(name##_RB_GETPARENT(elm), field) = (tmp); \ } else \ (head)->rbh_root = (tmp); \ RB_LEFT(tmp, field) = (elm); \ name##_RB_SETPARENT(elm, (tmp)); \ RB_AUGMENT(tmp); \ if ((name##_RB_GETPARENT(tmp))) \ RB_AUGMENT(name##_RB_GETPARENT(tmp)); \ } while ( /*CONSTCOND*/ 0) #define RB_ROTATE_RIGHT(name, head, elm, tmp, field) do { \ (tmp) = RB_LEFT(elm, field); \ if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field)) != NULL) { \ name##_RB_SETPARENT(RB_RIGHT(tmp, field), (elm)); \ } \ RB_AUGMENT(elm); \ if (name##_RB_SETPARENT(tmp, name##_RB_GETPARENT(elm)) != NULL) { \ if ((elm) == RB_LEFT(name##_RB_GETPARENT(elm), field)) \ RB_LEFT(name##_RB_GETPARENT(elm), field) = (tmp); \ else \ RB_RIGHT(name##_RB_GETPARENT(elm), field) = (tmp); \ } else \ (head)->rbh_root = (tmp); \ RB_RIGHT(tmp, field) = (elm); \ name##_RB_SETPARENT(elm, tmp); \ RB_AUGMENT(tmp); \ if ((name##_RB_GETPARENT(tmp))) \ RB_AUGMENT(name##_RB_GETPARENT(tmp)); \ } while ( /*CONSTCOND*/ 0) /* Generates prototypes and inline functions */ #define RB_PROTOTYPE(name, type, field, cmp) \ void name##_RB_INSERT_COLOR(struct name *, struct type *); \ void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *);\ struct type *name##_RB_REMOVE(struct name *, struct type *); \ struct type *name##_RB_INSERT(struct name *, struct type *); \ struct type *name##_RB_FIND(struct name *, struct type *); \ struct type *name##_RB_NFIND(struct name *, struct type *); \ struct type *name##_RB_NEXT(struct type *); \ struct type *name##_RB_MINMAX(struct name *, int); \ struct type *name##_RB_GETPARENT(struct type*); \ struct type *name##_RB_SETPARENT(struct type*, struct type*); \ int name##_RB_GETCOLOR(struct type*); \ void name##_RB_SETCOLOR(struct type*,int); /* Generates prototypes (with storage class) and inline functions */ #define RB_PROTOTYPE_SC(_sc_, name, type, field, cmp) \ _sc_ void name##_RB_INSERT_COLOR(struct name *, struct type *); \ _sc_ void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *); \ _sc_ struct type *name##_RB_REMOVE(struct name *, struct type *); \ _sc_ struct type *name##_RB_INSERT(struct name *, struct type *); \ _sc_ struct type *name##_RB_FIND(struct name *, struct type *); \ _sc_ struct type *name##_RB_NFIND(struct name *, struct type *); \ _sc_ struct type *name##_RB_NEXT(struct type *); \ _sc_ struct type *name##_RB_MINMAX(struct name *, int); \ _sc_ struct type *name##_RB_GETPARENT(struct type*); \ _sc_ struct type *name##_RB_SETPARENT(struct type*, struct type*); \ _sc_ int name##_RB_GETCOLOR(struct type*); \ _sc_ void name##_RB_SETCOLOR(struct type*,int) /* Main rb operation. * Moves node close to the key of elm to top */ #define RB_GENERATE(name, type, field, cmp) \ struct type *name##_RB_GETPARENT(struct type *elm) { \ struct type *parent = _RB_PARENT(elm, field); \ if( parent != NULL) { \ parent = (struct type*)((uintptr_t)parent & ~RB_COLOR_MASK);\ return( (struct type*) ( (parent == (struct type*) RB_PLACEHOLDER) ? NULL: parent));\ } \ return((struct type*)NULL); \ } \ int name##_RB_GETCOLOR(struct type *elm) { \ int color = 0; \ color = (int)((uintptr_t)_RB_PARENT(elm,field) & RB_COLOR_MASK);\ return(color); \ } \ void name##_RB_SETCOLOR(struct type *elm,int color) { \ struct type *parent = name##_RB_GETPARENT(elm); \ if(parent == (struct type*)NULL) \ parent = (struct type*) RB_PLACEHOLDER; \ _RB_PARENT(elm, field) = (struct type*)((uintptr_t)parent | (unsigned int)color);\ } \ struct type *name##_RB_SETPARENT(struct type *elm, struct type *parent) { \ int color = name##_RB_GETCOLOR(elm); \ _RB_PARENT(elm, field) = parent; \ if(color) name##_RB_SETCOLOR(elm, color); \ return(name##_RB_GETPARENT(elm)); \ } \ \ void \ name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \ { \ struct type *parent, *gparent, *tmp; \ while ((parent = name##_RB_GETPARENT(elm)) != NULL && \ name##_RB_GETCOLOR(parent) == RB_RED) { \ gparent = name##_RB_GETPARENT(parent); \ if (parent == RB_LEFT(gparent, field)) { \ tmp = RB_RIGHT(gparent, field); \ if (tmp && name##_RB_GETCOLOR(tmp) == RB_RED) { \ name##_RB_SETCOLOR(tmp, RB_BLACK); \ RB_SET_BLACKRED(name, parent, gparent, field);\ elm = gparent; \ continue; \ } \ if (RB_RIGHT(parent, field) == elm) { \ RB_ROTATE_LEFT(name, head, parent, tmp, field);\ tmp = parent; \ parent = elm; \ elm = tmp; \ } \ RB_SET_BLACKRED(name, parent, gparent, field); \ RB_ROTATE_RIGHT(name,head, gparent, tmp, field); \ } else { \ tmp = RB_LEFT(gparent, field); \ if (tmp && name##_RB_GETCOLOR(tmp) == RB_RED) { \ name##_RB_SETCOLOR(tmp, RB_BLACK); \ RB_SET_BLACKRED(name, parent, gparent, field);\ elm = gparent; \ continue; \ } \ if (RB_LEFT(parent, field) == elm) { \ RB_ROTATE_RIGHT(name, head, parent, tmp, field);\ tmp = parent; \ parent = elm; \ elm = tmp; \ } \ RB_SET_BLACKRED(name, parent, gparent, field); \ RB_ROTATE_LEFT(name, head, gparent, tmp, field); \ } \ } \ name##_RB_SETCOLOR(head->rbh_root, RB_BLACK); \ } \ \ void \ name##_RB_REMOVE_COLOR(struct name *head, struct type *parent, struct type *elm) \ { \ struct type *tmp; \ while ((elm == NULL || name##_RB_GETCOLOR(elm) == RB_BLACK) && \ elm != RB_ROOT(head)) { \ if (RB_LEFT(parent, field) == elm) { \ tmp = RB_RIGHT(parent, field); \ if (name##_RB_GETCOLOR(tmp) == RB_RED) { \ RB_SET_BLACKRED(name, tmp, parent, field); \ RB_ROTATE_LEFT(name, head, parent, tmp, field);\ tmp = RB_RIGHT(parent, field); \ } \ if ((RB_LEFT(tmp, field) == NULL || \ name##_RB_GETCOLOR(RB_LEFT(tmp, field)) == RB_BLACK) &&\ (RB_RIGHT(tmp, field) == NULL || \ name##_RB_GETCOLOR(RB_RIGHT(tmp, field)) == RB_BLACK)) {\ name##_RB_SETCOLOR(tmp, RB_RED); \ elm = parent; \ parent = name##_RB_GETPARENT(elm); \ } else { \ if (RB_RIGHT(tmp, field) == NULL || \ name##_RB_GETCOLOR(RB_RIGHT(tmp, field)) == RB_BLACK) {\ struct type *oleft; \ if ((oleft = RB_LEFT(tmp, field)) \ != NULL) \ name##_RB_SETCOLOR(oleft, RB_BLACK);\ name##_RB_SETCOLOR(tmp, RB_RED); \ RB_ROTATE_RIGHT(name, head, tmp, oleft, field);\ tmp = RB_RIGHT(parent, field); \ } \ name##_RB_SETCOLOR(tmp, (name##_RB_GETCOLOR(parent)));\ name##_RB_SETCOLOR(parent, RB_BLACK); \ if (RB_RIGHT(tmp, field)) \ name##_RB_SETCOLOR(RB_RIGHT(tmp, field),RB_BLACK);\ RB_ROTATE_LEFT(name, head, parent, tmp, field);\ elm = RB_ROOT(head); \ break; \ } \ } else { \ tmp = RB_LEFT(parent, field); \ if (name##_RB_GETCOLOR(tmp) == RB_RED) { \ RB_SET_BLACKRED(name, tmp, parent, field); \ RB_ROTATE_RIGHT(name, head, parent, tmp, field);\ tmp = RB_LEFT(parent, field); \ } \ if ((RB_LEFT(tmp, field) == NULL || \ name##_RB_GETCOLOR(RB_LEFT(tmp, field)) == RB_BLACK) &&\ (RB_RIGHT(tmp, field) == NULL || \ name##_RB_GETCOLOR(RB_RIGHT(tmp, field)) == RB_BLACK)) {\ name##_RB_SETCOLOR(tmp, RB_RED); \ elm = parent; \ parent = name##_RB_GETPARENT(elm); \ } else { \ if (RB_LEFT(tmp, field) == NULL || \ name##_RB_GETCOLOR(RB_LEFT(tmp, field)) == RB_BLACK) {\ struct type *oright; \ if ((oright = RB_RIGHT(tmp, field)) \ != NULL) \ name##_RB_SETCOLOR(oright, RB_BLACK);\ name##_RB_SETCOLOR(tmp, RB_RED); \ RB_ROTATE_LEFT(name, head, tmp, oright, field);\ tmp = RB_LEFT(parent, field); \ } \ name##_RB_SETCOLOR(tmp,(name##_RB_GETCOLOR(parent)));\ name##_RB_SETCOLOR(parent, RB_BLACK); \ if (RB_LEFT(tmp, field)) \ name##_RB_SETCOLOR(RB_LEFT(tmp, field), RB_BLACK);\ RB_ROTATE_RIGHT(name, head, parent, tmp, field);\ elm = RB_ROOT(head); \ break; \ } \ } \ } \ if (elm) \ name##_RB_SETCOLOR(elm, RB_BLACK); \ } \ \ struct type * \ name##_RB_REMOVE(struct name *head, struct type *elm) \ { \ struct type *child, *parent, *old = elm; \ int color; \ if (RB_LEFT(elm, field) == NULL) \ child = RB_RIGHT(elm, field); \ else if (RB_RIGHT(elm, field) == NULL) \ child = RB_LEFT(elm, field); \ else { \ struct type *left; \ elm = RB_RIGHT(elm, field); \ while ((left = RB_LEFT(elm, field)) != NULL) \ elm = left; \ child = RB_RIGHT(elm, field); \ parent = name##_RB_GETPARENT(elm); \ color = name##_RB_GETCOLOR(elm); \ if (child) \ name##_RB_SETPARENT(child, parent); \ if (parent) { \ if (RB_LEFT(parent, field) == elm) \ RB_LEFT(parent, field) = child; \ else \ RB_RIGHT(parent, field) = child; \ RB_AUGMENT(parent); \ } else \ RB_ROOT(head) = child; \ if (name##_RB_GETPARENT(elm) == old) \ parent = elm; \ (elm)->field = (old)->field; \ if (name##_RB_GETPARENT(old)) { \ if (RB_LEFT(name##_RB_GETPARENT(old), field) == old)\ RB_LEFT(name##_RB_GETPARENT(old), field) = elm;\ else \ RB_RIGHT(name##_RB_GETPARENT(old), field) = elm;\ RB_AUGMENT(name##_RB_GETPARENT(old)); \ } else \ RB_ROOT(head) = elm; \ name##_RB_SETPARENT(RB_LEFT(old, field), elm); \ if (RB_RIGHT(old, field)) \ name##_RB_SETPARENT(RB_RIGHT(old, field), elm); \ if (parent) { \ left = parent; \ do { \ RB_AUGMENT(left); \ } while ((left = name##_RB_GETPARENT(left)) != NULL); \ } \ goto color; \ } \ parent = name##_RB_GETPARENT(elm); \ color = name##_RB_GETCOLOR(elm); \ if (child) \ name##_RB_SETPARENT(child, parent); \ if (parent) { \ if (RB_LEFT(parent, field) == elm) \ RB_LEFT(parent, field) = child; \ else \ RB_RIGHT(parent, field) = child; \ RB_AUGMENT(parent); \ } else \ RB_ROOT(head) = child; \ color: \ if (color == RB_BLACK) \ name##_RB_REMOVE_COLOR(head, parent, child); \ return (old); \ } \ \ /* Inserts a node into the RB tree */ \ struct type * \ name##_RB_INSERT(struct name *head, struct type *elm) \ { \ struct type *tmp; \ struct type *parent = NULL; \ int comp = 0; \ tmp = RB_ROOT(head); \ while (tmp) { \ parent = tmp; \ comp = (cmp)(elm, parent); \ if (comp < 0) \ tmp = RB_LEFT(tmp, field); \ else if (comp > 0) \ tmp = RB_RIGHT(tmp, field); \ else \ return (tmp); \ } \ RB_SET(name, elm, parent, field); \ if (parent != NULL) { \ if (comp < 0) \ RB_LEFT(parent, field) = elm; \ else \ RB_RIGHT(parent, field) = elm; \ RB_AUGMENT(parent); \ } else \ RB_ROOT(head) = elm; \ name##_RB_INSERT_COLOR(head, elm); \ return (NULL); \ } \ \ /* Finds the node with the same key as elm */ \ struct type * \ name##_RB_FIND(struct name *head, struct type *elm) \ { \ struct type *tmp = RB_ROOT(head); \ int comp; \ while (tmp) { \ comp = cmp(elm, tmp); \ if (comp < 0) \ tmp = RB_LEFT(tmp, field); \ else if (comp > 0) \ tmp = RB_RIGHT(tmp, field); \ else \ return (tmp); \ } \ return (NULL); \ } \ \ /* Finds the first node greater than or equal to the search key */ \ __attribute__((unused)) \ struct type * \ name##_RB_NFIND(struct name *head, struct type *elm) \ { \ struct type *tmp = RB_ROOT(head); \ struct type *res = NULL; \ int comp; \ while (tmp) { \ comp = cmp(elm, tmp); \ if (comp < 0) { \ res = tmp; \ tmp = RB_LEFT(tmp, field); \ } \ else if (comp > 0) \ tmp = RB_RIGHT(tmp, field); \ else \ return (tmp); \ } \ return (res); \ } \ \ /* ARGSUSED */ \ struct type * \ name##_RB_NEXT(struct type *elm) \ { \ if (RB_RIGHT(elm, field)) { \ elm = RB_RIGHT(elm, field); \ while (RB_LEFT(elm, field)) \ elm = RB_LEFT(elm, field); \ } else { \ if (name##_RB_GETPARENT(elm) && \ (elm == RB_LEFT(name##_RB_GETPARENT(elm), field))) \ elm = name##_RB_GETPARENT(elm); \ else { \ while (name##_RB_GETPARENT(elm) && \ (elm == RB_RIGHT(name##_RB_GETPARENT(elm), field)))\ elm = name##_RB_GETPARENT(elm); \ elm = name##_RB_GETPARENT(elm); \ } \ } \ return (elm); \ } \ \ struct type * \ name##_RB_MINMAX(struct name *head, int val) \ { \ struct type *tmp = RB_ROOT(head); \ struct type *parent = NULL; \ while (tmp) { \ parent = tmp; \ if (val < 0) \ tmp = RB_LEFT(tmp, field); \ else \ tmp = RB_RIGHT(tmp, field); \ } \ return (parent); \ } #define RB_PROTOTYPE_PREV(name, type, field, cmp) \ RB_PROTOTYPE(name, type, field, cmp) \ struct type *name##_RB_PREV(struct type *); #define RB_PROTOTYPE_SC_PREV(_sc_, name, type, field, cmp) \ RB_PROTOTYPE_SC(_sc_, name, type, field, cmp); \ _sc_ struct type *name##_RB_PREV(struct type *) #define RB_GENERATE_PREV(name, type, field, cmp) \ RB_GENERATE(name, type, field, cmp); \ struct type * \ name##_RB_PREV(struct type *elm) \ { \ if (RB_LEFT(elm, field)) { \ elm = RB_LEFT(elm, field); \ while (RB_RIGHT(elm, field)) \ elm = RB_RIGHT(elm, field); \ } else { \ if (name##_RB_GETPARENT(elm) && \ (elm == RB_RIGHT(name##_RB_GETPARENT(elm), field))) \ elm = name##_RB_GETPARENT(elm); \ else { \ while (name##_RB_GETPARENT(elm) && \ (elm == RB_LEFT(name##_RB_GETPARENT(elm), field)))\ elm = name##_RB_GETPARENT(elm); \ elm = name##_RB_GETPARENT(elm); \ } \ } \ return (elm); \ } \ #define RB_NEGINF -1 #define RB_INF 1 #define RB_INSERT(name, x, y) name##_RB_INSERT(x, y) #define RB_REMOVE(name, x, y) name##_RB_REMOVE(x, y) #define RB_FIND(name, x, y) name##_RB_FIND(x, y) #define RB_NFIND(name, x, y) name##_RB_NFIND(x, y) #define RB_NEXT(name, x, y) name##_RB_NEXT(y) #define RB_PREV(name, x, y) name##_RB_PREV(y) #define RB_MIN(name, x) name##_RB_MINMAX(x, RB_NEGINF) #define RB_MAX(name, x) name##_RB_MINMAX(x, RB_INF) #define RB_FOREACH(x, name, head) \ for ((x) = RB_MIN(name, head); \ (x) != NULL; \ (x) = name##_RB_NEXT(x)) #define RB_FOREACH_FROM(x, name, y) \ for ((x) = (y); \ ((x) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL); \ (x) = (y)) #define RB_FOREACH_REVERSE_FROM(x, name, y) \ for ((x) = (y); \ ((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \ (x) = (y)) #define RB_FOREACH_SAFE(x, name, head, y) \ for ((x) = RB_MIN(name, head); \ ((x) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL); \ (x) = (y)) #endif /* _LIBKERN_TREE_H_ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/Block.h
/* * Block.h * * Copyright (c) 2008-2010 Apple Inc. All rights reserved. * * @APPLE_LLVM_LICENSE_HEADER@ * */ #ifndef _Block_H_ #define _Block_H_ #if !defined(BLOCK_EXPORT) # if defined(__cplusplus) # define BLOCK_EXPORT extern "C" # else # define BLOCK_EXPORT extern # endif #endif #include <Availability.h> #if __cplusplus extern "C" { #endif // Create a heap based copy of a Block or simply add a reference to an existing one. // This must be paired with Block_release to recover memory, even when running // under Objective-C Garbage Collection. BLOCK_EXPORT void *_Block_copy(const void *aBlock) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2); // Lose the reference, and if heap based and last reference, recover the memory BLOCK_EXPORT void _Block_release(const void *aBlock) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2); // Used by the compiler. Do not call this function yourself. BLOCK_EXPORT void _Block_object_assign(void *, const void *, const int) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2); // Used by the compiler. Do not call this function yourself. BLOCK_EXPORT void _Block_object_dispose(const void *, const int) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2); // Used by the compiler. Do not use these variables yourself. BLOCK_EXPORT void * _NSConcreteGlobalBlock[32] __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2); BLOCK_EXPORT void * _NSConcreteStackBlock[32] __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2); #if __cplusplus } #endif // Type correct macros #define Block_copy(...) ((__typeof(__VA_ARGS__))_Block_copy((const void *)(__VA_ARGS__))) #define Block_release(...) _Block_release((const void *)(__VA_ARGS__)) #endif
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/OSKextLib.h
/* * Copyright (c) 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 _LIBKERN_OSKEXTLIB_H #define _LIBKERN_OSKEXTLIB_H #include <sys/cdefs.h> __BEGIN_DECLS #include <stdint.h> #include <mach/kmod.h> #include <mach/vm_types.h> #include <uuid/uuid.h> #include <libkern/OSTypes.h> #include <libkern/OSReturn.h> /*! * @header * * Declares functions, basic return values, and other constants * related to kernel extensions (kexts). */ #if PRAGMA_MARK #pragma mark - /********************************************************************/ #pragma mark OSReturn Values for Kernel Extensions /********************************************************************/ #endif /*! * @group OSReturn Values for Kernel Extensions * Many kext-related functions return these values, * as well as those defined under * <code>@link //apple_ref/c/tdef/OSReturn OSReturn@/link</code> * and other variants of <code>kern_return_t</code>. */ #define sub_libkern_kext err_sub(2) #define libkern_kext_err(code) (sys_libkern|sub_libkern_kext|(code)) /*! * @define kOSKextReturnInternalError * @abstract An internal error in the kext library. * Contrast with <code>@link //apple_ref/c/econst/OSReturnError * OSReturnError@/link</code>. */ #define kOSKextReturnInternalError libkern_kext_err(0x1) /*! * @define kOSKextReturnNoMemory * @abstract Memory allocation failed. */ #define kOSKextReturnNoMemory libkern_kext_err(0x2) /*! * @define kOSKextReturnNoResources * @abstract Some resource other than memory (such as available load tags) * is exhausted. */ #define kOSKextReturnNoResources libkern_kext_err(0x3) /*! * @define kOSKextReturnNotPrivileged * @abstract The caller lacks privileges to perform the requested operation. */ #define kOSKextReturnNotPrivileged libkern_kext_err(0x4) /*! * @define kOSKextReturnInvalidArgument * @abstract Invalid argument. */ #define kOSKextReturnInvalidArgument libkern_kext_err(0x5) /*! * @define kOSKextReturnNotFound * @abstract Search item not found. */ #define kOSKextReturnNotFound libkern_kext_err(0x6) /*! * @define kOSKextReturnBadData * @abstract Malformed data (not used for XML). */ #define kOSKextReturnBadData libkern_kext_err(0x7) /*! * @define kOSKextReturnSerialization * @abstract Error converting or (un)serializing URL, string, or XML. */ #define kOSKextReturnSerialization libkern_kext_err(0x8) /*! * @define kOSKextReturnUnsupported * @abstract Operation is no longer or not yet supported. */ #define kOSKextReturnUnsupported libkern_kext_err(0x9) /*! * @define kOSKextReturnDisabled * @abstract Operation is currently disabled. */ #define kOSKextReturnDisabled libkern_kext_err(0xa) /*! * @define kOSKextReturnNotAKext * @abstract Bundle is not a kernel extension. */ #define kOSKextReturnNotAKext libkern_kext_err(0xb) /*! * @define kOSKextReturnValidation * @abstract Validation failures encountered; check diagnostics for details. */ #define kOSKextReturnValidation libkern_kext_err(0xc) /*! * @define kOSKextReturnAuthentication * @abstract Authetication failures encountered; check diagnostics for details. */ #define kOSKextReturnAuthentication libkern_kext_err(0xd) /*! * @define kOSKextReturnDependencies * @abstract Dependency resolution failures encountered; check diagnostics for details. */ #define kOSKextReturnDependencies libkern_kext_err(0xe) /*! * @define kOSKextReturnArchNotFound * @abstract Kext does not contain code for the requested architecture. */ #define kOSKextReturnArchNotFound libkern_kext_err(0xf) /*! * @define kOSKextReturnCache * @abstract An error occurred processing a system kext cache. */ #define kOSKextReturnCache libkern_kext_err(0x10) /*! * @define kOSKextReturnDeferred * @abstract Operation has been posted asynchronously to user space (kernel only). */ #define kOSKextReturnDeferred libkern_kext_err(0x11) /*! * @define kOSKextReturnBootLevel * @abstract Kext not loadable or operation not allowed at current boot level. */ #define kOSKextReturnBootLevel libkern_kext_err(0x12) /*! * @define kOSKextReturnNotLoadable * @abstract Kext cannot be loaded; check diagnostics for details. */ #define kOSKextReturnNotLoadable libkern_kext_err(0x13) /*! * @define kOSKextReturnLoadedVersionDiffers * @abstract A different version (or executable UUID, or executable by checksum) * of the requested kext is already loaded. */ #define kOSKextReturnLoadedVersionDiffers libkern_kext_err(0x14) /*! * @define kOSKextReturnDependencyLoadError * @abstract A load error occurred on a dependency of the kext being loaded. */ #define kOSKextReturnDependencyLoadError libkern_kext_err(0x15) /*! * @define kOSKextReturnLinkError * @abstract A link failure occured with this kext or a dependency. */ #define kOSKextReturnLinkError libkern_kext_err(0x16) /*! * @define kOSKextReturnStartStopError * @abstract The kext start or stop routine returned an error. */ #define kOSKextReturnStartStopError libkern_kext_err(0x17) /*! * @define kOSKextReturnInUse * @abstract The kext is currently in use or has outstanding references, * and cannot be unloaded. */ #define kOSKextReturnInUse libkern_kext_err(0x18) /*! * @define kOSKextReturnTimeout * @abstract A kext request has timed out. */ #define kOSKextReturnTimeout libkern_kext_err(0x19) /*! * @define kOSKextReturnStopping * @abstract The kext is in the process of stopping; requests cannot be made. */ #define kOSKextReturnStopping libkern_kext_err(0x1a) /*! * @define kOSKextReturnSystemPolicy * @abstract The kext was prevented from loading due to system policy. */ #define kOSKextReturnSystemPolicy libkern_kext_err(0x1b) /*! * @define kOSKextReturnKCLoadFailure * @abstract Loading of the System KC failed */ #define kOSKextReturnKCLoadFailure libkern_kext_err(0x1c) /*! * @define kOSKextReturnKCLoadFailureSystemKC * @abstract Loading of the System KC failed * * This a sub-code of kOSKextReturnKCLoadFailure. It can be OR'd together * with: kOSKextReturnKCLoadFailureAuxKC * * If both the System and Aux KCs fail to load, then the error code will be: * libkern_kext_err(0x1f) */ #define kOSKextReturnKCLoadFailureSystemKC libkern_kext_err(0x1d) /*! * @define kOSKextReturnKCLoadFailureAuxKC * @abstract Loading of the Aux KC failed * * This a sub-code of kOSKextReturnKCLoadFailure. It can be OR'd together * with: kOSKextReturnKCLoadFailureSystemKC * * If both the System and Aux KCs fail to load, then the error code will be: * libkern_kext_err(0x1f) */ #define kOSKextReturnKCLoadFailureAuxKC libkern_kext_err(0x1e) /* next available error is: libkern_kext_err(0x20) */ #if PRAGMA_MARK #pragma mark - /********************************************************************/ #pragma mark Kext/OSBundle Property List Keys /********************************************************************/ #endif /*! * @group Kext Property List Keys * These constants cover CFBundle properties defined for kernel extensions. * Because they are used in the kernel, if you want to use one with * CFBundle APIs you'll need to wrap it in a <code>CFSTR()</code> macro. */ /* Define C-string versions of the CFBundle keys for use in the kernel. */ #define kCFBundleIdentifierKey "CFBundleIdentifier" #define kCFBundleIdentifierKernelKey "CFBundleIdentifierKernel" #define kCFBundleVersionKey "CFBundleVersion" #define kCFBundleNameKey "CFBundleName" #define kCFBundleExecutableKey "CFBundleExecutable" #define kCFBundlePackageTypeKey "CFBundlePackageType" #define kCFBundleDriverKitUUIDKey "CFBundleDriverKitUUID" #define kCFBundleDriverKitExecutableKey "CFBundleUEXTExecutable" /*! * @define kOSBundleCompatibleVersionKey * @abstract A string giving the backwards-compatible version of a library kext * in extended Mac OS 'vers' format (####.##.##s{1-255} where 's' * is a build stage 'd', 'a', 'b', 'f' or 'fc'). */ #define kOSBundleCompatibleVersionKey "OSBundleCompatibleVersion" /*! * @define kOSBundleEnableKextLoggingKey * @abstract Set to true to have the kernel kext logging spec applied * to the kext. * See <code>@link //apple_ref/c/econst/OSKextLogSpec * OSKextLogSpec@/link</code>. */ #define kOSBundleEnableKextLoggingKey "OSBundleEnableKextLogging" /*! * @define kOSBundleIsInterfaceKey * @abstract A boolean value indicating whether the kext executable * contains only symbol references. */ #define kOSBundleIsInterfaceKey "OSBundleIsInterface" /*! * @define kOSBundleLibrariesKey * @abstract A dictionary listing link dependencies for this kext. * Keys are bundle identifiers, values are version strings. */ #define kOSBundleLibrariesKey "OSBundleLibraries" /*! * @define kOSBundleRequiredKey * @abstract A string indicating in which kinds of startup this kext * may need to load during early startup (before * <code>@link //apple_ref/doc/man/8/kextd kextcache(8)@/link</code>). * @discussion * The value is one of: * <ul> * <li>@link kOSBundleRequiredRoot "OSBundleRequiredRoot"@/link</li> * <li>@link kOSBundleRequiredLocalRoot "OSBundleRequiredLocalRoot"@/link</li> * <li>@link kOSBundleRequiredNetworkRoot "OSBundleRequiredNetworkRoot"@/link</li> * <li>@link kOSBundleRequiredSafeBoot "OSBundleRequiredSafeBoot"@/link</li> * <li>@link kOSBundleRequiredConsole "OSBundleRequiredConsole"@/link</li> * </ul> * * Use this property judiciously. * Every kext that declares a value other than "OSBundleRequiredSafeBoot" * increases startup time, as the booter must read it into memory, * or startup kext caches must include it. */ #define kOSBundleRequiredKey "OSBundleRequired" /*! * @define kOSBundleRequireExplicitLoadKey * @abstract A boolean value indicating whether the kext requires an * explicit kextload in order to start/match. */ #define kOSBundleRequireExplicitLoadKey "OSBundleRequireExplicitLoad" /*! * @define kOSBundleAllowUserLoadKey * @abstract A boolean value indicating whether * <code>@link //apple_ref/doc/man/8/kextd kextcache(8)@/link</code> * will honor a non-root process's request to load a kext. * @discussion * See <code>@link //apple_ref/doc/compositePage/c/func/KextManagerLoadKextWithURL * KextManagerLoadKextWithURL@/link</code> * and <code>@link //apple_ref/doc/compositePage/c/func/KextManagerLoadKextWithIdentifier * KextManagerLoadKextWithIdentifier@/link</code>. */ #define kOSBundleAllowUserLoadKey "OSBundleAllowUserLoad" /*! * @define kOSBundleAllowUserTerminateKey * @abstract A boolean value indicating whether the kextunload tool * is allowed to issue IOService terminate to classes defined in this kext. * @discussion A boolean value indicating whether the kextunload tool * is allowed to issue IOService terminate to classes defined in this kext. */ #define kOSBundleAllowUserTerminateKey "OSBundleAllowUserTerminate" /*! * @define kOSKernelResourceKey * @abstract A boolean value indicating whether the kext represents a built-in * component of the kernel. */ #define kOSKernelResourceKey "OSKernelResource" /*! * @define kOSKextVariantOverrideKey * @abstract A dictionary with target names as key and a target-specific variant * name as value. */ #define kOSKextVariantOverrideKey "OSKextVariantOverride" /*! * @define kIOKitPersonalitiesKey * @abstract A dictionary of dictionaries used in matching for I/O Kit drivers. */ #define kIOKitPersonalitiesKey "IOKitPersonalities" /* * @define kIOPersonalityPublisherKey * @abstract Used in personalities sent to the I/O Kit, * contains the CFBundleIdentifier of the kext * that the personality originated in. */ #define kIOPersonalityPublisherKey "IOPersonalityPublisher" #if CONFIG_KEC_FIPS /* * @define kAppleTextHashesKey * @abstract A dictionary conataining hashes for corecrypto kext. */ #define kAppleTextHashesKey "AppleTextHashes" #endif /*! * @define kOSMutableSegmentCopy * @abstract A boolean value indicating whether the kext requires a copy of * its mutable segments to be kept in memory, and then reset when the kext * unloads. This should be used with caution as it will increase the * amount of memory used by the kext. */ #define kOSMutableSegmentCopy "OSMutableSegmentCopy" #if PRAGMA_MARK /********************************************************************/ #pragma mark Kext/OSBundle Property Deprecated Keys /********************************************************************/ #endif /* * @define kOSBundleDebugLevelKey * @abstract * Deprecated (used on some releases of Mac OS X prior to 10.6 Snow Leopard). * Value is an integer from 1-6, corresponding to the verbose levels * of kext tools on those releases. * On 10.6 Snow Leopard, use <code>@link OSKextEnableKextLogging * OSKextEnableKextLogging@/link</code>. */ #define kOSBundleDebugLevelKey "OSBundleDebugLevel" /*! * @define kOSBundleSharedExecutableIdentifierKey * @abstract Deprecated (used on some releases of Mac OS X * prior to 10.6 Snow Leopard). * Value is the bundle identifier of the pseudokext * that contains an executable shared by this kext. */ #define kOSBundleSharedExecutableIdentifierKey "OSBundleSharedExecutableIdentifier" #if PRAGMA_MARK /********************************************************************/ #pragma mark Kext/OSBundle Property List Values /********************************************************************/ #endif /*! * @group Kext Property List Values * These constants encompass established values * for kernel extension bundle properties. */ /*! * @define kOSKextKernelIdentifier * @abstract * This is the CFBundleIdentifier user for the kernel itself. */ #define kOSKextKernelIdentifier "__kernel__" /*! * @define kOSKextBundlePackageTypeKext * @abstract * The bundle type value for Kernel Extensions. */ #define kOSKextBundlePackageTypeKext "KEXT" /*! * @define kOSKextBundlePackageTypeDriverKit * @abstract * The bundle type value for Driver Extensions. */ #define kOSKextBundlePackageTypeDriverKit "DEXT" /*! * @define kOSBundleRequiredRoot * @abstract * This <code>@link kOSBundleRequiredKey OSBundleRequired@/link</code> * value indicates that the kext may be needed to mount the root filesystem * whether starting from a local or a network volume. */ #define kOSBundleRequiredRoot "Root" /*! * @define kOSBundleRequiredLocalRoot * @abstract * This <code>@link kOSBundleRequiredKey OSBundleRequired@/link</code> * value indicates that the kext may be needed to mount the root filesystem * when starting from a local disk. */ #define kOSBundleRequiredLocalRoot "Local-Root" /*! * @define kOSBundleRequiredNetworkRoot * @abstract * This <code>@link kOSBundleRequiredKey OSBundleRequired@/link</code> * value indicates that the kext may be needed to mount the root filesystem * when starting over a network connection. */ #define kOSBundleRequiredNetworkRoot "Network-Root" /*! * @define kOSBundleRequiredSafeBoot * @abstract * This <code>@link kOSBundleRequiredKey OSBundleRequired@/link</code> * value indicates that the kext can be loaded during a safe startup. * This value does not normally cause the kext to be read by the booter * or included in startup kext caches. */ #define kOSBundleRequiredSafeBoot "Safe Boot" /*! * @define kOSBundleRequiredConsole * @abstract * This <code>@link kOSBundleRequiredKey OSBundleRequired@/link</code> * value indicates that the kext may be needed for console access * (specifically in a single-user startup when * <code>@link //apple_ref/doc/man/8/kextd kextd(8)@/link</code>. * does not run) * and should be loaded during early startup. */ #define kOSBundleRequiredConsole "Console" /*! * @define kOSBundleRequiredDriverKit * @abstract * This <code>@link kOSBundleRequiredKey OSBundleRequired@/link</code> * value indicates that the driver extension's (DriverKit driver's) * personalities must be present in the kernel at early boot (specifically * before <code>@link //apple_ref/doc/man/8/kextd kextd(8)@/link</code> starts) * in order to compete with kexts built into the prelinkedkernel. Note that * kextd is still required to launch the user space driver binary. The IOKit * matching will happen during early boot, and the actual driver launch * will happen after kextd starts. */ #define kOSBundleRequiredDriverKit "DriverKit" #if PRAGMA_MARK #pragma mark - /********************************************************************/ #pragma mark Kext Information /********************************************************************/ #endif /*! * @group Kext Information * Types, constants, and macros providing a kext with information * about itself. */ /*! * @typedef OSKextLoadTag * * @abstract * A unique identifier assigned to a loaded instanace of a kext. * * @discussion * If a kext is unloaded and later reloaded, the new instance * has a different load tag. * * A kext can get its own load tag in the <code>kmod_info_t</code> * structure passed into its module start routine, as the * <code>id</code> field (cast to this type). * You can use the load tag with the functions * <code>@link OSKextRetainKextWithLoadTag * OSKextRetainKextWithLoadTag@/link</code> and * <code>@link OSKextReleaseKextWithLoadTag * OSKextReleaseKextWithLoadTag@/link</code>. */ typedef uint32_t OSKextLoadTag; /*! * @define kOSKextInvalidLoadTag * * @abstract * A load tag value that will never be used for a loaded kext; * indicates kext not found. */ #define kOSKextInvalidLoadTag ((OSKextLoadTag)(-1)) /* Make these visible to kexts only and *not* the kernel. */ /*! * @function OSKextGetCurrentLoadTag * * @abstract * Returns the run-time load tag for the calling kext as an * <code>@link OSKextLoadTag OSKextLoadTag@/link</code>. * * @result * The run-time load tag for the calling kext as an * <code>@link OSKextLoadTag@/link</code>. * * @discussion * The load tag identifies this loaded instance of the kext to the kernel * and to kernel functions that operate on kexts. */ OSKextLoadTag OSKextGetCurrentLoadTag(void); /*! * @function OSKextGetCurrentIdentifier * * @abstract * Returns the CFBundleIdentifier for the calling kext as a C string. * * @result * The CFBundleIdentifier for the calling kext as a C string. */ const char * OSKextGetCurrentIdentifier(void); /*! * @function OSKextGetCurrentVersionString * * @abstract * Returns the CFBundleVersion for the calling kext as a C string. * * @result * The CFBundleVersion for the calling kext as a C string. */ const char * OSKextGetCurrentVersionString(void); #if PRAGMA_MARK #pragma mark - /********************************************************************/ #pragma mark Kext Loading C Functions /********************************************************************/ #endif /*! * @group Kext Loading C Functions * Functions for loading and tracking kexts in the kernel. */ /*! * @function OSKextLoadKextWithIdentifier * * @abstract * Request that a kext be loaded. * * @param kextIdentifier The bundle identifier of the kext to be loaded. * * @result * <code>@link //apple_ref/c/macro/kOSReturnSuccess kOSReturnSuccess@/link</code> * if the kext was loaded (or was already loaded). * <code>@link //apple_ref/c/macro/kOSKextReturnDeferred kOSKextReturnDeferred@/link</code> * if the kext was not found and a request * was queued to <code>@link //apple_ref/doc/man/8/kextd kextd(8)@/link</code>. * Other return values indicate a failure to load the kext. * * @discussion * If a kext is already in the kernel but not loaded, it is loaded immediately. * If it isn't found, an asynchronous load request is * made to <code>@link //apple_ref/doc/man/8/kextd kextd(8)@/link</code> * and <code>@link //apple_ref/c/macro/kOSKextReturnDeferred kOSKextReturnDeferred@/link</code> is returned. * There is no general notification or callback mechanism for load requests. */ OSReturn OSKextLoadKextWithIdentifier(const char * kextIdentifier); /*! * @function OSKextRetainKextWithLoadTag * * @abstract * Retain a loaded kext based on its load tag, * and enable autounload for that kext. * * @param loadTag The load tag of the kext to be retained. * See <code>@link OSKextGetCurrentLoadTag@/link</code>. * * @result * <code>@link //apple_ref/c/macro/kOSReturnSuccess kOSReturnSuccess@/link</code> * if the kext was retained. * <code>@link //apple_ref/c/macro/kOSKextReturnNotFound kOSKextReturnNotFound@/link</code> * if the kext was not found. * <code>@link //apple_ref/c/macro/kOSKextReturnInvalidArgument * kOSKextReturnInvalidArgument@/link</code> * if <code>loadTag</code> is * <code>@link kOSKextInvalidLoadTag kOSKextInvalidLoadTag@/link</code>. * * @discussion * Retaining a kext prevents it from being unloaded, * either explicitly or automatically, and enables autounload for the kext. * When autounload is enabled, then shortly after the kext's last reference * is dropped, it will be unloaded if there are no outstanding references to it * and there are no instances of its Libkern C++ subclasses (if any). * * Kexts that define subclasses of * <code>@link //apple_ref/doc/class/IOService IOService@/link</code> * have autounload enabled automatically. * Other kexts can use the reference count to manage automatic unload * without having to define and create Libkern C++ objects. * For example, a filesystem kext can retain itself whenever a new mount * is created, and release itself when a mount is removed. * When the last mount is removed, the kext will be unloaded after a brief delay. * * A kext can get its own load tag using the * <code>@link OSKextGetCurrentLoadTag@/link</code>. * * Kexts should not retain and release other kexts; linkage references * are accounted for internally. */ OSReturn OSKextRetainKextWithLoadTag(OSKextLoadTag loadTag); /*! * @function OSKextReleaseKextWithLoadTag * * @abstract * Release a loaded kext based on its load tag. * * @param loadTag The load tag of the kext to be released. * See <code>@link OSKextGetCurrentLoadTag@/link</code>. * * @result * <code>@link //apple_ref/c/macro/kOSReturnSuccess kOSReturnSuccess@/link</code> * if the kext was released. * <code>@link //apple_ref/c/macro/kOSKextReturnNotFound * kOSKextReturnNotFound@/link</code> * if the kext was not found. * <code>@link //apple_ref/c/macro/kOSKextReturnInvalidArgument * kOSKextReturnInvalidArgument@/link</code> * if <code>loadTag</code> is * <code>@link kOSKextInvalidLoadTag kOSKextInvalidLoadTag@/link</code>. * * @discussion * The kext should have been retained previously via * <code>@link OSKextRetainKextWithLoadTag@/link</code>. * * This function schedules an autounload scan for all kexts. * When that scan occurs, if a kext has autounload enabled, * it will be unloaded if there are no outstanding references to it * and there are no instances of its Libkern C++ classes (if any). * * Kexts that define subclasses of * <code>@link //apple_ref/doc/class/IOService IOService@/link</code> * have autounload enabled automatically. * Other kexts can use the reference count to manage automatic unload * without having to define and create Libkern C++ objects. * For example, a filesystem kext can be retained whenever a new mount * is created, and released when a mount is removed. * When the last mount is removed, the kext will be unloaded after a brief delay. * * While the autounload scan takes place after a delay of at least a minute, * a kext that manages its own reference counts for autounload should * be prepared to have its module stop function called even while the function * calling this function is still running. * * A kext can get its own load tag using the * <code>@link OSKextGetCurrentLoadTag@/link</code>. * * Kexts should not retain and release other kexts; linkage references * are accounted for internally. */ OSReturn OSKextReleaseKextWithLoadTag(OSKextLoadTag loadTag); #if PRAGMA_MARK /********************************************************************/ #pragma mark - #pragma mark Kext Requests /********************************************************************/ #endif /*! * @group Kext Requests to User Space * Functions for making requests to kextd in user space. */ /*! * @typedef OSKextRequestTag * * @abstract * Identifies a kext request made to user space. */ typedef uint32_t OSKextRequestTag; /*! * @define kOSKextRequestTagInvalid * * @abstract * A request tag value that will never be used for a kext request; * indicates failure to create/queue the request. */ #define kOSKextRequestTagInvalid ((OSKextRequestTag)-1) /*! * @typedef OSKextRequestResourceCallback * * @abstract * Invoked to provide results for a kext resource request. * * @param requestTag The tag of the request that the callback pertains to. * @param result The result of the request: * <code>@link kOSReturnSuccess * kOSReturnSuccess@/link</code> * if the request was fulfilled; * <code>@link kOSKextReturnTimeout * kOSKextReturnTimeout@/link</code> * if the request has timed out; * <code>@link kOSKextReturnStopping * kOSKextReturnStopping@/link</code> * if the kext containing the callback * address for the kext is being unloaded; * or other values on error. * @param resourceData A pointer to the requested resource data. * Owned by the system; the kext should make a copy * if it needs to keep the data past the callback. * @param resourceDataLength The length of <code>resourceData</code>. * @param context The context pointer originally passed to * <code>@link OSKextRequestResource * OSKextRequestResource@/link</code>. */ typedef void (* OSKextRequestResourceCallback)( OSKextRequestTag requestTag, OSReturn result, const void * resourceData, uint32_t resourceDataLength, void * context); /*! * @function OSKextRequestResource * * @abstract * Requests data from a nonlocalized resource file in a kext bundle on disk. * * @param kextIdentifier The CFBundleIdentifier of the kext * from which to read the file. * @param resourceName The name of the resource file to read. * @param callback A pointer to a callback function; the address * must be within a currently-loaded kext. * @param context A pointer to arbitrary run-time data * that will be passed to the callback * when it is invoked. May be <code>NULL</code>. * @param requestTagOut If non-<code>NULL</code>, * filled on success with a tag identifying the * pending request * (or on failure with <code>@link kOSKextRequestTagInvalid * kOSKextRequestTagInvalid@/link</code>; * can be used with * <code>@link OSKextCancelRequest * OSKextCancelRequest@/link</code>. * * @result * <code>@link kOSReturnSuccess kOSReturnSuccess@/link</code> * if the request is successfully queued. * <code>@link kOSKextReturnInvalidArgument kOSKextReturnInvalidArgument@/link</code> * if <code>kextIdentifier</code> or <code>resourceName</code> or if * <code>callback</code> is not an address within a loaded kext executable. * <code>@link kOSKextReturnStopping kOSKextReturnStopping@/link</code> * if an unload attempt is being made * on the kext containing <code>callback</code>. * Other <code>OSKextReturn...</code> errors are possible. * * @discussion * This function queues an asynchronous request to the user-space kext daemon * <code>@link //apple_ref/doc/man/8/kextd kextd(8)@/link</code>; * requests for resources early in system startup * will not be fulfilled until that daemon starts. * Requests made by a kext while that kext is loading * (specifically in the kext's module start routine) * will not be fulfilled until after the start routine returns and * the kext is completely loaded. * Kexts requesting resources should be sure to perform appropriate locking * in the callback function. * * Kext resources are stored in the kext's on-disk bundle under the * Resources subdirectory. * See {@linkdoc //apple_ref/doc/uid/10000123i Bundle Programming Guide} * for an overview of bundle structure. * The localization context of the kext daemon * (namely that of the superuser) * will be used in retrieving resources; * kext resources intended for use in the kernel * should generally not be localized. * * <code>callback</code> is guaranteed to be invoked except when: * <ul> * <li>@link OSKextCancelRequest <code>OSKextCancelRequest</code>@/link * is used to cancel the request. * In this case the kext gets the <code>context</code> pointer * and can clean it up.</li> * <li>The request is made during a kext's module start routine * and the start routine returns an error. * In this case, callbacks cannot be safely invoked, so * the kext should clean up all request contexts * when returning the error from the start routine.</li> * </ul> * * Kexts with pending requests are not subject to autounload, * but requests are subject to timeout after a few minutes. * If that amount of time passes with no response from user space, * <code>callback</code> is invoked with a result of. * <code>@link kOSKextReturnTimeout kOSKextReturnTimeout@/link</code>. * * Kexts that are explicitly unloaded have all pending request callbacks * invoked with a result of * <code>@link kOSKextReturnStopping kOSKextReturnStopping@/link</code>. * The kext must handle these callbacks, * even if its stop routine will prevent unloading. * If the kext does prevent unloading, it can reissue resource requests * outside of the stop function. */ OSReturn OSKextRequestResource( const char * kextIdentifier, const char * resourceName, OSKextRequestResourceCallback callback, void * context, OSKextRequestTag * requestTagOut); /*! * @function OSKextCancelRequest * * @abstract * Cancels a pending user-space kext request without invoking the callback. * * @param requestTag A tag identifying a pending request. * @param contextOut If non-<code>NULL</code>, filled with the context pointer * originally passed with the request. * * @result * <code>@link kOSReturnSuccess kOSReturnSuccess@/link</code> * if the request is successfully canceled. * <code>@link kOSKextReturnNotFound kOSKextReturnNotFound@/link</code> * if <code>requestTag</code> does not identify any pending request. * Other <code>OSKextReturn...</code> errors are possible. * * @discussion * This function cancels a pending request if it exists, * so that its callback will not be invoked. * It returns in <code>contextOut</code> * the context pointer used to create the request * so that any resources allocated for the request can be cleaned up. * * Kexts do not need to cancel outstanding requests * in their module stop functions; * when a kext is unloaded, all pending request callbacks * are invoked with a result of * <code>@link kOSKextReturnTimeout kOSKextReturnTimeout@/link</code> * before the stop function is called. */ OSReturn OSKextCancelRequest( OSKextRequestTag requestTag, void ** contextOut); /*! * @function OSKextGrabPgoData * * @abstract * Grab a LLVM profile data buffer from a loaded kext. * * @param uuid the uuid identifying the kext to retrieve data from * @param pSize pointer of where to store the size of the buffer. May be NULL. * @param pBuffer pointer to the output buffer. May be NULL. * @param bufferSize size of the buffer pointed to by pBuffer * @param wait_for_unload (boolean) sleep until the kext is unloaded * @param metadata (boolean) include metadata footer * * @result * 0 on success * ENOTSUP if the kext does not have profile data to retrieve. * ENOTSUP if no kext with the given UUID is found * ERRORS if the provided buffer is too small * EIO internal error, such as if __llvm_profile_write_buffer_internal fails */ int OSKextGrabPgoData(uuid_t uuid, uint64_t *pSize, char *pBuffer, uint64_t bufferSize, int wait_for_unload, int metadata); /*! * @function OSKextResetPgoCountersLock * * @abstract * Call this function before trapping into the debugger to call OSKextResetPgoCounters. */ void OSKextResetPgoCountersLock(void); /*! * @function OSKextResetPgoCountersUnlock * * @abstract * Call this function after trapping into the debugger to call OSKextResetPgoCounters. */ void OSKextResetPgoCountersUnlock(void); /*! * @function OSKextResetPgoCounters * * @abstract Reset the PGO counters for all kexts. Call only from debugger * context, while holding OSKextResetPgoCountersLock(). */ void OSKextResetPgoCounters(void); #if PRAGMA_MARK #pragma mark - /********************************************************************/ #pragma mark Weak linking /********************************************************************/ #endif /*! * @group Weak Linking * Support for weak references to symbols in kexts. */ /*! * @var gOSKextUnresolved * * @abstract * The value to which a kext's unresolved, weakly-referenced symbols are bound. * * @discussion * A kext must test a weak symbol before using it. A weak symbol * is only safe to use if it is not equal to <code>gOSKextUnresolved</code>. * * Example for a weak symbol named <code>foo</code>: * <pre> * @textblock * if (&foo != gOSKextUnresolved) { * foo(); * } else { * printf("foo() is not supported\n"); * } * @/textblock * </pre> */ extern const void * const gOSKextUnresolved; /*! * @define OSKextSymbolIsResolved * * @abstract * Checks whether a weakly-referenced symbol has been resolved. * * @param weak_sym The weak symbol to be tested for resolution. * * @result * <code>TRUE</code> if weak_sym is resolved, or <code>FALSE</code> * if weak_sym is unresolved. * * @discussion * This is a convenience macro for testing if weak symbols are resolved. * * Example for a weak symbol named <code>foo</code>: * <pre> * @textblock * if (OSKextSymbolIsResolved(foo)) { * foo(); * } else { * printf("foo() is not resolved\n"); * } * @/textblock * </pre> */ #define OSKextSymbolIsResolved(weak_sym) \ (&(weak_sym) != gOSKextUnresolved) #if CONFIG_KEC_FIPS #if PRAGMA_MARK #pragma mark - /********************************************************************/ #pragma mark Kernel External Components for FIPS compliance /********************************************************************/ #endif // Kernel External Components for FIPS compliance (KEC_FIPS) // WARNING - ath_hash is owned by the kernel, do not free typedef struct AppleTEXTHash { int ath_version;// version of this structure (value is 1 or 2) int ath_length; // length of hash data void * ath_hash; // hash extracted from AppleTextHashes dict } AppleTEXTHash_t; #endif // CONFIG_KEC_FIPS __END_DECLS #endif /* _LIBKERN_OSKEXTLIB_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/zlib.h
/* * Copyright (c) 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@ */ /* zlib.h -- interface of the 'zlib' general purpose compression library * version 1.2.3, July 18th, 2005 * * Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. * * Jean-loup Gailly Mark Adler * [email protected] [email protected] * * * The data format used by the zlib library is described by RFCs (Request for * Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt * (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). */ #ifndef ZLIB_H #define ZLIB_H #ifdef __cplusplus extern "C" { #endif #include "zconf.h" #define ZLIB_VERSION "1.2.3" #define ZLIB_VERNUM 0x1230 /* * The 'zlib' compression library provides in-memory compression and * decompression functions, including integrity checks of the uncompressed * data. This version of the library supports only one compression method * (deflation) but other algorithms will be added later and will have the same * stream interface. * * Compression can be done in a single step if the buffers are large * enough (for example if an input file is mmap'ed), or can be done by * repeated calls of the compression function. In the latter case, the * application must provide more input and/or consume the output * (providing more output space) before each call. * * The compressed data format used by default by the in-memory functions is * the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped * around a deflate stream, which is itself documented in RFC 1951. * * The library also supports reading and writing files in gzip (.gz) format * with an interface similar to that of stdio using the functions that start * with "gz". The gzip format is different from the zlib format. gzip is a * gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. * * This library can optionally read and write gzip streams in memory as well. * * The zlib format was designed to be compact and fast for use in memory * and on communications channels. The gzip format was designed for single- * file compression on file systems, has a larger header than zlib to maintain * directory information, and uses a different, slower check method than zlib. * * The library does not install any signal handler. The decoder checks * the consistency of the compressed data, so the library should never * crash even in case of corrupted input. */ typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); typedef void (*free_func) OF((voidpf opaque, voidpf address)); struct internal_state; typedef struct z_stream_s { Bytef *next_in;/* next input byte */ uInt avail_in;/* number of bytes available at next_in */ uLong total_in;/* total nb of input bytes read so far */ Bytef *next_out;/* next output byte should be put there */ uInt avail_out;/* remaining free space at next_out */ uLong total_out;/* total nb of bytes output so far */ char *msg; /* last error message, NULL if no error */ struct internal_state FAR *state; /* not visible by applications */ alloc_func zalloc; /* used to allocate the internal state */ free_func zfree;/* used to free the internal state */ voidpf opaque;/* private data object passed to zalloc and zfree */ int data_type;/* best guess about the data type: binary or text */ uLong adler; /* adler32 value of the uncompressed data */ uLong reserved;/* reserved for future use */ } z_stream; typedef z_stream FAR *z_streamp; /* * gzip header information passed to and from zlib routines. See RFC 1952 * for more details on the meanings of these fields. */ typedef struct gz_header_s { int text; /* true if compressed data believed to be text */ uLong time; /* modification time */ int xflags; /* extra flags (not used when writing a gzip file) */ int os; /* operating system */ Bytef *extra; /* pointer to extra field or Z_NULL if none */ uInt extra_len;/* extra field length (valid if extra != Z_NULL) */ uInt extra_max;/* space at extra (only when reading header) */ Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ uInt name_max;/* space at name (only when reading header) */ Bytef *comment;/* pointer to zero-terminated comment or Z_NULL */ uInt comm_max;/* space at comment (only when reading header) */ int hcrc; /* true if there was or will be a header crc */ int done; /* true when done reading gzip header (not used * when writing a gzip file) */ } gz_header; typedef gz_header FAR *gz_headerp; /* * The application must update next_in and avail_in when avail_in has * dropped to zero. It must update next_out and avail_out when avail_out * has dropped to zero. The application must initialize zalloc, zfree and * opaque before calling the init function. All other fields are set by the * compression library and must not be updated by the application. * * The opaque value provided by the application will be passed as the first * parameter for calls of zalloc and zfree. This can be useful for custom * memory management. The compression library attaches no meaning to the * opaque value. * * zalloc must return Z_NULL if there is not enough memory for the object. * If zlib is used in a multi-threaded application, zalloc and zfree must be * thread safe. * * On 16-bit systems, the functions zalloc and zfree must be able to allocate * exactly 65536 bytes, but will not be required to allocate more than this * if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, * pointers returned by zalloc for objects of exactly 65536 bytes *must* * have their offset normalized to zero. The default allocation function * provided by this library ensures this (see zutil.c). To reduce memory * requirements and avoid any allocation of 64K objects, at the expense of * compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). * * The fields total_in and total_out can be used for statistics or * progress reports. After compression, total_in holds the total size of * the uncompressed data and may be saved for use in the decompressor * (particularly if the decompressor wants to decompress everything in * a single step). */ /* constants */ #define Z_NO_FLUSH 0 #define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ /* 2 is a reserved value (in zlib 1.2.3, Z_PACKET_FLUSH was removed) */ #define Z_SYNC_FLUSH 3 #define Z_FULL_FLUSH 4 #define Z_FINISH 5 #define Z_BLOCK 6 /* Allowed flush values; see deflate() and inflate() below for details */ #define Z_OK 0 #define Z_STREAM_END 1 #define Z_NEED_DICT 2 #define Z_ERRNO (-1) #define Z_STREAM_ERROR (-2) #define Z_DATA_ERROR (-3) #define Z_MEM_ERROR (-4) #define Z_BUF_ERROR (-5) #define Z_VERSION_ERROR (-6) /* Return codes for the compression/decompression functions. Negative * values are errors, positive values are used for special but normal events. */ #define Z_NO_COMPRESSION 0 #define Z_BEST_SPEED 1 #define Z_BEST_COMPRESSION 9 #define Z_DEFAULT_COMPRESSION (-1) /* compression levels */ #define Z_FILTERED 1 #define Z_HUFFMAN_ONLY 2 #define Z_RLE 3 #define Z_FIXED 4 #define Z_DEFAULT_STRATEGY 0 /* compression strategy; see deflateInit2() below for details */ #define Z_BINARY 0 #define Z_TEXT 1 #define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ #define Z_UNKNOWN 2 /* Possible values of the data_type field (though see inflate()) */ #define Z_DEFLATED 8 /* The deflate compression method (the only one supported in this version) */ #define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ #define zlib_version zlibVersion() /* for compatibility with versions < 1.0.2 */ /* basic functions */ ZEXTERN const char * ZEXPORT zlibVersion OF((void)); /* The application can compare zlibVersion and ZLIB_VERSION for consistency. * If the first character differs, the library code actually used is * not compatible with the zlib.h header file used by the application. * This check is automatically made by deflateInit and inflateInit. */ /* * ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); * * Initializes the internal stream state for compression. The fields * zalloc, zfree and opaque must be initialized before by the caller. * If zalloc and zfree are set to Z_NULL, deflateInit updates them to * use default allocation functions. * * The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: * 1 gives best speed, 9 gives best compression, 0 gives no compression at * all (the input data is simply copied a block at a time). * Z_DEFAULT_COMPRESSION requests a default compromise between speed and * compression (currently equivalent to level 6). * * deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not * enough memory, Z_STREAM_ERROR if level is not a valid compression level, * Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible * with the version assumed by the caller (ZLIB_VERSION). * msg is set to null if there is no error message. deflateInit does not * perform any compression: this will be done by deflate(). */ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); /* * deflate compresses as much data as possible, and stops when the input * buffer becomes empty or the output buffer becomes full. It may introduce some * output latency (reading input without producing any output) except when * forced to flush. * * The detailed semantics are as follows. deflate performs one or both of the * following actions: * * - Compress more input starting at next_in and update next_in and avail_in * accordingly. If not all input can be processed (because there is not * enough room in the output buffer), next_in and avail_in are updated and * processing will resume at this point for the next call of deflate(). * * - Provide more output starting at next_out and update next_out and avail_out * accordingly. This action is forced if the parameter flush is non zero. * Forcing flush frequently degrades the compression ratio, so this parameter * should be set only when necessary (in interactive applications). * Some output may be provided even if flush is not set. * * Before the call of deflate(), the application should ensure that at least * one of the actions is possible, by providing more input and/or consuming * more output, and updating avail_in or avail_out accordingly; avail_out * should never be zero before the call. The application can consume the * compressed output when it wants, for example when the output buffer is full * (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK * and with zero avail_out, it must be called again after making room in the * output buffer because there might be more output pending. * * Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to * decide how much data to accumualte before producing output, in order to * maximize compression. * * If the parameter flush is set to Z_SYNC_FLUSH, all pending output is * flushed to the output buffer and the output is aligned on a byte boundary, so * that the decompressor can get all input data available so far. (In particular * avail_in is zero after the call if enough output space has been provided * before the call.) Flushing may degrade compression for some compression * algorithms and so it should be used only when necessary. * * If flush is set to Z_FULL_FLUSH, all output is flushed as with * Z_SYNC_FLUSH, and the compression state is reset so that decompression can * restart from this point if previous compressed data has been damaged or if * random access is desired. Using Z_FULL_FLUSH too often can seriously degrade * compression. * * If deflate returns with avail_out == 0, this function must be called again * with the same value of the flush parameter and more output space (updated * avail_out), until the flush is complete (deflate returns with non-zero * avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that * avail_out is greater than six to avoid repeated flush markers due to * avail_out == 0 on return. * * If the parameter flush is set to Z_FINISH, pending input is processed, * pending output is flushed and deflate returns with Z_STREAM_END if there * was enough output space; if deflate returns with Z_OK, this function must be * called again with Z_FINISH and more output space (updated avail_out) but no * more input data, until it returns with Z_STREAM_END or an error. After * deflate has returned Z_STREAM_END, the only possible operations on the * stream are deflateReset or deflateEnd. * * Z_FINISH can be used immediately after deflateInit if all the compression * is to be done in a single step. In this case, avail_out must be at least * the value returned by deflateBound (see below). If deflate does not return * Z_STREAM_END, then it must be called again as described above. * * deflate() sets strm->adler to the adler32 checksum of all input read * so far (that is, total_in bytes). * * deflate() may update strm->data_type if it can make a good guess about * the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered * binary. This field is only for information purposes and does not affect * the compression algorithm in any manner. * * deflate() returns Z_OK if some progress has been made (more input * processed or more output produced), Z_STREAM_END if all input has been * consumed and all output has been produced (only when flush is set to * Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example * if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible * (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not * fatal, and deflate() can be called again with more input and more output * space to continue compressing. */ ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); /* * All dynamically allocated data structures for this stream are freed. * This function discards any unprocessed input and does not flush any * pending output. * * deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the * stream state was inconsistent, Z_DATA_ERROR if the stream was freed * prematurely (some input or output was discarded). In the error case, * msg may be set but then points to a static string (which must not be * deallocated). */ /* * ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); * * Initializes the internal stream state for decompression. The fields * next_in, avail_in, zalloc, zfree and opaque must be initialized before by * the caller. If next_in is not Z_NULL and avail_in is large enough (the exact * value depends on the compression method), inflateInit determines the * compression method from the zlib header and allocates all data structures * accordingly; otherwise the allocation will be deferred to the first call of * inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to * use default allocation functions. * * inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough * memory, Z_VERSION_ERROR if the zlib library version is incompatible with the * version assumed by the caller. msg is set to null if there is no error * message. inflateInit does not perform any decompression apart from reading * the zlib header if present: this will be done by inflate(). (So next_in and * avail_in may be modified, but next_out and avail_out are unchanged.) */ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); /* * inflate decompresses as much data as possible, and stops when the input * buffer becomes empty or the output buffer becomes full. It may introduce * some output latency (reading input without producing any output) except when * forced to flush. * * The detailed semantics are as follows. inflate performs one or both of the * following actions: * * - Decompress more input starting at next_in and update next_in and avail_in * accordingly. If not all input can be processed (because there is not * enough room in the output buffer), next_in is updated and processing * will resume at this point for the next call of inflate(). * * - Provide more output starting at next_out and update next_out and avail_out * accordingly. inflate() provides as much output as possible, until there * is no more input data or no more space in the output buffer (see below * about the flush parameter). * * Before the call of inflate(), the application should ensure that at least * one of the actions is possible, by providing more input and/or consuming * more output, and updating the next_* and avail_* values accordingly. * The application can consume the uncompressed output when it wants, for * example when the output buffer is full (avail_out == 0), or after each * call of inflate(). If inflate returns Z_OK and with zero avail_out, it * must be called again after making room in the output buffer because there * might be more output pending. * * The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, * Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much * output as possible to the output buffer. Z_BLOCK requests that inflate() stop * if and when it gets to the next deflate block boundary. When decoding the * zlib or gzip format, this will cause inflate() to return immediately after * the header and before the first block. When doing a raw inflate, inflate() * will go ahead and process the first block, and will return when it gets to * the end of that block, or when it runs out of data. * * The Z_BLOCK option assists in appending to or combining deflate streams. * Also to assist in this, on return inflate() will set strm->data_type to the * number of unused bits in the last byte taken from strm->next_in, plus 64 * if inflate() is currently decoding the last block in the deflate stream, * plus 128 if inflate() returned immediately after decoding an end-of-block * code or decoding the complete header up to just before the first byte of the * deflate stream. The end-of-block will not be indicated until all of the * uncompressed data from that block has been written to strm->next_out. The * number of unused bits may in general be greater than seven, except when * bit 7 of data_type is set, in which case the number of unused bits will be * less than eight. * * inflate() should normally be called until it returns Z_STREAM_END or an * error. However if all decompression is to be performed in a single step * (a single call of inflate), the parameter flush should be set to * Z_FINISH. In this case all pending input is processed and all pending * output is flushed; avail_out must be large enough to hold all the * uncompressed data. (The size of the uncompressed data may have been saved * by the compressor for this purpose.) The next operation on this stream must * be inflateEnd to deallocate the decompression state. The use of Z_FINISH * is never required, but can be used to inform inflate that a faster approach * may be used for the single inflate() call. * * In this implementation, inflate() always flushes as much output as * possible to the output buffer, and always uses the faster approach on the * first call. So the only effect of the flush parameter in this implementation * is on the return value of inflate(), as noted below, or when it returns early * because Z_BLOCK is used. * * If a preset dictionary is needed after this call (see inflateSetDictionary * below), inflate sets strm->adler to the adler32 checksum of the dictionary * chosen by the compressor and returns Z_NEED_DICT; otherwise it sets * strm->adler to the adler32 checksum of all output produced so far (that is, * total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described * below. At the end of the stream, inflate() checks that its computed adler32 * checksum is equal to that saved by the compressor and returns Z_STREAM_END * only if the checksum is correct. * * inflate() will decompress and check either zlib-wrapped or gzip-wrapped * deflate data. The header type is detected automatically. Any information * contained in the gzip header is not retained, so applications that need that * information should instead use raw inflate, see inflateInit2() below, or * inflateBack() and perform their own processing of the gzip header and * trailer. * * inflate() returns Z_OK if some progress has been made (more input processed * or more output produced), Z_STREAM_END if the end of the compressed data has * been reached and all uncompressed output has been produced, Z_NEED_DICT if a * preset dictionary is needed at this point, Z_DATA_ERROR if the input data was * corrupted (input stream not conforming to the zlib format or incorrect check * value), Z_STREAM_ERROR if the stream structure was inconsistent (for example * if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory, * Z_BUF_ERROR if no progress is possible or if there was not enough room in the * output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and * inflate() can be called again with more input and more output space to * continue decompressing. If Z_DATA_ERROR is returned, the application may then * call inflateSync() to look for a good compression block if a partial recovery * of the data is desired. */ ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); /* * All dynamically allocated data structures for this stream are freed. * This function discards any unprocessed input and does not flush any * pending output. * * inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state * was inconsistent. In the error case, msg may be set but then points to a * static string (which must not be deallocated). */ /* Advanced functions */ /* * The following functions are needed only in some special applications. */ /* * ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, * int level, * int method, * int windowBits, * int memLevel, * int strategy)); * * This is another version of deflateInit with more compression options. The * fields next_in, zalloc, zfree and opaque must be initialized before by * the caller. * * The method parameter is the compression method. It must be Z_DEFLATED in * this version of the library. * * The windowBits parameter is the base two logarithm of the window size * (the size of the history buffer). It should be in the range 8..15 for this * version of the library. Larger values of this parameter result in better * compression at the expense of memory usage. The default value is 15 if * deflateInit is used instead. * * windowBits can also be -8..-15 for raw deflate. In this case, -windowBits * determines the window size. deflate() will then generate raw deflate data * with no zlib header or trailer, and will not compute an adler32 check value. * * windowBits can also be greater than 15 for optional gzip encoding. Add * 16 to windowBits to write a simple gzip header and trailer around the * compressed data instead of a zlib wrapper. The gzip header will have no * file name, no extra data, no comment, no modification time (set to zero), * no header crc, and the operating system will be set to 255 (unknown). If a * gzip stream is being written, strm->adler is a crc32 instead of an adler32. * * The memLevel parameter specifies how much memory should be allocated * for the internal compression state. memLevel=1 uses minimum memory but * is slow and reduces compression ratio; memLevel=9 uses maximum memory * for optimal speed. The default value is 8. See zconf.h for total memory * usage as a function of windowBits and memLevel. * * The strategy parameter is used to tune the compression algorithm. Use the * value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a * filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no * string match), or Z_RLE to limit match distances to one (run-length * encoding). Filtered data consists mostly of small values with a somewhat * random distribution. In this case, the compression algorithm is tuned to * compress them better. The effect of Z_FILTERED is to force more Huffman * coding and less string matching; it is somewhat intermediate between * Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as * Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy * parameter only affects the compression ratio but not the correctness of the * compressed output even if it is not set appropriately. Z_FIXED prevents the * use of dynamic Huffman codes, allowing for a simpler decoder for special * applications. * * deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough * memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid * method). msg is set to null if there is no error message. deflateInit2 does * not perform any compression: this will be done by deflate(). */ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, const Bytef *dictionary, uInt dictLength)); /* * Initializes the compression dictionary from the given byte sequence * without producing any compressed output. This function must be called * immediately after deflateInit, deflateInit2 or deflateReset, before any * call of deflate. The compressor and decompressor must use exactly the same * dictionary (see inflateSetDictionary). * * The dictionary should consist of strings (byte sequences) that are likely * to be encountered later in the data to be compressed, with the most commonly * used strings preferably put towards the end of the dictionary. Using a * dictionary is most useful when the data to be compressed is short and can be * predicted with good accuracy; the data can then be compressed better than * with the default empty dictionary. * * Depending on the size of the compression data structures selected by * deflateInit or deflateInit2, a part of the dictionary may in effect be * discarded, for example if the dictionary is larger than the window size in * deflate or deflate2. Thus the strings most likely to be useful should be * put at the end of the dictionary, not at the front. In addition, the * current implementation of deflate will use at most the window size minus * 262 bytes of the provided dictionary. * * Upon return of this function, strm->adler is set to the adler32 value * of the dictionary; the decompressor may later use this value to determine * which dictionary has been used by the compressor. (The adler32 value * applies to the whole dictionary even if only a subset of the dictionary is * actually used by the compressor.) If a raw deflate was requested, then the * adler32 value is not computed and strm->adler is not set. * * deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a * parameter is invalid (such as NULL dictionary) or the stream state is * inconsistent (for example if deflate has already been called for this stream * or if the compression method is bsort). deflateSetDictionary does not * perform any compression: this will be done by deflate(). */ ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, z_streamp source)); /* * Sets the destination stream as a complete copy of the source stream. * * This function can be useful when several compression strategies will be * tried, for example when there are several ways of pre-processing the input * data with a filter. The streams that will be discarded should then be freed * by calling deflateEnd. Note that deflateCopy duplicates the internal * compression state which can be quite large, so this strategy is slow and * can consume lots of memory. * * deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not * enough memory, Z_STREAM_ERROR if the source stream state was inconsistent * (such as zalloc being NULL). msg is left unchanged in both source and * destination. */ ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); /* * This function is equivalent to deflateEnd followed by deflateInit, * but does not free and reallocate all the internal compression state. * The stream will keep the same compression level and any other attributes * that may have been set by deflateInit2. * * deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source * stream state was inconsistent (such as zalloc or state being NULL). */ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, int level, int strategy)); /* * Dynamically update the compression level and compression strategy. The * interpretation of level and strategy is as in deflateInit2. This can be * used to switch between compression and straight copy of the input data, or * to switch to a different kind of input data requiring a different * strategy. If the compression level is changed, the input available so far * is compressed with the old level (and may be flushed); the new level will * take effect only at the next call of deflate(). * * Before the call of deflateParams, the stream state must be set as for * a call of deflate(), since the currently available input may have to * be compressed and flushed. In particular, strm->avail_out must be non-zero. * * deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source * stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR * if strm->avail_out was zero. */ ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, int good_length, int max_lazy, int nice_length, int max_chain)); /* * Fine tune deflate's internal compression parameters. This should only be * used by someone who understands the algorithm used by zlib's deflate for * searching for the best matching string, and even then only by the most * fanatic optimizer trying to squeeze out the last compressed bit for their * specific input data. Read the deflate.c source code for the meaning of the * max_lazy, good_length, nice_length, and max_chain parameters. * * deflateTune() can be called after deflateInit() or deflateInit2(), and * returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. */ ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, uLong sourceLen)); /* * deflateBound() returns an upper bound on the compressed size after * deflation of sourceLen bytes. It must be called after deflateInit() * or deflateInit2(). This would be used to allocate an output buffer * for deflation in a single pass, and so would be called before deflate(). */ ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, int bits, int value)); /* * deflatePrime() inserts bits in the deflate output stream. The intent * is that this function is used to start off the deflate output with the * bits leftover from a previous deflate stream when appending to it. As such, * this function can only be used for raw deflate, and must be used before the * first deflate() call after a deflateInit2() or deflateReset(). bits must be * less than or equal to 16, and that many of the least significant bits of * value will be inserted in the output. * * deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source * stream state was inconsistent. */ ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, gz_headerp head)); /* * deflateSetHeader() provides gzip header information for when a gzip * stream is requested by deflateInit2(). deflateSetHeader() may be called * after deflateInit2() or deflateReset() and before the first call of * deflate(). The text, time, os, extra field, name, and comment information * in the provided gz_header structure are written to the gzip header (xflag is * ignored -- the extra flags are set according to the compression level). The * caller must assure that, if not Z_NULL, name and comment are terminated with * a zero byte, and that if extra is not Z_NULL, that extra_len bytes are * available there. If hcrc is true, a gzip header crc is included. Note that * the current versions of the command-line version of gzip (up through version * 1.3.x) do not support header crc's, and will report that it is a "multi-part * gzip file" and give up. * * If deflateSetHeader is not used, the default gzip header has text false, * the time set to zero, and os set to 255, with no extra, name, or comment * fields. The gzip header is returned to the default state by deflateReset(). * * deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source * stream state was inconsistent. */ /* * ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, * int windowBits)); * * This is another version of inflateInit with an extra parameter. The * fields next_in, avail_in, zalloc, zfree and opaque must be initialized * before by the caller. * * The windowBits parameter is the base two logarithm of the maximum window * size (the size of the history buffer). It should be in the range 8..15 for * this version of the library. The default value is 15 if inflateInit is used * instead. windowBits must be greater than or equal to the windowBits value * provided to deflateInit2() while compressing, or it must be equal to 15 if * deflateInit2() was not used. If a compressed stream with a larger window * size is given as input, inflate() will return with the error code * Z_DATA_ERROR instead of trying to allocate a larger window. * * windowBits can also be -8..-15 for raw inflate. In this case, -windowBits * determines the window size. inflate() will then process raw deflate data, * not looking for a zlib or gzip header, not generating a check value, and not * looking for any check values for comparison at the end of the stream. This * is for use with other formats that use the deflate compressed data format * such as zip. Those formats provide their own check values. If a custom * format is developed using the raw deflate format for compressed data, it is * recommended that a check value such as an adler32 or a crc32 be applied to * the uncompressed data as is done in the zlib, gzip, and zip formats. For * most applications, the zlib format should be used as is. Note that comments * above on the use in deflateInit2() applies to the magnitude of windowBits. * * windowBits can also be greater than 15 for optional gzip decoding. Add * 32 to windowBits to enable zlib and gzip decoding with automatic header * detection, or add 16 to decode only the gzip format (the zlib format will * return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is * a crc32 instead of an adler32. * * inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough * memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg * is set to null if there is no error message. inflateInit2 does not perform * any decompression apart from reading the zlib header if present: this will * be done by inflate(). (So next_in and avail_in may be modified, but next_out * and avail_out are unchanged.) */ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, const Bytef *dictionary, uInt dictLength)); /* * Initializes the decompression dictionary from the given uncompressed byte * sequence. This function must be called immediately after a call of inflate, * if that call returned Z_NEED_DICT. The dictionary chosen by the compressor * can be determined from the adler32 value returned by that call of inflate. * The compressor and decompressor must use exactly the same dictionary (see * deflateSetDictionary). For raw inflate, this function can be called * immediately after inflateInit2() or inflateReset() and before any call of * inflate() to set the dictionary. The application must insure that the * dictionary that was used for compression is provided. * * inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a * parameter is invalid (such as NULL dictionary) or the stream state is * inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the * expected one (incorrect adler32 value). inflateSetDictionary does not * perform any decompression: this will be done by subsequent calls of * inflate(). */ ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); /* * Skips invalid compressed data until a full flush point (see above the * description of deflate with Z_FULL_FLUSH) can be found, or until all * available input is skipped. No output is provided. * * inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR * if no more input was provided, Z_DATA_ERROR if no flush point has been found, * or Z_STREAM_ERROR if the stream structure was inconsistent. In the success * case, the application may save the current current value of total_in which * indicates where valid compressed data was found. In the error case, the * application may repeatedly call inflateSync, providing more input each time, * until success or end of the input data. */ ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, z_streamp source)); /* * Sets the destination stream as a complete copy of the source stream. * * This function can be useful when randomly accessing a large stream. The * first pass through the stream can periodically record the inflate state, * allowing restarting inflate at those points when randomly accessing the * stream. * * inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not * enough memory, Z_STREAM_ERROR if the source stream state was inconsistent * (such as zalloc being NULL). msg is left unchanged in both source and * destination. */ ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); /* * This function is equivalent to inflateEnd followed by inflateInit, * but does not free and reallocate all the internal decompression state. * The stream will keep attributes that may have been set by inflateInit2. * * inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source * stream state was inconsistent (such as zalloc or state being NULL). */ ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, int bits, int value)); /* * This function inserts bits in the inflate input stream. The intent is * that this function is used to start inflating at a bit position in the * middle of a byte. The provided bits will be used before any bytes are used * from next_in. This function should only be used with raw inflate, and * should be used before the first inflate() call after inflateInit2() or * inflateReset(). bits must be less than or equal to 16, and that many of the * least significant bits of value will be inserted in the input. * * inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source * stream state was inconsistent. */ ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, gz_headerp head)); /* * inflateGetHeader() requests that gzip header information be stored in the * provided gz_header structure. inflateGetHeader() may be called after * inflateInit2() or inflateReset(), and before the first call of inflate(). * As inflate() processes the gzip stream, head->done is zero until the header * is completed, at which time head->done is set to one. If a zlib stream is * being decoded, then head->done is set to -1 to indicate that there will be * no gzip header information forthcoming. Note that Z_BLOCK can be used to * force inflate() to return immediately after header processing is complete * and before any actual data is decompressed. * * The text, time, xflags, and os fields are filled in with the gzip header * contents. hcrc is set to true if there is a header CRC. (The header CRC * was valid if done is set to one.) If extra is not Z_NULL, then extra_max * contains the maximum number of bytes to write to extra. Once done is true, * extra_len contains the actual extra field length, and extra contains the * extra field, or that field truncated if extra_max is less than extra_len. * If name is not Z_NULL, then up to name_max characters are written there, * terminated with a zero unless the length is greater than name_max. If * comment is not Z_NULL, then up to comm_max characters are written there, * terminated with a zero unless the length is greater than comm_max. When * any of extra, name, or comment are not Z_NULL and the respective field is * not present in the header, then that field is set to Z_NULL to signal its * absence. This allows the use of deflateSetHeader() with the returned * structure to duplicate the header. However if those fields are set to * allocated memory, then the application will need to save those pointers * elsewhere so that they can be eventually freed. * * If inflateGetHeader is not used, then the header information is simply * discarded. The header is always checked for validity, including the header * CRC if present. inflateReset() will reset the process to discard the header * information. The application would need to call inflateGetHeader() again to * retrieve the header from the next gzip stream. * * inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source * stream state was inconsistent. */ /* * ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, * unsigned char FAR *window)); * * Initialize the internal stream state for decompression using inflateBack() * calls. The fields zalloc, zfree and opaque in strm must be initialized * before the call. If zalloc and zfree are Z_NULL, then the default library- * derived memory allocation routines are used. windowBits is the base two * logarithm of the window size, in the range 8..15. window is a caller * supplied buffer of that size. Except for special applications where it is * assured that deflate was used with small window sizes, windowBits must be 15 * and a 32K byte window must be supplied to be able to decompress general * deflate streams. * * See inflateBack() for the usage of these routines. * * inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of * the paramaters are invalid, Z_MEM_ERROR if the internal state could not * be allocated, or Z_VERSION_ERROR if the version of the library does not * match the version of the header file. */ typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, in_func in, void FAR *in_desc, out_func out, void FAR *out_desc)); /* * inflateBack() does a raw inflate with a single call using a call-back * interface for input and output. This is more efficient than inflate() for * file i/o applications in that it avoids copying between the output and the * sliding window by simply making the window itself the output buffer. This * function trusts the application to not change the output buffer passed by * the output function, at least until inflateBack() returns. * * inflateBackInit() must be called first to allocate the internal state * and to initialize the state with the user-provided window buffer. * inflateBack() may then be used multiple times to inflate a complete, raw * deflate stream with each call. inflateBackEnd() is then called to free * the allocated state. * * A raw deflate stream is one with no zlib or gzip header or trailer. * This routine would normally be used in a utility that reads zip or gzip * files and writes out uncompressed files. The utility would decode the * header and process the trailer on its own, hence this routine expects * only the raw deflate stream to decompress. This is different from the * normal behavior of inflate(), which expects either a zlib or gzip header and * trailer around the deflate stream. * * inflateBack() uses two subroutines supplied by the caller that are then * called by inflateBack() for input and output. inflateBack() calls those * routines until it reads a complete deflate stream and writes out all of the * uncompressed data, or until it encounters an error. The function's * parameters and return types are defined above in the in_func and out_func * typedefs. inflateBack() will call in(in_desc, &buf) which should return the * number of bytes of provided input, and a pointer to that input in buf. If * there is no input available, in() must return zero--buf is ignored in that * case--and inflateBack() will return a buffer error. inflateBack() will call * out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() * should return zero on success, or non-zero on failure. If out() returns * non-zero, inflateBack() will return with an error. Neither in() nor out() * are permitted to change the contents of the window provided to * inflateBackInit(), which is also the buffer that out() uses to write from. * The length written by out() will be at most the window size. Any non-zero * amount of input may be provided by in(). * * For convenience, inflateBack() can be provided input on the first call by * setting strm->next_in and strm->avail_in. If that input is exhausted, then * in() will be called. Therefore strm->next_in must be initialized before * calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called * immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in * must also be initialized, and then if strm->avail_in is not zero, input will * initially be taken from strm->next_in[0 .. strm->avail_in - 1]. * * The in_desc and out_desc parameters of inflateBack() is passed as the * first parameter of in() and out() respectively when they are called. These * descriptors can be optionally used to pass any information that the caller- * supplied in() and out() functions need to do their job. * * On return, inflateBack() will set strm->next_in and strm->avail_in to * pass back any unused input that was provided by the last in() call. The * return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR * if in() or out() returned an error, Z_DATA_ERROR if there was a format * error in the deflate stream (in which case strm->msg is set to indicate the * nature of the error), or Z_STREAM_ERROR if the stream was not properly * initialized. In the case of Z_BUF_ERROR, an input or output error can be * distinguished using strm->next_in which will be Z_NULL only if in() returned * an error. If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to * out() returning non-zero. (in() will always be called before out(), so * strm->next_in is assured to be defined if out() returns non-zero.) Note * that inflateBack() cannot return Z_OK. */ ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); /* * All memory allocated by inflateBackInit() is freed. * * inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream * state was inconsistent. */ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); /* Return flags indicating compile-time options. * * Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: * 1.0: size of uInt * 3.2: size of uLong * 5.4: size of voidpf (pointer) * 7.6: size of z_off_t * * Compiler, assembler, and debug options: * 8: DEBUG * 9: ASMV or ASMINF -- use ASM code * 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention * 11: 0 (reserved) * * One-time table building (smaller code, but not thread-safe if true): * 12: BUILDFIXED -- build static block decoding tables when needed * 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed * 14,15: 0 (reserved) * * Library content (indicates missing functionality): * 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking * deflate code when not needed) * 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect * and decode gzip streams (to avoid linking crc code) * 18-19: 0 (reserved) * * Operation variations (changes in library functionality): * 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate * 21: FASTEST -- deflate algorithm with only one, lowest compression level * 22,23: 0 (reserved) * * The sprintf variant used by gzprintf (zero is best): * 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format * 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! * 26: 0 = returns value, 1 = void -- 1 means inferred string length returned * * Remainder: * 27-31: 0 (reserved) */ /* utility functions */ /* * The following utility functions are implemented on top of the * basic stream-oriented functions. To simplify the interface, some * default options are assumed (compression level and memory usage, * standard memory allocation functions). The source code of these * utility functions can easily be modified if you need special options. */ ZEXTERN int ZEXPORT compress OF((Bytef * dest, uLongf *destLen, const Bytef *source, uLong sourceLen)); /* * Compresses the source buffer into the destination buffer. sourceLen is * the byte length of the source buffer. Upon entry, destLen is the total * size of the destination buffer, which must be at least the value returned * by compressBound(sourceLen). Upon exit, destLen is the actual size of the * compressed buffer. * This function can be used to compress a whole file at once if the * input file is mmap'ed. * compress returns Z_OK if success, Z_MEM_ERROR if there was not * enough memory, Z_BUF_ERROR if there was not enough room in the output * buffer. */ ZEXTERN int ZEXPORT compress2 OF((Bytef * dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level)); /* * Compresses the source buffer into the destination buffer. The level * parameter has the same meaning as in deflateInit. sourceLen is the byte * length of the source buffer. Upon entry, destLen is the total size of the * destination buffer, which must be at least the value returned by * compressBound(sourceLen). Upon exit, destLen is the actual size of the * compressed buffer. * * compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough * memory, Z_BUF_ERROR if there was not enough room in the output buffer, * Z_STREAM_ERROR if the level parameter is invalid. */ ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); /* * compressBound() returns an upper bound on the compressed size after * compress() or compress2() on sourceLen bytes. It would be used before * a compress() or compress2() call to allocate the destination buffer. */ ZEXTERN int ZEXPORT uncompress OF((Bytef * dest, uLongf *destLen, const Bytef *source, uLong sourceLen)); /* * Decompresses the source buffer into the destination buffer. sourceLen is * the byte length of the source buffer. Upon entry, destLen is the total * size of the destination buffer, which must be large enough to hold the * entire uncompressed data. (The size of the uncompressed data must have * been saved previously by the compressor and transmitted to the decompressor * by some mechanism outside the scope of this compression library.) * Upon exit, destLen is the actual size of the compressed buffer. * This function can be used to decompress a whole file at once if the * input file is mmap'ed. * * uncompress returns Z_OK if success, Z_MEM_ERROR if there was not * enough memory, Z_BUF_ERROR if there was not enough room in the output * buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. */ /* checksum functions */ /* * These functions are not related to compression but are exported * anyway because they might be useful in applications using the * compression library. */ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); /* * Update a running Adler-32 checksum with the bytes buf[0..len-1] and * return the updated checksum. If buf is NULL, this function returns * the required initial value for the checksum. * An Adler-32 checksum is almost as reliable as a CRC32 but can be computed * much faster. Usage example: * * uLong adler = adler32(0L, Z_NULL, 0); * * while (read_buffer(buffer, length) != EOF) { * adler = adler32(adler, buffer, length); * } * if (adler != original_adler) error(); */ ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, z_off_t len2)); /* * Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 * and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for * each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of * seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. */ ZEXTERN uLong ZEXPORT z_crc32 OF((uLong crc, const Bytef *buf, uInt len)); /* * Update a running CRC-32 with the bytes buf[0..len-1] and return the * updated CRC-32. If buf is NULL, this function returns the required initial * value for the for the crc. Pre- and post-conditioning (one's complement) is * performed within this function so it shouldn't be done by the application. * Usage example: * * uLong crc = crc32(0L, Z_NULL, 0); * * while (read_buffer(buffer, length) != EOF) { * crc = crc32(crc, buffer, length); * } * if (crc != original_crc) error(); */ ZEXTERN uLong ZEXPORT z_crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); /* * Combine two CRC-32 check values into one. For two sequences of bytes, * seq1 and seq2 with lengths len1 and len2, CRC-32 check values were * calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 * check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and * len2. */ /* various hacks, don't look :) */ /* deflateInit and inflateInit are macros to allow checking the zlib version * and the compiler's view of z_stream: */ ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, const char *version, int stream_size)); ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, const char *version, int stream_size)); ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy, const char *version, int stream_size)); ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, const char *version, int stream_size)); ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, unsigned char FAR *window, const char *version, int stream_size)); #define deflateInit(strm, level) \ deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) #define inflateInit(strm) \ inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) #define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ (strategy), ZLIB_VERSION, sizeof(z_stream)) #define inflateInit2(strm, windowBits) \ inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) #define inflateBackInit(strm, windowBits, window) \ inflateBackInit_((strm), (windowBits), (window), \ ZLIB_VERSION, sizeof(z_stream)) #if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) struct internal_state {int dummy;}; /* hack for buggy compilers */ #endif ZEXTERN const char * ZEXPORT zError OF((int)); ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); #ifdef __cplusplus } #endif #endif /* ZLIB_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/OSBase.h
/* * 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) 1999 Apple Computer, Inc. All rights reserved. * * HISTORY * */ #ifndef _OS_OSBASE_H #define _OS_OSBASE_H #include <sys/cdefs.h> #include <libkern/OSTypes.h> #include <stdint.h> __BEGIN_DECLS __END_DECLS #endif /* _OS_OSBASE_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/OSDebug.h
/* * 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) 1999 Apple Computer, Inc. All rights reserved. * * HISTORY * */ #ifndef _OS_OSDEBBUG_H #define _OS_OSDEBBUG_H #include <sys/cdefs.h> #include <mach/mach_types.h> __BEGIN_DECLS extern int log_leaks; /* Use kernel_debug() to log a backtrace */ extern void trace_backtrace(unsigned int debugid, unsigned int debugid2, unsigned long size, unsigned long data); /* Report a message with a 4 entry backtrace - very slow */ extern void OSReportWithBacktrace(const char *str, ...); extern unsigned OSBacktrace(void **bt, unsigned maxAddrs); /* Simple dump of 20 backtrace entries */ extern void OSPrintBacktrace(void); /*! @function OSKernelStackRemaining * @abstract Returns bytes available below the current stack frame. * @discussion Returns bytes available below the current stack frame. Safe for interrupt or thread context. * @result Approximate byte count available. */ vm_offset_t OSKernelStackRemaining( void ); __END_DECLS #define TRACE_MACHLEAKS(a, b, c, d) \ do { \ if (__builtin_expect(!!log_leaks, 0)) \ trace_backtrace(a,b,c,d); \ } while(0) #endif /* !_OS_OSDEBBUG_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/version.h
/* * Copyright (c) 2004 Apple Computer, Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * * The contents of this file constitute Original Code as defined in and * are subject to the Apple Public Source License Version 1.1 (the * "License"). You may not use this file except in compliance with the * License. Please obtain a copy of the License at * http://www.apple.com/publicsource and read it before using this file. * * This 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 OR NON-INFRINGEMENT. Please see the * License for the specific language governing rights and limitations * under the License. * * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ #ifndef LIBKERN_VERSION_H #define LIBKERN_VERSION_H /* Kernel versions conform to kext version strings, as described in: * http://developer.apple.com/technotes/tn/tn1132.html */ /* VERSION_MAJOR, version_major is an integer that represents that major version * of the kernel */ #define VERSION_MAJOR 21 /* VERSION_MINOR, version_minor is an integer that represents the minor version * of the kernel */ #define VERSION_MINOR 0 /* VERSION_VARIANT, version_variant is a string that contains the revision, * stage, and prerelease level of the kernel */ #define VERSION_VARIANT "1" /* VERSION_REVISION, version_revision is an integer that represents the revision * of the kernel */ #define VERSION_REVISION 1 /* VERSION_STAGE, version_stage, is an integer set to one of the following: */ #define VERSION_STAGE_DEV 0x20 #define VERSION_STAGE_ALPHA 0x40 #define VERSION_STAGE_BETA 0x60 #define VERSION_STAGE_RELEASE 0x80 #define VERSION_STAGE VERSION_STAGE_RELEASE /* VERSION_PRERELEASE_LEVEL, version_prerelease_level, is an integer sequence * number to distinguish between pre-release builds */ #define VERSION_PRERELEASE_LEVEL 0 /* OSBUILD_CONFIG, osbuild_config is a one-word string describing the build * configuration of the kernel, e.g., development or release */ #define OSBUILD_CONFIG "development" /* OSTYPE, ostype, is a string as returned by uname -s */ #define OSTYPE "Darwin" /* OSRELEASE, osrelease, is a string as returned by uname -r */ #define OSRELEASE "21.0.1" #ifndef ASSEMBLER #if defined(__cplusplus) extern "C" { #endif /* Build-time value of VERSION_MAJOR */ extern const int version_major; /* Build-time value of VERSION_MINOR */ extern const int version_minor; /* Build-time value of VERSION_VARIANT */ extern const char version_variant[]; /* Build-time value of VERSION_REVISION */ extern const int version_revision; /* Build-time value of VERSION_STAGE */ extern const int version_stage; /* Build-time value of VERSION_PRERELEASE_LEVEL */ extern const int version_prerelease_level; /* Build-time value of CURRENT_KERNEL_CONFIG */ extern const char osbuild_config[]; /* Build-time value of OSTYPE */ extern const char ostype[]; /* Build-time value of OSRELEASE */ extern const char osrelease[]; /* osbuilder is a string as returned by uname -r */ extern const char osbuilder[]; /* version is a string of the following form, as returned by uname -v: * "Darwin Kernel Version <osrelease>: <build date>; <osbuilder>:<build root>" */ extern const char version[]; #define OSVERSIZE 256 extern char osversion[]; #if defined(__cplusplus) } #endif #endif /* !ASSEMBLER */ #endif /* LIBKERN_VERSION_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/locks.h
/* * Copyright (c) 2003-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@ */ #ifndef LIBKERN_LOCKS_H #define LIBKERN_LOCKS_H #include <sys/cdefs.h> #include <kern/locks.h> #endif /* LIBKERN_LOCKS_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/crc.h
/* * Copyright (c) 2017-2017 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 _LIBKERN_CRC_H_ #define _LIBKERN_CRC_H_ #include <sys/cdefs.h> #include <stdint.h> __BEGIN_DECLS uint16_t crc16(uint16_t crc, const void *bufp, size_t len); uint32_t crc32(uint32_t crc, const void *bufp, size_t len); __END_DECLS #endif /* _LIBKERN_CRC_H_ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/zconf.h
/* * Copyright (c) 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@ */ /* zconf.h -- configuration of the zlib compression library * Copyright (C) 1995-2005 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ #ifndef ZCONF_H #define ZCONF_H /* * If you *really* need a unique prefix for all types and library functions, * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. */ #ifdef Z_PREFIX # define deflateInit_ z_deflateInit_ # define deflate z_deflate # define deflateEnd z_deflateEnd # define inflateInit_ z_inflateInit_ # define inflate z_inflate # define inflateEnd z_inflateEnd # define deflateInit2_ z_deflateInit2_ # define deflateSetDictionary z_deflateSetDictionary # define deflateCopy z_deflateCopy # define deflateReset z_deflateReset # define deflateParams z_deflateParams # define deflateBound z_deflateBound # define deflatePrime z_deflatePrime # define inflateInit2_ z_inflateInit2_ # define inflateSetDictionary z_inflateSetDictionary # define inflateSync z_inflateSync # define inflateSyncPoint z_inflateSyncPoint # define inflateCopy z_inflateCopy # define inflateReset z_inflateReset # define inflateBack z_inflateBack # define inflateBackEnd z_inflateBackEnd # define compress z_compress # define compress2 z_compress2 # define compressBound z_compressBound # define uncompress z_uncompress # define adler32 z_adler32 # define crc32 z_crc32 # define get_crc_table z_get_crc_table # define zError z_zError # define alloc_func z_alloc_func # define free_func z_free_func # define in_func z_in_func # define out_func z_out_func # define Byte z_Byte # define uInt z_uInt # define uLong z_uLong # define Bytef z_Bytef # define charf z_charf # define intf z_intf # define uIntf z_uIntf # define uLongf z_uLongf # define voidpf z_voidpf # define voidp z_voidp #endif #if defined(__MSDOS__) && !defined(MSDOS) # define MSDOS #endif #if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) # define OS2 #endif #if defined(_WINDOWS) && !defined(WINDOWS) # define WINDOWS #endif #if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) # ifndef WIN32 # define WIN32 # endif #endif #if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) # if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) # ifndef SYS16BIT # define SYS16BIT # endif # endif #endif /* * Compile with -DMAXSEG_64K if the alloc function cannot allocate more * than 64k bytes at a time (needed on systems with 16-bit int). */ #ifdef SYS16BIT # define MAXSEG_64K #endif #ifdef MSDOS # define UNALIGNED_OK #endif #ifdef __STDC_VERSION__ # ifndef STDC # define STDC # endif # if __STDC_VERSION__ >= 199901L # ifndef STDC99 # define STDC99 # endif # endif #endif #if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) # define STDC #endif #if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) # define STDC #endif #if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) # define STDC #endif #if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) # define STDC #endif #if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ # define STDC #endif #ifndef STDC # ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ # define const /* note: need a more gentle solution here */ # endif #endif /* Some Mac compilers merge all .h files incorrectly: */ #if defined(__MWERKS__) || defined(applec) || defined(THINK_C) || defined(__SC__) # define NO_DUMMY_DECL #endif /* Maximum value for memLevel in deflateInit2 */ #ifndef MAX_MEM_LEVEL # ifdef MAXSEG_64K # define MAX_MEM_LEVEL 8 # else # define MAX_MEM_LEVEL 9 # endif #endif /* Maximum value for windowBits in deflateInit2 and inflateInit2. * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files * created by gzip. (Files created by minigzip can still be extracted by * gzip.) */ #ifndef MAX_WBITS # define MAX_WBITS 15 /* 32K LZ77 window */ #endif /* The memory requirements for deflate are (in bytes): * (1 << (windowBits+2)) + (1 << (memLevel+9)) * that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) * plus a few kilobytes for small objects. For example, if you want to reduce * the default memory requirements from 256K to 128K, compile with * make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" * Of course this will generally degrade compression (there's no free lunch). * * The memory requirements for inflate are (in bytes) 1 << windowBits * that is, 32K for windowBits=15 (default value) plus a few kilobytes * for small objects. */ /* Type declarations */ #ifndef OF /* function prototypes */ # ifdef STDC # define OF(args) args # else # define OF(args) () # endif #endif /* The following definitions for FAR are needed only for MSDOS mixed * model programming (small or medium model with some far allocations). * This was tested only with MSC; for other MSDOS compilers you may have * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, * just define FAR to be empty. */ #ifdef SYS16BIT # if defined(M_I86SM) || defined(M_I86MM) /* MSC small or medium model */ # define SMALL_MEDIUM # ifdef _MSC_VER # define FAR _far # else # define FAR far # endif # endif # if (defined(__SMALL__) || defined(__MEDIUM__)) /* Turbo C small or medium model */ # define SMALL_MEDIUM # ifdef __BORLANDC__ # define FAR _far # else # define FAR far # endif # endif #endif #if defined(WINDOWS) || defined(WIN32) /* If building or using zlib as a DLL, define ZLIB_DLL. * This is not mandatory, but it offers a little performance increase. */ # ifdef ZLIB_DLL # if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) # ifdef ZLIB_INTERNAL # define ZEXTERN extern __declspec(dllexport) # else # define ZEXTERN extern __declspec(dllimport) # endif # endif # endif /* ZLIB_DLL */ /* If building or using zlib with the WINAPI/WINAPIV calling convention, * define ZLIB_WINAPI. * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. */ # ifdef ZLIB_WINAPI # ifdef FAR # undef FAR # endif # include <windows.h> /* No need for _export, use ZLIB.DEF instead. */ /* For complete Windows compatibility, use WINAPI, not __stdcall. */ # define ZEXPORT WINAPI # ifdef WIN32 # define ZEXPORTVA WINAPIV # else # define ZEXPORTVA FAR CDECL # endif # endif #endif #if defined (__BEOS__) # ifdef ZLIB_DLL # ifdef ZLIB_INTERNAL # define ZEXPORT __declspec(dllexport) # define ZEXPORTVA __declspec(dllexport) # else # define ZEXPORT __declspec(dllimport) # define ZEXPORTVA __declspec(dllimport) # endif # endif #endif #ifndef ZEXTERN # define ZEXTERN extern #endif #ifndef ZEXPORT # define ZEXPORT #endif #ifndef ZEXPORTVA # define ZEXPORTVA #endif #ifndef FAR # define FAR #endif #if !defined(__MACTYPES__) typedef unsigned char Byte; /* 8 bits */ #endif typedef unsigned int uInt; /* 16 bits or more */ typedef unsigned long uLong; /* 32 bits or more */ #ifdef SMALL_MEDIUM /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ # define Bytef Byte FAR #else typedef Byte FAR Bytef; #endif typedef char FAR charf; typedef int FAR intf; typedef uInt FAR uIntf; typedef uLong FAR uLongf; #ifdef STDC typedef void const *voidpc; typedef void FAR *voidpf; typedef void *voidp; #else typedef Byte const *voidpc; typedef Byte FAR *voidpf; typedef Byte *voidp; #endif #if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */ # include <sys/types.h> /* for off_t */ # include <unistd.h> /* for SEEK_* and off_t */ # ifdef VMS # include <unixio.h> /* for off_t */ # endif # define z_off_t off_t #endif #ifndef SEEK_SET # define SEEK_SET 0 /* Seek from beginning of file. */ # define SEEK_CUR 1 /* Seek from current position. */ # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ #endif #ifndef z_off_t # define z_off_t long #endif #if defined(__OS400__) # define NO_vsnprintf #endif #if defined(__MVS__) # define NO_vsnprintf # ifdef FAR # undef FAR # endif #endif /* MVS linker does not support external names larger than 8 bytes */ #if defined(__MVS__) # pragma map(deflateInit_,"DEIN") # pragma map(deflateInit2_,"DEIN2") # pragma map(deflateEnd,"DEEND") # pragma map(deflateBound,"DEBND") # pragma map(inflateInit_,"ININ") # pragma map(inflateInit2_,"ININ2") # pragma map(inflateEnd,"INEND") # pragma map(inflateSync,"INSY") # pragma map(inflateSetDictionary,"INSEDI") # pragma map(compressBound,"CMBND") # pragma map(inflate_table,"INTABL") # pragma map(inflate_fast,"INFA") # pragma map(inflate_copyright,"INCOPY") #endif #endif /* ZCONF_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/OSMalloc.h
/* * Copyright (c) 2003-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@ */ #ifndef LIBKERN_OSMALLOC_h #define LIBKERN_OSMALLOC_h #include <sys/cdefs.h> __BEGIN_DECLS #include <stdint.h> /*! * @header * * @abstract * This header declares the OSMalloc memory-allocation KPI. * * @discussion * Kernel extensions can use these functions to allocate and deallocate * memory blocks that are tracked under named tags. * A kernel extension can create whatever tags it needs, * but typically just creates one with its bundle identifier. * * Tags are required; attempting to use these functions without one * will result in a panic. * * <b>Use Restrictions</b> * * None of the OSMalloc functions are safe to call * in a primary interrupt handler. */ /*! * @typedef OSMallocTag * * @abstract * An opaque type used to track memory allocations. */ typedef struct __OSMallocTag__ * OSMallocTag; /*! * @typedef OSMallocTag_t * * @abstract * See <code>@link OSMallocTag OSMallocTag@/link</code>. */ typedef struct __OSMallocTag__ * OSMallocTag_t; /*! * @define OSMT_DEFAULT * * @abstract * Indicates that an <code>@link OSMallocTag OSMallocTag@/link</code> * be created with default attributes. * * @discussion * An <code>@link OSMallocTag OSMallocTag@/link</code> created * with this attribute allocates all blocks in wired memory. */ #define OSMT_DEFAULT 0x00 /*! * @define OSMT_PAGEABLE * * @abstract * Indicates that an <code>@link OSMallocTag OSMallocTag@/link</code> * should allocate pageable memory when possible. * * @discussion * An <code>@link OSMallocTag OSMallocTag@/link</code> created * with this attribute allocates blocks of a full page size or larger * in pageable memory, * and blocks smaller than a full page size in wired memory. */ #define OSMT_PAGEABLE 0x01 /*! * @function OSMalloc_Tagalloc * * @abstract * Creates a tag for use with OSMalloc functions. * * @param name The name of the tag to create. * @param flags A bitmask that controls allocation behavior; see description. * * @result * An opaque tag to be used with OSMalloc functions for tracking memory usage. * * @discussion * OSMalloc tags can have arbitrary names of a length up to 63 characters. * Calling this function twice with the same name * creates two tags, which share that name. * * <code>flags</code> can be the bitwise OR of the following flags: * <ul> * <li><code>@link OSMT_DEFAULT OSMT_DEFAULT@/link</code> - * allocations are wired. This is the 'zero' bitmask value and * is overridden by any other flag specified.</li> * <li><code>@link OSMT_PAGEABLE OSMT_PAGEABLE@/link</code> - * allocations of a full page size or greater are pageable; * allocations smaller than a page are wired.</li> * </ul> */ extern OSMallocTag OSMalloc_Tagalloc( const char * name, uint32_t flags); /*! * @function OSMalloc_Tagfree * * @abstract * Frees a tag used with OSMalloc functions. * * @param tag The <code>@link OSMallocTag OSMallocTag@/link</code> to free. * * @discussion * OSMalloc tags must not be freed * while any memory blocks allocated * with them still exist. * Any OSMalloc function called on those blocks * will result in a panic. */ extern void OSMalloc_Tagfree(OSMallocTag tag); /*! * @function OSMalloc * * @abstract * Allocates a block of memory associated * with a given <code>@link OSMallocTag OSMallocTag@/link</code>. * * @param size The size of the memory block to allocate. * @param tag The <code>@link OSMallocTag OSMallocTag@/link</code> * under which to allocate the memory. * * @result * A pointer to the memory on success, <code>NULL</code> on failure. * * @discussion * If <code>tag</code> was created with the * <code>@link OSMT_PAGEABLE OSMT_PAGEABLE@/link</code> * attribute <i>and</i> <code>size</code> * is a full page or larger, the allocated memory is pageable; * otherwise it is wired. */ extern void * OSMalloc( uint32_t size, OSMallocTag tag) __attribute__((alloc_size(1))); /*! * @function OSMalloc_nowait * * @abstract * Equivalent to <code>@link OSMalloc_noblock OSMalloc_noblock@/link</code>. */ extern void * OSMalloc_nowait( uint32_t size, OSMallocTag tag) __attribute__((alloc_size(1))); /*! * @function OSMalloc_noblock * * @abstract * Allocates a block of memory associated * with a given <code>@link OSMallocTag OSMallocTag@/link</code>, * returning <code>NULL</code> if it would block. * * @param size The size of the memory block to allocate. * @param tag The <code>@link OSMallocTag OSMallocTag@/link</code> * under which to allocate the memory. * * @result * A pointer to the memory on success, <code>NULL</code> on failure * or if allocation would block. * * @discussion * If <code>tag</code> was created with the * <code>@link OSMT_PAGEABLE OSMT_PAGEABLE@/link</code> * attribute <i>and</i> <code>size</code> * is a full page or larger, the allocated memory is pageable; * otherwise it is wired. * * This function is guaranteed not to block. */ extern void * OSMalloc_noblock( uint32_t size, OSMallocTag tag) __attribute__((alloc_size(1))); /*! * @function OSFree * * @abstract * Frees a block of memory allocated by <code>@link OSMalloc OSMalloc@/link</code>. * * @param addr A pointer to the memory block to free. * @param size The size of the memory block to free. * @param tag The <code>@link OSMallocTag OSMallocTag@/link</code> * with which <code>addr</code> was originally allocated. */ extern void OSFree( void * addr, uint32_t size, OSMallocTag tag); __END_DECLS #endif /* LIBKERN_OSMALLOC_h */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/OSByteOrder.h
/* * 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@ */ #ifndef _OS_OSBYTEORDER_H #define _OS_OSBYTEORDER_H #include <stdint.h> #include <libkern/_OSByteOrder.h> /* Macros for swapping constant values in the preprocessing stage. */ #define OSSwapConstInt16(x) __DARWIN_OSSwapConstInt16(x) #define OSSwapConstInt32(x) __DARWIN_OSSwapConstInt32(x) #define OSSwapConstInt64(x) __DARWIN_OSSwapConstInt64(x) #if !defined(__DARWIN_OS_INLINE) # if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L # define __DARWIN_OS_INLINE static inline # elif defined(__MWERKS__) || defined(__cplusplus) # define __DARWIN_OS_INLINE static inline # else # define __DARWIN_OS_INLINE static __inline__ # endif #endif #if defined(__GNUC__) #if (defined(__i386__) || defined(__x86_64__)) #include <libkern/i386/OSByteOrder.h> #elif defined (__arm__) || defined(__arm64__) #include <libkern/arm/OSByteOrder.h> #else #include <libkern/machine/OSByteOrder.h> #endif #else /* ! __GNUC__ */ #include <libkern/machine/OSByteOrder.h> #endif /* __GNUC__ */ #define OSSwapInt16(x) __DARWIN_OSSwapInt16(x) #define OSSwapInt32(x) __DARWIN_OSSwapInt32(x) #define OSSwapInt64(x) __DARWIN_OSSwapInt64(x) enum { OSUnknownByteOrder, OSLittleEndian, OSBigEndian }; __DARWIN_OS_INLINE int32_t OSHostByteOrder(void) { #if defined(__LITTLE_ENDIAN__) return OSLittleEndian; #elif defined(__BIG_ENDIAN__) return OSBigEndian; #else return OSUnknownByteOrder; #endif } #define OSReadBigInt(x, y) OSReadBigInt32(x, y) #define OSWriteBigInt(x, y, z) OSWriteBigInt32(x, y, z) #define OSSwapBigToHostInt(x) OSSwapBigToHostInt32(x) #define OSSwapHostToBigInt(x) OSSwapHostToBigInt32(x) #define OSReadLittleInt(x, y) OSReadLittleInt32(x, y) #define OSWriteLittleInt(x, y, z) OSWriteLittleInt32(x, y, z) #define OSSwapHostToLittleInt(x) OSSwapHostToLittleInt32(x) #define OSSwapLittleToHostInt(x) OSSwapLittleToHostInt32(x) /* Functions for loading native endian values. */ __DARWIN_OS_INLINE uint16_t _OSReadInt16( const volatile void * base, uintptr_t byteOffset ) { return *(volatile uint16_t *)((uintptr_t)base + byteOffset); } __DARWIN_OS_INLINE uint32_t _OSReadInt32( const volatile void * base, uintptr_t byteOffset ) { return *(volatile uint32_t *)((uintptr_t)base + byteOffset); } __DARWIN_OS_INLINE uint64_t _OSReadInt64( const volatile void * base, uintptr_t byteOffset ) { return *(volatile uint64_t *)((uintptr_t)base + byteOffset); } /* Functions for storing native endian values. */ __DARWIN_OS_INLINE void _OSWriteInt16( volatile void * base, uintptr_t byteOffset, uint16_t data ) { *(volatile uint16_t *)((uintptr_t)base + byteOffset) = data; } __DARWIN_OS_INLINE void _OSWriteInt32( volatile void * base, uintptr_t byteOffset, uint32_t data ) { *(volatile uint32_t *)((uintptr_t)base + byteOffset) = data; } __DARWIN_OS_INLINE void _OSWriteInt64( volatile void * base, uintptr_t byteOffset, uint64_t data ) { *(volatile uint64_t *)((uintptr_t)base + byteOffset) = data; } #if defined(__BIG_ENDIAN__) /* Functions for loading big endian to host endianess. */ #define OSReadBigInt16(base, byteOffset) _OSReadInt16(base, byteOffset) #define OSReadBigInt32(base, byteOffset) _OSReadInt32(base, byteOffset) #define OSReadBigInt64(base, byteOffset) _OSReadInt64(base, byteOffset) /* Functions for storing host endianess to big endian. */ #define OSWriteBigInt16(base, byteOffset, data) _OSWriteInt16(base, byteOffset, data) #define OSWriteBigInt32(base, byteOffset, data) _OSWriteInt32(base, byteOffset, data) #define OSWriteBigInt64(base, byteOffset, data) _OSWriteInt64(base, byteOffset, data) /* Functions for loading little endian to host endianess. */ #define OSReadLittleInt16(base, byteOffset) OSReadSwapInt16(base, byteOffset) #define OSReadLittleInt32(base, byteOffset) OSReadSwapInt32(base, byteOffset) #define OSReadLittleInt64(base, byteOffset) OSReadSwapInt64(base, byteOffset) /* Functions for storing host endianess to little endian. */ #define OSWriteLittleInt16(base, byteOffset, data) OSWriteSwapInt16(base, byteOffset, data) #define OSWriteLittleInt32(base, byteOffset, data) OSWriteSwapInt32(base, byteOffset, data) #define OSWriteLittleInt64(base, byteOffset, data) OSWriteSwapInt64(base, byteOffset, data) /* Host endianess to big endian byte swapping macros for constants. */ #define OSSwapHostToBigConstInt16(x) ((uint16_t)(x)) #define OSSwapHostToBigConstInt32(x) ((uint32_t)(x)) #define OSSwapHostToBigConstInt64(x) ((uint64_t)(x)) /* Generic host endianess to big endian byte swapping functions. */ #define OSSwapHostToBigInt16(x) ((uint16_t)(x)) #define OSSwapHostToBigInt32(x) ((uint32_t)(x)) #define OSSwapHostToBigInt64(x) ((uint64_t)(x)) /* Host endianess to little endian byte swapping macros for constants. */ #define OSSwapHostToLittleConstInt16(x) OSSwapConstInt16(x) #define OSSwapHostToLittleConstInt32(x) OSSwapConstInt32(x) #define OSSwapHostToLittleConstInt64(x) OSSwapConstInt64(x) /* Generic host endianess to little endian byte swapping functions. */ #define OSSwapHostToLittleInt16(x) OSSwapInt16(x) #define OSSwapHostToLittleInt32(x) OSSwapInt32(x) #define OSSwapHostToLittleInt64(x) OSSwapInt64(x) /* Big endian to host endianess byte swapping macros for constants. */ #define OSSwapBigToHostConstInt16(x) ((uint16_t)(x)) #define OSSwapBigToHostConstInt32(x) ((uint32_t)(x)) #define OSSwapBigToHostConstInt64(x) ((uint64_t)(x)) /* Generic big endian to host endianess byte swapping functions. */ #define OSSwapBigToHostInt16(x) ((uint16_t)(x)) #define OSSwapBigToHostInt32(x) ((uint32_t)(x)) #define OSSwapBigToHostInt64(x) ((uint64_t)(x)) /* Little endian to host endianess byte swapping macros for constants. */ #define OSSwapLittleToHostConstInt16(x) OSSwapConstInt16(x) #define OSSwapLittleToHostConstInt32(x) OSSwapConstInt32(x) #define OSSwapLittleToHostConstInt64(x) OSSwapConstInt64(x) /* Generic little endian to host endianess byte swapping functions. */ #define OSSwapLittleToHostInt16(x) OSSwapInt16(x) #define OSSwapLittleToHostInt32(x) OSSwapInt32(x) #define OSSwapLittleToHostInt64(x) OSSwapInt64(x) #elif defined(__LITTLE_ENDIAN__) /* Functions for loading big endian to host endianess. */ #define OSReadBigInt16(base, byteOffset) OSReadSwapInt16(base, byteOffset) #define OSReadBigInt32(base, byteOffset) OSReadSwapInt32(base, byteOffset) #define OSReadBigInt64(base, byteOffset) OSReadSwapInt64(base, byteOffset) /* Functions for storing host endianess to big endian. */ #define OSWriteBigInt16(base, byteOffset, data) OSWriteSwapInt16(base, byteOffset, data) #define OSWriteBigInt32(base, byteOffset, data) OSWriteSwapInt32(base, byteOffset, data) #define OSWriteBigInt64(base, byteOffset, data) OSWriteSwapInt64(base, byteOffset, data) /* Functions for loading little endian to host endianess. */ #define OSReadLittleInt16(base, byteOffset) _OSReadInt16(base, byteOffset) #define OSReadLittleInt32(base, byteOffset) _OSReadInt32(base, byteOffset) #define OSReadLittleInt64(base, byteOffset) _OSReadInt64(base, byteOffset) /* Functions for storing host endianess to little endian. */ #define OSWriteLittleInt16(base, byteOffset, data) _OSWriteInt16(base, byteOffset, data) #define OSWriteLittleInt32(base, byteOffset, data) _OSWriteInt32(base, byteOffset, data) #define OSWriteLittleInt64(base, byteOffset, data) _OSWriteInt64(base, byteOffset, data) /* Host endianess to big endian byte swapping macros for constants. */ #define OSSwapHostToBigConstInt16(x) OSSwapConstInt16(x) #define OSSwapHostToBigConstInt32(x) OSSwapConstInt32(x) #define OSSwapHostToBigConstInt64(x) OSSwapConstInt64(x) /* Generic host endianess to big endian byte swapping functions. */ #define OSSwapHostToBigInt16(x) OSSwapInt16(x) #define OSSwapHostToBigInt32(x) OSSwapInt32(x) #define OSSwapHostToBigInt64(x) OSSwapInt64(x) /* Host endianess to little endian byte swapping macros for constants. */ #define OSSwapHostToLittleConstInt16(x) ((uint16_t)(x)) #define OSSwapHostToLittleConstInt32(x) ((uint32_t)(x)) #define OSSwapHostToLittleConstInt64(x) ((uint64_t)(x)) /* Generic host endianess to little endian byte swapping functions. */ #define OSSwapHostToLittleInt16(x) ((uint16_t)(x)) #define OSSwapHostToLittleInt32(x) ((uint32_t)(x)) #define OSSwapHostToLittleInt64(x) ((uint64_t)(x)) /* Big endian to host endianess byte swapping macros for constants. */ #define OSSwapBigToHostConstInt16(x) OSSwapConstInt16(x) #define OSSwapBigToHostConstInt32(x) OSSwapConstInt32(x) #define OSSwapBigToHostConstInt64(x) OSSwapConstInt64(x) /* Generic big endian to host endianess byte swapping functions. */ #define OSSwapBigToHostInt16(x) OSSwapInt16(x) #define OSSwapBigToHostInt32(x) OSSwapInt32(x) #define OSSwapBigToHostInt64(x) OSSwapInt64(x) /* Little endian to host endianess byte swapping macros for constants. */ #define OSSwapLittleToHostConstInt16(x) ((uint16_t)(x)) #define OSSwapLittleToHostConstInt32(x) ((uint32_t)(x)) #define OSSwapLittleToHostConstInt64(x) ((uint64_t)(x)) /* Generic little endian to host endianess byte swapping functions. */ #define OSSwapLittleToHostInt16(x) ((uint16_t)(x)) #define OSSwapLittleToHostInt32(x) ((uint32_t)(x)) #define OSSwapLittleToHostInt64(x) ((uint64_t)(x)) #else #error Unknown endianess. #endif #endif /* ! _OS_OSBYTEORDER_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/machine/OSByteOrder.h
/* * 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 _OS_OSBYTEORDERMACHINE_H #define _OS_OSBYTEORDERMACHINE_H #include <stdint.h> #if !defined(OS_INLINE) # if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L # define OS_INLINE static inline # elif defined(__MWERKS__) || defined(__cplusplus) # define OS_INLINE static inline # else # define OS_INLINE static __inline__ # endif #endif /* Generic byte swapping functions. */ OS_INLINE uint16_t _OSSwapInt16( uint16_t data ) { return OSSwapConstInt16(data); } OS_INLINE uint32_t _OSSwapInt32( uint32_t data ) { return OSSwapConstInt32(data); } OS_INLINE uint64_t _OSSwapInt64( uint64_t data ) { return OSSwapConstInt64(data); } /* Functions for byte reversed loads. */ OS_INLINE uint16_t OSReadSwapInt16( const volatile void * base, uintptr_t byteOffset ) { uint16_t data = *(volatile uint16_t *)((uintptr_t)base + byteOffset); return _OSSwapInt16(data); } OS_INLINE uint32_t OSReadSwapInt32( const volatile void * base, uintptr_t byteOffset ) { uint32_t data = *(volatile uint32_t *)((uintptr_t)base + byteOffset); return _OSSwapInt32(data); } OS_INLINE uint64_t OSReadSwapInt64( const volatile void * base, uintptr_t byteOffset ) { uint64_t data = *(volatile uint64_t *)((uintptr_t)base + byteOffset); return _OSSwapInt64(data); } /* Functions for byte reversed stores. */ OS_INLINE void OSWriteSwapInt16( volatile void * base, uintptr_t byteOffset, uint16_t data ) { *(volatile uint16_t *)((uintptr_t)base + byteOffset) = _OSSwapInt16(data); } OS_INLINE void OSWriteSwapInt32( volatile void * base, uintptr_t byteOffset, uint32_t data ) { *(volatile uint32_t *)((uintptr_t)base + byteOffset) = _OSSwapInt32(data); } OS_INLINE void OSWriteSwapInt64( volatile void * base, uintptr_t byteOffset, uint64_t data ) { *(volatile uint64_t *)((uintptr_t)base + byteOffset) = _OSSwapInt64(data); } #endif /* ! _OS_OSBYTEORDERMACHINE_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/i386/_OSByteOrder.h
/* * Copyright (c) 2006-2012 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 _OS__OSBYTEORDERI386_H #define _OS__OSBYTEORDERI386_H #if !defined(__DARWIN_OS_INLINE) # if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L # define __DARWIN_OS_INLINE static inline # elif defined(__MWERKS__) || defined(__cplusplus) # define __DARWIN_OS_INLINE static inline # else # define __DARWIN_OS_INLINE static __inline__ # endif #endif /* Generic byte swapping functions. */ __DARWIN_OS_INLINE __uint16_t _OSSwapInt16( __uint16_t _data ) { return (__uint16_t)((_data << 8) | (_data >> 8)); } __DARWIN_OS_INLINE __uint32_t _OSSwapInt32( __uint32_t _data ) { #if defined(__llvm__) return __builtin_bswap32(_data); #else __asm__ ("bswap %0" : "+r" (_data)); return _data; #endif } #if defined(__llvm__) __DARWIN_OS_INLINE __uint64_t _OSSwapInt64( __uint64_t _data ) { return __builtin_bswap64(_data); } #elif defined(__i386__) __DARWIN_OS_INLINE __uint64_t _OSSwapInt64( __uint64_t _data ) { __asm__ ("bswap %%eax\n\t" "bswap %%edx\n\t" "xchgl %%eax, %%edx" : "+A" (_data)); return _data; } #elif defined(__x86_64__) __DARWIN_OS_INLINE __uint64_t _OSSwapInt64( __uint64_t _data ) { __asm__ ("bswap %0" : "+r" (_data)); return _data; } #else #error Unknown architecture #endif #endif /* ! _OS__OSBYTEORDERI386_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/i386/OSByteOrder.h
/* * Copyright (c) 1999-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@ */ #ifndef _OS_OSBYTEORDERI386_H #define _OS_OSBYTEORDERI386_H #include <stdint.h> #include <libkern/i386/_OSByteOrder.h> #include <sys/_types/_os_inline.h> /* Functions for byte reversed loads. */ OS_INLINE uint16_t OSReadSwapInt16( const volatile void * base, uintptr_t byteOffset ) { uint16_t result; result = *(volatile uint16_t *)((uintptr_t)base + byteOffset); return _OSSwapInt16(result); } OS_INLINE uint32_t OSReadSwapInt32( const volatile void * base, uintptr_t byteOffset ) { uint32_t result; result = *(volatile uint32_t *)((uintptr_t)base + byteOffset); return _OSSwapInt32(result); } OS_INLINE uint64_t OSReadSwapInt64( const volatile void * base, uintptr_t byteOffset ) { uint64_t result; result = *(volatile uint64_t *)((uintptr_t)base + byteOffset); return _OSSwapInt64(result); } /* Functions for byte reversed stores. */ OS_INLINE void OSWriteSwapInt16( volatile void * base, uintptr_t byteOffset, uint16_t data ) { *(volatile uint16_t *)((uintptr_t)base + byteOffset) = _OSSwapInt16(data); } OS_INLINE void OSWriteSwapInt32( volatile void * base, uintptr_t byteOffset, uint32_t data ) { *(volatile uint32_t *)((uintptr_t)base + byteOffset) = _OSSwapInt32(data); } OS_INLINE void OSWriteSwapInt64( volatile void * base, uintptr_t byteOffset, uint64_t data ) { *(volatile uint64_t *)((uintptr_t)base + byteOffset) = _OSSwapInt64(data); } #endif /* ! _OS_OSBYTEORDERI386_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/bounded_ptr.h
// // Copyright (c) 2019 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 XNU_LIBKERN_LIBKERN_CXX_BOUNDED_PTR_H #define XNU_LIBKERN_LIBKERN_CXX_BOUNDED_PTR_H #if !TAPI #include <stddef.h> #include <stdint.h> #include <os/overflow.h> #include <os/base.h> #if !defined(__improbable) # define __improbable(...) __builtin_expect((__VA_ARGS__), 0) #endif namespace libkern { namespace detail { // Reimplementation of things in <type_traits> because we don't seem // to have the right to rely on the C++ Standard Library (based on // attempts to compile IOHIDFamily). // TODO: Do we really need to re-implement this here? template <typename ...> using void_t = void; template <typename T> T && declval() noexcept; using nullptr_t = decltype(nullptr); template <bool Cond, typename T = void> struct enable_if; template <typename T> struct enable_if<true, T> { using type = T; }; template <bool Cond, typename T = void> using enable_if_t = typename enable_if<Cond, T>::type; template <typename T1, typename T2> constexpr bool is_convertible_v = __is_convertible_to(T1, T2); template <typename T> inline constexpr bool is_void_v = false; template <> inline constexpr bool is_void_v<void> = true; template <> inline constexpr bool is_void_v<void const> = true; template <typename T, typename U> struct copy_const { using type = U; }; template <typename T, typename U> struct copy_const<T const, U> { using type = U const; }; template <typename T, typename U> using copy_const_t = typename copy_const<T, U>::type; template <typename T, typename U> struct copy_cv { using type = U; }; template <typename T, typename U> struct copy_cv<T const, U> { using type = U const; }; template <typename T, typename U> struct copy_cv<T volatile, U> { using type = U volatile; }; template <typename T, typename U> struct copy_cv<T const volatile, U> { using type = U const volatile; }; template <typename T, typename U> using copy_cv_t = typename copy_cv<T, U>::type; template <typename T, typename U> using WhenComparable = void_t< decltype(declval<T>() == declval<U>()), decltype(declval<T>() != declval<U>()) >; template <typename T, typename U> using WhenOrderable = void_t < decltype(declval<T>() < declval<U>()), decltype(declval<T>() > declval<U>()), decltype(declval<T>() >= declval<U>()), decltype(declval<T>() <= declval<U>()) >; // Pretend that sizeof(void) is 1, otherwise the in-bounds check doesn't // make sense for `bounded_ptr<void>`. template <typename T> constexpr size_t sizeof_v = sizeof(T); template <> inline constexpr size_t sizeof_v<void> = 1; template <> inline constexpr size_t sizeof_v<void const> = 1; template <> inline constexpr size_t sizeof_v<void volatile> = 1; template <> inline constexpr size_t sizeof_v<void const volatile> = 1; } // end namespace detail // Non-owning pointer to an object (or a range of objects) of type `T` // that validates that the address is within some specified bounds on // dereference-like operations. // // Conceptually, a `bounded_ptr` points within a range of memory `[begin, end)`. // If accessing any part of the result of dereferencing the pointer would // lead to an access outside of the `[begin, end)` range, the pointer is // said to be out-of-bounds. Due to representational constraints, the range // of in-bounds memory must be no larger than 4GB. // // Dereference-like operations (dereference, subscript, pointer member access) // validate that the pointer is not out-of-bounds. If an out-of-bounds pointer // is dereferenced, the `TrappingPolicy` is called as // `TrappingPolicy::trap(some-message)`, and the operation is said to "trap". // This terminology is used below to describe the behavior of the `TrappingPolicy`. // // Pointer arithmetic is allowed (and the bounds are not validated), so it is // entirely possible to make a `bounded_ptr` point outside of its range. // However, overflow checking is performed on arithmetic operations, and // any operation resulting in an overflow will also "trap". // // The behavior of the `TrappingPolicy` can be customized as desired, however // a trap should never return, causing the current `bounded_ptr` operation to // be aborted. This is important since the trap could signify an integer // overflow, a null-pointer dereference or something else that would lead to // undefined behavior (UB) if `TrappingPolicy::trap` were to return. // // Creation of `bounded_ptr`s // ========================== // `bounded_ptr` provides a single constructor allowing the bounds of the // pointer to be specified. When integrating `bounded_ptr` into an existing // code base, it is recommended to use `bounded_ptr` as an iterator obtained // from other container-like abstractions, instead of manually using the // constructor that allows specifying a range. Specifying the range manually // on construction is error-prone, and `bounded_ptr` can't help reduce // out-of-bounds accesses if the bounds are specified incorrectly. // // Furthermore, it is a design choice to not provide a constructor that uses // relative offsets from the pointer itself to determine the range, because // such a constructor is deemed more confusing than helpful. For example, is // the offset a number of bytes or a number of objects? Is the offset inclusive // or exclusive? Instead, factory functions should be used to create `bounded_ptr`s. // // Remark on const-ness // ==================== // Like for raw pointers, the const-ness of a `bounded_ptr` has no bearing on // whether the pointee is const. Hence, it is possible to obtain a non-const // reference to an object from a const `bounded_ptr`. To encode a // pointer-to-const, simply create a `bounded_ptr<T const>`. template <typename T, typename TrappingPolicy> struct __attribute__((trivial_abi)) bounded_ptr { private: using CharType = detail::copy_cv_t<T, char>; public: // Creates a null `bounded_ptr`. // // A null `bounded_ptr` does not point to any object and is conceptually // out of bounds, so dereferencing it will trap. "Observing" operations // like comparison and check-for-null, along with assignment, are valid // operations on a null `bounded_ptr`. OS_ALWAYS_INLINE constexpr bounded_ptr(detail::nullptr_t) : base_(nullptr), count_(0), offset_(0) { } OS_ALWAYS_INLINE constexpr explicit bounded_ptr() : bounded_ptr(nullptr) { } // Creates a `bounded_ptr` pointing to the given object, and whose bounds // are described by the provided `[begin, end)` range. // // This constructor does not check whether the constructed pointer is // within its bounds. However, it does check that the provided `[begin, end)` // range is a valid range (that is, `begin <= end`). // // Furthermore, the number of bytes in the range of in-bounds memory must be // representable by a uint32_t, which means that there can be no more than // 2^32 bytes (i.e. 4GB) in that range. Otherwise, the constructor will trap. OS_ALWAYS_INLINE explicit bounded_ptr(T* pointer, T const* begin, T const* end) { base_ = reinterpret_cast<CharType*>(const_cast<T*>(begin)); // Store (end - begin) into count_, making sure we don't overflow if (__improbable(os_sub_overflow(reinterpret_cast<uintptr_t>(end), reinterpret_cast<uintptr_t>(begin), &count_))) { TrappingPolicy::trap("The range of valid memory is too large to be represented " "by this type, or [begin, end) is not a well-formed range"); } // Store (pointer - begin) into offset_, making sure we don't overflow. // Note that offset_ can be negative if `pointer` is outside of the // range delimited by [begin, end), which can be valid if it represents // e.g. a subrange of an array. if (__improbable(os_sub_overflow(reinterpret_cast<uintptr_t>(pointer), reinterpret_cast<uintptr_t>(begin), &offset_))) { TrappingPolicy::trap("The offset of the pointer inside its valid memory " "range can't be represented using int32_t"); } } // Creates a `bounded_ptr` to a type `T` from a `bounded_ptr` to a type `U`. // // This converting constructor is enabled whenever `U*` is implicitly // convertible to `T*`. This allows the usual implicit conversions // between base-and-derived types, and also from any type `U*` to a // `void*`. If other casts (like between unrelated pointer types) are // desired, `libkern::reinterpret_pointer_cast` can be used instead. // // The bounds on the resulting `bounded_ptr` are inherited from the // original `bounded_ptr`. template <typename U, typename Policy, typename = detail::enable_if_t<detail::is_convertible_v<U*, T*> > > OS_ALWAYS_INLINE bounded_ptr(bounded_ptr<U, Policy> const & other) : base_(other.base_) , count_(other.count_) , offset_(static_cast<int32_t>(reinterpret_cast<CharType*>(static_cast<T*>(other.get_ptr_())) - other.base_)) { } // Assigns a `bounded_ptr` to a type `U` to a `bounded_ptr` to a type `T`, // as long as `U*` is convertible to `T*`. // // This is a rebinding operation, like assignment between raw pointers, // and the destination `bounded_ptr` will inherit the bounds of the // source `bounded_ptr`. template <typename U, typename Policy, typename = detail::enable_if_t<detail::is_convertible_v<U*, T*> > > OS_ALWAYS_INLINE bounded_ptr& operator=(bounded_ptr<U, Policy> const& other) { base_ = other.base_; count_ = other.count_; offset_ = static_cast<int32_t>(reinterpret_cast<CharType*>(static_cast<T*>(other.get_ptr_())) - other.base_); return *this; } // Sets a `bounded_ptr` to null. // // This is effectively equivalent to assigning a default-constructed // `bounded_ptr` to the target. As a result, the original bounds of // the `bounded_ptr` are discarded, and the resulting `bounded_ptr` // is both out-of-bounds and also has no bounds assigned to it (like // a default-constructed `bounded_ptr`). OS_ALWAYS_INLINE bounded_ptr& operator=(detail::nullptr_t) { *this = bounded_ptr(); return *this; } // Returns a reference to the object pointed-to by the `bounded_ptr`. // // Traps if the pointer is pointing outside of its bounds. // // Also note that this function will trap when dereferencing a null // `bounded_ptr`, unless the bounds of the pointer have been set and // include address 0, in which case there's effectively nothing to // diagnose. template <typename T_ = T> // delay instantiation to avoid forming invalid ref for bounded_ptr<void> OS_ALWAYS_INLINE T_& operator*() const { if (__improbable(!in_bounds_())) { TrappingPolicy::trap("bounded_ptr<T>::operator*: Dereferencing this pointer " "would access memory outside of the bounds set originally"); } return *get_ptr_(); } OS_ALWAYS_INLINE T* operator->() const { if (__improbable(!in_bounds_())) { TrappingPolicy::trap("bounded_ptr<T>::operator->: Accessing a member through this pointer " "would access memory outside of the bounds set originally"); } return get_ptr_(); } // Provides access to the n-th element past the given pointer. // // The `bounded_ptr` validates whether the provided index is within the // bounds of the `bounded_ptr`. Like for raw pointers, a negative index // may be passed, in which case the pointer is accessed at a negative // offset (which must still be in bounds). template <typename T_ = T> // delay instantiation to avoid forming invalid ref for bounded_ptr<void> OS_ALWAYS_INLINE T_& operator[](ptrdiff_t n) const { return *(*this + n); } // Converts a `bounded_ptr` to a raw pointer, after checking it is within // its bounds. // // The primary intended usage of this function is to aid bridging between // code that uses `bounded_ptr`s and code that does not. OS_ALWAYS_INLINE T* discard_bounds() const { if (__improbable(!in_bounds_())) { TrappingPolicy::trap("bounded_ptr<T>::discard_bounds: Discarding the bounds on " "this pointer would lose the fact that it is outside of the " "bounds set originally"); } return get_ptr_(); } // Converts a `bounded_ptr` to a raw pointer, without checking whether the // pointer is within its bounds. // // Like `discard_bounds()`, the primary intended usage of this function // is to aid bridging between code that uses `bounded_ptr`s and code that // does not. However, unlike `discard_bounds()`, this function does not // validate that the returned pointer is in bounds. This functionality is // necessary when the pointer represents something that can't be // dereferenced (hence it's OK for it to be out-of-bounds), but that // is still useful for other purposes like comparing against other // pointers. An example of that is the `end` pointer in a half-open // interval `[begin, end)`, where the `end` pointer is out-of-bounds and // can't be dereferenced, yet it's still useful to delimit the range. OS_ALWAYS_INLINE T* unsafe_discard_bounds() const { return get_ptr_(); } // Implicit conversion to bool, returning whether the pointer is null. // // This operation does not perform any validation of the bounds. OS_ALWAYS_INLINE explicit operator bool() const { return get_ptr_() != nullptr; } // Increment/decrement a `bounded_ptr`. // // Like for other arithmetic operations, this does not check whether the // increment or decrement operation results in an out-of-bounds pointer. OS_ALWAYS_INLINE bounded_ptr& operator++() { *this += 1; return *this; } OS_ALWAYS_INLINE bounded_ptr operator++(int) { bounded_ptr old = *this; ++*this; return old; } OS_ALWAYS_INLINE bounded_ptr& operator--() { *this -= 1; return *this; } OS_ALWAYS_INLINE bounded_ptr operator--(int) { bounded_ptr old = *this; --*this; return old; } // Increment or decrement a `bounded_ptr` by a given offset. // // This is equivalent to adding the given offset to the underlying raw // pointer. In particular, the bounds of the `bounded_ptr` are left // untouched by this operation. Furthermore, like for raw pointers, it // is possible to provide a negative offset, which will have the effect // of decrementing the `bounded_ptr` instead of incrementing it. // // Also note that the offset is NOT a number of bytes -- just like for // raw pointers, it is a number of "positions" to move the pointer from, // which essentially means `n * sizeof(T)` bytes. Again, this works exactly // the same as a raw pointer to an object of type `T`. // // Like other arithmetic operations, this does not check whether the // increment or decrement operation results in an out-of-bounds pointer. // However, this does check whether the arithmetic operation would result // in an overflow, in which case the operation will trap. template <typename T_ = T> OS_ALWAYS_INLINE bounded_ptr& operator+=(ptrdiff_t n) { static_assert(!detail::is_void_v<T_>, "Arithmetic on bounded_ptr<void> is not allowed."); ptrdiff_t bytes; if (__improbable(os_mul_overflow(n, sizeof(T), &bytes))) { TrappingPolicy::trap( "bounded_ptr<T>::operator+=(n): Calculating the number of bytes to " "add to the offset (n * sizeof(T)) would trigger an overflow"); } if (__improbable(os_add_overflow(offset_, bytes, &offset_))) { TrappingPolicy::trap( "bounded_ptr<T>::operator+=(n): Adding the specified number of bytes " "to the offset representing the current position would overflow."); } return *this; } template <typename T_ = T> OS_ALWAYS_INLINE bounded_ptr& operator-=(ptrdiff_t n) { static_assert(!detail::is_void_v<T_>, "Arithmetic on bounded_ptr<void> is not allowed."); ptrdiff_t bytes; if (__improbable(os_mul_overflow(n, sizeof(T), &bytes))) { TrappingPolicy::trap( "bounded_ptr<T>::operator-=(n): Calculating the number of bytes to " "subtract from the offset (n * sizeof(T)) would trigger an overflow"); } if (__improbable(os_sub_overflow(offset_, bytes, &offset_))) { TrappingPolicy::trap( "bounded_ptr<T>::operator-=(n): Subtracting the specified number of bytes " "from the offset representing the current position would overflow."); } return *this; } friend OS_ALWAYS_INLINE bounded_ptr operator+(bounded_ptr p, ptrdiff_t n) { p += n; return p; } friend OS_ALWAYS_INLINE bounded_ptr operator+(ptrdiff_t n, bounded_ptr p) { p += n; return p; } friend OS_ALWAYS_INLINE bounded_ptr operator-(bounded_ptr p, ptrdiff_t n) { p -= n; return p; } // Returns the difference between two `bounded_ptr`s. // // This is semantically equivalent to subtracting the two underlying // pointers. The bounds of the pointers are not validated by this // operation. friend OS_ALWAYS_INLINE ptrdiff_t operator-(bounded_ptr const& a, bounded_ptr const& b) { return a.get_ptr_() - b.get_ptr_(); } friend OS_ALWAYS_INLINE ptrdiff_t operator-(bounded_ptr const& a, T const* b) { return a.get_ptr_() - b; } friend OS_ALWAYS_INLINE ptrdiff_t operator-(T const* a, bounded_ptr const& b) { return a - b.get_ptr_(); } private: OS_ALWAYS_INLINE bool in_bounds_() const { static_assert(detail::sizeof_v<T> <= UINT32_MAX - INT32_MAX, "The type pointed-to by bounded_ptr is too large, which would defeat " "our optimization to check for inboundedness using arithmetic on unsigned"); return offset_ >= 0 && static_cast<uint32_t>(offset_) + static_cast<uint32_t>(detail::sizeof_v<T>) <= count_; } OS_ALWAYS_INLINE T* get_ptr_() const { // Compute `base_ + offset_`, catching overflows. uintptr_t ptr; if (__improbable(os_add_overflow(reinterpret_cast<uintptr_t>(base_), offset_, &ptr))) { TrappingPolicy::trap("This bounded_ptr is pointing to memory outside of what can " "be represented by a native pointer."); } return reinterpret_cast<T*>(ptr); } template <typename T_, typename U, typename Policy> friend bounded_ptr<T_, Policy> reinterpret_pointer_cast(bounded_ptr<U, Policy> const&) noexcept; template <typename U, typename P> friend struct bounded_ptr; // for cross-type operations and conversions CharType* base_; // pointer to the beginning of the valid address range uint32_t count_; // number of bytes considered in-bounds (non-negative) int32_t offset_; // current offset into the range, in bytes }; // Returns whether two `bounded_ptr`s point to the same object. // // This comparison is semantically equivalent to comparing the underlying // raw pointers. In particular, it doesn't validate the bounds of either // `bounded_ptr`, nor does it compare whether the two `bounded_ptr`s have // the same bounds. // // This comparison is enabled between `bounded_ptr`s whenever the two // corresponding raw pointer types are comparable. Comparison between a // raw pointer and a `bounded_ptr` is also allowed, so long as the // two corresponding raw pointer types are comparable. template <typename T, typename P1, typename U, typename P2, typename = detail::WhenComparable<T*, U*> > OS_ALWAYS_INLINE bool operator==(bounded_ptr<T, P1> const& a, bounded_ptr<U, P2> const& b) { return a.unsafe_discard_bounds() == b.unsafe_discard_bounds(); } template <typename T, typename P1, typename U, typename P2, typename = detail::WhenComparable<T*, U*> > OS_ALWAYS_INLINE bool operator!=(bounded_ptr<T, P1> const& a, bounded_ptr<U, P2> const& b) { return !(a == b); } template <typename T, typename P, typename U, typename = detail::WhenComparable<T*, U*> > OS_ALWAYS_INLINE bool operator==(bounded_ptr<T, P> const& a, U* b) { return a.unsafe_discard_bounds() == b; } template <typename T, typename P, typename U, typename = detail::WhenComparable<T*, U*> > OS_ALWAYS_INLINE bool operator==(U* a, bounded_ptr<T, P> const& b) { return a == b.unsafe_discard_bounds(); } template <typename T, typename P, typename U, typename = detail::WhenComparable<T*, U*> > OS_ALWAYS_INLINE bool operator!=(bounded_ptr<T, P> const& a, U* b) { return !(a == b); } template <typename T, typename P, typename U, typename = detail::WhenComparable<T*, U*> > OS_ALWAYS_INLINE bool operator!=(U* a, bounded_ptr<T, P> const& b) { return !(a == b); } template <typename T, typename Policy> OS_ALWAYS_INLINE bool operator==(detail::nullptr_t, bounded_ptr<T, Policy> const& p) { return p.unsafe_discard_bounds() == nullptr; } template <typename T, typename Policy> OS_ALWAYS_INLINE bool operator!=(detail::nullptr_t, bounded_ptr<T, Policy> const& p) { return p.unsafe_discard_bounds() != nullptr; } template <typename T, typename Policy> OS_ALWAYS_INLINE bool operator==(bounded_ptr<T, Policy> const& p, detail::nullptr_t) { return p.unsafe_discard_bounds() == nullptr; } template <typename T, typename Policy> OS_ALWAYS_INLINE bool operator!=(bounded_ptr<T, Policy> const& p, detail::nullptr_t) { return p.unsafe_discard_bounds() != nullptr; } // Returns whether a `bounded_ptr` points to an address that is {less-than, // less-than-or-equal-to, greater-than, greater-than-or-equal-to} the address // held in another `bounded_ptr`. // // This doesn't validate the bounds of either `bounded_ptr`, nor does it // compare those bounds to determine the ordering result. This ordering is // semantically equivalent to ordering the result of calling `get()` on both // `bounded_ptr`s. // // This ordering is enabled between `bounded_ptr`s whenever the two // corresponding raw pointer types are orderable. Ordering between a // raw pointer and a `bounded_ptr` is also allowed, so long as the // two corresponding raw pointer types are orderable. // template <typename T, typename U, typename P1, typename P2, typename = detail::WhenOrderable<T*, U*> > OS_ALWAYS_INLINE bool operator<(bounded_ptr<T, P1> const& a, bounded_ptr<U, P2> const& b) { return a.unsafe_discard_bounds() < b.unsafe_discard_bounds(); } template <typename T, typename U, typename P1, typename P2, typename = detail::WhenOrderable<T*, U*> > OS_ALWAYS_INLINE bool operator<=(bounded_ptr<T, P1> const& a, bounded_ptr<U, P2> const& b) { return a.unsafe_discard_bounds() <= b.unsafe_discard_bounds(); } template <typename T, typename U, typename P1, typename P2, typename = detail::WhenOrderable<T*, U*> > OS_ALWAYS_INLINE bool operator>(bounded_ptr<T, P1> const& a, bounded_ptr<U, P2> const& b) { return a.unsafe_discard_bounds() > b.unsafe_discard_bounds(); } template <typename T, typename U, typename P1, typename P2, typename = detail::WhenOrderable<T*, U*> > OS_ALWAYS_INLINE bool operator>=(bounded_ptr<T, P1> const& a, bounded_ptr<U, P2> const& b) { return a.unsafe_discard_bounds() >= b.unsafe_discard_bounds(); } template <typename T, typename U, typename P, typename = detail::WhenOrderable<T*, U*> > OS_ALWAYS_INLINE bool operator<(T* a, bounded_ptr<U, P> const& b) { return a < b.unsafe_discard_bounds(); } template <typename T, typename U, typename P, typename = detail::WhenOrderable<T*, U*> > OS_ALWAYS_INLINE bool operator<(bounded_ptr<T, P> const& a, U* b) { return a.unsafe_discard_bounds() < b; } template <typename T, typename U, typename P, typename = detail::WhenOrderable<T*, U*> > OS_ALWAYS_INLINE bool operator<=(T* a, bounded_ptr<U, P> const& b) { return a <= b.unsafe_discard_bounds(); } template <typename T, typename U, typename P, typename = detail::WhenOrderable<T*, U*> > OS_ALWAYS_INLINE bool operator<=(bounded_ptr<T, P> const& a, U* b) { return a.unsafe_discard_bounds() <= b; } template <typename T, typename U, typename P, typename = detail::WhenOrderable<T*, U*> > OS_ALWAYS_INLINE bool operator>(T* a, bounded_ptr<U, P> const& b) { return a > b.unsafe_discard_bounds(); } template <typename T, typename U, typename P, typename = detail::WhenOrderable<T*, U*> > OS_ALWAYS_INLINE bool operator>(bounded_ptr<T, P> const& a, U* b) { return a.unsafe_discard_bounds() > b; } template <typename T, typename U, typename P, typename = detail::WhenOrderable<T*, U*> > OS_ALWAYS_INLINE bool operator>=(T* a, bounded_ptr<U, P> const& b) { return a >= b.unsafe_discard_bounds(); } template <typename T, typename U, typename P, typename = detail::WhenOrderable<T*, U*> > OS_ALWAYS_INLINE bool operator>=(bounded_ptr<T, P> const& a, U* b) { return a.unsafe_discard_bounds() >= b; } template <typename T, typename U> OS_ALWAYS_INLINE T* reinterpret_pointer_cast(U* p) noexcept { return reinterpret_cast<T*>(p); } // Reinterprets a `bounded_ptr` to a type `T` to a `bounded_ptr` to a type `U`. // // This is equivalent to `reinterpret_cast`ing the underlying pointer as well // as the bounds of the original pointer. Like for a raw `reinterpret_cast`, // no offset adjustment is performed (even if needed, e.g. for derived-to-base // casts with multiple inheritance). Because this is extremely unsafe, it should // be used extremely sparingly. template <typename T, typename U, typename Policy> OS_ALWAYS_INLINE bounded_ptr<T, Policy> reinterpret_pointer_cast(bounded_ptr<U, Policy> const& p) noexcept { using CharType = detail::copy_cv_t<T, char>; CharType* new_begin = reinterpret_cast<CharType*>(p.base_); CharType* new_end = new_begin + p.count_; return bounded_ptr<T, Policy>(reinterpret_cast<T*>(p.get_ptr_()), reinterpret_cast<T const*>(new_begin), reinterpret_cast<T const*>(new_end)); } } // end namespace libkern #endif /* !TAPI */ #endif // !XNU_LIBKERN_LIBKERN_CXX_BOUNDED_PTR_H
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSIterator.h
/* * Copyright (c) 2019 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@ */ /* * Copyright (c) 1998-1999 Apple Computer, Inc. All rights reserved. * * HISTORY * */ #ifndef _OS_OSITERATOR_H #define _OS_OSITERATOR_H #include <libkern/c++/OSObject.h> /*! * @header * * @abstract * This header declares the OSIterator collection class. */ /*! * @class OSIterator * @abstract * The abstract superclass for Libkern iterators. * * @discussion * OSIterator is the abstract superclass for all Libkern C++ object iterators. * It defines the basic interface for iterating and resetting. * See @link //apple_ref/cpp/macro/OSCollection OSCollection@/link and * @link //apple_ref/cpp/macro/OSCollectionIterator OSCollectionIterator@/link * for more information. * * With very few exceptions in the I/O Kit, all Libkern-based C++ * classes, functions, and macros are <b>unsafe</b> * to use in a primary interrupt context. * Consult the I/O Kit documentation related to primary interrupts * for more information. * * OSIterator provides no concurrency protection. */ class OSIterator : public OSObject { OSDeclareAbstractStructors(OSIterator); public: /*! * @function reset * * @abstract * Resets the iterator to the beginning of the collection, * as if it had just been created. * * @discussion * Subclasses must implement this pure virtual member function. */ virtual void reset() = 0; /*! * @function isValid * * @abstract * Check that the collection hasn't been modified during iteration. * * @result * <code>true</code> if the iterator is valid for continued use, * <code>false</code> otherwise * (typically because the collection being iterated has been modified). * * @discussion * Subclasses must implement this pure virtual member function. */ virtual bool isValid() = 0; /*! * @function getNextObject * * @abstract * Advances to and returns the next object in the iteration. * * @return * The next object in the iteration context, * <code>NULL</code> if there is no next object * or if the iterator is no longer valid. * * @discussion * The returned object will be released if removed from the collection; * if you plan to store the reference, you should call * <code>@link * //apple_ref/cpp/instm/OSObject/retain/virtualvoid/() * retain@/link</code> * on that object. * * Subclasses must implement this pure virtual function * to check for validity with * <code>@link isValid isValid@/link</code>, * and then to advance the iteration context to the next object (if any) * and return that next object, or <code>NULL</code> if there is none. */ virtual OSObject *getNextObject() = 0; OSMetaClassDeclareReservedUnused(OSIterator, 0); OSMetaClassDeclareReservedUnused(OSIterator, 1); OSMetaClassDeclareReservedUnused(OSIterator, 2); OSMetaClassDeclareReservedUnused(OSIterator, 3); }; #endif /* ! _OS_OSITERATOR_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSSerialize.h
/* * Copyright (c) 2000-2019 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@ */ /* OSSerialize.h created by rsulack on Wen 25-Nov-1998 */ #ifndef _OS_OSSERIALIZE_H #define _OS_OSSERIALIZE_H #include <libkern/c++/OSObject.h> #include <libkern/c++/OSPtr.h> class OSCollection; class OSSet; class OSDictionary; class OSArray; class OSData; class OSSerializer; typedef OSSerializer* OSSerializerPtr; class OSSerialize; typedef OSSerialize* OSSerializePtr; /*! * @header * * @abstract * This header declares the OSSerialize class. */ OSObjectPtr OSUnserializeBinary(const void *buffer, size_t bufferSize); /*! * @class OSSerialize * * @abstract * OSSerialize coordinates serialization of Libkern C++ objects * into an XML stream. * * @discussion * This class is for the most part internal to the OSContainer classes, * used for transferring property tables between the kernel and user space. * It should not be used directly. * Classes that participate in serialization * override the * <code>@link * //apple_ref/cpp/instm/OSObject/serialize/virtualbool/(OSSerialize*) * OSObject::serialize@/link</code> . * function. * * <b>Use Restrictions</b> * * With very few exceptions in the I/O Kit, all Libkern-based C++ * classes, functions, and macros are <b>unsafe</b> * to use in a primary interrupt context. * Consult the I/O Kit documentation related to primary interrupts * for more information. * * OSSerialize provides no concurrency protection; * it's up to the usage context to provide any protection necessary. * Some portions of the I/O Kit, such as * @link //apple_ref/doc/class/IORegistryEntry IORegistryEntry@/link, * handle synchronization via defined member functions * for serializing properties. */ class OSSerialize : public OSObject { OSDeclareDefaultStructors(OSSerialize); friend class OSBoolean; private: char * data; // container for serialized data unsigned int length; // of serialized data (counting NULL) unsigned int capacity; // of container unsigned int capacityIncrement;// of container OSPtr<OSArray> tags; // tags for all objects seen typedef void * Editor; bool binary; bool endCollection; Editor editor; void * editRef; OSPtr<OSData> indexData; bool binarySerialize(const OSMetaClassBase *o); bool binarySerializeInternal(const OSMetaClassBase *o); bool addBinary(const void * data, size_t size); bool addBinaryObject(const OSMetaClassBase * o, uint32_t key, const void * _bits, uint32_t size, uint32_t * startCollection); void endBinaryCollection(uint32_t startCollection); public: /*! * @function withCapacity * * @abstract * Creates and initializes an empty OSSerialize object. * * @param capacity The initial size of the XML buffer. * * @result * A new instance of OSSerialize * with a retain count of 1; * <code>NULL</code> on failure. * * @discussion * The serializer will grow as needed to accommodate more data. */ static OSPtr<OSSerialize> withCapacity(unsigned int capacity); static OSPtr<OSSerialize> binaryWithCapacity(unsigned int inCapacity, Editor editor = NULL, void * reference = NULL); void setIndexed(bool index); /*! * @function text * * @abstract * Returns the XML text serialized so far. * * @result * The nul-terminated XML data serialized so far. */ virtual char * text() const; /*! * @function clearText * * @abstract * Resets the OSSerialize object. * * @discussion * This function is a useful optimization if you are serializing * the same object repeatedly. */ virtual void clearText(); // stuff to serialize your object /*! * @function previouslySerialized * * @abstract * Checks whether the object has already been serialized * into the XML stream, emitting a reference if it has. * * @param object The object to check. * * @result * <code>true</code> if <code>object</code> has already been serialized * by this OSSerialize object and a reference * to it is successfully added to the XML stream, * <code>false</code> otherwise. * * * @discussion * This function both reduces the size of generated XML * by emitting shorter references to existing objects with the same * value (particularly for OSString, OSSymbol, and OSData), * and also preserves instance references * so that the user-space I/O Kit library can reconstruct * an identical graph of object relationships. * * All classes that override * <code>@link * //apple_ref/cpp/instm/OSObject/serialize/virtualbool/(OSSerialize*) * OSObject::serialize@/link</code>. * should call this function before doing any actual serialization; * if it returns <code>true</code>, the <code>serialize</code> implementation * can immediately return <code>true</code>. */ virtual bool previouslySerialized(const OSMetaClassBase * object); /*! * @function addXMLStartTag * * @abstract * Appends an XML start tag to the XML stream. * * @param object The object being serialized. * @param tagString The name of the XML tag to emit; for example, "string". * * @result * <code>true</code> if an XML start tag for <code>tagString</code> * is successfully added to the XML stream, <code>false</code> otherwise. * * @discussion * This function emits the named tag, * enclosed within a pair of angle brackets. * * A class that implements serialization should call this function * with the name of the XML tag that best represents the serialized * contents of the object. * A limited number of tags are supported by the user-space * I/O Kit library: * <ul> * <li>array</li> * <li>dict</li> * <li>integer</li> * <li>key</li> * <li>set</li> * <li>string</li> * </ul> * * A call to this function must be balanced with one to * <code>@link addXMLEndTag addXMLEndTag@/link</code> * using the same <code>tagString</code>. */ virtual bool addXMLStartTag( const OSMetaClassBase * object, const char * tagString); /*! * @function addXMLEndTag * * @abstract * Appends an XML end tag to the XML stream. * * @param tagString The name of the XML tag to emit; for example, "string". * * @result * <code>true</code> if an XML end tag for <code>tagString</code> * is successfully added to the XML stream, <code>false</code> otherwise. * * @discussion * This function emits the named tag, * preceded by a slash character to indicate the closing of an entity, * all enclosed within a pair of angle brackets. * * A call to this function must balance an earlier call to * <code>@link addXMLStartTag addXMLStartTag@/link</code> * using the same <code>tagString</code>. */ virtual bool addXMLEndTag(const char * tagString); /*! * @function addChar * * @abstract * Appends a single character to the XML stream. * * @param aChar The character to append to the XML stream. * * @result * <code>true</code> if <code>char</code> * is successfully added to the XML stream, <code>false</code> otherwise. */ virtual bool addChar(const char aChar); /*! * @function addString * * @abstract * Appends a C string to the XML stream. * * @param cString The C string to append to the XML stream. * * @result * <code>true</code> if <code>cString</code> * is successfully added to the XML stream, <code>false</code> otherwise. */ virtual bool addString(const char * cString); // stuff you should never have to use (in theory) virtual bool initWithCapacity(unsigned int inCapacity); virtual unsigned int getLength() const; virtual unsigned int getCapacity() const; virtual unsigned int getCapacityIncrement() const; virtual unsigned int setCapacityIncrement(unsigned increment); virtual unsigned int ensureCapacity(unsigned int newCapacity); virtual void free() APPLE_KEXT_OVERRIDE; OSMetaClassDeclareReservedUnused(OSSerialize, 0); OSMetaClassDeclareReservedUnused(OSSerialize, 1); OSMetaClassDeclareReservedUnused(OSSerialize, 2); OSMetaClassDeclareReservedUnused(OSSerialize, 3); OSMetaClassDeclareReservedUnused(OSSerialize, 4); OSMetaClassDeclareReservedUnused(OSSerialize, 5); OSMetaClassDeclareReservedUnused(OSSerialize, 6); OSMetaClassDeclareReservedUnused(OSSerialize, 7); }; typedef bool (*OSSerializerCallback)(void * target, void * ref, OSSerialize * serializer); #ifdef __BLOCKS__ typedef bool (^OSSerializerBlock)(OSSerialize * serializer); #endif /* __BLOCKS__ */ class OSSerializer : public OSObject { OSDeclareDefaultStructors(OSSerializer); void * target; void * ref; OSSerializerCallback callback; public: static OSPtr<OSSerializer> forTarget( void * target, OSSerializerCallback callback, void * ref = NULL); #ifdef __BLOCKS__ static OSPtr<OSSerializer> withBlock( OSSerializerBlock callback); #endif virtual void free( void ) APPLE_KEXT_OVERRIDE; virtual bool serialize(OSSerialize * serializer) const APPLE_KEXT_OVERRIDE; }; #endif /* _OS_OSSERIALIZE_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSMetaClass.h
/* * Copyright (c) 2000-2019 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 _LIBKERN_OSMETACLASS_H #define _LIBKERN_OSMETACLASS_H #include <sys/types.h> #include <libkern/OSReturn.h> #include <kern/debug.h> #include <ptrauth.h> /* * LIBKERN_ macros below can be used to describe the ownership semantics * of functions handling subclasses of OSObject. * The attributes propagate with inheritance, but can be overriden. * New versions of the Clang Static Analyzer can use this knowledge to * check the code for leaks or uses-after-free. */ /* * By default, methods returning OSObjects are assumed to have the following * owneship semantics: * - Methods which start with "get" are "Get" and which are not returning * a subclass of OSIterator are assumed to be getters. * They return at "+0" and the caller is not responsible for releasing the * returned object. * * - All other methods are assumed to return at "+1", and the caller is * responsible for releasing the returned object. * * The semantics implied by the naming convention described above can be * overriden using either LIBKERN_RETURNS_RETAINED or LIBKERN_RETURNS_NOT_RETAINED * attribute applied to a function. * In the former case, it stipulates that the function is returning at "+1", * and in the latter case "+0". * * LIBKERN_RETURNS_RETAINED and LIBKERN_RETURNS_NOT_RETAINED attributes * can be also applied to out parameters, in which case they specify * that an out parameter is written into at +1 or +0 respectively. * For out parameters of non-void functions an assumption is * that an out parameter is written into iff the return value is non-zero * unless the function returns a typedef to kern_return_t, * in which case it is assumed to be written into on zero value * (kIOReturnSuccess). * This can be customized using the attributes * LIBKERN_RETURNS_RETAINED_ON_ZERO and LIBKERN_RETURNS_RETAINED_ON_NONZERO. */ #if __has_attribute(os_returns_retained) #define LIBKERN_RETURNS_RETAINED __attribute__((os_returns_retained)) #else #define LIBKERN_RETURNS_RETAINED #endif #if __has_attribute(os_returns_not_retained) #define LIBKERN_RETURNS_NOT_RETAINED __attribute__((os_returns_not_retained)) #else #define LIBKERN_RETURNS_NOT_RETAINED #endif /* * LIBKERN_CONSUMED attribute can be applied to parameters. * It specifies that this function call would consume the reference to the * annotated parameter. */ #if __has_attribute(os_consumed) #define LIBKERN_CONSUMED __attribute__((os_consumed)) #else #define LIBKERN_CONSUMED #endif /* * LIBKERN_CONSUMES_THIS attribute can be applied to methods. * It specifies that this method call consumes a reference to "this" (e.g. * by storing a reference to "this" in a passed parameter). */ #if __has_attribute(os_consumes_this) #define LIBKERN_CONSUMES_THIS __attribute__((os_consumes_this)) #else #define LIBKERN_CONSUMES_THIS #endif /* * LIBKERN_RETURNS_RETAINED_ON_ZERO is an attribute applicable to out * parameters. * It specifies that an out parameter at +1 is written into an argument iff * the function returns a zero return value. */ #if __has_attribute(os_returns_retained_on_zero) #define LIBKERN_RETURNS_RETAINED_ON_ZERO __attribute__((os_returns_retained_on_zero)) #else #define LIBKERN_RETURNS_RETAINED_ON_ZERO #endif /* * LIBKERN_RETURNS_RETAINED_ON_NON_ZERO is an attribute applicable to out * parameters. * It specifies that an out parameter at +1 is written into an argument iff * the function returns a non-zero return value. */ #if __has_attribute(os_returns_retained_on_non_zero) #define LIBKERN_RETURNS_RETAINED_ON_NONZERO __attribute__((os_returns_retained_on_non_zero)) #else #define LIBKERN_RETURNS_RETAINED_ON_NONZERO #endif class OSMetaClass; class OSObject; class OSString; class OSSymbol; class OSDictionary; class OSSerialize; struct IORPC; class OSInterface { }; /*! * @header * * @abstract * This header declares the OSMetaClassBase and OSMetaClass classes, * which together form the basis of the Libkern and I/O Kit C++ class hierarchy * and run-time type information facility. */ /*! @parseOnly */ #define APPLE_KEXT_COMPATIBILITY /* No xnu-private defines outside of xnu */ #include <TargetConditionals.h> #if TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR #define APPLE_KEXT_VTABLE_PADDING 0 #else /* TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR */ #define APPLE_KEXT_VTABLE_PADDING 1 #endif /* TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR */ #if TARGET_OS_OSX && defined(__arm64__) #define APPLE_KEXT_ALIGN_CONTAINERS 1 #else /* TARGET_OS_OSX && defined(__arm64__) */ #define APPLE_KEXT_ALIGN_CONTAINERS (0 == APPLE_KEXT_VTABLE_PADDING) #endif /* TARGET_OS_OSX && defined(__arm64__) */ #if defined(__LP64__) /*! @parseOnly */ #define APPLE_KEXT_LEGACY_ABI 0 #elif defined(__arm__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) #define APPLE_KEXT_LEGACY_ABI 0 #else #define APPLE_KEXT_LEGACY_ABI 1 #endif #if defined(__LP64__) /*! @parseOnly */ #define APPLE_KEXT_COMPATIBILITY_VIRTUAL #else // private method made virtual only for binary compatibility #define APPLE_KEXT_COMPATIBILITY_VIRTUAL virtual #endif /*! @parseOnly */ #define APPLE_KEXT_DEPRECATED __attribute__((deprecated)) /* * <rdar://problem/44872498> AppleUSBAudio builds xnu's libkern headers in user space */ #if !defined(BUILD_FOR_USERSPACE) && (__cplusplus >= 201103L) #define APPLE_KEXT_OVERRIDE override #if defined(__LP64__) #define APPLE_KEXT_COMPATIBILITY_OVERRIDE #else #define APPLE_KEXT_COMPATIBILITY_OVERRIDE APPLE_KEXT_OVERRIDE #endif #else #define APPLE_KEXT_OVERRIDE #define APPLE_KEXT_COMPATIBILITY_OVERRIDE #endif #define APPLE_KEXT_WSHADOW_PUSH _Pragma("clang diagnostic push") \ _Pragma("clang diagnostic ignored \"-Wunknown-warning-option\"") \ _Pragma("clang diagnostic ignored \"-Wshadow-field\"") #define APPLE_KEXT_WSHADOW_POP _Pragma("clang diagnostic pop") /*! * @class OSMetaClassBase * * @abstract * OSMetaClassBase is the abstract bootstrap class * for the Libkern and I/O Kit run-time type information system. * * @discussion * OSMetaClassBase is the abstract C++ root class * underlying the entire Libkern and I/O Kit class hierarchy. * It defines the run-time type information system, * including dynamic class allocation and safe type-casting, * as well as the abstract interface for reference counting * and a few other utility functions. * OSMetaClassBase is the immediate superclass of * @link //apple_ref/doc/class/OSObject OSObject@/link and * @link //apple_ref/doc/class/OSMetaClass OSMetaClass@/link; * no other class should derive from OSMetaClassBase. * * For more information, see * <i>@link //apple_ref/doc/uid/TP40002799 * I/O Kit Device Driver Design Guidelines@/link</i>. * * <b>Use by Kernel Extensions</b> * * Kernel Extensions should never interact directly with OSMetaClassBase, * but they will find useful several macros that tie in * to the run-time type information system, specifically: * <ul> * <li><code>@link OSTypeAlloc OSTypeAlloc@/link</code> - allocation of new instances</li> * <li><code>@link OSDynamicCast OSDynamicCast@/link</code> - safe type casting</li> * <li><code>@link OSCheckTypeInst OSCheckTypeInst@/link</code> - * checking for inheritance/derivation</li> * <li><code>@link OSMemberFunctionCast OSMemberFunctionCast@/link</code> - * casting C++ member functions to C function pointers * for registration as callbacks</li> * </ul> * * See @link //apple_ref/doc/class/OSMetaClass OSMetaClass@/link * for more run-time type information interfaces. * * <b>Use Restrictions</b> * * OSMetaClassBase should not be subclassed by kernel extensions, * nor should kernel extensions call its run-time type functions directly. * * The run-time type functions and macros are <b>not safe</b> * to call in a primary interrupt context. * * <b>Concurrency Protection</b> * * The run-time type macros and functions of OSMetaClassBase are thread-safe. */ class OSMetaClassBase { public: /*! * @define OSTypeAlloc * @hidecontents * * @abstract * Allocates an instance of the named object class. * * @param type The name of the desired class to be created, * as a raw token, <i>not</i> a string or macro. * * @result * A pointer to the new, uninitialized object on success; * <code>NULL</code> on failure. * * @discussion * See also * <code>@link * //apple_ref/cpp/clm/OSMetaClass/allocClassWithName/staticOSObject*\/(constchar*) * OSMetaClass::allocClassWithName(const char *)@/link</code> * and * <code>@link * //apple_ref/cpp/instm/OSMetaClass/alloc/virtualOSObject*\/() * OSMetaClass::alloc@/link</code>. * * The OSTypeAlloc macro is used to avoid binary compatibility difficulties * presented by the C++ <code>new</code> operator. */ #define OSTypeAlloc(type) ((type *) ((type::metaClass)->alloc())) /*! * @define OSTypeID * @hidecontents * * @abstract * Returns the type ID (metaclass) of a class based on its name. * * @param type The name of the desired class, as a raw token, * <i>not</i> a string or macro. * * @result * The unique type ID (metaclass) for the class. * * @discussion * It is typically more useful to determine whether a class is derived * from another; see * <code>@link //apple_ref/cpp/macro/OSDynamicCast OSDynamicCast@/link</code> * and * <code>@link //apple_ref/cpp/macro/OSCheckTypeInst OSCheckTypeInst@/link</code>. */ #define OSTypeID(type) (type::metaClass) #define OSMTypeID(type) (const_cast<OSMetaClass *>(type::metaClass)) /*! * @define OSTypeIDInst * @hidecontents * * @abstract * Returns the type ID (metaclass) for the class of an object instance. * * @param typeinst An instance of an OSObject subclass. * * @result * The type ID of that object's class; that is, its metaclass. * * @discussion * It is typically more useful to determine whether an object is derived * from a particular class; see * <code>@link //apple_ref/cpp/macro/OSDynamicCast OSDynamicCast@/link</code> * and * <code>@link //apple_ref/cpp/macro/OSCheckTypeInst OSCheckTypeInst@/link</code>. */ #define OSTypeIDInst(typeinst) ((typeinst)->getMetaClass()) /*! * @define OSDynamicCast * @hidecontents * * @abstract * Safe type-casting for Libkern C++ objects. * * @param type The name of the desired class type, as a raw token, * <i>not</i> a string or macro. * It is assumed you intend to cast to a pointer * to an object of this type. * Type qualifiers, such as <code>const</code>, * are not recognized and will cause * a (usually obscure) compile error. * @param inst A pointer to the object instance to be cast. * May be <code>NULL</code>. * * @result * <code>inst</code> if it is non-<code>NULL</code> * and derived from <code>type</code>; * otherwise <code>NULL</code>. * * @discussion * <code>OSDynamicCast</code> is a rough equivalent * to the standard C++ RTTI <code>dynamic_cast&lt;T&gt;</code> operator. * Your code should use this instead of raw C type-casting, * and check the resulting value. * If the result is non-<code>NULL</code>, * the object is safe to use as the type-cast class; * if the result is <code>NULL</code>, * the object does not derive from the type-cast class * and your code should take appropriate steps to handle the error. */ #define OSDynamicCast(type, inst) \ ((type *) OSMetaClassBase::safeMetaCast((inst), OSTypeID(type))) /*! * @define OSRequiredCast * @hidecontents * * @abstract * Safe type-casting for Libkern C++ objects; panics on failure. * The input parameters are the same as for the {@code OSDynamicCast} macro. * * @result {@code inst} if it is NULL or derived from {@code type}; * otherwise triggers a kernel panic. * * @discussion * This macro should be used in place of C-style casts or * <code>@link OSDynamicCast OSDynamicCast@/link</code>. * when the caller is absolutely sure that the passed * argument is a subclass of a required type. * It is equivalent to using {@code OSDynamicCast} and crashing with a kernel * panic on cast failure. */ #define OSRequiredCast(type, inst) \ ((type *) OSMetaClassBase::requiredMetaCast((inst), OSTypeID(type))) /*! * @define OSCheckTypeInst * @hidecontents * * @abstract * Checks whether two objects are type-compatible. * * @param typeinst The reference object. * @param inst The object to check for type compatibility. * * @result * <code>true</code> if both <code>inst</code> and * <code>typeinst</code> are non-<code>NULL</code> * and <code>inst</code> is derived from the class of <code>typeinst</code>; * otherwise <code>false</code>. */ #define OSCheckTypeInst(typeinst, inst) \ OSMetaClassBase::checkTypeInst(inst, typeinst) #define OSSafeRelease(inst) \ do { int OSSafeRelease __attribute__ ((deprecated("Use OSSafeReleaseNULL"))); (OSSafeRelease); \ if (inst) (inst)->release(); } while (0) /*! @function OSSafeReleaseNULL * @abstract Release an object if not <code>NULL</code>, then set it to <code>NULL</code>. * @param inst Instance of an OSObject, may be <code>NULL</code>. */ #define OSSafeReleaseNULL(inst) do { if (inst != NULL) (inst)->release(); (inst) = NULL; } while (0) typedef void (*_ptf_t)(void); #if defined(__arm__) || defined(__arm64__) static _ptf_t _ptmf2ptf(const OSMetaClassBase * self, void (OSMetaClassBase::*func)(void)); #elif defined(__i386__) || defined(__x86_64__) // Slightly less arcane and slightly less evil code to do // the same for kexts compiled with the standard Itanium C++ // ABI static inline _ptf_t _ptmf2ptf(const OSMetaClassBase *self, void (OSMetaClassBase::*func)(void)) { union { void (OSMetaClassBase::*fIn)(void); uintptr_t fVTOffset; _ptf_t fPFN; } map; map.fIn = func; if (map.fVTOffset & 1) { // virtual union { const OSMetaClassBase *fObj; _ptf_t **vtablep; } u; u.fObj = self; // Virtual member function so dereference vtable return *(_ptf_t *)(((uintptr_t)*u.vtablep) + map.fVTOffset - 1); } else { // Not virtual, i.e. plain member func return map.fPFN; } } #else #error Unknown architecture. #endif /* __arm__ */ /*! * @define OSMemberFunctionCast * @hidecontents * * @abstract * Converts a C++ member function pointer, relative to an instance, * to a C-style pointer to function. * * @param cptrtype The function type declaration to cast to * (typically provided as a <code>typedef</code> by I/O KitKit classes). * @param self The <code>this</code> pointer of the object whose function * you wish to cache. * @param func The pointer to the member function itself, * something like <code>&Class::function</code>. * It should be an explicit member function pointer constant, * rather than a variable. * Don't pass a <code>NULL</code> member function pointer. * Instead, directly use a <code>NULL</code> function pointer. * * @result * A pointer to a function of the given type referencing <code>self</code>. * * @discussion * This function is used to generate pointers to C++ functions for instances, * such that they can be registered as callbacks with I/O Kit objects. * * No warnings are generated. * * This function will panic if an attempt is made to call it * with a multiply-inheriting class. */ #if __has_builtin(__builtin_load_member_function_pointer) #define OSMemberFunctionCast(cptrtype, self, func) \ ((cptrtype) __builtin_load_member_function_pointer(*self, func) ? : \ (cptrtype) OSMetaClassBase:: \ _ptmf2ptf(self, (void (OSMetaClassBase::*)(void)) func)) #else #define OSMemberFunctionCast(cptrtype, self, func) \ (cptrtype) OSMetaClassBase:: \ _ptmf2ptf(self, (void (OSMetaClassBase::*)(void)) func) #endif protected: OSMetaClassBase(); virtual ~OSMetaClassBase(); private: // Disable copy constructors of OSMetaClassBase based objects /* Not to be included in headerdoc. * * @function operator = * * @abstract * Disable implicit copy constructor by making private * * @param src Reference to source object that isn't allowed to be copied. */ void operator =(OSMetaClassBase &src); /* Not to be included in headerdoc. * * @function OSMetaClassBase * * @abstract * Disable implicit copy constructor by making private * * @param src Reference to source object that isn't allowed to be copied. */ OSMetaClassBase(OSMetaClassBase &src); public: // xx-review: the original comment for this makes it sound to me like we don't // xx-review: catch over-releasing an object...? /*! * @function release * * @abstract * Abstract declaration of * <code>@link * //apple_ref/cpp/instm/OSObject/release/virtualvoid/(int) * release(int freeWhen)@/link</code>. * * @discussion * See * <code>@link * //apple_ref/cpp/instm/OSObject/release/virtualvoid/(int) * release(int freeWhen)@/link</code>. */ virtual void release(int freeWhen) const = 0; /*! * @function getRetainCount * * @abstract * Abstract declaration of * <code>@link * //apple_ref/cpp/instm/OSObject/getRetainCount/virtualint/() * getRetainCount()@/link</code>. * * @discussion * See * <code>@link * //apple_ref/cpp/instm/OSObject/getRetainCount/virtualint/() * OSObject::getRetainCount()@/link</code>. */ virtual int getRetainCount() const = 0; /*! * @function retain * * @abstract * Abstract declaration of * <code>@link * //apple_ref/cpp/instm/OSObject/retain/virtualvoid/() * retain()@/link</code>. * * @discussion * See * <code>@link * //apple_ref/cpp/instm/OSObject/retain/virtualvoid/() * OSObject::retain()@/link</code>. */ virtual void retain() const = 0; /*! * @function release * * @abstract * Abstract declaration of * <code>@link * //apple_ref/cpp/instm/OSObject/release/virtualvoid/() * release@/link</code>. * * @discussion * See * <code>@link * //apple_ref/cpp/instm/OSObject/release/virtualvoid/() * OSObject::release@/link</code>. */ virtual void release() const = 0; /*! * @function serialize * * @abstract * Abstract declaration of * <code>@link * //apple_ref/cpp/instm/OSObject/serialize/virtualbool/(OSSerialize*) * serialize@/link</code>. * * @discussion * See * <code>@link * //apple_ref/cpp/instm/OSObject/serialize/virtualbool/(OSSerialize*) * OSObject::serialize@/link</code>. */ virtual bool serialize(OSSerialize * serializer) const = 0; /*! * @function getMetaClass * * @abstract * Returns the OSMetaClass representing * an OSMetaClassBase subclass. * * @discussion * OSObject overrides this abstract member function * to return the OSMetaClass object that represents * each class for run-time typing. */ virtual const OSMetaClass * getMetaClass() const = 0; /*! * @function isEqualTo * * @abstract * Checks whether another object is equal to the receiver. * * @param anObject The object to copmare to the receiver. * * @result * <code>true</code> if the objects are equal, <code>false</code> otherwise. * * @discussion * OSMetaClassBase implements this as a direct pointer comparison, * since it has no other information to judge equality by. * Subclasses generally override this function * to do a more meaningful comparison. * For example, OSString implements it to return * <code>true</code> if <code>anObject</code> * is derived from OSString and represents the same C string. */ virtual bool isEqualTo(const OSMetaClassBase * anObject) const; /*! * @function metaCast * * @abstract * Casts this object is to the class managed by the given OSMetaClass. * * @param toMeta A pointer to a constant OSMetaClass * for the desired target type. * * @result * <code>this</code> if the object is derived * from the class managed by <code>toMeta</code>, * otherwise <code>NULL</code>. * * @discussion * It is far more convenient to use * <code>@link OSDynamicCast OSDynamicCast@/link</code>. */ OSMetaClassBase * metaCast(const OSMetaClass * toMeta) const; /*! * @function metaCast * * @abstract * Casts this object is to the class managed by the named OSMetaClass. * * @param toMeta An OSSymbol naming the desired target type. * * @result * <code>this</code> if the object is derived * from the class named by <code>toMeta</code>, * otherwise <code>NULL</code>. * * @discussion * It is far more convenient to use * <code>@link OSDynamicCast OSDynamicCast@/link</code>. */ OSMetaClassBase * metaCast(const OSSymbol * toMeta) const; /*! * @function metaCast * * @abstract * Casts this object is to the class managed by the named OSMetaClass. * * @param toMeta An OSString naming the desired target type. * @result * <code>this</code> if the object is derived * from the class named by <code>toMeta</code>, * otherwise <code>NULL</code>. * * @discussion * It is far more convenient to use * <code>@link OSDynamicCast OSDynamicCast@/link</code>. */ OSMetaClassBase * metaCast(const OSString * toMeta) const; /*! * @function metaCast * * @abstract * Casts this object is to the class managed by the named OSMetaClass. * * @param toMeta A C string naming the desired target type. * @result * <code>this</code> if the object is derived * from the class named by <code>toMeta</code>, * otherwise <code>NULL</code>. * * @discussion * It is far more convenient to use * <code>@link OSDynamicCast OSDynamicCast@/link</code>. */ OSMetaClassBase * metaCast(const char * toMeta) const; // Helper inlines for run-time type preprocessor macros /*! * @function safeMetaCast * * @abstract * Casts an object is to the class managed by the given OSMetaClass. * * @param anObject A pointer to the object to be cast. * @param toMeta A pointer to a constant OSMetaClass * for the desired target type. * * @result * <code>anObject</code> if the object is derived * from the class managed by <code>toMeta</code>, * otherwise <code>NULL</code>. * * @discussion * It is far more convenient to use * <code>@link OSDynamicCast OSDynamicCast@/link</code>. */ static OSMetaClassBase * safeMetaCast( const OSMetaClassBase * anObject, const OSMetaClass * toMeta); /*! * @function requiredMetaCast * * @abstract * Casts an object to the class managed by the given OSMetaClass or * fails with a kernel panic if the cast does not succeed. * * @param anObject A pointer to the object to be cast. * @param toMeta A pointer to a constant OSMetaClass * for the desired target type. * * @result * <code>anObject</code> if the object is derived * from the class managed by <code>toMeta</code>, * <code>NULL</code> if <code>anObject</code> was <code>NULL</code>, * kernel panic otherwise. * * @discussion * It is far more convenient to use * <code>@link OSRequiredCast OSRequiredCast@/link</code>. */ static OSMetaClassBase *requiredMetaCast( const OSMetaClassBase * anObject, const OSMetaClass * toMeta); /*! * @function checkTypeInst * * @abstract * Checks whether an object instance is of the same class * as another object instance (or a subclass of that class). * * @param inst A pointer to the object to check. * @param typeinst A pointer to an object of the class being checked. * * @result * <code>true</code> if the object is derived * from the class of <code>typeinst</code> * or a subclass of that class, * otherwise <code>false</code>. * * @discussion * It is far more convenient to use * <code>@link OSCheckTypeInst OSCheckTypeInst@/link</code>. */ static bool checkTypeInst( const OSMetaClassBase * inst, const OSMetaClassBase * typeinst); static void initialize(void); public: /*! * @function taggedRetain * * @abstract * Abstract declaration of * <code>@link * //apple_ref/cpp/instm/OSObject/taggedRetain/virtualvoid/(constvoid*) * taggedRetain(const void *)@/link</code>. * * @discussion * See * <code>@link * //apple_ref/cpp/instm/OSObject/taggedRetain/virtualvoid/(constvoid*) * OSObject::taggedRetain(const void *)@/link</code>. */ // WAS: virtual void _RESERVEDOSMetaClassBase0(); virtual void taggedRetain(const void * tag = NULL) const = 0; /*! * @function taggedRelease * * @abstract * Abstract declaration of * <code>@link * //apple_ref/cpp/instm/OSObject/taggedRelease/virtualvoid/(constvoid*) * taggedRelease(const void *)@/link</code>. * * @discussion * See * <code>@link * //apple_ref/cpp/instm/OSObject/taggedRelease/virtualvoid/(constvoid*) * OSObject::taggedRelease(const void *)@/link</code>. */ // WAS: virtual void _RESERVEDOSMetaClassBase1(); virtual void taggedRelease(const void * tag = NULL) const = 0; protected: /*! * @function taggedRelease * * @abstract * Abstract declaration of * <code>@link * //apple_ref/cpp/instm/OSObject/taggedRelease/virtualvoid/(constvoid*,constint) * taggedRelease(const void *, const int freeWhen)@/link</code>. * * @discussion * See * <code>@link * //apple_ref/cpp/instm/OSObject/taggedRelease/virtualvoid/(constvoid*,constint) * OSObject::taggedRelease(const void *, const int freeWhen)@/link</code>. */ // WAS: virtual void _RESERVEDOSMetaClassBase2(); virtual void taggedRelease( const void * tag, const int freeWhen) const = 0; public: virtual kern_return_t Dispatch(const IORPC rpc); kern_return_t Invoke(const IORPC rpc); private: #if APPLE_KEXT_VTABLE_PADDING // Virtual Padding #if defined(__arm64__) || defined(__arm__) virtual void _RESERVEDOSMetaClassBase0(); virtual void _RESERVEDOSMetaClassBase1(); virtual void _RESERVEDOSMetaClassBase2(); virtual void _RESERVEDOSMetaClassBase3(); #endif /* defined(__arm64__) || defined(__arm__) */ virtual void _RESERVEDOSMetaClassBase4(); virtual void _RESERVEDOSMetaClassBase5(); virtual void _RESERVEDOSMetaClassBase6(); virtual void _RESERVEDOSMetaClassBase7(); #endif /* APPLE_KEXT_VTABLE_PADDING */ } APPLE_KEXT_COMPATIBILITY; /*! * @class OSMetaClass * * @abstract * OSMetaClass manages run-time type information * for Libkern and I/O Kit C++ classes. * * @discussion OSMetaClass manages run-time type information * for Libkern and I/O Kit C++ classes. * An instance of OSMetaClass exists for (nearly) every such C++ class, * keeping track of inheritance relationships, class lookup by name, * instance counts, and more. * OSMetaClass operates almost entirely behind the scenes, * and kernel extensions should rarely, if ever, * have to interact directly with OSMetaClass. * * <b>Use by Kernel Extensions</b> * * While kernel extensions rarey interact directly with OSMetaClass at run time, * they must register their classes with the metaclass system * using the macros declared here. * The class declaration should use one of these two macros * before its first member function declaration: * <ul> * <li><code>@link OSDeclareDefaultStructors OSDeclareDefaultStructors@/link</code> - * for classes with no abstract member function declarations</li> * <li><code>@link OSDeclareAbstractStructors OSDeclareAbstractStructors@/link</code> - * for classes with at least one abstract member function declaration</li> * <li><code>@link OSDeclareFinalStructors OSDeclareFinalStructors@/link</code> - * for classes that should not be subclassable by another kext</li> * </ul> * * The class implementation should then use one of these macros: * <ul> * <li><code>@link OSDefineMetaClassAndStructors * OSDefineMetaClassAndStructors@/link</code> - * for classes with no abstract member function declarations</li> * <li><code>@link OSDefineMetaClassAndAbstractStructors * OSDefineMetaClassAndAbstractStructors@/link</code> - * for classes with at least one abstract member function declaration</li> * <li><code>@link OSDefineMetaClassAndFinalStructors * OSDefineMetaClassAndFinalStructors@/link</code> - * for classes that should not be subclassable by another kext</li> * </ul> * * Classes in kernel extensions that are intended for use as libraries * may need to reserve vtable slots to preserve binary compatibility * as new functions are added. They may do so with these macros: * <ul> * <li><code>@link OSMetaClassDeclareReservedUnused * OSMetaClassDeclareReservedUnused@/link</code> - * reserves a vtable slot</li> * <li><code>@link OSMetaClassDefineReservedUnused * OSMetaClassDefineReservedUnused@/link</code> - * defines the reserved vtable slot as an unimplemented function</li> * <li><code>@link OSMetaClassDeclareReservedUsed * OSMetaClassDeclareReservedUsed@/link</code> - * documents that a formerly reserved slot is now used</li> * <li><code>@link OSMetaClassDefineReservedUsed * OSMetaClassDefineReservedUsed@/link</code> - * documents that a formerly reserved slot is now used</li> * </ul> * * <b>Use Restrictions</b> * * OSMetaClass should not be explicitly subclassed by kernel extensions * (the declare/define macros do that), * nor should kernel extensions call its run-time type functions directly. * * OSMetaClass functions should be considered * <b>unsafe</b> to call in a primary interrupt context. * * <b>Concurrency Protection</b> * * Kernel extensions should in general not interact * with OSMetaClass objects directly, * instead using the run-time type macros. * Much of OSMetaClass's interface is intended for use * by the run-time type information system, * which handles concurrency and locking internally. */ class OSMetaClass : public OSMetaClassBase { friend class OSKext; #if IOKITSTATS friend class IOStatistics; #endif private: // Can never be allocated must be created at compile time static void * operator new(size_t size); /* Reserved for future use. (Internal use only) */ struct ExpansionData *reserved; /* superClass Handle to the superclass's meta class. */ const OSMetaClass *superClassLink; /* className OSSymbol of the class' name. */ const OSSymbol *className; /* classSize How big is a single instance of this class. */ unsigned int classSize; /* instanceCount Roughly number of instances of the object, * +1 for each direct subclass with a nonzero refcount. * Used primarily as a code-in-use flag. */ mutable unsigned int instanceCount; /* Not to be included in headerdoc. * * @function OSMetaClass * * @abstract * The default private constructor. */ OSMetaClass(); // Called by postModLoad /* Not to be included in headerdoc. * * @function logError * * @abstract * Logs an error string for an <code>OSReturn</code> value * using <code>printf</code>. * * @param result The <code>OSReturn</code> value for which to log a message. * * @discussion * This function is used to log errors loading kernel extensions. * Kernel extensions themselves should not call it. */ static void logError(OSReturn result); public: /*! * @function getMetaClassWithName * * @abstract * Look up a metaclass in the run-time type information system. * * @param name The name of the desired class's metaclass. * * @result * A pointer to the metaclass object if found, <code>NULL</code> otherwise. */ static const OSMetaClass * getMetaClassWithName(const OSSymbol * name); protected: /*! * @function retain * * @abstract * Implements the abstract <code>retain</code> function to do nothing. * * @discussion * Since an OSMetaClass instance must remain in existence * for as long as its kernel extension is loaded, * OSMetaClass does not use reference-counting. */ virtual void retain() const; /*! * @function release * * @abstract * Implements the abstract <code>release</code> function to do nothing. * * @discussion * Since an OSMetaClass instance must remain in existence * for as long as its kernel extension is loaded, * OSMetaClass does not use reference-counting. */ virtual void release() const; /*! * @function release * * @abstract * Implements the abstract <code>release(int freeWhen)</code> * function to do nothing. * * @param freeWhen Unused. * * @discussion * Since an OSMetaClass instance must remain in existence * for as long as its kernel extension is loaded, * OSMetaClass does not use reference-counting. */ virtual void release(int freeWhen) const; /*! * @function taggedRetain * * @abstract * Implements the abstract <code>taggedRetain(const void *)</code> * function to do nothing. * * @param tag Unused. * * @discussion * Since an OSMetaClass instance must remain in existence * for as long as its kernel extension is loaded, * OSMetaClass does not use reference-counting. */ virtual void taggedRetain(const void * tag = NULL) const; /*! * @function taggedRelease * * @abstract * Implements the abstract <code>taggedRelease(const void *)</code> * function to do nothing. * * @param tag Unused. * * @discussion * Since an OSMetaClass instance must remain in existence * for as long as its kernel extension is loaded, * OSMetaClass does not use reference-counting. */ virtual void taggedRelease(const void * tag = NULL) const; /*! * @function taggedRelease * * @abstract * Implements the abstract <code>taggedRelease(const void *, cont int)</code> * function to do nothing. * * @param tag Unused. * @param freeWhen Unused. * * @discussion * Since an OSMetaClass instance must remain in existence * for as long as its kernel extension is loaded, * OSMetaClass does not use reference-counting. */ virtual void taggedRelease( const void * tag, const int freeWhen) const; /*! * @function getRetainCount * * @abstract * Implements the abstract <code>getRetainCount</code> * function to return 0. * * @result * Always returns 0. * * @discussion * Since an OSMetaClass instance must remain in existence * for as long as its kernel extension is loaded, * OSMetaClass does not use reference-counting. */ virtual int getRetainCount() const; /* Not to be included in headerdoc. * * @function getMetaClass * * @abstract * Returns the meta-metaclass. * * @result * The metaclass of the OSMetaClass object. */ virtual const OSMetaClass * getMetaClass() const; /*! * @function OSMetaClass * * @abstract * Constructor for OSMetaClass objects. * * @param className A C string naming the C++ class * that this OSMetaClass represents. * @param superclass The OSMetaClass object representing the superclass * of this metaclass's class. * @param classSize The allocation size of the represented C++ class. * * @discussion * This constructor is protected and cannot be used * to instantiate OSMetaClass directly, as OSMetaClass is an abstract class. * This function is called during kext loading * to queue C++ classes for registration. * See <code>@link preModLoad preModLoad@/link</code> and * <code>@link postModLoad postModLoad@/link</code>. */ OSMetaClass(const char * className, const OSMetaClass * superclass, unsigned int classSize); /*! * @function ~OSMetaClass * * @abstract * Destructor for OSMetaClass objects. * * @discussion * This function is called when the kernel extension that implements * the metaclass's class is unloaded. * The destructor removes all references to the class * from the run-time type information system. */ virtual ~OSMetaClass(); // Needs to be overriden as NULL as all OSMetaClass objects are allocated // statically at compile time, don't accidently try to free them. void operator delete(void *, size_t) { } public: static const OSMetaClass * const metaClass; /*! * @function preModLoad * * @abstract * Prepares the run-time type system * for the creation of new metaclasses * during loading of a kernel extension (module). * * @param kextID The bundle ID of the kext being loaded. * * @result * An opaque handle to the load context * for the kernel extension on success; * <code>NULL</code> on failure. * * @discussion * <i>Not for use by kernel extensions.</i> * * Prepares the run-time type information system to record and register * metaclasses created by static constructors until a subsequent call to * <code>@link postModLoad postModLoad@/link</code>. * <code>preModLoad</code> takes a lock to ensure processing of a single * load operation at a time; the lock is released by * <code>@link postModLoad postModLoad@/link</code>. * Any OSMetaClass constructed between these two function calls * will be associated with <code>kextID</code>. */ static void * preModLoad(const char * kextID); /*! * @function checkModLoad * * @abstract * Checks whether the current kext load operation can proceed. * * @param loadHandle The opaque handle returned * by <code>@link preModLoad preModLoad@/link</code>. * @result * <code>true</code> if no errors are outstanding * and the system is ready to process more metaclasses. * * @discussion * <i>Not for use by kernel extensions.</i> */ static bool checkModLoad(void * loadHandle); /*! * @function postModLoad * * @abstract * Registers the metaclasses created during loading of a kernel extension. * * @param loadHandle The opaque handle returned * by <code>@link preModLoad preModLoad@/link</code>. * @result * The error code of the first error encountered, * or * <code>@link * //apple_ref/cpp/macro/kOSReturnSuccess * kOSReturnSuccess@/link</code> * if no error occurred. * * @discussion * <i>Not for use by kernel extensions.</i> * * Called after all static constructors in a kernel extension * have created metaclasses, * this function checks for duplicate class names, * then registers the new metaclasses under the kext ID * that @link preModLoad preModLoad@/link was called with, * so that they can be dynamically allocated * and have their instance counts tracked. * <code>postModLoad</code> releases the lock taken by * <code>@link preModLoad preModLoad@/link</code>. */ static OSReturn postModLoad(void * loadHandle); /*! * @function modHasInstance * * @abstract * Returns whether any classes defined by the named * kernel extension (or their subclasses) have existing instances. * * @param kextID The bundle ID of the kernel extension to check. * * @result * <code>true</code> if the kext is found and * if any class defined by that kext * has a nonzero instance count, * <code>false</code> otherwise. * * @discussion * This function is called before a kernel extension's static destructors * are invoked, prior to unloading the extension. * If any classes stil have instances or subclasses with instances, * those classes are logged * (using <code>@link reportModInstances reportModInstances@/link</code>) and * the kernel extension is not be unloaded. */ static bool modHasInstance(const char * kextID); /*! * @function reportModInstances * * @abstract * Logs the instance counts for classes * defined by a kernel extension. * * @param kextID The bundle ID of the kernel extension to report on. * * @discussion * This function prints the names and instance counts * of any class defined by <code>kextID</code> * that has a nonzero instance count. * It's called by <code>@link modHasInstance modHasInstance@/link</code> * to help diagnose problems unloading kernel extensions. */ static void reportModInstances(const char * kextID); /*! * @function considerUnloads * * @abstract * Schedule automatic unloading of unused kernel extensions. * * @discussion * This function schedules a check for kernel extensions * that can be automatically unloaded, * canceling any currently scheduled check. * At that time, any such kexts with no Libkern C++ instances * and no external references are unloaded. * * The I/O Kit calls this function when matching goes idle. * * Kernel extensions that define subclasses of * @link //apple_ref/doc/class/IOService IOService@/link * are eligible for automatic unloading. * * (On releases of Mac OS X prior to Snow Leopard (10.6), * any kernel extension defining any Libkern C++ class * was eligible for automatic unloading, * but that unload did not call the module stop routine. * Non-I/O Kit kernel extensions that define Libkern C++ subclasses * should be sure to have OSBundleLibraries declarations that ensure * they will not load on releases prior to Snow Leopard.) */ static void considerUnloads(); /*! * @function allocClassWithName * * @abstract * Allocates an instance of a named OSObject-derived class. * * @param name The name of the desired class. * * @result * A pointer to the newly-allocated, uninitialized object on success; * <code>NULL</code> on failure. * * @discussion * Kernel extensions should not need to use this function * directly, instead using static instance-creation functions * defined by classes. * * This function consults the run-time type information system * to find the metaclass for the named class. * If it exists, it calls the metaclass's <code>@link alloc alloc@/link</code> * function and returns the result. */ static OSObject * allocClassWithName(const OSSymbol * name); /*! * function allocClassWithName * * @abstract * Allocates an instance of a named OSObject-derived class. * * @param name The name of the desired class. * * @result * A pointer to the newly-allocated, uninitialized object on success; * <code>NULL</code> on failure. * * @discussion * Kernel extensions should not need to use this function * directly, instead using static instance-creation functions * defined by classes. * * This function consults the run-time type information system * to find the metaclass for the named class. * If it exists, it calls the metaclass's <code>@link alloc alloc@/link</code> * function and returns the result. */ static OSObject * allocClassWithName(const OSString * name); /*! * function allocClassWithName * * @abstract * Allocates an instance of a named OSObject-derived class. * * @param name The name of the desired class. * * @result * A pointer to the newly-allocated, uninitialized object on success; * <code>NULL</code> on failure. * * @discussion * Kernel extensions should not need to use this function * directly, instead using static instance-creation functions * defined by classes. * * This function consults the run-time type information system * to find the metaclass for the named class. * If it exists, it calls the metaclass's <code>@link alloc alloc@/link</code> * function and returns the result. */ static OSObject * allocClassWithName(const char * name); /*! * @function checkMetaCastWithName * * @abstract * Search the metaclass inheritance hierarchy by name for an object instance. * * @param className The name of the desired class or superclass. * @param object The object whose metaclass begins the search. * * @result * <code>object</code> if it's derived from <code>className</code>; * <code>NULL</code> otherwise. * * @discussion * This function is the basis of the Libkern run-time type-checking system. * Kernel extensions should not use it directly, * instead using <code>@link OSDynamicCast OSDynamicCast@/link</code> or * <code>@link OSCheckTypeInst OSCheckTypeInst@/link</code>. */ static OSMetaClassBase * checkMetaCastWithName( const OSSymbol * className, const OSMetaClassBase * object); /*! * @function checkMetaCastWithName * * @abstract * Search the metaclass inheritance hierarchy by name for an object instance. * * @param className The name of the desired class or superclass. * @param object The object whose metaclass begins the search. * * @result * <code>object</code> if it's derived from <code>className</code>; * <code>NULL</code> otherwise. * * @discussion * Kernel extensions should not use this function directly, * instead using <code>@link OSDynamicCast OSDynamicCast@/link</code> or * <code>@link OSCheckTypeInst OSCheckTypeInst@/link</code>. */ static OSMetaClassBase * checkMetaCastWithName( const OSString * className, const OSMetaClassBase * object); /*! * @function checkMetaCastWithName * * @abstract * Search the metaclass inheritance hierarchy by name for an object instance. * * @param className The name of the desired class or superclass. * @param object The object whose metaclass begins the search. * * @result * <code>object</code> if it's derived from <code>className</code>; * <code>NULL</code> otherwise. * * @discussion * Kernel extensions should not use this function directly, * instead using <code>@link OSDynamicCast OSDynamicCast@/link</code> or * <code>@link OSCheckTypeInst OSCheckTypeInst@/link</code>. */ static OSMetaClassBase * checkMetaCastWithName( const char * className, const OSMetaClassBase * object); /*! * @function instanceConstructed * * @abstract * Counts the instances of the class managed by this metaclass. * * @discussion * <i>Not for use by kernel extensions.</i> * * Every non-abstract class that inherits from OSObject * has a default constructor that calls it's own metaclass's * <code>instanceConstructed</code> function. * This constructor is defined by the * <code>@link * OSDefineMetaClassAndStructors * OSDefineMetaClassAndStructors@/link</code> * macro that all OSObject subclasses must use. * * If a class's instance count goes from 0 to 1--that is, * upon the creation of the first instance of that class--the * superclass's instance count is also incremented. * This propagates reference counts up the inheritance chain so that * superclasses are counted as "in use" when subclasses have instances. */ void instanceConstructed() const; /*! * @function instanceDestructed * * @abstract * Counts the instances of the class managed by this metaclass. * * @discussion * Every non-abstract class that inherits from OSObject * has a default destructor that calls it's own metaclass's * <code>instanceDestructed</code> function. * This constructor is defined by the * @link OSDefineMetaClassAndStructors OSDefineMetaClassAndStructors@/link * macro that all OSObject subclasses must use. * * If a class's instance count goes from 1 to 0--that is, * upon the destruction of the last instance of that class--the * superclass's instance count is also decremented. * This reduces "in use" counts from superclasses when their subclasses * no longer have instances. */ void instanceDestructed() const; /*! * @function checkMetaCast * * @abstract * Check whether a given object is an instance of the receiving * metaclass's class or one derived from it. * * @param object The object to check for inheritance. * * @result * <code>object</code> if it is derived from the receiver's class, * <code>NULL</code> if not. */ OSMetaClassBase * checkMetaCast(const OSMetaClassBase * object) const; /*! * @function getInstanceCount * * @abstract * Returns the number of existing instances of the metaclass's class. * * @result * The number of existing instances of the metaclass's class, * plus 1 for each subclass with any instance. */ unsigned int getInstanceCount() const; /*! * @function getSuperClass * * @abstract * Returns the super-metaclass of the receiver. * * @result * Returns a pointer to the super-metaclass of the receiving * OSMetaClass, or <code>NULL</code> for OSObject's metaclass. */ const OSMetaClass * getSuperClass() const; /*! * @function getKmodName * * @abstract * Returns the bundle identifier of the kernel extension * that defines this metaclass. * * @result * The bundle identifier of the kernel extension that defines this metaclass. * * @discussion * "Kmod" is an older term for kernel extension. */ const OSSymbol * getKmodName() const; /*! * @function getClassName * * @abstract * Returns the name of the C++ class managed by this metaclass. * * @result * Returns the name of the C++ class managed by this metaclass. */ const char * getClassName() const; const OSSymbol * getClassNameSymbol() const; /*! * @function getClassSize * * @abstract * Returns the allocation size of the C++ class managed by this metaclass. * * @result * The allocation size of the C++ class managed by this metaclass. */ unsigned int getClassSize() const; /*! * @function alloc * * @abstract * Allocates an instance of the C++ class managed by this metaclass. * * @result * A pointer to the newly allocated, uninitialized instance, * with a retain count of 1; <code>NULL</code> on allocation failure. * * @discussion * This function is automatically created by the metaclass-registration macros * to enable dynamic instance allocation. */ virtual OSObject * alloc() const = 0; /* Not to be included in headerdoc. * * @define OSDeclareCommonStructors * @hidecontents * * @abstract * Helper macro for for the standard metaclass-registration macros. * DO NOT USE. * * @param className The name of the C++ class, as a raw token, * <i>not</i> a string or macro. */ #define _OS_ADD_METAMETHODS(b) _OS_ADD_METAMETHODS_ ## b #define _OS_ADD_METAMETHODS_ #define _OS_ADD_METAMETHODS_dispatch \ virtual kern_return_t Dispatch(const IORPC rpc) APPLE_KEXT_OVERRIDE; #define _OS_ADD_METHODS(className, b) _OS_ADD_METHODS_ ## b(className) #define _OS_ADD_METHODS_(className) #define _OS_ADD_METHODS_dispatch(className) \ className ## _Methods \ className ## _KernelMethods #define SUPERDISPATCH ((OSDispatchMethod)&super::_Dispatch) #define OSDeclareCommonStructors(className, dispatch) \ private: \ static const OSMetaClass * const superClass; \ public: \ static const OSMetaClass * const metaClass; \ static class MetaClass : public OSMetaClass { \ public: \ MetaClass(); \ virtual OSObject *alloc() const APPLE_KEXT_OVERRIDE; \ _OS_ADD_METAMETHODS(dispatch); \ } gMetaClass; \ friend class className ::MetaClass; \ virtual const OSMetaClass * getMetaClass() const APPLE_KEXT_OVERRIDE; \ protected: \ className (const OSMetaClass *); \ virtual ~ className () APPLE_KEXT_OVERRIDE; \ _OS_ADD_METHODS(className, dispatch) #define _OS_ADD_OPERATOR_PROTO \ public: \ static void *operator new(size_t size); \ protected: \ static void operator delete(void *mem, size_t size); /*! * @define OSDeclareDefaultStructors * @hidecontents * * @abstract * Declares run-time type information and functions * for a final (non-subclassable) Libkern C++ class. * * @param className The name of the C++ class, as a raw token, * <i>not</i> a string or macro. * * @discussion * Concrete Libkern C++ classes should "call" this macro * immediately after the opening brace in a class declaration. * It leaves the current privacy state as <code>protected:</code>. */ #define _OSDeclareDefaultStructors(className, dispatch) \ OSDeclareCommonStructors(className, dispatch); \ public: \ className (void); \ _OS_ADD_OPERATOR_PROTO \ protected: #define OSDeclareDefaultStructors(className) \ _OSDeclareDefaultStructors(className, ) #define OSDeclareDefaultStructorsWithDispatch(className) \ _OSDeclareDefaultStructors(className, dispatch) /*! * @define OSDeclareAbstractStructors * @hidecontents * * @abstract * Declares run-time type information and functions * for an abstract Libkern C++ class. * * @param className The name of the C++ class, as a raw token, * <i>not</i> a string or macro. * * @discussion * Abstract Libkern C++ classes--those with at least one * pure virtual method--should "call" this macro * immediately after the opening brace in a class declaration. * It leaves the current privacy state as <code>protected:</code>. */ #define _OSDeclareAbstractStructors(className, dispatch) \ OSDeclareCommonStructors(className, dispatch) \ private: \ /* Make primary constructor private in abstract */ \ className (void); \ protected: \ #define OSDeclareAbstractStructors(className) \ _OSDeclareAbstractStructors(className, ) \ _OS_ADD_OPERATOR_PROTO #define OSDeclareAbstractStructorsWithDispatch(className) \ _OSDeclareAbstractStructors(className, dispatch) \ _OS_ADD_OPERATOR_PROTO #define OSDeclareAbstractStructorsWithDispatchAndNoOperators( \ className) \ _OSDeclareAbstractStructors(className, dispatch) /*! * @define OSDeclareFinalStructors * @hidecontents * * @abstract * Declares run-time type information and functions * for a concrete Libkern C++ class. * * @param className The name of the C++ class, as a raw token, * <i>not</i> a string or macro. * * @discussion * Final Libkern C++ classes--those that do not allow subclassing--should * "call" this macro immediately after the opening brace in a class declaration. * (Final classes in the kernel may actually have subclasses in the kernel, * but kexts cannot define any subclasses of a final class.) * It leaves the current privacy state as <code>protected:</code>. * * <b>Note:</b> If the class is exported by a pseudokext (symbol set), * the final symbol generated by this macro must be exported * for the final-class attribute to be enforced. * * <b>Warning:</b> Changing a class from "Default" to "Final" will break * binary compatibility. */ #define _OSDeclareFinalStructors(className, dispatch) \ _OSDeclareDefaultStructors(className, dispatch) \ private: \ void __OSFinalClass(void); \ protected: #define OSDeclareFinalStructors(className) \ _OSDeclareFinalStructors(className, ) #define OSDeclareFinalStructorsWithDispatch(className) \ _OSDeclareFinalStructors(className, dispatch) /* Not to be included in headerdoc. * * @define OSDefineMetaClassWithInit * @hidecontents * * @abstract * Helper macro for for the standard metaclass-registration macros. * DO NOT USE. * * @param className The name of the C++ class, as a raw token, * <i>not</i> a string or macro. * @param superclassName The name of the superclass of the C++ class, * as a raw token, * <i>not</i> a string or macro. * @param init A function to call in the constructor * of the class's OSMetaClass. * * @discussion * <b>Note:</b> Needs to be followed by * <code>OSMetaClassConstructorInit</code> or * <code>OSMetaClassConstructorInitWithZone</code> for initialization * of class's <code>OSMetaClass</code> constructor. */ #define OSMetaClassConstructorInit(className, superclassName, \ init) \ /* The ::MetaClass constructor */ \ className ::MetaClass::MetaClass() \ : OSMetaClass(#className, className::superClass, \ sizeof(className)) \ { init; } #define OSDefineMetaClassWithInit(className, superclassName, \ init) \ /* Class global data */ \ className ::MetaClass className ::gMetaClass; \ const OSMetaClass * const className ::metaClass = \ & className ::gMetaClass; \ const OSMetaClass * const className ::superClass = \ & superclassName ::gMetaClass; \ /* Class member functions */ \ className :: className(const OSMetaClass *meta) \ : superclassName (meta) { } \ className ::~ className() { } \ const OSMetaClass * className ::getMetaClass() const \ { return &gMetaClass; } /* Not to be included in headerdoc. * * @define OSDefineAbstractStructors * @hidecontents * * @abstract * Helper macro for for the standard metaclass-registration macros. * DO NOT USE. * * @param className The name of the C++ class, as a raw token, * <i>not</i> a string or macro. * @param superclassName The name of the superclass of the C++ class, * as a raw token, * <i>not</i> a string or macro. */ #define OSDefineAbstractStructors(className, superclassName) \ OSObject * className ::MetaClass::alloc() const { return NULL; } /* Not to be included in headerdoc. * * @define OSDefineDefaultStructors * @hidecontents * * @abstract * Helper macro for for the standard metaclass-registration macros. * DO NOT USE. * * @param className The name of the C++ class, as a raw token, * <i>not</i> a string or macro. * @param superclassName The name of the superclass of the C++ class, * as a raw token, * <i>not</i> a string or macro. */ #define OSDefineBasicStructors(className, superclassName) \ OSObject * className ::MetaClass::alloc() const \ { return new className; } \ className :: className () : superclassName (&gMetaClass) \ { gMetaClass.instanceConstructed(); } #define OSDefineOperatorMethods(className) \ void * className::operator new(size_t size) { \ return OSObject::operator new(size); \ } \ void className::operator delete(void *mem, size_t size) { \ return OSObject::operator delete(mem, size); \ } #define OSDefineDefaultStructors(className, superclassName) \ OSDefineBasicStructors(className, superclassName) \ OSDefineOperatorMethods(className) /* Not to be included in headerdoc. * * @define OSDefineDefaultStructors * @hidecontents * * @abstract * Helper macro for for the standard metaclass-registration macros. * DO NOT USE. * * @param className The name of the C++ class, as a raw token, * <i>not</i> a string or macro. * @param superclassName The name of the superclass of the C++ class, * as a raw token, * <i>not</i> a string or macro. */ #define OSDefineFinalStructors(className, superclassName) \ OSDefineBasicStructors(className, superclassName) \ void className ::__OSFinalClass(void) { } /* Not to be included in headerdoc. * * @define OSDefineMetaClassAndStructorsWithInit * @hidecontents * * @abstract * Helper macro for for the standard metaclass-registration macros. * DO NOT USE. * * @param className The name of the C++ class, as a raw token, * <i>not</i> a string or macro. * @param superclassName The name of the superclass of the C++ class, * as a raw token, * <i>not</i> a string or macro. * @param init A function to call in the constructor * of the class's OSMetaClass. */ #define OSDefineMetaClassAndStructorsWithInit(className, \ superclassName, init) \ OSDefineMetaClassWithInit(className, superclassName, init) \ OSMetaClassConstructorInit(className, superclassName, init) \ OSDefineDefaultStructors(className, superclassName) /* Not to be included in headerdoc. * * @define OSDefineMetaClassAndAbstractStructorsWithInit * @hidecontents * * @abstract * Helper macro for for the standard metaclass-registration macros. * DO NOT USE. * * @param className The name of the C++ class, as a raw token, * <i>not</i> a string or macro. * @param superclassName The name of the superclass of the C++ class, * as a raw token, * <i>not</i> a string or macro. * @param init A function to call in the constructor * of the class's OSMetaClass. */ #define OSDefineMetaClassAndAbstractStructorsWithInit( \ className, superclassName, init) \ OSDefineMetaClassWithInit(className, superclassName, init) \ OSMetaClassConstructorInit(className, superclassName, init) \ OSDefineAbstractStructors(className, superclassName) \ OSDefineOperatorMethods(className) /* Not to be included in headerdoc. * * @define OSDefineMetaClassAndFinalStructorsWithInit * @hidecontents * * @abstract * Helper macro for for the standard metaclass-registration macros. * DO NOT USE. * * @param className The name of the C++ class, as a raw token, * <i>not</i> a string or macro. * @param superclassName The name of the superclass of the C++ class, * as a raw token, * <i>not</i> a string or macro. * @param init A function to call in the constructor * of the class's OSMetaClass. */ #define OSDefineMetaClassAndFinalStructorsWithInit(className, \ superclassName, init) \ OSDefineMetaClassWithInit(className, superclassName, init) \ OSMetaClassConstructorInit(className, superclassName, init) \ OSDefineFinalStructors(className, superclassName) \ OSDefineOperatorMethods(className) /* Helpers */ /* Not to be included in headerdoc. * * @define OSDefineMetaClass * @hidecontents * * @abstract * Helper macro for for the standard metaclass-registration macros. * DO NOT USE. * * @param className The name of the C++ class, as a raw token, * <i>not</i> a string or macro. * @param superclassName The name of the superclass of the C++ class, * as a raw token, * <i>not</i> a string or macro. * @param init A function to call in the constructor * of the class's OSMetaClass. */ #define OSDefineMetaClass(className, superclassName) \ OSDefineMetaClassWithInit(className, superclassName, ) \ OSMetaClassConstructorInit(className, superclassName, ) \ OSDefineOperatorMethods(className) /*! * @define OSDefineMetaClassAndStructors * @hidecontents * * @abstract * Defines an OSMetaClass and associated routines * for a concrete Libkern C++ class. * * @param className The name of the C++ class, as a raw token, * <i>not</i> a string or macro. * @param superclassName The name of the superclass of the C++ class, * as a raw token, * <i>not</i> a string or macro. * * @discussion * Concrete Libkern C++ classes should "call" this macro * at the beginning of their implementation files, * before any function implementations for the class. */ #define OSDefineMetaClassAndStructors(className, superclassName) \ OSDefineMetaClassAndStructorsWithInit(className, \ superclassName, ) /*! * @define OSDefineMetaClassAndAbstractStructors * @hidecontents * * @abstract * Defines an OSMetaClass and associated routines * for an abstract Libkern C++ class. * * @param className The name of the C++ class, as a raw token, * <i>not</i> a string or macro. * @param superclassName The name of the superclass of the C++ class, * as a raw token, * <i>not</i> a string or macro. * * @discussion * Abstract Libkern C++ classes--those with at least one * pure virtual method--should "call" this macro * at the beginning of their implementation files, * before any function implementations for the class. */ #define OSDefineMetaClassAndAbstractStructors(className, \ superclassName) \ OSDefineMetaClassAndAbstractStructorsWithInit (className, \ superclassName, ) /*! * @define OSDefineMetaClassAndFinalStructors * @hidecontents * * @abstract * Defines an OSMetaClass and associated routines * for concrete Libkern C++ class. * * @param className The name of the C++ class, as a raw token, * <i>not</i> a string or macro. * @param superclassName The name of the superclass of the C++ class, * as a raw token, * <i>not</i> a string or macro. * * @discussion * Final Libkern C++ classes--those that do not allow * subclassing--should "call" this macro at the beginning * of their implementation files, * before any function implementations for the class. * (Final classes in the kernel may actually have subclasses in the kernel, * but kexts cannot define any subclasses of a final class.) * * <b>Note:</b> If the class is exported by a pseudokext (symbol set), * the final symbol generated by this macro must be exported * for the final-class attribute to be enforced. * * <b>Warning:</b> Changing a class from "Default" to "Final" will break * binary compatibility. */ #define OSDefineMetaClassAndFinalStructors(className, \ superclassName) \ OSDefineMetaClassAndFinalStructorsWithInit(className, \ superclassName, ) // Dynamic vtable patchup support routines and types void reservedCalled(int ind) const; /*! * @define OSMetaClassDeclareReservedUnused * @hidecontents * * @abstract * Reserves vtable space for new virtual functions * in a Libkern C++ class. * * @param className The name of the C++ class, as a raw token, * <i>not</i> a string or macro. * @param index The numeric index of the vtable slot, * as a raw constant, beginning from 0. * * @discussion * Libkern C++ classes in kernel extensions that can be used as libraries * can provide for backward compatibility by declaring a number * of reserved vtable slots * that can be replaced with new functions as they are added. * Each reserved declaration must be accompanied in the implementation * by a corresponding reference to * <code>@link OSMetaClassDefineReservedUnused * OSMetaClassDefineReservedUnused@/link</code>. * * When replacing a reserved slot, change the macro from "Unused" * to "Used" to document the fact that the slot used to be reserved, * and declare the new function immediately after the "Used" macro * to preserve vtable ordering. * See * <code>@link OSMetaClassDeclareReservedUsed * OSMetaClassDeclareReservedUsed@/link</code>. */ #if APPLE_KEXT_VTABLE_PADDING #define OSMetaClassDeclareReservedUnused(className, index) \ virtual void _RESERVED ## className ## index () #else #define OSMetaClassDeclareReservedUnused(className, index) #endif /*! * @define OSMetaClassDeclareReservedUsed * @hidecontents * * @abstract * Documents use of reserved vtable space for new virtual functions * in a Libkern C++ class. * * @param className The name of the C++ class, as a raw token, * <i>not</i> a string or macro. * @param index The numeric index of the vtable slot, * as a raw constant, beginning from 0. * * @discussion * This macro evaluates to nothing, and is used to document reserved * vtable slots as they are filled. * See * <code>@link OSMetaClassDeclareReservedUnused * OSMetaClassDeclareReservedUnused@/link</code>. */ #define OSMetaClassDeclareReservedUsed(className, index) #define OSMetaClassDeclareReservedUsedARM(className, x86index, armindex) /*! * @define OSMetaClassDefineReservedUnused * @hidecontents * * @abstract * Defines a reserved vtable slot for a Libkern C++ class. * * @param className The name of the C++ class, as a raw token, * <i>not</i> a string or macro. * @param index The numeric index of the vtable slot, * as a raw constant, beginning from 0. * * @discussion * Libkern C++ classes in kernel extensions that can be used as libraries * can provide for backward compatibility by declaring a number * of reserved vtable slots * that can be replaced with new functions as they are added. * Each reserved defintion accompanies * a corresponding declaration created with * <code>@link OSMetaClassDeclareReservedUnused * OSMetaClassDeclareReservedUnused@/link</code>. * * This macro is used in the implementation file * to provide a placeholder definition for the reserved vtable slot, * as a function that calls <code>panic</code> with an error message. * * When replacing a reserved slot, change the macro from "Unused" * to "Used" to document the fact that the slot used to be reserved, * and declare the new function immediately after the "Used" macro * to preserve vtable ordering. * See * <code>@link OSMetaClassDefineReservedUsed * OSMetaClassDefineReservedUsed@/link</code>. */ #if APPLE_KEXT_VTABLE_PADDING #define OSMetaClassDefineReservedUnused(className, index) \ void className ::_RESERVED ## className ## index () \ { gMetaClass.reservedCalled(index); } #else #define OSMetaClassDefineReservedUnused(className, index) #endif /*! * @define OSMetaClassDefineReservedUsed * @hidecontents * * @abstract * Reserves vtable space for new virtual functions in a Libkern C++ class. * * @param className The name of the C++ class, as a raw token, * <i>not</i> a string or macro. * @param index The numeric index of the vtable slot, * as a raw constant, beginning from 0. * * @discussion * This macro evaluates to nothing, and is used to document reserved * vtable slots as they are filled. * See * <code>@link OSMetaClassDefineReservedUnused * OSMetaClassDefineReservedUnused@/link</code>. */ #define OSMetaClassDefineReservedUsed(className, index) #define OSMetaClassDefineReservedUsedARM(className, x86index, armindex) /* * OSMetaClassDeclareReservedUsedX86 needs to be placed with the unused vtable * slots since it will unused on arm targets. */ #if defined(__arm64__) || defined(__arm__) #define OSMetaClassDeclareReservedUsedX86 OSMetaClassDeclareReservedUnused #define OSMetaClassDefineReservedUsedX86 OSMetaClassDefineReservedUnused #else #define OSMetaClassDeclareReservedUsedX86 OSMetaClassDeclareReservedUsed #define OSMetaClassDefineReservedUsedX86 OSMetaClassDefineReservedUsed #endif // I/O Kit debug internal routines. static void printInstanceCounts(); static void serializeClassDictionary(OSDictionary * dict); private: // Obsolete APIs static OSDictionary * getClassDictionary(); virtual bool serialize(OSSerialize * serializer) const; // Virtual Padding functions for MetaClass's OSMetaClassDeclareReservedUnused(OSMetaClass, 0); OSMetaClassDeclareReservedUnused(OSMetaClass, 1); OSMetaClassDeclareReservedUnused(OSMetaClass, 2); OSMetaClassDeclareReservedUnused(OSMetaClass, 3); OSMetaClassDeclareReservedUnused(OSMetaClass, 4); OSMetaClassDeclareReservedUnused(OSMetaClass, 5); OSMetaClassDeclareReservedUnused(OSMetaClass, 6); OSMetaClassDeclareReservedUnused(OSMetaClass, 7); }; #endif /* !_LIBKERN_OSMETACLASS_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSSet.h
/* * Copyright (c) 2019 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@ */ /* IOSet.h created by rsulack on Thu 11-Jun-1998 */ /* IOSet.h converted to C++ by gvdl on Fri 1998-10-30 */ #ifndef _OS_OSSET_H #define _OS_OSSET_H #include <libkern/c++/OSCollection.h> #include <libkern/c++/OSPtr.h> class OSArray; class OSSet; typedef OSSet* OSSetPtr; typedef OSArray* OSArrayPtr; /*! * @header * * @abstract * This header declares the OSSet collection class. */ /*! * @class OSSet * * @abstract * OSSet provides an unordered set store of objects. * * @discussion * OSSet is a container for Libkern C++ objects * (those derived from * @link //apple_ref/doc/class/OSMetaClassBase OSMetaClassBase@/link, * in particular @link //apple_ref/doc/class/OSObject OSObject@/link). * Storage and access follow basic set logic: you can add or remove an object, * and test whether the set contains a particular object. * A given object is only stored in the set once, * and there is no ordering of objects in the set. * A subclass @link //apple_ref/doc/class/OSOrderedSet OSOrderedSet@/link, * provides for ordered set logic. * * As with all Libkern collection classes, * OSSet retains objects added to it, * and releases objects removed from it. * An OSSet also grows as necessary to accommodate new objects, * <i>unlike</i> Core Foundation collections (it does not, however, shrink). * * <b>Use Restrictions</b> * * With very few exceptions in the I/O Kit, all Libkern-based C++ * classes, functions, and macros are <b>unsafe</b> * to use in a primary interrupt context. * Consult the I/O Kit documentation related to primary interrupts * for more information. * * OSSet provides no concurrency protection; * it's up to the usage context to provide any protection necessary. * Some portions of the I/O Kit, such as * @link //apple_ref/doc/class/IORegistryEntry IORegistryEntry@/link, * handle synchronization via defined member functions for setting * properties. */ class OSSet : public OSCollection { friend class OSSerialize; OSDeclareDefaultStructors(OSSet); #if APPLE_KEXT_ALIGN_CONTAINERS private: OSPtr<OSArray> members; #else /* APPLE_KEXT_ALIGN_CONTAINERS */ private: OSPtr<OSArray> members; protected: struct ExpansionData { }; /* Reserved for future use. (Internal use only) */ ExpansionData * reserved; #endif /* APPLE_KEXT_ALIGN_CONTAINERS */ /* * OSCollectionIterator interfaces. */ virtual unsigned int iteratorSize() const APPLE_KEXT_OVERRIDE; virtual bool initIterator(void * iterator) const APPLE_KEXT_OVERRIDE; virtual bool getNextObjectForIterator(void * iterator, OSObject ** ret) const APPLE_KEXT_OVERRIDE; public: /*! * @function withCapacity * * @abstract * Creates and initializes an empty OSSet. * * @param capacity The initial storage capacity of the new set object. * * @result * An empty instance of OSSet * with a retain count of 1; * <code>NULL</code> on failure. * * @discussion * <code>capacity</code> must be nonzero. * The new OSSet will grow as needed to accommodate more key/object pairs * (<i>unlike</i> @link //apple_ref/doc/uid/20001503 CFMutableSet@/link, * for which the initial capacity is a hard limit). */ static OSPtr<OSSet> withCapacity(unsigned int capacity); /*! * @function withObjects * * @abstract * Creates and initializes an OSSet * populated with objects provided. * * @param objects A C array of OSMetaClassBase-derived objects. * @param count The number of objects to be placed into the set. * @param capacity The initial storage capacity of the new set object. * If 0, <code>count</code> is used; otherwise this value * must be greater than or equal to <code>count</code>. * * @result * An instance of OSSet * containing the objects provided, * with a retain count of 1; * <code>NULL</code> on failure. * * @discussion * <code>objects</code> must be non-<code>NULL</code>, * and <code>count</code> must be nonzero. * If <code>capacity</code> is nonzero, * it must be greater than or equal to <code>count</code>. * The new OSSet will grow as needed to accommodate more objects * (<i>unlike</i> @link //apple_ref/doc/uid/20001503 CFMutableSet@/link, * for which the initial capacity is a hard limit). * * The objects in <code>objects</code> are retained for storage in the new set, * not copied. */ static OSPtr<OSSet> withObjects( const OSObject * objects[], unsigned int count, unsigned int capacity = 0); /*! * @function withArray * * @abstract * Creates and initializes an OSSet * populated with the contents of an OSArray. * * @param array An array whose objects will be stored in the new OSSet. * @param capacity The initial storage capacity of the new set object. * If 0, the capacity is set to the number of objects * in <code>array</code>; * otherwise <code>capacity</code> must be greater than or equal to * the number of objects in <code>array</code>. * @result * An instance of OSSet containing * the objects of <code>array</code>, * with a retain count of 1; * <code>NULL</code> on failure. * * @discussion * Each distinct object in <code>array</code> is added to the new set. * * <code>array</code> must be non-<code>NULL</code>. * If <code>capacity</code> is nonzero, * it must be greater than or equal to <code>count</code>. * The new OSSet will grow as needed to accommodate more key-object pairs * (<i>unlike</i> @link //apple_ref/doc/uid/20001503 CFMutableSet@/link, * for which the initial capacity is a hard limit). * * The objects in <code>array</code> are retained for storage in the new set, * not copied. */ static OSPtr<OSSet> withArray( const OSArray * array, unsigned int capacity = 0); /*! * @function withSet * * @abstract * Creates and initializes an OSSet * populated with the contents of another OSSet. * * @param set An OSSet whose contents will be stored * in the new instance. * @param capacity The initial storage capacity of the set object. * If 0, the capacity is set to the number of objects * in <code>set</code>; * otherwise <code>capacity</code> must be greater than or equal to * the number of objects in <code>array</code>. * @result * An instance of OSArray * containing the objects of <code>set</code>, * with a retain count of 1; * <code>NULL</code> on failure. * * @discussion * <code>set</code> must be non-<code>NULL</code>. * If <code>capacity</code> is nonzero, * it must be greater than or equal to <code>count</code>. * The array will grow as needed to accommodate more key-object pairs * (<i>unlike</i> @link //apple_ref/doc/uid/20001503 CFMutableSet@/link, * for which the initial capacity is a hard limit). * * The objects in <code>set</code> are retained for storage in the new set, * not copied. */ static OSPtr<OSSet> withSet(const OSSet * set, unsigned int capacity = 0); /*! * @function initWithCapacity * * @abstract * Initializes a new instance of OSSet. * * @param capacity The initial storage capacity of the new set object. * * @result * <code>true</code> on success, <code>false</code> on failure. * * @discussion * Not for general use. Use the static instance creation method * <code>@link * //apple_ref/cpp/clm/OSSet/withCapacity/staticOSSet*\/(unsignedint) * withCapacity@/link</code> * instead. * * <code>capacity</code> must be nonzero. * The new set will grow as needed to accommodate more key/object pairs * (<i>unlike</i> @link //apple_ref/doc/uid/20001503 CFMutableSet@/link, * for which the initial capacity is a hard limit). */ virtual bool initWithCapacity(unsigned int capacity); /*! * @function initWithObjects * * @abstract * Initializes a new OSSet populated with objects provided. * * @param objects A C array of OSObject-derived objects. * @param count The number of objects to be placed into the set. * @param capacity The initial storage capacity of the new set object. * If 0, <code>count</code> is used; otherwise this value * must be greater than or equal to <code>count</code>. * * @result * <code>true</code> on success, <code>false</code> on failure. * * @discussion * Not for general use. Use the static instance creation method * <code>@link * //apple_ref/cpp/clm/OSSet/withObjects/staticOSSet*\/(constOSObject*,unsignedint,unsignedint) * withObjects@/link</code> * instead. * * <code>objects</code> must be non-<code>NULL</code>, * and <code>count</code> must be nonzero. * If <code>capacity</code> is nonzero, it must be greater than or equal to <code>count</code>. * The new array will grow as needed to accommodate more key-object pairs * (<i>unlike</i> @link //apple_ref/doc/uid/20001503 CFMutableSet@/link, * for which the initial capacity is a hard limit). * * The objects in <code>objects</code> are retained for storage in the new set, * not copied. */ virtual bool initWithObjects( const OSObject * objects[], unsigned int count, unsigned int capacity = 0); /*! * @function initWithArray * * @abstract Initializes a new OSSet * populated with the contents of an OSArray. * * @param array An OSAray whose contents will be placed * in the new instance. * @param capacity The initial storage capacity of the new set object. * If 0, the capacity is set * to the number of objects in <code>array</code>; * otherwise <code>capacity</code> must be greater than or equal to * the number of objects in <code>array</code>. * * @result * <code>true</code> on success, <code>false</code> on failure. * * @discussion * Not for general use. Use the static instance creation method * <code>@link * //apple_ref/cpp/clm/OSSet/withArray/staticOSSet*\/(constOSArray*,unsignedint) * withArray@/link</code> * instead. * * <code>array</code> must be non-<code>NULL</code>. * If <code>capacity</code> is nonzero, * it must be greater than or equal to <code>count</code>. * The new array will grow as needed to accommodate more key-object pairs * (<i>unlike</i> @link //apple_ref/doc/uid/20001503 CFMutableSet@/link, * for which the initial capacity is a hard limit). * * The objects in <code>array</code> are retained for storage in the new set, * not copied. */ virtual bool initWithArray( const OSArray * array, unsigned int capacity = 0); /*! * @function initWithSet * * @abstract * Initializes a new OSSet * populated with the contents of another OSSet. * * @param set A set whose contents will be placed in the new instance. * @param capacity The initial storage capacity of the new set object. * If 0, the capacity is set * to the number of objects in <code>set</code>; * otherwise <code>capacity</code> must be greater than or equal to * the number of objects in <code>set</code>. * * @result * <code>true</code> on success, <code>false</code> on failure. * * @discussion * Not for general use. Use the static instance creation method * <code>@link withSet withSet@/link</code> instead. * * <code>set</code> must be non-<code>NULL</code>. * If <code>capacity</code> is nonzero, * it must be greater than or equal to <code>count</code>. * The new set will grow as needed to accommodate more key-object pairs * (<i>unlike</i> @link //apple_ref/doc/uid/20001503 CFMutableSet@/link, * for which the initial capacity is a hard limit). * * The objects in <code>set</code> are retained for storage in the new set, * not copied. */ virtual bool initWithSet(const OSSet *set, unsigned int capacity = 0); /*! * @function free * * @abstract * Deallocates or releases any resources * used by the OSSet instance. * * @discussion * This function should not be called directly; * use * <code>@link * //apple_ref/cpp/instm/OSObject/release/virtualvoid/() * release@/link</code> * instead. */ virtual void free() APPLE_KEXT_OVERRIDE; /*! * @function getCount * * @abstract * Returns the current number of objects within the set. * * @result * The current number of objects within the set. */ virtual unsigned int getCount() const APPLE_KEXT_OVERRIDE; /*! * @function getCapacity * * @abstract * Returns the number of objects the set * can store without reallocating. * * @result * The number objects the set * can store without reallocating. * * @discussion * OSSet objects grow when full to accommodate additional objects. * See * <code>@link * //apple_ref/cpp/instm/OSSet/getCapacityIncrement/virtualunsignedint/() * getCapacityIncrement@/link</code> * and * <code>@link * //apple_ref/cpp/instm/OSSet/ensureCapacity/virtualunsignedint/(unsignedint) * ensureCapacity@/link</code>. */ virtual unsigned int getCapacity() const APPLE_KEXT_OVERRIDE; /*! * @function getCapacityIncrement * * @abstract * Returns the storage increment of the set. * * @result * The storage increment of the set. * * @discussion * An OSSet allocates storage for objects in multiples * of the capacity increment. */ virtual unsigned int getCapacityIncrement() const APPLE_KEXT_OVERRIDE; /*! * @function setCapacityIncrement * * @abstract * Sets the storage increment of the set. * * @result * The new storage increment of the set, * which may be different from the number requested. * * @discussion * An OSSet allocates storage for objects in multiples * of the capacity increment. * Calling this function does not immediately reallocate storage. */ virtual unsigned int setCapacityIncrement(unsigned increment) APPLE_KEXT_OVERRIDE; /*! * @function ensureCapacity * * @abstract * Ensures the set has enough space * to store the requested number of distinct objects. * * @param newCapacity The total number of distinct objects the set * should be able to store. * @result * The new capacity of the set, * which may be different from the number requested * (if smaller, reallocation of storage failed). * * @discussion * This function immediately resizes the set, if necessary, * to accommodate at least <code>newCapacity</code> distinct objects. * If <code>newCapacity</code> is not greater than the current capacity, * or if an allocation error occurs, the original capacity is returned. * * There is no way to reduce the capacity of an OSSet. */ virtual unsigned int ensureCapacity(unsigned int newCapacity) APPLE_KEXT_OVERRIDE; /*! * @function flushCollection * * @abstract * Removes and releases all objects within the set. * * @discussion * The set's capacity (and therefore direct memory consumption) * is not reduced by this function. */ virtual void flushCollection() APPLE_KEXT_OVERRIDE; /*! * @function setObject * * @abstract * Adds an object to the OSSet if it is not already present. * * @param anObject The OSMetaClassBase-derived object to be added to the set. * * @result * <code>true</code> if <code>anObject</code> was successfully * added to the set, <code>false</code> otherwise * (including if it was already in the set). * * @discussion * The set adds storage to accomodate the new object, if necessary. * If successfully added, the object is retained. * * A <code>false</code> return value can mean either * that <code>anObject</code> is already present in the set, * or that a memory allocation failure occurred. * If you need to know whether the object * is already present, use * <code>@link containsObject containsObject@/link</code>. */ virtual bool setObject(const OSMetaClassBase * anObject); bool setObject(OSSharedPtr<const OSMetaClassBase> const& anObject); /*! * @function merge * * @abstract * Adds the contents of an OSArray to the set. * * @param array The OSArray object containing the objects to be added. * * @result * <code>true</code> if all objects from <code>array</code> * are successfully added the receiver (or were already present), * <code>false</code> otherwise. * * @discussion * This functions adds to the receiving set * all objects from <code>array</code> * that are not already in the receiving set. * Objects added to the receiver are retained. * * In releases prior to 10.7, this function would return <code>false</code> * if an object from <code>array</code> was already present in the set, * or if <code>array</code> was empty. * This is no longer the case, so this function correctly returns <code>true</code> * when the semantic of merging is met. */ virtual bool merge(const OSArray * array); /*! * @function merge * * @abstract * Adds the contents of an OSet to the set. * * @param set The OSSet object containing the objects to be added. * * @result * <code>true</code> if any object from <code>set</code> * are successfully added the receiver (or were already present), * <code>false</code> otherwise. * * @discussion * This functions adds to the receiving set * all objects from <code>set</code> * that are not already in the receiving set. * Objects added to the receiver are retained. * * In releases prior to 10.7, this function would return <code>false</code> * if an object from <code>set</code> was already present in the set, * or if <code>set</code> was empty. * This is no longer the case, so this function correctly returns <code>true</code> * when the semantic of merging is met. */ virtual bool merge(const OSSet * set); /*! * @function removeObject * * @abstract * Removes an object from the set. * * @param anObject The OSMetaClassBase-derived object * to be removed from the set. * * @discussion * The object removed from the set is released. */ virtual void removeObject(const OSMetaClassBase * anObject); void removeObject(OSSharedPtr<const OSMetaClassBase> const& anObject); /*! * @function containsObject * * @abstract * Checks the set for the presence of an object. * * @param anObject The OSMetaClassBase-derived object * to check for in the set. * * @result * <code>true</code> if <code>anObject</code> is present within the set, * <code>false</code> otherwise. * * @discussion * Pointer equality is used. * This function returns <code>false</code> if passed <code>NULL</code>. */ virtual bool containsObject(const OSMetaClassBase * anObject) const; /*! * @function member * * @abstract * Checks the set for the presence of an object. * * @param anObject The OSMetaClassBase-derived object * to check for in the set. * * @result * <code>true</code> if <code>anObject</code> is present * within the set, <code>false</code> otherwise. * * @discussion * Pointer equality is used. This function returns <code>false</code> * if passed <code>NULL</code>. * * <code>@link containsObject containsObject@/link</code> * checks for <code>NULL</code> first, * and is therefore more efficient than this function. */ virtual bool member(const OSMetaClassBase * anObject) const; /*! * @function getAnyObject * * @abstract * Returns an arbitrary (not random) object from the set. * * @result * An arbitrary (not random) object * if one exists within the set. * * @discussion * The returned object will be released if removed from the set; * if you plan to store the reference, you should call * <code>@link * //apple_ref/cpp/instm/OSObject/retain/virtualvoid/() * retain@/link</code> * on that object. */ virtual OSObject * getAnyObject() const; /*! * @function isEqualTo * * @abstract * Tests the equality of two OSSet objects. * * @param aSet The set object being compared against the receiver. * @result * <code>true</code> if the two sets are equivalent, * <code>false</code> otherwise. * * @discussion * Two OSSet objects are considered equal if they have same count * and the same object pointer values. */ virtual bool isEqualTo(const OSSet * aSet) const; /*! * @function isEqualTo * * @abstract * Tests the equality of an OSSet against an arbitrary object. * * @param anObject The object being compared against the receiver. * @result * <code>true</code> if the two objects are equivalent, * <code>false</code> otherwise. * * @discussion * An OSSet object is considered equal to another object if the other object * is derived from OSSet and compares equal as a set. */ virtual bool isEqualTo(const OSMetaClassBase * anObject) const APPLE_KEXT_OVERRIDE; /*! * @function serialize * * @abstract * Archives the receiver into the provided * @link //apple_ref/doc/class/OSSerialize OSSerialize@/link object. * * @param serializer The OSSerialize object. * * @result * <code>true</code> if serialization succeeds, <code>false</code> if not. */ virtual bool serialize(OSSerialize * serializer) const APPLE_KEXT_OVERRIDE; /*! * @function setOptions * * @abstract * Recursively sets option bits in the set * and all child collections. * * @param options A bitfield whose values turn the options on (1) or off (0). * @param mask A mask indicating which bits * in <code>options</code> to change. * Pass 0 to get the whole current options bitfield * without changing any settings. * @param context Unused. * * @result * The options bitfield as it was before the set operation. * * @discussion * Kernel extensions should not call this function. * * Child collections' options are changed only if the receiving set's * options actually change. */ virtual unsigned setOptions(unsigned options, unsigned mask, void * context = NULL) APPLE_KEXT_OVERRIDE; /*! * @function copyCollection * * @abstract * Creates a deep copy of this set and its child collections. * * @param cycleDict A dictionary of all of the collections * that have been copied so far, * which is used to track circular references. * To start the copy at the top level, * pass <code>NULL</code>. * * @result * The newly copied set, with a retain count of 1, * or <code>NULL</code> if there is insufficient memory to do the copy. * * @discussion * The receiving set, and any collections it contains, * recursively, are copied. * Objects that are not derived from OSCollection are retained * rather than copied. */ OSPtr<OSCollection> copyCollection(OSDictionary *cycleDict = NULL) APPLE_KEXT_OVERRIDE; OSMetaClassDeclareReservedUnused(OSSet, 0); OSMetaClassDeclareReservedUnused(OSSet, 1); OSMetaClassDeclareReservedUnused(OSSet, 2); OSMetaClassDeclareReservedUnused(OSSet, 3); OSMetaClassDeclareReservedUnused(OSSet, 4); OSMetaClassDeclareReservedUnused(OSSet, 5); OSMetaClassDeclareReservedUnused(OSSet, 6); OSMetaClassDeclareReservedUnused(OSSet, 7); }; #endif /* !_OS_OSSET_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSArray.h
/* * Copyright (c) 2019 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@ */ /* IOArray.h created by rsulack on Thu 11-Sep-1997 */ /* IOArray.h converted to C++ by gvdl on Fri 1998-10-30 */ #ifndef _OS_OSARRAY_H #define _OS_OSARRAY_H #include <libkern/c++/OSCollection.h> #include <libkern/c++/OSPtr.h> #include <os/base.h> class OSSerialize; class OSArray; typedef OSArray* OSArrayPtr; /*! * @header * * @abstract * This header declares the OSArray collection class. */ /*! * @class OSArray * * @abstract * OSArray provides an indexed store of objects. * * @discussion * OSArray is a container for Libkern C++ objects * (those derived from * @link //apple_ref/doc/class/OSMetaClassBase OSMetaClassBase@/link, * in particular * @link //apple_ref/doc/class/OSObject OSObject@/link). * Storage and access are by array index. * * You must generally cast retrieved objects from * @link //apple_ref/cpp/cl/OSObject OSObject@/link * to the desired class using * <code>@link //apple_ref/cpp/macro/OSDynamicCast OSDynamicCast@/link</code>. * This macro returns the object cast to the desired class, * or <code>NULL</code> if the object isn't derived from that class. * * As with all Libkern collection classes, * OSArray retains objects added to it, * and releases objects removed from it (or replaced). * An OSArray also grows as necessary to accommodate new objects, * <i>unlike</i> Core Foundation collections (it does not, however, shrink). * * <b>Use Restrictions</b> * * With very few exceptions in the I/O Kit, all Libkern-based C++ * classes, functions, and macros are <b>unsafe</b> * to use in a primary interrupt context. * Consult the I/O Kit documentation related to primary interrupts * for more information. * * OSArray provides no concurrency protection; * it's up to the usage context to provide any protection necessary. * Some portions of the I/O Kit, such as * @link //apple_ref/doc/class/IORegistryEntry IORegistryEntry@/link, * handle synchronization via defined member functions for setting * properties. */ class OSArray : public OSCollection { friend class OSSet; friend class OSSerialize; OSDeclareDefaultStructors(OSArray); typedef OSTaggedPtr<const OSMetaClassBase> ArrayPtrType; typedef OSTaggedSharedPtr<const OSMetaClassBase, OSCollection> ArraySharedPtrType; #if APPLE_KEXT_ALIGN_CONTAINERS protected: unsigned int count; unsigned int capacity; unsigned int capacityIncrement; ArrayPtrType * OS_PTRAUTH_SIGNED_PTR("OSArray.array") array; #else /* APPLE_KEXT_ALIGN_CONTAINERS */ protected: ArrayPtrType * OS_PTRAUTH_SIGNED_PTR("OSArray.array") array; unsigned int count; unsigned int capacity; unsigned int capacityIncrement; struct ExpansionData { }; /* Reserved for future use. (Internal use only) */ ExpansionData * reserved; #endif /* APPLE_KEXT_ALIGN_CONTAINERS */ /* OSCollectionIterator interfaces. */ virtual unsigned int iteratorSize() const APPLE_KEXT_OVERRIDE; virtual bool initIterator(void * iterator) const APPLE_KEXT_OVERRIDE; virtual bool getNextObjectForIterator(void * iterator, OSObject ** ret) const APPLE_KEXT_OVERRIDE; public: /*! * @function withCapacity * * @abstract * Creates and initializes an empty OSArray. * * @param capacity The initial storage capacity of the array object. * * @result * An empty instance of OSArray with a retain count of 1; * <code>NULL</code> on failure. * * @discussion * <code>capacity</code> must be nonzero. * The new array will grow as needed to accommodate more objects * (<i>unlike</i> @link //apple_ref/doc/uid/20001502 CFMutableArray@/link, * for which the initial capacity is a hard limit). */ static OSPtr<OSArray> withCapacity(unsigned int capacity); /*! * @function withObjects * * @abstract * Creates and initializes an OSArray populated with objects provided. * * @param objects A C array of OSObject-derived instances. * @param count The number of objects to be placed into the array. * @param capacity The initial storage capacity of the array object. * If 0, <code>count</code> is used; otherwise this value * must be greater than or equal to <code>count</code>. * * @result * An instance of OSArray containing the objects provided, * with a retain count of 1; * <code>NULL</code> on failure. * * @discussion * <code>objects</code> must be non-<code>NULL</code>, and <code>count</code> must be nonzero. * If <code>capacity</code> is nonzero, * it must be greater than or equal to <code>count</code>. * The new array will grow as needed to accommodate more objects * (<i>unlike</i> @link //apple_ref/doc/uid/20001502 CFMutableArray@/link, * for which the initial capacity is a hard limit). */ static OSPtr<OSArray> withObjects( const OSObject * objects[], unsigned int count, unsigned int capacity = 0); /*! * @function withArray * * @abstract * Creates and initializes an OSArray populated with the contents of another array. * * @param array An OSArray whose contents will be stored * in the new instance. * @param capacity The initial storage capacity of the array object. * If 0, the capacity is set to the number of objects * in <code>array</code>; * otherwise <code>capacity</code> must be * greater than or equal to the number of objects * in <code>array</code>. * * @result * An instance of OSArray containing the objects of <code>array</code>, * with a retain count of 1; * <code>NULL</code> on failure. * * @discussion * <code>array</code> must be non-<code>NULL</code>. * If <code>capacity</code> is nonzero, * it must be greater than or equal to <code>count</code>. * The new array will grow as needed to accommodate more objects * (<i>unlike</i> @link //apple_ref/doc/uid/20001502 CFMutableArray@/link, * for which the initial capacity is a hard limit). * * The objects in <code>array</code> are retained * for storage in the new OSArray, * not copied. */ static OSPtr<OSArray> withArray( const OSArray * array, unsigned int capacity = 0); /*! * @function initWithCapacity * * @abstract * Initializes a new instance of OSArray. * * @param capacity The initial storage capacity of the array object. * * @result * <code>true</code> on success, <code>false</code> on failure. * * @discussion * Not for general use. Use the static instance creation method * <code>@link //apple_ref/cpp/clm/OSArray/withCapacity/staticOSArray*\/(unsignedint) * withCapacity@/link</code> * instead. * * <code>capacity</code> must be nonzero. * The new array will grow as needed to accommodate more objects * (<i>unlike</i> @link //apple_ref/doc/uid/20001502 CFMutableArray@/link, * for which the initial capacity is a hard limit). */ virtual bool initWithCapacity(unsigned int capacity); /*! * @function initWithObjects * * @abstract * Initializes a new OSArray populated with objects provided. * * @param objects A C array of OSObject-derived objects. * @param count The number of objects to be placed into the array. * @param capacity The initial storage capacity of the array object. * If 0, <code>count</code> is used; otherwise this value * must be greater than or equal to <code>count</code>. * * @result * <code>true</code> on success, <code>false</code> on failure. * * @discussion * Not for general use. Use the static instance creation method * <code>@link * //apple_ref/cpp/clm/OSArray/withObjects/staticOSArray*\/(constOSObject*,unsignedint,unsignedint) * withObjects@/link</code> * instead. * * <code>objects</code> must be non-<code>NULL</code>, * and <code>count</code> must be nonzero. * If <code>capacity</code> is nonzero, * it must be greater than or equal to <code>count</code>. * The new array will grow as needed to accommodate more objects * (<i>unlike</i> @link //apple_ref/doc/uid/20001502 CFMutableArray@/link, * for which the initial capacity is a hard limit). */ virtual bool initWithObjects( const OSObject * objects[], unsigned int count, unsigned int capacity = 0); /*! * @function initWithArray * * @abstract * Initializes a new OSArray populated with the contents of another array. * * @param anArray The array whose contents will be placed * in the new instance. * @param capacity The initial storage capacity of the array object. * If 0, the capacity is set to the number of objects * in <code>array</code>; * otherwise <code>capacity</code> must be * greater than or equal to the number of objects * in <code>array</code>. * * @result * <code>true</code> on success, <code>false</code> on failure. * * @discussion * Not for general use. Use the static instance creation method * <code>@link //apple_ref/cpp/clm/OSArray/withArray/staticOSArray*\/(constOSArray*,unsignedint) * withArray@/link</code> instead. * * <code>array</code> must be non-<code>NULL</code>. * If <code>capacity</code> is nonzero, * it must be greater than or equal to <code>count</code>. * The new array will grow as needed to accommodate more objects * (<i>unlike</i> @link //apple_ref/doc/uid/20001502 CFMutableArray@/link, * for which the initial capacity is a hard limit). * * The objects in <code>array</code> are retained for storage in the new OSArray, * not copied. */ virtual bool initWithArray( const OSArray * anArray, unsigned int capacity = 0); /*! * @function free * * @abstract * Deallocates or releases any resources * used by the OSArray instance. * * @discussion * This function should not be called directly; * use * <code>@link * //apple_ref/cpp/instm/OSObject/release/virtualvoid/() * release@/link</code> * instead. */ virtual void free() APPLE_KEXT_OVERRIDE; /*! * @function getCount * * @abstract * Returns the current number of objects within the array. * * @result * The current number of objects within the array. */ virtual unsigned int getCount() const APPLE_KEXT_OVERRIDE; /*! * @function getCapacity * * @abstract * Returns the number of objects the array can store * without reallocating. * * @result * The number objects the array can store * without reallocating. * * @discussion * OSArray objects grow when full to accommodate additional objects. * See * <code>@link * //apple_ref/cpp/instm/OSArray/getCapacity/virtualunsignedint/() * getCapacityIncrement@/link</code> * and * @link * //apple_ref/cpp/instm/OSArray/ensureCapacity/virtualunsignedint/(unsignedint) * <code>ensureCapacity</code>.@/link */ virtual unsigned int getCapacity() const APPLE_KEXT_OVERRIDE; /*! * @function getCapacityIncrement * * @abstract * Returns the storage increment of the array. * * @result * The storage increment of the array. * * @discussion * An OSArray allocates storage for objects in multiples * of the capacity increment. */ virtual unsigned int getCapacityIncrement() const APPLE_KEXT_OVERRIDE; /*! * @function setCapacityIncrement * * @abstract * Sets the storage increment of the array. * * @result * The new storage increment of the array, * which may be different from the number requested. * * @discussion * An OSArray allocates storage for objects in multiples * of the capacity increment. * Calling this function does not immediately reallocate storage. */ virtual unsigned int setCapacityIncrement(unsigned increment) APPLE_KEXT_OVERRIDE; /*! * @function ensureCapacity * * @abstract * Ensures the array has enough space * to store the requested number of objects. * * @param newCapacity The total number of objects the array * should be able to store. * * @result * The new capacity of the array, * which may be different from the number requested * (if smaller, reallocation of storage failed). * * @discussion * This function immediately resizes the array, if necessary, * to accommodate at least <code>newCapacity</code> objects. * If <code>newCapacity</code> is not greater than the current capacity, * or if an allocation error occurs, the original capacity is returned. * * There is no way to reduce the capacity of an OSArray. */ virtual unsigned int ensureCapacity(unsigned int newCapacity) APPLE_KEXT_OVERRIDE; /*! * @function flushCollection * * @abstract * Removes and releases all objects within the array. * * @discussion * The array's capacity (and therefore direct memory consumption) * is not reduced by this function. */ virtual void flushCollection() APPLE_KEXT_OVERRIDE; /*! * @function setObject * * @abstract * Appends an object onto the end of the array, * increasing storage if necessary. * * @param anObject The object to add to the OSArray instance. * * @result * <code>true</code> if the addition of <code>anObject</code> was successful, * <code>false</code> if not. * * @discussion * The array adds storage to accomodate the new object, if necessary. * If successfully added, the object is retained. */ virtual bool setObject(const OSMetaClassBase * anObject); bool setObject(OSSharedPtr<const OSMetaClassBase> const& anObject); /*! * @function setObject * * @abstract * Inserts or appends an object into the array * at a particular index. * * @param index The index in the array at which to insert the object. * Must be less than or equal to the array's count. * @param anObject The object to add to the array. * * @result * <code>true</code> if the addition of <code>anObject</code> * was successful, <code>false</code> if not. * * @discussion * This function moves existing objects from <code>index</code> on, * in order to accommodate the new object; * it does not replace an existing object at <code>index</code>. See * <code>@link * //apple_ref/cpp/instm/OSArray/replaceObject/virtualvoid/(unsignedint,constOSMetaClassBase*) * replaceObject@/link</code>. * If successfully added, the object is retained. * * The array adds storage to accomodate the new object, if necessary. * Note, however, that this function does not allow for arbirtrary growth * of an array by specifying an index larger than the current count. * If you need to immediately grow an array by an arbitrary amount, * use * <code>@link * //apple_ref/cpp/instm/OSArray/ensureCapacity/virtualunsignedint/(unsignedint) * ensureCapacity@/link</code>. */ virtual bool setObject( unsigned int index, const OSMetaClassBase * anObject); bool setObject( unsigned int index, OSSharedPtr<const OSMetaClassBase> const& anObject); /*! * @function merge * * @abstract * Appends the contents of an array onto the receiving array. * * @param otherArray The array whose contents will be appended * to the receiving array. * @result * <code>true</code> if merging was successful, <code>false</code> otherwise. * * @discussion * This function merely appends one array onto another. * Duplicates are not avoided and no sorting is performed. * Objects successfully added to the receiver are retained. */ virtual bool merge(const OSArray * otherArray); /*! * @function replaceObject * * @abstract * Replaces an object in an array at a given index. * * @param index The index of the object to be replaced. * Must be less than the array's count. * @param anObject The object to be placed into the array. * * @discussion * The original object is released and the new object is retained. */ virtual void replaceObject( unsigned int index, const OSMetaClassBase * anObject); void replaceObject( unsigned int index, OSSharedPtr<const OSMetaClassBase> const& anObject); /*! * @function removeObject * * @abstract * Removes an object from the array. * * @param index The index of the object to be removed. * * @discussion * This function moves existing objects to fill the vacated index * so that there are no gaps. * The object removed is released. */ virtual void removeObject(unsigned int index); /*! * @function isEqualTo * * @abstract * Tests the equality of two OSArray objects. * * @param anArray The array object being compared against the receiver. * * @result * <code>true</code> if the two arrays are equivalent, *<code>false</code> otherwise. * * @discussion * Two OSArray objects are considered equal if they have same count * and if the objects at corresponding indices compare as equal using * <code>@link * //apple_ref/cpp/instm/OSMetaClassBase/isEqualTo/virtualbool/(constOSMetaClassBase*) * isEqualTo@/link</code>. */ virtual bool isEqualTo(const OSArray * anArray) const; /*! * @function isEqualTo * * @abstract * Tests the equality of an OSArray to an arbitrary object. * * @param anObject The object to be compared against the receiver. * * @result * <code>true</code> if the two objects are equivalent, * <code>false</code> otherwise. * * @discussion * An OSArray is considered equal to another object * if that object is derived from OSArray * and contains the same or equivalent objects. */ virtual bool isEqualTo(const OSMetaClassBase * anObject) const APPLE_KEXT_OVERRIDE; /*! * @function getObject * * @abstract * Return the object stored at a given index. * * @param index The index of the object to be returned to caller. * * @result * The object stored at <code>index</code>, * or <code>NULL</code> if <code>index</code> lies past the end of the array. * * @discussion * The returned object will be released if removed from the array; * if you plan to store the reference, you should call * <code>@link * //apple_ref/cpp/instm/OSObject/retain/virtualvoid/() * retain@/link</code> * on that object. */ virtual OSObject * getObject(unsigned int index) const; /*! * @function getLastObject * * @abstract * Returns the last object in the array. * * @result * The last object in the array, * or <code>NULL</code> if the array is empty. * * @discussion * The returned object will be released if removed from the array; * if you plan to store the reference, you should call * <code>@link * //apple_ref/cpp/instm/OSObject/retain/virtualvoid/() * retain@/link</code> * on that object. */ virtual OSObject * getLastObject() const; /*! * @function getNextIndexOfObject * * @abstract * Scans the array for the next instance of a specific object * at or beyond a given index. * * @param anObject The object to scan for. * @param index The index at which to begin the scan. * * @result * The next index of <code>anObject</code> in the array or (-1) * if none is found. * * @discussion * This function uses pointer equivalence, and does not use * <code>@link * //apple_ref/cpp/instm/OSMetaClassBase/isEqualTo/virtualbool/(constOSMetaClassBase*) * isEqualTo@/link</code>. */ virtual unsigned int getNextIndexOfObject( const OSMetaClassBase * anObject, unsigned int index) const; /*! * @function serialize * * @abstract * Archives the receiver into the provided * @link //apple_ref/doc/class/OSSerialize OSSerialize@/link object. * * @param serializer The OSSerialize object. * @result * <code>true</code> if serialization succeeds, <code>false</code> if not. */ virtual bool serialize(OSSerialize * serializer) const APPLE_KEXT_OVERRIDE; /*! * @function setOptions * * @abstract * Recursively sets option bits in an array * and all child collections. * * @param options A bitfield whose values turn the options on (1) or off (0). * @param mask A mask indicating which bits * in <code>options</code> to change. * Pass 0 to get the whole current options bitfield * without changing any settings. * @param context Unused. * * @result * The options bitfield as it was before the set operation. * * @discussion * Kernel extensions should not call this function. * * Child collections' options are changed only if the receiving array's * options actually change. */ virtual unsigned setOptions( unsigned options, unsigned mask, void * context = NULL) APPLE_KEXT_OVERRIDE; /*! * @function copyCollection * * @abstract * Creates a deep copy of an array and its child collections. * * @param cycleDict A dictionary of all of the collections * that have been copied so far, * which is used to track circular references. * To start the copy at the top level, * pass <code>NULL</code>. * * @result * The newly copied array, with a retain count of 1, * or <code>NULL</code> if there is insufficient memory to do the copy. * * @discussion * The receiving array, and any collections it contains, * recursively, are copied. * Objects that are not derived from OSCollection are retained * rather than copied. */ OSPtr<OSCollection> copyCollection(OSDictionary * cycleDict = NULL) APPLE_KEXT_OVERRIDE; OSMetaClassDeclareReservedUnused(OSArray, 0); OSMetaClassDeclareReservedUnused(OSArray, 1); OSMetaClassDeclareReservedUnused(OSArray, 2); OSMetaClassDeclareReservedUnused(OSArray, 3); OSMetaClassDeclareReservedUnused(OSArray, 4); OSMetaClassDeclareReservedUnused(OSArray, 5); OSMetaClassDeclareReservedUnused(OSArray, 6); OSMetaClassDeclareReservedUnused(OSArray, 7); }; #endif /* !_OS_OSARRAY_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/safe_allocation.h
// // Copyright (c) 2019-2021 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 XNU_LIBKERN_LIBKERN_CXX_SAFE_ALLOCATION_H #define XNU_LIBKERN_LIBKERN_CXX_SAFE_ALLOCATION_H #if !TAPI #include <stddef.h> #include <stdint.h> #include <os/base.h> #if DRIVERKIT_FRAMEWORK_INCLUDE #include <DriverKit/bounded_ptr.h> #else #include <libkern/c++/bounded_ptr.h> #endif /* DRIVERKIT_FRAMEWORK_INCLUDE */ void* operator new(size_t, void*) noexcept; // forward declaration needed for placement-new namespace libkern { namespace sa_detail { // TODO: Deduplicate these utilities with other smart pointer utilities using nullptr_t = decltype(nullptr); template <typename T> constexpr bool is_trivially_destructible_v = __is_trivially_destructible(T); template <typename T> constexpr bool is_empty_v = __is_empty(T); template <typename T> constexpr bool is_nothrow_default_constructible_v = __is_nothrow_constructible(T); template <bool Cond, typename T = void> struct enable_if; template <typename T> struct enable_if<true, T> { using type = T; }; template <bool Cond, typename T = void> using enable_if_t = typename enable_if<Cond, T>::type; template <typename T> struct remove_const { using type = T; }; template <typename T> struct remove_const<T const> { using type = T; }; template <typename T> using remove_const_t = typename remove_const<T>::type; template <typename T> void generic_swap(T& a, T& b) { T tmp = a; a = b; b = tmp; } template <typename T, enable_if_t<!is_trivially_destructible_v<T> >* = nullptr> void destroy(T* first, T* last) { for (; first != last; ++first) { first->~T(); } } template <typename T, enable_if_t<is_trivially_destructible_v<T> >* = nullptr> void destroy(T*, T*) { // Nothing to do, the elements are trivially destructible } template <typename T> void uninitialized_value_construct(T* first, T* last) { for (; first != last; ++first) { ::new (static_cast<void*>(first)) T(); } } } // end namespace sa_detail struct adopt_memory_t { explicit constexpr adopt_memory_t() = default; }; inline constexpr adopt_memory_t adopt_memory{}; struct allocate_memory_t { explicit constexpr allocate_memory_t() = default; }; inline constexpr allocate_memory_t allocate_memory{}; struct allocate_memory_zero_t { explicit constexpr allocate_memory_zero_t() = default; }; inline constexpr allocate_memory_zero_t allocate_memory_zero{}; // Lightweight utility class representing a dynamically allocated slab of // memory, with contiguous objects in it. // // The main purpose `safe_allocation` is to: // 1. Manage a uniquely-owned allocation of memory containing multiple objects // 2. Check that the allocation is accessed within its bounds on indexing operations // 3. Act as a source for obtaining (non-owning) `bounded_ptr`s to the underlying memory // // In fact, `safe_allocation` should be the primary source of `bounded_ptr`s to // heap-allocated memory, via its `.begin()` and `.end()` methods. `safe_allocation` // is optimized for use cases where simple scratch space is needed for calculation // and deallocated once the calculation is done. As such, it is not a full-blown // container class, which drives many design choices behind `safe_allocation`: // // 1. It can't be copied or compared for equality -- `safe_allocation` is not a proper value type // 2. It can't be resized -- this keeps the design extremely simple and free of overhead // 3. You can transfer ownership of `safe_allocation` by using std::move // // Design decision: stateless allocators // ===================================== // Only allow stateless allocators. While we could technically handle stateful // allocators (as the C++ Standard Library) does, the benefit of doing so // compared to the added complexity is absolutely not worth it. Supporting // stateful allocators everywhere in C++ is regarded (at least in the // Standardization Committee) as one of the worst design mistakes we've made, // and so we won't repeat it here. // // Design decision: size() is 0 when allocation is null // ==================================================== // When the `safe_allocation` is null (because it's been moved-from, or because // allocation failed, or whatever), we could technically leave the `size_` // undefined (as long as we make `data_` null). However, this would mean // that querying the size of the allocation in that case is undefined behavior // (UB), which is seen as something bad in the context of a type that vends // itself as safe. So instead, we "overimplement" the type to provide stronger // guarantees than would be strictly required if performance were the main goal. template <typename T, typename Allocator, typename TrappingPolicy> struct safe_allocation { static_assert(sa_detail::is_empty_v<Allocator>, "safe_allocation<T, Alloc, ...> requires the Allocator to be stateless"); // Create a null allocation, pointing to no memory. // // A null allocation can be destroyed, assigned-to, checked for nullness, // and otherwise queries for length, but trying to access an element of // the allocation will fail. // // A null allocation basically behaves as an empty array, i.e. `begin()` // and `end()` will return iterators that are equal and `size()` will // return `0`. explicit constexpr safe_allocation() noexcept : data_(nullptr), size_(0) { } constexpr safe_allocation(sa_detail::nullptr_t) noexcept : safe_allocation() { } // Create an allocation pointing to already-allocated and initialized memory. // // This constructor attaches existing memory to a `safe_allocation`, such // that it will be released automatically when the `safe_allocation` goes // out of scope. The objects in that memory must already have been // initialized, or they must be initialized before the `safe_allocation` // goes out of scope. // // The `n` argument is the number of objects of type `T` in the allocation, // i.e. `n * sizeof(T)` bytes should have been allocated. // // Note that the memory MUST have been allocated with an allocator compatible // with the `safe_allocation`'s `Allocator`, since the memory will be // deallocated using that `Allocator`. Bad things will happen if, for // example, `adopt_memory` is used with memory allocated on the stack: // the destructor will try to deallocate that memory and will fail to do so. explicit safe_allocation(T* data, size_t n, adopt_memory_t) : data_(data) { if (__improbable(n > UINT32_MAX)) { TrappingPolicy::trap("safe_allocation size exceeds UINT32_MAX"); } size_ = static_cast<uint32_t>(n); } // Allocate memory for `n` objects of type `T`, and manage it. // // This constructor allocates enough memory for `n` objects of type `T` // using the `Allocator`, and manages that. Each object in the allocation // is value-initialized (either set to 0 or the default-constructor called). // // If either `n * sizeof(T)` overflows or the allocation fails, the // resulting `safe_allocation` will be null. It is therefore necessary // to check whether the allocation is null after using this constructor. explicit safe_allocation(size_t n, allocate_memory_t) { size_t bytes; if (__improbable(os_mul_overflow(n, sizeof(T), &bytes) || (n > UINT32_MAX))) { data_ = nullptr; size_ = 0; } else { data_ = reinterpret_cast<T*>(Allocator::allocate(bytes)); size_ = static_cast<uint32_t>(n); using RawT = sa_detail::remove_const_t<T>; RawT* const data = const_cast<RawT*>(data_); sa_detail::uninitialized_value_construct(data, data + size_); } } // same as allocate_memory_t variant but allocated data is zero-initialized explicit safe_allocation(size_t n, allocate_memory_zero_t) { static_assert(__is_scalar(T) || __is_aggregate(T), "Creating objects via zero-allocation requires those objects to be scalars or aggregates (more broadly implicit lifetime types)"); size_t bytes; if (__improbable(os_mul_overflow(n, sizeof(T), &bytes) || (n > UINT32_MAX))) { data_ = nullptr; size_ = 0; } else { data_ = reinterpret_cast<T*>(Allocator::allocate_zero(bytes)); size_ = static_cast<uint32_t>(n); } } // A `safe_allocation` can't be copied, because it is not a proper value // type and it doesn't assume that the elements of the allocation can be // copied. safe_allocation(safe_allocation const&) = delete; safe_allocation& operator=(safe_allocation const&) = delete; // Moves the ownership of an allocation from one `safe_allocation` to // another one. // // After this operation, the moved-from `safe_allocation` is null, and // any iterator into the moved-from `safe_allocation` are now tied to // the `safe_allocation` that's the target of the assignment, in the // sense that the iterators will be invalidated when the target of the // assignment goes out of scope, not when the moved-from allocation // goes out of scope. safe_allocation(safe_allocation&& other) noexcept : data_(other.data_), size_(other.size_) { other.data_ = nullptr; other.size_ = 0; } // Clears a `safe_allocation`, making it a null allocation. // // If the `safe_allocation` was pointing to valid memory, the objects // in that memory are destroyed and that memory is freed. safe_allocation& operator=(sa_detail::nullptr_t) { if (data_ != nullptr) { destroy_dealloc_(data_, size_); } data_ = nullptr; size_ = 0; return *this; } // Moves the ownership of an allocation from one `safe_allocation` to // another one. // // After this operation, the moved-from `safe_allocation` is null, and // any iterator to the moved-from `safe_allocation` obtained before the // move operation are invalidated. // // If the destination `safe_allocation` was pointing to memory before the // move-assignment, the objects in that memory are destroyed and the // memory itself is freed. // // In case of self-move-assignment, nothing is done. safe_allocation& operator=(safe_allocation&& other) { if (&other == this) { return *this; } T* old_data = data_; size_t old_size = size_; data_ = other.data_; size_ = other.size_; other.data_ = nullptr; other.size_ = 0; if (old_data != nullptr) { destroy_dealloc_(old_data, old_size); } return *this; } // Destroys a `safe_allocation`, destroying the objects in it and // deallocating the underlying memory with the `Allocator`. // // If the `safe_allocation` is null, this destructor does nothing. ~safe_allocation() { if (data_ != nullptr) { destroy_dealloc_(data_, size_); } } // Returns whether a `safe_allocation` is non-null, i.e. whether it is // pointing to some memory. explicit operator bool() const noexcept { return data_ != nullptr; } using iterator = bounded_ptr<T, TrappingPolicy>; using const_iterator = bounded_ptr<T const, TrappingPolicy>; // The following methods allow obtaining iterators (i.e. cursors) to // objects inside a `safe_allocation`. // // The iterators of a `safe_allocation` are `bounded_ptr`s, which know // the bounds of the allocation and will trap when dereferenced outside // of those bounds. // // `begin()` returns a (const) iterator to the first element in the // allocation, and `end()` returns a (const) iterator to one-past-the-last // element in the allocation. The `end()` iterator can't be dereferenced, // since it is out of bounds. // // If the allocation is null, these methods will return null `bounded_ptr`s, // which can be checked for equality but can't be dereferenced. OS_ALWAYS_INLINE iterator begin() noexcept { if (data_ == nullptr) { return iterator(); } else { return iterator(data_, data_, data_ + size_); } } OS_ALWAYS_INLINE const_iterator begin() const noexcept { if (data_ == nullptr) { return const_iterator(); } else { return const_iterator(data_, data_, data_ + size_); } } iterator end() noexcept { if (data_ == nullptr) { return iterator(); } else { return iterator(data_ + size_, data_, data_ + size_); } } const_iterator end() const noexcept { if (data_ == nullptr) { return const_iterator(); } else { return const_iterator(data_ + size_, data_, data_ + size_); } } // Returns the number of objects in the allocation. // // This method returns `0` if the allocation is null, since such an // allocation behaves the same as an empty range. size_t size() const { return size_; } // Returns a non-owning pointer to the underlying memory managed by a // `safe_allocation`. // // This method can be called even if the `safe_allocation` is null, in // which case the returned pointer will be null. T* data() noexcept { return data_; } T const* data() const noexcept { return data_; } // Access the n-th element of an allocation. // // If `n` is out of the bounds of the allocation, this operation will // trap. If the allocation is null, this operation will trap too. // // Design note: // We voluntarily use a signed type to represent the index even though a // negative index will always cause a trap. If we used an unsigned type, // we could get an implicit conversion from signed to unsigned, which // could silently wrap around. We think trapping early is more likely // to be helpful in this situation. OS_ALWAYS_INLINE T& operator[](ptrdiff_t n) { return begin()[n]; // trap happens in `bounded_ptr` if null or OOB } OS_ALWAYS_INLINE T const& operator[](ptrdiff_t n) const { return begin()[n]; // trap happens in `bounded_ptr` if null or OOB } private: // Swap support friend void swap(safe_allocation& a, safe_allocation& b) noexcept { sa_detail::generic_swap(a.data_, b.data_); sa_detail::generic_swap(a.size_, b.size_); } static void destroy_dealloc_(T* ptr, size_t size) { sa_detail::destroy(ptr, ptr + size); // `size * sizeof(T)` can't overflow, because it would have // overflowed when the allocation was performed otherwise. using RawT = sa_detail::remove_const_t<T>; Allocator::deallocate(const_cast<RawT*>(ptr), size * sizeof(T)); } T* data_; uint32_t size_; }; // The comparison functions against `nullptr` all return whether the allocation // is null or not. template <typename T, typename A, typename P> bool operator==(safe_allocation<T, A, P> const& x, sa_detail::nullptr_t) { return !static_cast<bool>(x); } template <typename T, typename A, typename P> bool operator!=(safe_allocation<T, A, P> const& x, sa_detail::nullptr_t) { return !(x == nullptr); } template <typename T, typename A, typename P> bool operator==(sa_detail::nullptr_t, safe_allocation<T, A, P> const& x) { return x == nullptr; } template <typename T, typename A, typename P> bool operator!=(sa_detail::nullptr_t, safe_allocation<T, A, P> const& x) { return !(x == nullptr); } } // end namespace libkern #endif /* !TAPI */ #endif // !XNU_LIBKERN_LIBKERN_CXX_SAFE_ALLOCATION_H
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSAllocation.h
/* * Copyright (c) 2019-2021 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 XNU_LIBKERN_LIBKERN_CXX_OS_ALLOCATION_H #define XNU_LIBKERN_LIBKERN_CXX_OS_ALLOCATION_H #if !TAPI #include <stddef.h> #if DRIVERKIT_FRAMEWORK_INCLUDE #include <DriverKit/OSBoundedPtr.h> #include <DriverKit/safe_allocation.h> #include <DriverKit/IOLib.h> // IOMalloc/IOFree #else #include <libkern/c++/OSBoundedPtr.h> #include <libkern/c++/safe_allocation.h> #include <IOKit/IOLib.h> // IOMalloc/IOFree #endif /* DRIVERKIT_FRAMEWORK_INCLUDE */ namespace os_detail { struct IOKit_allocator { static void* allocate(size_t bytes) { return IOMalloc(bytes); } static void* allocate_zero(size_t bytes) { return IOMallocZero(bytes); } static void deallocate(void* p, size_t bytes) { IOFree(p, bytes); } }; } // end namespace os_detail template <typename T, typename Allocator = os_detail::IOKit_allocator> using OSAllocation = libkern::safe_allocation<T, Allocator, os_detail::panic_trapping_policy>; inline constexpr auto OSAllocateMemory = libkern::allocate_memory; inline constexpr auto OSAllocateMemoryZero = libkern::allocate_memory_zero; inline constexpr auto OSAdoptMemory = libkern::adopt_memory; #endif /* !TAPI */ #endif /* !XNU_LIBKERN_LIBKERN_CXX_OS_ALLOCATION_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSObject.h
/* * Copyright (c) 2000-2019 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@ */ /* * Copyright (c) 1998 Apple Computer, Inc. All rights reserved. * HISTORY * 1998-10-30 Godfrey van der Linden(gvdl) * Created */ #ifndef _LIBKERN_OSOBJECT_H #define _LIBKERN_OSOBJECT_H #include <libkern/c++/OSMetaClass.h> #include <libkern/c++/OSPtr.h> #include <IOKit/IORPC.h> #include <DriverKit/OSObject.h> #if defined(__clang__) #pragma clang diagnostic ignored "-Woverloaded-virtual" #endif class OSSymbol; class OSString; class OSObject; typedef OSObject* OSObjectPtr; /*! * @header * * @abstract * This header declares the OSObject class, * which is the concrete root of the Libkern C++ class hierarchy. */ /*! * @class OSObject * * @abstract * OSObject is the concrete root class * of the Libkern and I/O Kit C++ class hierarchy. * * @discussion * OSObject defines the minimal functionality * required of Libkern and I/O Kit C++ classes: * tie-in to the run-time type information facility, * the dynamic allocation/initialization paradigm, * and reference counting. * While kernel extensions are free to use their own C++ classes internally, * any interaction they have with Libkern or the I/O Kit will require * classes ultimately derived from OSObject. * * <b>Run-Time Type Information</b> * * OSObject is derived from the abstract root class * @link //apple_ref/doc/class/OSMetaClassBase OSMetaClassBase@/link, * which declares (and defines many of) the primitives * on which the run-time type information facility is based. * A parallel inheritance hierarchy of metaclass objects * provides run-time introspection, including access to class names, * inheritance, and safe type-casting. * See @link //apple_ref/doc/class/OSMetaClass OSMetaClass@/link * for more information. * * <b>Dynamic Allocation/Initialization</b> * * The kernel-resident C++ runtime does not support exceptions, * so Libkern classes cannot use standard C++ object * constructors and destructors, * which use exceptions to report errors. * To support error-handling during instance creation, then, * OSObject separates object allocation from initialization. * You can create a new OSObject-derived instance * with the <code>new</code> operator, * but this does nothing more than allocate memory * and initialize the reference count to 1. * Following this, you must call a designated initialization function * and check its <code>bool</code> return value. * If the initialization fails, * you must immediately call * <code>@link * //apple_ref/cpp/instm/OSObject/release/virtualvoid/() * release@/link</code> * on the instance and handle the failure in whatever way is appropriate. * Many Libkern and I/O Kit classes define static instance-creation functions * (beginning with the word "with") * to make construction a one-step process for clients. * * <b>Reference Counting</b> * * OSObject provides reference counting services using the * <code>@link * //apple_ref/cpp/instm/OSObject/retain/virtualvoid/() * retain@/link</code>, * <code>@link * //apple_ref/cpp/instm/OSObject/release/virtualvoid/() * release()@/link</code>, * <code>@link * //apple_ref/cpp/instm/OSObject/release/virtualvoid/(int) * release(int freeWhen)@/link</code> * and *<code> @link * //apple_ref/cpp/instm/OSObject/free/virtualvoid/() * free@/link</code> * functions. * The public interface to the reference counting is * <code>@link * //apple_ref/cpp/instm/OSObject/retain/virtualvoid/() * retain@/link</code>, * and * <code>@link * //apple_ref/cpp/instm/OSObject/release/virtualvoid/() * release@/link</code>; * <code>@link * //apple_ref/cpp/instm/OSObject/release/virtualvoid/(int) * release(int freeWhen)@/link</code> * is provided * for objects that have internal retain cycles. * * In general, a subclass is expected to only override * <code>@link * //apple_ref/cpp/instm/OSObject/free/virtualvoid/() * free@/link</code>. * It may also choose to override * <code>@link * //apple_ref/cpp/instm/OSObject/release/virtualvoid/(int) * release(int freeWhen)@/link</code> * if the object has a circular retain count, as noted above. * * <b>Use Restrictions</b> * * With very few exceptions in the I/O Kit, all Libkern-based C++ * classes, functions, and macros are <b>unsafe</b> * to use in a primary interrupt context. * Consult the I/O Kit documentation related to primary interrupts * for more information. * * <b>Concurrency Protection</b> * * The basic features of OSObject are thread-safe. * Most Libkern subclasses are not, and require locking or other protection * if instances are shared between threads. * I/O Kit driver objects are either designed for use within thread-safe contexts * or designed to inherently be thread-safe. * Always check the individual class documentation to see what * steps are necessary for concurrent use of instances. */ class OSObject : public OSMetaClassBase { OSDeclareAbstractStructorsWithDispatchAndNoOperators(OSObject); #if IOKITSTATS friend class IOStatistics; #endif private: /* Not to be included in headerdoc. * * @var retainCount Number of references held on this instance. */ mutable int retainCount; protected: // xx-review: seems not to be used, should we deprecate? /*! * @function release * * @abstract * Releases a reference to an object, * freeing it immediately if the reference count * drops below the specified threshold. * * @param freeWhen If decrementing the reference count makes it * < <code>freeWhen</code>, the object is immediately freed. * * @discussion * If the receiver has fewer than <code>freeWhen</code> references * after its reference count is decremented, * it is immediately freed. * * This version of <code>release</code> * can be used to break certain retain cycles in object graphs. * In general, however, it should be avoided. */ virtual void release(int freeWhen) const APPLE_KEXT_OVERRIDE; /*! * @function taggedRelease * * @abstract * Releases a tagged reference to an object, * freeing it immediately if the reference count * drops below the specified threshold. * * @param tag Used for tracking collection references. * @param freeWhen If decrementing the reference count makes it * < <code>freeWhen</code>, the object is immediately freed. * * @discussion * Kernel extensions should not use this function. * It is for use by OSCollection and subclasses to track * inclusion in collections. * * If the receiver has fewer than <code>freeWhen</code> references * after its reference count is decremented, * it is immediately freed. * * This version of <code>release</code> * can be used to break certain retain cycles in object graphs. * In general, however, it should be avoided. */ virtual void taggedRelease(const void * tag, const int freeWhen) const APPLE_KEXT_OVERRIDE; /*! * @function init * * @abstract * Initializes a newly-allocated object. * * @result * <code>true</code> on success, <code>false</code> on failure. * * @discussion * Classes derived from OSObject must override the primary init method * of their parent. * In general most implementations call * <code><i>super</i>::init()</code> * before doing local initialisation. * If the superclass call fails then return <code>false</code> immediately. * If the subclass encounters a failure then it should return <code>false</code>. */ virtual bool init(); /*! * @function free * * @abstract * Deallocates/releases resources held by the object. * * @discussion * Classes derived from OSObject should override this function * to deallocate or release all dynamic resources held by the instance, * then call the superclass's implementation. * * <b>Caution:</b> * <ol> * <li>You can not assume that you have completed initialization * before <code>free</code> is called, * so be very careful in your implementation.</li> * <li>OSObject's implementation performs the C++ <code>delete</code> * of the instance, so be sure that you call the superclass * implementation <i>last</i> in your implementation.</li> * <li><code>free</code> must not fail; * all resources must be deallocated or released on completion.</li> * </ol> */ virtual void free(); /*! * @function operator delete * * @abstract * Frees the memory of the object itself. * * @param mem A pointer to the object's memory. * @param size The size of the object's block of memory. * * @discussion * Never use <code>delete</code> on objects derived from OSObject; * use * <code>@link * //apple_ref/cpp/instm/OSObject/release/virtualvoid/() * release@/link</code> * instead. */ static void operator delete(void * mem, size_t size); // XXX: eventually we can flip this switch //#ifdef LIBKERN_SMART_POINTERS #if 0 private: #else public: #endif /*! * @function operator new * * @abstract * Allocates memory for an instance of the class. * * @param size The number of bytes to allocate * * @result * A pointer to block of memory if available, <code>NULL</code> otherwise. */ static void * operator new(size_t size); public: /*! * @function getRetainCount * * @abstract * Returns the reference count of the object. * * @result * The reference count of the object. */ virtual int getRetainCount() const APPLE_KEXT_OVERRIDE; /*! * @function retain * * @abstract * Retains a reference to the object. * * @discussion * This function increments the reference count of the receiver by 1. * If you need to maintain a reference to an object * outside the context in which you received it, * you should always retain it immediately. */ virtual void retain() const APPLE_KEXT_OVERRIDE; /*! * @function release * * @abstract * Releases a reference to the object, * freeing it immediately if the reference count drops to zero. * * @discussion * This function decrements the reference count of the receiver by 1. * If the reference count drops to zero, * the object is immediately freed using * <code>@link * //apple_ref/cpp/instm/OSObject/free/virtualvoid/() * free@/link</code>. */ virtual void release() const APPLE_KEXT_OVERRIDE; /*! * @function taggedRetain * * @abstract * Retains a reference to the object with an optional * tag used for reference-tracking. * * @param tag Used for tracking collection references. * * @discussion * Kernel extensions should not use this function. * It is for use by OSCollection and subclasses to track * inclusion in collections. * * If you need to maintain a reference to an object * outside the context in which you received it, * you should always retain it immediately. */ virtual void taggedRetain(const void * tag = NULL) const APPLE_KEXT_OVERRIDE; /*! * @function taggedRelease * * @abstract * Releases a tagged reference to an object, * freeing it immediately if the reference count * drops to zero. * * @param tag Used for tracking collection references. * * @discussion * Kernel extensions should not use this function. * It is for use by OSCollection and subclasses to track * inclusion in collections. */ virtual void taggedRelease(const void * tag = NULL) const APPLE_KEXT_OVERRIDE; // xx-review: used to say, "Remove a reference on this object with this tag, if an attempt is made to remove a reference that isn't associated with this tag the kernel will panic immediately", but I don't see that in the implementation /*! * @function serialize * * @abstract * Overridden by subclasses to archive the receiver into the provided * @link //apple_ref/doc/class/OSSerialize OSSerialize@/link object. * * @param serializer The OSSerialize object. * * @result * <code>true</code> if serialization succeeds, <code>false</code> if not. * * @discussion * OSObject's implementation writes a string indicating that * the class of the object receiving the function call * is not serializable. * Subclasses that can meaningfully encode themselves * in I/O Kit-style property list XML can override this function to do so. * See * @link //apple_ref/doc/class/OSSerialize OSSerialize@/link * for more information. */ virtual bool serialize(OSSerialize * serializer) const APPLE_KEXT_OVERRIDE; // Unused Padding OSMetaClassDeclareReservedUnused(OSObject, 0); OSMetaClassDeclareReservedUnused(OSObject, 1); OSMetaClassDeclareReservedUnused(OSObject, 2); OSMetaClassDeclareReservedUnused(OSObject, 3); OSMetaClassDeclareReservedUnused(OSObject, 4); OSMetaClassDeclareReservedUnused(OSObject, 5); OSMetaClassDeclareReservedUnused(OSObject, 6); OSMetaClassDeclareReservedUnused(OSObject, 7); OSMetaClassDeclareReservedUnused(OSObject, 8); OSMetaClassDeclareReservedUnused(OSObject, 9); OSMetaClassDeclareReservedUnused(OSObject, 10); OSMetaClassDeclareReservedUnused(OSObject, 11); OSMetaClassDeclareReservedUnused(OSObject, 12); OSMetaClassDeclareReservedUnused(OSObject, 13); OSMetaClassDeclareReservedUnused(OSObject, 14); OSMetaClassDeclareReservedUnused(OSObject, 15); }; #endif /* !_LIBKERN_OSOBJECT_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSCPPDebug.h
/* * 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@ */ #ifndef _OSCPPDEBUG_H #define _OSCPPDEBUG_H #include <libkern/OSBase.h> #define OSCPP_DEBUG #ifdef OSCPP_DEBUG __BEGIN_DECLS extern size_t debug_malloc_size; extern size_t debug_iomalloc_size; extern size_t debug_container_malloc_size; extern size_t debug_ivars_size; void OSPrintMemory(void); __END_DECLS #endif /* OSCPP_DEBUG */ #endif /* _OSCPPDEBUG_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSCollectionIterator.h
/* * Copyright (c) 2019 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@ */ /* IOCollectionIterator.h created by gvdl on Fri 1998-10-30 */ #ifndef _OS_OSCOLLECTIONITERATOR_H #define _OS_OSCOLLECTIONITERATOR_H #include <libkern/c++/OSIterator.h> #include <libkern/c++/OSCollection.h> #include <libkern/c++/OSPtr.h> class OSCollectionIterator; typedef OSCollectionIterator* OSCollectionIteratorPtr; /*! * @header * * @abstract * This header declares the OSCollectionIterator collection class. */ /*! * @class OSCollectionIterator * * @discussion * OSCollectionIterator defines a consistent mechanism to iterate * through the objects of an OSCollection. * It expands on the basic interface of * @link //apple_ref/cpp/class/OSIterator OSIterator@/link * to allow association of an iterator with a specific collection. * * To use an OSCollectionIterator, you create it with the collection * to be iterated, then call * @link //apple_ref/cpp/class/OSIterator OSIterator@/link * as long as it returns an object: * * @textblock * <pre> * OSPtr <OSCollectionIterator> iterator = * OSCollectionIterator::withCollection(myCollection); * OSObject * object; * while (object = iterator->getNextObject()) { * // do something with object * } * // optional * if (!iterator->isValid()) { * // report that collection changed during iteration * } * iterator = nullptr; * </pre> * @/textblock * * Note that when iterating associative collections, * the objects returned by <code>getNextObject</code> are keys; * if you want to work with the associated values, * simply look them up in the collection with the keys. * * <b>Use Restrictions</b> * * With very few exceptions in the I/O Kit, all Libkern-based C++ * classes, functions, and macros are <b>unsafe</b> * to use in a primary interrupt context. * Consult the I/O Kit documentation related to primary interrupts * for more information. * * OSCollectionIterator provides no concurrency protection. */ class OSCollectionIterator : public OSIterator { OSDeclareDefaultStructors(OSCollectionIterator); protected: // xx-review: Do we want to document these? OSPtr<const OSCollection> collection; void * collIterator; unsigned int initialUpdateStamp; bool valid; public: /*! * @function withCollection * * @abstract * Creates and initializes an OSCollectionIterator * for the provided collection object. * * @param inColl The OSCollection-derived collection object to be iteratated. * * @result * A new instance of OSCollectionIterator, or <code>NULL</code> on failure. */ static OSPtr<OSCollectionIterator> withCollection(const OSCollection * inColl); /*! * @function initWithCollection * * @abstract * Initializes an OSCollectionIterator * for the provided collection object. * * @param inColl The OSCollection-derived collection object to be iteratated. * @result * <code>true</code> if the initialization was successful, * or <code>false</code> on failure. * * @discussion * Not for general use. Use the static instance creation method * <code>@link withCollection withCollection@/link</code> instead. */ virtual bool initWithCollection(const OSCollection * inColl); /*! * @function free * * @abstract * Releases or deallocates any resources used * by the OSCollectionIterator object. * * @discussion * This function should not be called directly; * use * <code>@link * //apple_ref/cpp/instm/OSObject/release/virtualvoid/() * release@/link</code> * instead. */ virtual void free() APPLE_KEXT_OVERRIDE; /*! * @function reset * * @abstract * Resets the iterator to the beginning of the collection, * as if it had just been created. */ virtual void reset() APPLE_KEXT_OVERRIDE; /*! * @function isValid * * @abstract * Checks that the collection hasn't been modified during iteration. * * @return * <code>true</code> if the iterator is valid for continued use, * <code>false</code> otherwise * (typically because the iteration context has been modified). */ virtual bool isValid() APPLE_KEXT_OVERRIDE; /*! * @function getNextObject * * @abstract * Advances to and returns the next object in the iteration. * * @return * The next object in the iteration context, * <code>NULL</code> if there is no next object * or if the iterator is no longer valid. * * @discussion * This function first calls * <code>@link //apple_ref/cpp/instm/OSCollectionIterator/isValid/virtualbool/() * isValid@/link</code> * and returns <code>NULL</code> if that function * returns <code>false</code>. * * Subclasses must implement this pure virtual function * to check for validity with * <code>@link * //apple_ref/cpp/instm/OSCollectionIterator/isValid/virtualbool/() * isValid@/link</code>, * and then to advance the iteration context to the next object (if any) * and return that next object, or <code>NULL</code> if there is none. */ virtual OSObject * getNextObject() APPLE_KEXT_OVERRIDE; }; #endif /* !_OS_OSCOLLECTIONITERATOR_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSBoundedArray.h
/* * Copyright (c) 2019 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 XNU_LIBKERN_LIBKERN_CXX_OS_BOUNDED_ARRAY_H #define XNU_LIBKERN_LIBKERN_CXX_OS_BOUNDED_ARRAY_H #if !TAPI #if DRIVERKIT_FRAMEWORK_INCLUDE #include <DriverKit/bounded_array.h> #include <DriverKit/OSBoundedPtr.h> #else #include <libkern/c++/bounded_array.h> #include <libkern/c++/OSBoundedPtr.h> #endif /* DRIVERKIT_FRAMEWORK_INCLUDE */ #include <stddef.h> template <typename T, size_t N> using OSBoundedArray = libkern::bounded_array<T, N, os_detail::panic_trapping_policy>; #endif /* !TAPI */ #endif /* !XNU_LIBKERN_LIBKERN_CXX_OS_BOUNDED_ARRAY_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSBoundedArrayRef.h
/* * Copyright (c) 2019 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 XNU_LIBKERN_LIBKERN_CXX_OS_BOUNDED_ARRAY_REF_H #define XNU_LIBKERN_LIBKERN_CXX_OS_BOUNDED_ARRAY_REF_H #if !TAPI #if DRIVERKIT_FRAMEWORK_INCLUDE #include <DriverKit/bounded_array_ref.h> #include <DriverKit/OSBoundedPtr.h> #else #include <libkern/c++/bounded_array_ref.h> #include <libkern/c++/OSBoundedPtr.h> #endif /* DRIVERKIT_FRAMEWORK_INCLUDE */ template <typename T> using OSBoundedArrayRef = libkern::bounded_array_ref<T, os_detail::panic_trapping_policy>; #endif /* !TAPI */ #endif /* !XNU_LIBKERN_LIBKERN_CXX_OS_BOUNDED_ARRAY_REF_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSCollection.h
/* * 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@ */ /* IOCollection.h created by gvdl on Thu 1998-10-22 */ #ifndef _OS_OSCOLLECTION_H #define _OS_OSCOLLECTION_H #include <libkern/c++/OSObject.h> #include <libkern/c++/OSPtr.h> class OSDictionary; class OSCollection; typedef OSCollection* OSCollectionPtr; // We're not necessarily in C++11 mode, so we need to disable warnings // for C++11 extensions #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wc++11-extensions" template <typename T> using OSCollectionTaggedPtr = T *; #pragma clang diagnostic pop /*! * @header * * @abstract * This header declares the OSDictionary collection class. */ /*! * @class OSCollection * * @abstract * The abstract superclass for Libkern collections. * * @discussion * OSCollection is the abstract superclass * for all Libkern C++ object collections. * It defines the necessary interfaces for managing storage space * and iterating through an arbitrary collection * (see the * @link //apple_ref/cpp/class/OSIterator OSIterator@/link * and * @link //apple_ref/cpp/class/OSCollectionIterator OSCollectionIterator@/link * classes). * It is up to concrete subclasses * to define their specific content management functions. * * <b>Use Restrictions</b> * * With very few exceptions in the I/O Kit, all Libkern-based C++ * classes, functions, and macros are <b>unsafe</b> * to use in a primary interrupt context. * Consult the I/O Kit documentation related to primary interrupts * for more information. * * OSCollection provides no concurrency protection; * it's up to the usage context to provide any protection necessary. * Some portions of the I/O Kit, such as * @link //apple_ref/doc/class/IORegistryEntry IORegistryEntry@/link, * handle synchronization via defined member functions for setting * properties. */ class OSCollection : public OSObject { friend class OSCollectionIterator; OSDeclareAbstractStructors(OSCollection); struct ExpansionData { }; protected: /* Not to be included in headerdoc. * * @var updateStamp * * @abstract * A counter for changes to the collection object. * * @discussion * The update stamp is used primarily to track validity * of iteration contexts. * See @link //apple_ref/cpp/class/OSIterator OSIterator@/link and * @link //apple_ref/cpp/class/OSCollectionIterator OSCollectionIterator@/link * for more information. */ unsigned int updateStamp; private: /* Reserved for future use. (Internal use only) */ // ExpansionData * reserved; unsigned int fOptions; protected: // Member functions used by the OSCollectionIterator class. /*! * @function iteratorSize * * @abstract * Returns the size in bytes of a subclass's iteration context. * * @result * The size in bytes of the iteration context * needed by the subclass of OSCollection. * * @discussion * This pure virtual member function, which subclasses must implement, * is called by an * @link //apple_ref/doc/class/OSCollectionIterator OSCollectionIterator@/link * object so that it can allocate the storage needed * for the iteration context. * An iteration context contains the data necessary * to iterate through the collection. */ virtual unsigned int iteratorSize() const = 0; /*! * @function initIterator * * @abstract * Initializes the iteration context for a collection subclass. * * @param iterationContext The iteration context to initialize. * * @result * <code>true</code> if initialization was successful, * <code>false</code> otherwise. * * @discussion * This pure virtual member function, which subclasses must implement, * is called by an * @link //apple_ref/doc/class/OSCollectionIterator OSCollectionIterator@/link * object to initialize an iteration context for a collection. * The collection object should interpret <code>iterationContext</code> appropriately * and initialize its contents to begin an iteration. * * This function can be called repeatedly for a given context, * whenever the iterator is reset via the * @link //apple_ref/cpp/instm/OSCollectionIterator/reset/virtualvoid/() * OSCollectionIterator::reset@/link * function. */ virtual bool initIterator(void * iterationContext) const = 0; /*! * @function getNextObjectForIterator * * @abstract * Returns the next member of a collection. * * @param iterationContext The iteration context. * @param nextObject The object returned by reference to the caller. * * @result * <code>true</code> if an object was found, <code>false</code> otherwise. * * @discussion * This pure virtual member function, which subclasses must implement, * is called by an * @link //apple_ref/doc/class/OSCollectionIterator OSCollectionIterator@/link * to get the next object for a given iteration context. * The collection object should interpret * <code>iterationContext</code> appropriately, * advance the context from its current object * to the next object (if it exists), * return that object by reference in <code>nextObject</code>, * and return <code>true</code> for the function call. * If there is no next object, the collection object must return <code>false</code>. * * For associative collections, the object returned should be the key * used to access its associated value, and not the value itself. */ virtual bool getNextObjectForIterator( void * iterationContext, OSObject ** nextObject) const = 0; /*! * @function init * * @abstract * Initializes the OSCollection object. * * @result * <code>true</code> on success, <code>false</code> otherwise. * * @discussion * This function is used to initialize state * within a newly created OSCollection object. */ virtual bool init() APPLE_KEXT_OVERRIDE; public: /*! * @typedef _OSCollectionFlags * * @const kImmutable * @discussion * Used with <code>@link setOptions setOptions@/link</code> * to indicate the collection's contents should * or should not change. * * An @link //apple_ref/doc/class/IORegistryEntry IORegistryEntry@/link * object marks collections immutable when set * as properties of a registry entry that's attached to a plane. * This is generally an advisory flag, used for debugging; * setting it does not mean a collection will in fact * disallow modifications. */ typedef enum { kImmutable = 0x00000001, kSort = 0x00000002, kMASK = (unsigned) - 1 } _OSCollectionFlags; // xx-review: should be protected, not public /*! * @function haveUpdated * * @abstract * Tracks updates to the collection. * * @discussion * Subclasses call this function <i>before</i> * making any change to their contents (not after, as the name implies). * Update tracking is used for collection iterators, * and to enforce certain protections in the IORegistry. */ void haveUpdated(); /*! * @function getCount * * @abstract * Returns the number of objects in the collection. * * @result * The number of objects in the collection. * * @discussion * Subclasses must implement this pure virtual member function. */ virtual unsigned int getCount() const = 0; /*! * @function getCapacity * * @abstract * Returns the number of objects the collection * can store without reallocating. * * @result * The number objects the collection * can store without reallocating. * * @discussion * Subclasses must implement this pure virtual member function. */ virtual unsigned int getCapacity() const = 0; /*! * @function getCapacityIncrement * * @abstract * Returns the storage increment of the collection. * * @result * The storage increment of the collection. * * @discussion * Subclasses must implement this pure virtual member function. * Most collection subclasses allocate their storage * in multiples of the capacity increment. * * See * <code>@link * //apple_ref/cpp/instm/OSCollection/ensureCapacity/virtualunsignedint/(unsignedint) * ensureCapacity@/link</code> * for how the capacity increment is used. */ virtual unsigned int getCapacityIncrement() const = 0; /*! * @function setCapacityIncrement * * @abstract * Sets the storage increment of the collection. * * @result * The new storage increment of the collection, * which may be different from the number requested. * * @discussion * Subclasses must implement this pure virtual member function. * Most collection subclasses allocate their storage * in multiples of the capacity increment. * * Collection subclasses should gracefully handle * an <code>increment</code> of zero * by applying (and returning) a positive minimum capacity. * * Setting the capacity increment does not trigger an immediate adjustment * of a collection's storage. * * See * @link * //apple_ref/cpp/instm/OSCollection/ensureCapacity/virtualunsignedint/(unsignedint) * ensureCapacity@/link * for how the capacity increment is used. */ virtual unsigned int setCapacityIncrement(unsigned increment) = 0; /*! * @function ensureCapacity * * @abstract * Ensures the collection has enough space to store * the requested number of objects. * * @param newCapacity The total number of objects the collection * should be able to store. * * @result * The new capacity of the collection, * which may be different from the number requested * (if smaller, reallocation of storage failed). * * @discussion * Subclasses implement this pure virtual member function * to adjust their storage so that they can hold * at least <code>newCapacity</code> objects. * Libkern collections generally allocate storage * in multiples of their capacity increment. * * Subclass methods that add objects to the collection * should call this function before adding any object, * and should check the return value for success. * * Collection subclasses may reduce their storage * when the number of contained objects falls below some threshold, * but no Libkern collections currently do. */ virtual unsigned int ensureCapacity(unsigned int newCapacity) = 0; /*! * @function flushCollection * * @abstract * Empties the collection, releasing any objects retained. * * @discussion * Subclasses implement this pure virtual member function * to remove their entire contents. * This must not release the collection itself. */ virtual void flushCollection() = 0; /*! * @function setOptions * * @abstract * Recursively sets option bits in this collection * and all child collections. * * @param options A bitfield whose values turn the options on (1) or off (0). * @param mask A mask indicating which bits * in <code>options</code> to change. * Pass 0 to get the whole current options bitfield * without changing any settings. * @param context Unused. * * @result * The options bitfield as it was before the set operation. * * @discussion * Kernel extensions should not call this function. * * The only option currently in use is * <code>@link //apple_ref/doc/title:econst/OSCollectionFlags/kImmutable * kImmutable@/link</code>. * * Subclasses should override this function to recursively apply * the options to their contents if the options actually change. */ virtual unsigned setOptions( unsigned options, unsigned mask, void * context = NULL); /*! * @function copyCollection * * @abstract * Creates a deep copy of a collection. * * @param cycleDict A dictionary of all of the collections * that have been copied so far, * to start the copy at the top level * pass <code>NULL</code> for <code>cycleDict</code>. * * @result * The newly copied collecton, * <code>NULL</code> on failure. * * @discussion * This function copies the collection * and all of the contained collections recursively. * Objects that are not derived from OSCollection are retained * rather than copied. * * Subclasses of OSCollection must override this function * to properly support deep copies. */ virtual OSPtr<OSCollection> copyCollection(OSDictionary * cycleDict = NULL); /*! * @function iterateObjects * * @abstract * Invoke a callback for each member of the collection. * * @param refcon A reference constant for the callback. * @param callback The callback function, * called with the refcon and each member object * of the collection in turn, on the callers thread. * The callback should return true to early terminate * the iteration, false otherwise. * * @result * False if the collection iteration was made invalid * (see OSCollectionIterator::isValid()) otherwise true. */ bool iterateObjects(void * refcon, bool (*callback)(void * refcon, OSObject * object)); #ifdef __BLOCKS__ /*! * @function iterateObjects * * @abstract * Invoke a block for each member of the collection. * * @param block The block, * called with the refcon and each member object * of the collection in turn, on the callers thread. * The block should return true to early terminate * the iteration, false otherwise. * * @result * False if the collection iteration was made invalid * (see OSCollectionIterator::isValid()) otherwise true. */ bool iterateObjects(bool (^block)(OSObject * object)); #endif /* __BLOCKS__ */ OSMetaClassDeclareReservedUsedX86(OSCollection, 0); OSMetaClassDeclareReservedUsedX86(OSCollection, 1); OSMetaClassDeclareReservedUnused(OSCollection, 2); OSMetaClassDeclareReservedUnused(OSCollection, 3); OSMetaClassDeclareReservedUnused(OSCollection, 4); OSMetaClassDeclareReservedUnused(OSCollection, 5); OSMetaClassDeclareReservedUnused(OSCollection, 6); OSMetaClassDeclareReservedUnused(OSCollection, 7); }; #endif /* !_OS_OSCOLLECTION_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSLib.h
/* * Copyright (c) 1999-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@ */ #ifndef _OS_OSLIB_H #define _OS_OSLIB_H #include <libkern/OSBase.h> #define MACH_ASSERT 1 __BEGIN_DECLS #include <stdarg.h> #include <sys/systm.h> #include <kern/assert.h> __END_DECLS #ifndef NULL #if defined (__cplusplus) #if __cplusplus >= 201103L #define NULL nullptr #else #define NULL 0 #endif #else #define NULL ((void *)0) #endif #endif #endif /* _OS_OSLIB_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSEndianTypes.h
/* * Copyright (c) 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@ * * HISTORY * gvdl 20050620 Created */ // xx-review: are these even used anywhere? Grep turns up squat. /*! * @header OSEndianTypes * * @abstract * C++ inline types for byte-swapping. * * @discussion * The OSEndianTypes consist of a number of types that are used * very similarly to the traditional MacOS C scalar integers types, * for example, <code>UInt32</code> and <code>SInt32</code>. * @copyright 2005 Apple Computer, Inc. All rights reserved. * @updated 2005-07-25 */ // Header doc magic trick for simple documentation #if 0 /*! * @typedef BigUInt16 * @abstract A Big-endian unsigned integer scalar size 16 - UInt16 */ typedef class BigUInt16 BigUInt16; /*! * @typedef BigSInt16 * @abstract A Big-endian signed integer scalar size 16 - SInt16 */ typedef class BigSInt16 BigSInt16; /*! * @typedef BigUInt32 * @abstract A Big-endian unsigned integer scalar size 32 - UInt32 */ typedef class BigUInt32 BigUInt32; /*! * @typedef BigSInt32 * @abstract A Big-endian signed integer scalar size 32 - SInt32 */ typedef class BigSInt32 BigSInt32; /*! * @typedef BigUInt64 * @abstract A Big-endian unsigned integer scalar size 64 - UInt64 */ typedef class BigUInt64 BigUInt64; /*! * @typedef BigSInt64 * @abstract A Big-endian signed integer scalar size 64 - SInt64 */ typedef class BigSInt64 BigSInt64; /*! * @typedef LittleUInt16 * @abstract A Little-endian unsigned integer scalar size 16 - UInt16 */ typedef class LittleUInt16 LittleUInt16; /*! * @typedef LittleSInt16 * @abstract A Little-endian signed integer scalar size 16 - SInt16 */ typedef class LittleSInt16 LittleSInt16; /*! * @typedef LittleUInt32 * @abstract A Little-endian unsigned integer scalar size 32 - UInt32 */ typedef class LittleUInt32 LittleUInt32; /*! * @typedef LittleSInt32 * @abstract A Little-endian signed integer scalar size 32 - SInt32 */ typedef class LittleSInt32 LittleSInt32; /*! * @typedef LittleUInt64 * @abstract A Little-endian unsigned integer scalar size 64 - UInt64 */ typedef class LittleUInt64 LittleUInt64; /*! * @typedef LittleSInt64 * @abstract A Little-endian signed integer scalar size 64 - SInt64 */ typedef class LittleSInt64 LittleSInt64; #endif /* 0 - headerdoc trick */ #ifndef _OS_OSENDIANHELPER_H #define _OS_OSENDIANHELPER_H #if __cplusplus #include <libkern/OSTypes.h> #include <libkern/OSByteOrder.h> // Probably should really be using templates, this is one of the few cases // where they do make sense. But as the kernel is not allowed to export // template based C++ APIs we have to use sophisticated macros instead #define __OSEndianSignIntSizeDEF(argname, argend, argtype, argsize) { \ public: \ typedef argtype ## argsize Value; \ \ private: \ typedef UInt ## argsize UValue; \ UValue mValue; \ \ void writeValue(Value v) { \ if (__builtin_constant_p(v)) \ mValue = OSSwapHostTo ## argend ## ConstInt ## argsize(v); \ else \ OSWrite ## argend ## Int ## argsize(&mValue, 0, (UValue) v); \ }; \ \ Value readValue() const { \ return (Value) OSRead ## argend ## Int ## argsize(&mValue, 0); \ }; \ \ public: \ argname() { }; \ \ argname (Value v) { writeValue(v); }; \ argname &operator = (Value v) { writeValue(v); return *this; } \ \ Value get() const { return readValue(); }; \ operator Value () const { return readValue(); }; \ } class BigUInt16 __OSEndianSignIntSizeDEF(BigUInt16, Big, UInt, 16); class BigSInt16 __OSEndianSignIntSizeDEF(BigSInt16, Big, SInt, 16); class BigUInt32 __OSEndianSignIntSizeDEF(BigUInt32, Big, UInt, 32); class BigSInt32 __OSEndianSignIntSizeDEF(BigSInt32, Big, SInt, 32); class BigUInt64 __OSEndianSignIntSizeDEF(BigUInt64, Big, UInt, 64); class BigSInt64 __OSEndianSignIntSizeDEF(BigSInt64, Big, SInt, 64); class LittleUInt16 __OSEndianSignIntSizeDEF(LittleUInt16, Little, UInt, 16); class LittleSInt16 __OSEndianSignIntSizeDEF(LittleSInt16, Little, SInt, 16); class LittleUInt32 __OSEndianSignIntSizeDEF(LittleUInt32, Little, UInt, 32); class LittleSInt32 __OSEndianSignIntSizeDEF(LittleSInt32, Little, SInt, 32); class LittleUInt64 __OSEndianSignIntSizeDEF(LittleUInt64, Little, UInt, 64); class LittleSInt64 __OSEndianSignIntSizeDEF(LittleSInt64, Little, SInt, 64); #undef __OSEndianSignIntSizeDEF #endif /* __cplusplus */ #endif /* ! _OS_OSENDIANHELPER_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSString.h
/* * Copyright (c) 2019 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@ */ /* IOString.h created by rsulack on Wed 17-Sep-1997 */ /* IOString.h converted to C++ by gvdl on Fri 1998-10-30 */ #ifndef _OS_OSSTRING_H #define _OS_OSSTRING_H #include <libkern/c++/OSObject.h> #include <libkern/c++/OSPtr.h> #include <os/base.h> class OSData; class OSString; typedef OSString* OSStringPtr; typedef OSString const* OSStringConstPtr; /*! * @header * * @abstract * This header declares the OSString container class. */ /* Not to be included in headerdoc. * * For internal use. */ enum { kOSStringNoCopy = 0x00000001 }; /*! * @class OSString * * @abstract * OSString wraps a C string in a C++ object for use in Libkern collections. * * @discussion * OSString is a container class for managing arrays of characters. * An OSString normally maintains its own character buffer and allows changes, * but you can create an "immutable" OSString * that references an external C string * buffer using the "NoCopy" creator functions. * Functions called to change the contents of an immutable OSString will fail. * * <b>Encodings</b> * * OSString makes no provisions for different character encodings and * assumes that a string is a nul-terminated sequence of single-byte characters. * User-space code must either assume an encoding (typically ASCII or UTF-8) * or determine it in some other way (such as an IORegistryEntry property). * * <b>Altering Strings</b> * * OSString's indended use is as a reference-counted object container * for a C string and little more. * While OSString provides full access to the underlying C string, * it provides little in the way of string object manipulation; * there are no append or insert functions, * only a set-character function. * If you need to manipulate OSStrings, * it's generally best to get the C strings, * alter them as necessary, and create a new OSString object * from the resulting C string. * * <b>Use Restrictions</b> * * With very few exceptions in the I/O Kit, all Libkern-based C++ * classes, functions, and macros are <b>unsafe</b> * to use in a primary interrupt context. * Consult the I/O Kit documentation related to primary interrupts * for more information. * * OSString provides no concurrency protection; * it's up to the usage context to provide any protection necessary. * Some portions of the I/O Kit, such as * @link //apple_ref/doc/class/IORegistryEntry IORegistryEntry@/link, * handle synchronization via defined member functions for setting * properties. */ class OSString : public OSObject { OSDeclareDefaultStructors(OSString); enum { kMaxStringLength = 262142 }; #if APPLE_KEXT_ALIGN_CONTAINERS protected: unsigned int flags:14, length:18; char * OS_PTRAUTH_SIGNED_PTR("OSString.string") string; #else /* APPLE_KEXT_ALIGN_CONTAINERS */ protected: char * OS_PTRAUTH_SIGNED_PTR("OSString.string") string; unsigned int flags; unsigned int length; #endif /* APPLE_KEXT_ALIGN_CONTAINERS */ public: /*! * @function withString * * @abstract * Creates and initializes an OSString from another OSString. * * @param aString The OSString object whose contents to copy. * * @result * An instance of OSString representing * the same characters as <code>aString</code>, * and with a reference count of 1; * <code>NULL</code> on failure. * * @discussion * The new OSString is a distinct instance from <code>aString</code>, * and is not merely the original object * with the reference count incremented. * Changes to one will not be reflected in the other. */ static OSPtr<OSString> withString(const OSString * aString); /*! * @function withCString * * @abstract * Creates and initializes an OSString from a C string. * * @param cString The C string to copy into the new OSString. * * @result * An instance of OSString representing * the same characters as <code>aString</code>, * and with a reference count of 1; * <code>NULL</code> on failure. */ static OSPtr<OSString> withCString(const char * cString); /*! * @function withCStringNoCopy * * @abstract * Creates and initializes an immutable OSString * that shares the provided C string buffer. * * @param cString The C string to reference. * * @result * An instance of OSString containing <code>cString</code>, * and with a reference count of 1; * <code>NULL</code> on failure. * * @discussion * An OSString object created with this function * does not claim ownership of the C string, * but shares it with the caller. * When the caller determines that the OSString object has actually been freed, * it can safely dispose of the data buffer. * Conversely, if it frees the shared data buffer, * it must not attempt to use the OSString object and should release it. * * An OSString object created with this function does not * allow changing the string via <code>@link setChar setChar@/link</code>. */ static OSPtr<OSString> withCStringNoCopy(const char * cString); /*! * @function withCString * * @abstract * Creates and initializes an OSString from a C string and the given length. * * @param cString The C string to copy into the new OSString. * @param length Number of characters to copy from cString. If the actual length of the * C string is less than this length, then the length of the resulting * OSString will be the same as that of the C cstring. * * @result * An instance of OSString representing * the same characters as <code>cString</code> with the specified length, * and with a reference count of 1; * <code>NULL</code> on failure. */ static OSPtr<OSString> withCString(const char *cString, size_t length); /*! * @function initWithString * * @abstract * Initializes an OSString from another OSString. * * @param aString The OSString object whose contents to copy. * * @result * <code>true</code> on success, <code>false</code> on failure. * * @discussion * Not for general use. Use the static instance creation method * <code>@link withString withString@/link</code> instead. */ virtual bool initWithString(const OSString * aString); /*! * @function initWithCString * * @abstract * Initializes an OSString from a C string. * * @param cString The C string to copy into the new OSString. * * @result * <code>true</code> on success, <code>false</code> on failure. * * @discussion * Not for general use. Use the static instance creation method * <code>@link withCString withCString@/link</code> instead. */ virtual bool initWithCString(const char * cString); /*! * @function initWithCStringNoCopy * * @abstract * Initializes an immutable OSString * to share the provided C string buffer. * * @param cString The C string to reference. * * @result * <code>true</code> on success, <code>false</code> on failure. * * @discussion * Not for general use. Use the static instance creation method * <code>@link withCStringNoCopy withCStringNoCopy@/link</code> instead. * * An OSString object initialized with this function * does not claim ownership of the C string, * but shares it with the caller. * When the caller determines that the OSString object has actually been freed, * it can safely dispose of the data buffer. * Conversely, if it frees the shared data buffer, * it must not attempt to use the OSString object and should release it. * * An OSString object created with this function does not * allow changing the string via <code>@link setChar setChar@/link</code>. */ virtual bool initWithCStringNoCopy(const char * cString); /*! * @function free * * @abstract * Deallocates or releases any resources * used by the OSString instance. * * @discussion * This function should not be called directly; * use * <code>@link * //apple_ref/cpp/instm/OSObject/release/virtualvoid/() * release@/link</code> * instead. */ virtual void free() APPLE_KEXT_OVERRIDE; /*! * @function getLength * * @abstract * Returns the number of characters in the OSString object. * * @result * The number of characters in the OSString object. */ virtual unsigned int getLength() const; /*! * @function getChar * * @abstract * Returns the character at a given index in the string object. * * @param index The index into the string. * * @result * The character at <code>index</code> within the string, * or <code>'\0'</code> if index is past the end of the string. */ virtual char getChar(unsigned int index) const; /*! * @function setChar * * @abstract * Replaces a character at a given index in the string object. * * @param aChar The character value to set. * @param index The index into the string. * * @result * <code>true</code> if the character was replaced, * <code>false</code> if the was created "NoCopy" * or <code>index</code> is past the end of the string. */ virtual bool setChar(char aChar, unsigned int index); /*! * @function getCStringNoCopy * * @abstract * Returns a pointer to the internal C string buffer. * * @result * A pointer to the internal C string buffer. */ virtual const char * getCStringNoCopy() const; /*! * @function isEqualTo * * @abstract * Tests the equality of two OSString objects. * * @param aString The OSString object being compared against the receiver. * * @result * <code>true</code> if the two OSString objects are equivalent, * <code>false</code> otherwise. * * @discussion * Two OSString objects are considered equal if they have same length * and if their byte buffers hold the same contents. */ virtual bool isEqualTo(const OSString * aString) const; /*! * @function isEqualTo * * @abstract * Tests the equality of an OSString object with a C string. * * @param cString The C string to compare against the receiver. * * @result * <code>true</code> if the OSString's characters * are equivalent to the C string's, * <code>false</code> otherwise. */ virtual bool isEqualTo(const char * cString) const; /*! * @function isEqualTo * * @abstract * Tests the equality of an OSString object to an arbitrary object. * * @param anObject The object to be compared against the receiver. * * @result * Returns <code>true</code> if the two objects are equivalent, * <code>false</code> otherwise. * * @discussion * An OSString is considered equal to another object * if that object is derived from OSString * and contains the equivalent bytes of the same length. */ virtual bool isEqualTo(const OSMetaClassBase * anObject) const APPLE_KEXT_OVERRIDE; /*! * @function isEqualTo * * @abstract * Tests the equality of an OSData object and the OSString instance. * * @param aDataObject An OSData object. * * @result * <code>true</code> if the two objects are equivalent, <code>false</code> otherwise. * * @discussion * This function compares the bytes of the OSData object * against those of the OSString, * accounting for the possibility that an OSData * might explicitly include a nul * character as part of its total length. * Thus, for example, an OSData object containing * either the bytes <'u', 's', 'b', '\0'> * or <'u', 's', 'b'> * will compare as equal to the OSString containing "usb". */ virtual bool isEqualTo(const OSData * aDataObject) const; /*! * @function serialize * * @abstract * Archives the receiver into the provided * @link //apple_ref/doc/class/OSSerialize OSSerialize@/link object. * * @param serializer The OSSerialize object. * * @result * <code>true</code> if serialization succeeds, <code>false</code> if not. */ virtual bool serialize(OSSerialize * serializer) const APPLE_KEXT_OVERRIDE; OSMetaClassDeclareReservedUnused(OSString, 0); OSMetaClassDeclareReservedUnused(OSString, 1); OSMetaClassDeclareReservedUnused(OSString, 2); OSMetaClassDeclareReservedUnused(OSString, 3); OSMetaClassDeclareReservedUnused(OSString, 4); OSMetaClassDeclareReservedUnused(OSString, 5); OSMetaClassDeclareReservedUnused(OSString, 6); OSMetaClassDeclareReservedUnused(OSString, 7); OSMetaClassDeclareReservedUnused(OSString, 8); OSMetaClassDeclareReservedUnused(OSString, 9); OSMetaClassDeclareReservedUnused(OSString, 10); OSMetaClassDeclareReservedUnused(OSString, 11); OSMetaClassDeclareReservedUnused(OSString, 12); OSMetaClassDeclareReservedUnused(OSString, 13); OSMetaClassDeclareReservedUnused(OSString, 14); OSMetaClassDeclareReservedUnused(OSString, 15); }; #endif /* !_OS_OSSTRING_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSSymbol.h
/* * Copyright (c) 2019 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@ */ /* IOSymbol.h created by gvdl on Fri 1998-10-30 */ /* OSSymbol must be created through the factory methods and thus is not subclassable. */ #ifndef _OS_OSSYMBOL_H #define _OS_OSSYMBOL_H #include <libkern/c++/OSString.h> #include <libkern/c++/OSPtr.h> class OSSymbol; typedef OSSymbol* OSSymbolPtr; typedef OSSymbol const* OSSymbolConstPtr; /*! * @header * * @abstract * This header declares the OSSymbol container class. */ // xx-review: OSSymbol does not override setChar /*! * @class OSSymbol * * @abstract * OSSymbol wraps a C string in a unique C++ object * for use as keys in Libkern collections. * * @discussion * OSSymbol is a container class for managing uniqued strings, * for example, those used as dictionary keys. * Its static instance-creation functions check * for an existing instance of OSSymbol * with the requested C string value before creating a new object. * If an instance already exists in the pool of unique symbols, * its reference count is incremented * and the existing instance is returned. * * While OSSymbol provides for uniquing of a given string value, * it makes no effort to enforce immutability of that value. * Altering the contents of an OSSymbol should be avoided. * * <b>Use Restrictions</b> * * With very few exceptions in the I/O Kit, all Libkern-based C++ * classes, functions, and macros are <b>unsafe</b> * to use in a primary interrupt context. * Consult the I/O Kit documentation related to primary interrupts * for more information. * * OSSymbol provides no concurrency protection; * it's up to the usage context to provide any protection necessary. * Some portions of the I/O Kit, such as * @link //apple_ref/doc/class/IORegistryEntry IORegistryEntry@/link, * handle synchronization via defined member functions for setting * properties. */ class OSSymbol : public OSString { friend class OSSymbolPool; OSDeclareAbstractStructors(OSSymbol); private: static void initialize(); /*! * @function initWithString * * @abstract * Overridden to prevent creation of duplicate symbols. * * @param aString Unused. * * @result * <code>false</code>. * * @discussion * Overrides OSString's implementation to prevent creation * of distinct OSSymbols with the same string value. */ virtual bool initWithString(const OSString * aString) APPLE_KEXT_OVERRIDE; /*! * @function initWithCString * * @abstract * Overridden to prevent creation of duplicate symbols. * * @param cString Unused. * * @result * <code>false</code>. * * @discussion * Overrides OSString's implementation to prevent creation * of distinct OSSymbols with the same string value. */ virtual bool initWithCString(const char * cString) APPLE_KEXT_OVERRIDE; /*! * @function initWithCStringNoCopy * * @abstract * Overridden to prevent creation of duplicate symbols. * * @param cString Unused. * * @result * <code>false</code>. * * @discussion * Overrides OSString's implementation to prevent creation * of distinct OSSymbols with the same string value. */ virtual bool initWithCStringNoCopy(const char *cString) APPLE_KEXT_OVERRIDE; protected: // xx-review: should we just omit this from headerdoc? /*! * @function taggedRelease * * @abstract * Overrides * <code>@link * //apple_ref/cpp/instm/OSObject/taggedRelease/virtualvoid/(constvoid*,constint) * OSObject::taggedRelease(const void *, const int)@/link</code> * to synchronize with the symbol pool. * * @param tag Used for tracking collection references. * @param freeWhen If decrementing the reference count makes it * >= <code>freeWhen</code>, the object is immediately freed. * * @discussion * Because OSSymbol shares instances, the reference-counting functions * must synchronize access to the class-internal tables * used to track those instances. */ virtual void taggedRelease( const void * tag, const int freeWhen) const APPLE_KEXT_OVERRIDE; // xx-review: should we just omit this from headerdoc? /*! * @function free * * @abstract * Overrides * <code>@link * //apple_ref/cpp/instm/OSObject/free/virtualvoid/() * OSObject::free@/link</code> * to synchronize with the symbol pool. * * @discussion * Because OSSymbol shares instances, the reference-counting functions * must synchronize access to the class-internal tables * used to track those instances. */ virtual void free() APPLE_KEXT_OVERRIDE; public: // xx-review: should we just omit this from headerdoc? /*! * @function taggedRelease * * @abstract * Overrides * <code>@link * //apple_ref/cpp/instm/OSObject/taggedRelease/virtualvoid/(constvoid*) * OSObject::taggedRelease(const void *)@/link</code> * to synchronize with the symbol pool. * * @param tag Used for tracking collection references. * * @discussion * Because OSSymbol shares instances, the reference-counting functions * must synchronize access to the class-internal tables * used to track those instances. */ /* Original note (not for headerdoc): * The C++ language has forced me to override this method * even though I have implemented it as * <code>{ super::taggedRelease(tag) }</code>. * It seems that C++ is confused about the appearance of the protected * taggedRelease with 2 parameters and refuses to only inherit one function. * See * <code>@link * //apple_ref/cpp/instm/OSObject/taggedRelease/virtualvoid/(constvoid*,constint) * OSObject::taggedRelease(const void *, const int)@/link</code>. */ virtual void taggedRelease(const void * tag) const APPLE_KEXT_OVERRIDE; /*! * @function withString * * @abstract * Returns an OSSymbol created from an OSString, * or the existing unique instance of the same value. * * @param aString The OSString object to look up or copy. * * @result * An instance of OSSymbol * representing the same characters as <code>aString</code>; * <code>NULL</code> on failure. * * @discussion * This function creates or returns the unique OSSymbol instance * representing the string value of <code>aString</code>. * You can compare it with other OSSymbols using the <code>==</code> operator. * * OSSymbols are reference-counted normally. * This function either returns a * new OSSymbol with a retain count of 1, * or increments the retain count of the existing instance. */ static OSPtr<const OSSymbol> withString(const OSString * aString); /*! * @function withCString * * @abstract * Returns an OSSymbol created from a C string, * or the existing unique instance of the same value. * * @param cString The C string to look up or copy. * * @result * An instance of OSSymbol representing * the same characters as <code>cString</code>; * <code>NULL</code> on failure. * * @discussion * This function returns the unique OSSymbol instance * representing the string value of <code>cString</code>. * You can compare it with other OSSymbols using the <code>==</code> operator. * * OSSymbols are reference-counted normally. * This function either returns a * new OSSymbol with a retain count of 1, * or increments the retain count of the existing instance. */ static OSPtr<const OSSymbol> withCString(const char * cString); /*! * @function withCStringNoCopy * * @abstract * Returns an OSSymbol created from a C string, * without copying that string, * or the existing unique instance of the same value. * * @param cString The C string to look up or use. * @result * An instance of OSSymbol representing * the same characters as <code>cString</code>; * <code>NULL</code>. * * @discussion * Avoid using this function; * OSSymbols should own their internal string buffers. * * This function returns the unique OSSymbol instance * representing the string value of <code>cString</code>. * You can compare it with other OSSymbols using the <code>==</code> operator. * * OSSymbols are reference-counted normally. * This function either returns a * new OSSymbol with a retain count of 1, * or increments the retain count of the existing instance. */ static OSPtr<const OSSymbol> withCStringNoCopy(const char * cString); /*! * @function existingSymbolForString * * @abstract * Returns an existing OSSymbol for the given OSString. * * @param aString The OSString Object to look up. * * @result * An existing instance of OSSymbol representing * the same characters as <code>aString</code>; * <code>NULL</code> if none is found. * * @discussion * The returned OSSymbol object is returned with an incremented refcount * that needs to be released. */ static OSPtr<const OSSymbol> existingSymbolForString(const OSString *aString); /*! * @function existingSymbolForCString * * @abstract * Returns an existing OSSymbol for the given C string. * * @param aCString The C string to look up. * * @result * An existing instance of OSSymbol representing * the same characters as <code>aString</code>; * <code>NULL</code> if none is found. * * @discussion * The returned OSSymbol object is returned with an incremented refcount * that needs to be released. */ static OSPtr<const OSSymbol> existingSymbolForCString(const char *aCString); /*! * @function isEqualTo * * @abstract * Tests the equality of two OSSymbol objects. * * @param aSymbol The OSSymbol object being compared against the receiver. * * @result * <code>true</code> if the two OSSymbol objects are equivalent, * <code>false</code> otherwise. * * @discussion * Two OSSymbol objects are considered equal if they have the same address; * that is, this function is equivalent to the <code>==</code> operator. */ virtual bool isEqualTo(const OSSymbol * aSymbol) const; /*! * @function isEqualTo * * @abstract Tests the equality of an OSSymbol object with a C string. * * @param cString The C string to compare against the receiver. * * @result * <code>true</code> if the OSSymbol's characters * are equivalent to the C string's, * <code>false</code> otherwise. */ virtual bool isEqualTo(const char * cString) const APPLE_KEXT_OVERRIDE; /*! * @function isEqualTo * * @abstract Tests the equality of an OSSymbol object to an arbitrary object. * * @param anObject The object to be compared against the receiver. * @result Returns <code>true</code> if the two objects are equivalent, * <code>false</code> otherwise. * * @discussion * An OSSymbol is considered equal to another object * if that object is derived from * @link //apple_ref/doc/class/OSMetaClassBase OSString@/link * and contains the equivalent bytes of the same length. */ virtual bool isEqualTo(const OSMetaClassBase * anObject) const APPLE_KEXT_OVERRIDE; OSMetaClassDeclareReservedUnused(OSSymbol, 0); OSMetaClassDeclareReservedUnused(OSSymbol, 1); OSMetaClassDeclareReservedUnused(OSSymbol, 2); OSMetaClassDeclareReservedUnused(OSSymbol, 3); OSMetaClassDeclareReservedUnused(OSSymbol, 4); OSMetaClassDeclareReservedUnused(OSSymbol, 5); OSMetaClassDeclareReservedUnused(OSSymbol, 6); OSMetaClassDeclareReservedUnused(OSSymbol, 7); }; #endif /* !_OS_OSSYMBOL_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSDictionary.h
/* * Copyright (c) 2019 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@ */ /* * Copyright (c) 1998-1999 Apple Computer, Inc. All rights reserved. * * HISTORY * * OSDictionary.h created by rsulack on Wed 17-Sep-1997 * OSDictionary.h converted to C++ by gvdl on Fri 1998-10-30 */ #ifndef _IOKIT_IODICTIONARY_H #define _IOKIT_IODICTIONARY_H #include <libkern/c++/OSCollection.h> #include <libkern/c++/OSArray.h> #include <libkern/c++/OSPtr.h> #include <os/base.h> class OSArray; class OSSymbol; class OSString; class OSDictionary; typedef OSDictionary* OSDictionaryPtr; /*! * @header * * @abstract * This header declares the OSDictionary collection class. */ /*! * @class OSDictionary * * @abstract * OSDictionary provides an associative store using strings for keys. * * @discussion * OSDictionary is a container for Libkern C++ objects * (those derived from * @link //apple_ref/doc/class/OSMetaClassBase OSMetaClassBase@/link, * in particular @link //apple_ref/doc/class/OSObject OSObject@/link). * Storage and access are associative, based on string-valued keys * (C string, @link //apple_ref/cpp/cl/OSString OSString@/link, * or @link //apple_ref/cpp/cl/OSSymbol OSSymbol@/link). * When adding an object to an OSDictionary, you provide a string identifier, * which can then used to retrieve that object or remove it from the dictionary. * Setting an object with a key that already has an associated object * replaces the original object. * * You must generally cast retrieved objects from * @link //apple_ref/cpp/cl/OSObject OSObject@/link * to the desired class using * <code>@link //apple_ref/cpp/macro/OSDynamicCast OSDynamicCast@/link</code>. * This macro returns the object cast to the desired class, * or <code>NULL</code> if the object isn't derived from that class. * * When iterating an OSDictionary using * @link //apple_ref/doc/class/OSCollectionIterator OSCollectionIterator@/link, * the objects returned from * <code>@link //apple_ref/doc/function/OSCollectionIterator::getNextObject * getNextObject@/link</code> * are dictionary keys (not the object values for those keys). * You can use the keys to retrieve their associated object values. * * As with all Libkern collection classes, * OSDictionary retains keys and objects added to it, * and releases keys and objects removed from it (or replaced). * An OSDictionary also grows as necessary to accommodate new key/value pairs, * <i>unlike</i> Core Foundation collections (it does not, however, shrink). * * <b>Note:</b> OSDictionary currently uses a linear search algorithm, * and is not designed for high-performance access of many values. * It is intended as a simple associative-storage mechanism only. * * <b>Use Restrictions</b> * * With very few exceptions in the I/O Kit, all Libkern-based C++ * classes, functions, and macros are <b>unsafe</b> * to use in a primary interrupt context. * Consult the I/O Kit documentation related to primary interrupts * for more information. * * OSDictionary provides no concurrency protection; * it's up to the usage context to provide any protection necessary. * Some portions of the I/O Kit, such as * @link //apple_ref/doc/class/IORegistryEntry IORegistryEntry@/link, * handle synchronization via defined member functions for setting * properties. */ class OSDictionary : public OSCollection { friend class OSSerialize; OSDeclareDefaultStructors(OSDictionary); #if APPLE_KEXT_ALIGN_CONTAINERS protected: unsigned int count; unsigned int capacity; unsigned int capacityIncrement; struct dictEntry { OSTaggedPtr<const OSSymbol> key; OSTaggedPtr<const OSMetaClassBase> value; }; dictEntry * OS_PTRAUTH_SIGNED_PTR("OSDictionary.dictionary") dictionary; #else /* APPLE_KEXT_ALIGN_CONTAINERS */ protected: struct dictEntry { OSTaggedPtr<const OSSymbol> key; OSTaggedPtr<const OSMetaClassBase> value; }; dictEntry * OS_PTRAUTH_SIGNED_PTR("OSDictionary.dictionary") dictionary; unsigned int count; unsigned int capacity; unsigned int capacityIncrement; struct ExpansionData { }; /* Reserved for future use. (Internal use only) */ ExpansionData * reserved; #endif /* APPLE_KEXT_ALIGN_CONTAINERS */ // Member functions used by the OSCollectionIterator class. virtual unsigned int iteratorSize() const APPLE_KEXT_OVERRIDE; virtual bool initIterator(void * iterator) const APPLE_KEXT_OVERRIDE; virtual bool getNextObjectForIterator(void * iterator, OSObject ** ret) const APPLE_KEXT_OVERRIDE; public: /*! * @function withCapacity * * @abstract * Creates and initializes an empty OSDictionary. * * @param capacity The initial storage capacity of the new dictionary object. * * @result * An empty instance of OSDictionary * with a retain count of 1; * <code>NULL</code> on failure. * * @discussion * <code>capacity</code> must be nonzero. * The new dictionary will grow as needed to accommodate more key/object pairs * (<i>unlike</i> @link //apple_ref/doc/uid/20001497 CFMutableDictionary@/link, * for which the initial capacity is a hard limit). */ static OSPtr<OSDictionary> withCapacity(unsigned int capacity); /*! * @function withObjects * * @abstract Creates and initializes an OSDictionary * populated with keys and objects provided. * * @param objects A C array of OSMetaClassBase-derived objects. * @param keys A C array of OSSymbol keys * for the corresponding objects in <code>objects</code>. * @param count The number of keys and objects * to be placed into the dictionary. * @param capacity The initial storage capacity of the new dictionary object. * If 0, <code>count</code> is used; otherwise this value * must be greater than or equal to <code>count</code>. * * @result * An instance of OSDictionary * containing the key/object pairs provided, * with a retain count of 1; * <code>NULL</code> on failure. * * @discussion * <code>objects</code> and <code>keys</code> must be non-<code>NULL</code>, * and <code>count</code> must be nonzero. * If <code>capacity</code> is nonzero, * it must be greater than or equal to <code>count</code>. * The new dictionary will grow as needed * to accommodate more key/object pairs * (<i>unlike</i> * @link //apple_ref/doc/uid/20001497 CFMutableDictionary@/link, * for which the initial capacity is a hard limit). */ static OSPtr<OSDictionary> withObjects( const OSObject * objects[], const OSSymbol * keys[], unsigned int count, unsigned int capacity = 0); /*! * @function withObjects * * @abstract * Creates and initializes an OSDictionary * populated with keys and objects provided. * * @param objects A C array of OSMetaClassBase-derived objects. * @param keys A C array of OSString keys for the corresponding objects * in <code>objects</code>. * @param count The number of keys and objects * to be placed into the dictionary. * @param capacity The initial storage capacity of the new dictionary object. * If 0, <code>count</code> is used; otherwise this value * must be greater than or equal to <code>count</code>. * * @result * An instance of OSDictionary * containing the key/object pairs provided, * with a retain count of 1; * <code>NULL</code> on failure. * * @discussion * <code>objects</code> and <code>keys</code> must be non-<code>NULL</code>, * and <code>count</code> must be nonzero. * If <code>capacity</code> is nonzero, it must be greater than or equal to <code>count</code>. * The new dictionary will grow as needed * to accommodate more key/object pairs * (<i>unlike</i> * @link //apple_ref/doc/uid/20001497 CFMutableDictionary@/link, * for which the initial capacity is a hard limit). */ static OSPtr<OSDictionary> withObjects( const OSObject * objects[], const OSString * keys[], unsigned int count, unsigned int capacity = 0); /*! * @function withDictionary * * @abstract * Creates and initializes an OSDictionary * populated with the contents of another dictionary. * * @param dict A dictionary whose contents will be stored * in the new instance. * @param capacity The initial storage capacity of the new dictionary object. * If 0, the capacity is set to the number of key/value pairs * in <code>dict</code>; * otherwise <code>capacity</code> must be greater than or equal to * the number of key/value pairs in <code>dict</code>. * * @result * An instance of OSDictionary * containing the key/value pairs of <code>dict</code>, * with a retain count of 1; * <code>NULL</code> on failure. * * @discussion * <code>dict</code> must be non-<code>NULL</code>. * If <code>capacity</code> is nonzero, it must be greater than or equal to <code>count</code>. * The new dictionary will grow as needed * to accommodate more key/object pairs * (<i>unlike</i> * @link //apple_ref/doc/uid/20001497 CFMutableDictionary@/link, * for which the initial capacity is a hard limit). * * The keys and objects in <code>dict</code> are retained for storage * in the new OSDictionary, * not copied. */ static OSPtr<OSDictionary> withDictionary( const OSDictionary * dict, unsigned int capacity = 0); /*! * @function initWithCapacity * * @abstract * Initializes a new instance of OSDictionary. * * @param capacity The initial storage capacity of the new dictionary object. * @result * <code>true</code> on success, <code>false</code> on failure. * * @discussion * Not for general use. Use the static instance creation method * <code>@link //apple_ref/cpp/clm/OSDictionary/withCapacity/staticOSDictionary*\/(unsignedint) * withCapacity@/link</code> * instead. * * <code>capacity</code> must be nonzero. * The new dictionary will grow as needed * to accommodate more key/object pairs * (<i>unlike</i> * @link //apple_ref/doc/uid/20001497 CFMutableDictionary@/link, * for which the initial capacity is a hard limit). */ virtual bool initWithCapacity(unsigned int capacity); /*! * @function initWithObjects * * @abstract Initializes a new OSDictionary with keys and objects provided. * * @param objects A C array of OSMetaClassBase-derived objects. * @param keys A C array of OSSymbol keys * for the corresponding objects in <code>objects</code>. * @param count The number of keys and objects to be placed * into the dictionary. * @param capacity The initial storage capacity of the new dictionary object. * If 0, <code>count</code> is used; otherwise this value * must be greater than or equal to <code>count</code>. * * @result * <code>true</code> on success, <code>false</code> on failure. * * @discussion * Not for general use. Use the static instance creation method * <code>@link * //apple_ref/cpp/clm/OSDictionary/withObjects/staticOSDictionary*\/(constOSObject*,constOSString*,unsignedint,unsignedint) * withObjects@/link</code> * instead. * * <code>objects</code> and <code>keys</code> must be non-<code>NULL</code>, * and <code>count</code> must be nonzero. * If <code>capacity</code> is nonzero, * it must be greater than or equal to <code>count</code>. * The new dictionary will grow as neede * to accommodate more key/object pairs * (<i>unlike</i> * @link //apple_ref/doc/uid/20001497 CFMutableDictionary@/link, * for which the initial capacity is a hard limit). */ virtual bool initWithObjects( const OSObject * objects[], const OSSymbol * keys[], unsigned int count, unsigned int capacity = 0); /*! * @function initWithObjects * * @abstract * Initializes a new OSDictionary with keys and objects provided. * * @param objects A C array of OSMetaClassBase-derived objects. * @param keys A C array of OSString keys * for the corresponding objects in <code>objects</code>. * @param count The number of keys and objects * to be placed into the dictionary. * @param capacity The initial storage capacity of the new dictionary object. * If 0, <code>count</code> is used; otherwise this value * must be greater than or equal to <code>count</code>. * * @result * <code>true</code> on success, <code>false</code> on failure. * * @discussion * Not for general use. Use the static instance creation method * <code>@link * //apple_ref/cpp/clm/OSDictionary/withObjects/staticOSDictionary*\/(constOSObject*,constOSString*,unsignedint,unsignedint) * withObjects@/link</code> * instead. * * <code>objects</code> and <code>keys</code> must be non-<code>NULL</code>, * and <code>count</code> must be nonzero. * If <code>capacity</code> is nonzero, it must be greater than or equal to <code>count</code>. * The new dictionary will grow as needed * to accommodate more key/object pairs * (<i>unlike</i> * @link //apple_ref/doc/uid/20001497 CFMutableDictionary@/link, * for which the initial capacity is a hard limit). */ virtual bool initWithObjects( const OSObject * objects[], const OSString * keys[], unsigned int count, unsigned int capacity = 0); /*! * @function initWithDictionary * * @abstract * Initializes a new OSDictionary * with the contents of another dictionary. * * @param dict A dictionary whose contents will be placed * in the new instance. * @param capacity The initial storage capacity of the new dictionary object. * If 0, the capacity is set to the number of key/value pairs * in <code>dict</code>; * otherwise <code>capacity</code> must be greater than or equal to * the number of key/value pairs in <code>dict</code>. * * @result * <code>true</code> on success, <code>false</code> on failure. * * @discussion * Not for general use. Use the static instance creation method * <code>@link withDictionary withDictionary@/link</code> instead. * * <code>dict</code> must be non-<code>NULL</code>. * If <code>capacity</code> is nonzero, * it must be greater than or equal to <code>count</code>. * The new dictionary will grow as needed * to accommodate more key/object pairs * (<i>unlike</i> * @link //apple_ref/doc/uid/20001497 CFMutableDictionary@/link, * for which the initial capacity is a hard limit). * * The keys and objects in <code>dict</code> are retained for storage * in the new OSDictionary, * not copied. */ virtual bool initWithDictionary( const OSDictionary * dict, unsigned int capacity = 0); /*! * @function free * * @abstract * Deallocates or releases any resources * used by the OSDictionary instance. * * @discussion * This function should not be called directly, * use * <code>@link * //apple_ref/cpp/instm/OSObject/release/virtualvoid/() * release@/link</code> * instead. */ virtual void free() APPLE_KEXT_OVERRIDE; /*! * @function getCount * * @abstract * Returns the current number of key/object pairs * contained within the dictionary. * * @result * The current number of key/object pairs * contained within the dictionary. */ virtual unsigned int getCount() const APPLE_KEXT_OVERRIDE; /*! * @function getCapacity * * @abstract * Returns the number of objects the dictionary can store without reallocating. * * @result * The number objects the dictionary can store without reallocating. * * @discussion * OSDictionary objects grow when full * to accommodate additional key/object pairs. * See * <code>@link * //apple_ref/cpp/instm/OSDictionary/getCapacityIncrement/virtualunsignedint/() * getCapacityIncrement@/link</code> * and * <code>@link * //apple_ref/cpp/instm/OSDictionary/ensureCapacity/virtualunsignedint/(unsignedint) * ensureCapacity@/link</code>. */ virtual unsigned int getCapacity() const APPLE_KEXT_OVERRIDE; /*! * @function getCapacityIncrement * * @abstract * Returns the storage increment of the dictionary. * * @result * The storage increment of the dictionary. * * @discussion * An OSDictionary allocates storage for key/object pairs in multiples * of the capacity increment. */ virtual unsigned int getCapacityIncrement() const APPLE_KEXT_OVERRIDE; /*! * @function setCapacityIncrement * * @abstract * Sets the storage increment of the dictionary. * * @result * The new storage increment of the dictionary, * which may be different from the number requested. * * @discussion * An OSDictionary allocates storage for key/object pairs in multiples * of the capacity increment. * Calling this function does not immediately reallocate storage. */ virtual unsigned int setCapacityIncrement(unsigned increment) APPLE_KEXT_OVERRIDE; /*! * @function ensureCapacity * * @abstract * Ensures the dictionary has enough space * to store the requested number of key/object pairs. * * @param newCapacity The total number of key/object pairs the dictionary * should be able to store. * * @result * The new capacity of the dictionary, * which may be different from the number requested * (if smaller, reallocation of storage failed). * * @discussion * This function immediately resizes the dictionary, if necessary, * to accommodate at least <code>newCapacity</code> key/object pairs. * If <code>newCapacity</code> is not greater than the current capacity, * or if an allocation error occurs, the original capacity is returned. * * There is no way to reduce the capacity of an OSDictionary. */ virtual unsigned int ensureCapacity(unsigned int newCapacity) APPLE_KEXT_OVERRIDE; /*! * @function flushCollection * * @abstract * Removes and releases all keys and objects within the dictionary. * * @discussion * The dictionary's capacity (and therefore direct memory consumption) * is not reduced by this function. */ virtual void flushCollection() APPLE_KEXT_OVERRIDE; /*! * @function setObject * * @abstract * Stores an object in the dictionary under a key. * * @param aKey An OSSymbol identifying the object * placed within the dictionary. * It is automatically retained. * @param anObject The object to be stored in the dictionary. * It is automatically retained. * * @result * <code>true</code> if the addition was successful, * <code>false</code> otherwise. * * @discussion * An object already stored under <code>aKey</code> is released. */ virtual bool setObject( const OSSymbol * aKey, const OSMetaClassBase * anObject); bool setObject( OSSharedPtr<const OSSymbol> const& aKey, OSSharedPtr<const OSMetaClassBase> const& anObject); /*! * @function setObject * * @abstract Stores an object in the dictionary under a key. * * @param aKey An OSString identifying the object * placed within the dictionary. * @param anObject The object to be stored in the dictionary. * It is automatically retained. * * @result * <code>true</code> if the addition was successful, * <code>false</code> otherwise. * * @discussion * An OSSymbol for <code>aKey</code> is created internally. * An object already stored under <code>aKey</code> is released. */ virtual bool setObject( const OSString * aKey, const OSMetaClassBase * anObject); bool setObject( const OSString * aKey, OSSharedPtr<const OSMetaClassBase> const& anObject); /*! * @function setObject * * @abstract * Stores an object in the dictionary under a key. * * @param aKey A C string identifying the object * placed within the dictionary. * @param anObject The object to be stored in the dictionary. * It is automatically retained. * * @result * <code>true</code> if the addition was successful, * <code>false</code> otherwise. * * @discussion * An OSSymbol for <code>aKey</code> is created internally. * An object already stored under <code>aKey</code> is released. */ virtual bool setObject( const char * aKey, const OSMetaClassBase * anObject); bool setObject( const char * aKey, OSSharedPtr<const OSMetaClassBase> const& anObject); /*! * @function removeObject * * @abstract * Removes a key/object pair from the dictionary. * * @param aKey An OSSymbol identifying the object * to be removed from the dictionary. * * @discussion * The removed key (not necessarily <code>aKey</code> itself) * and object are automatically released. */ virtual void removeObject(const OSSymbol * aKey); /*! * @function removeObject * * @abstract * Removes a key/object pair from the dictionary. * * @param aKey A OSString identifying the object * to be removed from the dictionary. * * @discussion * The removed key (not necessarily <code>aKey</code> itself) * and object are automatically released. */ virtual void removeObject(const OSString * aKey); /*! * @function removeObject * * @abstract * Removes a key/object pair from the dictionary. * * @param aKey A C string identifying the object * to be removed from the dictionary. * * @discussion * The removed key (internally an OSSymbol) * and object are automatically released. */ virtual void removeObject(const char * aKey); /*! * @function merge * * @abstract * Merges the contents of a dictionary into the receiver. * * @param aDictionary The dictionary whose contents * are to be merged with the receiver. * @result * <code>true</code> if the merge succeeds, <code>false</code> otherwise. * * @discussion * If there are keys in <code>aDictionary</code> that match keys * in the receiving dictionary, * then the objects in the receiver are replaced * by those from <code>aDictionary</code>, * and the replaced objects are released. */ virtual bool merge(const OSDictionary * aDictionary); /*! * @function getObject * * @abstract * Returns the object stored under a given key. * * @param aKey An OSSymbol key identifying the object * to be returned to the caller. * * @result * The object stored under <code>aKey</code>, * or <code>NULL</code> if the key does not exist in the dictionary. * * @discussion * The returned object will be released if removed from the dictionary; * if you plan to store the reference, you should call * <code>@link * //apple_ref/cpp/instm/OSObject/retain/virtualvoid/() * retain@/link</code> * on that object. */ virtual OSObject * getObject(const OSSymbol * aKey) const; /*! * @function getObject * * @abstract Returns the object stored under a given key. * * @param aKey An OSString key identifying the object * to be returned to caller. * * @result * The object stored under <code>aKey</code>, * or <code>NULL</code> if the key does not exist in the dictionary. * * @discussion * The returned object will be released if removed from the dictionary; * if you plan to store the reference, you should call * <code>@link * //apple_ref/cpp/instm/OSObject/retain/virtualvoid/() * retain@/link</code> * on that object. */ virtual OSObject * getObject(const OSString * aKey) const; /*! * @function getObject * * @abstract * Returns the object stored under a given key. * * @param aKey A C string key identifying the object * to be returned to caller. * * @result * The object stored under <code>aKey</code>, * or <code>NULL</code> if the key does not exist in the dictionary. * * @discussion * The returned object will be released if removed from the dictionary; * if you plan to store the reference, you should call * <code>@link * //apple_ref/cpp/instm/OSObject/retain/virtualvoid/() * retain@/link</code> * on that object. */ virtual OSObject * getObject(const char * aKey) const; /*! * @function isEqualTo * * @abstract Tests the equality of two OSDictionary objects * over a subset of keys. * * @param aDictionary The dictionary to be compared against the receiver. * @param keys An OSArray or OSDictionary containing the keys * (as @link //apple_ref/cpp/cl/OSString OSStrings@/link or * @link //apple_ref/cpp/cl/OSSymbol OSSymbols@/link) * describing the intersection for the comparison. * * @result * <code>true</code> if the intersections * of the two dictionaries are equal. * * @discussion * Two OSDictionary objects are considered equal by this function * if both have objects stored for all keys provided, * and if the objects stored in each under * a given key compare as equal using * <code>@link * //apple_ref/cpp/instm/OSMetaClassBase/isEqualTo/virtualbool/(constOSMetaClassBase*) * isEqualTo@/link</code>. */ virtual bool isEqualTo( const OSDictionary * aDictionary, const OSCollection * keys) const; /*! * @function isEqualTo * * @abstract Tests the equality of two OSDictionary objects. * * @param aDictionary The dictionary to be compared against the receiver. * * @result * <code>true</code> if the dictionaries are equal, * <code>false</code> if not. * * @discussion * Two OSDictionary objects are considered equal if they have same count, * the same keys, and if the objects stored in each under * a given key compare as equal using * <code>@link * //apple_ref/cpp/instm/OSMetaClassBase/isEqualTo/virtualbool/(constOSMetaClassBase*) * isEqualTo@/link</code>. */ virtual bool isEqualTo(const OSDictionary * aDictionary) const; /*! * @function isEqualTo * * @abstract * Tests the equality of an OSDictionary to an arbitrary object. * * @param anObject An object to be compared against the receiver. * * @result * <code>true</code> if the objects are equal. * * @discussion * An OSDictionary is considered equal to another object * if that object is derived from OSDictionary * and contains the same or equivalent objects. */ virtual bool isEqualTo(const OSMetaClassBase * anObject) const APPLE_KEXT_OVERRIDE; /*! * @function serialize * * @abstract * Archives the receiver into the provided * @link //apple_ref/doc/class/OSSerialize OSSerialize@/link object. * * @param serializer The OSSerialize object. * * @result * <code>true</code> if serialization succeeds, <code>false</code> if not. */ virtual bool serialize(OSSerialize * serializer) const APPLE_KEXT_OVERRIDE; /*! * @function setOptions * * @abstract * Recursively sets option bits in the dictionary * and all child collections. * * @param options A bitfield whose values turn the options on (1) or off (0). * @param mask A mask indicating which bits * in <code>options</code> to change. * Pass 0 to get the whole current options bitfield * without changing any settings. * @param context Unused. * * @result * The options bitfield as it was before the set operation. * * @discussion * Kernel extensions should not call this function. * * Child collections' options are changed only if the receiving dictionary's * options actually change. */ virtual unsigned setOptions( unsigned options, unsigned mask, void * context = NULL) APPLE_KEXT_OVERRIDE; /*! * @function copyCollection * * @abstract * Creates a deep copy of the dictionary * and its child collections. * * @param cycleDict A dictionary of all of the collections * that have been copied so far, * which is used to track circular references. * To start the copy at the top level, * pass <code>NULL</code>. * * @result * The newly copied dictionary, with a retain count of 1, * or <code>NULL</code> if there is insufficient memory to do the copy. * * @discussion * The receiving dictionary, and any collections it contains, recursively, * are copied. * Objects that are not derived from OSCollection are retained * rather than copied. */ OSPtr<OSCollection> copyCollection(OSDictionary * cycleDict = NULL) APPLE_KEXT_OVERRIDE; /*! * @function iterateObjects * * @abstract * Invoke a callback for each member of the collection. * * @param refcon A reference constant for the callback. * @param callback The callback function, * called with the refcon and each member key & object * of the dictionary in turn, on the callers thread. * The callback should return true to early terminate * the iteration, false otherwise. * * @result * False if the dictionary iteration was made invalid * (see OSCollectionIterator::isValid()) otherwise true. */ bool iterateObjects(void * refcon, bool (*callback)(void * refcon, const OSSymbol * key, OSObject * object)); #ifdef __BLOCKS__ /*! * @function iterateObjects * * @abstract * Invoke a block for each member of the collection. * * @param block The block, * called with the refcon and each member key & object * of the dictionary in turn, on the callers thread. * The callback should return true to early terminate * the iteration, false otherwise. * * @result * False if the dictionary iteration was made invalid * (see OSCollectionIterator::isValid()) otherwise true. */ bool iterateObjects(bool (^block)(const OSSymbol * key, OSObject * object)); #endif /* __BLOCKS__ */ OSMetaClassDeclareReservedUnused(OSDictionary, 0); OSMetaClassDeclareReservedUnused(OSDictionary, 1); OSMetaClassDeclareReservedUnused(OSDictionary, 2); OSMetaClassDeclareReservedUnused(OSDictionary, 3); OSMetaClassDeclareReservedUnused(OSDictionary, 4); OSMetaClassDeclareReservedUnused(OSDictionary, 5); OSMetaClassDeclareReservedUnused(OSDictionary, 6); OSMetaClassDeclareReservedUnused(OSDictionary, 7); }; #endif /* !_IOKIT_IODICTIONARY_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/intrusive_shared_ptr.h
// // Copyright (c) 2019 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 XNU_LIBKERN_LIBKERN_CXX_INTRUSIVE_SHARED_PTR_H #define XNU_LIBKERN_LIBKERN_CXX_INTRUSIVE_SHARED_PTR_H namespace libkern { namespace isp_detail { // TODO: Consolidate these utilities with the ones used in other similar places. using nullptr_t = decltype(nullptr); template <typename T> T && declval() noexcept; template <typename ...> using void_t = void; template <typename T> struct is_lvalue_reference { static constexpr bool value = false; }; template <typename T> struct is_lvalue_reference<T&> { static constexpr bool value = true; }; template <typename T> constexpr bool is_lvalue_reference_v = is_lvalue_reference<T>::value; template <typename T> constexpr bool is_empty_v = __is_empty(T); template <typename T> struct remove_reference { using type = T; }; template <typename T> struct remove_reference<T&> { using type = T; }; template <typename T> struct remove_reference<T &&> { using type = T; }; template <typename T> using remove_reference_t = typename remove_reference<T>::type; template <bool Cond, typename T = void> struct enable_if; template <typename T> struct enable_if<true, T> { using type = T; }; template <bool Cond, typename T = void> using enable_if_t = typename enable_if<Cond, T>::type; template <typename From, typename To> constexpr bool is_convertible_v = __is_convertible_to(From, To); template <typename T> constexpr T && forward(remove_reference_t<T>&t) noexcept { return static_cast<T &&>(t); } template <typename T> constexpr T && forward(remove_reference_t<T>&& t) noexcept { static_assert(!is_lvalue_reference_v<T>, "can not forward an rvalue as an lvalue"); return static_cast<T &&>(t); } template <typename T> constexpr remove_reference_t<T>&& move(T && t) noexcept { using RvalueRef = remove_reference_t<T>&&; return static_cast<RvalueRef>(t); } template <typename T, typename U> using WhenComparable = void_t< decltype(declval<T>() == declval<U>()), decltype(declval<T>() != declval<U>()) >; } // end namespace isp_detail struct no_retain_t { explicit constexpr no_retain_t() { } }; struct retain_t { explicit constexpr retain_t() { } }; inline constexpr no_retain_t no_retain{}; inline constexpr retain_t retain{}; // Smart pointer representing a shared resource. // // This shared pointer class implements a refcounted resource that uses // a policy to manage the refcount. This allows various refcount // implementations, notably ones where the refcount is contained // in the pointed-to object. // // The refcounting policy must consist of the following two static functions: // // static void RefcountPolicy::retain(T&); // static void RefcountPolicy::release(T&); // // The `retain` function is called whenever a new reference to the pointed-to // object is created, and should increase the refcount. The `release` function // is called whenever a reference to the pointed-to object is removed, and // should decrease the refcount. These functions are always called with a // reference to a valid object, i.e. there is no need to check whether the // reference is null in `retain()` and `release()` (since this is already // handled by the shared pointer). // // One notable difference between this shared pointer and most other shared // pointer classes is that this shared pointer never destroys the pointed-to // object. It relies on the `release()` function to do it whenever the refcount // hits 0. // // Since this class represents a pointer to an object (as opposed to a range // of objects), pointer arithmetic is not allowed on `intrusive_shared_ptr`s. template <typename T, typename RefcountPolicy> struct __attribute__((trivial_abi)) intrusive_shared_ptr { static_assert(isp_detail::is_empty_v<RefcountPolicy>, "intrusive_shared_ptr only allows a stateless RefcountPolicy " "because it must be ABI compatible with raw pointers."); // TODO: Add a check that `T` can be used with the `RefcountPolicy` using pointer = T *; using element_type = T; // Constructs a null shared pointer. // // A null shared pointer can't be dereferenced, but it can be checked // for nullness, assigned to, reset, etc. constexpr intrusive_shared_ptr() noexcept : ptr_(nullptr) { } constexpr intrusive_shared_ptr(isp_detail::nullptr_t) noexcept : ptr_(nullptr) { } // Constructs a shared pointer to the given object, incrementing the // refcount for that object. // // This constructor is adequate when transforming a raw pointer with // shared ownership into a shared pointer, when the raw pointer is at // +1. This can be done by replacing the raw pointer and the manual call // to `retain()` by a shared pointer constructed with this constructor, // which will retain the pointed-to object. // // If the original code did not contain a manual retain and you use this // constructor, you will create a leak. explicit intrusive_shared_ptr(pointer p, retain_t) noexcept : ptr_(p) { if (ptr_ != nullptr) { RefcountPolicy::retain(*ptr_); } } // Constructs a shared pointer to the given object, without incrementing // the refcount for that object. // // This constructor is adequate when transforming a raw pointer with // shared ownership into a shared pointer, when the raw pointer is at // +0. This can be done by replacing the raw pointer by a shared // pointer constructed with this constructor, which does not retain // the pointed-to object. // // If the original code contained a manual retain that you removed and // you use this constructor, you will cause a use-after-free bug. explicit constexpr intrusive_shared_ptr(pointer p, no_retain_t) noexcept : ptr_(p) { } // Makes a copy of a shared pointer, incrementing the refcount. // // Since this creates a new reference to the pointed-to object, the // refcount is increased. Unlike for move operations, the source // pointer is left untouched. intrusive_shared_ptr(intrusive_shared_ptr const & other) : ptr_(other.ptr_) { if (ptr_ != nullptr) { RefcountPolicy::retain(*ptr_); } } // Makes a copy of a shared pointer from another compatible shared pointer, // increasing the refcount. // // This converting constructor is enabled whenever `U*` is implicitly // convertible to `T*`. This allows the usual implicit conversions // between base-and-derived types. // // Since this creates a new reference to the pointed-to object, the // refcount is increased. Unlike for move operations, the source // pointer is left untouched. template <typename U, typename = isp_detail::enable_if_t<isp_detail::is_convertible_v<U*, T*> > > intrusive_shared_ptr(intrusive_shared_ptr<U, RefcountPolicy> const & other) : ptr_(other.ptr_) { if (ptr_ != nullptr) { RefcountPolicy::retain(*ptr_); } } // Moves a shared pointer into another one, nulling the source. // // Since this moves the ownership from one pointer to another, no // refcount increment or decrement is required. The moved-from pointer // becomes a null pointer, as if it had been default-constructed. constexpr intrusive_shared_ptr(intrusive_shared_ptr && other) noexcept : ptr_(other.ptr_) { other.ptr_ = nullptr; } // Moves a shared pointer to a type `U` into a shared pointer // to a type `T`. // // This converting constructor is enabled whenever `U*` is implicitly // convertible to `T*`. This allows the usual implicit conversions // between base-and-derived types. // // Since this moves the ownership from one pointer to another, no // refcount increment or decrement is required. The moved-from pointer // becomes a null pointer, as if it had been default-constructed. template <typename U, typename = isp_detail::enable_if_t<isp_detail::is_convertible_v<U*, T*> > > constexpr intrusive_shared_ptr(intrusive_shared_ptr<U, RefcountPolicy>&& other) noexcept : ptr_(other.ptr_) { other.ptr_ = nullptr; } // Destroys a shared pointer. // // The destruction of the shared pointer implies that one fewer reference // to the pointed-to object exist, which means that the refcount of the // pointed-to object is decremented. // // If that decrement causes the refcount to reach 0, the refcounting // policy must destroy the pointed-to object and perform any cleanup // associated to it (such as freeing the allocated memory). ~intrusive_shared_ptr() { reset(); } // Copy-assigns a shared pointer. // // Since this creates a new reference to the pointed-to object, the // refcount is increased. Unlike for move operations, the source // pointer is left untouched. // // If the destination shared pointer is pointing to an object before // the assignment, the refcount is decremented on that object after // the assignment is performed. intrusive_shared_ptr& operator=(intrusive_shared_ptr const& other) { reset(other.get(), retain); return *this; } // Copy-assigns a shared pointer, enabling implicit conversions. // // This converting copy-assignment is enabled whenever `U*` is implicitly // convertible to `T*`. This allows the usual implicit conversions // between base-and-derived types. // // Since this creates a new reference to the pointed-to object, the // refcount is increased. Unlike for move operations, the source // pointer is left untouched. // // If the destination shared pointer is pointing to an object before // the assignment, the refcount is decremented on that object after // the assignment is performed. template <typename U, typename = isp_detail::enable_if_t<isp_detail::is_convertible_v<U*, T*> > > intrusive_shared_ptr& operator=(intrusive_shared_ptr<U, RefcountPolicy> const& other) { reset(other.get(), retain); return *this; } // Move-assigns a shared pointer. // // Since this moves the ownership from one pointer to another, no // refcount increment or decrement is required. The moved-from pointer // becomes a null pointer, as if it had been default-constructed. // // If the destination shared pointer is pointing to an object before // the assignment, the refcount is decremented on that object after // the assignment is performed. intrusive_shared_ptr& operator=(intrusive_shared_ptr&& other) { reset(other.get(), no_retain); other.ptr_ = nullptr; return *this; } // Move-assigns a shared pointer, enabling implicit conversions. // // This converting move-assignment is enabled whenever `U*` is implicitly // convertible to `T*`. This allows the usual implicit conversions // between base-and-derived types. // // Since this moves the ownership from one pointer to another, no // refcount increment or decrement is required. The moved-from pointer // becomes a null pointer, as if it had been default-constructed. // // If the destination shared pointer is pointing to an object before // the assignment, the refcount is decremented on that object after // the assignment is performed. template <typename U, typename = isp_detail::enable_if_t<isp_detail::is_convertible_v<U*, T*> > > intrusive_shared_ptr& operator=(intrusive_shared_ptr<U, RefcountPolicy>&& other) { reset(other.get(), no_retain); other.ptr_ = nullptr; return *this; } // Resets a shared pointer to a null pointer, as if calling `reset()`. // // If the destination shared pointer is pointing to an object before // the assignment, the refcount is decremented on that object after // the assignment is performed. intrusive_shared_ptr& operator=(isp_detail::nullptr_t) noexcept { reset(); return *this; } // Returns a reference to the object pointed-to by the shared pointer. constexpr T& operator*() const noexcept { return *ptr_; } constexpr pointer operator->() const noexcept { return ptr_; } // Implicit conversion to bool, returning whether the shared pointer is null. explicit constexpr operator bool() const noexcept { return ptr_ != nullptr; } // Sets a shared pointer to null. // // If the shared pointer is pointing to an object, the refcount is // decremented on that object. intrusive_shared_ptr& reset() noexcept { if (ptr_ != nullptr) { RefcountPolicy::release(*ptr_); } ptr_ = nullptr; return *this; } // Sets the object pointed-to by the shared pointer to the given object. // // This variant of `reset()` does not increment the refcount on the object // assigned to the shared pointer. // // If the shared pointer is pointing to an object before calling `reset`, // the refcount is decremented on that object. intrusive_shared_ptr& reset(pointer p, no_retain_t) noexcept { if (ptr_ != nullptr) { RefcountPolicy::release(*ptr_); } ptr_ = p; return *this; } // Sets the object pointed-to by the shared pointer to the given object. // // This variant of `reset()` increments the refcount on the object // assigned to the shared pointer. // // If the shared pointer is pointing to an object before calling `reset`, // the refcount is decremented on that object. intrusive_shared_ptr& reset(pointer p, retain_t) noexcept { // Make sure we don't release-before-we-retain in case of self-reset pointer old = ptr_; ptr_ = p; if (ptr_ != nullptr) { RefcountPolicy::retain(*ptr_); } if (old != nullptr) { RefcountPolicy::release(*old); } return *this; } // Retrieves the raw pointer held by a shared pointer. // // The primary intended usage of this function is to aid bridging between // code that uses shared pointers and code that does not, or simply to // obtain a non-owning reference to the object managed by the shared pointer. // // After this operation, the shared pointer still manages the object it // points to (unlike for `detach()`). // // One must not hold on to the pointer returned by `.get()` after the // last shared pointer pointing to that object goes out of scope, since // it will then be a dangling pointer. To try and catch frequent cases of // misuse, calling `.get()` on a temporary shared pointer is not allowed. constexpr pointer get() const & noexcept { return ptr_; } constexpr pointer get() const&& noexcept = delete; // Returns the raw pointer contained in a shared pointer, detaching // ownership management from the shared pointer. // // This operation returns a pointer to the object pointed-to by the // shared pointer, and severes the link between the shared pointer and // that object. After this operation, the shared pointer is no longer // responsible for managing the object, and instead whoever called // `detach()` has that responsibility. // // `detach()` does _not_ decrement the refcount of the pointee, since // the caller of `detach()` is responsible for managing the lifetime of // that object. // // After a call to `detach()`, the shared pointer is null since it has // no more object to manage. constexpr pointer detach() noexcept { pointer tmp = ptr_; ptr_ = nullptr; return tmp; } private: friend constexpr void swap(intrusive_shared_ptr& a, intrusive_shared_ptr& b) noexcept { pointer tmp = a.ptr_; a.ptr_ = b.ptr_; b.ptr_ = tmp; } // For access to other.ptr_ in converting operations template <typename U, typename Policy> friend struct intrusive_shared_ptr; pointer ptr_; }; // Casts a shared pointer to a type `T` to a shared pointer to a type `U` // using `static_cast` on the underlying pointer type. // // The version of this function that takes a const reference to the source // shared pointer makes a copy, and as such it increments the refcount of the // pointed-to object (since a new reference is created). It leaves the source // shared pointer untouched. // // The version of this function that takes a rvalue-reference moves the // ownership from the source shared pointer to the destination shared pointer. // It does not increment the refcount, and the source shared pointer is in a // moved-from state (i.e. null). template <typename To, typename From, typename R> intrusive_shared_ptr<To, R> static_pointer_cast(intrusive_shared_ptr<From, R> const& ptr) { return intrusive_shared_ptr<To, R>(static_cast<To*>(ptr.get()), retain); } template <typename To, typename From, typename R> intrusive_shared_ptr<To, R> static_pointer_cast(intrusive_shared_ptr<From, R>&& ptr) { return intrusive_shared_ptr<To, R>(static_cast<To*>(ptr.detach()), no_retain); } // Const-casts a shared pointer to a type `cv-T` to a shared pointer to a // type `T` (without cv-qualifiers) using `const_cast` on the underlying // pointer type. // // The version of this function that takes a const reference to the source // shared pointer makes a copy, and as such it increments the refcount of the // pointed-to object (since a new reference is created). It leaves the source // shared pointer untouched. // // The version of this function that takes a rvalue-reference moves the // ownership from the source shared pointer to the destination shared pointer. // It does not increment the refcount, and the source shared pointer is in a // moved-from state (i.e. null). template <typename To, typename From, typename R> intrusive_shared_ptr<To, R> const_pointer_cast(intrusive_shared_ptr<From, R> const& ptr) noexcept { return intrusive_shared_ptr<To, R>(const_cast<To*>(ptr.get()), retain); } template <typename To, typename From, typename R> intrusive_shared_ptr<To, R> const_pointer_cast(intrusive_shared_ptr<From, R>&& ptr) noexcept { return intrusive_shared_ptr<To, R>(const_cast<To*>(ptr.detach()), no_retain); } // Casts a shared pointer to a type `T` to a shared pointer to a type `U` // using `reinterpret_cast` on the underlying pointer type. // // The version of this function that takes a const reference to the source // shared pointer makes a copy, and as such it increments the refcount of the // pointed-to object (since a new reference is created). It leaves the source // shared pointer untouched. // // The version of this function that takes a rvalue-reference moves the // ownership from the source shared pointer to the destination shared pointer. // It does not increment the refcount, and the source shared pointer is in a // moved-from state (i.e. null). // // WARNING: // This function makes it possible to cast pointers between unrelated types. // This rarely makes sense, and when it does, it can often point to a design // problem. You should have red lights turning on when you're about to use // this function. template<typename To, typename From, typename R> intrusive_shared_ptr<To, R> reinterpret_pointer_cast(intrusive_shared_ptr<From, R> const& ptr) noexcept { return intrusive_shared_ptr<To, R>(reinterpret_cast<To*>(ptr.get()), retain); } template<typename To, typename From, typename R> intrusive_shared_ptr<To, R> reinterpret_pointer_cast(intrusive_shared_ptr<From, R>&& ptr) noexcept { return intrusive_shared_ptr<To, R>(reinterpret_cast<To*>(ptr.detach()), no_retain); } // Comparison operations between: // - two shared pointers // - a shared pointer and nullptr_t // - a shared pointer and a raw pointer template <typename T, typename U, typename R, typename = isp_detail::WhenComparable<T*, U*> > bool operator==(intrusive_shared_ptr<T, R> const& x, intrusive_shared_ptr<U, R> const& y) { return x.get() == y.get(); } template <typename T, typename U, typename R, typename = isp_detail::WhenComparable<T*, U*> > bool operator!=(intrusive_shared_ptr<T, R> const& x, intrusive_shared_ptr<U, R> const& y) { return x.get() != y.get(); } template <typename T, typename U, typename R, typename = isp_detail::WhenComparable<T*, U*> > bool operator==(intrusive_shared_ptr<T, R> const& x, U* y) { return x.get() == y; } template <typename T, typename U, typename R, typename = isp_detail::WhenComparable<T*, U*> > bool operator!=(intrusive_shared_ptr<T, R> const& x, U* y) { return x.get() != y; } template <typename T, typename U, typename R, typename = isp_detail::WhenComparable<T*, U*> > bool operator==(T* x, intrusive_shared_ptr<U, R> const& y) { return x == y.get(); } template <typename T, typename U, typename R, typename = isp_detail::WhenComparable<T*, U*> > bool operator!=(T* x, intrusive_shared_ptr<U, R> const& y) { return x != y.get(); } template <typename T, typename R> bool operator==(intrusive_shared_ptr<T, R> const& x, isp_detail::nullptr_t) noexcept { return x.get() == nullptr; } template <typename T, typename R> bool operator==(isp_detail::nullptr_t, intrusive_shared_ptr<T, R> const& x) noexcept { return nullptr == x.get(); } template <typename T, typename R> bool operator!=(intrusive_shared_ptr<T, R> const& x, isp_detail::nullptr_t) noexcept { return x.get() != nullptr; } template <typename T, typename R> bool operator!=(isp_detail::nullptr_t, intrusive_shared_ptr<T, R> const& x) noexcept { return nullptr != x.get(); } } // end namespace libkern #endif // !XNU_LIBKERN_LIBKERN_CXX_INTRUSIVE_SHARED_PTR_H
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSData.h
/* * Copyright (c) 2000-2019 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@ */ /* IOData.h created by rsulack on Wed 17-Sep-1997 */ /* IOData.h converted to C++ by gvdl on Fri 1998-10-30 */ #ifndef _OS_OSDATA_H #define _OS_OSDATA_H #include <libkern/c++/OSObject.h> #include <libkern/c++/OSPtr.h> #include <os/base.h> class OSData; class OSString; typedef OSData* OSDataPtr; typedef OSData const* OSDataConstPtr; /*! * @header * * @abstract * This header declares the OSData container class. */ /*! * @class OSData * * @abstract * OSData wraps an array of bytes in a C++ object * for use in Libkern collections. * * @discussion * OSData represents an array of bytes as a Libkern C++ object. * OSData objects are mutable: * You can add bytes to them and * overwrite portions of the byte array. * * <b>Use Restrictions</b> * * With very few exceptions in the I/O Kit, all Libkern-based C++ * classes, functions, and macros are <b>unsafe</b> * to use in a primary interrupt context. * Consult the I/O Kit documentation related to primary interrupts * for more information. * * OSData provides no concurrency protection; * it's up to the usage context to provide any protection necessary. * Some portions of the I/O Kit, such as * @link //apple_ref/doc/class/IORegistryEntry IORegistryEntry@/link, * handle synchronization via defined member functions for setting * properties. */ class OSData : public OSObject { friend class OSSerialize; OSDeclareDefaultStructors(OSData); #if APPLE_KEXT_ALIGN_CONTAINERS protected: unsigned int length; unsigned int capacity; unsigned int capacityIncrement; void * OS_PTRAUTH_SIGNED_PTR("OSData.data") data; #else /* APPLE_KEXT_ALIGN_CONTAINERS */ protected: void * OS_PTRAUTH_SIGNED_PTR("OSData.data") data; unsigned int length; unsigned int capacity; unsigned int capacityIncrement; #endif /* APPLE_KEXT_ALIGN_CONTAINERS */ private: typedef void (*DeallocFunction)(void * ptr, unsigned int length); protected: struct ExpansionData; /* Reserved for future use. (Internal use only) */ ExpansionData * reserved; public: /*! * @function withCapacity * * @abstract * Creates and initializes an empty instance of OSData. * * @param capacity The initial capacity of the OSData object in bytes. * * @result * An instance of OSData with a reference count of 1; * <code>NULL</code> on failure. * * @discussion * <code>capacity</code> may be zero. * The OSData object will allocate a buffer internally * when necessary, and will grow as needed to accommodate more bytes * (<i>unlike</i> @link //apple_ref/doc/uid/20001498 CFMutableData@/link, * for which a nonzero initial capacity is a hard limit). */ static OSPtr<OSData> withCapacity(unsigned int capacity); /*! * @function withBytes * * @abstract * Creates and initializes an instance of OSData * with a copy of the provided data buffer. * * @param bytes The buffer of data to copy. * @param numBytes The length of <code>bytes</code>. * * @result * An instance of OSData containing a copy of the provided byte array, * with a reference count of 1; * <code>NULL</code> on failure. * * @discussion * The new OSData object will grow as needed to accommodate more bytes * (<i>unlike</i> @link //apple_ref/doc/uid/20001498 CFMutableData@/link, * for which a nonzero initial capacity is a hard limit). */ static OSPtr<OSData> withBytes( const void * bytes, unsigned int numBytes); /*! * @function withBytesNoCopy * * @abstract * Creates and initializes an instance of OSData * that shares the provided data buffer. * * @param bytes The buffer of data to represent. * @param numBytes The length of <code>bytes</code>. * * @result * A instance of OSData that shares the provided byte array, * with a reference count of 1; * <code>NULL</code> on failure. * * @discussion * An OSData object created with this function * does not claim ownership * of the data buffer, but shares it with the caller. * When the caller determines that the OSData object has actually been freed, * it can safely dispose of the data buffer. * Conversely, if it frees the shared data buffer, * it must not attempt to use the OSData object and should release it. * * An OSData object created with shared external data cannot append bytes, * but you can get the byte pointer and * modify bytes within the shared buffer. */ static OSPtr<OSData> withBytesNoCopy( void * bytes, unsigned int numBytes); /*! * @function withData * * @abstract * Creates and initializes an instance of OSData * with contents copied from another OSData object. * * @param inData An OSData object that provides the initial data. * * @result * An instance of OSData containing a copy of the data in <code>inData</code>, * with a reference count of 1; * <code>NULL</code> on failure. * * @discussion * The new OSData object will grow as needed to accommodate more bytes * (<i>unlike</i> @link //apple_ref/doc/uid/20001498 CFMutableData@/link, * for which a nonzero initial capacity is a hard limit). */ static OSPtr<OSData> withData(const OSData * inData); /*! * @function withData * * @abstract * Creates and initializes an instance of OSData * with contents copied from a range within another OSData object. * * @param inData An OSData object that provides the initial data. * @param start The starting index from which bytes will be copied. * @param numBytes The number of bytes to be copied from <code>start</code>. * * @result * An instance of OSData containing a copy * of the specified data range from <code>inData</code>, * with a reference count of 1; * <code>NULL</code> on failure. * * @discussion * The new OSData object will grow as needed to accommodate more bytes * (<i>unlike</i> @link //apple_ref/doc/uid/20001498 CFMutableData@/link, * for which a nonzero initial capacity is a hard limit). */ static OSPtr<OSData> withData( const OSData * inData, unsigned int start, unsigned int numBytes); /*! * @function initWithCapacity * * @abstract * Initializes an instance of OSData. * * @param capacity The initial capacity of the OSData object in bytes. * * @result * <code>true</code> on success, <code>false</code> on failure. * * @discussion * Not for general use. Use the static instance creation method * <code>@link * //apple_ref/cpp/clm/OSData/withCapacity/staticOSData*\/(unsignedint) * withCapacity@/link</code> instead. * * <code>capacity</code> may be zero. * The OSData object will allocate a buffer internally * when necessary, and will grow as needed to accommodate more bytes * (<i>unlike</i> @link //apple_ref/doc/uid/20001498 CFMutableData@/link, * for which a nonzero initial capacity is a hard limit). */ virtual bool initWithCapacity(unsigned int capacity); /*! * @function initWithBytes * * @abstract * Initializes an instance of OSData * with a copy of the provided data buffer. * * @param bytes The buffer of data to copy. * @param numBytes The length of <code>bytes</code>. * * @result * <code>true</code> on success, <code>false</code> on failure. * * @discussion * Not for general use. Use the static instance creation method * <code>@link withBytes withBytes@/link</code> instead. * * The new OSData object will grow as needed to accommodate more bytes * (<i>unlike</i> @link //apple_ref/doc/uid/20001498 CFMutableData@/link, * for which a nonzero initial capacity is a hard limit). */ virtual bool initWithBytes( const void * bytes, unsigned int numBytes); /*! * @function initWithBytesNoCopy * * @abstract * Initializes an instance of OSData * to share the provided data buffer. * * @param bytes The buffer of data to represent. * @param numBytes The length of <code>bytes</code>. * * @result * <code>true</code> on success, <code>false</code> on failure. * * @discussion * Not for general use. Use the static instance creation method * <code>@link withBytesNoCopy withBytesNoCopy@/link</code> instead. * * An OSData object initialized with this function * does not claim ownership * of the data buffer, but merely shares it with the caller. * * An OSData object created with shared external data cannot append bytes, * but you can get the byte pointer and * modify bytes within the shared buffer. */ virtual bool initWithBytesNoCopy( void * bytes, unsigned int numBytes); /*! * @function initWithData * * @abstract * Creates and initializes an instance of OSData * with contents copied from another OSData object. * * @param inData An OSData object that provides the initial data. * * @result * <code>true</code> on success, <code>false</code> on failure. * * @discussion * Not for general use. Use the static instance creation method * <code>@link * //apple_ref/cpp/clm/OSData/withData/staticOSData*\/(constOSData*) * withData(OSData *)@/link</code> * instead. * * The new OSData object will grow as needed to accommodate more bytes * (<i>unlike</i> @link //apple_ref/doc/uid/20001498 CFMutableData@/link, * for which a nonzero initial capacity is a hard limit). */ virtual bool initWithData(const OSData * inData); /*! * @function initWithData * * @abstract * Initializes an instance of OSData * with contents copied from a range within another OSData object. * * @param inData An OSData object that provides the initial data. * @param start The starting index from which bytes will be copied. * @param numBytes The number of bytes to be copied from <code>start</code>. * * @result * Returns <code>true</code> on success, <code>false</code> on failure. * * @discussion * Not for general use. Use the static instance creation method * <code>@link * //apple_ref/cpp/clm/OSData/withData/staticOSData*\/(constOSData*,unsignedint,unsignedint) * withData(OSData *, unsigned int, unsigned int)@/link</code> * instead. * * The new OSData object will grow as needed to accommodate more bytes * (<i>unlike</i> @link //apple_ref/doc/uid/20001498 CFMutableData@/link, * for which a nonzero initial capacity is a hard limit). */ virtual bool initWithData( const OSData * inData, unsigned int start, unsigned int numBytes); /*! * @function free * * @abstract * Deallocates or releases any resources * used by the OSData instance. * * @discussion * This function should not be called directly; * use * <code>@link * //apple_ref/cpp/instm/OSObject/release/virtualvoid/() * release@/link</code> * instead. */ virtual void free() APPLE_KEXT_OVERRIDE; /*! * @function getLength * * @abstract * Returns the number of bytes in or referenced by the OSData object. * * @result * The number of bytes in or referenced by the OSData object. */ virtual unsigned int getLength() const; /*! * @function getCapacity * * @abstract * Returns the total number of bytes the OSData can store without reallocating. * * @result * The total number bytes the OSData can store without reallocating. * * @discussion * OSData objects grow when full to accommodate additional bytes. * See * <code>@link * //apple_ref/cpp/instm/OSData/getCapacityIncrement/virtualunsignedint/() * getCapacityIncrement@/link</code> * and * <code>@link * //apple_ref/cpp/instm/OSData/ensureCapacity/virtualunsignedint/(unsignedint) * ensureCapacity@/link</code>. * * OSData objects created or initialized to use a shared buffer * do not make use of this attribute, and return -1 from this function. */ virtual unsigned int getCapacity() const; /*! * @function getCapacityIncrement * * @abstract * Returns the storage increment of the OSData object. * * @result * The storage increment of the OSData object. * * @discussion * An OSData object allocates storage for bytes in multiples * of the capacity increment. * * OSData objects created or initialized to use a shared buffer * do not make use of this attribute. */ virtual unsigned int getCapacityIncrement() const; /*! * @function setCapacityIncrement * * @abstract * Sets the storage increment of the array. * * @result * The original storage increment of the array. * * @discussion * An OSArray allocates storage for objects in multiples * of the capacity increment. * * OSData objects created or initialized to use a shared buffer * do not make use of this attribute. */ virtual unsigned int setCapacityIncrement(unsigned increment); // xx-review: does not check for capacity == EXTERNAL /*! * @function ensureCapacity * * @abstract * Ensures the array has enough space * to store the requested number of bytes. * * @param newCapacity The total number of bytes the OSData object * should be able to store. * * @result * Returns the new capacity of the OSData object, * which may be different from the number requested * (if smaller, reallocation of storage failed). * * @discussion * This function immediately resizes the OSData's buffer, if necessary, * to accommodate at least <code>newCapacity</code> bytes. * If <code>newCapacity</code> is not greater than the current capacity, * or if an allocation error occurs, the original capacity is returned. * * There is no way to reduce the capacity of an OSData. * * An OSData object created "NoCopy" does not allow resizing. */ virtual unsigned int ensureCapacity(unsigned int newCapacity); /*! * @function appendBytes * * @abstract * Appends a buffer of bytes to the OSData object's internal data buffer. * * @param bytes A pointer to the data to append. * If <code>bytes</code> is <code>NULL</code> * then a zero-filled buffer of length <code>numBytes</code> * is appended. * @param numBytes The number of bytes from <code>bytes</code> to append. * * @result * <code>true</code> if the new data was successfully added, * <code>false</code> on failure. * * @discussion * This function immediately resizes the OSData's buffer, if necessary, * to accommodate the new total size. * * An OSData object created "NoCopy" does not allow bytes * to be appended. */ virtual bool appendBytes( const void * bytes, unsigned int numBytes); /*! * @function appendBytes * * @abstract * Appends the data contained in another OSData object. * * @param aDataObj The OSData object whose contents will be appended. * * @result * <code>true</code> if the new data was successfully added, * <code>false</code> on failure. * * @discussion * This function immediately resizes the OSData's buffer, if necessary, * to accommodate the new total size. * * An OSData object created "NoCopy" does not allow bytes * to be appended. */ virtual bool appendBytes(const OSData * aDataObj); /*! * @function getBytesNoCopy * * @abstract * Returns a pointer to the OSData object's internal data buffer. * * @result * A pointer to the OSData object's internal data buffer. * * @discussion * You can modify the existing contents of an OSData object * via this function. * It works with OSData objects that have their own data buffers * as well as with OSData objects that have shared buffers. * * If you append bytes or characters to an OSData object, * it may have to reallocate its internal storage, * rendering invalid an extrated pointer to that storage. */ virtual const void * getBytesNoCopy() const; /*! * @function getBytesNoCopy * * @abstract * Returns a pointer into the OSData object's internal data buffer * with a given offset and length. * * @param start The offset from the base of the internal data buffer. * @param numBytes The length of the window. * * @result * A pointer to the bytes in the specified range * within the OSData object, * or 0 if that range does not lie completely * within the object's buffer. * * @discussion * You can modify the existing contents of an OSData object * via this function. * It works with OSData objects that have their own data buffers * as well as with OSData objects that have shared buffers. * * If you append bytes or characters to an OSData object, * it may have to reallocate its internal storage, * rendering invalid an extrated pointer to that storage. */ virtual const void * getBytesNoCopy( unsigned int start, unsigned int numBytes) const; /*! * @function isEqualTo * * @abstract * Tests the equality of two OSData objects. * * @param aDataObj The OSData object being compared against the receiver. * * @result * <code>true</code> if the two OSData objects are equivalent, * <code>false</code> otherwise. * * @discussion * Two OSData objects are considered equal * if they have same length and if their * byte buffers hold the same contents. */ virtual bool isEqualTo(const OSData * aDataObj) const; /*! * @function isEqualTo * * @abstract * Tests the equality of an OSData object's contents * to a C array of bytes. * * @param bytes A pointer to the bytes to compare. * @param numBytes The number of bytes to compare. * * @result * <code>true</code> if the data buffers are equal * over the given length, * <code>false</code> otherwise. */ virtual bool isEqualTo( const void * bytes, unsigned int numBytes) const; /*! * @function isEqualTo * * @abstract * Tests the equality of an OSData object to an arbitrary object. * * @param anObject The object to be compared against the receiver. * * @result * <code>true</code> if the two objects are equivalent, * <code>false</code> otherwise. * * @discussion * An OSData is considered equal to another object * if that object is derived from OSData * and contains the equivalent bytes of the same length. */ virtual bool isEqualTo(const OSMetaClassBase * anObject) const APPLE_KEXT_OVERRIDE; /*! * @function isEqualTo * * @abstract * Tests the equality of an OSData object to an OSString. * * @param aString The string object to be compared against the receiver. * * @result * <code>true</code> if the two objects are equivalent, * <code>false</code> otherwise. * * @discussion * This function compares the bytes of the OSData object * against those of the OSString, * accounting for the possibility that an OSData * might explicitly include a nul * character as part of its total length. * Thus, for example, an OSData object containing * either the bytes <'u', 's', 'b', '\0'> * or <'u', 's', 'b'> * will compare as equal to the OSString containing "usb". */ virtual bool isEqualTo(const OSString * aString) const; /*! * @function serialize * * @abstract * Archives the receiver into the provided * @link //apple_ref/doc/class/IORegistryEntry OSSerialize@/link object. * * @param serializer The OSSerialize object. * * @result * <code>true</code> if serialization succeeds, <code>false</code> if not. */ virtual bool serialize(OSSerialize * serializer) const APPLE_KEXT_OVERRIDE; /*! * @function appendByte * * @abstract * Appends a single byte value * to the OSData object's internal data buffer * a specified number of times. * * @param byte The byte value to append. * @param numBytes The number of copies of <code>byte</code> to append. * * @result * <code>true</code> if the new data was successfully added, * <code>false</code> if not. * * @discussion * This function immediately resizes the OSData's buffer, if necessary, * to accommodate the new total size. * * An OSData object created "NoCopy" does not allow bytes * to be appended. */ virtual bool appendByte( unsigned char byte, unsigned int numBytes); void setSerializable(bool serializable); private: virtual void setDeallocFunction(DeallocFunction func); bool isSerializable(void); private: OSMetaClassDeclareReservedUsedX86(OSData, 0); OSMetaClassDeclareReservedUnused(OSData, 1); OSMetaClassDeclareReservedUnused(OSData, 2); OSMetaClassDeclareReservedUnused(OSData, 3); OSMetaClassDeclareReservedUnused(OSData, 4); OSMetaClassDeclareReservedUnused(OSData, 5); OSMetaClassDeclareReservedUnused(OSData, 6); OSMetaClassDeclareReservedUnused(OSData, 7); }; #endif /* !_OS_OSDATA_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/bounded_array_ref.h
// // Copyright (c) 2019 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 XNU_LIBKERN_LIBKERN_CXX_BOUNDED_ARRAY_REF_H #define XNU_LIBKERN_LIBKERN_CXX_BOUNDED_ARRAY_REF_H #if !TAPI #if DRIVERKIT_FRAMEWORK_INCLUDE #include <DriverKit/bounded_array.h> #include <DriverKit/bounded_ptr.h> #else #include <libkern/c++/bounded_array.h> #include <libkern/c++/bounded_ptr.h> #endif /* DRIVERKIT_FRAMEWORK_INCLUDE */ #include <stddef.h> #include <os/base.h> namespace libkern { namespace bar_detail { using nullptr_t = decltype(nullptr); } // Represents a reference to a sequence of 0 or more elements consecutively in // memory, i.e. a start pointer and a length. // // When elements of the sequence are accessed, `bounded_array_ref` ensures // that those elements are in the bounds of the sequence (which are provided // when the `bounded_array_ref` is constructed). // // This class does not own the underlying data, it is expected to be used in // situations where the data resides in some other buffer, whose lifetime // extends past that of the `bounded_array_ref`. For this reason, it is not // in general safe to store a `bounded_array_ref`. // // `bounded_array_ref` is trivially copyable and it should be passed by value. template <typename T, typename TrappingPolicy> struct bounded_array_ref { // Creates an empty `bounded_array_ref`. // // An empty `bounded_array_ref` does not reference anything, so its // `data()` is null and its `size()` is 0. explicit constexpr bounded_array_ref() noexcept : data_(nullptr), size_(0) { } // Creates a `bounded_array_ref` from a bounded pointer and a size. // // The resulting `bounded_array_ref` starts at the location where the // pointer points, and has the given number of elements. All the elements // must be in the bounds of the `bounded_ptr`, otherwise this constructor // will trap. explicit constexpr bounded_array_ref(bounded_ptr<T, TrappingPolicy> data, size_t n) : data_(data.unsafe_discard_bounds()), size_(static_cast<uint32_t>(n)) { if (n != 0) { data[n - 1]; // make sure the bounds are valid // TODO: find a better way to do that } if (__improbable(n > UINT32_MAX)) { TrappingPolicy::trap("bounded_array_ref: Can't construct from a size greater than UINT32_MAX"); } } // Creates a `bounded_array_ref` from a raw pointer and a size. // // The resulting `bounded_array_ref` starts at the location where the // pointer points, and has the given number of elements. This constructor // trusts that `n` elements are reachable from the given pointer. explicit constexpr bounded_array_ref(T* data, size_t n) : data_(data), size_(static_cast<uint32_t>(n)) { if (__improbable(n > UINT32_MAX)) { TrappingPolicy::trap("bounded_array_ref: Can't construct from a size greater than UINT32_MAX"); } } // Creates a `bounded_array_ref` from a `[first, last)` half-open range. // // The resulting `bounded_array_ref` starts at the location pointed-to by // `first`, and contains `last - first` elements. The `[first, last)` // half-open range must be a valid range, i.e. it must be the case that // `first <= last`, otherwise the constructor traps. explicit constexpr bounded_array_ref(T* first, T* last) : data_(first), size_(static_cast<uint32_t>(last - first)) { if (__improbable(first > last)) { TrappingPolicy::trap("bounded_array_ref: The [first, last) constructor requires a valid range."); } if (__improbable(last - first > UINT32_MAX)) { TrappingPolicy::trap("bounded_array_ref: Can't construct from a size greater than UINT32_MAX"); } } // Creates a `bounded_array_ref` from a `bounded_array`. // // The resulting `bounded_array_ref` starts at the first element of the // `bounded_array`, and has the number of elements in the `bounded_array`. template <size_t N> constexpr bounded_array_ref(bounded_array<T, N, TrappingPolicy>& data) : data_(data.data()), size_(static_cast<uint32_t>(data.size())) { if (__improbable(data.size() > UINT32_MAX)) { TrappingPolicy::trap("bounded_array_ref: Can't construct from a size greater than UINT32_MAX"); } } // Creates a `bounded_array_ref` from a C-style array. // // The resulting `bounded_array_ref` starts at the first element of the // C-style array, and has the number of elements in that array. template <size_t N> constexpr bounded_array_ref(T (&array)[N]) : data_(array), size_(static_cast<uint32_t>(N)) { if (__improbable(N > UINT32_MAX)) { TrappingPolicy::trap("bounded_array_ref: Can't construct from a size greater than UINT32_MAX"); } } constexpr bounded_array_ref(bounded_array_ref const&) = default; constexpr bounded_array_ref(bounded_array_ref&& other) noexcept = default; constexpr bounded_array_ref& operator=(bounded_array_ref const&) = default; constexpr bounded_array_ref& operator=(bounded_array_ref&& other) = default; ~bounded_array_ref() = default; // Returns whether the `bounded_array_ref` points to a sequence or not. // // Note that pointing to a sequence at all is different from pointing to // a valid sequence, or having a size of 0. If a `bounded_array_ref` // points to a sequence (regardless of whether it is valid or whether // the size of that sequence is 0), this operator will return true. explicit operator bool() const noexcept { return data_ != nullptr; } using iterator = bounded_ptr<T, TrappingPolicy>; // The following methods allow obtaining iterators (i.e. cursors) to // objects inside a `bounded_array_ref`. // // The iterators of a `bounded_array_ref` are `bounded_ptr`s, which know // the bounds of the sequence and will trap when dereferenced outside // of those bounds. // // `begin()` returns an iterator to the first element in the range, and // `end()` returns an iterator to one-past-the-last element in the range. // The `end()` iterator can't be dereferenced, since it is out of bounds. // // If the `bounded_array_ref` is empty, these methods will return null // `bounded_ptr`s, which can be checked for equality but can't be // dereferenced. iterator begin() const noexcept { return iterator(data_, data_, data_ + size_); } iterator end() const noexcept { return iterator(data_ + size_, data_, data_ + size_); } // Returns the number of elements in the range referenced by the // `bounded_array_ref`. // // This method returns `0` if the `bounded_array_ref` is null, since // such an array ref behaves the same as an empty range. constexpr size_t size() const { return size_; } // Returns a non-owning pointer to the underlying memory referenced by a // `bounded_array_ref`. // // This method can be called even if the `bounded_array_ref` is null, in // which case the returned pointer will be null. constexpr T* data() const noexcept { return data_; } // Access the n-th element of a `bounded_array_ref`. // // If `n` is out of the bounds of the sequence, this operation will // trap. If the array ref is null, this operation will trap too. // // Design note: // We voluntarily use a signed type to represent the index even though a // negative index will always cause a trap. If we used an unsigned type, // we could get an implicit conversion from signed to unsigned, which // could silently wrap around. We think trapping early is more likely // to be helpful in this situation. OS_ALWAYS_INLINE T& operator[](ptrdiff_t n) const { return begin()[n]; } // Chop off the first `n` elements of the array, and keep `m` elements // in the array. // // The resulting range can be described by `[beg + n, beg + n + m)`, where // `beg` is the `begin()` of the range being sliced. This operation traps // if `n + m` is larger than the number of elements in the array. // // Since `bounded_array_ref` checks (or assumes) that the range it is // given on construction is within bounds and `slice()` checks that the // produced slice is within the original range, it is impossible to create // a `bounded_array_ref` that isn't a subset of a valid range using this // function. bounded_array_ref<T, TrappingPolicy> slice(size_t n, size_t m) const { uint32_t total; if (__improbable(os_add_overflow(n, m, &total))) { TrappingPolicy::trap("bounded_array_ref: n + m is larger than the size of any bounded_array_ref"); } if (__improbable(total > size())) { TrappingPolicy::trap("bounded_array_ref: invalid slice provided, the indices are of bounds for the bounded_array_ref"); } return bounded_array_ref(data_ + n, m); } private: T* data_; uint32_t size_; }; // The comparison functions against `nullptr` all return whether the // `bounded_array_ref` references a sequence or not. template <typename T, typename P> bool operator==(bounded_array_ref<T, P> const& x, bar_detail::nullptr_t) { return !static_cast<bool>(x); } template <typename T, typename P> bool operator!=(bounded_array_ref<T, P> const& x, bar_detail::nullptr_t) { return !(x == nullptr); } template <typename T, typename P> bool operator==(bar_detail::nullptr_t, bounded_array_ref<T, P> const& x) { return x == nullptr; } template <typename T, typename P> bool operator!=(bar_detail::nullptr_t, bounded_array_ref<T, P> const& x) { return x != nullptr; } } // end namespace libkern #endif /* !TAPI */ #endif // !XNU_LIBKERN_LIBKERN_CXX_BOUNDED_ARRAY_REF_H
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSKext.h
/* * Copyright (c) 2008-2019 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 _LIBKERN_OSKEXT_H #define _LIBKERN_OSKEXT_H extern "C" { #include <kern/thread_call.h> #include <libkern/OSKextLibPrivate.h> #include <libkern/kernel_mach_header.h> #include <libkern/kxld.h> #include <mach/kmod.h> } #include <libkern/OSKextLib.h> #include <libkern/OSKextLibPrivate.h> #include <libkern/c++/OSObject.h> #include <libkern/c++/OSContainers.h> #include <libkern/c++/OSPtr.h> #include <IOKit/IOLocks.h> /********************************************************************* * C functions used for callbacks. *********************************************************************/ /********************************************************************* * C Function Prototypes for Friend Declarations. *********************************************************************/ class OSKext; extern "C" { void OSKextLog( OSKext * aKext, OSKextLogSpec msgLogSpec, const char * format, ...) __attribute__((format(printf, 3, 4))); void OSKextVLog( OSKext * aKext, OSKextLogSpec msgLogSpec, const char * format, va_list srcArgList); }; /********************************************************************/ #if PRAGMA_MARK #pragma mark - #endif struct list_head { struct list_head *prev; struct list_head *next; }; struct OSKextGrabPgoStruct { bool metadata; uint64_t *pSize; char *pBuffer; uint64_t bufferSize; int err; struct list_head list_head; }; #ifndef container_of #define container_of(ptr, type, member) ((type*)(((uintptr_t)ptr) - offsetof(type, member))) #endif /********************************************************************/ /* * @class OSKext */ /********************************************************************/ class OSKext : public OSObject { OSDeclareDefaultStructors(OSKext); #if PRAGMA_MARK /**************************************/ #pragma mark Friend Declarations /**************************************/ #endif friend class IOCatalogue; friend class KLDBootstrap; friend class OSMetaClass; friend int OSKextGrabPgoData(uuid_t uuid, uint64_t *pSize, char *pBuffer, uint64_t bufferSize, int wait_for_unload, int metadata); private: /************************* * Instance variables *************************/ OSPtr<OSDictionary> infoDict; OSPtr<const OSSymbol> bundleID; OSPtr<OSString> path; // not necessarily correct :-/ OSPtr<OSString> executableRelPath;// relative to bundle OSPtr<OSString> userExecutableRelPath;// relative to bundle OSKextVersion version; // parsed OSKextVersion compatibleVersion;// parsed /* These fields are required for tracking loaded kexts and * will always have values for a loaded kext. */ OSKextLoadTag loadTag; // 'id' from old kmod_info; // kOSKextInvalidLoadTag invalid kmod_info_t * kmod_info; // address into linkedExec./alloced for interface OSPtr<OSArray> dependencies; // kernel resource does not have any; // links directly to kernel /* Only real kexts have these; interface kexts do not. */ OSPtr<OSData> linkedExecutable; OSPtr<OSSet> metaClasses; // for C++/OSMetaClass kexts /* Only interface kexts have these; non-interface kexts can get at them * in the linked Executable. */ OSPtr<OSData> interfaceUUID; OSPtr<OSData> driverKitUUID; struct { unsigned int loggingEnabled:1; unsigned int hasAllDependencies:1; unsigned int hasBleedthrough:1; unsigned int interface:1; unsigned int kernelComponent:1; unsigned int prelinked:1; unsigned int builtin:1; unsigned int loaded:1; unsigned int dtraceInitialized:1; unsigned int starting:1; unsigned int started:1; unsigned int stopping:1; unsigned int unloading:1; unsigned int resetSegmentsFromVnode:1; unsigned int requireExplicitLoad:1; unsigned int autounloadEnabled:1; unsigned int delayAutounload:1; // for development unsigned int CPPInitialized:1; unsigned int jettisonLinkeditSeg:1; unsigned int resetSegmentsFromImmutableCopy:1; unsigned int unloadUnsupported:1; } flags; uint32_t matchingRefCount; kc_kind_t kc_type; struct list_head pendingPgoHead; uuid_t instance_uuid; OSKextAccount * account; uint32_t builtinKmodIdx; OSPtr<OSArray> savedMutableSegments; #if PRAGMA_MARK /**************************************/ #pragma mark Private Functions /**************************************/ #endif private: /* Called by power management at sleep/shutdown. */ static bool setLoadEnabled(bool flag); static bool setUnloadEnabled(bool flag); static bool setAutounloadsEnabled(bool flag); static bool setKernelRequestsEnabled(bool flag); // all getters subject to race condition, caller beware static bool getLoadEnabled(void); static bool getUnloadEnabled(void); static bool getAutounloadEnabled(void); static bool getKernelRequestsEnabled(void); /* Instance life cycle. */ static OSPtr<OSKext> withBooterData( OSString * deviceTreeName, OSData * booterData); virtual bool initWithBooterData( OSString * deviceTreeName, OSData * booterData); static OSPtr<OSKext> withPrelinkedInfoDict( OSDictionary * infoDict, bool doCoalesedSlides, kc_kind_t type); virtual bool initWithPrelinkedInfoDict( OSDictionary * infoDict, bool doCoalesedSlides, kc_kind_t type); static OSSharedPtr<OSKext> withCodelessInfo( OSDictionary * infoDict); virtual bool initWithCodelessInfo( OSDictionary * infoDict); static void setAllVMAttributes(void); virtual bool setInfoDictionaryAndPath( OSDictionary * aDictionary, OSString * aPath); virtual bool setExecutable( OSData * anExecutable, OSData * externalData = NULL, bool externalDataIsMkext = false); virtual bool registerIdentifier(void); virtual void free(void) APPLE_KEXT_OVERRIDE; static OSReturn removeKext( OSKext * aKext, bool terminateServicesAndRemovePersonalitiesFlag = false); virtual bool isInExcludeList(void); virtual bool isLoadable(void); /* Mkexts. */ #if CONFIG_KXLD static OSPtr<OSKext> withMkext2Info( OSDictionary * anInfoDict, OSData * mkextData); virtual bool initWithMkext2Info( OSDictionary * anInfoDict, OSData * mkextData); static OSReturn readMkextArchive( OSData * mkextData, uint32_t * checksumPtr = NULL); static OSReturn readMkext2Archive( OSData * mkextData, OSDictionary ** mkextPlistOut, uint32_t * checksumPtr = NULL); static OSReturn readMkext2Archive( OSData * mkextData, OSSharedPtr<OSDictionary> &mkextPlistOut, uint32_t * checksumPtr = NULL); virtual OSPtr<OSData> createMkext2FileEntry( OSData * mkextData, OSNumber * offsetNum, const char * entryName); virtual OSPtr<OSData> extractMkext2FileData( UInt8 * data, const char * name, uint32_t compressedSize, uint32_t fullSize); #endif // CONFIG_KXLD /* Dependencies. */ virtual bool resolveDependencies( OSArray * loopStack = NULL); // priv/prot virtual bool addBleedthroughDependencies(OSArray * anArray); virtual bool flushDependencies(bool forceFlag = false); // priv/prot virtual uint32_t getNumDependencies(void); virtual OSArray * getDependencies(void); /* User-space requests (load/generic). */ static OSReturn loadFromMkext( OSKextLogSpec clientLogSpec, char * mkextBuffer, uint32_t mkextBufferLength, char ** logInfoOut, uint32_t * logInfoLengthOut); static OSReturn handleRequest( host_priv_t hostPriv, OSKextLogSpec clientLogSpec, char * requestBuffer, uint32_t requestLength, char ** responseOut, uint32_t * responseLengthOut, char ** logInfoOut, uint32_t * logInfoLengthOut); static OSReturn loadCodelessKext( OSString * kextIdentifier, OSDictionary * requestDict); static OSReturn serializeLogInfo( OSArray * logInfoArray, char ** logInfoOut, uint32_t * logInfoLengthOut); /* Loading. */ static bool addKextsFromKextCollection(kernel_mach_header_t *mh, OSDictionary *infoDict, const char *text_seg_name, OSData **kcUUID, kc_kind_t type); static bool addKextsFromKextCollection(kernel_mach_header_t *mh, OSDictionary *infoDict, const char *text_seg_name, OSSharedPtr<OSData> &kcUUID, kc_kind_t type); static bool registerDeferredKextCollection(kernel_mach_header_t *mh, OSSharedPtr<OSObject> &parsedXML, kc_kind_t type); static OSSharedPtr<OSObject> consumeDeferredKextCollection(kc_kind_t type); virtual OSReturn load( OSKextExcludeLevel startOpt = kOSKextExcludeNone, OSKextExcludeLevel startMatchingOpt = kOSKextExcludeAll, OSArray * personalityNames = NULL);// priv/prot virtual OSReturn unload(void); virtual OSReturn queueKextNotification( const char * notificationName, OSString * kextIdentifier); static void recordIdentifierRequest( OSString * kextIdentifier); virtual OSReturn slidePrelinkedExecutable(bool doCoalesedSlides); virtual OSReturn loadExecutable(void); virtual void jettisonLinkeditSegment(void); virtual void jettisonDATASegmentPadding(void); static void considerDestroyingLinkContext(void); virtual OSData * getExecutable(void); virtual void setLinkedExecutable(OSData * anExecutable); #if CONFIG_DTRACE friend void OSKextRegisterKextsWithDTrace(void); static void registerKextsWithDTrace(void); virtual void registerWithDTrace(void); virtual void unregisterWithDTrace(void); #endif /* CONFIG_DTRACE */ virtual OSReturn start(bool startDependenciesFlag = true); virtual OSReturn stop(void); virtual OSReturn setVMAttributes(bool protect, bool wire); virtual boolean_t segmentShouldBeWired(kernel_segment_command_t *seg); virtual OSReturn validateKextMapping(bool startFlag); virtual boolean_t verifySegmentMapping(kernel_segment_command_t *seg); static OSPtr<OSArray> copyAllKextPersonalities( bool filterSafeBootFlag = false); static void setPrelinkedPersonalities(OSArray * personalitiesArray); static void sendAllKextPersonalitiesToCatalog( bool startMatching = false); virtual OSReturn sendPersonalitiesToCatalog( bool startMatching = false, OSArray * personalityNames = NULL); static bool canUnloadKextWithIdentifier( OSString * kextIdentifier, bool checkClassesFlag = true); static OSReturn autounloadKext(OSKext * aKext); /* Sync with user space. */ static OSReturn pingIOKitDaemon(void); /* Getting info about loaded kexts (kextstat). */ static OSPtr<OSDictionary> copyLoadedKextInfo( OSArray * kextIdentifiers = NULL, OSArray * keys = NULL); static OSPtr<OSDictionary> copyLoadedKextInfoByUUID( OSArray * kextIdentifiers = NULL, OSArray * keys = NULL); static OSPtr<OSDictionary> copyKextCollectionInfo( OSDictionary *requestDict, OSArray *infoKeys = NULL); static OSPtr<OSData> copyKextUUIDForAddress(OSNumber *address = NULL); virtual OSPtr<OSDictionary> copyInfo(OSArray * keys = NULL); /* Logging to user space. */ static OSKextLogSpec setUserSpaceLogFilter( OSKextLogSpec userLogSpec, bool captureFlag = false); static OSPtr<OSArray> clearUserSpaceLogFilter(void); static OSKextLogSpec getUserSpaceLogFilter(void); /* OSMetaClasses defined by kext. */ virtual OSReturn addClass( OSMetaClass * aClass, uint32_t numClasses); virtual OSReturn removeClass( OSMetaClass * aClass); virtual bool hasOSMetaClassInstances(void); virtual OSSet * getMetaClasses(void); virtual void reportOSMetaClassInstances( OSKextLogSpec msgLogSpec); /* Resource requests and other callback stuff. */ static OSReturn loadFileSetKexts(OSDictionary * requestDict); static OSReturn loadKCFileSet(const char *filepath, kc_kind_t type); #if defined(__x86_64__) || defined(__i386__) static OSReturn mapKCFileSet( void *control, vm_size_t fsize, kernel_mach_header_t **mh, off_t file_offset, uintptr_t *slide, bool pageable, void *map_entry_buffer); static OSReturn protectKCFileSet( kernel_mach_header_t *mh, kc_kind_t type); static OSReturn mapKCTextSegment( void *control, kernel_mach_header_t **mhp, off_t file_offset, uintptr_t *slide, void *map_entry_list); static void freeKCFileSetcontrol(void); OSReturn resetKCFileSetSegments(void); #endif //(__x86_64__) || defined(__i386__) static void jettisonFileSetLinkeditSegment(kernel_mach_header_t *mh); static OSReturn validateKCFileSetUUID( OSDictionary *infoDict, kc_kind_t type); static OSReturn validateKCUUIDfromPrelinkInfo( uuid_t *loaded_kcuuid, kc_kind_t type, OSDictionary *infoDict, const char *uuid_key); static OSReturn dispatchResource(OSDictionary * requestDict); static OSReturn setMissingAuxKCBundles(OSDictionary * requestDict); static OSReturn setAuxKCBundleAvailable(OSString *kextIdentifier, OSDictionary *requestDict); static OSReturn dequeueCallbackForRequestTag( OSKextRequestTag requestTag, LIBKERN_RETURNS_RETAINED OSDictionary ** callbackRecordOut); static OSReturn dequeueCallbackForRequestTag( OSNumber * requestTagNum, LIBKERN_RETURNS_RETAINED OSDictionary ** callbackRecordOut); static OSReturn dequeueCallbackForRequestTag( OSKextRequestTag requestTag, OSSharedPtr<OSDictionary> &callbackRecordOut); static OSReturn dequeueCallbackForRequestTag( OSNumber * requestTagNum, OSSharedPtr<OSDictionary> &callbackRecordOut); static void invokeRequestCallback( OSDictionary * callbackRecord, OSReturn requestResult); virtual void invokeOrCancelRequestCallbacks( OSReturn callbackResult, bool invokeFlag = true); virtual uint32_t countRequestCallbacks(void); OSReturn resetMutableSegments(void); /* panic() support. */ public: enum { kPrintKextsLock = 0x01, kPrintKextsUnslide = 0x02, kPrintKextsTerse = 0x04 }; static void printKextsInBacktrace( vm_offset_t * addr, unsigned int cnt, int (* printf_func)(const char *fmt, ...), uint32_t flags); bool isDriverKit(void); bool isInFileset(void); private: static OSKextLoadedKextSummary *summaryForAddress(const uintptr_t addr); static void *kextForAddress(const void *addr); static boolean_t summaryIsInBacktrace( OSKextLoadedKextSummary * summary, vm_offset_t * addr, unsigned int cnt); static void printSummary( OSKextLoadedKextSummary * summary, int (* printf_func)(const char *fmt, ...), uint32_t flags); static int saveLoadedKextPanicListTyped( const char * prefix, int invertFlag, int libsFlag, char * paniclist, uint32_t list_size); static void saveLoadedKextPanicList(void); void savePanicString(bool isLoading); static void printKextPanicLists(int (*printf_func)(const char *fmt, ...)); /* Kext summary support. */ static void updateLoadedKextSummaries(void); void updateLoadedKextSummary(OSKextLoadedKextSummary *summary); void updateActiveAccount(OSKextActiveAccount *accountp); static void removeDaemonExitRequests(void); /* C++ Initialization. */ virtual void setCPPInitialized(bool initialized = true); #if PRAGMA_MARK /**************************************/ #pragma mark Public Functions /**************************************/ #endif public: // caller must release static OSPtr<OSKext> lookupKextWithIdentifier(const char * kextIdentifier); static OSPtr<OSKext> lookupKextWithIdentifier(OSString * kextIdentifier); static OSPtr<OSKext> lookupKextWithLoadTag(OSKextLoadTag aTag); static OSPtr<OSKext> lookupKextWithAddress(vm_address_t address); static OSPtr<OSKext> lookupKextWithUUID(uuid_t uuid); kernel_section_t *lookupSection(const char *segname, const char*secname); static bool isKextWithIdentifierLoaded(const char * kextIdentifier); static OSReturn loadKextWithIdentifier( const char * kextIdentifier, Boolean allowDeferFlag = true, Boolean delayAutounloadFlag = false, OSKextExcludeLevel startOpt = kOSKextExcludeNone, OSKextExcludeLevel startMatchingOpt = kOSKextExcludeAll, OSArray * personalityNames = NULL); static OSReturn loadKextWithIdentifier( OSString * kextIdentifier, LIBKERN_RETURNS_RETAINED_ON_ZERO OSObject ** kextRef, Boolean allowDeferFlag = true, Boolean delayAutounloadFlag = false, OSKextExcludeLevel startOpt = kOSKextExcludeNone, OSKextExcludeLevel startMatchingOpt = kOSKextExcludeAll, OSArray * personalityNames = NULL); static OSReturn loadKextWithIdentifier( OSString * kextIdentifier, OSSharedPtr<OSObject> &kextRef, Boolean allowDeferFlag = true, Boolean delayAutounloadFlag = false, OSKextExcludeLevel startOpt = kOSKextExcludeNone, OSKextExcludeLevel startMatchingOpt = kOSKextExcludeAll, OSArray * personalityNames = NULL); static OSReturn loadKextFromKC(OSKext *theKext, OSDictionary *requestDict); static void dropMatchingReferences( OSSet * kexts); bool hasDependency(const OSSymbol * depID); static OSReturn removeKextWithIdentifier( const char * kextIdentifier, bool terminateServicesAndRemovePersonalitiesFlag = false); static OSReturn removeKextWithLoadTag( OSKextLoadTag loadTag, bool terminateServicesAndRemovePersonalitiesFlag = false); static OSReturn requestDaemonLaunch( OSString * kextIdentifier, OSString * serverName, OSNumber * serverTag, class IOUserServerCheckInToken * checkInToken); static OSReturn requestResource( const char * kextIdentifier, const char * resourceName, OSKextRequestResourceCallback callback, void * context, OSKextRequestTag * requestTagOut); static OSReturn cancelRequest( OSKextRequestTag requestTag, void ** contextOut); static void considerUnloads(Boolean rescheduleOnlyFlag = false); static void flushNonloadedKexts(Boolean flushPrelinkedKexts); static void setIOKitDaemonActive(bool active = true); static void setDeferredLoadSucceeded(Boolean succeeded = true); static void considerRebuildOfPrelinkedKernel(void); static void createExcludeListFromBooterData( OSDictionary * theDictionary, OSCollectionIterator * theIterator); static void createExcludeListFromPrelinkInfo(OSArray * theInfoArray); static boolean_t updateExcludeList(OSDictionary * infoDict); static bool pendingIOKitDaemonRequests(void); virtual bool setAutounloadEnabled(bool flag); virtual const OSSymbol * getIdentifier(void); virtual const char * getIdentifierCString(void); virtual OSKextVersion getVersion(void); virtual OSKextVersion getCompatibleVersion(void); virtual bool isLibrary(void); virtual bool isCompatibleWithVersion(OSKextVersion aVersion); virtual OSObject * getPropertyForHostArch(const char * key); virtual OSKextLoadTag getLoadTag(void); virtual void getSizeInfo(uint32_t *loadSize, uint32_t *wiredSize); virtual OSPtr<OSData> copyUUID(void); OSPtr<OSData> copyTextUUID(void); OSPtr<OSData> copyMachoUUID(const kernel_mach_header_t * header); virtual OSPtr<OSArray> copyPersonalitiesArray(void); static bool copyUserExecutablePath(const OSSymbol * bundleID, char * pathResult, size_t pathSize); virtual void setDriverKitUUID(LIBKERN_CONSUMED OSData *uuid); /* This removes personalities naming the kext (by CFBundleIdentifier), * not all personalities defined by the kext (IOPersonalityPublisher or CFBundleIdentifier). */ virtual void removePersonalitiesFromCatalog(void); /* Converts common string-valued properties to OSSymbols for lower memory consumption. */ static void uniquePersonalityProperties(OSDictionary * personalityDict); virtual bool declaresExecutable(void); // might be missing virtual bool isInterface(void); virtual bool isKernel(void); virtual bool isKernelComponent(void); virtual bool isExecutable(void); virtual bool isLoadableInSafeBoot(void); virtual bool isPrelinked(void); virtual bool isLoaded(void); virtual bool isStarted(void); virtual bool isCPPInitialized(void); const char * getKCTypeString(void) { switch (kc_type) { case KCKindPrimary: return kKCTypePrimary; case KCKindPageable: return kKCTypeSystem; case KCKindAuxiliary: return kKCTypeAuxiliary; case KCKindNone: return kKCTypeCodeless; default: return "??"; } } }; extern "C" void OSKextResetAfterUserspaceReboot(void); #endif /* !_LIBKERN_OSKEXT_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSBoundedPtrFwd.h
/* * Copyright (c) 2019 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 XNU_LIBKERN_LIBKERN_CXX_OS_BOUNDED_PTR_FWD_H #define XNU_LIBKERN_LIBKERN_CXX_OS_BOUNDED_PTR_FWD_H #if !TAPI #if DRIVERKIT_FRAMEWORK_INCLUDE #include <DriverKit/IOLib.h> #include <DriverKit/bounded_ptr_fwd.h> #else #include <kern/debug.h> #include <libkern/c++/bounded_ptr_fwd.h> #endif /* DRIVERKIT_FRAMEWORK_INCLUDE */ namespace os_detail { struct panic_trapping_policy; } template <typename T> using OSBoundedPtr = libkern::bounded_ptr<T, os_detail::panic_trapping_policy>; #endif /* !TAPI */ #endif /* !XNU_LIBKERN_LIBKERN_CXX_OS_BOUNDED_PTR_FWD_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSUnserialize.h
/* * Copyright (c) 2000-2016 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@ */ /* OSUnserialize.h created by rsulack on Mon 23-Nov-1998 */ #ifndef _OS_OSUNSERIALIZE_H #define _OS_OSUNSERIALIZE_H #include <libkern/c++/OSMetaClass.h> #include <libkern/c++/OSString.h> #include <libkern/c++/OSPtr.h> #include <sys/appleapiopts.h> #include <sys/types.h> class OSObject; class OSString; /*! * @header * * @abstract * This header declares the <code>OSUnserializeXML</code> function. */ /*! * @function OSUnserializeXML * * @abstract * Recreates an OSContainer object * from its previously serialized OSContainer class instance data. * * @param buffer A buffer containing nul-terminated XML data * representing the object to be recreated. * @param errorString If non-<code>NULL</code>, and the XML parser * finds an error in <code>buffer</code>, * <code>*errorString</code> indicates the line number * and type of error encountered. * * @result * The recreated object, or <code>NULL</code> on failure. * * @discussion * <b>Not safe</b> to call in a primary interrupt handler. */ extern "C++" OSPtr<OSObject> OSUnserializeXML( const char * buffer, OSString * * errorString = NULL); extern "C++" OSPtr<OSObject> OSUnserializeXML( const char * buffer, OSSharedPtr<OSString>& errorString); /*! * @function OSUnserializeXML * * @abstract * Recreates an OSContainer object * from its previously serialized OSContainer class instance data. * * @param buffer A buffer containing nul-terminated XML data * representing the object to be recreated. * @param bufferSize The size of the block of memory. The function * never scans beyond the first bufferSize bytes. * @param errorString If non-<code>NULL</code>, and the XML parser * finds an error in <code>buffer</code>, * <code>*errorString</code> indicates the line number * and type of error encountered. * * @result * The recreated object, or <code>NULL</code> on failure. * * @discussion * <b>Not safe</b> to call in a primary interrupt handler. */ extern "C++" OSPtr<OSObject> OSUnserializeXML( const char * buffer, size_t bufferSize, OSString * *errorString = NULL); extern "C++" OSPtr<OSObject> OSUnserializeXML( const char * buffer, size_t bufferSize, OSSharedPtr<OSString> &errorString); extern "C++" OSPtr<OSObject> OSUnserializeBinary(const char *buffer, size_t bufferSize, OSString * *errorString); extern "C++" OSPtr<OSObject> OSUnserializeBinary(const char *buffer, size_t bufferSize, OSSharedPtr<OSString>& errorString); #ifdef __APPLE_API_OBSOLETE extern OSPtr<OSObject> OSUnserialize(const char *buffer, OSString * *errorString = NULL); extern OSPtr<OSObject> OSUnserialize(const char *buffer, OSSharedPtr<OSString>& errorString); #endif /* __APPLE_API_OBSOLETE */ #endif /* _OS_OSUNSERIALIZE_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSBoolean.h
/* * Copyright (c) 2019 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@ */ /* OSBoolean.cpp created by rsulack on Tue Oct 12 1999 */ #ifndef _OS_OSBOOLEAN_H #define _OS_OSBOOLEAN_H #include <libkern/c++/OSObject.h> #include <libkern/c++/OSPtr.h> class OSString; class OSBoolean; typedef OSBoolean* OSBooleanPtr; /*! * @header * * @abstract * This header declares the OSBoolean container class. */ /*! * @class OSBoolean * * @abstract * OSBoolean wraps a boolean value in a C++ object * for use in Libkern collections. * * @discussion * OSBoolean represents a boolean <code>true</code>/<code>false</code> value * as a Libkern C++ object. * There are only two instances of OSBoolean, * <code>@link kOSBooleanTrue kOSBooleanTrue@/link</code> * and <code>@link kOSBooleanFalse kOSBooleanFalse@/link</code>. * These are shared globally and returned by the instance-creation function * <code>@link withBoolean withBoolean@/link</code>. * Thus, you can use pointer comparison * to test whether two OSBoolean objects are equal. */ class OSBoolean : public OSObject { OSDeclareDefaultStructors(OSBoolean); friend class OSSerialize; protected: bool value; /*! * @function taggedRelease * * @abstract * Overrides the reference counting mechanism * for the shared global instances. * * @param tag Unused. * @param when Unused. */ virtual void taggedRelease( const void * tag, const int when) const APPLE_KEXT_OVERRIDE; public: static void initialize(); /*! * @function withBoolean * * @abstract * Returns one of the global instances of OSBoolean. * * @param value A boolean value. * * @result * The global instance of OSBoolean with the boolean <code>value</code>. * * @discussion * This function actually returns either * <code>@link kOSBooleanTrue kOSBooleanTrue@/link</code> or * <code>@link kOSBooleanFalse kOSBooleanFalse@/link</code>, * so that you can always use pointer comparison with OSBoolean objects. */ static OSPtr<OSBoolean> withBoolean(bool value); /*! * @function free * * @abstract * Overridden to prevent deallocation of the shared global instances. * * @discussion * This function should never be called. */ virtual void free() APPLE_KEXT_OVERRIDE; /*! * @function taggedRetain * * @abstract * Overrides the reference counting mechanism for the shared global instances. * * @param tag Unused. */ virtual void taggedRetain(const void * tag) const APPLE_KEXT_OVERRIDE; /*! * @function isTrue * * @abstract * Checks whether the OSBoolean object * represents a <code>true</code> <code>bool</code> value. * * @result * <code>true</code> if the OSBoolean object is <code>true</code>, * <code>false</code> otherwise. * * @discussion * You can also use <code>==</code> against * <code>@link kOSBooleanTrue kOSBooleanTrue@/link</code>. */ virtual bool isTrue() const; /*! * @function isFalse * * @abstract * Checks whether the OSBoolean object * represents a <code>false</code> <code>bool</code> value. * * @result * <code>true</code> if the OSBoolean object is <code>false</code>, * <code>true</code> otherwise. * * @discussion * You can also use <code>==</code> against * <code>@link kOSBooleanFalse kOSBooleanFalse@/link</code>. */ virtual bool isFalse() const; /*! * @function getValue * * @abstract * Returns the C++ <code>bool</code> value for the OSBoolean object. * * @result * Returns the C++ <code>bool</code> value of the OSBoolean object. */ virtual bool getValue() const; /*! * @function isEqualTo * * @abstract * Tests the equality of two OSBoolean objects. * * @param aBoolean The OSBoolean to be compared against the receiver. * * @result * <code>true</code> if the OSBoolean objects are equal, * <code>false</code> if not. * * @discussion * Two OSBoolean objects are considered equal * if they are the same exact object (pointer equality). */ virtual bool isEqualTo(const OSBoolean * aBoolean) const; /*! * @function isEqualTo * * @abstract * Tests the equality an OSBoolean to an arbitrary object. * * @param anObject An object to be compared against the receiver. * * @result * <code>true</code> if the objects are equal, <code>false</code> if not. * * @discussion * An OSBoolean is considered equal to another object * if that object is derived from OSBoolean * and represents the same C++ <code>bool</code> value. */ virtual bool isEqualTo(const OSMetaClassBase * anObject) const APPLE_KEXT_OVERRIDE; /*! * @function serialize * * @abstract * Archives the receiver into the provided * @link //apple_ref/doc/class/OSSerialize OSSerialize@/link object. * * @param serializer The OSSerialize object. * * @result * <code>true</code> if serialization succeeds, <code>false</code> if not. */ virtual bool serialize(OSSerialize * serializer) const APPLE_KEXT_OVERRIDE; OSMetaClassDeclareReservedUnused(OSBoolean, 0); OSMetaClassDeclareReservedUnused(OSBoolean, 1); OSMetaClassDeclareReservedUnused(OSBoolean, 2); OSMetaClassDeclareReservedUnused(OSBoolean, 3); OSMetaClassDeclareReservedUnused(OSBoolean, 4); OSMetaClassDeclareReservedUnused(OSBoolean, 5); OSMetaClassDeclareReservedUnused(OSBoolean, 6); OSMetaClassDeclareReservedUnused(OSBoolean, 7); }; /*! * @const kOSBooleanTrue * * @abstract * The OSBoolean constant for <code>true</code>. * * @discussion * kOSBooleanTrue is the OSBoolean constant for <code>true</code>. * This object does not need to be retained or released (but it can be). * Comparisons of the form * <code>booleanObject == kOSBooleanTrue</code> * are acceptable and are equivalent to * <code>booleanObject->getValue() == true</code>. */ extern OSBoolean * const & kOSBooleanTrue; /*! * @const kOSBooleanFalse * * @abstract * The OSBoolean constant for <code>false</code>. * * @discussion * kOSBooleanFalse is the OSBoolean constant for <code>false</code>. * This object does not need to be retained or released (but it can be). * Comparisons of the form * <code>booleanObject == kOSBooleanFalse</code> * are acceptable and are equivalent to * <code>booleanObject->getValue() == false</code>. */ extern OSBoolean * const & kOSBooleanFalse; #endif /* !_OS_OSBOOLEAN_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSPtr.h
// // Copyright (c) 2019 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 XNU_LIBKERN_LIBKERN_CXX_OS_PTR_H #define XNU_LIBKERN_LIBKERN_CXX_OS_PTR_H // // The declarations in this file are a transition tool from raw pointers to // the new OSSharedPtr class. // // Basically, code in headers that wants to be able to vend both a raw pointer // and a shared pointer interface should use `OSPtr<T>` instead of `T*`. // Then, users that want to opt into using `OSSharedPtr` can define the // `IOKIT_ENABLE_SHARED_PTR` macro in their translation unit (.cpp file), // and `OSPtr<T>` will suddenly be `OSSharedPtr<T>`. // // When the `IOKIT_ENABLE_SHARED_PTR` macro is not enabled, however, `OSPtr<T>` // will simply be `T*`, so that clients that do not wish to migrate to smart // pointers don't need to. // // Note that defining `IOKIT_ENABLE_SHARED_PTR` requires C++17, because the // implementation of `OSSharedPtr` requires that. // # if defined(IOKIT_ENABLE_SHARED_PTR) # if !defined(IOKIT_ENABLE_EXPERIMENTAL_SHARED_PTR_IN_API) # error It seems that you have defined IOKIT_ENABLE_SHARED_PTR to \ ask IOKit to return shared pointers from many of its API \ functions. This is great! However, please note that we may \ transition more IOKit APIs to shared pointers in the future, \ so if you enable IOKIT_ENABLE_SHARED_PTR right now, your \ code may fail to compile with future versions of IOKit \ (which would return shared pointers where you expect raw \ pointers). If you are OK with that, please define the \ IOKIT_ENABLE_EXPERIMENTAL_SHARED_PTR_IN_API macro to \ silence this error. If that is not acceptable, please hold \ off on enabling shared pointers in IOKit APIs until we have \ committed to API stability for it. # endif # endif #if defined(IOKIT_ENABLE_SHARED_PTR) #if __cplusplus < 201703L #error "Your code must compile with C++17 or later to adopt shared pointers. Use Xcode's 'C++ Language Dialect' setting, or on clang's command-line use -std=gnu++17" #endif #include <libkern/c++/OSSharedPtr.h> template <typename T> using OSPtr = OSSharedPtr<T>; class OSCollection; // Forward declare only because OSCollection.h needs OSPtr.h template <typename T> using OSTaggedPtr = OSTaggedSharedPtr<T, OSCollection>; #else template <typename T> class __attribute__((trivial_abi)) OSSharedPtr; template <typename T, typename Tag> class __attribute__((trivial_abi)) OSTaggedSharedPtr; // We're not necessarily in C++11 mode, so we need to disable warnings // for C++11 extensions #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wc++11-extensions" template <typename T> using OSPtr = T *; template <typename T> using OSTaggedPtr = T *; #pragma clang diagnostic pop #endif // Allow C++98 code to use nullptr. // // This isn't the right place to put this, however the old OSPtr.h header // had it and some code has now started relying on nullptr being defined. #if !__has_feature(cxx_nullptr) && !defined(nullptr) # define nullptr NULL #endif #endif // !XNU_LIBKERN_LIBKERN_CXX_OS_PTR_H
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSContainers.h
/* * 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@ */ /* IOContainers.h created by rsulack on Fri 26-Jun-1998 */ #ifndef _OS_OSCONTAINERS_H #define _OS_OSCONTAINERS_H #include <libkern/c++/OSObject.h> #include <libkern/c++/OSBoolean.h> #include <libkern/c++/OSString.h> #include <libkern/c++/OSSymbol.h> #include <libkern/c++/OSData.h> #include <libkern/c++/OSNumber.h> #include <libkern/c++/OSArray.h> #include <libkern/c++/OSSet.h> #include <libkern/c++/OSOrderedSet.h> #include <libkern/c++/OSCollectionIterator.h> #include <libkern/c++/OSDictionary.h> #include <libkern/c++/OSSerialize.h> #include <libkern/c++/OSUnserialize.h> #endif /* ! _OS_OSCONTAINERS_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSOrderedSet.h
/* * Copyright (c) 2000-2019 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 _OS_OSORDEREDSET_H #define _OS_OSORDEREDSET_H #include <libkern/c++/OSCollection.h> #include <libkern/c++/OSPtr.h> #include <libkern/OSTypes.h> class OSOffset; class OSOrderedSet; typedef OSOrderedSet* OSOrderedSetPtr; /*! * @header * * @abstract * This header declares the OSOrderedSet collection class. */ /*! * @class OSOrderedSet * * @abstract * OSOrderedSet provides an ordered set store of objects. * * @discussion * OSOrderedSet is a container for Libkern C++ objects * (those derived from * @link //apple_ref/doc/class/OSMetaClassBase OSMetaClassBase@/link, * in particular @link //apple_ref/doc/class/OSObject OSObject@/link). * Storage and access follow ordered set logic. * A given object is stored in the set only once, but you can: * <ul> * <li>Define a sorting function for automated ordering * (upon addition only)</li> * <li>Manually insert new objects in the set (overriding sorting)</li> * <li>Add and remove objects in the set</li> * <li>Test whether the set contains a particular object</li> * <li>Get the object stored at a particular index.</li> * </ul> * * Note that automated ordering is performed only upon addition of objects * and depends on the existing objects being properly sorted. * There is no function to re-sort the contents of an OSOrderedSet * or to change the ordering function. * In general, you should either use the one ordered-insertion function, * or the indexed-insertion functions, and not mix the two. * * As with all Libkern collection classes, * OSOrderedSet retains objects added to it, * and releases objects removed from it. * An OSOrderedSet also grows as necessary to accommodate new objects, * <i>unlike</i> Core Foundation collections (it does not, however, shrink). * * <b>Use Restrictions</b> * * With very few exceptions in the I/O Kit, all Libkern-based C++ * classes, functions, and macros are <b>unsafe</b> * to use in a primary interrupt context. * Consult the I/O Kit documentation related to primary interrupts * for more information. * * OSOrderedSet provides no concurrency protection; * it's up to the usage context to provide any protection necessary. * Some portions of the I/O Kit, such as * @link //apple_ref/doc/class/IORegistryEntry IORegistryEntry@/link, * handle synchronization via defined member functions for setting * properties. */ class OSOrderedSet : public OSCollection { OSDeclareDefaultStructors(OSOrderedSet); public: /*! * @typedef OSOrderFunction * * @abstract * The sorting function used by an OSOrderedSet to order objects. * * @param obj1 An object from the ordered set. May be <code>NULL</code>. * @param obj2 The object being ordered within the ordered set. * May be <code>NULL</code>. * @param context A pointer to a user-provided context. May be <code>NULL</code>. * * @result * A comparison result of the object: * <ul> * <li>a negative value if obj2 should precede obj1,</li> * <li>a positive value if obj1 should precede obj2,</li> * <li>and 0 if obj1 and obj2 have an equivalent ordering.</li> * </ul> */ typedef SInt32 (*OSOrderFunction)(const OSMetaClassBase * obj1, const OSMetaClassBase * obj2, void * context); typedef int32_t (^OSOrderBlock)(const OSMetaClassBase * obj1, const OSMetaClassBase * obj2); protected: struct _Element * array; OSOrderFunction ordering; void * orderingRef; unsigned int count; unsigned int capacity; unsigned int capacityIncrement; struct ExpansionData { }; /* Reserved for future use. (Internal use only) */ ExpansionData *reserved; protected: /* OSCollectionIterator interfaces. */ virtual unsigned int iteratorSize() const APPLE_KEXT_OVERRIDE; virtual bool initIterator(void *iterator) const APPLE_KEXT_OVERRIDE; virtual bool getNextObjectForIterator(void *iterator, OSObject **ret) const APPLE_KEXT_OVERRIDE; public: /*! * @function withCapacity * * @abstract * Creates and initializes an empty OSOrderedSet. * * @param capacity The initial storage capacity * of the new ordered set object. * @param orderFunc A C function that implements the sorting algorithm * for the set. * @param orderingContext An ordering context, * which is passed to <code>orderFunc</code>. * @result * An empty instance of OSOrderedSet * with a retain count of 1; * <code>NULL</code> on failure. * * @discussion * <code>capacity</code> must be nonzero. * The new OSOrderedSet will grow as needed * to accommodate more key/object pairs * (<i>unlike</i> Core Foundation collections, * for which the initial capacity is a hard limit). * * If <code>orderFunc</code> is provided, it is used by * <code>@link * //apple_ref/cpp/instm/OSOrderedSet/setObject/virtualbool/(constOSMetaClassBase*) * setObject(const OSMetaClassBase *)@/link</code> * to determine where to insert a new object. * Other object-setting functions ignore ordering. * * <code>orderingContext</code> is not retained or otherwise memory-managed * by the ordered set. * If it needs to be deallocated, * you must track references to it and the ordered set * in order to deallocate it appropriately. * See * <code>@link getOrderingRef getOrderingRef@/link</code>. */ static OSPtr<OSOrderedSet> withCapacity( unsigned int capacity, OSOrderFunction orderFunc = NULL, void * orderingContext = NULL); static OSPtr<OSOrderedSet> withCapacity( unsigned int capacity, OSOrderBlock orderBlock); /*! * @function initWithCapacity * * @abstract * Initializes a new instance of OSOrderedSet. * * @param capacity The initial storage capacity * of the new ordered set object. * @param orderFunc A C function that implements the sorting algorithm * for the set. * @param orderingContext An ordering context, * which is passed to <code>orderFunc</code>. * * @result * <code>true</code> on success, <code>false</code> on failure. * * @discussion * Not for general use. Use the static instance creation method * <code>@link * //apple_ref/cpp/clm/OSOrderedSet/withCapacity/staticOSOrderedSet*\/(unsignedint,OSOrderFunction,void*) * withCapacity@/link</code> * instead. * * <code>capacity</code> must be nonzero. * The new set will grow as needed to accommodate more key/object pairs * (<i>unlike</i> Core Foundation collections, * for which the initial capacity is a hard limit). * * If <code>orderFunc</code> is provided, it is used by * <code>@link * //apple_ref/cpp/instm/OSOrderedSet/setObject/virtualbool/(constOSMetaClassBase*) * setObject(const OSMetaClassBase *)@/link</code> * to determine where to insert a new object. * Other object-setting functions ignore ordering. * * <code>orderingContext</code> is not retained or otherwise memory-managed * by the ordered set. * If it needs to be deallocated, * you must track references to it and the ordered set * in order to deallocate it appropriately. * See * <code>@link getOrderingRef getOrderingRef@/link</code>. */ virtual bool initWithCapacity( unsigned int capacity, OSOrderFunction orderFunc = NULL, void * orderingContext = NULL); /*! * @function free * * @abstract * Deallocatesand releases any resources * used by the OSOrderedSet instance. * * @discussion * This function should not be called directly; * use * <code>@link * //apple_ref/cpp/instm/OSObject/release/virtualvoid/() * release@/link</code> * instead. */ virtual void free() APPLE_KEXT_OVERRIDE; /*! * @function getCount * * @abstract * Returns the current number of objects within the ordered set. * * @result * The current number of objects within the ordered set. */ virtual unsigned int getCount() const APPLE_KEXT_OVERRIDE; /*! * @function getCapacity * * @abstract * Returns the number of objects the ordered set * can store without reallocating. * * @result * The number objects the ordered set * can store without reallocating. * * @discussion * OSOrderedSet objects grow when full to accommodate additional objects. * See * <code>@link * //apple_ref/cpp/instm/OSOrderedSet/getCapacityIncrement/virtualunsignedint/() * getCapacityIncrement@/link</code> * and * <code>@link * //apple_ref/cpp/instm/OSOrderedSet/ensureCapacity/virtualunsignedint/(unsignedint) * ensureCapacity@/link</code>. */ virtual unsigned int getCapacity() const APPLE_KEXT_OVERRIDE; /*! * @function getCapacityIncrement * * @abstract * Returns the storage increment of the ordered set. * * @result * The storage increment of the ordered set. * * @discussion * An OSOrderedSet allocates storage for objects in multiples * of the capacity increment. */ virtual unsigned int getCapacityIncrement() const APPLE_KEXT_OVERRIDE; /*! * @function setCapacityIncrement * * @abstract * Sets the storage increment of the ordered set. * * @result * The new storage increment of the ordered set, * which may be different from the number requested. * * @discussion * An OSOrderedSet allocates storage for objects in multiples * of the capacity increment. * Calling this function does not immediately reallocate storage. */ virtual unsigned int setCapacityIncrement(unsigned increment) APPLE_KEXT_OVERRIDE; /*! * @function ensureCapacity * * @abstract * Ensures the set has enough space * to store the requested number of distinct objects. * * @param newCapacity The total number of distinct objects the ordered set * should be able to store. * * @result * The new capacity of the ordered set, * which may be different from the number requested * (if smaller, reallocation of storage failed). * * @discussion * This function immediately resizes the ordered set, if necessary, * to accommodate at least <code>newCapacity</code> distinct objects. * If <code>newCapacity</code> is not greater than the current capacity, * or if an allocation error occurs, the original capacity is returned. * * There is no way to reduce the capacity of an OSOrderedSet. */ virtual unsigned int ensureCapacity(unsigned int newCapacity) APPLE_KEXT_OVERRIDE; /*! * @function flushCollection * * @abstract * Removes and releases all objects within the ordered set. * * @discussion * The ordered set's capacity (and therefore direct memory consumption) * is not reduced by this function. */ virtual void flushCollection() APPLE_KEXT_OVERRIDE; /*! * @function setObject * * @abstract * Adds an object to the OSOrderedSet if it is not already present, * storing it in sorted order if there is an order function. * * @param anObject The OSMetaClassBase-derived object to be added * to the ordered set. * @result * <code>true</code> if <code>anObject</code> was successfully * added to the ordered set, <code>false</code> otherwise * (including if it was already in the ordered set). * * @discussion * The set adds storage to accomodate the new object, if necessary. * If successfully added, the object is retained. * * If <code>anObject</code> is not already in the ordered set * and there is an order function, * this function loops through the existing objects, * calling the @link OSOrderFunction order function@/link * with arguments each existingObject, <code>anObject</code>, * and the ordering context * (or <code>NULL</code> if none was set), * until the order function returns * a value <i>greater than</i> or equal to 0. * It then inserts <code>anObject</code> at the index of the existing object. * * If there is no order function, the object is inserted at index 0. * * A <code>false</code> return value can mean either * that <code>anObject</code> is already present in the set, * or that a memory allocation failure occurred. * If you need to know whether the object * is already present, use * <code>@link * //apple_ref/cpp/instm/OSOrderedSet/containsObject/virtualbool/(constOSMetaClassBase*) * containsObject(const OSMetaClassBase *)@/link</code>. */ virtual bool setObject(const OSMetaClassBase * anObject); bool setObject(OSSharedPtr<const OSMetaClassBase> const& anObject); /*! * @function setFirstObject * * @abstract * Adds an object to the OSOrderedSet at index 0 * if it is not already present. * * @param anObject The OSMetaClassBase-derived object * to be added to the ordered set. * @result * <code>true</code> if <code>anObject</code> was successfully added * to the ordered set, <code>false</code> otherwise * (including if it was already in the ordered set at any index). * * @discussion * The set adds storage to accomodate the new object, if necessary. * If successfully added, the object is retained. * * This function ignores any ordering function of the ordered set, * and can disrupt the automatic sorting mechanism. * Only call this function if you are managing the ordered set directly. * * A <code>false</code> return value can mean either that <code>anObject</code> * is already present in the set, * or that a memory allocation failure occurred. * If you need to know whether the object * is already present, use * <code>@link * //apple_ref/cpp/instm/OSOrderedSet/containsObject/virtualbool/(constOSMetaClassBase*) * containsObject(const OSMetaClassBase *)@/link</code>. */ virtual bool setFirstObject(const OSMetaClassBase * anObject); bool setFirstObject(OSSharedPtr<const OSMetaClassBase> const& anObject); /*! * @function setLastObject * * @abstract * Adds an object at the end of the OSOrderedSet * if it is not already present. * * @param anObject The OSMetaClassBase-derived object to be added * to the ordered set. * @result * <code>true</code> if <code>anObject</code> was successfully added * to the ordered set, <code>false</code> otherwise * (including if it was already in the ordered set at any index). * * @discussion * The set adds storage to accomodate the new object, if necessary. * If successfully added, the object is retained. * * This function ignores any ordering function of the ordered set, * and can disrupt the automatic sorting mechanism. * Only call this function if you are managing the ordered set directly. * * A <code>false</code> return value can mean either that <code>anObject</code> * is already present in the set, * or that a memory allocation failure occurred. * If you need to know whether the object * is already present, use * <code>@link * //apple_ref/cpp/instm/OSOrderedSet/containsObject/virtualbool/(constOSMetaClassBase*) * containsObject(const OSMetaClassBase *)@/link</code>. */ virtual bool setLastObject(const OSMetaClassBase * anObject); bool setLastObject(OSSharedPtr<const OSMetaClassBase> const& anObject); /*! * @function removeObject * * @abstract * Removes an object from the ordered set. * * @param anObject The OSMetaClassBase-derived object * to be removed from the ordered set. * * @discussion * The object removed from the ordered set is released. */ virtual void removeObject(const OSMetaClassBase * anObject); void removeObject(OSSharedPtr<const OSMetaClassBase> const& anObject); /*! * @function containsObject * * @abstract * Checks the ordered set for the presence of an object. * * @param anObject The OSMetaClassBase-derived object to check for * in the ordered set. * * @result * <code>true</code> if <code>anObject</code> is present * within the ordered set, <code>false</code> otherwise. * * @discussion * Pointer equality is used. * This function returns <code>false</code> if passed <code>NULL</code>. */ virtual bool containsObject(const OSMetaClassBase * anObject) const; /*! * @function member * * @abstract * Checks the ordered set for the presence of an object. * * @param anObject The OSMetaClassBase-derived object to check for * in the ordered set. * * @result * <code>true</code> if <code>anObject</code> is present * within the ordered set, <code>false</code> otherwise. * * @discussion * Pointer equality is used. * Returns <code>false</code> if passed <code>NULL</code>. * * <code>@link * //apple_ref/cpp/instm/OSOrderedSet/containsObject/virtualbool/(constOSMetaClassBase*) * containsObject(const OSMetaClassBase *)@/link</code> * checks for <code>NULL</code> before scanning the contents, * and is therefore more efficient than this function. */ virtual bool member(const OSMetaClassBase * anObject) const; /*! * @function getFirstObject * * @abstract * The object at index 0 in the ordered set if there is one, * otherwise <code>NULL</code>. * * @discussion * The returned object will be released if removed from the ordered set; * if you plan to store the reference, you should call * <code>@link * //apple_ref/cpp/instm/OSObject/retain/virtualvoid/() * retain@/link</code> * on that object. */ virtual OSObject * getFirstObject() const; /*! * @function getLastObject * * @abstract * The last object in the ordered set if there is one, * otherwise <code>NULL</code>. * * @discussion * The returned object will be released if removed from the ordered set; * if you plan to store the reference, you should call * <code>@link * //apple_ref/cpp/instm/OSObject/retain/virtualvoid/() * retain@/link</code> * on that object. */ virtual OSObject * getLastObject() const; /*! * @function orderObject * * @abstract * Calls the ordered set's order function against a <code>NULL</code> object. * * @param anObject The object to be ordered. * * @result * The ordering value for the object. * * @discussion * This function calls the ordered set's * @link OSOrderFunction order function@/link * with <code>anObject</code>, <code>NULL</code>, and the ordering context * (or <code>NULL</code> if none was set), * and returns the result of that function. */ virtual SInt32 orderObject(const OSMetaClassBase * anObject); /*! * @function setObject * * @abstract * Adds an object to an OSOrderedSet at a specified index * if it is not already present. * * @param index The index at which to insert the new object. * @param anObject The OSMetaClassBase-derived object to be added * to the ordered set. * * @result * <code>true</code> if the object was successfully added * to the ordered set, <code>false</code> otherwise * (including if it was already in the set). * * @discussion * The set adds storage to accomodate the new object, if necessary. * If successfully added, the object is retained. * * This function ignores any ordering function of the ordered set, * and can disrupt the automatic sorting mechanism. * Only call this function if you are managing the ordered set directly. * * A <code>false</code> return value can mean either that the object * is already present in the set, * or that a memory allocation failure occurred. * If you need to know whether the object * is already present, use * <code>@link //apple_ref/cpp/instm/OSOrderedSet/containsObject/virtualbool/(constOSMetaClassBase*) * containsObject containsObject@/link</code>. */ virtual bool setObject( unsigned int index, const OSMetaClassBase * anObject); bool setObject( unsigned int index, OSSharedPtr<const OSMetaClassBase> const& anObject); /*! * @function getObject * * @abstract * Gets the object at a particular index. * * @param index The index into the set. * @result * The object at the given index, * or <code>NULL</code> if none exists at that location. * * @discussion * The returned object will be released if removed from the set; * if you plan to store the reference, you should call * <code>@link * //apple_ref/cpp/instm/OSObject/retain/virtualvoid/() * retain@/link</code> * on that object. */ virtual OSObject * getObject(unsigned int index) const; /*! * @function getOrderingRef * * @abstract * Returns the ordering context the ordered set was created with. * * @result * The ordered set's ordering context, * or <code>NULL</code> if it doesn't have one. */ virtual void * getOrderingRef(); /*! * @function isEqualTo * * @abstract * Tests the equality of two OSOrderedSet objects. * * @param anOrderedSet The ordered set object being compared * against the receiver. * @result * <code>true</code> if the two sets are equivalent, * <code>false</code> otherwise. * * @discussion * Two OSOrderedSet objects are considered equal if they have same count * and the same object pointer values in the same order. */ virtual bool isEqualTo(const OSOrderedSet * anOrderedSet) const; /*! * @function isEqualTo * * @abstract * Tests the equality of an OSOrderedSet * against an arbitrary object. * * @param anObject The object being compared against the receiver. * @result * <code>true</code> if the two objects are equivalent, * <code>false</code> otherwise. * * @discussion * An OSOrderedSet object is considered equal to another object * if the other object is derived from OSOrderedSet * and compares equal as an OSOrderedSet. */ virtual bool isEqualTo(const OSMetaClassBase * anObject) const APPLE_KEXT_OVERRIDE; /*! * @function setOptions * * Recursively sets option bits in the ordered set * and all child collections. * * @param options A bitfield whose values turn the options on (1) or off (0). * @param mask A mask indicating which bits * in <code>options</code> to change. * Pass 0 to get the whole current options bitfield * without changing any settings. * @param context Unused. * * @result * The options bitfield as it was before the set operation. * * @discussion * Kernel extensions should not call this function. * * Child collections' options are changed only if the receiving ordered set's * options actually change. */ virtual unsigned setOptions( unsigned options, unsigned mask, void * context = NULL) APPLE_KEXT_OVERRIDE; /*! * @function copyCollection * * @abstract * Creates a deep copy of this ordered set and its child collections. * * @param cycleDict A dictionary of all of the collections * that have been copied so far, * which is used to track circular references. * To start the copy at the top level, * pass <code>NULL</code>. * * @result * The newly copied ordered set, with a retain count of 1, * or <code>NULL</code> if there is insufficient memory to do the copy. * * @discussion * The receiving ordered set, and any collections it contains, * recursively, are copied. * Objects that are not derived from OSCollection are retained * rather than copied. */ OSPtr<OSCollection> copyCollection(OSDictionary * cycleDict = NULL) APPLE_KEXT_OVERRIDE; OSMetaClassDeclareReservedUnused(OSOrderedSet, 0); OSMetaClassDeclareReservedUnused(OSOrderedSet, 1); OSMetaClassDeclareReservedUnused(OSOrderedSet, 2); OSMetaClassDeclareReservedUnused(OSOrderedSet, 3); OSMetaClassDeclareReservedUnused(OSOrderedSet, 4); OSMetaClassDeclareReservedUnused(OSOrderedSet, 5); OSMetaClassDeclareReservedUnused(OSOrderedSet, 6); OSMetaClassDeclareReservedUnused(OSOrderedSet, 7); }; #endif /* ! _OS_OSORDEREDSET_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/bounded_array.h
// // Copyright (c) 2019 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 XNU_LIBKERN_LIBKERN_CXX_BOUNDED_ARRAY_H #define XNU_LIBKERN_LIBKERN_CXX_BOUNDED_ARRAY_H #if !TAPI #if DRIVERKIT_FRAMEWORK_INCLUDE #include <DriverKit/bounded_ptr.h> #else #include <libkern/c++/bounded_ptr.h> #endif /* DRIVERKIT_FRAMEWORK_INCLUDE */ #include <stddef.h> #include <os/base.h> namespace libkern { // `bounded_array` is a simple abstraction for a C-style array. // // Unlike C-style arrays, however, it ensures that the array is not accessed // outside of its bounds. Furthermore, the iterators of the `bounded_array` // are `bounded_ptr`, which track the range they're allowed to access. // // TODO: // - Should we provide deep comparison operators? // - Document individual methods template <typename T, size_t N, typename TrappingPolicy> struct bounded_array { // DO NOT USE THIS MEMBER DIRECTLY OR WE WILL BREAK YOUR CODE IN THE FUTURE. // THIS HAS TO BE PUBLIC FOR THIS TYPE TO SUPPORT AGGREGATE-INITIALIZATION. T data_[N]; using iterator = bounded_ptr<T, TrappingPolicy>; using const_iterator = bounded_ptr<T const, TrappingPolicy>; iterator begin() noexcept { return iterator(data_, data_, data_ + N); } const_iterator begin() const noexcept { return const_iterator(data_, data_, data_ + N); } iterator end() noexcept { return iterator(data_ + N, data_, data_ + N); } const_iterator end() const noexcept { return const_iterator(data_ + N, data_, data_ + N); } constexpr size_t size() const { return N; } constexpr T* data() noexcept { return data_; } constexpr T const* data() const noexcept { return data_; } OS_ALWAYS_INLINE T& operator[](ptrdiff_t n) { return begin()[n]; } OS_ALWAYS_INLINE T const& operator[](ptrdiff_t n) const { return begin()[n]; } }; } // end namespace libkern #endif /* !TAPI */ #endif // !XNU_LIBKERN_LIBKERN_CXX_BOUNDED_ARRAY_H
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSNumber.h
/* * Copyright (c) 2019 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@ */ /* IOOffset.h created by rsulack on Wed 17-Sep-1997 */ /* IOOffset.h converted to C++ by gvdl on Fri 1998-10-30 */ #ifndef _OS_OSNUMBER_H #define _OS_OSNUMBER_H #include <libkern/c++/OSPtr.h> #include <libkern/c++/OSObject.h> /*! * @header * * @abstract * This header declares the OSNumber container class. */ class OSNumber; typedef OSNumber* OSNumberPtr; /*! * @class OSNumber * * @abstract * OSNumber wraps an integer value in a C++ object * for use in Libkern collections. * * @discussion * OSNumber represents an integer of 8, 16, 32, or 64 bits * as a Libkern C++ object. * OSNumber objects are mutable: you can add to or set their values. * * <b>Use Restrictions</b> * * With very few exceptions in the I/O Kit, all Libkern-based C++ * classes, functions, and macros are <b>unsafe</b> * to use in a primary interrupt context. * Consult the I/O Kit documentation related to primary interrupts * for more information. * * OSNumber provides no concurrency protection; * it's up to the usage context to provide any protection necessary. * Some portions of the I/O Kit, such as * @link //apple_ref/doc/class/IORegistryEntry IORegistryEntry@/link, * handle synchronization via defined member functions for setting * properties. */ class OSNumber : public OSObject { friend class OSSerialize; OSDeclareDefaultStructors(OSNumber); #if APPLE_KEXT_ALIGN_CONTAINERS protected: unsigned int size; unsigned long long value; #else /* APPLE_KEXT_ALIGN_CONTAINERS */ protected: unsigned long long value; unsigned int size; struct ExpansionData { }; /* Reserved for future use. (Internal use only) */ ExpansionData * reserved; #endif /* APPLE_KEXT_ALIGN_CONTAINERS */ public: /*! * @function withNumber * * @abstract * Creates and initializes an instance of OSNumber * with an integer value. * * @param value The numeric integer value for the OSNumber to store. * @param numberOfBits The number of bits to limit storage to. * * @result * An instance of OSNumber with a reference count of 1; * <code>NULL</code> on failure. * * @discussion * <code>value</code> is masked to the provided <code>numberOfBits</code> * when the OSNumber object is initialized. * * You can change the value of an OSNumber later * using <code>@link setValue setValue@/link</code> * and <code>@link addValue addValue@/link</code>, * but you can't change the bit size. */ static OSPtr<OSNumber> withNumber( unsigned long long value, unsigned int numberOfBits); /*! * @function withNumber * * @abstract * Creates and initializes an instance of OSNumber * with an unsigned integer value represented as a C string. * * @param valueString A C string representing a numeric value * for the OSNumber to store. * @param numberOfBits The number of bits to limit storage to. * * @result * An instance of OSNumber with a reference count of 1; * <code>NULL</code> on failure. * * @discussion * This function does not work in I/O Kit versions prior to 8.0 (Mac OS X 10.4). * In I/O Kit version 8.0 and later, it works * but is limited to parsing unsigned 32 bit quantities. * The format of the C string may be decimal, hexadecimal ("0x" prefix), * binary ("0b" prefix), or octal ("0" prefix). * * The parsed value is masked to the provided <code>numberOfBits</code> * when the OSNumber object is initialized. * * You can change the value of an OSNumber later * using <code>@link setValue setValue@/link</code> * and <code>@link addValue addValue@/link</code>, * but you can't change the bit size. */ static OSPtr<OSNumber> withNumber( const char * valueString, unsigned int numberOfBits); /*! * @function init * * @abstract * Initializes an instance of OSNumber with an integer value. * * @param value The numeric integer value for the OSNumber to store. * @param numberOfBits The number of bits to limit storage to. * * @result * <code>true</code> if initialization succeeds, * <code>false</code> on failure. * * @discussion * Not for general use. Use the static instance creation method * <code>@link * //apple_ref/cpp/clm/OSNumber/withNumber/staticOSNumber*\/(constchar*,unsignedint) * withNumber(unsigned long long, unsigned int)@/link</code> * instead. */ virtual bool init( unsigned long long value, unsigned int numberOfBits); /*! * @function init * * @abstract * Initializes an instance of OSNumber * with an unsigned integer value represented as a C string. * * @param valueString A C string representing a numeric value * for the OSNumber to store. * @param numberOfBits The number of bits to limit storage to. * * @result * <code>true</code> if initialization succeeds, * <code>false</code> on failure. * * @discussion * Not for general use. Use the static instance creation method * <code>@link * //apple_ref/cpp/clm/OSNumber/withNumber/staticOSNumber*\/(constchar*,unsignedint) * withNumber(const char *, unsigned int)@/link</code> * instead. */ virtual bool init( const char * valueString, unsigned int numberOfBits); /*! * @function free * * @abstract * Deallocates or releases any resources * used by the OSNumber instance. * * @discussion * This function should not be called directly; * use * <code>@link * //apple_ref/cpp/instm/OSObject/release/virtualvoid/() * release@/link</code> * instead. */ virtual void free() APPLE_KEXT_OVERRIDE; /*! * @function numberOfBits * * @abstract * Returns the number of bits used to represent * the OSNumber object's integer value. * * @result * The number of bits used to represent * the OSNumber object's integer value. * * @discussion * The number of bits is used to limit the stored value of the OSNumber. * Any change to its value is performed as an <code>unsigned long long</code> * and then truncated to the number of bits. */ virtual unsigned int numberOfBits() const; /*! * @function numberOfBytes * * @abstract * Returns the number of bytes used to represent * the OSNumber object's integer value. * * @result * The number of bytes used to represent * the OSNumber object's integer value. * See <code>@link numberOfBits numberOfBits@/link</code>. */ virtual unsigned int numberOfBytes() const; // xx-review: should switch to explicitly-sized int types // xx-review: but that messes up C++ mangled symbols :-( /*! * @function unsigned8BitValue * * @abstract * Returns the OSNumber object's integer value * cast as an unsigned 8-bit integer. * * @result * The OSNumber object's integer value * cast as an unsigned 8-bit integer. * * @discussion * This function merely casts the internal integer value, * giving no indication of truncation or other potential conversion problems. */ virtual unsigned char unsigned8BitValue() const; /*! * @function unsigned16BitValue * * @abstract * Returns the OSNumber object's integer value * cast as an unsigned 16-bit integer. * * @result * Returns the OSNumber object's integer value * cast as an unsigned 16-bit integer. * * @discussion * This function merely casts the internal integer value, * giving no indication of truncation or other potential conversion problems. */ virtual unsigned short unsigned16BitValue() const; /*! * @function unsigned32BitValue * * @abstract * Returns the OSNumber object's integer value * cast as an unsigned 32-bit integer. * * @result * Returns the OSNumber object's integer value * cast as an unsigned 32-bit integer. * * @discussion * This function merely casts the internal integer value, * giving no indication of truncation or other potential conversion problems. */ virtual unsigned int unsigned32BitValue() const; /*! * @function unsigned64BitValue * * @abstract * Returns the OSNumber object's integer value * cast as an unsigned 64-bit integer. * * @result * Returns the OSNumber object's integer value * cast as an unsigned 64-bit integer. * * @discussion * This function merely casts the internal integer value, * giving no indication of truncation or other potential conversion problems. */ virtual unsigned long long unsigned64BitValue() const; // xx-review: wow, there's no addNumber(OSNumber *)! /*! * @function addValue * * @abstract * Adds a signed integer value to the internal integer value * of the OSNumber object. * * @param value The value to be added. * * @discussion * This function adds values as 64-bit integers, * but masks the result by the bit size * (see <code>@link numberOfBits numberOfBits@/link</code>), * so addition overflows will not necessarily * be the same as for plain C integers. */ virtual void addValue(signed long long value); /*! * @function setValue * * @abstract * Replaces the current internal integer value * of the OSNumber object by the value given. * * @param value The new value for the OSNumber object, * which is truncated by the bit size of the OSNumber object * (see <code>@link numberOfBits numberOfBits@/link</code>). */ virtual void setValue(unsigned long long value); /*! * @function isEqualTo * * @abstract * Tests the equality of two OSNumber objects. * * @param aNumber The OSNumber to be compared against the receiver. * * @result * <code>true</code> if the OSNumber objects are equal, * <code>false</code> if not. * * @discussion * Two OSNumber objects are considered equal * if they represent the same C integer value. */ virtual bool isEqualTo(const OSNumber * aNumber) const; /*! * @function isEqualTo * * @abstract * Tests the equality an OSNumber to an arbitrary object. * * @param anObject An object to be compared against the receiver. * * @result * <code>true</code> if the objects are equal, * <code>false</code> if not. * * @discussion * An OSNumber is considered equal to another object if that object is * derived from OSNumber and represents the same C integer value. */ virtual bool isEqualTo(const OSMetaClassBase * anObject) const APPLE_KEXT_OVERRIDE; /*! * @function serialize * * @abstract * Archives the receiver into the provided * @link //apple_ref/doc/class/OSSerialize OSSerialize@/link object. * * @param serializer The OSSerialize object. * * @result * <code>true</code> if serialization succeeds, <code>false</code> if not. */ virtual bool serialize(OSSerialize * serializer) const APPLE_KEXT_OVERRIDE; OSMetaClassDeclareReservedUnused(OSNumber, 0); OSMetaClassDeclareReservedUnused(OSNumber, 1); OSMetaClassDeclareReservedUnused(OSNumber, 2); OSMetaClassDeclareReservedUnused(OSNumber, 3); OSMetaClassDeclareReservedUnused(OSNumber, 4); OSMetaClassDeclareReservedUnused(OSNumber, 5); OSMetaClassDeclareReservedUnused(OSNumber, 6); OSMetaClassDeclareReservedUnused(OSNumber, 7); }; #endif /* !_OS_OSNUMBER_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSSharedPtr.h
// // Copyright (c) 2019 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 XNU_LIBKERN_LIBKERN_CXX_OS_SHARED_PTR_H #define XNU_LIBKERN_LIBKERN_CXX_OS_SHARED_PTR_H #include <libkern/c++/intrusive_shared_ptr.h> #include <libkern/c++/OSMetaClass.h> struct intrusive_osobject_retainer { static void retain(OSMetaClassBase const& obj) { obj.retain(); } static void release(OSMetaClassBase const& obj) { obj.release(); } }; template <typename Tag> struct intrusive_tagged_osobject_retainer { static void retain(OSMetaClassBase const& obj) { obj.taggedRetain(OSTypeID(Tag)); } static void release(OSMetaClassBase const& obj) { obj.taggedRelease(OSTypeID(Tag)); } }; inline constexpr auto OSNoRetain = libkern::no_retain; inline constexpr auto OSRetain = libkern::retain; template <typename T> class __attribute__((trivial_abi)) OSSharedPtr: public libkern::intrusive_shared_ptr<T, intrusive_osobject_retainer> { using libkern::intrusive_shared_ptr<T, intrusive_osobject_retainer>::intrusive_shared_ptr; }; template <typename T, typename Tag> class __attribute__((trivial_abi)) OSTaggedSharedPtr: public libkern::intrusive_shared_ptr<T, intrusive_tagged_osobject_retainer<Tag> > { using libkern::intrusive_shared_ptr<T, intrusive_tagged_osobject_retainer<Tag> >::intrusive_shared_ptr; }; template <typename T> OSSharedPtr<T> OSMakeShared() { T* memory = OSTypeAlloc(T); // OSTypeAlloc returns an object with a refcount of 1, so we must not // retain when constructing the shared pointer. return OSSharedPtr<T>(memory, OSNoRetain); } template <typename Destination, typename Source> OSSharedPtr<Destination> OSDynamicPtrCast(OSSharedPtr<Source> const& source) { Destination* raw = OSDynamicCast(Destination, source.get()); if (raw == nullptr) { return nullptr; } else { OSSharedPtr<Destination> dest(raw, OSRetain); return dest; } } template <typename Destination, typename Source> OSSharedPtr<Destination> OSDynamicPtrCast(OSSharedPtr<Source> && source) { Destination* raw = OSDynamicCast(Destination, source.get()); if (raw == nullptr) { return nullptr; } else { OSSharedPtr<Destination> dest(raw, OSNoRetain); source.detach(); // we stole the retain! return dest; } } template <typename Destination, typename Tag, typename Source> OSTaggedSharedPtr<Destination, Tag> OSDynamicPtrCast(OSTaggedSharedPtr<Source, Tag> const& source) { Destination* raw = OSDynamicCast(Destination, source.get()); if (raw == nullptr) { return nullptr; } else { OSTaggedSharedPtr<Destination, Tag> dest(raw, OSRetain); return dest; } } template <typename To, typename From> OSSharedPtr<To> OSStaticPtrCast(OSSharedPtr<From> const& ptr) noexcept { return OSSharedPtr<To>(static_cast<To*>(ptr.get()), OSRetain); } template <typename To, typename From> OSSharedPtr<To> OSStaticPtrCast(OSSharedPtr<From>&& ptr) noexcept { return OSSharedPtr<To>(static_cast<To*>(ptr.detach()), OSNoRetain); } template <typename To, typename From> OSSharedPtr<To> OSConstPtrCast(OSSharedPtr<From> const& ptr) noexcept { return OSSharedPtr<To>(const_cast<To*>(ptr.get()), OSRetain); } template <typename To, typename From> OSSharedPtr<To> OSConstPtrCast(OSSharedPtr<From>&& ptr) noexcept { return OSSharedPtr<To>(const_cast<To*>(ptr.detach()), OSNoRetain); } #endif // !XNU_LIBKERN_LIBKERN_CXX_OS_SHARED_PTR_H
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSBoundedPtr.h
/* * Copyright (c) 2019 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 XNU_LIBKERN_LIBKERN_CXX_OS_BOUNDED_PTR_H #define XNU_LIBKERN_LIBKERN_CXX_OS_BOUNDED_PTR_H #if !TAPI #if DRIVERKIT_FRAMEWORK_INCLUDE #include <DriverKit/IOLib.h> #include <DriverKit/OSBoundedPtrFwd.h> #if __cplusplus >= 201703L #include <DriverKit/bounded_ptr.h> #endif /* __cplusplus >= 201703L */ #else #include <kern/debug.h> #include <libkern/c++/OSBoundedPtrFwd.h> #if __cplusplus >= 201703L #include <libkern/c++/bounded_ptr.h> #endif /* __cplusplus >= 201703L */ #endif /* DRIVERKIT_FRAMEWORK_INCLUDE */ namespace os_detail { struct panic_trapping_policy { [[noreturn]] static void trap(char const* message) { panic("%s", message); } }; } // OSBoundedPtr alias is defined in the fwd decl header #endif /* !TAPI */ #endif /* !XNU_LIBKERN_LIBKERN_CXX_OS_BOUNDED_PTR_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/bounded_ptr_fwd.h
// // Copyright (c) 2019 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 XNU_LIBKERN_LIBKERN_CXX_BOUNDED_PTR_FWD_H #define XNU_LIBKERN_LIBKERN_CXX_BOUNDED_PTR_FWD_H #if !TAPI namespace libkern { template <typename T, typename TrappingPolicy> struct __attribute__((trivial_abi)) bounded_ptr; } // end namespace libkern #endif /* !TAPI */ #endif // !XNU_LIBKERN_LIBKERN_CXX_BOUNDED_PTR_FWD_H
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/crypto/rand.h
/* * Copyright (c) 2016 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 _RAND_H #define _RAND_H #include <sys/types.h> __BEGIN_DECLS int random_buf(void *buf, size_t buflen); __END_DECLS #endif
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/crypto/md5.h
/* * 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@ */ /* * MD5.H - header file for MD5.C */ /* * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All * rights reserved. * * License to copy and use this software is granted provided that it * is identified as the "RSA Data Security, Inc. MD5 Message-Digest * Algorithm" in all material mentioning or referencing this software * or this function. * * License is also granted to make and use derivative works provided * that such works are identified as "derived from the RSA Data * Security, Inc. MD5 Message-Digest Algorithm" in all material * mentioning or referencing the derived work. * * RSA Data Security, Inc. makes no representations concerning either * the merchantability of this software or the suitability of this * software for any particular purpose. It is provided "as is" * without express or implied warranty of any kind. * * These notices must be retained in any copies of any part of this * documentation and/or software. */ #ifndef _CRYPTO_MD5_H_ #define _CRYPTO_MD5_H_ #include <sys/types.h> #include <sys/cdefs.h> __BEGIN_DECLS #define MD5_DIGEST_LENGTH 16 /* MD5 context. */ typedef struct { u_int32_t state[4]; /* state (ABCD) */ u_int32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */ unsigned char buffer[64]; /* input buffer */ } MD5_CTX; extern void MD5Init(MD5_CTX *); extern void MD5Update(MD5_CTX *, const void *, unsigned int); extern void MD5Final(unsigned char [MD5_DIGEST_LENGTH], MD5_CTX *); __END_DECLS #endif /* _CRYPTO_MD5_H_ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/crypto/sha1.h
/* * 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@ */ #ifndef _CRYPTO_SHA1_H_ #define _CRYPTO_SHA1_H_ #include <sys/types.h> #ifdef __cplusplus extern "C" { #endif #define SHA_DIGEST_LENGTH 20 #define SHA1_RESULTLEN SHA_DIGEST_LENGTH typedef struct sha1_ctxt { union { u_int8_t b8[20]; u_int32_t b32[5]; /* state (ABCDE) */ } h; union { u_int8_t b8[8]; u_int32_t b32[2]; u_int64_t b64[1]; /* # of bits, modulo 2^64 (msb first) */ } c; union { u_int8_t b8[64]; u_int32_t b32[16]; /* input buffer */ } m; u_int8_t count; /* unused; for compatibility only */ } SHA1_CTX; /* For compatibility with the other SHA-1 implementation. */ #define sha1_init(c) SHA1Init(c) #define sha1_loop(c, b, l) SHA1Update(c, b, l) #define sha1_result(c, b) SHA1Final(b, c) extern void SHA1Init(SHA1_CTX *); extern void SHA1Update(SHA1_CTX *, const void *, size_t); extern void SHA1Final(void *, SHA1_CTX *); #ifdef __cplusplus } #endif #endif /*_CRYPTO_SHA1_H_*/
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/libkern/arm/OSByteOrder.h
/* * Copyright (c) 1999-2007 Apple Inc. All rights reserved. */ #ifndef _OS_OSBYTEORDERARM_H #define _OS_OSBYTEORDERARM_H #include <stdint.h> #include <arm/arch.h> /* for _ARM_ARCH_6 */ /* Generic byte swapping functions. */ __DARWIN_OS_INLINE uint16_t _OSSwapInt16( uint16_t _data ) { /* Reduces to 'rev16' with clang */ return (uint16_t)(_data << 8 | _data >> 8); } __DARWIN_OS_INLINE uint32_t _OSSwapInt32( uint32_t _data ) { #if defined(__llvm__) _data = __builtin_bswap32(_data); #else /* This actually generates the best code */ _data = (((_data ^ (_data >> 16 | (_data << 16))) & 0xFF00FFFF) >> 8) ^ (_data >> 8 | _data << 24); #endif return _data; } __DARWIN_OS_INLINE uint64_t _OSSwapInt64( uint64_t _data ) { #if defined(__llvm__) return __builtin_bswap64(_data); #else union { uint64_t _ull; uint32_t _ul[2]; } _u; /* This actually generates the best code */ _u._ul[0] = (uint32_t)(_data >> 32); _u._ul[1] = (uint32_t)(_data & 0xffffffff); _u._ul[0] = _OSSwapInt32(_u._ul[0]); _u._ul[1] = _OSSwapInt32(_u._ul[1]); return _u._ull; #endif } /* Functions for byte reversed loads. */ struct _OSUnalignedU16 { volatile uint16_t __val; } __attribute__((__packed__)); struct _OSUnalignedU32 { volatile uint32_t __val; } __attribute__((__packed__)); struct _OSUnalignedU64 { volatile uint64_t __val; } __attribute__((__packed__)); #if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) __DARWIN_OS_INLINE uint16_t _OSReadSwapInt16( const volatile void * _base, uintptr_t _offset ) { return _OSSwapInt16(((struct _OSUnalignedU16 *)((uintptr_t)_base + _offset))->__val); } #else __DARWIN_OS_INLINE uint16_t OSReadSwapInt16( const volatile void * _base, uintptr_t _offset ) { return _OSSwapInt16(((struct _OSUnalignedU16 *)((uintptr_t)_base + _offset))->__val); } #endif #if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) __DARWIN_OS_INLINE uint32_t _OSReadSwapInt32( const volatile void * _base, uintptr_t _offset ) { return _OSSwapInt32(((struct _OSUnalignedU32 *)((uintptr_t)_base + _offset))->__val); } #else __DARWIN_OS_INLINE uint32_t OSReadSwapInt32( const volatile void * _base, uintptr_t _offset ) { return _OSSwapInt32(((struct _OSUnalignedU32 *)((uintptr_t)_base + _offset))->__val); } #endif #if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) __DARWIN_OS_INLINE uint64_t _OSReadSwapInt64( const volatile void * _base, uintptr_t _offset ) { return _OSSwapInt64(((struct _OSUnalignedU64 *)((uintptr_t)_base + _offset))->__val); } #else __DARWIN_OS_INLINE uint64_t OSReadSwapInt64( const volatile void * _base, uintptr_t _offset ) { return _OSSwapInt64(((struct _OSUnalignedU64 *)((uintptr_t)_base + _offset))->__val); } #endif /* Functions for byte reversed stores. */ #if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) __DARWIN_OS_INLINE void _OSWriteSwapInt16( volatile void * _base, uintptr_t _offset, uint16_t _data ) { ((struct _OSUnalignedU16 *)((uintptr_t)_base + _offset))->__val = _OSSwapInt16(_data); } #else __DARWIN_OS_INLINE void OSWriteSwapInt16( volatile void * _base, uintptr_t _offset, uint16_t _data ) { ((struct _OSUnalignedU16 *)((uintptr_t)_base + _offset))->__val = _OSSwapInt16(_data); } #endif #if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) __DARWIN_OS_INLINE void _OSWriteSwapInt32( volatile void * _base, uintptr_t _offset, uint32_t _data ) { ((struct _OSUnalignedU32 *)((uintptr_t)_base + _offset))->__val = _OSSwapInt32(_data); } #else __DARWIN_OS_INLINE void OSWriteSwapInt32( volatile void * _base, uintptr_t _offset, uint32_t _data ) { ((struct _OSUnalignedU32 *)((uintptr_t)_base + _offset))->__val = _OSSwapInt32(_data); } #endif #if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) __DARWIN_OS_INLINE void _OSWriteSwapInt64( volatile void * _base, uintptr_t _offset, uint64_t _data ) { ((struct _OSUnalignedU64 *)((uintptr_t)_base + _offset))->__val = _OSSwapInt64(_data); } #else __DARWIN_OS_INLINE void OSWriteSwapInt64( volatile void * _base, uintptr_t _offset, uint64_t _data ) { ((struct _OSUnalignedU64 *)((uintptr_t)_base + _offset))->__val = _OSSwapInt64(_data); } #endif #endif /* ! _OS_OSBYTEORDERARM_H */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/i386/types.h
/* * 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@ */ /* * Copyright 1995 NeXT Computer, Inc. All rights reserved. */ /* * 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. 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. * * @(#)types.h 8.3 (Berkeley) 1/5/94 */ #ifndef _I386_MACHTYPES_H_ #define _I386_MACHTYPES_H_ #define _MACHTYPES_H_ #if defined (__i386__) || defined (__x86_64__) #ifndef __ASSEMBLER__ #include <i386/_types.h> #include <sys/cdefs.h> /* * Basic integral types. Omit the typedef if * not possible for a machine/compiler combination. */ #include <sys/_types/_int8_t.h> #include <sys/_types/_int16_t.h> #include <sys/_types/_int32_t.h> #include <sys/_types/_int64_t.h> #include <sys/_types/_u_int8_t.h> #include <sys/_types/_u_int16_t.h> #include <sys/_types/_u_int32_t.h> #include <sys/_types/_u_int64_t.h> #if __LP64__ typedef int64_t register_t; #else typedef int32_t register_t; #endif #include <sys/_types/_intptr_t.h> #include <sys/_types/_uintptr_t.h> #if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) /* These types are used for reserving the largest possible size. */ typedef u_int64_t user_addr_t; typedef u_int64_t user_size_t; typedef int64_t user_ssize_t; typedef int64_t user_long_t; typedef u_int64_t user_ulong_t; typedef int64_t user_time_t; typedef int64_t user_off_t; #define USER_ADDR_NULL ((user_addr_t) 0) #define CAST_USER_ADDR_T(a_ptr) ((user_addr_t)((uintptr_t)(a_ptr))) /* * These types are used when you know the word size of the target * user process. They can be used to create struct layouts independent * of the types and alignment requirements of the current running * kernel. */ /* * The default ABI for the 32-bit Intel userspace aligns fundamental * integral data types to their natural boundaries, with a maximum alignment * of 4, even for 8-byte quantites. The default ABI for 64-bit Intel * userspace aligns fundamental integral data types for their natural * boundaries, including those in composite data types. PowerPC applications * running under translation must conform to the 32-bit Intel ABI. */ typedef __uint64_t user64_addr_t __attribute__((aligned(8))); typedef __uint64_t user64_size_t __attribute__((aligned(8))); typedef __int64_t user64_ssize_t __attribute__((aligned(8))); typedef __int64_t user64_long_t __attribute__((aligned(8))); typedef __uint64_t user64_ulong_t __attribute__((aligned(8))); typedef __int64_t user64_time_t __attribute__((aligned(8))); typedef __int64_t user64_off_t __attribute__((aligned(8))); typedef __uint32_t user32_addr_t; typedef __uint32_t user32_size_t; typedef __int32_t user32_ssize_t; typedef __int32_t user32_long_t; typedef __uint32_t user32_ulong_t; typedef __int32_t user32_time_t; typedef __int64_t user32_off_t __attribute__((aligned(4))); #endif /* !_ANSI_SOURCE && (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ /* This defines the size of syscall arguments after copying into the kernel: */ typedef u_int64_t syscall_arg_t; #endif /* __ASSEMBLER__ */ #endif /* defined (__i386__) || defined (__x86_64__) */ #endif /* _I386_MACHTYPES_H_ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/i386/signal.h
/* * 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@ */ /* * Copyright (c) 1992 NeXT Computer, Inc. * */ #ifndef _I386_SIGNAL_H_ #define _I386_SIGNAL_H_ 1 #if defined (__i386__) || defined (__x86_64__) #include <sys/cdefs.h> #ifndef _ANSI_SOURCE typedef int sig_atomic_t; #endif /* ! _ANSI_SOURCE */ #endif /* defined (__i386__) || defined (__x86_64__) */ #endif /* _I386_SIGNAL_H_ */
0
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers
repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/i386/endian.h
/* * 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@ */ /* * Copyright 1995 NeXT Computer, Inc. All rights reserved. */ /* * Copyright (c) 1987, 1991, 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. * * @(#)endian.h 8.1 (Berkeley) 6/11/93 */ #ifndef _I386__ENDIAN_H_ #define _I386__ENDIAN_H_ #if defined (__i386__) || defined (__x86_64__) #include <sys/cdefs.h> /* * Define _NOQUAD if the compiler does NOT support 64-bit integers. */ /* #define _NOQUAD */ /* * Define the order of 32-bit words in 64-bit words. */ #define _QUAD_HIGHWORD 1 #define _QUAD_LOWWORD 0 /* * Definitions for byte order, according to byte significance from low * address to high. */ #define __DARWIN_LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ #define __DARWIN_BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ #define __DARWIN_PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ #define __DARWIN_BYTE_ORDER __DARWIN_LITTLE_ENDIAN #define LITTLE_ENDIAN __DARWIN_LITTLE_ENDIAN #define BIG_ENDIAN __DARWIN_BIG_ENDIAN #define PDP_ENDIAN __DARWIN_PDP_ENDIAN #define BYTE_ORDER __DARWIN_BYTE_ORDER #include <sys/_endian.h> #endif /* defined (__i386__) || defined (__x86_64__) */ #endif /* !_I386__ENDIAN_H_ */