hare

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

commit 88644f79ebf937c2b15477b0228480707aa8afc8
parent dafc12de705058dffcbf7c1e44460ca6f4d91541
Author: Drew DeVault <sir@cmpwn.com>
Date:   Mon,  8 Nov 2021 13:19:32 +0100

rt+linux: expand ioctl functionality

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

Diffstat:
Mrt/+linux/syscalls.ha | 13++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/rt/+linux/syscalls.ha b/rt/+linux/syscalls.ha @@ -562,9 +562,16 @@ export fn setsockopt(sockfd: int, level: int, optname: int, optval: *void, optle optval: uintptr: u64, optlen: u64))?: int; }; -export fn ioctl(fd: int, req: u64, arg: nullable *void) (int | errno) = { - return wrap_return(syscall3(SYS_ioctl, fd: u64, - req, arg: uintptr: u64))?: int; +export type ioctl_arg = (nullable *void | u64); + +export fn ioctl(fd: int, req: u64, arg: ioctl_arg) (int | errno) = { + let fd = fd: u64, req = req: u64; + return wrap_return(match (arg) { + case u: u64 => + yield syscall3(SYS_ioctl, fd, req, u); + case v: nullable *void => + yield syscall3(SYS_ioctl, fd, req, v: uintptr: u64); + })?: int; }; export fn getsockname(sockfd: int, addr: nullable *sockaddr, addrlen: nullable *u32) (int | errno) = {