]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (c) 2008-2013 Apple Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_APACHE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
7 | * you may not use this file except in compliance with the License. | |
8 | * You may obtain a copy of the License at | |
9 | * | |
10 | * http://www.apache.org/licenses/LICENSE-2.0 | |
11 | * | |
12 | * Unless required by applicable law or agreed to in writing, software | |
13 | * distributed under the License is distributed on an "AS IS" BASIS, | |
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
15 | * See the License for the specific language governing permissions and | |
16 | * limitations under the License. | |
17 | * | |
18 | * @APPLE_APACHE_LICENSE_HEADER_END@ | |
19 | */ | |
20 | ||
21 | /* | |
22 | * IMPORTANT: This header file describes INTERNAL interfaces to libdispatch | |
23 | * which are subject to change in future releases of Mac OS X. Any applications | |
24 | * relying on these interfaces WILL break. | |
25 | */ | |
26 | ||
27 | #ifndef __DISPATCH_PRIVATE__ | |
28 | #define __DISPATCH_PRIVATE__ | |
29 | ||
30 | #ifdef __APPLE__ | |
31 | #include <TargetConditionals.h> | |
32 | #endif | |
33 | ||
34 | #if TARGET_OS_MAC | |
35 | #include <mach/boolean.h> | |
36 | #include <mach/mach.h> | |
37 | #include <mach/message.h> | |
38 | #endif | |
39 | #if HAVE_UNISTD_H | |
40 | #include <unistd.h> | |
41 | #endif | |
42 | #if HAVE_SYS_CDEFS_H | |
43 | #include <sys/cdefs.h> | |
44 | #endif | |
45 | #include <pthread.h> | |
46 | ||
47 | #ifndef __DISPATCH_BUILDING_DISPATCH__ | |
48 | #include <dispatch/dispatch.h> | |
49 | ||
50 | #ifndef __DISPATCH_INDIRECT__ | |
51 | #define __DISPATCH_INDIRECT__ | |
52 | #endif | |
53 | ||
54 | #include <dispatch/benchmark.h> | |
55 | #include <dispatch/queue_private.h> | |
56 | #include <dispatch/source_private.h> | |
57 | #include <dispatch/mach_private.h> | |
58 | #include <dispatch/data_private.h> | |
59 | #include <dispatch/io_private.h> | |
60 | ||
61 | #undef __DISPATCH_INDIRECT__ | |
62 | ||
63 | #endif /* !__DISPATCH_BUILDING_DISPATCH__ */ | |
64 | ||
65 | // <rdar://problem/9627726> Check that public and private dispatch headers match | |
66 | #if DISPATCH_API_VERSION != 20130520 // Keep in sync with <dispatch/dispatch.h> | |
67 | #error "Dispatch header mismatch between /usr/include and /usr/local/include" | |
68 | #endif | |
69 | ||
70 | __BEGIN_DECLS | |
71 | ||
72 | /*! | |
73 | * @function _dispatch_is_multithreaded | |
74 | * | |
75 | * @abstract | |
76 | * Returns true if the current process has become multithreaded by the use | |
77 | * of libdispatch functionality. | |
78 | * | |
79 | * @discussion | |
80 | * This SPI is intended for use by low-level system components that need to | |
81 | * ensure that they do not make a single-threaded process multithreaded, to | |
82 | * avoid negatively affecting child processes of a fork (without exec). | |
83 | * | |
84 | * Such components must not use any libdispatch functionality if this function | |
85 | * returns false. | |
86 | * | |
87 | * @result | |
88 | * Boolean indicating whether the process has used libdispatch and become | |
89 | * multithreaded. | |
90 | */ | |
91 | __OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_6_0) | |
92 | DISPATCH_EXPORT DISPATCH_NOTHROW | |
93 | bool _dispatch_is_multithreaded(void); | |
94 | ||
95 | /*! | |
96 | * @function _dispatch_is_fork_of_multithreaded_parent | |
97 | * | |
98 | * @abstract | |
99 | * Returns true if the current process is a child of a parent process that had | |
100 | * become multithreaded by the use of libdispatch functionality at the time of | |
101 | * fork (without exec). | |
102 | * | |
103 | * @discussion | |
104 | * This SPI is intended for use by (rare) low-level system components that need | |
105 | * to continue working on the child side of a fork (without exec) of a | |
106 | * multithreaded process. | |
107 | * | |
108 | * Such components must not use any libdispatch functionality if this function | |
109 | * returns true. | |
110 | * | |
111 | * @result | |
112 | * Boolean indicating whether the parent process had used libdispatch and | |
113 | * become multithreaded at the time of fork. | |
114 | */ | |
115 | __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0) | |
116 | DISPATCH_EXPORT DISPATCH_NOTHROW | |
117 | bool _dispatch_is_fork_of_multithreaded_parent(void); | |
118 | ||
119 | /* | |
120 | * dispatch_time convenience macros | |
121 | */ | |
122 | ||
123 | #define _dispatch_time_after_nsec(t) \ | |
124 | dispatch_time(DISPATCH_TIME_NOW, (t)) | |
125 | #define _dispatch_time_after_usec(t) \ | |
126 | dispatch_time(DISPATCH_TIME_NOW, (t) * NSEC_PER_USEC) | |
127 | #define _dispatch_time_after_msec(t) \ | |
128 | dispatch_time(DISPATCH_TIME_NOW, (t) * NSEC_PER_MSEC) | |
129 | #define _dispatch_time_after_sec(t) \ | |
130 | dispatch_time(DISPATCH_TIME_NOW, (t) * NSEC_PER_SEC) | |
131 | ||
132 | /* | |
133 | * SPI for CoreFoundation/Foundation/libauto ONLY | |
134 | */ | |
135 | ||
136 | #define DISPATCH_COCOA_COMPAT (TARGET_OS_MAC || TARGET_OS_WIN32) | |
137 | ||
138 | #if DISPATCH_COCOA_COMPAT | |
139 | ||
140 | #if TARGET_OS_MAC | |
141 | __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0) | |
142 | DISPATCH_EXPORT DISPATCH_CONST DISPATCH_WARN_RESULT DISPATCH_NOTHROW | |
143 | mach_port_t | |
144 | _dispatch_get_main_queue_port_4CF(void); | |
145 | ||
146 | __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0) | |
147 | DISPATCH_EXPORT DISPATCH_NOTHROW | |
148 | void | |
149 | _dispatch_main_queue_callback_4CF(mach_msg_header_t *msg); | |
150 | #elif TARGET_OS_WIN32 | |
151 | __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0) | |
152 | DISPATCH_EXPORT DISPATCH_NOTHROW | |
153 | HANDLE | |
154 | _dispatch_get_main_queue_handle_4CF(void); | |
155 | ||
156 | __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0) | |
157 | DISPATCH_EXPORT DISPATCH_NOTHROW | |
158 | void | |
159 | _dispatch_main_queue_callback_4CF(void); | |
160 | #endif // TARGET_OS_WIN32 | |
161 | ||
162 | __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0) | |
163 | DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT | |
164 | DISPATCH_NOTHROW | |
165 | dispatch_queue_t | |
166 | _dispatch_runloop_root_queue_create_4CF(const char *label, unsigned long flags); | |
167 | ||
168 | #if TARGET_OS_MAC | |
169 | __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0) | |
170 | DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_NOTHROW | |
171 | mach_port_t | |
172 | _dispatch_runloop_root_queue_get_port_4CF(dispatch_queue_t queue); | |
173 | #endif | |
174 | ||
175 | __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0) | |
176 | DISPATCH_EXPORT DISPATCH_NOTHROW | |
177 | void | |
178 | _dispatch_runloop_root_queue_wakeup_4CF(dispatch_queue_t queue); | |
179 | ||
180 | __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0) | |
181 | DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_NOTHROW | |
182 | bool | |
183 | _dispatch_runloop_root_queue_perform_4CF(dispatch_queue_t queue); | |
184 | ||
185 | __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0) | |
186 | DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW | |
187 | void | |
188 | _dispatch_source_set_runloop_timer_4CF(dispatch_source_t source, | |
189 | dispatch_time_t start, uint64_t interval, uint64_t leeway); | |
190 | ||
191 | __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0) | |
192 | DISPATCH_EXPORT | |
193 | void (*dispatch_begin_thread_4GC)(void); | |
194 | ||
195 | __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0) | |
196 | DISPATCH_EXPORT | |
197 | void (*dispatch_end_thread_4GC)(void); | |
198 | __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0) | |
199 | DISPATCH_EXPORT | |
200 | void *(*_dispatch_begin_NSAutoReleasePool)(void); | |
201 | ||
202 | __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0) | |
203 | DISPATCH_EXPORT | |
204 | void (*_dispatch_end_NSAutoReleasePool)(void *); | |
205 | ||
206 | #endif /* DISPATCH_COCOA_COMPAT */ | |
207 | ||
208 | __END_DECLS | |
209 | ||
210 | #endif // __DISPATCH_PRIVATE__ |