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@
24 dispatch_mach_msg_get_context(mach_msg_header_t
*msg
)
26 mach_msg_context_trailer_t
*tp
;
29 tp
= (mach_msg_context_trailer_t
*)((uint8_t *)msg
+ round_msg(msg
->msgh_size
));
30 if (tp
->msgh_trailer_size
>= (mach_msg_size_t
)sizeof(mach_msg_context_trailer_t
)) {
31 context
= (void *)(uintptr_t)tp
->msgh_context
;
38 * Raw Mach message support
41 _dispatch_machport_callback(mach_msg_header_t
*msg
, mach_msg_header_t
*reply
,
42 void (*callback
)(mach_msg_header_t
*))
44 mig_reply_setup(msg
, reply
);
45 ((mig_reply_error_t
*)reply
)->RetCode
= MIG_NO_REPLY
;
53 * CFMachPort compatibility
56 _dispatch_CFMachPortCallBack(mach_msg_header_t
*msg
, mach_msg_header_t
*reply
,
57 void (*callback
)(struct __CFMachPort
*, void *msg
, signed long size
, void *))
59 mig_reply_setup(msg
, reply
);
60 ((mig_reply_error_t
*)reply
)->RetCode
= MIG_NO_REPLY
;
62 callback(NULL
, msg
, msg
->msgh_size
, dispatch_mach_msg_get_context(msg
));