hare

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

commit 2508eb35bd97aba1abfa11c697dc1dcb2fe8a0f1
parent 1c380b16964b571a708ab8be43aa211a8eda35f1
Author: Drew DeVault <sir@cmpwn.com>
Date:   Tue,  2 Jan 2024 12:36:57 +0100

rt: add sigaltstack wrappers

Signed-off-by: Drew DeVault <sir@cmpwn.com>

Diffstat:
Mrt/+freebsd/syscalls.ha | 8++++++++
Mrt/+freebsd/types.ha | 6++++++
Mrt/+linux/syscalls.ha | 8++++++++
Mrt/+linux/types.ha | 6++++++
Mrt/+openbsd/syscalls.ha | 15+++++++++++++++
Mrt/+openbsd/types.ha | 6++++++
6 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/rt/+freebsd/syscalls.ha b/rt/+freebsd/syscalls.ha @@ -571,6 +571,14 @@ export fn sigaction( signum: u64, act: uintptr: u64, old: uintptr: u64))?: int; }; +export fn sigaltstack( + ss: nullable *stack_t, + old_ss: nullable *stack_t, +) (void | errno) = { + wrap_return(syscall2(SYS_sigaltstack, + ss: uintptr: u64, old_ss: uintptr: u64))?; +}; + export fn shutdown(sockfd: int, how: int) (void | errno) = { wrap_return(syscall2(SYS_shutdown, sockfd: u64, how: u64))?; diff --git a/rt/+freebsd/types.ha b/rt/+freebsd/types.ha @@ -57,6 +57,12 @@ export type sigval = union { sival_ptr: *opaque, }; +export type stack_t = struct { + ss_sp: *opaque, + ss_size: size, + ss_flags: int, +}; + export type pollfd = struct { fd: int, events: i16, diff --git a/rt/+linux/syscalls.ha b/rt/+linux/syscalls.ha @@ -579,6 +579,14 @@ export fn sigaction( size(sigset): u64))?: int; }; +export fn sigaltstack( + ss: nullable *stack_t, + old_ss: nullable *stack_t, +) (void | errno) = { + wrap_return(syscall2(SYS_sigaltstack, + ss: uintptr: u64, old_ss: uintptr: u64))?; +}; + export fn socket(domain: int, type_: int, protocol: int) (int | errno) = { return wrap_return(syscall3(SYS_socket, domain: u64, type_: u64, protocol: u64))?: int; diff --git a/rt/+linux/types.ha b/rt/+linux/types.ha @@ -513,6 +513,12 @@ export type sigact = struct { sa_mask: sigset, }; +export type stack_t = struct { + ss_sp: *opaque, + ss_flags: int, + ss_size: size, +}; + export def SFD_NONBLOCK: int = O_NONBLOCK; export def SFD_CLOEXEC: int = O_CLOEXEC; diff --git a/rt/+openbsd/syscalls.ha b/rt/+openbsd/syscalls.ha @@ -342,6 +342,7 @@ export @symbol("getegid") fn getegid() gid_t; // profil // ktrace // sigaction +// sigaltstack export @symbol("sigaction") fn libc_sigaction( sig: int, @@ -359,6 +360,20 @@ export fn sigaction( return *__errno(): errno; }; }; + +export @symbol("sigaltstack") fn libc_sigaltstack( + ss: const nullable *stack_t, oss: nullable *stack_t, +) int; + +export fn sigaltstack( + ss: const nullable *stack_t, + oss: nullable *stack_t, +) (void | errno) = { + let res = libc_sigaltstack(ss, oss); + if (res == -1) { + return *__errno(): errno; + }; +}; // getgid export @symbol("getgid") fn getgid() gid_t; diff --git a/rt/+openbsd/types.ha b/rt/+openbsd/types.ha @@ -298,6 +298,12 @@ export type sigval = union { sival_ptr: *opaque, }; +export type stack_t = struct { + ss_sp: *opaque, + ss_size: size, + ss_flags: int, +}; + export type timeval = struct { tv_sec: time_t, tv_usec: suseconds_t,