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