1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26: #include <mach/port.h>
27: #include <mach/message.h>
28:
29: #ifdef MACH_MSG_OVERWRITE
30:
31:
32: mach_msg_return_t
33: __mach_msg_trap (mach_msg_header_t *msg,
34: mach_msg_option_t option,
35: mach_msg_size_t send_size,
36: mach_msg_size_t rcv_size,
37: mach_port_t rcv_name,
38: mach_msg_timeout_t timeout,
39: mach_port_t notify)
40: {
41: return __mach_msg_overwrite_trap (msg, option, send_size,
42: rcv_size, rcv_name, timeout, notify,
43: MACH_MSG_NULL, 0);
44: }
45: weak_alias (__mach_msg_trap, mach_msg_trap)
46:
47:
48: mach_msg_return_t
49: __mach_msg_overwrite (mach_msg_header_t *msg,
50: mach_msg_option_t option,
51: mach_msg_size_t send_size,
52: mach_msg_size_t rcv_size,
53: mach_port_t rcv_name,
54: mach_msg_timeout_t timeout,
55: mach_port_t notify,
56: mach_msg_header_t *rcv_msg,
57: mach_msg_size_t rcv_msg_size)
58:
59: {
60: mach_msg_return_t ret;
61:
62:
63:
64:
65:
66:
67:
68:
69: ret = __mach_msg_overwrite_trap (msg, option, send_size,
70: rcv_size, rcv_name, timeout, notify,
71: rcv_msg, rcv_msg_size);
72: if (ret == MACH_MSG_SUCCESS)
73: return MACH_MSG_SUCCESS;
74:
75: if (!(option & MACH_SEND_INTERRUPT))
76: while (ret == MACH_SEND_INTERRUPTED)
77: ret = __mach_msg_overwrite_trap (msg, option, send_size,
78: rcv_size, rcv_name, timeout, notify,
79: rcv_msg, rcv_msg_size);
80:
81: if (!(option & MACH_RCV_INTERRUPT))
82: while (ret == MACH_RCV_INTERRUPTED)
83: ret = __mach_msg_overwrite_trap (msg, option & ~MACH_SEND_MSG,
84: 0, rcv_size, rcv_name, timeout, notify,
85: rcv_msg, rcv_msg_size);
86:
87: return ret;
88: }
89: weak_alias (__mach_msg_overwrite, mach_msg_overwrite)
90: #endif
91:
92: mach_msg_return_t
93: __mach_msg (mach_msg_header_t *msg,
94: mach_msg_option_t option,
95: mach_msg_size_t send_size,
96: mach_msg_size_t rcv_size,
97: mach_port_t rcv_name,
98: mach_msg_timeout_t timeout,
99: mach_port_t notify)
100: {
101: mach_msg_return_t ret;
102:
103:
104:
105:
106:
107:
108:
109:
110: ret = __mach_msg_trap (msg, option, send_size,
111: rcv_size, rcv_name, timeout, notify);
112: if (ret == MACH_MSG_SUCCESS)
113: return MACH_MSG_SUCCESS;
114:
115: if (!(option & MACH_SEND_INTERRUPT))
116: while (ret == MACH_SEND_INTERRUPTED)
117: ret = __mach_msg_trap (msg, option, send_size,
118: rcv_size, rcv_name, timeout, notify);
119:
120: if (!(option & MACH_RCV_INTERRUPT))
121: while (ret == MACH_RCV_INTERRUPTED)
122: ret = __mach_msg_trap (msg, option & ~MACH_SEND_MSG,
123: 0, rcv_size, rcv_name, timeout, notify);
124:
125: return ret;
126: }
127: weak_alias (__mach_msg, mach_msg)
128:
129: mach_msg_return_t
130: __mach_msg_send (mach_msg_header_t *msg)
131: {
132: return __mach_msg (msg, MACH_SEND_MSG,
133: msg->msgh_size, 0, MACH_PORT_NULL,
134: MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
135: }
136: weak_alias (__mach_msg_send, mach_msg_send)
137:
138: mach_msg_return_t
139: __mach_msg_receive (mach_msg_header_t *msg)
140: {
141: return __mach_msg (msg, MACH_RCV_MSG,
142: 0, msg->msgh_size, msg->msgh_local_port,
143: MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
144: }
145: weak_alias (__mach_msg_receive, mach_msg_receive)