Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
2cf23c9
IoUring: use typed Flags and Features for IoUring
bernardassan Sep 28, 2025
3d67bfd
replace some more fn flags with Typed Flags
bernardassan Sep 29, 2025
2bd223b
move Flags that were mistakenly tagged as constants
bernardassan Sep 30, 2025
1d374e0
Replace STATX_* with StatxMask & StatxAttr
bernardassan Sep 30, 2025
45f924f
Improve organization of fn and structs in IoUring
bernardassan Oct 1, 2025
79475dc
Replace AT,W,SHUT,SOCK with a packed struct Flag type
bernardassan Oct 1, 2025
18bcf8e
update some syscall APIs to use the new flags
bernardassan Oct 2, 2025
25850b9
Restore deprecated contants using new Flag types
bernardassan Oct 5, 2025
8a443a2
Replace MSG with Packed Struct Flags
bernardassan Oct 6, 2025
922bd94
Get test passing for all the newly introduced flags
bernardassan Oct 7, 2025
864316a
Add So and Sol typed flags
bernardassan Oct 9, 2025
efbd148
Replace EPOLL struct with an EpollOp enum and Epoll packed struct type
bernardassan Oct 9, 2025
eba509d
fix error of setting some fields in Epoll to true by default
bernardassan Oct 10, 2025
d814926
Remove io_uring_sqe.zig from CMakeLists
bernardassan Oct 10, 2025
c17b67d
Use lower case identifiers for IoUring flags and enums
bernardassan Oct 10, 2025
9465385
replace direct set of some flags with link_next and set_flags calls
bernardassan Oct 10, 2025
0d16810
Remove io_uring bit and pieces from linux.zig
bernardassan Oct 11, 2025
e514091
Fix posix.W in process/Child.zig
bernardassan Oct 11, 2025
fc7385e
Add mips defination for Epoll
bernardassan Oct 12, 2025
96f295a
Add and improve comments
bernardassan Oct 12, 2025
2a8565b
Remove unnecessary use of @as coercion
bernardassan Oct 12, 2025
9f1db4e
Implement more IoUring register functions
bernardassan Oct 12, 2025
ba34ff2
Remove unnecessary null to optional anyopaque coercion
bernardassan Oct 12, 2025
42a13cf
Move buf_ring_* functions into BufferRing type as methods
bernardassan Oct 13, 2025
5ceaa00
Implement some more IoUring operations
bernardassan Oct 14, 2025
e856ced
add IoUring send_bundle, send_to, recv_multishot, sync_file_range
bernardassan Oct 15, 2025
4f05fd4
add msg_ring_*, setxattr and getxattr IoUring operations
bernardassan Oct 17, 2025
f04aa8f
IoUring: Implement set_iowait functionality
bernardassan Oct 17, 2025
f9b1a1a
Add XattrSource to decide how to prepare set/getxattr operations
bernardassan Oct 18, 2025
dd43389
IoUring: futex operations
bernardassan Oct 19, 2025
c6b3844
Add a Futex2 `Bitset` type for futex2 wake and wait syscalls
bernardassan Oct 21, 2025
7a3cd45
IoUring: Working on Pipe2 flags
bernardassan Oct 23, 2025
c036f68
IoUring: implement pipe and pipe_direct operations
bernardassan Oct 23, 2025
aea148c
Merge archs that have the same Pipe2 flags
bernardassan Oct 24, 2025
f4b1bde
Use linux types directly since IoUring is only supported on linux
bernardassan Oct 24, 2025
729c555
IoUring: implement outstanding flags and enumerations
bernardassan Oct 24, 2025
267ed9e
IoUring: use the splice flags type for splice and tee
bernardassan Oct 25, 2025
8f6f969
IoUring: fix and remove TODOs
bernardassan Oct 25, 2025
23a4561
IoUring: Fix merge conflicts
bernardassan Nov 3, 2025
cc474ab
Fix `At` flags for real
bernardassan Nov 14, 2025
1240ace
Implement W as packed struct in `c.zig`
bernardassan Nov 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,6 @@ set(ZIG_STAGE2_SOURCES
lib/std/os/linux.zig
lib/std/os/linux.zig
lib/std/os/linux/IoUring.zig
lib/std/os/linux/io_uring_sqe.zig
lib/std/os/linux/x86_64.zig
lib/std/os/linux/x86_64.zig
lib/std/os/windows.zig
Expand Down
2 changes: 1 addition & 1 deletion lib/std/Io/Dir.zig
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub fn cwd() Dir {
return switch (native_os) {
.windows => .{ .handle = std.os.windows.peb().ProcessParameters.CurrentDirectory.Handle },
.wasi => .{ .handle = std.options.wasiCwd() },
else => .{ .handle = std.posix.AT.FDCWD },
else => .{ .handle = std.posix.At.fdcwd },
};
}

Expand Down
37 changes: 26 additions & 11 deletions lib/std/Io/Threaded.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1353,8 +1353,7 @@ fn dirStatPathLinux(
var path_buffer: [posix.PATH_MAX]u8 = undefined;
const sub_path_posix = try pathToPosix(sub_path, &path_buffer);

const flags: u32 = linux.AT.NO_AUTOMOUNT |
@as(u32, if (!options.follow_symlinks) linux.AT.SYMLINK_NOFOLLOW else 0);
const flags: linux.At = .{ .no_automount = true, .symlink_nofollow = if (!options.follow_symlinks) true else false };

while (true) {
try t.checkCancel();
Expand All @@ -1363,7 +1362,15 @@ fn dirStatPathLinux(
dir.handle,
sub_path_posix,
flags,
linux.STATX_INO | linux.STATX_SIZE | linux.STATX_TYPE | linux.STATX_MODE | linux.STATX_ATIME | linux.STATX_MTIME | linux.STATX_CTIME,
.{
.ino = true,
.size = true,
.type = true,
.mode = true,
.atime = true,
.mtime = true,
.ctime = true,
},
&statx,
);
switch (linux.errno(rc)) {
Expand Down Expand Up @@ -1396,12 +1403,12 @@ fn dirStatPathPosix(
var path_buffer: [posix.PATH_MAX]u8 = undefined;
const sub_path_posix = try pathToPosix(sub_path, &path_buffer);

const flags: u32 = if (!options.follow_symlinks) posix.AT.SYMLINK_NOFOLLOW else 0;
const flags: posix.At = .{ .symlink_nofollow = if (!options.follow_symlinks) true else false };

while (true) {
try t.checkCancel();
var stat = std.mem.zeroes(posix.Stat);
switch (posix.errno(fstatat_sym(dir.handle, sub_path_posix, &stat, flags))) {
switch (posix.errno(fstatat_sym(dir.handle, sub_path_posix, &stat, @bitCast(flags)))) {
.SUCCESS => return statFromPosix(&stat),
.INTR => continue,
.CANCELED => return error.Canceled,
Expand Down Expand Up @@ -1509,8 +1516,16 @@ fn fileStatLinux(userdata: ?*anyopaque, file: Io.File) Io.File.StatError!Io.File
const rc = linux.statx(
file.handle,
"",
linux.AT.EMPTY_PATH,
linux.STATX_INO | linux.STATX_SIZE | linux.STATX_TYPE | linux.STATX_MODE | linux.STATX_ATIME | linux.STATX_MTIME | linux.STATX_CTIME,
.{ .empty_path = true },
.{
.ino = true,
.size = true,
.type = true,
.mode = true,
.atime = true,
.mtime = true,
.ctime = true,
},
&statx,
);
switch (linux.errno(rc)) {
Expand Down Expand Up @@ -1617,7 +1632,7 @@ fn dirAccessPosix(
var path_buffer: [posix.PATH_MAX]u8 = undefined;
const sub_path_posix = try pathToPosix(sub_path, &path_buffer);

const flags: u32 = @as(u32, if (!options.follow_symlinks) posix.AT.SYMLINK_NOFOLLOW else 0);
const flags: posix.At = .{ .symlink_nofollow = if (!options.follow_symlinks) true else false };

const mode: u32 =
@as(u32, if (options.read) posix.R_OK else 0) |
Expand All @@ -1626,7 +1641,7 @@ fn dirAccessPosix(

while (true) {
try t.checkCancel();
switch (posix.errno(posix.system.faccessat(dir.handle, sub_path_posix, mode, flags))) {
switch (posix.errno(posix.system.faccessat(dir.handle, sub_path_posix, mode, @bitCast(flags)))) {
.SUCCESS => return,
.INTR => continue,
.CANCELED => return error.Canceled,
Expand Down Expand Up @@ -2886,7 +2901,7 @@ fn fileSeekTo(userdata: ?*anyopaque, file: Io.File, offset: u64) Io.File.SeekErr
fn openSelfExe(userdata: ?*anyopaque, flags: Io.File.OpenFlags) Io.File.OpenSelfExeError!Io.File {
const t: *Threaded = @ptrCast(@alignCast(userdata));
switch (native_os) {
.linux, .serenity => return dirOpenFilePosix(t, .{ .handle = posix.AT.FDCWD }, "/proc/self/exe", flags),
.linux, .serenity => return dirOpenFilePosix(t, .{ .handle = posix.At.fdcwd }, "/proc/self/exe", flags),
.windows => {
// If ImagePathName is a symlink, then it will contain the path of the symlink,
// not the path that the symlink points to. However, because we are opening
Expand Down Expand Up @@ -5941,7 +5956,7 @@ pub fn futexWake(ptr: *const std.atomic.Value(u32), max_waiters: u32) void {
.linux => {
const linux = std.os.linux;
switch (linux.errno(linux.futex_3arg(
&ptr.raw,
ptr,
.{ .cmd = .WAKE, .private = true },
@min(max_waiters, std.math.maxInt(i32)),
))) {
Expand Down
6 changes: 3 additions & 3 deletions lib/std/Thread.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1217,8 +1217,8 @@ const LinuxThreadImpl = struct {
thread: *ThreadCompletion,

const ThreadCompletion = struct {
completion: Completion = Completion.init(.running),
child_tid: std.atomic.Value(i32) = std.atomic.Value(i32).init(1),
completion: Completion = .init(.running),
child_tid: std.atomic.Value(i32) = .init(1),
parent_tid: i32 = undefined,
mapped: []align(std.heap.page_size_min) u8,

Expand Down Expand Up @@ -1663,7 +1663,7 @@ const LinuxThreadImpl = struct {
if (tid == 0) break;

switch (linux.errno(linux.futex_4arg(
&self.thread.child_tid.raw,
@ptrCast(&self.thread.child_tid),
.{ .cmd = .WAIT, .private = false },
@bitCast(tid),
null,
Expand Down
4 changes: 2 additions & 2 deletions lib/std/Thread/Futex.zig
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ const LinuxImpl = struct {
}

const rc = linux.futex_4arg(
&ptr.raw,
ptr,
.{ .cmd = .WAIT, .private = true },
expect,
if (timeout != null) &ts else null,
Expand All @@ -285,7 +285,7 @@ const LinuxImpl = struct {

fn wake(ptr: *const atomic.Value(u32), max_waiters: u32) void {
const rc = linux.futex_3arg(
&ptr.raw,
ptr,
.{ .cmd = .WAKE, .private = true },
@min(max_waiters, std.math.maxInt(i32)),
);
Expand Down
Loading