hare

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

commit 30f0e29d17478c166bc9d8a06be78a253b46a5a4
parent 4e9dfdaae6ff296b363b7f91de998115599fd1c5
Author: Mykyta Holubakha <hilobakho@gmail.com>
Date:   Wed, 10 Mar 2021 22:54:07 +0200

rt/+linux: added poll and timerfd_* syscalls

Diffstat:
Mrt/+linux/syscalls.ha | 26++++++++++++++++++++++++++
Mrt/+linux/types.ha | 19+++++++++++++++++++
2 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/rt/+linux/syscalls.ha b/rt/+linux/syscalls.ha @@ -302,3 +302,29 @@ export fn getcwd() (*const char | errno) = { PATH_MAX + 1))?; return &pathbuf: *const char; }; + +export fn poll(fds: *pollfd, nfds: nfds_t, timeout: int) (int | errno) = { + return wrap_return(syscall3(SYS_poll, + fds: uintptr: u64, nfds: u64, timeout: u64))?: int; +}; + +export fn timerfd_create(clock_id: int, flags: int) (int | errno) = { + return wrap_return(syscall2(SYS_timerfd_create, + clock_id: u64, flags: u64))?: int; +}; + +export fn timerfd_settime( + fd: int, + flags: int, + new_value: *itimerspec, + old_value: *itimerspec +) (int | errno) = { + return wrap_return(syscall4(SYS_timerfd_settime, + fd: u64, flags: u64, + new_value: uintptr: u64, old_value: uintptr: u64))?: int; +}; + +export fn timerfd_gettime(fd: int, curr_value: *itimerspec) (int | errno) = { + return wrap_return(syscall2(SYS_timerfd_gettime, + fd: u64, curr_value: uintptr: u64))?: int; +}; diff --git a/rt/+linux/types.ha b/rt/+linux/types.ha @@ -7,6 +7,7 @@ export type uid_t = uint; export type gid_t = uint; export type time_t = i64; export type suseconds_t = i64; +export type nfds_t = u64; export type timeval = struct { tv_sec: time_t, @@ -18,6 +19,11 @@ export type timespec = struct { tv_nsec: i64, }; +export type itimerspec = struct { + it_interval: timespec, + it_value: timespec, +}; + export def AT_FDCWD: int = -100; export def AT_SYMLINK_NOFOLLOW: int = 0x100; export def AT_REMOVEDIR: int = 0x200; @@ -304,3 +310,16 @@ export type utsname = struct { machine: [65]char, domainname: [65]char, }; + +export def POLLIN: i16 = 0x001; +export def POLLPRI: i16 = 0x002; +export def POLLOUT: i16 = 0x004; + +export type pollfd = struct { + fd: int, + events: i16, + revents: i16, +}; + +export def TFD_TIMER_ABSTIME: int = 1; +export def TFD_TIMER_CANCEL_ON_SET: int = 2;