diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-10-29 21:03:04 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-10-29 21:03:04 -0600 |
commit | 26361be59c08917c47718bcd4114b8028aaf7810 (patch) | |
tree | b05dfad7baa755da4592a3d47412f1e062560a5e /libhw/common_alarmclock.c | |
parent | 3c3e9e2c62ad9a83ab9b0e1255204d57894c20ff (diff) |
libhw: Tidy
Diffstat (limited to 'libhw/common_alarmclock.c')
-rw-r--r-- | libhw/common_alarmclock.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/libhw/common_alarmclock.c b/libhw/common_alarmclock.c new file mode 100644 index 0000000..9812d44 --- /dev/null +++ b/libhw/common_alarmclock.c @@ -0,0 +1,21 @@ +/* libhw/common_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); +} |