hare

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

commit 1f08b4bc493a65fcc5e68aef42d141e6c925fb3e
parent bd4dee296d01f6e72c510d9c2c30754d4a9a3742
Author: Mykyta Holubakha <hilobakho@gmail.com>
Date:   Wed, 31 Mar 2021 02:58:54 +0300

rt: add readv, writev, readmsg, sendmsg syscalls

Diffstat:
Mrt/+linux/socket.ha | 2+-
Mrt/+linux/syscalls.ha | 19+++++++++++++++++++
Mrt/+linux/types.ha | 32++++++++++++++++++++++++++++++++
3 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/rt/+linux/socket.ha b/rt/+linux/socket.ha @@ -30,7 +30,7 @@ export type sockaddr_in6 = struct { export def UNIX_PATH_MAX: int = 108; export type sockaddr_un = struct { - sin_family: sa_family_t, + sun_family: sa_family_t, sun_path: [UNIX_PATH_MAX]char, }; diff --git a/rt/+linux/syscalls.ha b/rt/+linux/syscalls.ha @@ -526,3 +526,22 @@ export fn getpeername(sockfd: int, addr: nullable *sockaddr, addrlen: nullable * sockfd: u64, addr: uintptr: u64, addrlen: uintptr: u64))?: int; }; +export fn readv(fd: int, iov: *const iovec, iovcnt: int) (int | errno) = { + return wrap_return(syscall3(SYS_readv, + fd: u64, iov: uintptr: u64, iovcnt: u64))?: int; +}; + +export fn writev(fd: int, iov: *const iovec, iovcnt: int) (int | errno) = { + return wrap_return(syscall3(SYS_writev, + fd: u64, iov: uintptr: u64, iovcnt: u64))?: int; +}; + +export fn sendmsg(fd: int, msg: *const msghdr, flags: int) (int | errno) = { + return wrap_return(syscall3(SYS_sendmsg, + fd: u64, msg: uintptr: u64, flags: u64))?: int; +}; + +export fn recvmsg(fd: int, msg: *const msghdr, flags: int) (int | errno) = { + return wrap_return(syscall3(SYS_recvmsg, + fd: u64, msg: uintptr: u64, flags: u64))?: int; +}; diff --git a/rt/+linux/types.ha b/rt/+linux/types.ha @@ -519,3 +519,35 @@ export type signalfd_siginfo = struct { __pad: [28]u8, // pad to 128 bytes }; + +export type iovec = struct { + iov_base: *void, + iov_len: size +}; + +export def SCM_RIGHTS: int = 0x01; +export def SCM_CREDENTIALS: int = 0x02; + +export type msghdr = struct { + msg_name: nullable *void, + msg_namelen: u32, + + msg_iov: *[*]iovec, + msg_iovlen: size, + + msg_control: *void, + msg_controllen: size, + + msg_flags: int +}; + +export type cmsghdr = struct { + cmsg_len: size, + cmsg_level: int, + cmsg_type: int, +}; + +export type cmsg = struct { + hdr: cmsghdr, + cmsg_data: [*]u8, +};