Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | /* * Copyright (c) 2000-2007 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. The rights granted to you under the License * may not be used to create, or enable the creation or redistribution of, * unlawful or unlicensed copies of an Apple operating system, or to * circumvent, violate, or enable the circumvention or violation of, any * terms of an Apple operating system software license agreement. * * Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ /* * @OSF_COPYRIGHT@ */ #ifndef _KERN_KERN_TYPES_H_ #define _KERN_KERN_TYPES_H_ #include <stdint.h> #include <mach/mach_types.h> #include <mach/machine/vm_types.h> #ifdef KERNEL_PRIVATE #ifndef MACH_KERNEL_PRIVATE struct zone ; #ifndef __LP64__ struct wait_queue { unsigned int opaque[2]; uintptr_t opaquep[2]; } ; #else struct wait_queue { unsigned char opaque[32]; }; #endif #endif /* MACH_KERNEL_PRIVATE */ typedef struct zone *zone_t; #define ZONE_NULL ((zone_t) 0) typedef struct wait_queue *wait_queue_t; #define WAIT_QUEUE_NULL ((wait_queue_t) 0) #define SIZEOF_WAITQUEUE sizeof(struct wait_queue) typedef vm_offset_t ipc_kobject_t; #define IKO_NULL ((ipc_kobject_t) 0) #endif /* KERNEL_PRIVATE */ typedef void *event_t; /* wait event */ #define NO_EVENT ((event_t) 0) typedef uint64_t event64_t; /* 64 bit wait event */ #define NO_EVENT64 ((event64_t) 0) #define CAST_EVENT64_T(a_ptr) ((event64_t)((uintptr_t)(a_ptr))) /* * Possible wait_result_t values. */ typedef int wait_result_t; #define THREAD_WAITING -1 /* thread is waiting */ #define THREAD_AWAKENED 0 /* normal wakeup */ #define THREAD_TIMED_OUT 1 /* timeout expired */ #define THREAD_INTERRUPTED 2 /* aborted/interrupted */ #define THREAD_RESTART 3 /* restart operation entirely */ #define THREAD_NOT_WAITING 10 /* thread didn't need to wait */ typedef void (*thread_continue_t)(void *, wait_result_t); #define THREAD_CONTINUE_NULL ((thread_continue_t) 0) /* * Interruptible flag for waits. * * THREAD_UNINT: Uninterruptible wait * Wait will only end when someone explicitly wakes up the thread, or if the * wait timeout expires. * * Use this state if the system as a whole cannot recover from a thread being * interrupted out of the wait. * * THREAD_INTERRUPTIBLE: * Wait will end if someone explicitly wakes up the thread, the wait timeout * expires, or the current thread is being terminated. * * This value can be used when your operation may not be cleanly restartable * for the current process or thread (i.e. the loss of state would be only visible * to the current client). Since the thread is exiting anyways, you're willing * to cut the operation short. The system as a whole must be able to cleanly * deal with the interruption (i.e. remain in a consistent and recoverable state). * * THREAD_ABORTSAFE: * Wait will end if someone explicitly wakes up the thread, the wait timeout * expires, the current thread is being terminated, if any signal arrives for * the task, or thread_abort_safely() is called on the thread. * * Using this value means that you are willing to be interrupted in the face * of any user signal, and safely rewind the thread back to the user/kernel * boundary. Many syscalls will try to restart the operation they were performing * after the signal has been handled. * * You must provide this value for any unbounded wait - otherwise you will * pend user signals forever. * * Thread interrupt mask: * * The current maximum interruptible state for the thread, as set by * thread_interrupt_level(), will limit the conditions that will cause a wake. * This is useful for code that can't be interrupted to set before calling code * that doesn't know that. * * Thread termination vs safe abort: * * Termination abort: thread_abort(), thread_terminate() * * A termination abort is sticky. Once a thread is marked for termination, every * THREAD_INTERRUPTIBLE wait will return immediately with THREAD_INTERRUPTED * until the thread successfully exits. * * Safe abort: thread_abort_safely() * * A safe abort is not sticky. The current wait, (or the next wait if the thread * is not currently waiting) will be interrupted, but then the abort condition is cleared. * The next wait will sleep as normal. Safe aborts only have a single effect. * * The path back to the user/kernel boundary must not make any further unbounded * wait calls. The waiter should detect the THREAD_INTERRUPTED return code * from an ABORTSAFE wait and return an error code that causes its caller * to understand that the current operation has been interrupted, and its * caller should return a similar error code, and so on until the * user/kernel boundary is reached. For Mach, the error code is usually KERN_ABORTED, * for BSD it is EINTR. * * Debuggers rely on the safe abort mechanism - a signaled thread must return to * the AST at the user/kernel boundary for the debugger to finish attaching. * * No wait/block will ever disappear a thread out from under the waiter. The block * call will always either return or call the passed in continuation. */ typedef int wait_interrupt_t; #define THREAD_UNINT 0 /* not interruptible */ #define THREAD_INTERRUPTIBLE 1 /* may not be restartable */ #define THREAD_ABORTSAFE 2 /* abortable safely */ typedef int wait_timeout_urgency_t; #define TIMEOUT_URGENCY_SYS_NORMAL 0x00 /* use default leeway thresholds for system */ #define TIMEOUT_URGENCY_SYS_CRITICAL 0x01 /* use critical leeway thresholds for system */ #define TIMEOUT_URGENCY_SYS_BACKGROUND 0x02 /* use background leeway thresholds for system */ #define TIMEOUT_URGENCY_USER_MASK 0x10 /* mask to identify user timeout urgency classes */ #define TIMEOUT_URGENCY_USER_NORMAL 0x10 /* use default leeway thresholds for user */ #define TIMEOUT_URGENCY_USER_CRITICAL 0x11 /* use critical leeway thresholds for user */ #define TIMEOUT_URGENCY_USER_BACKGROUND 0x12 /* use background leeway thresholds for user */ #define TIMEOUT_URGENCY_MASK 0x13 /* mask to identify timeout urgency */ #define TIMEOUT_URGENCY_LEEWAY 0x20 /* don't ignore provided leeway value */ #define TIMEOUT_URGENCY_FIRST_AVAIL 0x40 /* first available bit outside of urgency mask/leeway */ #ifdef KERNEL_PRIVATE #ifdef MACH_KERNEL_PRIVATE #include <kern/misc_protos.h> typedef struct clock *clock_t; typedef struct mig_object *mig_object_t; #define MIG_OBJECT_NULL ((mig_object_t) 0) typedef struct mig_notify *mig_notify_t; #define MIG_NOTIFY_NULL ((mig_notify_t) 0) typedef struct pset_node *pset_node_t; #define PSET_NODE_NULL ((pset_node_t) 0) typedef struct affinity_set *affinity_set_t; #define AFFINITY_SET_NULL ((affinity_set_t) 0) typedef struct run_queue *run_queue_t; #define RUN_QUEUE_NULL ((run_queue_t) 0) typedef struct grrr_run_queue *grrr_run_queue_t; #define GRRR_RUN_QUEUE_NULL ((grrr_run_queue_t) 0) typedef struct grrr_group *grrr_group_t; #define GRRR_GROUP_NULL ((grrr_group_t) 0) #else /* MACH_KERNEL_PRIVATE */ struct wait_queue_set ; struct _wait_queue_link ; #endif /* MACH_KERNEL_PRIVATE */ typedef struct wait_queue_set *wait_queue_set_t; #define WAIT_QUEUE_SET_NULL ((wait_queue_set_t)0) #define SIZEOF_WAITQUEUE_SET wait_queue_set_size() typedef struct _wait_queue_link *wait_queue_link_t; #define WAIT_QUEUE_LINK_NULL ((wait_queue_link_t)0) #define SIZEOF_WAITQUEUE_LINK wait_queue_link_size() /* legacy definitions - going away */ struct wait_queue_sub ; typedef struct wait_queue_sub *wait_queue_sub_t; #define WAIT_QUEUE_SUB_NULL ((wait_queue_sub_t)0) #define SIZEOF_WAITQUEUE_SUB wait_queue_set_size() #endif /* KERNEL_PRIVATE */ #endif /* _KERN_KERN_TYPES_H_ */ |