-/*
- * work_interval_port_alloc
- *
- * Description: Obtain a send right for the given work interval struct.
- *
- * Parameters: work_interval - A work_interval struct
- * Consumes a +1 ref count on work_interval, now owned by the port.
- *
- * Returns: Port of type IKOT_WORK_INTERVAL with work_interval set as its kobject.
- * Returned with a +1 send right and no-senders notification armed.
- * Work interval struct reference is held by the port.
- */
-static ipc_port_t
-work_interval_port_alloc(struct work_interval *work_interval)
-{
- ipc_port_t work_interval_port = ipc_port_alloc_kernel();
-
- if (work_interval_port == IP_NULL)
- panic("failed to allocate work interval port");
-
- assert(work_interval->wi_port == IP_NULL);
-
- ip_lock(work_interval_port);
- ipc_kobject_set_atomically(work_interval_port, (ipc_kobject_t)work_interval,
- IKOT_WORK_INTERVAL);
-
- ipc_port_t notify_port = ipc_port_make_sonce_locked(work_interval_port);
- ipc_port_t old_notify_port = IP_NULL;
- ipc_port_nsrequest(work_interval_port, 1, notify_port, &old_notify_port);
- /* port unlocked */
-
- assert(old_notify_port == IP_NULL);
-
- /* This is the only make-send that will happen on this port */
- ipc_port_t send_port = ipc_port_make_send(work_interval_port);
- assert(IP_VALID(send_port));
-
- work_interval->wi_port = work_interval_port;
-
- return send_port;
-}
-