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