Commit graph

61 commits

Author SHA1 Message Date
Bernard Assan
ac53361721
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-12-01 12:16:00 +00:00
Bernard Assan
35bbe99cb2
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-12-01 12:15:59 +00:00
Bernard Assan
e21f9fb4c5
Add XattrSource to decide how to prepare set/getxattr operations
Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-12-01 12:15:59 +00:00
Bernard Assan
64ef55bbd8
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-12-01 12:15:59 +00:00
Bernard Assan
33460a78cf
add msg_ring_*, setxattr and getxattr IoUring operations
TODO: add SetXattr flags

Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-12-01 12:15:58 +00:00
Bernard Assan
f99459a53f
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-12-01 12:15:58 +00:00
Bernard Assan
4b0988f167
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-12-01 12:15:58 +00:00
Bernard Assan
40a691838c
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-12-01 12:15:58 +00:00
Bernard Assan
6f0bd2651d
Remove unnecessary null to optional anyopaque coercion
Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-12-01 12:15:58 +00:00
Bernard Assan
3c1ca128d2
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-12-01 12:15:57 +00:00
Bernard Assan
604cf4244e
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-12-01 12:15:57 +00:00
Bernard Assan
15534e190e
Add and improve comments
Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-12-01 12:15:57 +00:00
Bernard Assan
6f40669413
replace direct set of some flags with link_next and set_flags calls
Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-12-01 12:15:56 +00:00
Bernard Assan
a07abaa248
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-12-01 12:15:56 +00:00
Bernard Assan
2584301978
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-12-01 12:15:55 +00:00
Bernard Assan
9d460e7a78
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-12-01 12:15:55 +00:00
Bernard Assan
1ae677fda1
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-12-01 12:15:55 +00:00
Bernard Assan
0464bcc98d
Replace MSG with Packed Struct Flags
Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-12-01 12:15:55 +00:00
Bernard Assan
88fa1decbf
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-12-01 12:15:54 +00:00
Bernard Assan
b5dab22f26
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-12-01 12:15:54 +00:00
Bernard Assan
af2397777a
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-12-01 12:15:54 +00:00
Bernard Assan
86ed53e28f
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-12-01 12:15:54 +00:00
Bernard Assan
3e4f8ee485
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-12-01 12:15:54 +00:00
Bernard Assan
c20b2b91a9
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-12-01 12:15:53 +00:00
Bernard Assan
3b715fda9a
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-12-01 12:15:53 +00:00
Bernard Assan
c0a97b7d5f
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-12-01 12:15:53 +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
Andrew Kelley
e8c4e79499 std.c reorganization
It is now composed of these main sections:
* Declarations that are shared among all operating systems.
* Declarations that have the same name, but different type signatures
  depending on the operating system. Often multiple operating systems
  share the same type signatures however.
* Declarations that are specific to a single operating system.
  - These are imported one per line so you can see where they come from,
    protected by a comptime block to prevent accessing the wrong one.

Closes #19352 by changing the convention to making types `void` and
functions `{}`, so that it becomes possible to update `@hasDecl` sites
to use `@TypeOf(f) != void` or `T != void`. Happily, this ended up
removing some duplicate logic and update some bitrotted feature
detection checks.

A handful of types have been modified to gain namespacing and type
safety. This is a breaking change.

Oh, and the last usage of `usingnamespace` site is eliminated.
2024-07-19 00:30:32 -07:00
Jora Troosh
13070448f5
std: fix typos (#20560) 2024-07-09 14:25:42 -07:00
Igor Anić
b8890f8ee1 io_uring: don't assume completions order (2)
In my first [try](https://github.com/ziglang/zig/pull/20224) to fix
20212 I didn't reproduce bug on required kernel (6.9.2) and wrongly
concluded that first two completions have different order on newer
kernel.
On my current kernel (6.5.0) order of completions is: send1, recv,
send2. On 6.9.2 order is send1, send2, recv. This fix allows second two
completions to arrive in any order.
Tested on both kernels.

Fixes: #20212
2024-06-20 18:03:28 -04:00
Ryan Liptak
76fb2b685b std: Convert deprecated aliases to compile errors and fix usages
Deprecated aliases that are now compile errors:

- `std.fs.MAX_PATH_BYTES` (renamed to `std.fs.max_path_bytes`)
- `std.mem.tokenize` (split into `tokenizeAny`, `tokenizeSequence`, `tokenizeScalar`)
- `std.mem.split` (split into `splitSequence`, `splitAny`, `splitScalar`)
- `std.mem.splitBackwards` (split into `splitBackwardsSequence`, `splitBackwardsAny`, `splitBackwardsScalar`)
- `std.unicode`
  + `utf16leToUtf8Alloc`, `utf16leToUtf8AllocZ`, `utf16leToUtf8`, `fmtUtf16le` (all renamed to have capitalized `Le`)
  + `utf8ToUtf16LeWithNull` (renamed to `utf8ToUtf16LeAllocZ`)
- `std.zig.CrossTarget` (moved to `std.Target.Query`)

Deprecated `lib/std/std.zig` decls were deleted instead of made a `@compileError` because the `refAllDecls` in the test block would trigger the `@compileError`. The deleted top-level `std` namespaces are:

- `std.rand` (renamed to `std.Random`)
- `std.TailQueue` (renamed to `std.DoublyLinkedList`)
- `std.ChildProcess` (renamed/moved to `std.process.Child`)

This is not exhaustive. Deprecated aliases that I didn't touch:
  + `std.io.*`
  + `std.Build.*`
  + `std.builtin.Mode`
  + `std.zig.c_translation.CIntLiteralRadix`
  + anything in `src/`
2024-06-13 10:18:59 -04:00