Skip to content

Commit 4236ca4

Browse files
authored
Merge pull request #24561 from linusg/serenity-fixes
Small fixes for SerenityOS
2 parents 5fb36d2 + bf4fda4 commit 4236ca4

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

lib/std/c.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7147,7 +7147,7 @@ pub const dirent = switch (native_os) {
71477147
off: off_t,
71487148
reclen: c_ushort,
71497149
type: u8,
7150-
name: [256:0]u8,
7150+
name: [255:0]u8,
71517151
},
71527152
else => void,
71537153
};

lib/std/posix.zig

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,27 @@ pub const iovec_const = extern struct {
192192
len: usize,
193193
};
194194

195-
pub const ACCMODE = enum(u2) {
196-
RDONLY = 0,
197-
WRONLY = 1,
198-
RDWR = 2,
195+
pub const ACCMODE = switch (native_os) {
196+
// POSIX has a note about the access mode values:
197+
//
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+
},
199216
};
200217

201218
pub const TCSA = enum(c_uint) {

src/target.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,8 @@ pub fn libcFullLinkFlags(target: *const std.Target) []const []const u8 {
414414
.android, .androideabi, .ohos, .ohoseabi => &.{ "-lm", "-lc", "-ldl" },
415415
else => &.{ "-lm", "-lpthread", "-lc", "-ldl", "-lrt", "-lutil" },
416416
},
417+
// On SerenityOS libc includes libm, libpthread, libdl, and libssp.
418+
.serenity => &.{"-lc"},
417419
else => &.{},
418420
};
419421
return result;

0 commit comments

Comments
 (0)