2 * Copyright (c) 2008-2016 Apple Inc. All rights reserved.
4 * @APPLE_APACHE_LICENSE_HEADER_START@
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @APPLE_APACHE_LICENSE_HEADER_END@
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.
27 #ifndef __DISPATCH_MACH_INTERNAL__
28 #define __DISPATCH_MACH_INTERNAL__
31 #ifndef __DISPATCH_INDIRECT__
32 #error "Please #include <dispatch/dispatch.h> instead of this file directly."
33 #include <dispatch/base.h> // for HeaderDoc
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 !
40 * @enum dispatch_source_mach_send_flags_t
42 * @constant DISPATCH_MACH_SEND_DELETED
43 * Port-deleted notification. Disabled for source registration.
46 DISPATCH_MACH_SEND_DELETED
= 0x4,
49 * @enum dispatch_source_mach_recv_flags_t
51 * @constant DISPATCH_MACH_RECV_MESSAGE
52 * Receive right has pending messages
55 DISPATCH_MACH_RECV_MESSAGE
= 0x2,
59 DISPATCH_CLASS_DECL(mach
);
60 DISPATCH_CLASS_DECL(mach_msg
);
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
;
69 struct dispatch_mach_msg_s
{
70 DISPATCH_OBJECT_HEADER(mach_msg
);
72 mach_msg_option_t dmsg_options
;
73 mach_error_t dmsg_error
;
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
;
81 mach_msg_header_t
*dmsg_msg
;
86 DISPATCH_ALWAYS_INLINE
88 _dispatch_mach_xref_dispose(struct dispatch_mach_s
*dm
)
91 dm
->dm_recv_refs
->dmrr_handler_ctxt
= (void *)0xbadfeed;
97 _dispatch_source_create_mach_msg_direct_recv(mach_port_t recvp
,
98 const struct dispatch_continuation_s
*dc
);
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
);
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
,
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
);
131 #endif /* __DISPATCH_MACH_INTERNAL__ */