]> git.saurik.com Git - apple/libdispatch.git/blob - private/private.h
libdispatch-228.18.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 #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/data_private.h>
58
59 #undef __DISPATCH_INDIRECT__
60
61 #endif /* !__DISPATCH_BUILDING_DISPATCH__ */
62
63 // <rdar://problem/9627726> Check that public and private dispatch headers match
64 #if DISPATCH_API_VERSION != 20111201 // Keep in sync with <dispatch/dispatch.h>
65 #error "Dispatch header mismatch between /usr/include and /usr/local/include"
66 #endif
67
68 __BEGIN_DECLS
69
70 DISPATCH_EXPORT DISPATCH_NOTHROW
71 void
72 libdispatch_init(void);
73
74 #if TARGET_OS_MAC
75 #define DISPATCH_COCOA_COMPAT 1
76 #if DISPATCH_COCOA_COMPAT
77
78 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
79 DISPATCH_EXPORT DISPATCH_CONST DISPATCH_WARN_RESULT DISPATCH_NOTHROW
80 mach_port_t
81 _dispatch_get_main_queue_port_4CF(void);
82
83 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
84 DISPATCH_EXPORT DISPATCH_NOTHROW
85 void
86 _dispatch_main_queue_callback_4CF(mach_msg_header_t *msg);
87
88 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
89 DISPATCH_EXPORT
90 void (*dispatch_begin_thread_4GC)(void);
91
92 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
93 DISPATCH_EXPORT
94 void (*dispatch_end_thread_4GC)(void);
95
96 __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_3)
97 DISPATCH_EXPORT
98 void (*dispatch_no_worker_threads_4GC)(void);
99
100 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
101 DISPATCH_EXPORT
102 void *(*_dispatch_begin_NSAutoReleasePool)(void);
103
104 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
105 DISPATCH_EXPORT
106 void (*_dispatch_end_NSAutoReleasePool)(void *);
107
108 __OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_6_0)
109 DISPATCH_EXPORT DISPATCH_NOTHROW
110 bool _dispatch_is_multithreaded(void);
111
112 #define _dispatch_time_after_nsec(t) \
113 dispatch_time(DISPATCH_TIME_NOW, (t))
114 #define _dispatch_time_after_usec(t) \
115 dispatch_time(DISPATCH_TIME_NOW, (t) * NSEC_PER_USEC)
116 #define _dispatch_time_after_msec(t) \
117 dispatch_time(DISPATCH_TIME_NOW, (t) * NSEC_PER_MSEC)
118 #define _dispatch_time_after_sec(t) \
119 dispatch_time(DISPATCH_TIME_NOW, (t) * NSEC_PER_SEC)
120
121 #endif
122 #endif /* TARGET_OS_MAC */
123
124 /* pthreads magic */
125
126 DISPATCH_EXPORT DISPATCH_NOTHROW void dispatch_atfork_prepare(void);
127 DISPATCH_EXPORT DISPATCH_NOTHROW void dispatch_atfork_parent(void);
128 DISPATCH_EXPORT DISPATCH_NOTHROW void dispatch_atfork_child(void);
129
130 #if TARGET_OS_MAC
131 /*
132 * Extract the context pointer from a mach message trailer.
133 */
134 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
135 DISPATCH_EXPORT DISPATCH_PURE DISPATCH_WARN_RESULT DISPATCH_NONNULL_ALL
136 DISPATCH_NOTHROW
137 void *
138 dispatch_mach_msg_get_context(mach_msg_header_t *msg);
139 #endif /* TARGET_OS_MAC */
140
141 __END_DECLS
142
143 #endif