hare

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

commit a9799a93449a950531c73b6d9e9388415735ba53
parent 9762dd010d6728dc55a335b80ce4324246098103
Author: Sebastian <sebastian@sebsite.pw>
Date:   Thu, 14 Sep 2023 00:04:09 -0400

rt: drop wrap_errno

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

Diffstat:
Mrt/+freebsd/errno.ha | 5+----
Mrt/+freebsd/signal.ha | 6+++---
Mrt/+linux/errno.ha | 5+----
Mrt/+linux/signal.ha | 6+++---
Mrt/+linux/syscalls.ha | 2+-
Mtime/+linux/functions.ha | 6+++---
6 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/rt/+freebsd/errno.ha b/rt/+freebsd/errno.ha @@ -4,14 +4,11 @@ // Represents an error returned from the FreeBSD kernel. export type errno = !int; -// Given an integer error number, wraps it in an error type. -export fn wrap_errno(err: int) errno = err: errno; - // Checks the return value from a FreeBSD syscall and, if found to be in error, // returns the appropriate error. Otherwise, returns the original value. fn wrap_return(r: u64) (errno | u64) = { if (r > -4096: u64) { - return (-(r: i64)): int: errno; + return (-(r: i64)): errno; }; return r; }; diff --git a/rt/+freebsd/signal.ha b/rt/+freebsd/signal.ha @@ -11,7 +11,7 @@ export fn sigemptyset(set: *sigset) void = { export fn sigaddset(set: *sigset, signum: int) (void | errno) = { if (signum < 1 || signum > NSIG) { - return wrap_errno(EINVAL); + return EINVAL; }; signum -= 1; set.__bits[signum >> 5] |= (1 << signum): u32; @@ -19,7 +19,7 @@ export fn sigaddset(set: *sigset, signum: int) (void | errno) = { export fn sigdelset(set: *sigset, signum: int) (void | errno) = { if (signum < 1 || signum > NSIG) { - return wrap_errno(EINVAL); + return EINVAL; }; signum -= 1; set.__bits[signum >> 5] &= ~(1 << signum: u32); @@ -27,7 +27,7 @@ export fn sigdelset(set: *sigset, signum: int) (void | errno) = { export fn sigismember(set: *sigset, signum: int) (bool | errno) = { if (signum < 1 || signum > NSIG) { - return wrap_errno(EINVAL); + return EINVAL; }; signum -= 1; return (set.__bits[signum >> 5] & (1 << signum: u32)) != 0; diff --git a/rt/+linux/errno.ha b/rt/+linux/errno.ha @@ -5,14 +5,11 @@ // Represents an error returned from the Linux kernel. export type errno = !int; -// Given an integer error number, wraps it in an error type. -export fn wrap_errno(err: int) errno = err: errno; - // Checks the return value from a Linux syscall and, if found to be in error, // returns the appropriate error. Otherwise, returns the original value. fn wrap_return(r: u64) (errno | u64) = { if (r > -4096: u64) { - return (-(r: i64)): int: errno; + return (-(r: i64)): errno; }; return r; }; diff --git a/rt/+linux/signal.ha b/rt/+linux/signal.ha @@ -9,7 +9,7 @@ export fn sigemptyset(set: *sigset) void = { export fn sigaddset(set: *sigset, signum: int) (void | errno) = { if (signum < 1 || signum > NSIG) { - return wrap_errno(EINVAL); + return EINVAL; }; signum -= 1; set.__val[0] |= (1 << signum): u64; @@ -17,7 +17,7 @@ export fn sigaddset(set: *sigset, signum: int) (void | errno) = { export fn sigdelset(set: *sigset, signum: int) (void | errno) = { if (signum < 1 || signum > NSIG) { - return wrap_errno(EINVAL); + return EINVAL; }; signum -= 1; set.__val[0] &= ~(1 << signum: u64); @@ -25,7 +25,7 @@ export fn sigdelset(set: *sigset, signum: int) (void | errno) = { export fn sigismember(set: *sigset, signum: int) (bool | errno) = { if (signum < 1 || signum > NSIG) { - return wrap_errno(EINVAL); + return EINVAL; }; signum -= 1; return (set.__val[0] & (1 << signum: u64)) != 0; diff --git a/rt/+linux/syscalls.ha b/rt/+linux/syscalls.ha @@ -310,7 +310,7 @@ export fn mmap( if (err == -EPERM && addr == null && (flags & MAP_ANON) > 0 && (flags & MAP_FIXED) == 0) { // Fix up incorrect EPERM from kernel: - return wrap_errno(ENOMEM); + return ENOMEM; }; return err; case let n: u64 => diff --git a/time/+linux/functions.ha b/time/+linux/functions.ha @@ -94,7 +94,7 @@ fn cgt_vdso() nullable *fn(int, *rt::timespec) int = { fn now_vdso(clock: clock, tp: *rt::timespec) (void | rt::errno) = { const vfn = match (cgt_vdso()) { case null => - return rt::wrap_errno(rt::ENOSYS); + return rt::ENOSYS; case let vfn: *fn(int, *rt::timespec) int => yield vfn; }; @@ -102,7 +102,7 @@ fn now_vdso(clock: clock, tp: *rt::timespec) (void | rt::errno) = { if (ret == 0) { return; }; - return rt::wrap_errno(ret); + return ret; }; // Returns the current time for a given clock. @@ -114,7 +114,7 @@ export fn now(clock: clock) instant = { case let err: rt::errno => yield err; }; - if (err != rt::wrap_errno(rt::ENOSYS)) { + if (err != rt::ENOSYS) { abort("Unexpected error from clock_gettime"); }; match (rt::clock_gettime(clock, &tp)) {