authorgravatar for mail@linusgroh.deLinus Groh <mail@linusgroh.de> 2025-07-24 00:25:39+01:00
committergravatar for mail@linusgroh.deLinus Groh <mail@linusgroh.de> 2025-07-24 00:54:40+01:00
log26bd74e87f97262f4f7ceaa5a383851d5e0878e0
treeda10b970b0fd1156853dde921f041d4ac9bfbd1b
parentea90ec4d8861427b3bca8b230ec04920a1242443

std.posix: Fix ACCMODE values for serenity


1 files changed, 21 insertions(+), 4 deletions(-)

lib/std/posix.zig+21-4
...@@ -192,10 +192,27 @@ pub const iovec_const = extern struct {...@@ -192,10 +192,27 @@ pub const iovec_const = extern struct {
192 len: usize,192 len: usize,
193};193};
194194
195pub const ACCMODE = enum(u2) {195pub const ACCMODE = switch (native_os) {
196 RDONLY = 0,196 // POSIX has a note about the access mode values:
197 WRONLY = 1,197 //
198 RDWR = 2,198 // In historical implementations the value of O_RDONLY is zero. Because of
199 // that, it is not possible to detect the presence of O_RDONLY and another
200 // option. Future implementations should encode O_RDONLY and O_WRONLY as
201 // bit flags so that: O_RDONLY | O_WRONLY == O_RDWR
202 //
203 // In practice SerenityOS is the only system supported by Zig that
204 // implements this suggestion.
205 // https://github.com/SerenityOS/serenity/blob/4adc51fdf6af7d50679c48b39362e062f5a3b2cb/Kernel/API/POSIX/fcntl.h#L28-L30
206 .serenity => enum(u2) {
207 RDONLY = 1,
208 WRONLY = 2,
209 RDWR = 3,
210 },
211 else => enum(u2) {
212 RDONLY = 0,
213 WRONLY = 1,
214 RDWR = 2,
215 },
199};216};
200217
201pub const TCSA = enum(c_uint) {218pub const TCSA = enum(c_uint) {