+ return rv;
+}
+
+kern_return_t
+mach_port_construct(
+ ipc_space_t task,
+ mach_port_options_t *options,
+ mach_port_context_t context,
+ mach_port_name_t *name)
+{
+ kern_return_t rv;
+
+ rv = _kernelrpc_mach_port_construct_trap(task, options, (uint64_t) context, name);
+
+ if (rv == MACH_SEND_INVALID_DEST) {
+ rv = _kernelrpc_mach_port_construct(task, options, (uint64_t) context, name);
+ }
+
+ return rv;
+}
+
+kern_return_t
+mach_port_destruct(
+ ipc_space_t task,
+ mach_port_name_t name,
+ mach_port_delta_t srdelta,
+ mach_port_context_t guard)
+{
+ kern_return_t rv;
+
+ rv = _kernelrpc_mach_port_destruct_trap(task, name, srdelta, (uint64_t) guard);
+
+ if (rv == MACH_SEND_INVALID_DEST) {
+ rv = _kernelrpc_mach_port_destruct(task, name, srdelta, (uint64_t) guard);
+ }
+
+ return rv;
+}
+
+kern_return_t
+mach_port_guard(
+ ipc_space_t task,
+ mach_port_name_t name,
+ mach_port_context_t guard,
+ boolean_t strict)
+{
+ kern_return_t rv;
+
+ rv = _kernelrpc_mach_port_guard_trap(task, name, (uint64_t) guard, strict);
+
+ if (rv == MACH_SEND_INVALID_DEST) {
+ rv = _kernelrpc_mach_port_guard(task, name, (uint64_t) guard, strict);
+ }
+
+ return rv;
+}
+
+kern_return_t
+mach_port_unguard(
+ ipc_space_t task,
+ mach_port_name_t name,
+ mach_port_context_t guard)
+{
+ kern_return_t rv;
+
+ rv = _kernelrpc_mach_port_unguard_trap(task, name, (uint64_t) guard);
+
+ if (rv == MACH_SEND_INVALID_DEST) {
+ rv = _kernelrpc_mach_port_unguard(task, name, (uint64_t) guard);
+ }
+
+ return rv;
+}
+
+extern kern_return_t
+_kernelrpc_mach_voucher_extract_attr_recipe(
+ mach_port_name_t voucher,
+ mach_voucher_attr_key_t key,
+ mach_voucher_attr_raw_recipe_t recipe,
+ mach_msg_type_number_t *recipe_size);
+
+kern_return_t
+mach_voucher_extract_attr_recipe(
+ mach_port_name_t voucher,
+ mach_voucher_attr_key_t key,
+ mach_voucher_attr_raw_recipe_t recipe,
+ mach_msg_type_number_t *recipe_size)
+{
+ kern_return_t rv;
+
+ rv = mach_voucher_extract_attr_recipe_trap(voucher, key, recipe, recipe_size);
+
+ if (rv == MACH_SEND_INVALID_DEST) {
+ rv = _kernelrpc_mach_voucher_extract_attr_recipe(voucher, key, recipe, recipe_size);
+ }
+
+ return rv;
+}
+
+
+kern_return_t
+thread_destruct_special_reply_port(
+ mach_port_name_t port,
+ thread_destruct_special_reply_port_rights_t rights)
+{
+ switch (rights) {
+ case THREAD_SPECIAL_REPLY_PORT_ALL:
+ return mach_port_destruct(mach_task_self(), port, -1, 0);
+
+ case THREAD_SPECIAL_REPLY_PORT_RECEIVE_ONLY:
+ return mach_port_destruct(mach_task_self(), port, 0, 0);
+
+ case THREAD_SPECIAL_REPLY_PORT_SEND_ONLY:
+ return mach_port_deallocate(mach_task_self(), port);
+
+ default:
+ return KERN_INVALID_ARGUMENT;
+ }
+}
+
+kern_return_t
+mach_port_guard_with_flags(
+ ipc_space_t task,
+ mach_port_name_t name,
+ mach_port_context_t guard,
+ uint64_t flags)
+{
+ kern_return_t rv;
+
+ rv = _kernelrpc_mach_port_guard_with_flags(task, name, (uint64_t) guard, flags);
+
+ return rv;
+}
+
+kern_return_t
+mach_port_swap_guard(
+ ipc_space_t task,
+ mach_port_name_t name,
+ mach_port_context_t old_guard,
+ mach_port_context_t new_guard)
+{
+ kern_return_t rv;
+
+ rv = _kernelrpc_mach_port_swap_guard(task, name, (uint64_t)old_guard, (uint64_t)new_guard);
+
+ return rv;