]> git.saurik.com Git - apple/libdispatch.git/blob - src/mach_internal.h
libdispatch-913.1.6.tar.gz
[apple/libdispatch.git] / src / mach_internal.h
1 /*
2 * Copyright (c) 2008-2016 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_MACH_INTERNAL__
28 #define __DISPATCH_MACH_INTERNAL__
29 #if HAVE_MACH
30
31 #ifndef __DISPATCH_INDIRECT__
32 #error "Please #include <dispatch/dispatch.h> instead of this file directly."
33 #include <dispatch/base.h> // for HeaderDoc
34 #endif
35
36 // NOTE: dispatch_source_mach_send_flags_t and dispatch_source_mach_recv_flags_t
37 // bit values must not overlap as they share the same kevent fflags !
38
39 /*!
40 * @enum dispatch_source_mach_send_flags_t
41 *
42 * @constant DISPATCH_MACH_SEND_DELETED
43 * Port-deleted notification. Disabled for source registration.
44 */
45 enum {
46 DISPATCH_MACH_SEND_DELETED = 0x4,
47 };
48 /*!
49 * @enum dispatch_source_mach_recv_flags_t
50 *
51 * @constant DISPATCH_MACH_RECV_MESSAGE
52 * Receive right has pending messages
53 */
54 enum {
55 DISPATCH_MACH_RECV_MESSAGE = 0x2,
56 };
57
58
59 DISPATCH_CLASS_DECL(mach);
60 DISPATCH_CLASS_DECL(mach_msg);
61
62 #ifndef __cplusplus
63 struct dispatch_mach_s {
64 DISPATCH_SOURCE_HEADER(mach);
65 dispatch_mach_send_refs_t dm_send_refs;
66 dispatch_xpc_term_refs_t dm_xpc_term_refs;
67 } DISPATCH_ATOMIC64_ALIGN;
68
69 struct dispatch_mach_msg_s {
70 DISPATCH_OBJECT_HEADER(mach_msg);
71 union {
72 mach_msg_option_t dmsg_options;
73 mach_error_t dmsg_error;
74 };
75 mach_port_t dmsg_reply;
76 pthread_priority_t dmsg_priority;
77 voucher_t dmsg_voucher;
78 dispatch_mach_msg_destructor_t dmsg_destructor;
79 size_t dmsg_size;
80 union {
81 mach_msg_header_t *dmsg_msg;
82 char dmsg_buf[0];
83 };
84 };
85
86 DISPATCH_ALWAYS_INLINE
87 static inline void
88 _dispatch_mach_xref_dispose(struct dispatch_mach_s *dm)
89 {
90 if (dm->dm_is_xpc) {
91 dm->dm_recv_refs->dmrr_handler_ctxt = (void *)0xbadfeed;
92 }
93 }
94 #endif // __cplusplus
95
96 dispatch_source_t
97 _dispatch_source_create_mach_msg_direct_recv(mach_port_t recvp,
98 const struct dispatch_continuation_s *dc);
99
100 void _dispatch_mach_msg_async_reply_invoke(dispatch_continuation_t dc,
101 dispatch_invoke_context_t dic, dispatch_invoke_flags_t flags);
102 void _dispatch_mach_dispose(dispatch_mach_t dm, bool *allow_free);
103 void _dispatch_mach_finalize_activation(dispatch_mach_t dm, bool *allow_resume);
104 void _dispatch_mach_invoke(dispatch_mach_t dm, dispatch_invoke_context_t dic,
105 dispatch_invoke_flags_t flags);
106 void _dispatch_mach_wakeup(dispatch_mach_t dm, dispatch_qos_t qos,
107 dispatch_wakeup_flags_t flags);
108 size_t _dispatch_mach_debug(dispatch_mach_t dm, char* buf, size_t bufsiz);
109 void _dispatch_mach_merge_notification(dispatch_unote_t du,
110 uint32_t flags, uintptr_t data, uintptr_t status,
111 pthread_priority_t pp);
112 void _dispatch_mach_merge_msg(dispatch_unote_t du, uint32_t flags,
113 mach_msg_header_t *msg, mach_msg_size_t msgsz);
114 void _dispatch_mach_reply_merge_msg(dispatch_unote_t du, uint32_t flags,
115 mach_msg_header_t *msg, mach_msg_size_t msgsz);
116 void _dispatch_xpc_sigterm_merge(dispatch_unote_t du, uint32_t flags,
117 uintptr_t data, uintptr_t status, pthread_priority_t pp);
118
119 void _dispatch_mach_msg_dispose(dispatch_mach_msg_t dmsg, bool *allow_free);
120 void _dispatch_mach_msg_invoke(dispatch_mach_msg_t dmsg,
121 dispatch_invoke_context_t dic, dispatch_invoke_flags_t flags);
122 size_t _dispatch_mach_msg_debug(dispatch_mach_msg_t dmsg, char* buf,
123 size_t bufsiz);
124
125 void _dispatch_mach_send_barrier_drain_invoke(dispatch_continuation_t dc,
126 dispatch_invoke_context_t dic, dispatch_invoke_flags_t flags);
127 void _dispatch_mach_barrier_invoke(dispatch_continuation_t dc,
128 dispatch_invoke_context_t dic, dispatch_invoke_flags_t flags);
129
130 #endif // HAVE_MACH
131 #endif /* __DISPATCH_MACH_INTERNAL__ */