From 6c114930eef133293856189a93f7ca7ca3751268 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Tue, 29 Oct 2024 20:20:07 -0600 Subject: wip host_alarmclock --- libhw/alarmclock.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 libhw/alarmclock.c (limited to 'libhw/alarmclock.c') 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 utilities + * + * Copyright (C) 2024 Luke T. Shumaker + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +#include +#include + +#include + +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); +} -- cgit v1.2.3-2-g168b