+#define set_port_send_turnstile(port, value) \
+MACRO_BEGIN \
+if (IP_PREALLOC(port)) { \
+ (port)->ip_premsg->ikm_turnstile = (value); \
+} else { \
+ (port)->ip_send_turnstile = (value); \
+} \
+MACRO_END
+
+#define port_send_turnstile_address(port) \
+(IP_PREALLOC(port) ? &((port)->ip_premsg->ikm_turnstile) : &((port)->ip_send_turnstile))
+
+#define port_rcv_turnstile_address(port) \
+ &(port)->ip_messages.imq_wait_queue.waitq_ts
+
+
+/*
+ * SYNC IPC state flags for special reply port/ rcv right.
+ *
+ * PORT_SYNC_LINK_ANY
+ * Special reply port is not linked to any other port
+ * or WL and linkage should be allowed.
+ *
+ * PORT_SYNC_LINK_PORT
+ * Special reply port is linked to the port and
+ * ip_sync_inheritor_port contains the inheritor
+ * port.
+ *
+ * PORT_SYNC_LINK_WORKLOOP_KNOTE
+ * Special reply port is linked to a WL (via a knote).
+ * ip_sync_inheritor_knote contains a pointer to the knote
+ * the port is stashed on.
+ *
+ * PORT_SYNC_LINK_WORKLOOP_STASH
+ * Special reply port is linked to a WL (via a knote stash).
+ * ip_sync_inheritor_ts contains a pointer to the turnstile with a +1
+ * the port is stashed on.
+ *
+ * PORT_SYNC_LINK_NO_LINKAGE
+ * Message sent to special reply port, do
+ * not allow any linkages till receive is
+ * complete.
+ *
+ * PORT_SYNC_LINK_RCV_THREAD
+ * Receive right copied out as a part of bootstrap check in,
+ * push on the thread which copied out the port.
+ */
+#define PORT_SYNC_LINK_ANY (0)
+#define PORT_SYNC_LINK_PORT (0x1)
+#define PORT_SYNC_LINK_WORKLOOP_KNOTE (0x2)
+#define PORT_SYNC_LINK_WORKLOOP_STASH (0x3)
+#define PORT_SYNC_LINK_NO_LINKAGE (0x4)
+#define PORT_SYNC_LINK_RCV_THREAD (0x5)
+
+#define IP_NULL IPC_PORT_NULL
+#define IP_DEAD IPC_PORT_DEAD
+#define IP_VALID(port) IPC_PORT_VALID(port)
+
+#define ip_object_to_port(io) __container_of(io, struct ipc_port, ip_object)
+#define ip_to_object(port) (&(port)->ip_object)
+#define ip_active(port) io_active(ip_to_object(port))
+#define ip_lock_init(port) io_lock_init(ip_to_object(port))
+#define ip_lock_held(port) io_lock_held(ip_to_object(port))
+#define ip_lock(port) io_lock(ip_to_object(port))
+#define ip_lock_try(port) io_lock_try(ip_to_object(port))
+#define ip_lock_held_kdp(port) io_lock_held_kdp(ip_to_object(port))
+#define ip_unlock(port) io_unlock(ip_to_object(port))
+
+#define ip_reference(port) io_reference(ip_to_object(port))
+#define ip_release(port) io_release(ip_to_object(port))
+
+/* get an ipc_port pointer from an ipc_mqueue pointer */
+#define ip_from_mq(mq) \
+ __container_of(mq, struct ipc_port, ip_messages)
+
+#define ip_reference_mq(mq) ip_reference(ip_from_mq(mq))
+#define ip_release_mq(mq) ip_release(ip_from_mq(mq))
+
+#define ip_kotype(port) io_kotype(ip_to_object(port))
+#define ip_is_kobject(port) io_is_kobject(ip_to_object(port))
+#define ip_is_kolabeled(port) io_is_kolabeled(ip_to_object(port))
+#define ip_get_kobject(port) ipc_kobject_get(port)
+#define ip_label_check(space, port, msgt_name) \
+ (!ip_is_kolabeled(port) || ipc_kobject_label_check((space), (port), (msgt_name)))
+
+#define ip_full_kernel(port) imq_full_kernel(&(port)->ip_messages)
+#define ip_full(port) imq_full(&(port)->ip_messages)