commit 33a21bae4493ad82dfb20344cdb68856de06d77f
parent d9a6e0f0d75d8cdf70cdbba244a02b399b0705cb
Author: Drew DeVault <sir@cmpwn.com>
Date: Mon, 3 May 2021 18:43:40 -0400
time+linux: minor improvements
Signed-off-by: Drew DeVault <sir@cmpwn.com>
Diffstat:
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/time/+linux/functions.ha b/time/+linux/functions.ha
@@ -1,7 +1,6 @@
use rt;
use linux::vdso;
-
fn duration_to_timespec(n: duration, ts: *rt::timespec) void = {
ts.tv_sec = n / SECOND;
ts.tv_nsec = n % SECOND;
@@ -56,25 +55,24 @@ export type clock = enum {
BOOT = 7,
};
-let cgt_vdso: nullable *fn(_: int, _: *rt::timespec) int = null;
-
-fn get_cgt_vdso() nullable *fn(_: int, _: *rt::timespec) int = {
+fn cgt_vdso() nullable *fn(_: int, _: *rt::timespec) int = {
static let vdso_checked: bool = false;
- if (vdso_checked)
+ static let cgt_vdso: nullable *fn(_: int, _: *rt::timespec) int = null;
+ if (vdso_checked) {
return cgt_vdso;
+ };
vdso_checked = true;
-
- cgt_vdso = vdso::getsym(VDSO_CGT_SYM, VDSO_CGT_VER)
- : nullable *fn(_: int, _: *rt::timespec) int;
+ cgt_vdso = vdso::getsym(VDSO_CGT_SYM, VDSO_CGT_VER):
+ nullable *fn(_: int, _: *rt::timespec) int;
return cgt_vdso;
};
fn now_vdso(clock: clock, tp: *rt::timespec) (void | rt::errno) = {
- let vfn = match (get_cgt_vdso()) {
+ const vfn = match (cgt_vdso()) {
null => return rt::wrap_errno(rt::ENOSYS),
vfn: *fn(_: int, _: *rt::timespec) int => vfn,
};
- let ret = vfn(clock, tp);
+ const ret = vfn(clock, tp);
if (ret == 0) {
return;
};