Commit graph

531 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
be63611c64
Add a Futex2 Bitset type for futex2 wake and wait syscalls
Cleanup linux/test.zig

type futex/2_* uaddr as *const u32
consider changing to *const atomic.Value(u32)

Use At Flags in fstatat

Use EpollOp in epoll_ctl syscall

Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2025-12-01 12:15:59 +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
Alex Rønne Petersen
1231aa9719
Revert "std.os.linux.sparc64: use icc instead of xcc in asm clobbers"
This reverts commit b34a13da38.

This is not the right fix; rather, the C backend needs to translate all of ccr,
icc, and xcc to just icc.
2025-11-23 07:27:45 +01: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
a072d821be
Merge pull request #25592 from ziglang/init-std.Io
std: Introduce `Io` Interface
2025-10-29 13:51:37 -07:00
Alex Rønne Petersen
b2bc44e0d5
std.os.linux: fix restore for powerpc/powerpc64
sigreturn and rt_sigreturn are distinct syscalls on PowerPC.
2025-10-29 20:44:43 +01: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
b1d270d38e std.os.linux.s390x: fix restore function 2025-10-29 06:20:52 -07:00
Andrew Kelley
1553c8eae7 std.os.linux.x86: fix signal restore function
After handling any signal on x86, it would previously segfault.
2025-10-29 06:20:52 -07:00
Andrew Kelley
8b269f7e18 std: make signal numbers into an enum
fixes start logic for checking whether IO/POLL exist
2025-10-29 06:20:51 -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
Alex Rønne Petersen
f723d69a58
std.os.linux.tls: add hppa support
Turns out Linux on PA-RISC does system calls in a pretty fascinating way; see
arch/parisc/kernel/syscall.S for details.
2025-10-23 09:27:17 +02:00
Alex Rønne Petersen
aff557e4e8
std.os.linux.tls: add sh support 2025-10-23 09:27:17 +02:00
Alex Rønne Petersen
5e921261a0
std.os.linux.tls: add microblaze support
Implemented according to glibc because I'm pretty sure musl gets it wrong.
2025-10-23 09:27:17 +02:00
Alex Rønne Petersen
9fde44229c
std.os.linux.tls: add alpha support 2025-10-23 09:27:17 +02:00
Alex Rønne Petersen
3e2daa509a
std.Target: add arceb and xtensaeb Cpu.Arch tags 2025-10-23 09:27:17 +02:00
Alex Rønne Petersen
c571840e71
std.os.linux: add or1k arch bits 2025-10-18 22:27:35 +02:00
Alex Rønne Petersen
35e819aac8
std.os.linux.tls: implement or1k support 2025-10-18 22:27:35 +02:00
Alex Rønne Petersen
3585f79f44
std.os.linux: remove syscall7() on mips64/mipsn32
I'm not sure why this was here, but this is only a thing on O32, not N32/N64.
2025-10-18 14:01:41 +02:00
Alex Rønne Petersen
842de66db8
std.os.linux: fix some issues in x32 inline asm
ref https://github.com/ziglang/zig/issues/22189
2025-10-18 11:16:31 +02:00
Alex Rønne Petersen
f3eacec226
std.os.linux: fix some issues in mipsn32 inline asm
ref https://github.com/ziglang/zig/issues/22189
2025-10-18 11:16:31 +02:00