| author | |
| committer | |
| log | db0d9c21267dd6e482c96be1fc532a5f4eef9219 |
| tree | ec7d264c7356e55599a99b525ce272d8bc884fde |
| parent | 6dc1a4db7f9561dd2b84a99159b3ad7b55958717 |
| parent | 408c817e1e9b4f68f2d0c6b4cc1c6673c591bb2f |
| signature |
linux(io_uring): port new functions from liburing2 files changed, 46 insertions(+), 0 deletions(-)
lib/std/os/linux/IoUring.zig+22| ... | ... | @@ -1186,6 +1186,28 @@ pub fn register_files_update(self: *IoUring, offset: u32, fds: []const posix.fd_ |
| 1186 | 1186 | try handle_registration_result(res); |
| 1187 | 1187 | } |
| 1188 | 1188 | |
| 1189 | /// Registers an empty (-1) file table of `nr_files` number of file descriptors. | |
| 1190 | pub fn register_files_sparse(self: *IoUring, nr_files: u32) !void { | |
| 1191 | assert(self.fd >= 0); | |
| 1192 | ||
| 1193 | const reg = &linux.io_uring_rsrc_register{ | |
| 1194 | .nr = nr_files, | |
| 1195 | .flags = linux.IORING_RSRC_REGISTER_SPARSE, | |
| 1196 | .resv2 = 0, | |
| 1197 | .data = 0, | |
| 1198 | .tags = 0, | |
| 1199 | }; | |
| 1200 | ||
| 1201 | const res = linux.io_uring_register( | |
| 1202 | self.fd, | |
| 1203 | .REGISTER_FILES2, | |
| 1204 | @ptrCast(reg), | |
| 1205 | @as(u32, @sizeOf(linux.io_uring_rsrc_register)), | |
| 1206 | ); | |
| 1207 | ||
| 1208 | return handle_registration_result(res); | |
| 1209 | } | |
| 1210 | ||
| 1189 | 1211 | /// Registers the file descriptor for an eventfd that will be notified of completion events on |
| 1190 | 1212 | /// an io_uring instance. |
| 1191 | 1213 | /// Only a single a eventfd can be registered at any given point in time. |
lib/std/os/linux/io_uring_sqe.zig+24| ... | ... | @@ -436,6 +436,15 @@ pub const io_uring_sqe = extern struct { |
| 436 | 436 | sqe.rw_flags = flags; |
| 437 | 437 | } |
| 438 | 438 | |
| 439 | pub fn prep_cancel_fd( | |
| 440 | sqe: *linux.io_uring_sqe, | |
| 441 | fd: linux.fd_t, | |
| 442 | flags: u32, | |
| 443 | ) void { | |
| 444 | sqe.prep_rw(.ASYNC_CANCEL, fd, 0, 0, 0); | |
| 445 | sqe.rw_flags = flags | linux.IORING_ASYNC_CANCEL_FD; | |
| 446 | } | |
| 447 | ||
| 439 | 448 | pub fn prep_shutdown( |
| 440 | 449 | sqe: *linux.io_uring_sqe, |
| 441 | 450 | sockfd: linux.socket_t, |
| ... | ... | @@ -516,6 +525,21 @@ pub const io_uring_sqe = extern struct { |
| 516 | 525 | sqe.rw_flags = flags; |
| 517 | 526 | } |
| 518 | 527 | |
| 528 | pub fn prep_files_update( | |
| 529 | sqe: *linux.io_uring_sqe, | |
| 530 | fds: []const linux.fd_t, | |
| 531 | offset: u32, | |
| 532 | ) void { | |
| 533 | sqe.prep_rw(.FILES_UPDATE, -1, @intFromPtr(fds.ptr), fds.len, @intCast(offset)); | |
| 534 | } | |
| 535 | ||
| 536 | pub fn prep_files_update_alloc( | |
| 537 | sqe: *linux.io_uring_sqe, | |
| 538 | fds: []linux.fd_t, | |
| 539 | ) void { | |
| 540 | sqe.prep_rw(.FILES_UPDATE, -1, @intFromPtr(fds.ptr), fds.len, linux.IORING_FILE_INDEX_ALLOC); | |
| 541 | } | |
| 542 | ||
| 519 | 543 | pub fn prep_provide_buffers( |
| 520 | 544 | sqe: *linux.io_uring_sqe, |
| 521 | 545 | buffers: [*]u8, |