From 86177ef6e1bd91cea4f1569b3569c183a475d586 Mon Sep 17 00:00:00 2001 From: Alexey Yerin Date: Fri, 15 Oct 2021 16:01:32 +0300 Subject: [PATCH] all: add 0 value to enums used as flags It indicates to the type system that none of flags can be active. Which also allows types::strflag to work correctly on those types. Signed-off-by: Alexey Yerin --- io_uring/cqe.ha | 4 ++-- io_uring/queue.ha | 2 +- io_uring/uring.ha | 12 ++++++++++++ diff --git a/io_uring/cqe.ha b/io_uring/cqe.ha index 8683c60ec652f756860fccaadc1fab73508dbbe9..b278da82625d0eb113fdeac5c2b1f00e1ca587fe 100644 --- a/io_uring/cqe.ha +++ b/io_uring/cqe.ha @@ -28,7 +28,7 @@ // queue. 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) = +export fn result(cqe: *cqe) (int | error) = if (cqe.res < 0) errors::errno(rt::wrap_errno(-cqe.res)) else cqe.res; @@ -56,7 +56,7 @@ ) (nullable *cqe | error) = { let cq: nullable *cqe = null; for (cq == null) { let enter = false, overflow = false; - let flags: enter_flags = 0; + let flags = enter_flags::NONE; // TODO: tuple destructuring let tup = peek_cqe(ring); diff --git a/io_uring/queue.ha b/io_uring/queue.ha index f3f33967b1303c93586858ab8103434f7e487151..19b696a605a2cf530eca9a16b6fbf3d603325b7e 100644 --- a/io_uring/queue.ha +++ b/io_uring/queue.ha @@ -81,7 +81,7 @@ ring: *io_uring, submitted: uint, wait: uint, ) (uint | error) = { - let flags: enter_flags = enter_flags::GETEVENTS; + let flags = enter_flags::GETEVENTS; if (needs_enter(ring, &flags) || wait != 0) { match (rt::io_uring_enter(ring.fd, submitted, wait, flags, null)) { diff --git a/io_uring/uring.ha b/io_uring/uring.ha index 6f1c68c46b5e9de19c7e7c3c364ea3d20dcfaf78..b6f46b55acff142638f1d8177b339cfe27ffe97b 100644 --- a/io_uring/uring.ha +++ b/io_uring/uring.ha @@ -56,6 +56,7 @@ }; // Flags for an [[sqe]]. export type flags = enum u8 { + NONE = 0, // Use fixed fileset FIXED_FILE = 1 << 0, // Issue after inflight IO @@ -72,11 +73,13 @@ }; // Flags for an fsync operation. export type fsync_flags = enum u32 { + NONE = 0, DATASYNC = 1 << 0, }; // Flags for a timeout operation. export type timeout_flags = enum u32 { + NONE = 0, // If set, the timeout will be "absolute", waiting until CLOCK_MONOTONIC // reaches the time defined by the timespec. If unset, it will be // interpted as a duration relative to the I/O submission. @@ -88,11 +91,13 @@ }; // Flags for a splice operation. export type splice_flags = enum u32 { + NONE = 0, F_FD_IN_FIXED = 1 << 31, }; // Flags for a [[cqe]]. export type cqe_flags = enum u32 { + NONE = 0, F_BUFFER = 1 << 0, }; @@ -162,6 +167,7 @@ }; // Flags for the sq ring. export type sqring_flags = enum u32 { + NONE = 0, // Needs io_uring_enter wakeup NEED_WAKEUP = 1 << 0, // CQ ring is overflown @@ -183,11 +189,13 @@ }; // Flags for the cq ring. export type cqring_flags = enum u32 { + NONE = 0, EVENTFD_DISABLED = 1 << 0, }; // Flags for [[setup]]. export type setup_flags = enum u32 { + NONE = 0, // io_context is polled IOPOLL = 1 << 0, // SQ poll thread @@ -220,6 +228,7 @@ }; // Features supported by the kernel. export type features = enum u32 { + NONE = 0, SINGLE_MMAP = 1 << 0, NODROP = 1 << 1, SUBMIT_STABLE = 1 << 2, @@ -231,6 +240,7 @@ }; // Flags for [[enter]]. export type enter_flags = enum uint { + NONE = 0, GETEVENTS = 1 << 0, SQ_WAKEUP = 1 << 1, SQ_WAIT = 1 << 2, @@ -263,6 +273,7 @@ }; // Flags for a probe operation. export type op_flags = enum u16 { + NONE = 0, SUPPORTED = 1 << 0, }; @@ -297,6 +308,7 @@ }; // Opcode for a [[restriction]]. export type resop = enum u16 { + NONE = 0, // Allow an io_uring_register(2) opcode REGISTER_OP = 0, // Allow an sqe opcode -- 2.48.1