Commit graph

65 commits

Author SHA1 Message Date
Bernard Assan
23e3753ca7
IoUring: use the splice flags type for splice and tee
Use appropriately sized integers where applicable

Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-11-21 12:51:20 +00:00
Bernard Assan
f6be2c37c6
IoUring: implement outstanding flags and enumerations
Add SYNC_FILE_RANGE_* flags
add XATTR_* flags
Add Madvise for MADV_* constants
Add Fadvise enum type for POSIX_FADV_* constants

Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-11-21 12:51:20 +00:00
Bernard Assan
f17c49390d
Use linux types directly since IoUring is only supported on linux
Use explicit array types were possible

Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-11-21 12:51:20 +00:00
Bernard Assan
a9ea85fe18
IoUring: implement pipe and pipe_direct operations
Add dedicated Pipe2 flags for pipe2 as O contains some fields which are
invalid in that context

Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-11-21 12:51:20 +00:00
Bernard Assan
97b3c06a84
IoUring: Working on Pipe2 flags
Build on the extensive work already done

IoUring: add fixed_fd_install, ftruncate, cmd_discard

Working on IoUring pipe flags

Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-11-21 12:51:20 +00:00
Bernard Assan
3f1933edeb
IoUring: futex operations
Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>

Add futex_* operations to IoUring

Refactor Futex 2 flags into Futex2 struct

add mpol to Wait flags and fix private field as its 128 not 32

Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>

Update futex2_* functions and constants to use the new Futex2 type

Improve the Api of futex2_* functions to be more idiomatic Zig

Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-11-21 12:44:58 +00:00
Bernard Assan
b426714f72
Add XattrSource to decide how to prepare set/getxattr operations
Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-11-21 12:44:58 +00:00
Bernard Assan
8a9320c013
IoUring: Implement set_iowait functionality
closes https://github.com/ziglang/zig/issues/25566
closes https://github.com/ziglang/zig/pull/25604

and IoUring enter_flags() helper function
add typed Init flags which match int_flags in liburing

Co-authored-by: RaidoAun <45874591+RaidoAun@users.noreply.github.com>
Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-11-21 12:44:58 +00:00
Bernard Assan
5b49e7af9e
add msg_ring_*, setxattr and getxattr IoUring operations
TODO: add SetXattr flags

Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-11-21 12:44:57 +00:00
Bernard Assan
ae9a05fc82
add IoUring send_bundle, send_to, recv_multishot, sync_file_range
ignore prep_openat2* for now

add non-at variant of some unlink, rename, mkdir, symlink, link

TODO: add Sync File Flags

Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-11-21 12:44:57 +00:00
Bernard Assan
ee71dcca10
Implement some more IoUring operations
Add timeout update, cancel_fd, epoll_wait, files_update, open, open_direct, f/madvice

don't implement f/madvice64 for now I doubt it is used by a lot of people in practice

Implement BufferGroup read_multishot

Try to make definition of function align as logically as posible with
liburing to make keeping our implementation in sync easy

TODO: add M/Fadvice enum flags
TODO: understand buffer_selection and how its different from BufferGroup

Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-11-21 12:44:57 +00:00
Bernard Assan
f68bcb6b5f
Move buf_ring_* functions into BufferRing type as methods
add IoUring tee syscall functionality

adapt ReadBuffer union idea for read_fixed to support fixed read and readv

Use same idea and create a WriteBuffer type for write() and write_fixed()

ignored flags for splice and tee lets see if they become important in
the future

add a get_data helper to Cqe

Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-11-21 12:44:57 +00:00
Bernard Assan
70ee443ae7
Remove unnecessary null to optional anyopaque coercion
Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-11-21 12:44:57 +00:00
Bernard Assan
df65a82650
Implement more IoUring register functions
Future enhancement:
enter_ring_fd: u24,
init_flags: u8,

register functions that require the extra fields above like
io_uring_register_ring_fd, io_uring_close_ring_fd,
io_uring_clone_buffers_offset, io_uring_set_iowait not implemented

register_*_tag functions not implemented

remove unnecessary use of @ptrCast in io_uring_register

Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-11-21 12:44:55 +00:00
Bernard Assan
4ae77a12c5
Remove unnecessary use of @as coercion
update `cq_ring_needs_flush()` to match liburing

replace FilesUpdate with RsrcUpdate struct
Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-11-21 12:42:16 +00:00
Bernard Assan
1970dbbe8a
Add and improve comments
Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-11-21 12:41:15 +00:00
Bernard Assan
d3457bb4ca
replace direct set of some flags with link_next and set_flags calls
Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-11-21 12:41:14 +00:00
Bernard Assan
f5598cb8f5
Use lower case identifiers for IoUring flags and enums
update io_uring_enter and io_uring_register syscalls to
use IoUring flags and types

Cleanup comments

Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-11-21 12:41:12 +00:00
Bernard Assan
a0d1867a2f
Replace EPOLL struct with an EpollOp enum and Epoll packed struct type
Prefer Using aliases over packed union field

Fix bug in HANDLE_FID declaration

Use EpollOp op type and Epoll packed struct flag type in IoUring

Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-11-21 12:36:22 +00:00
Bernard Assan
298fdf1647
Add So and Sol typed flags
Replace SO with So type and Add SO named constants for compatability

Replace SOL with Sol type and Add SOL named constants for compatability

Replace some more typed flags with their typed equivalent

Remove any unnecessary IoUring dependency on linux.*

Add TODOs for all untyped flags

Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-11-21 12:36:22 +00:00
Bernard Assan
9692c2dc99
Get test passing for all the newly introduced flags
4❯ zig test lib/std/std.zig --zig-lib-dir lib --test-filter "os.linux"
68/116 os.linux.test.test.futex2_wait...SKIP
69/116 os.linux.test.test.futex2_wake...SKIP
70/116 os.linux.test.test.futex2_requeue...SKIP
111/116 os.linux.IoUring.test.waitid...SKIP
116/116 os.linux.IoUring.test.bind/listen/connect...SKIP
111 passed; 5 skipped; 0 failed.

fix skipKernelLessThan fn to work on wsl linux

fix logical error in flags compatibility check

Update all IoUring to use the implemented flags

bandage types that affect posix for now so that the scope
doesn't become unmanageable

TODO: impl linux.SOL and linux.SO types

Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-11-21 12:36:18 +00:00
Bernard Assan
5520354537
Replace MSG with Packed Struct Flags
Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-11-21 12:33:03 +00:00
Bernard Assan
20ceb21632
Restore deprecated contants using new Flag types
This allows for a gradual transitioning to the new typed flags

Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-11-21 12:33:03 +00:00
Bernard Assan
000761df30
update some syscall APIs to use the new flags
Add Shut, PF, AF, IPPROTO types

Update IoUring and test to use some of this flags

TODO: avoid breaking API and make transitioning smooth
Instead mark the previous API as deprecated for at least
One zig release while using the new in the Zig codebase

Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-11-21 12:33:01 +00:00
Bernard Assan
a80243f707
Replace AT,W,SHUT,SOCK with a packed struct Flag type
Use the new Flag types in IoUring

fix some test

Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-11-21 12:31:05 +00:00
Bernard Assan
80d09dd2fd
Improve organization of fn and structs in IoUring
Update std to use Statx.Mask
Update statx syscall to use Statx.Mask

Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-11-21 12:31:01 +00:00
Bernard Assan
371488f785
Replace STATX_* with StatxMask & StatxAttr
Add RenameFlags for IoUring renameat

Start update io_uring Types in linux.zig to use IoUring

Continue change options and flags to Typed types

Fix test cases to use updated IoUring flags and options

Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-11-21 12:28:41 +00:00
Bernard Assan
1bacc42144
move Flags that were mistakenly tagged as constants
Improve naming and namespacing of IoUring flags and types to
match Zig Style

move some flags from uflags to its type

Add matches doc comments to make it easy to match Zig IoUring types
to liburing

Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-11-21 12:26:33 +00:00
Bernard Assan
f24bdbbe93
replace some more fn flags with Typed Flags
and use linux Flags where appropriate

constants is a namespace

make AsyncCancel flags more descriptive

move cqe.flags into the Cqe type

make io_uring_sqe ioprio a packed union of SendRecv & Accept

TODO: move some of the used linux Flags to be packed structs

Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-11-21 12:26:33 +00:00
Bernard Assan
1463617ae8
IoUring: use typed Flags and Features for IoUring
IoUring Overhaul

Named Constants for IoUring

Move io_uring_sqe.zig into IoUring

Add new exposed IoUring data types

Improve naming and namespacing a bit

Improve api of init with Setup.Flags

 // https://github.com/axboe/liburing/issues/1075#issuecomment-1970744640
 // https://github.com/axboe/liburing/issues/811#issuecomment-1454967969
 // https://nick-black.com/dankwiki/index.php/Io_uring
Catch simple incompatible flag configurations during init_params

Start updating IoUring gradually to use the new typed flags

Slowly remove IoUring bits and pieces from linux.zig

Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-11-21 12:26:30 +00:00
rpkak
6b4f45f782 system specific errno 2025-11-20 15:03:23 -08:00
Alex Rønne Petersen
508f676bb4
std.os.linux.IoUring: disable bind/listen/connect on s390x
https://github.com/ziglang/zig/issues/25956
2025-11-19 01:42:45 +01:00
John Benediktsson
74c23a237e
Merge pull request #25763 from mrjbq7/cancelled
rename Cancelled to Canceled
2025-10-30 04:40:13 +00:00
Andrew Kelley
0205ce4736 std.os.linux.IoUring: disable failing test
tracked by https://github.com/ziglang/zig/issues/25734
2025-10-29 06:26:05 -07:00
Andrew Kelley
c87fbd5878 std.os.linux.IoUring: use linux msghdr
it disagrees with posix msghdr
2025-10-29 06:20:51 -07:00
Andrew Kelley
750b1431bf std: fix some Io compilation errors 2025-10-29 06:20:49 -07:00
Andrew Kelley
47aa5a70a5 std: updating to std.Io interface
got the build runner compiling
2025-10-29 06:20:48 -07:00
Özgür Akkurt
99c4890559
implement registering NAPI on IoUring (#24850) 2025-08-16 09:18:49 +02:00
Seiichi Uchida
bbc21393b4 Add register_file_alloc_range 2025-05-06 18:01:07 +02:00
Igor Anić
94b36dbe50 io_uring: refactor buf_reg flags
Use packed struct instead of or-ed integers.

Thanks to @linsug for pr comments: https://github.com/ziglang/zig/pull/23062
2025-03-05 13:35:52 +01:00
Igor Anić
c133171567 io_uring: incremental provided buffer consumption
[Incremental provided buffer
consumption](https://github.com/axboe/liburing/wiki/What's-new-with-io_uring-in-6.11-and-6.12#incremental-provided-buffer-consumption)
support is added in kernel 6.12.

IoUring.BufferGroup will now use incremental consumption whenever
kernel supports it.

Before, provided buffers are wholly consumed when picked. Each cqe
points to the different buffer. With this, cqe points to the part of the
buffer. Multiple cqe's can reuse same buffer.
Appropriate sizing of buffers becomes less important.

There are slight changes in BufferGroup interface (it now needs to track
current receive point for each buffer). Init requires allocator
instead of buffers slice, it will allocate buffers slice and head
pointers slice. Get and put now requires cqe becasue there we have
information will the buffer be reused.
2025-03-05 13:35:52 +01:00
Igor Anić
4df039d235 io_uring: add setsockopt/getsockopt
ring.cmd_sock is generic socket operation. Two most common uses are
setsockopt and getsockopt. This provides same interface as posix
versions of this methods.

libring has also [sqe_set_flags](https://man7.org/linux/man-pages/man3/io_uring_sqe_set_flags.3.html)
method. Adding that in our io_uring_sqe. Adding sqe.link_next method for setting most common flag.
2025-03-05 13:35:52 +01:00
Igor Anić
d98c0893b0 io_uring: probe capabilities function
ring.get_probe returns io_uring_probe which can be use to probe
capabilities of the current running kernel.

Ref:
https://unixism.net/loti/ref-liburing/supported_caps.html
e1003e496e/src/setup.c (L454)
2025-03-05 13:35:52 +01:00
Igor Anić
85e2074878 io_uring: fix tests on 5.4.0 kernel
Found it failing in a new way on that kernel.
2025-03-05 13:35:52 +01:00
Igor Anić
2da8eff9d6 io_uring: add bind and listen 2025-03-05 13:35:52 +01:00
nikneym
408c817e1e linux/IoUring: add register_files_sparse 2025-02-11 13:19:05 +03:00
Andrew Kelley
284de7d957 adjust runtime page size APIs
* fix merge conflicts
* rename the declarations
* reword documentation
* extract FixedBufferAllocator to separate file
* take advantage of locals
* remove the assertion about max alignment in Allocator API, leaving it
  Allocator implementation defined
* fix non-inline function call in start logic

The GeneralPurposeAllocator implementation is totally broken because it
uses global state but I didn't address that in this commit.
2025-02-06 14:23:23 -08:00
Archbirdplus
439667be04 runtime page size detection
heap.zig: define new default page sizes
heap.zig: add min/max_page_size and their options
lib/std/c: add miscellaneous declarations
heap.zig: add pageSize() and its options
switch to new page sizes, especially in GPA/stdlib
mem.zig: remove page_size
2025-02-06 14:23:23 -08:00
Jean-Baptiste "Jiboo" Lepesme
901f344be2 IoUring: fix an issue in tests where InvalidVersion might get thrown by skipKernelLessThan, due to some kernel versions not being SemVer compliant. 2024-10-11 17:07:34 +02:00
Andrew Kelley
33c7984183 add std.testing.random_seed
closes #17609
2024-07-23 11:43:12 -07:00