+struct task_watchport_elem {
+ task_t twe_task;
+ ipc_port_t twe_port; /* (Space lock) */
+};
+
+struct task_watchports {
+ os_refcnt_t tw_refcount; /* (Space lock) */
+ task_t tw_task; /* (Space lock) & tw_refcount == 0 */
+ thread_t tw_thread; /* (Space lock) & tw_refcount == 0 */
+ uint32_t tw_elem_array_count; /* (Space lock) */
+ struct task_watchport_elem tw_elem[]; /* (Space lock) & (Portlock) & (mq lock) */
+};
+
+#define task_watchports_retain(x) (os_ref_retain(&(x)->tw_refcount))
+#define task_watchports_release(x) (os_ref_release(&(x)->tw_refcount))
+
+#define task_watchport_elem_init(elem, task, port) \
+do { \
+ (elem)->twe_task = (task); \
+ (elem)->twe_port = (port); \
+} while(0)
+
+#define task_watchport_elem_clear(elem) task_watchport_elem_init((elem), NULL, NULL)
+
+extern void
+task_add_turnstile_watchports(
+ task_t task,
+ thread_t thread,
+ ipc_port_t *portwatch_ports,
+ uint32_t portwatch_count);
+
+extern void
+task_watchport_elem_deallocate(
+ struct task_watchport_elem *watchport_elem);
+
+extern boolean_t
+task_has_watchports(task_t task);
+