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