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