diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-10-29 20:20:07 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-10-29 20:20:07 -0600 |
commit | 6c114930eef133293856189a93f7ca7ca3751268 (patch) | |
tree | dfb880db4838503ce8d0ac79b8fa56a0f2624fa1 /libhw/alarmclock.c | |
parent | bcaf0bc655df337bc02c5dd78bfc3f4487103959 (diff) |
wip host_alarmclock
Diffstat (limited to 'libhw/alarmclock.c')
-rw-r--r-- | libhw/alarmclock.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/libhw/alarmclock.c b/libhw/alarmclock.c new file mode 100644 index 0000000..7b311c0 --- /dev/null +++ b/libhw/alarmclock.c @@ -0,0 +1,21 @@ +/* libhw/alarmclock.c - Device-independent <libhw/generic/alarmclock.h> utilities + * + * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com> + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +#include <libcr/coroutine.h> +#include <libmisc/vcall.h> + +#include <libhw/generic/alarmclock.h> + +static void alarmclock_sleep_intrhandler(void *_arg) { + cid_t *cid = _arg; + cr_unpause_from_intrhandler(*cid); +} + +void alarmclock_sleep_until_ns(implements_alarmclock *clock, uint64_t abstime_ns) { + cid_t cid = cr_getcid(); + struct alarmclock_trigger trigger; + VCALL(clock, add_trigger, &trigger, abstime_ns, alarmclock_sleep_intrhandler, &cid); +} |