aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2025-07-31 09:56:26 -0700
committerGitHub <noreply@github.com>2025-07-31 09:56:26 -0700
commit982c387753c33a9eb42349c109fc4a6ed0675165 (patch)
treed3314abedac7c83e2f2c0e932dba78b9284e1270
parent627a292a1139c96f5de80084ab5ce8b852db5132 (diff)
parentce776d32455f5ac43f91cc8904765836c00605cf (diff)
downloadzig-982c387753c33a9eb42349c109fc4a6ed0675165.tar.gz
zig-982c387753c33a9eb42349c109fc4a6ed0675165.zip
Merge pull request #24633 from linusg/more-serenity-fixes
std: A few more fixes for serenity
-rw-r--r--lib/std/Progress.zig1
-rw-r--r--lib/std/c.zig14
-rw-r--r--lib/std/heap.zig2
-rw-r--r--lib/std/posix.zig4
-rw-r--r--lib/std/start.zig1
5 files changed, 13 insertions, 9 deletions
diff --git a/lib/std/Progress.zig b/lib/std/Progress.zig
index 2806c1a09c..8b741187e7 100644
--- a/lib/std/Progress.zig
+++ b/lib/std/Progress.zig
@@ -1548,6 +1548,7 @@ const have_sigwinch = switch (builtin.os.tag) {
.visionos,
.dragonfly,
.freebsd,
+ .serenity,
=> true,
else => false,
diff --git a/lib/std/c.zig b/lib/std/c.zig
index 32f5fc1c3b..818a4ae0cc 100644
--- a/lib/std/c.zig
+++ b/lib/std/c.zig
@@ -4131,7 +4131,7 @@ pub const msghdr_const = switch (native_os) {
.serenity => extern struct {
name: ?*const anyopaque,
namelen: socklen_t,
- iov: [*]const iovec,
+ iov: [*]const iovec_const,
iovlen: c_uint,
control: ?*const anyopaque,
controllen: socklen_t,
@@ -8614,7 +8614,7 @@ pub const O = switch (native_os) {
},
// https://github.com/SerenityOS/serenity/blob/2808b0376406a40e31293bb3bcb9170374e90506/Kernel/API/POSIX/fcntl.h#L28-L43
.serenity => packed struct(c_int) {
- ACCMODE: std.posix.ACCMODE = .RDONLY,
+ ACCMODE: std.posix.ACCMODE = .NONE,
EXEC: bool = false,
CREAT: bool = false,
EXCL: bool = false,
@@ -8770,10 +8770,10 @@ pub const MAP = switch (native_os) {
},
// https://github.com/SerenityOS/serenity/blob/6d59d4d3d9e76e39112842ec487840828f1c9bfe/Kernel/API/POSIX/sys/mman.h#L16-L26
.serenity => packed struct(c_int) {
- FILE: bool = false,
- SHARED: bool = false,
- PRIVATE: bool = false,
- _3: u2 = 0,
+ TYPE: enum(u4) {
+ SHARED = 0x01,
+ PRIVATE = 0x02,
+ },
FIXED: bool = false,
ANONYMOUS: bool = false,
STACK: bool = false,
@@ -8781,7 +8781,7 @@ pub const MAP = switch (native_os) {
RANDOMIZED: bool = false,
PURGEABLE: bool = false,
FIXED_NOREPLACE: bool = false,
- _: std.meta.Int(.unsigned, @bitSizeOf(c_int) - 12) = 0,
+ _: std.meta.Int(.unsigned, @bitSizeOf(c_int) - 11) = 0,
},
else => void,
};
diff --git a/lib/std/heap.zig b/lib/std/heap.zig
index 51e4fe44a2..a39cf5e1cb 100644
--- a/lib/std/heap.zig
+++ b/lib/std/heap.zig
@@ -146,7 +146,7 @@ const CAllocator = struct {
else {};
pub const supports_posix_memalign = switch (builtin.os.tag) {
- .dragonfly, .netbsd, .freebsd, .solaris, .openbsd, .linux, .macos, .ios, .tvos, .watchos, .visionos => true,
+ .dragonfly, .netbsd, .freebsd, .solaris, .openbsd, .linux, .macos, .ios, .tvos, .watchos, .visionos, .serenity => true,
else => false,
};
diff --git a/lib/std/posix.zig b/lib/std/posix.zig
index 54c6470d2c..fefb57de1c 100644
--- a/lib/std/posix.zig
+++ b/lib/std/posix.zig
@@ -204,6 +204,7 @@ pub const ACCMODE = switch (native_os) {
// implements this suggestion.
// https://github.com/SerenityOS/serenity/blob/4adc51fdf6af7d50679c48b39362e062f5a3b2cb/Kernel/API/POSIX/fcntl.h#L28-L30
.serenity => enum(u2) {
+ NONE = 0,
RDONLY = 1,
WRONLY = 2,
RDWR = 3,
@@ -1128,8 +1129,9 @@ pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void {
/// * Windows
/// On these systems, the read races with concurrent writes to the same file descriptor.
pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) PReadError!usize {
+ // NOTE: serenity does not have preadv but it *does* have pwritev.
const have_pread_but_not_preadv = switch (native_os) {
- .windows, .macos, .ios, .watchos, .tvos, .visionos, .haiku => true,
+ .windows, .macos, .ios, .watchos, .tvos, .visionos, .haiku, .serenity => true,
else => false,
};
if (have_pread_but_not_preadv) {
diff --git a/lib/std/start.zig b/lib/std/start.zig
index f889885c84..30543ead8a 100644
--- a/lib/std/start.zig
+++ b/lib/std/start.zig
@@ -699,6 +699,7 @@ fn maybeIgnoreSigpipe() void {
.visionos,
.dragonfly,
.freebsd,
+ .serenity,
=> true,
else => false,