hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 0bcecc54838c9a96c1e18060649a2067e241d971
parent d12fca83c4680da1cd29ddc0341499f5c0a0d9ca
Author: Drew DeVault <sir@cmpwn.com>
Date:   Mon, 18 Mar 2024 09:15:44 +0100

rt+linux: fix getpgrp, alarm for !x86_64

Fixes: https://todo.sr.ht/~sircmpwn/hare/931
Signed-off-by: Drew DeVault <sir@cmpwn.com>

Diffstat:
Mrt/+linux/signal.ha | 9++++++++-
Mrt/+linux/syscalls.ha | 2+-
2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/rt/+linux/signal.ha b/rt/+linux/signal.ha @@ -4,7 +4,14 @@ // TODO: work when _NSIG != 64 export fn alarm(sec: uint) uint = { - return syscall1(SYS_alarm, sec: u64): uint; + let nval = itimerval { ... }; + let oval = itimerval { ... }; + nval.it_value.tv_sec = sec: time_t; + setitimer(ITIMER_REAL, &nval, &oval)!; + if (oval.it_value.tv_usec != 0) { + oval.it_value.tv_sec += 1; + }; + return oval.it_value.tv_sec: uint; }; export def ITIMER_REAL: int = 0; diff --git a/rt/+linux/syscalls.ha b/rt/+linux/syscalls.ha @@ -276,7 +276,7 @@ export fn getpid() pid_t = syscall0(SYS_getpid): pid_t; export fn getppid() pid_t = syscall0(SYS_getppid): pid_t; -export fn getpgrp() pid_t = syscall0(SYS_getpgrp): pid_t; +export fn getpgrp() pid_t = getpgid(0)!; export fn getpgid(pid: pid_t) (pid_t | errno) = { return wrap_return(syscall1(SYS_getpgid, pid: u64))?: pid_t;