]> git.saurik.com Git - apple/xnu.git/blob - osfmk/kern/thread_call.h
xnu-792.6.56.tar.gz
[apple/xnu.git] / osfmk / kern / thread_call.h
1 /*
2 * Copyright (c) 1993-1995, 1999-2005 Apple Computer, Inc.
3 * All rights reserved.
4 *
5 * @APPLE_LICENSE_HEADER_START@
6 *
7 * This file contains Original Code and/or Modifications of Original Code
8 * as defined in and that are subject to the Apple Public Source License
9 * Version 2.0 (the 'License'). You may not use this file except in
10 * compliance with the License. Please obtain a copy of the License at
11 * http://www.opensource.apple.com/apsl/ and read it before using this
12 * file.
13 *
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 * Please see the License for the specific language governing rights and
20 * limitations under the License.
21 *
22 * @APPLE_LICENSE_HEADER_END@
23 */
24 /*
25 * Declarations for thread-based callouts.
26 */
27
28 #ifndef _KERN_THREAD_CALL_H_
29 #define _KERN_THREAD_CALL_H_
30
31 #include <mach/mach_types.h>
32
33 #include <kern/clock.h>
34
35 #include <sys/cdefs.h>
36
37 typedef struct call_entry *thread_call_t;
38 typedef void *thread_call_param_t;
39 typedef void (*thread_call_func_t)(
40 thread_call_param_t param0,
41 thread_call_param_t param1);
42 __BEGIN_DECLS
43
44 boolean_t
45 thread_call_enter(
46 thread_call_t call
47 );
48
49 boolean_t
50 thread_call_enter1(
51 thread_call_t call,
52 thread_call_param_t param1
53 );
54
55 boolean_t
56 thread_call_enter_delayed(
57 thread_call_t call,
58 uint64_t deadline
59 );
60
61 boolean_t
62 thread_call_enter1_delayed(
63 thread_call_t call,
64 thread_call_param_t param1,
65 uint64_t deadline
66 );
67
68 boolean_t
69 thread_call_cancel(
70 thread_call_t call
71 );
72
73 thread_call_t
74 thread_call_allocate(
75 thread_call_func_t func,
76 thread_call_param_t param0
77 );
78
79 boolean_t
80 thread_call_free(
81 thread_call_t call
82 );
83
84 __END_DECLS
85
86 #ifdef MACH_KERNEL_PRIVATE
87
88 #include <kern/call_entry.h>
89
90 typedef struct call_entry thread_call_data_t;
91
92 void
93 thread_call_initialize(void);
94
95 void
96 thread_call_setup(
97 thread_call_t call,
98 thread_call_func_t func,
99 thread_call_param_t param0
100 );
101
102 void
103 call_thread_block(void),
104 call_thread_unblock(void);
105
106 #endif /* MACH_KERNEL_PRIVATE */
107
108 #ifdef KERNEL_PRIVATE
109
110 __BEGIN_DECLS
111
112 /*
113 * Obsolete interfaces.
114 */
115
116 boolean_t
117 thread_call_is_delayed(
118 thread_call_t call,
119 uint64_t *deadline
120 );
121
122 void
123 thread_call_func(
124 thread_call_func_t func,
125 thread_call_param_t param,
126 boolean_t unique_call
127 );
128
129 void
130 thread_call_func_delayed(
131 thread_call_func_t func,
132 thread_call_param_t param,
133 uint64_t deadline
134 );
135
136 boolean_t
137 thread_call_func_cancel(
138 thread_call_func_t func,
139 thread_call_param_t param,
140 boolean_t cancel_all
141 );
142
143 #ifndef MACH_KERNEL_PRIVATE
144
145 #ifndef ABSOLUTETIME_SCALAR_TYPE
146
147 #define thread_call_enter_delayed(a, b) \
148 thread_call_enter_delayed((a), __OSAbsoluteTime(b))
149
150 #define thread_call_enter1_delayed(a, b, c) \
151 thread_call_enter1_delayed((a), (b), __OSAbsoluteTime(c))
152
153 #define thread_call_is_delayed(a, b) \
154 thread_call_is_delayed((a), __OSAbsoluteTimePtr(b))
155
156 #define thread_call_func_delayed(a, b, c) \
157 thread_call_func_delayed((a), (b), __OSAbsoluteTime(c))
158
159 #endif /* ABSOLUTETIME_SCALAR_TYPE */
160
161 #endif /* MACH_KERNEL_PRIVATE */
162
163 __END_DECLS
164
165 #endif /* KERNEL_PRIVATE */
166
167 #endif /* _KERN_THREAD_CALL_H_ */