~sircmpwn/hare-linux

0ae2e61ad452dfe931a8a9d04f130b62da367847 — Drew DeVault 2 years ago 0b33642
iobus: implement nobuffers error

Signed-off-by: Drew DeVault <sir@cmpwn.com>
1 files changed, 11 insertions(+), 3 deletions(-)

M io_uring/cqe.ha
M io_uring/cqe.ha => io_uring/cqe.ha +11 -3
@@ 28,9 28,17 @@ export fn wait(ring: *io_uring) (*cqe | error) = {
export fn peek(ring: *io_uring) (nullable *cqe | error) = get_cqe(ring, 0, 0);

// Returns the result of a [[cqe]], or an error if unsuccessful.
export fn result(cqe: *cqe) (int | error) =
	if (cqe.res < 0) errors::errno(rt::wrap_errno(-cqe.res))
	else cqe.res;
export fn result(cqe: *cqe) (int | error) = {
	if (cqe.res >= 0) {
		return cqe.res;
	};
	switch (-cqe.res) {
	case rt::ENOBUFS =>
		return nobuffers;
	case =>
		return errors::errno(rt::wrap_errno(-cqe.res));
	};
};

// Gets the user data field of a [[cqe]]. See [[set_user]] for the corresponding
// SQE function.