commit 825ffee3ec68e8d65f4075cd5a6fe32b1617319e
parent e0ed8fa32b0c4d66fd1ec1c2bd4d684cba14e471
Author: Ember Sawady <ecs@d2evs.net>
Date: Wed, 7 Jun 2023 08:19:01 +0000
rt: make errno constants have type rt::errno
Signed-off-by: Ember Sawady <ecs@d2evs.net>
Diffstat:
8 files changed, 244 insertions(+), 246 deletions(-)
diff --git a/net/tcp/+freebsd.ha b/net/tcp/+freebsd.ha
@@ -48,7 +48,7 @@ export fn connect(
const sz = ip::native_addrlen(addr);
match (rt::connect(sockfd, &sockaddr, sz)) {
case let err: rt::errno =>
- if (err: int != rt::EINPROGRESS) {
+ if (err != rt::EINPROGRESS) {
return errors::errno(err);
};
assert(f & rt::SOCK_NONBLOCK == rt::SOCK_NONBLOCK);
diff --git a/net/tcp/+linux.ha b/net/tcp/+linux.ha
@@ -48,7 +48,7 @@ export fn connect(
const sz = size(rt::sockaddr): u32;
match (rt::connect(sockfd, &sockaddr, sz)) {
case let err: rt::errno =>
- if (err: int != rt::EINPROGRESS) {
+ if (err != rt::EINPROGRESS) {
return errors::errno(err);
};
assert(f & rt::SOCK_NONBLOCK == rt::SOCK_NONBLOCK);
diff --git a/os/exec/process+freebsd.ha b/os/exec/process+freebsd.ha
@@ -102,7 +102,7 @@ export fn waitall() (uint | error | !(process, exit_status)) = {
let ru: rt::rusage = rt::rusage { ... };
for (let i = 0u; true; i += 1) match (rt::wait4(-1, &st.status, 0, &ru)) {
case let err: rt::errno =>
- if (err: int == rt::ECHILD) {
+ if (err == rt::ECHILD) {
return i;
} else {
return errors::errno(err);
diff --git a/os/exec/process+linux.ha b/os/exec/process+linux.ha
@@ -88,11 +88,10 @@ export fn waitall() (uint | error | !(process, exit_status)) = {
let ru: rt::rusage = rt::rusage { ... };
for (let i = 0u; true; i += 1) match (rt::wait4(-1, &st.status, 0, &ru)) {
case let err: rt::errno =>
- if (err: int == rt::ECHILD) {
+ if (err == rt::ECHILD) {
return i;
- } else {
- return errors::errno(err);
};
+ return errors::errno(err);
case let pid: int =>
match (check(&st)) {
case void => void;
diff --git a/rt/+freebsd/errno.ha b/rt/+freebsd/errno.ha
@@ -417,102 +417,102 @@ export fn errname(err: errno) str = {
};
};
-export def EPERM: int = 1;
-export def ENOENT: int = 2;
-export def ESRCH: int = 3;
-export def EINTR: int = 4;
-export def EIO: int = 5;
-export def ENXIO: int = 6;
-export def E2BIG: int = 7;
-export def ENOEXEC: int = 8;
-export def EBADF: int = 9;
-export def ECHILD: int = 10;
-export def EDEADLK: int = 11;
-export def ENOMEM: int = 12;
-export def EACCES: int = 13;
-export def EFAULT: int = 14;
-export def ENOTBLK: int = 15;
-export def EBUSY: int = 16;
-export def EEXIST: int = 17;
-export def EXDEV: int = 18;
-export def ENODEV: int = 19;
-export def ENOTDIR: int = 20;
-export def EISDIR: int = 21;
-export def EINVAL: int = 22;
-export def ENFILE: int = 23;
-export def EMFILE: int = 24;
-export def ENOTTY: int = 25;
-export def ETXTBSY: int = 26;
-export def EFBIG: int = 27;
-export def ENOSPC: int = 28;
-export def ESPIPE: int = 29;
-export def EROFS: int = 30;
-export def EMLINK: int = 31;
-export def EPIPE: int = 32;
-export def EDOM: int = 33;
-export def ERANGE: int = 34;
-export def EAGAIN: int = 35;
-export def EWOULDBLOCK: int = EAGAIN;
-export def EINPROGRESS: int = 36;
-export def EALREADY: int = 37;
-export def ENOTSOCK: int = 38;
-export def EDESTADDRREQ: int = 39;
-export def EMSGSIZE: int = 40;
-export def EPROTOTYPE: int = 41;
-export def ENOPROTOOPT: int = 42;
-export def EPROTONOSUPPORT: int = 43;
-export def ESOCKTNOSUPPORT: int = 44;
-export def EOPNOTSUPP: int = 45;
-export def ENOTSUP: int = EOPNOTSUPP;
-export def EPFNOSUPPORT: int = 46;
-export def EAFNOSUPPORT: int = 47;
-export def EADDRINUSE: int = 48;
-export def EADDRNOTAVAIL: int = 49;
-export def ENETDOWN: int = 50;
-export def ENETUNREACH: int = 51;
-export def ENETRESET: int = 52;
-export def ECONNABORTED: int = 53;
-export def ECONNRESET: int = 54;
-export def ENOBUFS: int = 55;
-export def EISCONN: int = 56;
-export def ENOTCONN: int = 57;
-export def ESHUTDOWN: int = 58;
-export def ETOOMANYREFS: int = 59;
-export def ETIMEDOUT: int = 60;
-export def ECONNREFUSED: int = 61;
-export def ELOOP: int = 62;
-export def ENAMETOOLONG: int = 63;
-export def EHOSTDOWN: int = 64;
-export def EHOSTUNREACH: int = 65;
-export def ENOTEMPTY: int = 66;
-export def EPROCLIM: int = 67;
-export def EUSERS: int = 68;
-export def EDQUOT: int = 69;
-export def ESTALE: int = 70;
-export def EREMOTE: int = 71;
-export def EBADRPC: int = 72;
-export def ERPCMISMATCH: int = 73;
-export def EPROGUNAVAIL: int = 74;
-export def EPROGMISMATCH: int = 75;
-export def EPROCUNAVAIL: int = 76;
-export def ENOLCK: int = 77;
-export def ENOSYS: int = 78;
-export def EFTYPE: int = 79;
-export def EAUTH: int = 80;
-export def ENEEDAUTH: int = 81;
-export def EIDRM: int = 82;
-export def ENOMSG: int = 83;
-export def EOVERFLOW: int = 84;
-export def ECANCELED: int = 85;
-export def EILSEQ: int = 86;
-export def ENOATTR: int = 87;
-export def EDOOFUS: int = 88;
-export def EBADMSG: int = 89;
-export def EMULTIHOP: int = 90;
-export def ENOLINK: int = 91;
-export def EPROTO: int = 92;
-export def ENOTCAPABLE: int = 93;
-export def ECAPMODE: int = 94;
-export def ENOTRECOVERABLE: int = 95;
-export def EOWNERDEAD: int = 96;
-export def EINTEGRITY: int = 97;
+export def EPERM: errno = 1;
+export def ENOENT: errno = 2;
+export def ESRCH: errno = 3;
+export def EINTR: errno = 4;
+export def EIO: errno = 5;
+export def ENXIO: errno = 6;
+export def E2BIG: errno = 7;
+export def ENOEXEC: errno = 8;
+export def EBADF: errno = 9;
+export def ECHILD: errno = 10;
+export def EDEADLK: errno = 11;
+export def ENOMEM: errno = 12;
+export def EACCES: errno = 13;
+export def EFAULT: errno = 14;
+export def ENOTBLK: errno = 15;
+export def EBUSY: errno = 16;
+export def EEXIST: errno = 17;
+export def EXDEV: errno = 18;
+export def ENODEV: errno = 19;
+export def ENOTDIR: errno = 20;
+export def EISDIR: errno = 21;
+export def EINVAL: errno = 22;
+export def ENFILE: errno = 23;
+export def EMFILE: errno = 24;
+export def ENOTTY: errno = 25;
+export def ETXTBSY: errno = 26;
+export def EFBIG: errno = 27;
+export def ENOSPC: errno = 28;
+export def ESPIPE: errno = 29;
+export def EROFS: errno = 30;
+export def EMLINK: errno = 31;
+export def EPIPE: errno = 32;
+export def EDOM: errno = 33;
+export def ERANGE: errno = 34;
+export def EAGAIN: errno = 35;
+export def EWOULDBLOCK: errno = EAGAIN;
+export def EINPROGRESS: errno = 36;
+export def EALREADY: errno = 37;
+export def ENOTSOCK: errno = 38;
+export def EDESTADDRREQ: errno = 39;
+export def EMSGSIZE: errno = 40;
+export def EPROTOTYPE: errno = 41;
+export def ENOPROTOOPT: errno = 42;
+export def EPROTONOSUPPORT: errno = 43;
+export def ESOCKTNOSUPPORT: errno = 44;
+export def EOPNOTSUPP: errno = 45;
+export def ENOTSUP: errno = EOPNOTSUPP;
+export def EPFNOSUPPORT: errno = 46;
+export def EAFNOSUPPORT: errno = 47;
+export def EADDRINUSE: errno = 48;
+export def EADDRNOTAVAIL: errno = 49;
+export def ENETDOWN: errno = 50;
+export def ENETUNREACH: errno = 51;
+export def ENETRESET: errno = 52;
+export def ECONNABORTED: errno = 53;
+export def ECONNRESET: errno = 54;
+export def ENOBUFS: errno = 55;
+export def EISCONN: errno = 56;
+export def ENOTCONN: errno = 57;
+export def ESHUTDOWN: errno = 58;
+export def ETOOMANYREFS: errno = 59;
+export def ETIMEDOUT: errno = 60;
+export def ECONNREFUSED: errno = 61;
+export def ELOOP: errno = 62;
+export def ENAMETOOLONG: errno = 63;
+export def EHOSTDOWN: errno = 64;
+export def EHOSTUNREACH: errno = 65;
+export def ENOTEMPTY: errno = 66;
+export def EPROCLIM: errno = 67;
+export def EUSERS: errno = 68;
+export def EDQUOT: errno = 69;
+export def ESTALE: errno = 70;
+export def EREMOTE: errno = 71;
+export def EBADRPC: errno = 72;
+export def ERPCMISMATCH: errno = 73;
+export def EPROGUNAVAIL: errno = 74;
+export def EPROGMISMATCH: errno = 75;
+export def EPROCUNAVAIL: errno = 76;
+export def ENOLCK: errno = 77;
+export def ENOSYS: errno = 78;
+export def EFTYPE: errno = 79;
+export def EAUTH: errno = 80;
+export def ENEEDAUTH: errno = 81;
+export def EIDRM: errno = 82;
+export def ENOMSG: errno = 83;
+export def EOVERFLOW: errno = 84;
+export def ECANCELED: errno = 85;
+export def EILSEQ: errno = 86;
+export def ENOATTR: errno = 87;
+export def EDOOFUS: errno = 88;
+export def EBADMSG: errno = 89;
+export def EMULTIHOP: errno = 90;
+export def ENOLINK: errno = 91;
+export def EPROTO: errno = 92;
+export def ENOTCAPABLE: errno = 93;
+export def ECAPMODE: errno = 94;
+export def ENOTRECOVERABLE: errno = 95;
+export def EOWNERDEAD: errno = 96;
+export def EINTEGRITY: errno = 97;
diff --git a/rt/+linux/errno.ha b/rt/+linux/errno.ha
@@ -558,136 +558,136 @@ export fn errname(err: errno) str = {
};
};
-export def EPERM: int = 1;
-export def ENOENT: int = 2;
-export def ESRCH: int = 3;
-export def EINTR: int = 4;
-export def EIO: int = 5;
-export def ENXIO: int = 6;
-export def E2BIG: int = 7;
-export def ENOEXEC: int = 8;
-export def EBADF: int = 9;
-export def ECHILD: int = 10;
-export def EAGAIN: int = 11;
-export def EWOULDBLOCK: int = EAGAIN;
-export def ENOMEM: int = 12;
-export def EACCES: int = 13;
-export def EFAULT: int = 14;
-export def ENOTBLK: int = 15;
-export def EBUSY: int = 16;
-export def EEXIST: int = 17;
-export def EXDEV: int = 18;
-export def ENODEV: int = 19;
-export def ENOTDIR: int = 20;
-export def EISDIR: int = 21;
-export def EINVAL: int = 22;
-export def ENFILE: int = 23;
-export def EMFILE: int = 24;
-export def ENOTTY: int = 25;
-export def ETXTBSY: int = 26;
-export def EFBIG: int = 27;
-export def ENOSPC: int = 28;
-export def ESPIPE: int = 29;
-export def EROFS: int = 30;
-export def EMLINK: int = 31;
-export def EPIPE: int = 32;
-export def EDOM: int = 33;
-export def ERANGE: int = 34;
-export def EDEADLK: int = 35;
-export def ENAMETOOLONG: int = 36;
-export def ENOLCK: int = 37;
-export def ENOSYS: int = 38;
-export def ENOTEMPTY: int = 39;
-export def ELOOP: int = 40;
-export def ENOMSG: int = 42;
-export def EIDRM: int = 43;
-export def ECHRNG: int = 44;
-export def EL2NSYNC: int = 45;
-export def EL3HLT: int = 46;
-export def EL3RST: int = 47;
-export def ELNRNG: int = 48;
-export def EUNATCH: int = 49;
-export def ENOCSI: int = 50;
-export def EL2HLT: int = 51;
-export def EBADE: int = 52;
-export def EBADR: int = 53;
-export def EXFULL: int = 54;
-export def ENOANO: int = 55;
-export def EBADRQC: int = 56;
-export def EBADSLT: int = 57;
-export def EBFONT: int = 59;
-export def ENOSTR: int = 60;
-export def ENODATA: int = 61;
-export def ETIME: int = 62;
-export def ENOSR: int = 63;
-export def ENONET: int = 64;
-export def ENOPKG: int = 65;
-export def EREMOTE: int = 66;
-export def ENOLINK: int = 67;
-export def EADV: int = 68;
-export def ESRMNT: int = 69;
-export def ECOMM: int = 70;
-export def EPROTO: int = 71;
-export def EMULTIHOP: int = 72;
-export def EDOTDOT: int = 73;
-export def EBADMSG: int = 74;
-export def EOVERFLOW: int = 75;
-export def ENOTUNIQ: int = 76;
-export def EBADFD: int = 77;
-export def EREMCHG: int = 78;
-export def ELIBACC: int = 79;
-export def ELIBBAD: int = 80;
-export def ELIBSCN: int = 81;
-export def ELIBMAX: int = 82;
-export def ELIBEXEC: int = 83;
-export def EILSEQ: int = 84;
-export def ERESTART: int = 85;
-export def ESTRPIPE: int = 86;
-export def EUSERS: int = 87;
-export def ENOTSOCK: int = 88;
-export def EDESTADDRREQ: int = 89;
-export def EMSGSIZE: int = 90;
-export def EPROTOTYPE: int = 91;
-export def ENOPROTOOPT: int = 92;
-export def EPROTONOSUPPORT: int = 93;
-export def ESOCKTNOSUPPORT: int = 94;
-export def EOPNOTSUPP: int = 95;
-export def ENOTSUP: int = EOPNOTSUPP;
-export def EPFNOSUPPORT: int = 96;
-export def EAFNOSUPPORT: int = 97;
-export def EADDRINUSE: int = 98;
-export def EADDRNOTAVAIL: int = 99;
-export def ENETDOWN: int = 100;
-export def ENETUNREACH: int = 101;
-export def ENETRESET: int = 102;
-export def ECONNABORTED: int = 103;
-export def ECONNRESET: int = 104;
-export def ENOBUFS: int = 105;
-export def EISCONN: int = 106;
-export def ENOTCONN: int = 107;
-export def ESHUTDOWN: int = 108;
-export def ETOOMANYREFS: int = 109;
-export def ETIMEDOUT: int = 110;
-export def ECONNREFUSED: int = 111;
-export def EHOSTDOWN: int = 112;
-export def EHOSTUNREACH: int = 113;
-export def EALREADY: int = 114;
-export def EINPROGRESS: int = 115;
-export def ESTALE: int = 116;
-export def EUCLEAN: int = 117;
-export def ENOTNAM: int = 118;
-export def ENAVAIL: int = 119;
-export def EISNAM: int = 120;
-export def EREMOTEIO: int = 121;
-export def EDQUOT: int = 122;
-export def ENOMEDIUM: int = 123;
-export def EMEDIUMTYPE: int = 124;
-export def ECANCELED: int = 125;
-export def ENOKEY: int = 126;
-export def EKEYEXPIRED: int = 127;
-export def EKEYREVOKED: int = 128;
-export def EKEYREJECTED: int = 129;
-export def EOWNERDEAD: int = 130;
-export def ENOTRECOVERABLE: int = 131;
-export def ERFKILL: int = 132;
-export def EHWPOISON: int = 133;
+export def EPERM: errno = 1;
+export def ENOENT: errno = 2;
+export def ESRCH: errno = 3;
+export def EINTR: errno = 4;
+export def EIO: errno = 5;
+export def ENXIO: errno = 6;
+export def E2BIG: errno = 7;
+export def ENOEXEC: errno = 8;
+export def EBADF: errno = 9;
+export def ECHILD: errno = 10;
+export def EAGAIN: errno = 11;
+export def EWOULDBLOCK: errno = EAGAIN;
+export def ENOMEM: errno = 12;
+export def EACCES: errno = 13;
+export def EFAULT: errno = 14;
+export def ENOTBLK: errno = 15;
+export def EBUSY: errno = 16;
+export def EEXIST: errno = 17;
+export def EXDEV: errno = 18;
+export def ENODEV: errno = 19;
+export def ENOTDIR: errno = 20;
+export def EISDIR: errno = 21;
+export def EINVAL: errno = 22;
+export def ENFILE: errno = 23;
+export def EMFILE: errno = 24;
+export def ENOTTY: errno = 25;
+export def ETXTBSY: errno = 26;
+export def EFBIG: errno = 27;
+export def ENOSPC: errno = 28;
+export def ESPIPE: errno = 29;
+export def EROFS: errno = 30;
+export def EMLINK: errno = 31;
+export def EPIPE: errno = 32;
+export def EDOM: errno = 33;
+export def ERANGE: errno = 34;
+export def EDEADLK: errno = 35;
+export def ENAMETOOLONG: errno = 36;
+export def ENOLCK: errno = 37;
+export def ENOSYS: errno = 38;
+export def ENOTEMPTY: errno = 39;
+export def ELOOP: errno = 40;
+export def ENOMSG: errno = 42;
+export def EIDRM: errno = 43;
+export def ECHRNG: errno = 44;
+export def EL2NSYNC: errno = 45;
+export def EL3HLT: errno = 46;
+export def EL3RST: errno = 47;
+export def ELNRNG: errno = 48;
+export def EUNATCH: errno = 49;
+export def ENOCSI: errno = 50;
+export def EL2HLT: errno = 51;
+export def EBADE: errno = 52;
+export def EBADR: errno = 53;
+export def EXFULL: errno = 54;
+export def ENOANO: errno = 55;
+export def EBADRQC: errno = 56;
+export def EBADSLT: errno = 57;
+export def EBFONT: errno = 59;
+export def ENOSTR: errno = 60;
+export def ENODATA: errno = 61;
+export def ETIME: errno = 62;
+export def ENOSR: errno = 63;
+export def ENONET: errno = 64;
+export def ENOPKG: errno = 65;
+export def EREMOTE: errno = 66;
+export def ENOLINK: errno = 67;
+export def EADV: errno = 68;
+export def ESRMNT: errno = 69;
+export def ECOMM: errno = 70;
+export def EPROTO: errno = 71;
+export def EMULTIHOP: errno = 72;
+export def EDOTDOT: errno = 73;
+export def EBADMSG: errno = 74;
+export def EOVERFLOW: errno = 75;
+export def ENOTUNIQ: errno = 76;
+export def EBADFD: errno = 77;
+export def EREMCHG: errno = 78;
+export def ELIBACC: errno = 79;
+export def ELIBBAD: errno = 80;
+export def ELIBSCN: errno = 81;
+export def ELIBMAX: errno = 82;
+export def ELIBEXEC: errno = 83;
+export def EILSEQ: errno = 84;
+export def ERESTART: errno = 85;
+export def ESTRPIPE: errno = 86;
+export def EUSERS: errno = 87;
+export def ENOTSOCK: errno = 88;
+export def EDESTADDRREQ: errno = 89;
+export def EMSGSIZE: errno = 90;
+export def EPROTOTYPE: errno = 91;
+export def ENOPROTOOPT: errno = 92;
+export def EPROTONOSUPPORT: errno = 93;
+export def ESOCKTNOSUPPORT: errno = 94;
+export def EOPNOTSUPP: errno = 95;
+export def ENOTSUP: errno = EOPNOTSUPP;
+export def EPFNOSUPPORT: errno = 96;
+export def EAFNOSUPPORT: errno = 97;
+export def EADDRINUSE: errno = 98;
+export def EADDRNOTAVAIL: errno = 99;
+export def ENETDOWN: errno = 100;
+export def ENETUNREACH: errno = 101;
+export def ENETRESET: errno = 102;
+export def ECONNABORTED: errno = 103;
+export def ECONNRESET: errno = 104;
+export def ENOBUFS: errno = 105;
+export def EISCONN: errno = 106;
+export def ENOTCONN: errno = 107;
+export def ESHUTDOWN: errno = 108;
+export def ETOOMANYREFS: errno = 109;
+export def ETIMEDOUT: errno = 110;
+export def ECONNREFUSED: errno = 111;
+export def EHOSTDOWN: errno = 112;
+export def EHOSTUNREACH: errno = 113;
+export def EALREADY: errno = 114;
+export def EINPROGRESS: errno = 115;
+export def ESTALE: errno = 116;
+export def EUCLEAN: errno = 117;
+export def ENOTNAM: errno = 118;
+export def ENAVAIL: errno = 119;
+export def EISNAM: errno = 120;
+export def EREMOTEIO: errno = 121;
+export def EDQUOT: errno = 122;
+export def ENOMEDIUM: errno = 123;
+export def EMEDIUMTYPE: errno = 124;
+export def ECANCELED: errno = 125;
+export def ENOKEY: errno = 126;
+export def EKEYEXPIRED: errno = 127;
+export def EKEYREVOKED: errno = 128;
+export def EKEYREJECTED: errno = 129;
+export def EOWNERDEAD: errno = 130;
+export def ENOTRECOVERABLE: errno = 131;
+export def ERFKILL: errno = 132;
+export def EHWPOISON: errno = 133;
diff --git a/rt/+linux/syscalls.ha b/rt/+linux/syscalls.ha
@@ -300,17 +300,16 @@ export fn mmap(
) (*void | errno) = {
let r = syscall6(SYS_mmap, addr: uintptr: u64,
length: u64, prot: u64, flags: u64, fd: u64, offs: u64);
- return match (wrap_return(r)) {
+ match (wrap_return(r)) {
case let err: errno =>
- return if (r: int == -EPERM
- && addr == null
- && (flags & MAP_ANON) > 0
+ if (err == -EPERM && addr == null && (flags & MAP_ANON) > 0
&& (flags & MAP_FIXED) == 0) {
// Fix up incorrect EPERM from kernel:
- yield wrap_errno(ENOMEM);
- } else err;
+ return wrap_errno(ENOMEM);
+ };
+ return err;
case let n: u64 =>
- yield n: uintptr: *void;
+ return n: uintptr: *void;
};
};
diff --git a/unix/tty/+freebsd/pty.ha b/unix/tty/+freebsd/pty.ha
@@ -28,7 +28,7 @@ export fn ptsname(master: io::file) (str | error) = {
// Ensure that the file descriptor refers to a master
match (rt::ioctl(master, rt::TIOCPTMASTER, null)) {
case let e: rt::errno =>
- if (e: int == rt::EBADF) return errors::invalid
+ if (e == rt::EBADF) return errors::invalid
else return errors::unsupported;
case => void;
};