]> git.saurik.com Git - apple/libdispatch.git/blame - private/private.h
libdispatch-339.92.1.tar.gz
[apple/libdispatch.git] / private / private.h
CommitLineData
0ab74447 1/*
517da941 2 * Copyright (c) 2008-2013 Apple Inc. All rights reserved.
0ab74447
A
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
e85f4437 5 *
0ab74447
A
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
e85f4437 9 *
0ab74447 10 * http://www.apache.org/licenses/LICENSE-2.0
e85f4437 11 *
0ab74447
A
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.
e85f4437 17 *
0ab74447
A
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
e85f4437
A
30#ifdef __APPLE__
31#include <TargetConditionals.h>
32#endif
33
34#if TARGET_OS_MAC
0ab74447
A
35#include <mach/boolean.h>
36#include <mach/mach.h>
37#include <mach/message.h>
e85f4437
A
38#endif
39#if HAVE_UNISTD_H
0ab74447 40#include <unistd.h>
e85f4437
A
41#endif
42#if HAVE_SYS_CDEFS_H
0ab74447 43#include <sys/cdefs.h>
e85f4437 44#endif
0ab74447
A
45#include <pthread.h>
46
47#ifndef __DISPATCH_BUILDING_DISPATCH__
c093abd6 48#include <dispatch/dispatch.h>
0ab74447
A
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>
517da941 57#include <dispatch/mach_private.h>
c093abd6 58#include <dispatch/data_private.h>
517da941 59#include <dispatch/io_private.h>
0ab74447 60
0ab74447
A
61#undef __DISPATCH_INDIRECT__
62
63#endif /* !__DISPATCH_BUILDING_DISPATCH__ */
64
c093abd6 65// <rdar://problem/9627726> Check that public and private dispatch headers match
517da941 66#if DISPATCH_API_VERSION != 20130520 // Keep in sync with <dispatch/dispatch.h>
c093abd6
A
67#error "Dispatch header mismatch between /usr/include and /usr/local/include"
68#endif
0ab74447
A
69
70__BEGIN_DECLS
71
517da941
A
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)
e85f4437 92DISPATCH_EXPORT DISPATCH_NOTHROW
517da941
A
93bool _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)
116DISPATCH_EXPORT DISPATCH_NOTHROW
117bool _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)
0ab74447 137
0ab74447
A
138#if DISPATCH_COCOA_COMPAT
139
517da941 140#if TARGET_OS_MAC
e85f4437
A
141__OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
142DISPATCH_EXPORT DISPATCH_CONST DISPATCH_WARN_RESULT DISPATCH_NOTHROW
0ab74447
A
143mach_port_t
144_dispatch_get_main_queue_port_4CF(void);
145
e85f4437
A
146__OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
147DISPATCH_EXPORT DISPATCH_NOTHROW
0ab74447
A
148void
149_dispatch_main_queue_callback_4CF(mach_msg_header_t *msg);
517da941
A
150#elif TARGET_OS_WIN32
151__OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
152DISPATCH_EXPORT DISPATCH_NOTHROW
153HANDLE
154_dispatch_get_main_queue_handle_4CF(void);
155
156__OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
157DISPATCH_EXPORT DISPATCH_NOTHROW
158void
159_dispatch_main_queue_callback_4CF(void);
160#endif // TARGET_OS_WIN32
161
162__OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0)
163DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT
164DISPATCH_NOTHROW
165dispatch_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)
170DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_NOTHROW
171mach_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)
176DISPATCH_EXPORT DISPATCH_NOTHROW
177void
178_dispatch_runloop_root_queue_wakeup_4CF(dispatch_queue_t queue);
179
180__OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0)
181DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_NOTHROW
182bool
183_dispatch_runloop_root_queue_perform_4CF(dispatch_queue_t queue);
184
185__OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0)
186DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
187void
188_dispatch_source_set_runloop_timer_4CF(dispatch_source_t source,
189 dispatch_time_t start, uint64_t interval, uint64_t leeway);
0ab74447 190
e85f4437
A
191__OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
192DISPATCH_EXPORT
193void (*dispatch_begin_thread_4GC)(void);
194
195__OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
196DISPATCH_EXPORT
197void (*dispatch_end_thread_4GC)(void);
e85f4437
A
198__OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
199DISPATCH_EXPORT
200void *(*_dispatch_begin_NSAutoReleasePool)(void);
0ab74447 201
e85f4437
A
202__OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
203DISPATCH_EXPORT
204void (*_dispatch_end_NSAutoReleasePool)(void *);
205
517da941 206#endif /* DISPATCH_COCOA_COMPAT */
0ab74447
A
207
208__END_DECLS
209
517da941 210#endif // __DISPATCH_PRIVATE__