diff options
| author | Linus Groh <mail@linusgroh.de> | 2025-07-24 00:25:39 +0100 |
|---|---|---|
| committer | Linus Groh <mail@linusgroh.de> | 2025-07-24 00:54:40 +0100 |
| commit | 26bd74e87f97262f4f7ceaa5a383851d5e0878e0 (patch) | |
| tree | da10b970b0fd1156853dde921f041d4ac9bfbd1b | |
| parent | ea90ec4d8861427b3bca8b230ec04920a1242443 (diff) | |
| download | zig-26bd74e87f97262f4f7ceaa5a383851d5e0878e0.tar.gz zig-26bd74e87f97262f4f7ceaa5a383851d5e0878e0.zip | |
std.posix: Fix ACCMODE values for serenity
| -rw-r--r-- | lib/std/posix.zig | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/lib/std/posix.zig b/lib/std/posix.zig index 3f654422b1..d8806fe40c 100644 --- a/lib/std/posix.zig +++ b/lib/std/posix.zig @@ -192,10 +192,27 @@ pub const iovec_const = extern struct { len: usize, }; -pub const ACCMODE = enum(u2) { - RDONLY = 0, - WRONLY = 1, - RDWR = 2, +pub const ACCMODE = switch (native_os) { + // POSIX has a note about the access mode values: + // + // In historical implementations the value of O_RDONLY is zero. Because of + // that, it is not possible to detect the presence of O_RDONLY and another + // option. Future implementations should encode O_RDONLY and O_WRONLY as + // bit flags so that: O_RDONLY | O_WRONLY == O_RDWR + // + // In practice SerenityOS is the only system supported by Zig that + // implements this suggestion. + // https://github.com/SerenityOS/serenity/blob/4adc51fdf6af7d50679c48b39362e062f5a3b2cb/Kernel/API/POSIX/fcntl.h#L28-L30 + .serenity => enum(u2) { + RDONLY = 1, + WRONLY = 2, + RDWR = 3, + }, + else => enum(u2) { + RDONLY = 0, + WRONLY = 1, + RDWR = 2, + }, }; pub const TCSA = enum(c_uint) { |
