~sircmpwn/hare-dev

hare: rt+linux: make errno constants have type rt::errno v1 SUPERSEDED

Ember Sawady: 2
 rt+linux: make errno constants have type rt::errno
 io+linux::fd_copy: simplify

 5 files changed, 149 insertions(+), 163 deletions(-)
#1003005 alpine.yml success
#1003006 freebsd.yml success
hare/patches: SUCCESS in 1m42s

[rt+linux: make errno constants have type rt::errno][0] from [Ember Sawady][1]

[0]: https://lists.sr.ht/~sircmpwn/hare-dev/patches/41699
[1]: mailto:ecs@d2evs.net

✓ #1003005 SUCCESS hare/patches/alpine.yml  https://builds.sr.ht/~sircmpwn/job/1003005
✓ #1003006 SUCCESS hare/patches/freebsd.yml https://builds.sr.ht/~sircmpwn/job/1003006
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/hare-dev/patches/41699/mbox | git am -3
Learn more about email & git

[PATCH hare 1/2] rt+linux: make errno constants have type rt::errno Export this patch

Signed-off-by: Ember Sawady <ecs@d2evs.net>
---
 net/tcp/+linux.ha        |   2 +-
 os/exec/process+linux.ha |   5 +-
 rt/+linux/errno.ha       | 266 +++++++++++++++++++--------------------
 rt/+linux/syscalls.ha    |  13 +-
 4 files changed, 142 insertions(+), 144 deletions(-)

diff --git a/net/tcp/+linux.ha b/net/tcp/+linux.ha
index 993e383f..f627f85e 100644
--- 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+linux.ha b/os/exec/process+linux.ha
index 37a70365..146208ad 100644
--- a/os/exec/process+linux.ha
+++ b/os/exec/process+linux.ha
@@ -78,11 +78,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/+linux/errno.ha b/rt/+linux/errno.ha
index 5319e17f..647e1a2d 100644
--- 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
index 3ae538e8..9a172256 100644
--- 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;
	};
};

-- 
2.41.0
This should be done for FreeBSD as well

[PATCH hare 2/2] io+linux::fd_copy: simplify Export this patch

Signed-off-by: Ember Sawady <ecs@d2evs.net>
---
 io/+linux/file.ha | 26 +++++++-------------------
 1 file changed, 7 insertions(+), 19 deletions(-)

diff --git a/io/+linux/file.ha b/io/+linux/file.ha
index b30b0b9a..fa259bb5 100644
--- a/io/+linux/file.ha
+++ b/io/+linux/file.ha
@@ -67,26 +67,14 @@ def SENDFILE_MAX: size = 2147479552z;

fn fd_copy(to: file, from: file) (size | error) = {
	let sum = 0z;
	for (true) {
		let n = match (rt::sendfile(to, from, null, SENDFILE_MAX)) {
		case let err: rt::errno =>
			switch (err) {
			case rt::EINVAL =>
				if (sum == 0) {
					return errors::unsupported;
				};
				return errors::errno(err);
			case =>
				return errors::errno(err);
			};
		case let n: size =>
			yield switch (n) {
			case 0 =>
				break;
			case =>
				yield n;
			};
	for (true) match (rt::sendfile(to, from, null, SENDFILE_MAX)) {
	case let err: rt::errno =>
		if (err == rt::EINVAL && sum == 0) {
			return errors::unsupported;
		};
		return errors::errno(err);
	case let n: size =>
		if (n == 0) break;
		sum += n;
	};
	return sum;
-- 
2.41.0
hare/patches: SUCCESS in 1m42s

[rt+linux: make errno constants have type rt::errno][0] from [Ember Sawady][1]

[0]: https://lists.sr.ht/~sircmpwn/hare-dev/patches/41699
[1]: mailto:ecs@d2evs.net

✓ #1003005 SUCCESS hare/patches/alpine.yml  https://builds.sr.ht/~sircmpwn/job/1003005
✓ #1003006 SUCCESS hare/patches/freebsd.yml https://builds.sr.ht/~sircmpwn/job/1003006