hare

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

commit c9ba7fc1fbe3bdf28cac405f41a11a4d2dfc5a80
parent bec2735b7682502ef6fe593c9d9e62b7319db803
Author: Sebastian <sebastian@sebsite.pw>
Date:   Mon,  8 May 2023 20:44:50 -0400

unix::poll: add error type

Signed-off-by: Sebastian <sebastian@sebsite.pw>

Diffstat:
Mscripts/gen-stdlib | 4++--
Mstdlib.mk | 12++++++++----
Munix/poll/+freebsd.ha | 2+-
Munix/poll/+linux.ha | 2+-
Aunix/poll/types.ha | 7+++++++
5 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/scripts/gen-stdlib b/scripts/gen-stdlib @@ -1434,10 +1434,10 @@ unix_passwd() { } unix_poll() { - gen_srcs -plinux unix::poll +linux.ha + gen_srcs -plinux unix::poll +linux.ha types.ha gen_ssa -plinux unix::poll rt errors time io - gen_srcs -pfreebsd unix::poll +freebsd.ha + gen_srcs -pfreebsd unix::poll +freebsd.ha types.ha gen_ssa -pfreebsd unix::poll rt errors time io } diff --git a/stdlib.mk b/stdlib.mk @@ -2120,7 +2120,8 @@ $(HARECACHE)/unix/passwd/unix_passwd-any.ssa: $(stdlib_unix_passwd_any_srcs) $(s # unix::poll (+linux) stdlib_unix_poll_linux_srcs = \ - $(STDLIB)/unix/poll/+linux.ha + $(STDLIB)/unix/poll/+linux.ha \ + $(STDLIB)/unix/poll/types.ha $(HARECACHE)/unix/poll/unix_poll-linux.ssa: $(stdlib_unix_poll_linux_srcs) $(stdlib_rt) $(stdlib_rt_$(PLATFORM)) $(stdlib_errors_$(PLATFORM)) $(stdlib_time_$(PLATFORM)) $(stdlib_io_$(PLATFORM)) @printf 'HAREC \t$@\n' @@ -2130,7 +2131,8 @@ $(HARECACHE)/unix/poll/unix_poll-linux.ssa: $(stdlib_unix_poll_linux_srcs) $(std # unix::poll (+freebsd) stdlib_unix_poll_freebsd_srcs = \ - $(STDLIB)/unix/poll/+freebsd.ha + $(STDLIB)/unix/poll/+freebsd.ha \ + $(STDLIB)/unix/poll/types.ha $(HARECACHE)/unix/poll/unix_poll-freebsd.ssa: $(stdlib_unix_poll_freebsd_srcs) $(stdlib_rt) $(stdlib_rt_$(PLATFORM)) $(stdlib_errors_$(PLATFORM)) $(stdlib_time_$(PLATFORM)) $(stdlib_io_$(PLATFORM)) @printf 'HAREC \t$@\n' @@ -4402,7 +4404,8 @@ $(TESTCACHE)/unix/passwd/unix_passwd-any.ssa: $(testlib_unix_passwd_any_srcs) $( # unix::poll (+linux) testlib_unix_poll_linux_srcs = \ - $(STDLIB)/unix/poll/+linux.ha + $(STDLIB)/unix/poll/+linux.ha \ + $(STDLIB)/unix/poll/types.ha $(TESTCACHE)/unix/poll/unix_poll-linux.ssa: $(testlib_unix_poll_linux_srcs) $(testlib_rt) $(testlib_rt_$(PLATFORM)) $(testlib_errors_$(PLATFORM)) $(testlib_time_$(PLATFORM)) $(testlib_io_$(PLATFORM)) @printf 'HAREC \t$@\n' @@ -4412,7 +4415,8 @@ $(TESTCACHE)/unix/poll/unix_poll-linux.ssa: $(testlib_unix_poll_linux_srcs) $(te # unix::poll (+freebsd) testlib_unix_poll_freebsd_srcs = \ - $(STDLIB)/unix/poll/+freebsd.ha + $(STDLIB)/unix/poll/+freebsd.ha \ + $(STDLIB)/unix/poll/types.ha $(TESTCACHE)/unix/poll/unix_poll-freebsd.ssa: $(testlib_unix_poll_freebsd_srcs) $(testlib_rt) $(testlib_rt_$(PLATFORM)) $(testlib_errors_$(PLATFORM)) $(testlib_time_$(PLATFORM)) $(testlib_io_$(PLATFORM)) @printf 'HAREC \t$@\n' diff --git a/unix/poll/+freebsd.ha b/unix/poll/+freebsd.ha @@ -38,7 +38,7 @@ export def NONBLOCK: time::duration = 0; export fn poll( fds: []pollfd, timeout: time::duration, -) (uint | errors::error) = { +) (uint | error) = { let ts = rt::timespec { ... }; time::duration_to_timespec(timeout, &ts); let ts = if (timeout == INDEF) null else &ts; diff --git a/unix/poll/+linux.ha b/unix/poll/+linux.ha @@ -38,7 +38,7 @@ export def NONBLOCK: time::duration = 0; export fn poll( fds: []pollfd, timeout: time::duration, -) (uint | errors::error) = { +) (uint | error) = { let ts = rt::timespec { ... }; time::duration_to_timespec(timeout, &ts); let ts = if (timeout == INDEF) null else &ts; diff --git a/unix/poll/types.ha b/unix/poll/types.ha @@ -0,0 +1,7 @@ +use errors; + +// All error types that can be returned from [[poll]]. +export type error = !errors::error; + +// Converts an [[error]] into a human-friendly string representation. +export fn strerror(err: error) const str = errors::strerror(err);