2 * Copyright (c) 2008-2009 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@
25 dispatch_mach_msg_get_context(mach_msg_header_t *msg)
27 mach_msg_context_trailer_t *tp;
30 tp = (mach_msg_context_trailer_t *)((uint8_t *)msg + round_msg(msg->msgh_size));
31 if (tp->msgh_trailer_size >= (mach_msg_size_t)sizeof(mach_msg_context_trailer_t)) {
32 context = (void *)(uintptr_t)tp->msgh_context;
38 #ifndef DISPATCH_NO_LEGACY
40 * Raw Mach message support
43 _dispatch_machport_callback(mach_msg_header_t *msg, mach_msg_header_t *reply,
44 void (*callback)(mach_msg_header_t *))
46 mig_reply_setup(msg, reply);
47 ((mig_reply_error_t*)reply)->RetCode = MIG_NO_REPLY;
55 * CFMachPort compatibility
58 _dispatch_CFMachPortCallBack(mach_msg_header_t *msg, mach_msg_header_t *reply,
59 void (*callback)(struct __CFMachPort *, void *msg, signed long size, void *))
61 mig_reply_setup(msg, reply);
62 ((mig_reply_error_t*)reply)->RetCode = MIG_NO_REPLY;
64 callback(NULL, msg, msg->msgh_size, dispatch_mach_msg_get_context(msg));
69 #endif /* HAVE_MACH */