]> git.saurik.com Git - apple/libdispatch.git/blob - private/private.h
libdispatch-187.9.tar.gz
[apple/libdispatch.git] / private / private.h
1 /*
2 * Copyright (c) 2008-2011 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 #define DISPATCH_NO_LEGACY 1
48 #ifdef DISPATCH_LEGACY // <rdar://problem/7366725>
49 #error "Dispatch legacy API unavailable."
50 #endif
51
52 #ifndef __DISPATCH_BUILDING_DISPATCH__
53 #include_next <dispatch/dispatch.h>
54
55 // Workaround <rdar://problem/6597365/>
56 #ifndef __DISPATCH_PUBLIC__
57 #include "/usr/include/dispatch/dispatch.h"
58 #endif
59
60 #ifndef __DISPATCH_INDIRECT__
61 #define __DISPATCH_INDIRECT__
62 #endif
63
64 #include <dispatch/benchmark.h>
65 #include <dispatch/queue_private.h>
66 #include <dispatch/source_private.h>
67
68 #undef __DISPATCH_INDIRECT__
69
70 #endif /* !__DISPATCH_BUILDING_DISPATCH__ */
71
72 /* LEGACY: Use DISPATCH_API_VERSION */
73 #define LIBDISPATCH_VERSION DISPATCH_API_VERSION
74
75 __BEGIN_DECLS
76
77 DISPATCH_EXPORT DISPATCH_NOTHROW
78 void
79 libdispatch_init(void);
80
81 #if TARGET_OS_MAC
82 #define DISPATCH_COCOA_COMPAT 1
83 #if DISPATCH_COCOA_COMPAT
84
85 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
86 DISPATCH_EXPORT DISPATCH_CONST DISPATCH_WARN_RESULT DISPATCH_NOTHROW
87 mach_port_t
88 _dispatch_get_main_queue_port_4CF(void);
89
90 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
91 DISPATCH_EXPORT DISPATCH_NOTHROW
92 void
93 _dispatch_main_queue_callback_4CF(mach_msg_header_t *msg);
94
95 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
96 DISPATCH_EXPORT
97 void (*dispatch_begin_thread_4GC)(void);
98
99 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
100 DISPATCH_EXPORT
101 void (*dispatch_end_thread_4GC)(void);
102
103 __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_3)
104 DISPATCH_EXPORT
105 void (*dispatch_no_worker_threads_4GC)(void);
106
107 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
108 DISPATCH_EXPORT
109 void *(*_dispatch_begin_NSAutoReleasePool)(void);
110
111 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
112 DISPATCH_EXPORT
113 void (*_dispatch_end_NSAutoReleasePool)(void *);
114
115 #define _dispatch_time_after_nsec(t) \
116 dispatch_time(DISPATCH_TIME_NOW, (t))
117 #define _dispatch_time_after_usec(t) \
118 dispatch_time(DISPATCH_TIME_NOW, (t) * NSEC_PER_USEC)
119 #define _dispatch_time_after_msec(t) \
120 dispatch_time(DISPATCH_TIME_NOW, (t) * NSEC_PER_MSEC)
121 #define _dispatch_time_after_sec(t) \
122 dispatch_time(DISPATCH_TIME_NOW, (t) * NSEC_PER_SEC)
123
124 #endif
125 #endif /* TARGET_OS_MAC */
126
127 /* pthreads magic */
128
129 DISPATCH_EXPORT DISPATCH_NOTHROW void dispatch_atfork_prepare(void);
130 DISPATCH_EXPORT DISPATCH_NOTHROW void dispatch_atfork_parent(void);
131 DISPATCH_EXPORT DISPATCH_NOTHROW void dispatch_atfork_child(void);
132
133 #if TARGET_OS_MAC
134 /*
135 * Extract the context pointer from a mach message trailer.
136 */
137 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
138 DISPATCH_EXPORT DISPATCH_PURE DISPATCH_WARN_RESULT DISPATCH_NONNULL_ALL
139 DISPATCH_NOTHROW
140 void *
141 dispatch_mach_msg_get_context(mach_msg_header_t *msg);
142 #endif /* TARGET_OS_MAC */
143
144 __END_DECLS
145
146 #endif