| ... | ... | @@ -7,10 +7,6 @@ const os = std.os; |
| 7 | 7 | const linux = os.linux; |
| 8 | 8 | const testing = std.testing; |
| 9 | 9 | |
| 10 | | const io_uring_params = linux.io_uring_params; |
| 11 | | const io_uring_sqe = linux.io_uring_sqe; |
| 12 | | const io_uring_cqe = linux.io_uring_cqe; |
| 13 | | |
| 14 | 10 | pub const IO_Uring = struct { |
| 15 | 11 | fd: os.fd_t = -1, |
| 16 | 12 | sq: SubmissionQueue, |
| ... | ... | @@ -18,24 +14,24 @@ pub const IO_Uring = struct { |
| 18 | 14 | flags: u32, |
| 19 | 15 | features: u32, |
| 20 | 16 | |
| 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. |
| 22 | 18 | /// `entries` must be a power of two between 1 and 4096, although the kernel will make the final |
| 23 | 19 | /// call on how many entries the submission and completion queues will ultimately have, |
| 24 | 20 | /// see https://github.com/torvalds/linux/blob/v5.8/fs/io_uring.c#L8027-L8050. |
| 25 | 21 | /// Matches the interface of io_uring_queue_init() in liburing. |
| 26 | 22 | 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, .{ |
| 28 | 24 | .flags = flags, |
| 29 | 25 | .sq_thread_idle = 1000, |
| 30 | 26 | }); |
| 31 | 27 | return try IO_Uring.init_params(entries, &params); |
| 32 | 28 | } |
| 33 | 29 | |
| 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 |
| 35 | 31 | /// queue thread cpu affinity or thread idle timeout (the kernel and our default is 1 second). |
| 36 | 32 | /// `params` is passed by reference because the kernel needs to modify the parameters. |
| 37 | 33 | /// 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 { |
| 39 | 35 | if (entries == 0) return error.EntriesZero; |
| 40 | 36 | if (!std.math.isPowerOfTwo(entries)) return error.EntriesNotPowerOfTwo; |
| 41 | 37 | |
| ... | ... | @@ -53,7 +49,7 @@ pub const IO_Uring = struct { |
| 53 | 49 | .FAULT => return error.ParamsOutsideAccessibleAddressSpace, |
| 54 | 50 | // The resv array contains non-zero data, p.flags contains an unsupported flag, |
| 55 | 51 | // 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: |
| 57 | 53 | .INVAL => return error.ArgumentsInvalid, |
| 58 | 54 | .MFILE => return error.ProcessFdQuotaExceeded, |
| 59 | 55 | .NFILE => return error.SystemFdQuotaExceeded, |
| ... | ... | @@ -135,7 +131,7 @@ pub const IO_Uring = struct { |
| 135 | 131 | /// and the null return in liburing is more a C idiom than anything else, for lack of a better |
| 136 | 132 | /// alternative. In Zig, we have first-class error handling... so let's use it. |
| 137 | 133 | /// 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 { |
| 139 | 135 | const head = @atomicLoad(u32, self.sq.head, .Acquire); |
| 140 | 136 | // Remember that these head and tail offsets wrap around every four billion operations. |
| 141 | 137 | // We must therefore use wrapping addition and subtraction to avoid a runtime crash. |
| ... | ... | @@ -268,7 +264,7 @@ pub const IO_Uring = struct { |
| 268 | 264 | /// Faster, because we can now amortize the atomic store release to `cq.head` across the batch. |
| 269 | 265 | /// See https://github.com/axboe/liburing/issues/103#issuecomment-686665007. |
| 270 | 266 | /// 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 { |
| 272 | 268 | const count = self.copy_cqes_ready(cqes, wait_nr); |
| 273 | 269 | if (count > 0) return count; |
| 274 | 270 | if (self.cq_ring_needs_flush() or wait_nr > 0) { |
| ... | ... | @@ -278,7 +274,7 @@ pub const IO_Uring = struct { |
| 278 | 274 | return 0; |
| 279 | 275 | } |
| 280 | 276 | |
| 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 { |
| 282 | 278 | _ = wait_nr; |
| 283 | 279 | const ready = self.cq_ready(); |
| 284 | 280 | const count = std.math.min(cqes.len, ready); |
| ... | ... | @@ -298,8 +294,8 @@ pub const IO_Uring = struct { |
| 298 | 294 | |
| 299 | 295 | /// Returns a copy of an I/O completion, waiting for it if necessary, and advancing the CQ ring. |
| 300 | 296 | /// 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; |
| 303 | 299 | while (true) { |
| 304 | 300 | const count = try ring.copy_cqes(&cqes, 1); |
| 305 | 301 | if (count > 0) return cqes[0]; |
| ... | ... | @@ -316,7 +312,7 @@ pub const IO_Uring = struct { |
| 316 | 312 | /// Must be called exactly once after a zero-copy CQE has been processed by your application. |
| 317 | 313 | /// Not idempotent, calling more than once will result in other CQEs being lost. |
| 318 | 314 | /// 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 { |
| 320 | 316 | _ = cqe; |
| 321 | 317 | self.cq_advance(1); |
| 322 | 318 | } |
| ... | ... | @@ -339,7 +335,7 @@ pub const IO_Uring = struct { |
| 339 | 335 | /// apply to the write, since the fsync may complete before the write is issued to the disk. |
| 340 | 336 | /// You should preferably use `link_with_next_sqe()` on a write's SQE to link it with an fsync, |
| 341 | 337 | /// 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 { |
| 343 | 339 | const sqe = try self.get_sqe(); |
| 344 | 340 | io_uring_prep_fsync(sqe, fd, flags); |
| 345 | 341 | sqe.user_data = user_data; |
| ... | ... | @@ -351,7 +347,7 @@ pub const IO_Uring = struct { |
| 351 | 347 | /// A no-op is more useful than may appear at first glance. |
| 352 | 348 | /// For example, you could call `drain_previous_sqes()` on the returned SQE, to use the no-op to |
| 353 | 349 | /// 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 { |
| 355 | 351 | const sqe = try self.get_sqe(); |
| 356 | 352 | io_uring_prep_nop(sqe); |
| 357 | 353 | sqe.user_data = user_data; |
| ... | ... | @@ -387,7 +383,7 @@ pub const IO_Uring = struct { |
| 387 | 383 | fd: os.fd_t, |
| 388 | 384 | buffer: ReadBuffer, |
| 389 | 385 | offset: u64, |
| 390 | | ) !*io_uring_sqe { |
| 386 | ) !*linux.io_uring_sqe { |
| 391 | 387 | const sqe = try self.get_sqe(); |
| 392 | 388 | switch (buffer) { |
| 393 | 389 | .buffer => |slice| io_uring_prep_read(sqe, fd, slice, offset), |
| ... | ... | @@ -410,7 +406,7 @@ pub const IO_Uring = struct { |
| 410 | 406 | fd: os.fd_t, |
| 411 | 407 | buffer: []const u8, |
| 412 | 408 | offset: u64, |
| 413 | | ) !*io_uring_sqe { |
| 409 | ) !*linux.io_uring_sqe { |
| 414 | 410 | const sqe = try self.get_sqe(); |
| 415 | 411 | io_uring_prep_write(sqe, fd, buffer, offset); |
| 416 | 412 | sqe.user_data = user_data; |
| ... | ... | @@ -429,7 +425,7 @@ pub const IO_Uring = struct { |
| 429 | 425 | buffer: *os.iovec, |
| 430 | 426 | offset: u64, |
| 431 | 427 | buffer_index: u16, |
| 432 | | ) !*io_uring_sqe { |
| 428 | ) !*linux.io_uring_sqe { |
| 433 | 429 | const sqe = try self.get_sqe(); |
| 434 | 430 | io_uring_prep_read_fixed(sqe, fd, buffer, offset, buffer_index); |
| 435 | 431 | sqe.user_data = user_data; |
| ... | ... | @@ -446,7 +442,7 @@ pub const IO_Uring = struct { |
| 446 | 442 | fd: os.fd_t, |
| 447 | 443 | iovecs: []const os.iovec_const, |
| 448 | 444 | offset: u64, |
| 449 | | ) !*io_uring_sqe { |
| 445 | ) !*linux.io_uring_sqe { |
| 450 | 446 | const sqe = try self.get_sqe(); |
| 451 | 447 | io_uring_prep_writev(sqe, fd, iovecs, offset); |
| 452 | 448 | sqe.user_data = user_data; |
| ... | ... | @@ -465,7 +461,7 @@ pub const IO_Uring = struct { |
| 465 | 461 | buffer: *os.iovec, |
| 466 | 462 | offset: u64, |
| 467 | 463 | buffer_index: u16, |
| 468 | | ) !*io_uring_sqe { |
| 464 | ) !*linux.io_uring_sqe { |
| 469 | 465 | const sqe = try self.get_sqe(); |
| 470 | 466 | io_uring_prep_write_fixed(sqe, fd, buffer, offset, buffer_index); |
| 471 | 467 | sqe.user_data = user_data; |
| ... | ... | @@ -481,7 +477,7 @@ pub const IO_Uring = struct { |
| 481 | 477 | addr: *os.sockaddr, |
| 482 | 478 | addrlen: *os.socklen_t, |
| 483 | 479 | flags: u32, |
| 484 | | ) !*io_uring_sqe { |
| 480 | ) !*linux.io_uring_sqe { |
| 485 | 481 | const sqe = try self.get_sqe(); |
| 486 | 482 | io_uring_prep_accept(sqe, fd, addr, addrlen, flags); |
| 487 | 483 | sqe.user_data = user_data; |
| ... | ... | @@ -496,7 +492,7 @@ pub const IO_Uring = struct { |
| 496 | 492 | fd: os.fd_t, |
| 497 | 493 | addr: *const os.sockaddr, |
| 498 | 494 | addrlen: os.socklen_t, |
| 499 | | ) !*io_uring_sqe { |
| 495 | ) !*linux.io_uring_sqe { |
| 500 | 496 | const sqe = try self.get_sqe(); |
| 501 | 497 | io_uring_prep_connect(sqe, fd, addr, addrlen); |
| 502 | 498 | sqe.user_data = user_data; |
| ... | ... | @@ -512,7 +508,7 @@ pub const IO_Uring = struct { |
| 512 | 508 | fd: os.fd_t, |
| 513 | 509 | op: u32, |
| 514 | 510 | ev: ?*linux.epoll_event, |
| 515 | | ) !*io_uring_sqe { |
| 511 | ) !*linux.io_uring_sqe { |
| 516 | 512 | const sqe = try self.get_sqe(); |
| 517 | 513 | io_uring_prep_epoll_ctl(sqe, epfd, fd, op, ev); |
| 518 | 514 | sqe.user_data = user_data; |
| ... | ... | @@ -541,7 +537,7 @@ pub const IO_Uring = struct { |
| 541 | 537 | fd: os.fd_t, |
| 542 | 538 | buffer: RecvBuffer, |
| 543 | 539 | flags: u32, |
| 544 | | ) !*io_uring_sqe { |
| 540 | ) !*linux.io_uring_sqe { |
| 545 | 541 | const sqe = try self.get_sqe(); |
| 546 | 542 | switch (buffer) { |
| 547 | 543 | .buffer => |slice| io_uring_prep_recv(sqe, fd, slice, flags), |
| ... | ... | @@ -564,7 +560,7 @@ pub const IO_Uring = struct { |
| 564 | 560 | fd: os.fd_t, |
| 565 | 561 | buffer: []const u8, |
| 566 | 562 | flags: u32, |
| 567 | | ) !*io_uring_sqe { |
| 563 | ) !*linux.io_uring_sqe { |
| 568 | 564 | const sqe = try self.get_sqe(); |
| 569 | 565 | io_uring_prep_send(sqe, fd, buffer, flags); |
| 570 | 566 | sqe.user_data = user_data; |
| ... | ... | @@ -579,7 +575,7 @@ pub const IO_Uring = struct { |
| 579 | 575 | fd: os.fd_t, |
| 580 | 576 | msg: *os.msghdr, |
| 581 | 577 | flags: u32, |
| 582 | | ) !*io_uring_sqe { |
| 578 | ) !*linux.io_uring_sqe { |
| 583 | 579 | const sqe = try self.get_sqe(); |
| 584 | 580 | io_uring_prep_recvmsg(sqe, fd, msg, flags); |
| 585 | 581 | sqe.user_data = user_data; |
| ... | ... | @@ -594,7 +590,7 @@ pub const IO_Uring = struct { |
| 594 | 590 | fd: os.fd_t, |
| 595 | 591 | msg: *const os.msghdr_const, |
| 596 | 592 | flags: u32, |
| 597 | | ) !*io_uring_sqe { |
| 593 | ) !*linux.io_uring_sqe { |
| 598 | 594 | const sqe = try self.get_sqe(); |
| 599 | 595 | io_uring_prep_sendmsg(sqe, fd, msg, flags); |
| 600 | 596 | sqe.user_data = user_data; |
| ... | ... | @@ -610,7 +606,7 @@ pub const IO_Uring = struct { |
| 610 | 606 | path: [*:0]const u8, |
| 611 | 607 | flags: u32, |
| 612 | 608 | mode: os.mode_t, |
| 613 | | ) !*io_uring_sqe { |
| 609 | ) !*linux.io_uring_sqe { |
| 614 | 610 | const sqe = try self.get_sqe(); |
| 615 | 611 | io_uring_prep_openat(sqe, fd, path, flags, mode); |
| 616 | 612 | sqe.user_data = user_data; |
| ... | ... | @@ -619,7 +615,7 @@ pub const IO_Uring = struct { |
| 619 | 615 | |
| 620 | 616 | /// Queues (but does not submit) an SQE to perform a `close(2)`. |
| 621 | 617 | /// 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 { |
| 623 | 619 | const sqe = try self.get_sqe(); |
| 624 | 620 | io_uring_prep_close(sqe, fd); |
| 625 | 621 | sqe.user_data = user_data; |
| ... | ... | @@ -645,7 +641,7 @@ pub const IO_Uring = struct { |
| 645 | 641 | ts: *const os.linux.kernel_timespec, |
| 646 | 642 | count: u32, |
| 647 | 643 | flags: u32, |
| 648 | | ) !*io_uring_sqe { |
| 644 | ) !*linux.io_uring_sqe { |
| 649 | 645 | const sqe = try self.get_sqe(); |
| 650 | 646 | io_uring_prep_timeout(sqe, ts, count, flags); |
| 651 | 647 | sqe.user_data = user_data; |
| ... | ... | @@ -665,7 +661,7 @@ pub const IO_Uring = struct { |
| 665 | 661 | user_data: u64, |
| 666 | 662 | timeout_user_data: u64, |
| 667 | 663 | flags: u32, |
| 668 | | ) !*io_uring_sqe { |
| 664 | ) !*linux.io_uring_sqe { |
| 669 | 665 | const sqe = try self.get_sqe(); |
| 670 | 666 | io_uring_prep_timeout_remove(sqe, timeout_user_data, flags); |
| 671 | 667 | sqe.user_data = user_data; |
| ... | ... | @@ -693,7 +689,7 @@ pub const IO_Uring = struct { |
| 693 | 689 | user_data: u64, |
| 694 | 690 | ts: *const os.linux.kernel_timespec, |
| 695 | 691 | flags: u32, |
| 696 | | ) !*io_uring_sqe { |
| 692 | ) !*linux.io_uring_sqe { |
| 697 | 693 | const sqe = try self.get_sqe(); |
| 698 | 694 | io_uring_prep_link_timeout(sqe, ts, flags); |
| 699 | 695 | sqe.user_data = user_data; |
| ... | ... | @@ -707,7 +703,7 @@ pub const IO_Uring = struct { |
| 707 | 703 | user_data: u64, |
| 708 | 704 | fd: os.fd_t, |
| 709 | 705 | poll_mask: u32, |
| 710 | | ) !*io_uring_sqe { |
| 706 | ) !*linux.io_uring_sqe { |
| 711 | 707 | const sqe = try self.get_sqe(); |
| 712 | 708 | io_uring_prep_poll_add(sqe, fd, poll_mask); |
| 713 | 709 | sqe.user_data = user_data; |
| ... | ... | @@ -720,7 +716,7 @@ pub const IO_Uring = struct { |
| 720 | 716 | self: *IO_Uring, |
| 721 | 717 | user_data: u64, |
| 722 | 718 | target_user_data: u64, |
| 723 | | ) !*io_uring_sqe { |
| 719 | ) !*linux.io_uring_sqe { |
| 724 | 720 | const sqe = try self.get_sqe(); |
| 725 | 721 | io_uring_prep_poll_remove(sqe, target_user_data); |
| 726 | 722 | sqe.user_data = user_data; |
| ... | ... | @@ -736,7 +732,7 @@ pub const IO_Uring = struct { |
| 736 | 732 | new_user_data: u64, |
| 737 | 733 | poll_mask: u32, |
| 738 | 734 | flags: u32, |
| 739 | | ) !*io_uring_sqe { |
| 735 | ) !*linux.io_uring_sqe { |
| 740 | 736 | const sqe = try self.get_sqe(); |
| 741 | 737 | io_uring_prep_poll_update(sqe, old_user_data, new_user_data, poll_mask, flags); |
| 742 | 738 | sqe.user_data = user_data; |
| ... | ... | @@ -752,7 +748,7 @@ pub const IO_Uring = struct { |
| 752 | 748 | mode: i32, |
| 753 | 749 | offset: u64, |
| 754 | 750 | len: u64, |
| 755 | | ) !*io_uring_sqe { |
| 751 | ) !*linux.io_uring_sqe { |
| 756 | 752 | const sqe = try self.get_sqe(); |
| 757 | 753 | io_uring_prep_fallocate(sqe, fd, mode, offset, len); |
| 758 | 754 | sqe.user_data = user_data; |
| ... | ... | @@ -769,7 +765,7 @@ pub const IO_Uring = struct { |
| 769 | 765 | flags: u32, |
| 770 | 766 | mask: u32, |
| 771 | 767 | buf: *linux.Statx, |
| 772 | | ) !*io_uring_sqe { |
| 768 | ) !*linux.io_uring_sqe { |
| 773 | 769 | const sqe = try self.get_sqe(); |
| 774 | 770 | io_uring_prep_statx(sqe, fd, path, flags, mask, buf); |
| 775 | 771 | sqe.user_data = user_data; |
| ... | ... | @@ -789,7 +785,7 @@ pub const IO_Uring = struct { |
| 789 | 785 | user_data: u64, |
| 790 | 786 | cancel_user_data: u64, |
| 791 | 787 | flags: u32, |
| 792 | | ) !*io_uring_sqe { |
| 788 | ) !*linux.io_uring_sqe { |
| 793 | 789 | const sqe = try self.get_sqe(); |
| 794 | 790 | io_uring_prep_cancel(sqe, cancel_user_data, flags); |
| 795 | 791 | sqe.user_data = user_data; |
| ... | ... | @@ -805,7 +801,7 @@ pub const IO_Uring = struct { |
| 805 | 801 | user_data: u64, |
| 806 | 802 | sockfd: os.socket_t, |
| 807 | 803 | how: u32, |
| 808 | | ) !*io_uring_sqe { |
| 804 | ) !*linux.io_uring_sqe { |
| 809 | 805 | const sqe = try self.get_sqe(); |
| 810 | 806 | io_uring_prep_shutdown(sqe, sockfd, how); |
| 811 | 807 | sqe.user_data = user_data; |
| ... | ... | @@ -822,7 +818,7 @@ pub const IO_Uring = struct { |
| 822 | 818 | new_dir_fd: os.fd_t, |
| 823 | 819 | new_path: [*:0]const u8, |
| 824 | 820 | flags: u32, |
| 825 | | ) !*io_uring_sqe { |
| 821 | ) !*linux.io_uring_sqe { |
| 826 | 822 | const sqe = try self.get_sqe(); |
| 827 | 823 | io_uring_prep_renameat(sqe, old_dir_fd, old_path, new_dir_fd, new_path, flags); |
| 828 | 824 | sqe.user_data = user_data; |
| ... | ... | @@ -837,7 +833,7 @@ pub const IO_Uring = struct { |
| 837 | 833 | dir_fd: os.fd_t, |
| 838 | 834 | path: [*:0]const u8, |
| 839 | 835 | flags: u32, |
| 840 | | ) !*io_uring_sqe { |
| 836 | ) !*linux.io_uring_sqe { |
| 841 | 837 | const sqe = try self.get_sqe(); |
| 842 | 838 | io_uring_prep_unlinkat(sqe, dir_fd, path, flags); |
| 843 | 839 | sqe.user_data = user_data; |
| ... | ... | @@ -852,7 +848,7 @@ pub const IO_Uring = struct { |
| 852 | 848 | dir_fd: os.fd_t, |
| 853 | 849 | path: [*:0]const u8, |
| 854 | 850 | mode: os.mode_t, |
| 855 | | ) !*io_uring_sqe { |
| 851 | ) !*linux.io_uring_sqe { |
| 856 | 852 | const sqe = try self.get_sqe(); |
| 857 | 853 | io_uring_prep_mkdirat(sqe, dir_fd, path, mode); |
| 858 | 854 | sqe.user_data = user_data; |
| ... | ... | @@ -867,7 +863,7 @@ pub const IO_Uring = struct { |
| 867 | 863 | target: [*:0]const u8, |
| 868 | 864 | new_dir_fd: os.fd_t, |
| 869 | 865 | link_path: [*:0]const u8, |
| 870 | | ) !*io_uring_sqe { |
| 866 | ) !*linux.io_uring_sqe { |
| 871 | 867 | const sqe = try self.get_sqe(); |
| 872 | 868 | io_uring_prep_symlinkat(sqe, target, new_dir_fd, link_path); |
| 873 | 869 | sqe.user_data = user_data; |
| ... | ... | @@ -884,7 +880,7 @@ pub const IO_Uring = struct { |
| 884 | 880 | new_dir_fd: os.fd_t, |
| 885 | 881 | new_path: [*:0]const u8, |
| 886 | 882 | flags: u32, |
| 887 | | ) !*io_uring_sqe { |
| 883 | ) !*linux.io_uring_sqe { |
| 888 | 884 | const sqe = try self.get_sqe(); |
| 889 | 885 | io_uring_prep_linkat(sqe, old_dir_fd, old_path, new_dir_fd, new_path, flags); |
| 890 | 886 | sqe.user_data = user_data; |
| ... | ... | @@ -905,7 +901,7 @@ pub const IO_Uring = struct { |
| 905 | 901 | buffer_size: usize, |
| 906 | 902 | group_id: usize, |
| 907 | 903 | buffer_id: usize, |
| 908 | | ) !*io_uring_sqe { |
| 904 | ) !*linux.io_uring_sqe { |
| 909 | 905 | const sqe = try self.get_sqe(); |
| 910 | 906 | io_uring_prep_provide_buffers(sqe, buffers, buffers_count, buffer_size, group_id, buffer_id); |
| 911 | 907 | sqe.user_data = user_data; |
| ... | ... | @@ -919,7 +915,7 @@ pub const IO_Uring = struct { |
| 919 | 915 | user_data: u64, |
| 920 | 916 | buffers_count: usize, |
| 921 | 917 | group_id: usize, |
| 922 | | ) !*io_uring_sqe { |
| 918 | ) !*linux.io_uring_sqe { |
| 923 | 919 | const sqe = try self.get_sqe(); |
| 924 | 920 | io_uring_prep_remove_buffers(sqe, buffers_count, group_id); |
| 925 | 921 | sqe.user_data = user_data; |
| ... | ... | @@ -1083,7 +1079,7 @@ pub const SubmissionQueue = struct { |
| 1083 | 1079 | flags: *u32, |
| 1084 | 1080 | dropped: *u32, |
| 1085 | 1081 | array: []u32, |
| 1086 | | sqes: []io_uring_sqe, |
| 1082 | sqes: []linux.io_uring_sqe, |
| 1087 | 1083 | mmap: []align(mem.page_size) u8, |
| 1088 | 1084 | mmap_sqes: []align(mem.page_size) u8, |
| 1089 | 1085 | |
| ... | ... | @@ -1094,12 +1090,12 @@ pub const SubmissionQueue = struct { |
| 1094 | 1090 | sqe_head: u32 = 0, |
| 1095 | 1091 | sqe_tail: u32 = 0, |
| 1096 | 1092 | |
| 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 { |
| 1098 | 1094 | assert(fd >= 0); |
| 1099 | 1095 | assert((p.features & linux.IORING_FEAT_SINGLE_MMAP) != 0); |
| 1100 | 1096 | const size = std.math.max( |
| 1101 | 1097 | 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), |
| 1103 | 1099 | ); |
| 1104 | 1100 | const mmap = try os.mmap( |
| 1105 | 1101 | null, |
| ... | ... | @@ -1113,8 +1109,8 @@ pub const SubmissionQueue = struct { |
| 1113 | 1109 | assert(mmap.len == size); |
| 1114 | 1110 | |
| 1115 | 1111 | // 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); |
| 1118 | 1114 | const mmap_sqes = try os.mmap( |
| 1119 | 1115 | null, |
| 1120 | 1116 | size_sqes, |
| ... | ... | @@ -1127,7 +1123,7 @@ pub const SubmissionQueue = struct { |
| 1127 | 1123 | assert(mmap_sqes.len == size_sqes); |
| 1128 | 1124 | |
| 1129 | 1125 | 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])); |
| 1131 | 1127 | // We expect the kernel copies p.sq_entries to the u32 pointed to by p.sq_off.ring_entries, |
| 1132 | 1128 | // see https://github.com/torvalds/linux/blob/v5.8/fs/io_uring.c#L7843-L7844. |
| 1133 | 1129 | assert( |
| ... | ... | @@ -1158,15 +1154,15 @@ pub const CompletionQueue = struct { |
| 1158 | 1154 | tail: *u32, |
| 1159 | 1155 | mask: u32, |
| 1160 | 1156 | overflow: *u32, |
| 1161 | | cqes: []io_uring_cqe, |
| 1157 | cqes: []linux.io_uring_cqe, |
| 1162 | 1158 | |
| 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 { |
| 1164 | 1160 | assert(fd >= 0); |
| 1165 | 1161 | assert((p.features & linux.IORING_FEAT_SINGLE_MMAP) != 0); |
| 1166 | 1162 | const mmap = sq.mmap; |
| 1167 | 1163 | 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]), |
| 1170 | 1166 | ); |
| 1171 | 1167 | assert(p.cq_entries == |
| 1172 | 1168 | @ptrCast(*u32, @alignCast(@alignOf(u32), &mmap[p.cq_off.ring_entries])).*); |
| ... | ... | @@ -1186,7 +1182,7 @@ pub const CompletionQueue = struct { |
| 1186 | 1182 | } |
| 1187 | 1183 | }; |
| 1188 | 1184 | |
| 1189 | | pub fn io_uring_prep_nop(sqe: *io_uring_sqe) void { |
| 1185 | pub fn io_uring_prep_nop(sqe: *linux.io_uring_sqe) void { |
| 1190 | 1186 | sqe.* = .{ |
| 1191 | 1187 | .opcode = .NOP, |
| 1192 | 1188 | .flags = 0, |
| ... | ... | @@ -1204,7 +1200,7 @@ pub fn io_uring_prep_nop(sqe: *io_uring_sqe) void { |
| 1204 | 1200 | }; |
| 1205 | 1201 | } |
| 1206 | 1202 | |
| 1207 | | pub fn io_uring_prep_fsync(sqe: *io_uring_sqe, fd: os.fd_t, flags: u32) void { |
| 1203 | pub fn io_uring_prep_fsync(sqe: *linux.io_uring_sqe, fd: os.fd_t, flags: u32) void { |
| 1208 | 1204 | sqe.* = .{ |
| 1209 | 1205 | .opcode = .FSYNC, |
| 1210 | 1206 | .flags = 0, |
| ... | ... | @@ -1224,7 +1220,7 @@ pub fn io_uring_prep_fsync(sqe: *io_uring_sqe, fd: os.fd_t, flags: u32) void { |
| 1224 | 1220 | |
| 1225 | 1221 | pub fn io_uring_prep_rw( |
| 1226 | 1222 | op: linux.IORING_OP, |
| 1227 | | sqe: *io_uring_sqe, |
| 1223 | sqe: *linux.io_uring_sqe, |
| 1228 | 1224 | fd: os.fd_t, |
| 1229 | 1225 | addr: u64, |
| 1230 | 1226 | len: usize, |
| ... | ... | @@ -1247,16 +1243,16 @@ pub fn io_uring_prep_rw( |
| 1247 | 1243 | }; |
| 1248 | 1244 | } |
| 1249 | 1245 | |
| 1250 | | pub fn io_uring_prep_read(sqe: *io_uring_sqe, fd: os.fd_t, buffer: []u8, offset: u64) void { |
| 1246 | pub fn io_uring_prep_read(sqe: *linux.io_uring_sqe, fd: os.fd_t, buffer: []u8, offset: u64) void { |
| 1251 | 1247 | io_uring_prep_rw(.READ, sqe, fd, @ptrToInt(buffer.ptr), buffer.len, offset); |
| 1252 | 1248 | } |
| 1253 | 1249 | |
| 1254 | | pub fn io_uring_prep_write(sqe: *io_uring_sqe, fd: os.fd_t, buffer: []const u8, offset: u64) void { |
| 1250 | pub fn io_uring_prep_write(sqe: *linux.io_uring_sqe, fd: os.fd_t, buffer: []const u8, offset: u64) void { |
| 1255 | 1251 | io_uring_prep_rw(.WRITE, sqe, fd, @ptrToInt(buffer.ptr), buffer.len, offset); |
| 1256 | 1252 | } |
| 1257 | 1253 | |
| 1258 | 1254 | pub fn io_uring_prep_readv( |
| 1259 | | sqe: *io_uring_sqe, |
| 1255 | sqe: *linux.io_uring_sqe, |
| 1260 | 1256 | fd: os.fd_t, |
| 1261 | 1257 | iovecs: []const os.iovec, |
| 1262 | 1258 | offset: u64, |
| ... | ... | @@ -1265,7 +1261,7 @@ pub fn io_uring_prep_readv( |
| 1265 | 1261 | } |
| 1266 | 1262 | |
| 1267 | 1263 | pub fn io_uring_prep_writev( |
| 1268 | | sqe: *io_uring_sqe, |
| 1264 | sqe: *linux.io_uring_sqe, |
| 1269 | 1265 | fd: os.fd_t, |
| 1270 | 1266 | iovecs: []const os.iovec_const, |
| 1271 | 1267 | offset: u64, |
| ... | ... | @@ -1273,12 +1269,12 @@ pub fn io_uring_prep_writev( |
| 1273 | 1269 | io_uring_prep_rw(.WRITEV, sqe, fd, @ptrToInt(iovecs.ptr), iovecs.len, offset); |
| 1274 | 1270 | } |
| 1275 | 1271 | |
| 1276 | | pub fn io_uring_prep_read_fixed(sqe: *io_uring_sqe, fd: os.fd_t, buffer: *os.iovec, offset: u64, buffer_index: u16) void { |
| 1272 | pub fn io_uring_prep_read_fixed(sqe: *linux.io_uring_sqe, fd: os.fd_t, buffer: *os.iovec, offset: u64, buffer_index: u16) void { |
| 1277 | 1273 | io_uring_prep_rw(.READ_FIXED, sqe, fd, @ptrToInt(buffer.iov_base), buffer.iov_len, offset); |
| 1278 | 1274 | sqe.buf_index = buffer_index; |
| 1279 | 1275 | } |
| 1280 | 1276 | |
| 1281 | | pub fn io_uring_prep_write_fixed(sqe: *io_uring_sqe, fd: os.fd_t, buffer: *os.iovec, offset: u64, buffer_index: u16) void { |
| 1277 | pub fn io_uring_prep_write_fixed(sqe: *linux.io_uring_sqe, fd: os.fd_t, buffer: *os.iovec, offset: u64, buffer_index: u16) void { |
| 1282 | 1278 | io_uring_prep_rw(.WRITE_FIXED, sqe, fd, @ptrToInt(buffer.iov_base), buffer.iov_len, offset); |
| 1283 | 1279 | sqe.buf_index = buffer_index; |
| 1284 | 1280 | } |
| ... | ... | @@ -1294,7 +1290,7 @@ pub inline fn __io_uring_prep_poll_mask(poll_mask: u32) u32 { |
| 1294 | 1290 | } |
| 1295 | 1291 | |
| 1296 | 1292 | pub fn io_uring_prep_accept( |
| 1297 | | sqe: *io_uring_sqe, |
| 1293 | sqe: *linux.io_uring_sqe, |
| 1298 | 1294 | fd: os.fd_t, |
| 1299 | 1295 | addr: *os.sockaddr, |
| 1300 | 1296 | addrlen: *os.socklen_t, |
| ... | ... | @@ -1307,7 +1303,7 @@ pub fn io_uring_prep_accept( |
| 1307 | 1303 | } |
| 1308 | 1304 | |
| 1309 | 1305 | pub fn io_uring_prep_connect( |
| 1310 | | sqe: *io_uring_sqe, |
| 1306 | sqe: *linux.io_uring_sqe, |
| 1311 | 1307 | fd: os.fd_t, |
| 1312 | 1308 | addr: *const os.sockaddr, |
| 1313 | 1309 | addrlen: os.socklen_t, |
| ... | ... | @@ -1317,7 +1313,7 @@ pub fn io_uring_prep_connect( |
| 1317 | 1313 | } |
| 1318 | 1314 | |
| 1319 | 1315 | pub fn io_uring_prep_epoll_ctl( |
| 1320 | | sqe: *io_uring_sqe, |
| 1316 | sqe: *linux.io_uring_sqe, |
| 1321 | 1317 | epfd: os.fd_t, |
| 1322 | 1318 | fd: os.fd_t, |
| 1323 | 1319 | op: u32, |
| ... | ... | @@ -1326,18 +1322,18 @@ pub fn io_uring_prep_epoll_ctl( |
| 1326 | 1322 | io_uring_prep_rw(.EPOLL_CTL, sqe, epfd, @ptrToInt(ev), op, @intCast(u64, fd)); |
| 1327 | 1323 | } |
| 1328 | 1324 | |
| 1329 | | pub fn io_uring_prep_recv(sqe: *io_uring_sqe, fd: os.fd_t, buffer: []u8, flags: u32) void { |
| 1325 | pub fn io_uring_prep_recv(sqe: *linux.io_uring_sqe, fd: os.fd_t, buffer: []u8, flags: u32) void { |
| 1330 | 1326 | io_uring_prep_rw(.RECV, sqe, fd, @ptrToInt(buffer.ptr), buffer.len, 0); |
| 1331 | 1327 | sqe.rw_flags = flags; |
| 1332 | 1328 | } |
| 1333 | 1329 | |
| 1334 | | pub fn io_uring_prep_send(sqe: *io_uring_sqe, fd: os.fd_t, buffer: []const u8, flags: u32) void { |
| 1330 | pub fn io_uring_prep_send(sqe: *linux.io_uring_sqe, fd: os.fd_t, buffer: []const u8, flags: u32) void { |
| 1335 | 1331 | io_uring_prep_rw(.SEND, sqe, fd, @ptrToInt(buffer.ptr), buffer.len, 0); |
| 1336 | 1332 | sqe.rw_flags = flags; |
| 1337 | 1333 | } |
| 1338 | 1334 | |
| 1339 | 1335 | pub fn io_uring_prep_recvmsg( |
| 1340 | | sqe: *io_uring_sqe, |
| 1336 | sqe: *linux.io_uring_sqe, |
| 1341 | 1337 | fd: os.fd_t, |
| 1342 | 1338 | msg: *os.msghdr, |
| 1343 | 1339 | flags: u32, |
| ... | ... | @@ -1347,7 +1343,7 @@ pub fn io_uring_prep_recvmsg( |
| 1347 | 1343 | } |
| 1348 | 1344 | |
| 1349 | 1345 | pub fn io_uring_prep_sendmsg( |
| 1350 | | sqe: *io_uring_sqe, |
| 1346 | sqe: *linux.io_uring_sqe, |
| 1351 | 1347 | fd: os.fd_t, |
| 1352 | 1348 | msg: *const os.msghdr_const, |
| 1353 | 1349 | flags: u32, |
| ... | ... | @@ -1357,7 +1353,7 @@ pub fn io_uring_prep_sendmsg( |
| 1357 | 1353 | } |
| 1358 | 1354 | |
| 1359 | 1355 | pub fn io_uring_prep_openat( |
| 1360 | | sqe: *io_uring_sqe, |
| 1356 | sqe: *linux.io_uring_sqe, |
| 1361 | 1357 | fd: os.fd_t, |
| 1362 | 1358 | path: [*:0]const u8, |
| 1363 | 1359 | flags: u32, |
| ... | ... | @@ -1367,7 +1363,7 @@ pub fn io_uring_prep_openat( |
| 1367 | 1363 | sqe.rw_flags = flags; |
| 1368 | 1364 | } |
| 1369 | 1365 | |
| 1370 | | pub fn io_uring_prep_close(sqe: *io_uring_sqe, fd: os.fd_t) void { |
| 1366 | pub fn io_uring_prep_close(sqe: *linux.io_uring_sqe, fd: os.fd_t) void { |
| 1371 | 1367 | sqe.* = .{ |
| 1372 | 1368 | .opcode = .CLOSE, |
| 1373 | 1369 | .flags = 0, |
| ... | ... | @@ -1386,7 +1382,7 @@ pub fn io_uring_prep_close(sqe: *io_uring_sqe, fd: os.fd_t) void { |
| 1386 | 1382 | } |
| 1387 | 1383 | |
| 1388 | 1384 | pub fn io_uring_prep_timeout( |
| 1389 | | sqe: *io_uring_sqe, |
| 1385 | sqe: *linux.io_uring_sqe, |
| 1390 | 1386 | ts: *const os.linux.kernel_timespec, |
| 1391 | 1387 | count: u32, |
| 1392 | 1388 | flags: u32, |
| ... | ... | @@ -1395,7 +1391,7 @@ pub fn io_uring_prep_timeout( |
| 1395 | 1391 | sqe.rw_flags = flags; |
| 1396 | 1392 | } |
| 1397 | 1393 | |
| 1398 | | pub fn io_uring_prep_timeout_remove(sqe: *io_uring_sqe, timeout_user_data: u64, flags: u32) void { |
| 1394 | pub fn io_uring_prep_timeout_remove(sqe: *linux.io_uring_sqe, timeout_user_data: u64, flags: u32) void { |
| 1399 | 1395 | sqe.* = .{ |
| 1400 | 1396 | .opcode = .TIMEOUT_REMOVE, |
| 1401 | 1397 | .flags = 0, |
| ... | ... | @@ -1414,7 +1410,7 @@ pub fn io_uring_prep_timeout_remove(sqe: *io_uring_sqe, timeout_user_data: u64, |
| 1414 | 1410 | } |
| 1415 | 1411 | |
| 1416 | 1412 | pub fn io_uring_prep_link_timeout( |
| 1417 | | sqe: *io_uring_sqe, |
| 1413 | sqe: *linux.io_uring_sqe, |
| 1418 | 1414 | ts: *const os.linux.kernel_timespec, |
| 1419 | 1415 | flags: u32, |
| 1420 | 1416 | ) void { |
| ... | ... | @@ -1423,7 +1419,7 @@ pub fn io_uring_prep_link_timeout( |
| 1423 | 1419 | } |
| 1424 | 1420 | |
| 1425 | 1421 | pub fn io_uring_prep_poll_add( |
| 1426 | | sqe: *io_uring_sqe, |
| 1422 | sqe: *linux.io_uring_sqe, |
| 1427 | 1423 | fd: os.fd_t, |
| 1428 | 1424 | poll_mask: u32, |
| 1429 | 1425 | ) void { |
| ... | ... | @@ -1432,14 +1428,14 @@ pub fn io_uring_prep_poll_add( |
| 1432 | 1428 | } |
| 1433 | 1429 | |
| 1434 | 1430 | pub fn io_uring_prep_poll_remove( |
| 1435 | | sqe: *io_uring_sqe, |
| 1431 | sqe: *linux.io_uring_sqe, |
| 1436 | 1432 | target_user_data: u64, |
| 1437 | 1433 | ) void { |
| 1438 | 1434 | io_uring_prep_rw(.POLL_REMOVE, sqe, -1, target_user_data, 0, 0); |
| 1439 | 1435 | } |
| 1440 | 1436 | |
| 1441 | 1437 | pub fn io_uring_prep_poll_update( |
| 1442 | | sqe: *io_uring_sqe, |
| 1438 | sqe: *linux.io_uring_sqe, |
| 1443 | 1439 | old_user_data: u64, |
| 1444 | 1440 | new_user_data: u64, |
| 1445 | 1441 | poll_mask: u32, |
| ... | ... | @@ -1450,7 +1446,7 @@ pub fn io_uring_prep_poll_update( |
| 1450 | 1446 | } |
| 1451 | 1447 | |
| 1452 | 1448 | pub fn io_uring_prep_fallocate( |
| 1453 | | sqe: *io_uring_sqe, |
| 1449 | sqe: *linux.io_uring_sqe, |
| 1454 | 1450 | fd: os.fd_t, |
| 1455 | 1451 | mode: i32, |
| 1456 | 1452 | offset: u64, |
| ... | ... | @@ -1474,7 +1470,7 @@ pub fn io_uring_prep_fallocate( |
| 1474 | 1470 | } |
| 1475 | 1471 | |
| 1476 | 1472 | pub fn io_uring_prep_statx( |
| 1477 | | sqe: *io_uring_sqe, |
| 1473 | sqe: *linux.io_uring_sqe, |
| 1478 | 1474 | fd: os.fd_t, |
| 1479 | 1475 | path: [*:0]const u8, |
| 1480 | 1476 | flags: u32, |
| ... | ... | @@ -1486,7 +1482,7 @@ pub fn io_uring_prep_statx( |
| 1486 | 1482 | } |
| 1487 | 1483 | |
| 1488 | 1484 | pub fn io_uring_prep_cancel( |
| 1489 | | sqe: *io_uring_sqe, |
| 1485 | sqe: *linux.io_uring_sqe, |
| 1490 | 1486 | cancel_user_data: u64, |
| 1491 | 1487 | flags: u32, |
| 1492 | 1488 | ) void { |
| ... | ... | @@ -1495,7 +1491,7 @@ pub fn io_uring_prep_cancel( |
| 1495 | 1491 | } |
| 1496 | 1492 | |
| 1497 | 1493 | pub fn io_uring_prep_shutdown( |
| 1498 | | sqe: *io_uring_sqe, |
| 1494 | sqe: *linux.io_uring_sqe, |
| 1499 | 1495 | sockfd: os.socket_t, |
| 1500 | 1496 | how: u32, |
| 1501 | 1497 | ) void { |
| ... | ... | @@ -1503,7 +1499,7 @@ pub fn io_uring_prep_shutdown( |
| 1503 | 1499 | } |
| 1504 | 1500 | |
| 1505 | 1501 | pub fn io_uring_prep_renameat( |
| 1506 | | sqe: *io_uring_sqe, |
| 1502 | sqe: *linux.io_uring_sqe, |
| 1507 | 1503 | old_dir_fd: os.fd_t, |
| 1508 | 1504 | old_path: [*:0]const u8, |
| 1509 | 1505 | new_dir_fd: os.fd_t, |
| ... | ... | @@ -1523,7 +1519,7 @@ pub fn io_uring_prep_renameat( |
| 1523 | 1519 | } |
| 1524 | 1520 | |
| 1525 | 1521 | pub fn io_uring_prep_unlinkat( |
| 1526 | | sqe: *io_uring_sqe, |
| 1522 | sqe: *linux.io_uring_sqe, |
| 1527 | 1523 | dir_fd: os.fd_t, |
| 1528 | 1524 | path: [*:0]const u8, |
| 1529 | 1525 | flags: u32, |
| ... | ... | @@ -1533,7 +1529,7 @@ pub fn io_uring_prep_unlinkat( |
| 1533 | 1529 | } |
| 1534 | 1530 | |
| 1535 | 1531 | pub fn io_uring_prep_mkdirat( |
| 1536 | | sqe: *io_uring_sqe, |
| 1532 | sqe: *linux.io_uring_sqe, |
| 1537 | 1533 | dir_fd: os.fd_t, |
| 1538 | 1534 | path: [*:0]const u8, |
| 1539 | 1535 | mode: os.mode_t, |
| ... | ... | @@ -1542,7 +1538,7 @@ pub fn io_uring_prep_mkdirat( |
| 1542 | 1538 | } |
| 1543 | 1539 | |
| 1544 | 1540 | pub fn io_uring_prep_symlinkat( |
| 1545 | | sqe: *io_uring_sqe, |
| 1541 | sqe: *linux.io_uring_sqe, |
| 1546 | 1542 | target: [*:0]const u8, |
| 1547 | 1543 | new_dir_fd: os.fd_t, |
| 1548 | 1544 | link_path: [*:0]const u8, |
| ... | ... | @@ -1558,7 +1554,7 @@ pub fn io_uring_prep_symlinkat( |
| 1558 | 1554 | } |
| 1559 | 1555 | |
| 1560 | 1556 | pub fn io_uring_prep_linkat( |
| 1561 | | sqe: *io_uring_sqe, |
| 1557 | sqe: *linux.io_uring_sqe, |
| 1562 | 1558 | old_dir_fd: os.fd_t, |
| 1563 | 1559 | old_path: [*:0]const u8, |
| 1564 | 1560 | new_dir_fd: os.fd_t, |
| ... | ... | @@ -1578,7 +1574,7 @@ pub fn io_uring_prep_linkat( |
| 1578 | 1574 | } |
| 1579 | 1575 | |
| 1580 | 1576 | pub fn io_uring_prep_provide_buffers( |
| 1581 | | sqe: *io_uring_sqe, |
| 1577 | sqe: *linux.io_uring_sqe, |
| 1582 | 1578 | buffers: [*]u8, |
| 1583 | 1579 | num: usize, |
| 1584 | 1580 | buffer_len: usize, |
| ... | ... | @@ -1591,7 +1587,7 @@ pub fn io_uring_prep_provide_buffers( |
| 1591 | 1587 | } |
| 1592 | 1588 | |
| 1593 | 1589 | pub fn io_uring_prep_remove_buffers( |
| 1594 | | sqe: *io_uring_sqe, |
| 1590 | sqe: *linux.io_uring_sqe, |
| 1595 | 1591 | num: usize, |
| 1596 | 1592 | group_id: usize, |
| 1597 | 1593 | ) void { |
| ... | ... | @@ -1602,9 +1598,9 @@ pub fn io_uring_prep_remove_buffers( |
| 1602 | 1598 | test "structs/offsets/entries" { |
| 1603 | 1599 | if (builtin.os.tag != .linux) return error.SkipZigTest; |
| 1604 | 1600 | |
| 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)); |
| 1608 | 1604 | |
| 1609 | 1605 | try testing.expectEqual(0, linux.IORING_OFF_SQ_RING); |
| 1610 | 1606 | try testing.expectEqual(0x8000000, linux.IORING_OFF_CQ_RING); |
| ... | ... | @@ -1628,7 +1624,7 @@ test "nop" { |
| 1628 | 1624 | } |
| 1629 | 1625 | |
| 1630 | 1626 | const sqe = try ring.nop(0xaaaaaaaa); |
| 1631 | | try testing.expectEqual(io_uring_sqe{ |
| 1627 | try testing.expectEqual(linux.io_uring_sqe{ |
| 1632 | 1628 | .opcode = .NOP, |
| 1633 | 1629 | .flags = 0, |
| 1634 | 1630 | .ioprio = 0, |
| ... | ... | @@ -1658,7 +1654,7 @@ test "nop" { |
| 1658 | 1654 | try testing.expectEqual(@as(u32, 0), ring.cq.head.*); |
| 1659 | 1655 | try testing.expectEqual(@as(u32, 0), ring.sq_ready()); |
| 1660 | 1656 | |
| 1661 | | try testing.expectEqual(io_uring_cqe{ |
| 1657 | try testing.expectEqual(linux.io_uring_cqe{ |
| 1662 | 1658 | .user_data = 0xaaaaaaaa, |
| 1663 | 1659 | .res = 0, |
| 1664 | 1660 | .flags = 0, |
| ... | ... | @@ -1669,7 +1665,7 @@ test "nop" { |
| 1669 | 1665 | const sqe_barrier = try ring.nop(0xbbbbbbbb); |
| 1670 | 1666 | sqe_barrier.flags |= linux.IOSQE_IO_DRAIN; |
| 1671 | 1667 | try testing.expectEqual(@as(u32, 1), try ring.submit()); |
| 1672 | | try testing.expectEqual(io_uring_cqe{ |
| 1668 | try testing.expectEqual(linux.io_uring_cqe{ |
| 1673 | 1669 | .user_data = 0xbbbbbbbb, |
| 1674 | 1670 | .res = 0, |
| 1675 | 1671 | .flags = 0, |
| ... | ... | @@ -1909,7 +1905,7 @@ test "openat" { |
| 1909 | 1905 | const flags: u32 = os.O.CLOEXEC | os.O.RDWR | os.O.CREAT; |
| 1910 | 1906 | const mode: os.mode_t = 0o666; |
| 1911 | 1907 | 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{ |
| 1913 | 1909 | .opcode = .OPENAT, |
| 1914 | 1910 | .flags = 0, |
| 1915 | 1911 | .ioprio = 0, |