| ... | @@ -634,6 +634,22 @@ pub const IO_Uring = struct { | ... | @@ -634,6 +634,22 @@ pub const IO_Uring = struct { |
| 634 | return sqe; | 634 | return sqe; |
| 635 | } | 635 | } |
| 636 | | 636 | |
| | 637 | /// Queues (but does not submit) an SQE to update the user data of an existing poll |
| | 638 | /// operation. Returns a pointer to the SQE. |
| | 639 | pub fn poll_update( |
| | 640 | self: *IO_Uring, |
| | 641 | user_data: u64, |
| | 642 | old_user_data: u64, |
| | 643 | new_user_data: u64, |
| | 644 | poll_mask: u32, |
| | 645 | flags: u32, |
| | 646 | ) !*io_uring_sqe { |
| | 647 | const sqe = try self.get_sqe(); |
| | 648 | io_uring_prep_poll_update(sqe, old_user_data, new_user_data, poll_mask, flags); |
| | 649 | sqe.user_data = user_data; |
| | 650 | return sqe; |
| | 651 | } |
| | 652 | |
| 637 | /// Queues (but does not submit) an SQE to perform an `fallocate(2)`. | 653 | /// Queues (but does not submit) an SQE to perform an `fallocate(2)`. |
| 638 | /// Returns a pointer to the SQE. | 654 | /// Returns a pointer to the SQE. |
| 639 | pub fn fallocate( | 655 | pub fn fallocate( |
| ... | @@ -993,6 +1009,16 @@ pub fn io_uring_prep_write_fixed(sqe: *io_uring_sqe, fd: os.fd_t, buffer: *os.io | ... | @@ -993,6 +1009,16 @@ pub fn io_uring_prep_write_fixed(sqe: *io_uring_sqe, fd: os.fd_t, buffer: *os.io |
| 993 | sqe.buf_index = buffer_index; | 1009 | sqe.buf_index = buffer_index; |
| 994 | } | 1010 | } |
| 995 | | 1011 | |
| | 1012 | /// Poll masks previously used to comprise of 16 bits in the flags union of |
| | 1013 | /// a SQE, but were then extended to comprise of 32 bits in order to make |
| | 1014 | /// room for additional option flags. To ensure that the correct bits of |
| | 1015 | /// poll masks are consistently and properly read across multiple kernel |
| | 1016 | /// versions, poll masks are enforced to be little-endian. |
| | 1017 | /// https://www.spinics.net/lists/io-uring/msg02848.html |
| | 1018 | pub inline fn __io_uring_prep_poll_mask(poll_mask: u32) u32 { |
| | 1019 | return std.mem.nativeToLittle(u32, poll_mask); |
| | 1020 | } |
| | 1021 | |
| 996 | pub fn io_uring_prep_accept( | 1022 | pub fn io_uring_prep_accept( |
| 997 | sqe: *io_uring_sqe, | 1023 | sqe: *io_uring_sqe, |
| 998 | fd: os.fd_t, | 1024 | fd: os.fd_t, |
| ... | @@ -1099,7 +1125,7 @@ pub fn io_uring_prep_poll_add( | ... | @@ -1099,7 +1125,7 @@ pub fn io_uring_prep_poll_add( |
| 1099 | poll_mask: u32, | 1125 | poll_mask: u32, |
| 1100 | ) void { | 1126 | ) void { |
| 1101 | io_uring_prep_rw(.POLL_ADD, sqe, fd, @ptrToInt(@as(?*c_void, null)), 0, 0); | 1127 | io_uring_prep_rw(.POLL_ADD, sqe, fd, @ptrToInt(@as(?*c_void, null)), 0, 0); |
| 1102 | sqe.rw_flags = std.mem.nativeToLittle(u32, poll_mask); | 1128 | sqe.rw_flags = __io_uring_prep_poll_mask(poll_mask); |
| 1103 | } | 1129 | } |
| 1104 | | 1130 | |
| 1105 | pub fn io_uring_prep_poll_remove( | 1131 | pub fn io_uring_prep_poll_remove( |
| ... | @@ -1109,6 +1135,17 @@ pub fn io_uring_prep_poll_remove( | ... | @@ -1109,6 +1135,17 @@ pub fn io_uring_prep_poll_remove( |
| 1109 | io_uring_prep_rw(.POLL_REMOVE, sqe, -1, target_user_data, 0, 0); | 1135 | io_uring_prep_rw(.POLL_REMOVE, sqe, -1, target_user_data, 0, 0); |
| 1110 | } | 1136 | } |
| 1111 | | 1137 | |
| | 1138 | pub fn io_uring_prep_poll_update( |
| | 1139 | sqe: *io_uring_sqe, |
| | 1140 | old_user_data: u64, |
| | 1141 | new_user_data: u64, |
| | 1142 | poll_mask: u32, |
| | 1143 | flags: u32, |
| | 1144 | ) void { |
| | 1145 | io_uring_prep_rw(.POLL_REMOVE, sqe, -1, old_user_data, flags, new_user_data); |
| | 1146 | sqe.rw_flags = __io_uring_prep_poll_mask(poll_mask); |
| | 1147 | } |
| | 1148 | |
| 1112 | pub fn io_uring_prep_fallocate( | 1149 | pub fn io_uring_prep_fallocate( |
| 1113 | sqe: *io_uring_sqe, | 1150 | sqe: *io_uring_sqe, |
| 1114 | fd: os.fd_t, | 1151 | fd: os.fd_t, |