| ... | @@ -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 | }; |
| 194 | | 194 | |
| 195 | pub const ACCMODE = enum(u2) { | 195 | pub 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 | }; |
| 200 | | 217 | |
| 201 | pub const TCSA = enum(c_uint) { | 218 | pub const TCSA = enum(c_uint) { |