| ... | ... | @@ -18,7 +18,7 @@ comptime { |
| 18 | 18 | assert(@sizeOf(io_uring_params) == 120); |
| 19 | 19 | assert(@sizeOf(io_uring_sqe) == 64); |
| 20 | 20 | assert(@sizeOf(io_uring_cqe) == 16); |
| 21 | | |
| 21 | |
| 22 | 22 | assert(linux.IORING_OFF_SQ_RING == 0); |
| 23 | 23 | assert(linux.IORING_OFF_CQ_RING == 0x8000000); |
| 24 | 24 | assert(linux.IORING_OFF_SQES == 0x10000000); |
| ... | ... | @@ -192,9 +192,9 @@ pub const IO_Uring = struct { |
| 192 | 192 | return submitted; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | | // Tell the kernel we have submitted SQEs and/or want to wait for CQEs. |
| 196 | | // Returns the number of SQEs submitted. |
| 197 | | fn enter(self: *IO_Uring, to_submit: u32, min_complete: u32, flags: u32) !u32 { |
| 195 | /// Tell the kernel we have submitted SQEs and/or want to wait for CQEs. |
| 196 | /// Returns the number of SQEs submitted. |
| 197 | pub fn enter(self: *IO_Uring, to_submit: u32, min_complete: u32, flags: u32) !u32 { |
| 198 | 198 | assert(self.fd >= 0); |
| 199 | 199 | const res = linux.io_uring_enter(self.fd, to_submit, min_complete, flags, null); |
| 200 | 200 | switch (linux.getErrno(res)) { |
| ... | ... | @@ -225,12 +225,12 @@ pub const IO_Uring = struct { |
| 225 | 225 | return @truncate(u32, res); |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | | // Sync internal state with kernel ring state on the SQ side. |
| 229 | | // Returns the number of all pending events in the SQ ring, for the shared ring. |
| 230 | | // This return value includes previously flushed SQEs, as per liburing. |
| 231 | | // The reasoning for this is to suggest that an io_uring_enter() call is needed rather than not. |
| 232 | | // Matches the implementation of __io_uring_flush_sq() in liburing. |
| 233 | | fn flush_sq(self: *IO_Uring) u32 { |
| 228 | /// Sync internal state with kernel ring state on the SQ side. |
| 229 | /// Returns the number of all pending events in the SQ ring, for the shared ring. |
| 230 | /// This return value includes previously flushed SQEs, as per liburing. |
| 231 | /// The rationale is to suggest that an io_uring_enter() call is needed rather than not. |
| 232 | /// Matches the implementation of __io_uring_flush_sq() in liburing. |
| 233 | pub fn flush_sq(self: *IO_Uring) u32 { |
| 234 | 234 | if (self.sq.sqe_head != self.sq.sqe_tail) { |
| 235 | 235 | // Fill in SQEs that we have queued up, adding them to the kernel ring. |
| 236 | 236 | const to_submit = self.sq.sqe_tail -% self.sq.sqe_head; |
| ... | ... | @@ -252,7 +252,7 @@ pub const IO_Uring = struct { |
| 252 | 252 | /// or if IORING_SQ_NEED_WAKEUP is set and the SQ thread must be explicitly awakened. |
| 253 | 253 | /// For the latter case, we set the SQ thread wakeup flag. |
| 254 | 254 | /// Matches the implementation of sq_ring_needs_enter() in liburing. |
| 255 | | fn sq_ring_needs_enter(self: *IO_Uring, submitted: u32, flags: *u32) bool { |
| 255 | pub fn sq_ring_needs_enter(self: *IO_Uring, submitted: u32, flags: *u32) bool { |
| 256 | 256 | assert(flags.* == 0); |
| 257 | 257 | if ((self.flags & linux.IORING_SETUP_SQPOLL) == 0 and submitted > 0) return true; |
| 258 | 258 | if ((@atomicLoad(u32, self.sq.flags, .Unordered) & linux.IORING_SQ_NEED_WAKEUP) != 0) { |
| ... | ... | @@ -326,8 +326,8 @@ pub const IO_Uring = struct { |
| 326 | 326 | return cqes[0]; |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | | // Matches the implementation of cq_ring_needs_flush() in liburing. |
| 330 | | fn cq_ring_needs_flush(self: *IO_Uring) bool { |
| 329 | /// Matches the implementation of cq_ring_needs_flush() in liburing. |
| 330 | pub fn cq_ring_needs_flush(self: *IO_Uring) bool { |
| 331 | 331 | return (@atomicLoad(u32, self.sq.flags, .Unordered) & linux.IORING_SQ_CQ_OVERFLOW) != 0; |
| 332 | 332 | } |
| 333 | 333 | |
| ... | ... | @@ -567,7 +567,6 @@ pub const IO_Uring = struct { |
| 567 | 567 | } |
| 568 | 568 | }; |
| 569 | 569 | |
| 570 | | |
| 571 | 570 | pub const SubmissionQueue = struct { |
| 572 | 571 | head: *u32, |
| 573 | 572 | tail: *u32, |