Skip to content

Commit 11c95a1

Browse files
committed
MemoryAccessor.zig: Make it build with 'other' target OS
Make the `have_msync` check depend directly on the presence of posix.system.msync (instead of indirectly via a list of systems that may or may not have msync). Add an explicit empty `msync` symbol in the default posix.system struct and in the Wasi system.
1 parent 812557b commit 11c95a1

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

lib/std/c.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9069,6 +9069,7 @@ pub const gettimeofday = switch (native_os) {
90699069

90709070
pub const msync = switch (native_os) {
90719071
.netbsd => private.__msync13,
9072+
.wasi => {},
90729073
else => private.msync,
90739074
};
90749075

lib/std/debug/MemoryAccessor.zig

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,6 @@ pub fn load(ma: *MemoryAccessor, comptime Type: type, address: usize) ?Type {
7878
}
7979

8080
pub fn isValidMemory(address: usize) bool {
81-
// We are unable to determine validity of memory for freestanding targets
82-
if (native_os == .freestanding or native_os == .uefi) return true;
83-
8481
const aligned_address = address & ~@as(usize, @intCast((page_size - 1)));
8582
if (aligned_address == 0) return false;
8683
const aligned_memory = @as([*]align(page_size) u8, @ptrFromInt(aligned_address))[0..page_size];
@@ -122,7 +119,4 @@ pub fn isValidMemory(address: usize) bool {
122119
}
123120
}
124121

125-
const have_msync = switch (native_os) {
126-
.wasi, .emscripten, .windows => false,
127-
else => true,
128-
};
122+
const have_msync = @TypeOf(posix.system.msync) != void;

lib/std/posix.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ else switch (native_os) {
5252
pub const fd_t = void;
5353
pub const uid_t = void;
5454
pub const gid_t = void;
55+
pub const msync = {};
5556
},
5657
};
5758

0 commit comments

Comments
 (0)