#ifndef __DISPATCH_MACH_INTERNAL__
#define __DISPATCH_MACH_INTERNAL__
#if HAVE_MACH
#ifndef __DISPATCH_INDIRECT__
#error "Please #include <dispatch/dispatch.h> instead of this file directly."
#include <dispatch/base.h> // for HeaderDoc
#endif
enum {
DISPATCH_MACH_SEND_DELETED = 0x4,
};
enum {
DISPATCH_MACH_RECV_MESSAGE = 0x2,
};
DISPATCH_CLASS_DECL(mach, QUEUE);
DISPATCH_CLASS_DECL(mach_msg, OBJECT);
struct dispatch_mach_s {
DISPATCH_SOURCE_CLASS_HEADER(mach);
dispatch_mach_send_refs_t dm_send_refs;
dispatch_xpc_term_refs_t dm_xpc_term_refs;
} DISPATCH_ATOMIC64_ALIGN;
dispatch_assert_valid_lane_type(dispatch_mach_s);
struct dispatch_mach_msg_s {
DISPATCH_OBJECT_HEADER(mach_msg);
union {
mach_msg_option_t dmsg_options;
mach_error_t dmsg_error;
};
mach_port_t dmsg_reply;
pthread_priority_t dmsg_priority;
voucher_t dmsg_voucher;
dispatch_mach_msg_destructor_t dmsg_destructor;
size_t dmsg_size;
union {
mach_msg_header_t *dmsg_msg;
char dmsg_buf[0];
};
};
DISPATCH_ALWAYS_INLINE
static inline void
_dispatch_mach_xref_dispose(struct dispatch_mach_s *dm)
{
if (dm->dm_is_xpc) {
dm->dm_recv_refs->dmrr_handler_ctxt = (void *)0xbadfeed;
}
}
extern dispatch_mach_xpc_hooks_t _dispatch_mach_xpc_hooks;
extern const struct dispatch_mach_xpc_hooks_s _dispatch_mach_xpc_hooks_default;
void _dispatch_mach_msg_async_reply_invoke(dispatch_continuation_t dc,
dispatch_invoke_context_t dic, dispatch_invoke_flags_t flags);
void _dispatch_mach_dispose(dispatch_mach_t dm, bool *allow_free);
void _dispatch_mach_activate(dispatch_mach_t dm, bool *allow_resume);
void _dispatch_mach_invoke(dispatch_mach_t dm, dispatch_invoke_context_t dic,
dispatch_invoke_flags_t flags);
void _dispatch_mach_wakeup(dispatch_mach_t dm, dispatch_qos_t qos,
dispatch_wakeup_flags_t flags);
size_t _dispatch_mach_debug(dispatch_mach_t dm, char* buf, size_t bufsiz);
void _dispatch_mach_notification_merge_evt(dispatch_unote_t du,
uint32_t flags, uintptr_t data, pthread_priority_t pp);
void _dispatch_mach_merge_msg(dispatch_unote_t du, uint32_t flags,
mach_msg_header_t *msg, mach_msg_size_t msgsz,
pthread_priority_t msg_pp, pthread_priority_t ovr_pp);
void _dispatch_mach_reply_merge_msg(dispatch_unote_t du, uint32_t flags,
mach_msg_header_t *msg, mach_msg_size_t msgsz,
pthread_priority_t msg_pp, pthread_priority_t ovr_pp);
void _dispatch_xpc_sigterm_merge_evt(dispatch_unote_t du, uint32_t flags,
uintptr_t data, pthread_priority_t pp);
void _dispatch_mach_msg_dispose(dispatch_mach_msg_t dmsg, bool *allow_free);
void _dispatch_mach_msg_invoke(dispatch_mach_msg_t dmsg,
dispatch_invoke_context_t dic, dispatch_invoke_flags_t flags);
size_t _dispatch_mach_msg_debug(dispatch_mach_msg_t dmsg, char* buf,
size_t bufsiz);
void _dispatch_mach_send_barrier_drain_invoke(dispatch_continuation_t dc,
dispatch_invoke_context_t dic, dispatch_invoke_flags_t flags);
void _dispatch_mach_barrier_invoke(dispatch_continuation_t dc,
dispatch_invoke_context_t dic, dispatch_invoke_flags_t flags);
#endif // HAVE_MACH
#endif