| ... | ... | @@ -15,7 +15,7 @@ const io_uring_sqe = linux.io_uring_sqe; |
| 15 | 15 | const io_uring_cqe = linux.io_uring_cqe; |
| 16 | 16 | |
| 17 | 17 | pub const IO_Uring = struct { |
| 18 | | fd: i32 = -1, |
| 18 | fd: os.fd_t = -1, |
| 19 | 19 | sq: SubmissionQueue, |
| 20 | 20 | cq: CompletionQueue, |
| 21 | 21 | flags: u32, |
| ... | ... | @@ -76,7 +76,7 @@ pub const IO_Uring = struct { |
| 76 | 76 | linux.ENOSYS => return error.SystemOutdated, |
| 77 | 77 | else => |errno| return os.unexpectedErrno(errno) |
| 78 | 78 | } |
| 79 | | const fd = @intCast(i32, res); |
| 79 | const fd = @intCast(os.fd_t, res); |
| 80 | 80 | assert(fd >= 0); |
| 81 | 81 | errdefer os.close(fd); |
| 82 | 82 | |
| ... | ... | @@ -510,8 +510,9 @@ pub const IO_Uring = struct { |
| 510 | 510 | /// Registering file descriptors will wait for the ring to idle. |
| 511 | 511 | /// Files are automatically unregistered by the kernel when the ring is torn down. |
| 512 | 512 | /// An application need unregister only if it wants to register a new array of file descriptors. |
| 513 | | pub fn register_files(self: *IO_Uring, fds: []const i32) !void { |
| 513 | pub fn register_files(self: *IO_Uring, fds: []const os.fd_t) !void { |
| 514 | 514 | assert(self.fd >= 0); |
| 515 | comptime assert(@sizeOf(os.fd_t) == @sizeOf(c_int)); |
| 515 | 516 | const res = linux.io_uring_register( |
| 516 | 517 | self.fd, |
| 517 | 518 | .REGISTER_FILES, |
| ... | ... | @@ -575,7 +576,7 @@ pub const SubmissionQueue = struct { |
| 575 | 576 | sqe_head: u32 = 0, |
| 576 | 577 | sqe_tail: u32 = 0, |
| 577 | 578 | |
| 578 | | pub fn init(fd: i32, p: io_uring_params) !SubmissionQueue { |
| 579 | pub fn init(fd: os.fd_t, p: io_uring_params) !SubmissionQueue { |
| 579 | 580 | assert(fd >= 0); |
| 580 | 581 | assert((p.features & linux.IORING_FEAT_SINGLE_MMAP) != 0); |
| 581 | 582 | const size = std.math.max( |
| ... | ... | @@ -641,7 +642,7 @@ pub const CompletionQueue = struct { |
| 641 | 642 | overflow: *u32, |
| 642 | 643 | cqes: []io_uring_cqe, |
| 643 | 644 | |
| 644 | | pub fn init(fd: i32, p: io_uring_params, sq: SubmissionQueue) !CompletionQueue { |
| 645 | pub fn init(fd: os.fd_t, p: io_uring_params, sq: SubmissionQueue) !CompletionQueue { |
| 645 | 646 | assert(fd >= 0); |
| 646 | 647 | assert((p.features & linux.IORING_FEAT_SINGLE_MMAP) != 0); |
| 647 | 648 | const mmap = sq.mmap; |
| ... | ... | @@ -678,7 +679,7 @@ test "queue_nop" { |
| 678 | 679 | }; |
| 679 | 680 | defer { |
| 680 | 681 | ring.deinit(); |
| 681 | | testing.expectEqual(@as(i32, -1), ring.fd); |
| 682 | testing.expectEqual(@as(os.fd_t, -1), ring.fd); |
| 682 | 683 | } |
| 683 | 684 | |
| 684 | 685 | var sqe = try ring.queue_nop(@intCast(u64, 0xaaaaaaaa)); |
| ... | ... | @@ -754,7 +755,7 @@ test "queue_readv" { |
| 754 | 755 | // https://github.com/torvalds/linux/blob/v5.4/fs/io_uring.c#L3119-L3124 vs |
| 755 | 756 | // https://github.com/torvalds/linux/blob/v5.8/fs/io_uring.c#L6687-L6691 |
| 756 | 757 | // We therefore avoid stressing sparse fd sets here: |
| 757 | | var registered_fds = [_]i32{0} ** 1; |
| 758 | var registered_fds = [_]os.fd_t{0} ** 1; |
| 758 | 759 | const fd_index = 0; |
| 759 | 760 | registered_fds[fd_index] = fd; |
| 760 | 761 | try ring.register_files(registered_fds[0..]); |