#include <sys/errno.h>
#include <stdlib.h>
+#include <strings.h>
struct work_interval {
uint64_t thread_id;
};
ret = __work_interval_ctl(WORK_INTERVAL_OPERATION_CREATE2, 0,
- &create_params, sizeof(create_params));
+ &create_params, sizeof(create_params));
if (ret == -1) {
return ret;
}
return 0;
}
+int
+work_interval_get_flags_from_port(mach_port_t port, uint32_t *flags)
+{
+ if (!MACH_PORT_VALID(port) || flags == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ struct work_interval_create_params create_params = { 0 };
+
+ int ret = __work_interval_ctl(WORK_INTERVAL_OPERATION_GET_FLAGS, port,
+ &create_params, sizeof(create_params));
+ if (ret == -1) {
+ return ret;
+ }
+
+ *flags = create_params.wicp_create_flags;
+ return 0;
+}
+
int
work_interval_notify(work_interval_t interval_handle, uint64_t start,
- uint64_t finish, uint64_t deadline, uint64_t next_start,
- uint32_t notify_flags)
+ uint64_t finish, uint64_t deadline, uint64_t next_start,
+ uint32_t notify_flags)
{
int ret;
uint64_t work_interval_id;
return -1;
}
+ if (interval_handle->create_flags & WORK_INTERVAL_FLAG_IGNORED) {
+ return 0;
+ }
+
notification.create_flags = interval_handle->create_flags;
work_interval_id = interval_handle->work_interval_id;
ret = __work_interval_ctl(WORK_INTERVAL_OPERATION_NOTIFY, work_interval_id,
- ¬ification, sizeof(notification));
+ ¬ification, sizeof(notification));
return ret;
}
int
work_interval_notify_simple(work_interval_t interval_handle, uint64_t start,
- uint64_t deadline, uint64_t next_start)
+ uint64_t deadline, uint64_t next_start)
{
return work_interval_notify(interval_handle, start, mach_absolute_time(),
- deadline, next_start, 0);
+ deadline, next_start, 0);
}
+
int
work_interval_destroy(work_interval_t interval_handle)
{
uint64_t work_interval_id = interval_handle->work_interval_id;
int ret = __work_interval_ctl(WORK_INTERVAL_OPERATION_DESTROY,
- work_interval_id, NULL, 0);
+ work_interval_id, NULL, 0);
interval_handle->work_interval_id = 0;
}
return __work_interval_ctl(WORK_INTERVAL_OPERATION_JOIN,
- (uint64_t)port, NULL, 0);
+ (uint64_t)port, NULL, 0);
}
int
work_interval_leave(void)
{
return __work_interval_ctl(WORK_INTERVAL_OPERATION_JOIN,
- (uint64_t)MACH_PORT_NULL, NULL, 0);
+ (uint64_t)MACH_PORT_NULL, NULL, 0);
}
int
mach_port_t wi_port = interval_handle->wi_port;
kern_return_t kr = mach_port_mod_refs(mach_task_self(), wi_port,
- MACH_PORT_RIGHT_SEND, 1);
+ MACH_PORT_RIGHT_SEND, 1);
if (kr != KERN_SUCCESS) {
*port = MACH_PORT_NULL;
return 0;
}
-
-
-
-