authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-06-05 20:08:20+03:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-06-06 13:11:50-07:00
log15ec55406d4e29cb0b3a753ea76b912d789746d9
tree5792ec4ce50d72000936852ab9b8df9ab6734aa9
parent84000aa820de2d00571f7e8fde5d3973e2fdc441

std: fix ambiguous references


1 files changed, 96 insertions(+), 100 deletions(-)

lib/std/os/linux/io_uring.zig+96-100
......@@ -7,10 +7,6 @@ const os = std.os;
77const linux = os.linux;
88const testing = std.testing;
99
10const io_uring_params = linux.io_uring_params;
11const io_uring_sqe = linux.io_uring_sqe;
12const io_uring_cqe = linux.io_uring_cqe;
13
1410pub const IO_Uring = struct {
1511 fd: os.fd_t = -1,
1612 sq: SubmissionQueue,
......@@ -18,24 +14,24 @@ pub const IO_Uring = struct {
1814 flags: u32,
1915 features: u32,
2016
21 /// A friendly way to setup an io_uring, with default io_uring_params.
17 /// A friendly way to setup an io_uring, with default linux.io_uring_params.
2218 /// `entries` must be a power of two between 1 and 4096, although the kernel will make the final
2319 /// call on how many entries the submission and completion queues will ultimately have,
2420 /// see https://github.com/torvalds/linux/blob/v5.8/fs/io_uring.c#L8027-L8050.
2521 /// Matches the interface of io_uring_queue_init() in liburing.
2622 pub fn init(entries: u13, flags: u32) !IO_Uring {
27 var params = mem.zeroInit(io_uring_params, .{
23 var params = mem.zeroInit(linux.io_uring_params, .{
2824 .flags = flags,
2925 .sq_thread_idle = 1000,
3026 });
3127 return try IO_Uring.init_params(entries, &params);
3228 }
3329
34 /// A powerful way to setup an io_uring, if you want to tweak io_uring_params such as submission
30 /// A powerful way to setup an io_uring, if you want to tweak linux.io_uring_params such as submission
3531 /// queue thread cpu affinity or thread idle timeout (the kernel and our default is 1 second).
3632 /// `params` is passed by reference because the kernel needs to modify the parameters.
3733 /// Matches the interface of io_uring_queue_init_params() in liburing.
38 pub fn init_params(entries: u13, p: *io_uring_params) !IO_Uring {
34 pub fn init_params(entries: u13, p: *linux.io_uring_params) !IO_Uring {
3935 if (entries == 0) return error.EntriesZero;
4036 if (!std.math.isPowerOfTwo(entries)) return error.EntriesNotPowerOfTwo;
4137
......@@ -53,7 +49,7 @@ pub const IO_Uring = struct {
5349 .FAULT => return error.ParamsOutsideAccessibleAddressSpace,
5450 // The resv array contains non-zero data, p.flags contains an unsupported flag,
5551 // entries out of bounds, IORING_SETUP_SQ_AFF was specified without IORING_SETUP_SQPOLL,
56 // or IORING_SETUP_CQSIZE was specified but io_uring_params.cq_entries was invalid:
52 // or IORING_SETUP_CQSIZE was specified but linux.io_uring_params.cq_entries was invalid:
5753 .INVAL => return error.ArgumentsInvalid,
5854 .MFILE => return error.ProcessFdQuotaExceeded,
5955 .NFILE => return error.SystemFdQuotaExceeded,
......@@ -135,7 +131,7 @@ pub const IO_Uring = struct {
135131 /// and the null return in liburing is more a C idiom than anything else, for lack of a better
136132 /// alternative. In Zig, we have first-class error handling... so let's use it.
137133 /// Matches the implementation of io_uring_get_sqe() in liburing.
138 pub fn get_sqe(self: *IO_Uring) !*io_uring_sqe {
134 pub fn get_sqe(self: *IO_Uring) !*linux.io_uring_sqe {
139135 const head = @atomicLoad(u32, self.sq.head, .Acquire);
140136 // Remember that these head and tail offsets wrap around every four billion operations.
141137 // We must therefore use wrapping addition and subtraction to avoid a runtime crash.
......@@ -268,7 +264,7 @@ pub const IO_Uring = struct {
268264 /// Faster, because we can now amortize the atomic store release to `cq.head` across the batch.
269265 /// See https://github.com/axboe/liburing/issues/103#issuecomment-686665007.
270266 /// Matches the implementation of io_uring_peek_batch_cqe() in liburing, but supports waiting.
271 pub fn copy_cqes(self: *IO_Uring, cqes: []io_uring_cqe, wait_nr: u32) !u32 {
267 pub fn copy_cqes(self: *IO_Uring, cqes: []linux.io_uring_cqe, wait_nr: u32) !u32 {
272268 const count = self.copy_cqes_ready(cqes, wait_nr);
273269 if (count > 0) return count;
274270 if (self.cq_ring_needs_flush() or wait_nr > 0) {
......@@ -278,7 +274,7 @@ pub const IO_Uring = struct {
278274 return 0;
279275 }
280276
281 fn copy_cqes_ready(self: *IO_Uring, cqes: []io_uring_cqe, wait_nr: u32) u32 {
277 fn copy_cqes_ready(self: *IO_Uring, cqes: []linux.io_uring_cqe, wait_nr: u32) u32 {
282278 _ = wait_nr;
283279 const ready = self.cq_ready();
284280 const count = std.math.min(cqes.len, ready);
......@@ -298,8 +294,8 @@ pub const IO_Uring = struct {
298294
299295 /// Returns a copy of an I/O completion, waiting for it if necessary, and advancing the CQ ring.
300296 /// A convenience method for `copy_cqes()` for when you don't need to batch or peek.
301 pub fn copy_cqe(ring: *IO_Uring) !io_uring_cqe {
302 var cqes: [1]io_uring_cqe = undefined;
297 pub fn copy_cqe(ring: *IO_Uring) !linux.io_uring_cqe {
298 var cqes: [1]linux.io_uring_cqe = undefined;
303299 while (true) {
304300 const count = try ring.copy_cqes(&cqes, 1);
305301 if (count > 0) return cqes[0];
......@@ -316,7 +312,7 @@ pub const IO_Uring = struct {
316312 /// Must be called exactly once after a zero-copy CQE has been processed by your application.
317313 /// Not idempotent, calling more than once will result in other CQEs being lost.
318314 /// Matches the implementation of cqe_seen() in liburing.
319 pub fn cqe_seen(self: *IO_Uring, cqe: *io_uring_cqe) void {
315 pub fn cqe_seen(self: *IO_Uring, cqe: *linux.io_uring_cqe) void {
320316 _ = cqe;
321317 self.cq_advance(1);
322318 }
......@@ -339,7 +335,7 @@ pub const IO_Uring = struct {
339335 /// apply to the write, since the fsync may complete before the write is issued to the disk.
340336 /// You should preferably use `link_with_next_sqe()` on a write's SQE to link it with an fsync,
341337 /// or else insert a full write barrier using `drain_previous_sqes()` when queueing an fsync.
342 pub fn fsync(self: *IO_Uring, user_data: u64, fd: os.fd_t, flags: u32) !*io_uring_sqe {
338 pub fn fsync(self: *IO_Uring, user_data: u64, fd: os.fd_t, flags: u32) !*linux.io_uring_sqe {
343339 const sqe = try self.get_sqe();
344340 io_uring_prep_fsync(sqe, fd, flags);
345341 sqe.user_data = user_data;
......@@ -351,7 +347,7 @@ pub const IO_Uring = struct {
351347 /// A no-op is more useful than may appear at first glance.
352348 /// For example, you could call `drain_previous_sqes()` on the returned SQE, to use the no-op to
353349 /// know when the ring is idle before acting on a kill signal.
354 pub fn nop(self: *IO_Uring, user_data: u64) !*io_uring_sqe {
350 pub fn nop(self: *IO_Uring, user_data: u64) !*linux.io_uring_sqe {
355351 const sqe = try self.get_sqe();
356352 io_uring_prep_nop(sqe);
357353 sqe.user_data = user_data;
......@@ -387,7 +383,7 @@ pub const IO_Uring = struct {
387383 fd: os.fd_t,
388384 buffer: ReadBuffer,
389385 offset: u64,
390 ) !*io_uring_sqe {
386 ) !*linux.io_uring_sqe {
391387 const sqe = try self.get_sqe();
392388 switch (buffer) {
393389 .buffer => |slice| io_uring_prep_read(sqe, fd, slice, offset),
......@@ -410,7 +406,7 @@ pub const IO_Uring = struct {
410406 fd: os.fd_t,
411407 buffer: []const u8,
412408 offset: u64,
413 ) !*io_uring_sqe {
409 ) !*linux.io_uring_sqe {
414410 const sqe = try self.get_sqe();
415411 io_uring_prep_write(sqe, fd, buffer, offset);
416412 sqe.user_data = user_data;
......@@ -429,7 +425,7 @@ pub const IO_Uring = struct {
429425 buffer: *os.iovec,
430426 offset: u64,
431427 buffer_index: u16,
432 ) !*io_uring_sqe {
428 ) !*linux.io_uring_sqe {
433429 const sqe = try self.get_sqe();
434430 io_uring_prep_read_fixed(sqe, fd, buffer, offset, buffer_index);
435431 sqe.user_data = user_data;
......@@ -446,7 +442,7 @@ pub const IO_Uring = struct {
446442 fd: os.fd_t,
447443 iovecs: []const os.iovec_const,
448444 offset: u64,
449 ) !*io_uring_sqe {
445 ) !*linux.io_uring_sqe {
450446 const sqe = try self.get_sqe();
451447 io_uring_prep_writev(sqe, fd, iovecs, offset);
452448 sqe.user_data = user_data;
......@@ -465,7 +461,7 @@ pub const IO_Uring = struct {
465461 buffer: *os.iovec,
466462 offset: u64,
467463 buffer_index: u16,
468 ) !*io_uring_sqe {
464 ) !*linux.io_uring_sqe {
469465 const sqe = try self.get_sqe();
470466 io_uring_prep_write_fixed(sqe, fd, buffer, offset, buffer_index);
471467 sqe.user_data = user_data;
......@@ -481,7 +477,7 @@ pub const IO_Uring = struct {
481477 addr: *os.sockaddr,
482478 addrlen: *os.socklen_t,
483479 flags: u32,
484 ) !*io_uring_sqe {
480 ) !*linux.io_uring_sqe {
485481 const sqe = try self.get_sqe();
486482 io_uring_prep_accept(sqe, fd, addr, addrlen, flags);
487483 sqe.user_data = user_data;
......@@ -496,7 +492,7 @@ pub const IO_Uring = struct {
496492 fd: os.fd_t,
497493 addr: *const os.sockaddr,
498494 addrlen: os.socklen_t,
499 ) !*io_uring_sqe {
495 ) !*linux.io_uring_sqe {
500496 const sqe = try self.get_sqe();
501497 io_uring_prep_connect(sqe, fd, addr, addrlen);
502498 sqe.user_data = user_data;
......@@ -512,7 +508,7 @@ pub const IO_Uring = struct {
512508 fd: os.fd_t,
513509 op: u32,
514510 ev: ?*linux.epoll_event,
515 ) !*io_uring_sqe {
511 ) !*linux.io_uring_sqe {
516512 const sqe = try self.get_sqe();
517513 io_uring_prep_epoll_ctl(sqe, epfd, fd, op, ev);
518514 sqe.user_data = user_data;
......@@ -541,7 +537,7 @@ pub const IO_Uring = struct {
541537 fd: os.fd_t,
542538 buffer: RecvBuffer,
543539 flags: u32,
544 ) !*io_uring_sqe {
540 ) !*linux.io_uring_sqe {
545541 const sqe = try self.get_sqe();
546542 switch (buffer) {
547543 .buffer => |slice| io_uring_prep_recv(sqe, fd, slice, flags),
......@@ -564,7 +560,7 @@ pub const IO_Uring = struct {
564560 fd: os.fd_t,
565561 buffer: []const u8,
566562 flags: u32,
567 ) !*io_uring_sqe {
563 ) !*linux.io_uring_sqe {
568564 const sqe = try self.get_sqe();
569565 io_uring_prep_send(sqe, fd, buffer, flags);
570566 sqe.user_data = user_data;
......@@ -579,7 +575,7 @@ pub const IO_Uring = struct {
579575 fd: os.fd_t,
580576 msg: *os.msghdr,
581577 flags: u32,
582 ) !*io_uring_sqe {
578 ) !*linux.io_uring_sqe {
583579 const sqe = try self.get_sqe();
584580 io_uring_prep_recvmsg(sqe, fd, msg, flags);
585581 sqe.user_data = user_data;
......@@ -594,7 +590,7 @@ pub const IO_Uring = struct {
594590 fd: os.fd_t,
595591 msg: *const os.msghdr_const,
596592 flags: u32,
597 ) !*io_uring_sqe {
593 ) !*linux.io_uring_sqe {
598594 const sqe = try self.get_sqe();
599595 io_uring_prep_sendmsg(sqe, fd, msg, flags);
600596 sqe.user_data = user_data;
......@@ -610,7 +606,7 @@ pub const IO_Uring = struct {
610606 path: [*:0]const u8,
611607 flags: u32,
612608 mode: os.mode_t,
613 ) !*io_uring_sqe {
609 ) !*linux.io_uring_sqe {
614610 const sqe = try self.get_sqe();
615611 io_uring_prep_openat(sqe, fd, path, flags, mode);
616612 sqe.user_data = user_data;
......@@ -619,7 +615,7 @@ pub const IO_Uring = struct {
619615
620616 /// Queues (but does not submit) an SQE to perform a `close(2)`.
621617 /// Returns a pointer to the SQE.
622 pub fn close(self: *IO_Uring, user_data: u64, fd: os.fd_t) !*io_uring_sqe {
618 pub fn close(self: *IO_Uring, user_data: u64, fd: os.fd_t) !*linux.io_uring_sqe {
623619 const sqe = try self.get_sqe();
624620 io_uring_prep_close(sqe, fd);
625621 sqe.user_data = user_data;
......@@ -645,7 +641,7 @@ pub const IO_Uring = struct {
645641 ts: *const os.linux.kernel_timespec,
646642 count: u32,
647643 flags: u32,
648 ) !*io_uring_sqe {
644 ) !*linux.io_uring_sqe {
649645 const sqe = try self.get_sqe();
650646 io_uring_prep_timeout(sqe, ts, count, flags);
651647 sqe.user_data = user_data;
......@@ -665,7 +661,7 @@ pub const IO_Uring = struct {
665661 user_data: u64,
666662 timeout_user_data: u64,
667663 flags: u32,
668 ) !*io_uring_sqe {
664 ) !*linux.io_uring_sqe {
669665 const sqe = try self.get_sqe();
670666 io_uring_prep_timeout_remove(sqe, timeout_user_data, flags);
671667 sqe.user_data = user_data;
......@@ -693,7 +689,7 @@ pub const IO_Uring = struct {
693689 user_data: u64,
694690 ts: *const os.linux.kernel_timespec,
695691 flags: u32,
696 ) !*io_uring_sqe {
692 ) !*linux.io_uring_sqe {
697693 const sqe = try self.get_sqe();
698694 io_uring_prep_link_timeout(sqe, ts, flags);
699695 sqe.user_data = user_data;
......@@ -707,7 +703,7 @@ pub const IO_Uring = struct {
707703 user_data: u64,
708704 fd: os.fd_t,
709705 poll_mask: u32,
710 ) !*io_uring_sqe {
706 ) !*linux.io_uring_sqe {
711707 const sqe = try self.get_sqe();
712708 io_uring_prep_poll_add(sqe, fd, poll_mask);
713709 sqe.user_data = user_data;
......@@ -720,7 +716,7 @@ pub const IO_Uring = struct {
720716 self: *IO_Uring,
721717 user_data: u64,
722718 target_user_data: u64,
723 ) !*io_uring_sqe {
719 ) !*linux.io_uring_sqe {
724720 const sqe = try self.get_sqe();
725721 io_uring_prep_poll_remove(sqe, target_user_data);
726722 sqe.user_data = user_data;
......@@ -736,7 +732,7 @@ pub const IO_Uring = struct {
736732 new_user_data: u64,
737733 poll_mask: u32,
738734 flags: u32,
739 ) !*io_uring_sqe {
735 ) !*linux.io_uring_sqe {
740736 const sqe = try self.get_sqe();
741737 io_uring_prep_poll_update(sqe, old_user_data, new_user_data, poll_mask, flags);
742738 sqe.user_data = user_data;
......@@ -752,7 +748,7 @@ pub const IO_Uring = struct {
752748 mode: i32,
753749 offset: u64,
754750 len: u64,
755 ) !*io_uring_sqe {
751 ) !*linux.io_uring_sqe {
756752 const sqe = try self.get_sqe();
757753 io_uring_prep_fallocate(sqe, fd, mode, offset, len);
758754 sqe.user_data = user_data;
......@@ -769,7 +765,7 @@ pub const IO_Uring = struct {
769765 flags: u32,
770766 mask: u32,
771767 buf: *linux.Statx,
772 ) !*io_uring_sqe {
768 ) !*linux.io_uring_sqe {
773769 const sqe = try self.get_sqe();
774770 io_uring_prep_statx(sqe, fd, path, flags, mask, buf);
775771 sqe.user_data = user_data;
......@@ -789,7 +785,7 @@ pub const IO_Uring = struct {
789785 user_data: u64,
790786 cancel_user_data: u64,
791787 flags: u32,
792 ) !*io_uring_sqe {
788 ) !*linux.io_uring_sqe {
793789 const sqe = try self.get_sqe();
794790 io_uring_prep_cancel(sqe, cancel_user_data, flags);
795791 sqe.user_data = user_data;
......@@ -805,7 +801,7 @@ pub const IO_Uring = struct {
805801 user_data: u64,
806802 sockfd: os.socket_t,
807803 how: u32,
808 ) !*io_uring_sqe {
804 ) !*linux.io_uring_sqe {
809805 const sqe = try self.get_sqe();
810806 io_uring_prep_shutdown(sqe, sockfd, how);
811807 sqe.user_data = user_data;
......@@ -822,7 +818,7 @@ pub const IO_Uring = struct {
822818 new_dir_fd: os.fd_t,
823819 new_path: [*:0]const u8,
824820 flags: u32,
825 ) !*io_uring_sqe {
821 ) !*linux.io_uring_sqe {
826822 const sqe = try self.get_sqe();
827823 io_uring_prep_renameat(sqe, old_dir_fd, old_path, new_dir_fd, new_path, flags);
828824 sqe.user_data = user_data;
......@@ -837,7 +833,7 @@ pub const IO_Uring = struct {
837833 dir_fd: os.fd_t,
838834 path: [*:0]const u8,
839835 flags: u32,
840 ) !*io_uring_sqe {
836 ) !*linux.io_uring_sqe {
841837 const sqe = try self.get_sqe();
842838 io_uring_prep_unlinkat(sqe, dir_fd, path, flags);
843839 sqe.user_data = user_data;
......@@ -852,7 +848,7 @@ pub const IO_Uring = struct {
852848 dir_fd: os.fd_t,
853849 path: [*:0]const u8,
854850 mode: os.mode_t,
855 ) !*io_uring_sqe {
851 ) !*linux.io_uring_sqe {
856852 const sqe = try self.get_sqe();
857853 io_uring_prep_mkdirat(sqe, dir_fd, path, mode);
858854 sqe.user_data = user_data;
......@@ -867,7 +863,7 @@ pub const IO_Uring = struct {
867863 target: [*:0]const u8,
868864 new_dir_fd: os.fd_t,
869865 link_path: [*:0]const u8,
870 ) !*io_uring_sqe {
866 ) !*linux.io_uring_sqe {
871867 const sqe = try self.get_sqe();
872868 io_uring_prep_symlinkat(sqe, target, new_dir_fd, link_path);
873869 sqe.user_data = user_data;
......@@ -884,7 +880,7 @@ pub const IO_Uring = struct {
884880 new_dir_fd: os.fd_t,
885881 new_path: [*:0]const u8,
886882 flags: u32,
887 ) !*io_uring_sqe {
883 ) !*linux.io_uring_sqe {
888884 const sqe = try self.get_sqe();
889885 io_uring_prep_linkat(sqe, old_dir_fd, old_path, new_dir_fd, new_path, flags);
890886 sqe.user_data = user_data;
......@@ -905,7 +901,7 @@ pub const IO_Uring = struct {
905901 buffer_size: usize,
906902 group_id: usize,
907903 buffer_id: usize,
908 ) !*io_uring_sqe {
904 ) !*linux.io_uring_sqe {
909905 const sqe = try self.get_sqe();
910906 io_uring_prep_provide_buffers(sqe, buffers, buffers_count, buffer_size, group_id, buffer_id);
911907 sqe.user_data = user_data;
......@@ -919,7 +915,7 @@ pub const IO_Uring = struct {
919915 user_data: u64,
920916 buffers_count: usize,
921917 group_id: usize,
922 ) !*io_uring_sqe {
918 ) !*linux.io_uring_sqe {
923919 const sqe = try self.get_sqe();
924920 io_uring_prep_remove_buffers(sqe, buffers_count, group_id);
925921 sqe.user_data = user_data;
......@@ -1083,7 +1079,7 @@ pub const SubmissionQueue = struct {
10831079 flags: *u32,
10841080 dropped: *u32,
10851081 array: []u32,
1086 sqes: []io_uring_sqe,
1082 sqes: []linux.io_uring_sqe,
10871083 mmap: []align(mem.page_size) u8,
10881084 mmap_sqes: []align(mem.page_size) u8,
10891085
......@@ -1094,12 +1090,12 @@ pub const SubmissionQueue = struct {
10941090 sqe_head: u32 = 0,
10951091 sqe_tail: u32 = 0,
10961092
1097 pub fn init(fd: os.fd_t, p: io_uring_params) !SubmissionQueue {
1093 pub fn init(fd: os.fd_t, p: linux.io_uring_params) !SubmissionQueue {
10981094 assert(fd >= 0);
10991095 assert((p.features & linux.IORING_FEAT_SINGLE_MMAP) != 0);
11001096 const size = std.math.max(
11011097 p.sq_off.array + p.sq_entries * @sizeOf(u32),
1102 p.cq_off.cqes + p.cq_entries * @sizeOf(io_uring_cqe),
1098 p.cq_off.cqes + p.cq_entries * @sizeOf(linux.io_uring_cqe),
11031099 );
11041100 const mmap = try os.mmap(
11051101 null,
......@@ -1113,8 +1109,8 @@ pub const SubmissionQueue = struct {
11131109 assert(mmap.len == size);
11141110
11151111 // The motivation for the `sqes` and `array` indirection is to make it possible for the
1116 // application to preallocate static io_uring_sqe entries and then replay them when needed.
1117 const size_sqes = p.sq_entries * @sizeOf(io_uring_sqe);
1112 // application to preallocate static linux.io_uring_sqe entries and then replay them when needed.
1113 const size_sqes = p.sq_entries * @sizeOf(linux.io_uring_sqe);
11181114 const mmap_sqes = try os.mmap(
11191115 null,
11201116 size_sqes,
......@@ -1127,7 +1123,7 @@ pub const SubmissionQueue = struct {
11271123 assert(mmap_sqes.len == size_sqes);
11281124
11291125 const array = @ptrCast([*]u32, @alignCast(@alignOf(u32), &mmap[p.sq_off.array]));
1130 const sqes = @ptrCast([*]io_uring_sqe, @alignCast(@alignOf(io_uring_sqe), &mmap_sqes[0]));
1126 const sqes = @ptrCast([*]linux.io_uring_sqe, @alignCast(@alignOf(linux.io_uring_sqe), &mmap_sqes[0]));
11311127 // We expect the kernel copies p.sq_entries to the u32 pointed to by p.sq_off.ring_entries,
11321128 // see https://github.com/torvalds/linux/blob/v5.8/fs/io_uring.c#L7843-L7844.
11331129 assert(
......@@ -1158,15 +1154,15 @@ pub const CompletionQueue = struct {
11581154 tail: *u32,
11591155 mask: u32,
11601156 overflow: *u32,
1161 cqes: []io_uring_cqe,
1157 cqes: []linux.io_uring_cqe,
11621158
1163 pub fn init(fd: os.fd_t, p: io_uring_params, sq: SubmissionQueue) !CompletionQueue {
1159 pub fn init(fd: os.fd_t, p: linux.io_uring_params, sq: SubmissionQueue) !CompletionQueue {
11641160 assert(fd >= 0);
11651161 assert((p.features & linux.IORING_FEAT_SINGLE_MMAP) != 0);
11661162 const mmap = sq.mmap;
11671163 const cqes = @ptrCast(
1168 [*]io_uring_cqe,
1169 @alignCast(@alignOf(io_uring_cqe), &mmap[p.cq_off.cqes]),
1164 [*]linux.io_uring_cqe,
1165 @alignCast(@alignOf(linux.io_uring_cqe), &mmap[p.cq_off.cqes]),
11701166 );
11711167 assert(p.cq_entries ==
11721168 @ptrCast(*u32, @alignCast(@alignOf(u32), &mmap[p.cq_off.ring_entries])).*);
......@@ -1186,7 +1182,7 @@ pub const CompletionQueue = struct {
11861182 }
11871183};
11881184
1189pub fn io_uring_prep_nop(sqe: *io_uring_sqe) void {
1185pub fn io_uring_prep_nop(sqe: *linux.io_uring_sqe) void {
11901186 sqe.* = .{
11911187 .opcode = .NOP,
11921188 .flags = 0,
......@@ -1204,7 +1200,7 @@ pub fn io_uring_prep_nop(sqe: *io_uring_sqe) void {
12041200 };
12051201}
12061202
1207pub fn io_uring_prep_fsync(sqe: *io_uring_sqe, fd: os.fd_t, flags: u32) void {
1203pub fn io_uring_prep_fsync(sqe: *linux.io_uring_sqe, fd: os.fd_t, flags: u32) void {
12081204 sqe.* = .{
12091205 .opcode = .FSYNC,
12101206 .flags = 0,
......@@ -1224,7 +1220,7 @@ pub fn io_uring_prep_fsync(sqe: *io_uring_sqe, fd: os.fd_t, flags: u32) void {
12241220
12251221pub fn io_uring_prep_rw(
12261222 op: linux.IORING_OP,
1227 sqe: *io_uring_sqe,
1223 sqe: *linux.io_uring_sqe,
12281224 fd: os.fd_t,
12291225 addr: u64,
12301226 len: usize,
......@@ -1247,16 +1243,16 @@ pub fn io_uring_prep_rw(
12471243 };
12481244}
12491245
1250pub fn io_uring_prep_read(sqe: *io_uring_sqe, fd: os.fd_t, buffer: []u8, offset: u64) void {
1246pub fn io_uring_prep_read(sqe: *linux.io_uring_sqe, fd: os.fd_t, buffer: []u8, offset: u64) void {
12511247 io_uring_prep_rw(.READ, sqe, fd, @ptrToInt(buffer.ptr), buffer.len, offset);
12521248}
12531249
1254pub fn io_uring_prep_write(sqe: *io_uring_sqe, fd: os.fd_t, buffer: []const u8, offset: u64) void {
1250pub fn io_uring_prep_write(sqe: *linux.io_uring_sqe, fd: os.fd_t, buffer: []const u8, offset: u64) void {
12551251 io_uring_prep_rw(.WRITE, sqe, fd, @ptrToInt(buffer.ptr), buffer.len, offset);
12561252}
12571253
12581254pub fn io_uring_prep_readv(
1259 sqe: *io_uring_sqe,
1255 sqe: *linux.io_uring_sqe,
12601256 fd: os.fd_t,
12611257 iovecs: []const os.iovec,
12621258 offset: u64,
......@@ -1265,7 +1261,7 @@ pub fn io_uring_prep_readv(
12651261}
12661262
12671263pub fn io_uring_prep_writev(
1268 sqe: *io_uring_sqe,
1264 sqe: *linux.io_uring_sqe,
12691265 fd: os.fd_t,
12701266 iovecs: []const os.iovec_const,
12711267 offset: u64,
......@@ -1273,12 +1269,12 @@ pub fn io_uring_prep_writev(
12731269 io_uring_prep_rw(.WRITEV, sqe, fd, @ptrToInt(iovecs.ptr), iovecs.len, offset);
12741270}
12751271
1276pub fn io_uring_prep_read_fixed(sqe: *io_uring_sqe, fd: os.fd_t, buffer: *os.iovec, offset: u64, buffer_index: u16) void {
1272pub fn io_uring_prep_read_fixed(sqe: *linux.io_uring_sqe, fd: os.fd_t, buffer: *os.iovec, offset: u64, buffer_index: u16) void {
12771273 io_uring_prep_rw(.READ_FIXED, sqe, fd, @ptrToInt(buffer.iov_base), buffer.iov_len, offset);
12781274 sqe.buf_index = buffer_index;
12791275}
12801276
1281pub fn io_uring_prep_write_fixed(sqe: *io_uring_sqe, fd: os.fd_t, buffer: *os.iovec, offset: u64, buffer_index: u16) void {
1277pub fn io_uring_prep_write_fixed(sqe: *linux.io_uring_sqe, fd: os.fd_t, buffer: *os.iovec, offset: u64, buffer_index: u16) void {
12821278 io_uring_prep_rw(.WRITE_FIXED, sqe, fd, @ptrToInt(buffer.iov_base), buffer.iov_len, offset);
12831279 sqe.buf_index = buffer_index;
12841280}
......@@ -1294,7 +1290,7 @@ pub inline fn __io_uring_prep_poll_mask(poll_mask: u32) u32 {
12941290}
12951291
12961292pub fn io_uring_prep_accept(
1297 sqe: *io_uring_sqe,
1293 sqe: *linux.io_uring_sqe,
12981294 fd: os.fd_t,
12991295 addr: *os.sockaddr,
13001296 addrlen: *os.socklen_t,
......@@ -1307,7 +1303,7 @@ pub fn io_uring_prep_accept(
13071303}
13081304
13091305pub fn io_uring_prep_connect(
1310 sqe: *io_uring_sqe,
1306 sqe: *linux.io_uring_sqe,
13111307 fd: os.fd_t,
13121308 addr: *const os.sockaddr,
13131309 addrlen: os.socklen_t,
......@@ -1317,7 +1313,7 @@ pub fn io_uring_prep_connect(
13171313}
13181314
13191315pub fn io_uring_prep_epoll_ctl(
1320 sqe: *io_uring_sqe,
1316 sqe: *linux.io_uring_sqe,
13211317 epfd: os.fd_t,
13221318 fd: os.fd_t,
13231319 op: u32,
......@@ -1326,18 +1322,18 @@ pub fn io_uring_prep_epoll_ctl(
13261322 io_uring_prep_rw(.EPOLL_CTL, sqe, epfd, @ptrToInt(ev), op, @intCast(u64, fd));
13271323}
13281324
1329pub fn io_uring_prep_recv(sqe: *io_uring_sqe, fd: os.fd_t, buffer: []u8, flags: u32) void {
1325pub fn io_uring_prep_recv(sqe: *linux.io_uring_sqe, fd: os.fd_t, buffer: []u8, flags: u32) void {
13301326 io_uring_prep_rw(.RECV, sqe, fd, @ptrToInt(buffer.ptr), buffer.len, 0);
13311327 sqe.rw_flags = flags;
13321328}
13331329
1334pub fn io_uring_prep_send(sqe: *io_uring_sqe, fd: os.fd_t, buffer: []const u8, flags: u32) void {
1330pub fn io_uring_prep_send(sqe: *linux.io_uring_sqe, fd: os.fd_t, buffer: []const u8, flags: u32) void {
13351331 io_uring_prep_rw(.SEND, sqe, fd, @ptrToInt(buffer.ptr), buffer.len, 0);
13361332 sqe.rw_flags = flags;
13371333}
13381334
13391335pub fn io_uring_prep_recvmsg(
1340 sqe: *io_uring_sqe,
1336 sqe: *linux.io_uring_sqe,
13411337 fd: os.fd_t,
13421338 msg: *os.msghdr,
13431339 flags: u32,
......@@ -1347,7 +1343,7 @@ pub fn io_uring_prep_recvmsg(
13471343}
13481344
13491345pub fn io_uring_prep_sendmsg(
1350 sqe: *io_uring_sqe,
1346 sqe: *linux.io_uring_sqe,
13511347 fd: os.fd_t,
13521348 msg: *const os.msghdr_const,
13531349 flags: u32,
......@@ -1357,7 +1353,7 @@ pub fn io_uring_prep_sendmsg(
13571353}
13581354
13591355pub fn io_uring_prep_openat(
1360 sqe: *io_uring_sqe,
1356 sqe: *linux.io_uring_sqe,
13611357 fd: os.fd_t,
13621358 path: [*:0]const u8,
13631359 flags: u32,
......@@ -1367,7 +1363,7 @@ pub fn io_uring_prep_openat(
13671363 sqe.rw_flags = flags;
13681364}
13691365
1370pub fn io_uring_prep_close(sqe: *io_uring_sqe, fd: os.fd_t) void {
1366pub fn io_uring_prep_close(sqe: *linux.io_uring_sqe, fd: os.fd_t) void {
13711367 sqe.* = .{
13721368 .opcode = .CLOSE,
13731369 .flags = 0,
......@@ -1386,7 +1382,7 @@ pub fn io_uring_prep_close(sqe: *io_uring_sqe, fd: os.fd_t) void {
13861382}
13871383
13881384pub fn io_uring_prep_timeout(
1389 sqe: *io_uring_sqe,
1385 sqe: *linux.io_uring_sqe,
13901386 ts: *const os.linux.kernel_timespec,
13911387 count: u32,
13921388 flags: u32,
......@@ -1395,7 +1391,7 @@ pub fn io_uring_prep_timeout(
13951391 sqe.rw_flags = flags;
13961392}
13971393
1398pub fn io_uring_prep_timeout_remove(sqe: *io_uring_sqe, timeout_user_data: u64, flags: u32) void {
1394pub fn io_uring_prep_timeout_remove(sqe: *linux.io_uring_sqe, timeout_user_data: u64, flags: u32) void {
13991395 sqe.* = .{
14001396 .opcode = .TIMEOUT_REMOVE,
14011397 .flags = 0,
......@@ -1414,7 +1410,7 @@ pub fn io_uring_prep_timeout_remove(sqe: *io_uring_sqe, timeout_user_data: u64,
14141410}
14151411
14161412pub fn io_uring_prep_link_timeout(
1417 sqe: *io_uring_sqe,
1413 sqe: *linux.io_uring_sqe,
14181414 ts: *const os.linux.kernel_timespec,
14191415 flags: u32,
14201416) void {
......@@ -1423,7 +1419,7 @@ pub fn io_uring_prep_link_timeout(
14231419}
14241420
14251421pub fn io_uring_prep_poll_add(
1426 sqe: *io_uring_sqe,
1422 sqe: *linux.io_uring_sqe,
14271423 fd: os.fd_t,
14281424 poll_mask: u32,
14291425) void {
......@@ -1432,14 +1428,14 @@ pub fn io_uring_prep_poll_add(
14321428}
14331429
14341430pub fn io_uring_prep_poll_remove(
1435 sqe: *io_uring_sqe,
1431 sqe: *linux.io_uring_sqe,
14361432 target_user_data: u64,
14371433) void {
14381434 io_uring_prep_rw(.POLL_REMOVE, sqe, -1, target_user_data, 0, 0);
14391435}
14401436
14411437pub fn io_uring_prep_poll_update(
1442 sqe: *io_uring_sqe,
1438 sqe: *linux.io_uring_sqe,
14431439 old_user_data: u64,
14441440 new_user_data: u64,
14451441 poll_mask: u32,
......@@ -1450,7 +1446,7 @@ pub fn io_uring_prep_poll_update(
14501446}
14511447
14521448pub fn io_uring_prep_fallocate(
1453 sqe: *io_uring_sqe,
1449 sqe: *linux.io_uring_sqe,
14541450 fd: os.fd_t,
14551451 mode: i32,
14561452 offset: u64,
......@@ -1474,7 +1470,7 @@ pub fn io_uring_prep_fallocate(
14741470}
14751471
14761472pub fn io_uring_prep_statx(
1477 sqe: *io_uring_sqe,
1473 sqe: *linux.io_uring_sqe,
14781474 fd: os.fd_t,
14791475 path: [*:0]const u8,
14801476 flags: u32,
......@@ -1486,7 +1482,7 @@ pub fn io_uring_prep_statx(
14861482}
14871483
14881484pub fn io_uring_prep_cancel(
1489 sqe: *io_uring_sqe,
1485 sqe: *linux.io_uring_sqe,
14901486 cancel_user_data: u64,
14911487 flags: u32,
14921488) void {
......@@ -1495,7 +1491,7 @@ pub fn io_uring_prep_cancel(
14951491}
14961492
14971493pub fn io_uring_prep_shutdown(
1498 sqe: *io_uring_sqe,
1494 sqe: *linux.io_uring_sqe,
14991495 sockfd: os.socket_t,
15001496 how: u32,
15011497) void {
......@@ -1503,7 +1499,7 @@ pub fn io_uring_prep_shutdown(
15031499}
15041500
15051501pub fn io_uring_prep_renameat(
1506 sqe: *io_uring_sqe,
1502 sqe: *linux.io_uring_sqe,
15071503 old_dir_fd: os.fd_t,
15081504 old_path: [*:0]const u8,
15091505 new_dir_fd: os.fd_t,
......@@ -1523,7 +1519,7 @@ pub fn io_uring_prep_renameat(
15231519}
15241520
15251521pub fn io_uring_prep_unlinkat(
1526 sqe: *io_uring_sqe,
1522 sqe: *linux.io_uring_sqe,
15271523 dir_fd: os.fd_t,
15281524 path: [*:0]const u8,
15291525 flags: u32,
......@@ -1533,7 +1529,7 @@ pub fn io_uring_prep_unlinkat(
15331529}
15341530
15351531pub fn io_uring_prep_mkdirat(
1536 sqe: *io_uring_sqe,
1532 sqe: *linux.io_uring_sqe,
15371533 dir_fd: os.fd_t,
15381534 path: [*:0]const u8,
15391535 mode: os.mode_t,
......@@ -1542,7 +1538,7 @@ pub fn io_uring_prep_mkdirat(
15421538}
15431539
15441540pub fn io_uring_prep_symlinkat(
1545 sqe: *io_uring_sqe,
1541 sqe: *linux.io_uring_sqe,
15461542 target: [*:0]const u8,
15471543 new_dir_fd: os.fd_t,
15481544 link_path: [*:0]const u8,
......@@ -1558,7 +1554,7 @@ pub fn io_uring_prep_symlinkat(
15581554}
15591555
15601556pub fn io_uring_prep_linkat(
1561 sqe: *io_uring_sqe,
1557 sqe: *linux.io_uring_sqe,
15621558 old_dir_fd: os.fd_t,
15631559 old_path: [*:0]const u8,
15641560 new_dir_fd: os.fd_t,
......@@ -1578,7 +1574,7 @@ pub fn io_uring_prep_linkat(
15781574}
15791575
15801576pub fn io_uring_prep_provide_buffers(
1581 sqe: *io_uring_sqe,
1577 sqe: *linux.io_uring_sqe,
15821578 buffers: [*]u8,
15831579 num: usize,
15841580 buffer_len: usize,
......@@ -1591,7 +1587,7 @@ pub fn io_uring_prep_provide_buffers(
15911587}
15921588
15931589pub fn io_uring_prep_remove_buffers(
1594 sqe: *io_uring_sqe,
1590 sqe: *linux.io_uring_sqe,
15951591 num: usize,
15961592 group_id: usize,
15971593) void {
......@@ -1602,9 +1598,9 @@ pub fn io_uring_prep_remove_buffers(
16021598test "structs/offsets/entries" {
16031599 if (builtin.os.tag != .linux) return error.SkipZigTest;
16041600
1605 try testing.expectEqual(@as(usize, 120), @sizeOf(io_uring_params));
1606 try testing.expectEqual(@as(usize, 64), @sizeOf(io_uring_sqe));
1607 try testing.expectEqual(@as(usize, 16), @sizeOf(io_uring_cqe));
1601 try testing.expectEqual(@as(usize, 120), @sizeOf(linux.io_uring_params));
1602 try testing.expectEqual(@as(usize, 64), @sizeOf(linux.io_uring_sqe));
1603 try testing.expectEqual(@as(usize, 16), @sizeOf(linux.io_uring_cqe));
16081604
16091605 try testing.expectEqual(0, linux.IORING_OFF_SQ_RING);
16101606 try testing.expectEqual(0x8000000, linux.IORING_OFF_CQ_RING);
......@@ -1628,7 +1624,7 @@ test "nop" {
16281624 }
16291625
16301626 const sqe = try ring.nop(0xaaaaaaaa);
1631 try testing.expectEqual(io_uring_sqe{
1627 try testing.expectEqual(linux.io_uring_sqe{
16321628 .opcode = .NOP,
16331629 .flags = 0,
16341630 .ioprio = 0,
......@@ -1658,7 +1654,7 @@ test "nop" {
16581654 try testing.expectEqual(@as(u32, 0), ring.cq.head.*);
16591655 try testing.expectEqual(@as(u32, 0), ring.sq_ready());
16601656
1661 try testing.expectEqual(io_uring_cqe{
1657 try testing.expectEqual(linux.io_uring_cqe{
16621658 .user_data = 0xaaaaaaaa,
16631659 .res = 0,
16641660 .flags = 0,
......@@ -1669,7 +1665,7 @@ test "nop" {
16691665 const sqe_barrier = try ring.nop(0xbbbbbbbb);
16701666 sqe_barrier.flags |= linux.IOSQE_IO_DRAIN;
16711667 try testing.expectEqual(@as(u32, 1), try ring.submit());
1672 try testing.expectEqual(io_uring_cqe{
1668 try testing.expectEqual(linux.io_uring_cqe{
16731669 .user_data = 0xbbbbbbbb,
16741670 .res = 0,
16751671 .flags = 0,
......@@ -1909,7 +1905,7 @@ test "openat" {
19091905 const flags: u32 = os.O.CLOEXEC | os.O.RDWR | os.O.CREAT;
19101906 const mode: os.mode_t = 0o666;
19111907 const sqe_openat = try ring.openat(0x33333333, linux.AT.FDCWD, path, flags, mode);
1912 try testing.expectEqual(io_uring_sqe{
1908 try testing.expectEqual(linux.io_uring_sqe{
19131909 .opcode = .OPENAT,
19141910 .flags = 0,
19151911 .ioprio = 0,