authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-10-13 20:45:29+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-10-22 22:15:31+02:00
log84745e1eb25c369611aaab9d9041e76b9e1613c4
treea22b6fa9094dc9454552aba338ae2b801834fd40
parent10ecbd71deaab97378b2aadd603abb2a4f233e2f
signature Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.c: fix mremap() signature for serenity


2 files changed, 10 insertions(+), 1 deletions(-)

lib/std/c.zig+5-1
......@@ -10905,7 +10905,10 @@ pub extern "c" fn write(fd: fd_t, buf: [*]const u8, nbyte: usize) isize;
1090510905pub extern "c" fn pwrite(fd: fd_t, buf: [*]const u8, nbyte: usize, offset: off_t) isize;
1090610906pub extern "c" fn mmap(addr: ?*align(page_size) anyopaque, len: usize, prot: PROT, flags: MAP, fd: fd_t, offset: off_t) *anyopaque;
1090710907pub extern "c" fn munmap(addr: *align(page_size) const anyopaque, len: usize) c_int;
10908pub extern "c" fn mremap(addr: ?*align(page_size) const anyopaque, old_len: usize, new_len: usize, flags: MREMAP, ...) *anyopaque;
10908pub const mremap = switch (native_os) {
10909 .serenity => serenity.mremap,
10910 else => private.mremap,
10911};
1090910912pub extern "c" fn mprotect(addr: *align(page_size) anyopaque, len: usize, prot: PROT) c_int;
1091010913pub extern "c" fn link(oldpath: [*:0]const u8, newpath: [*:0]const u8) c_int;
1091110914pub extern "c" fn linkat(oldfd: fd_t, oldpath: [*:0]const u8, newfd: fd_t, newpath: [*:0]const u8, flags: c_uint) c_int;
......@@ -11849,6 +11852,7 @@ const private = struct {
1184911852 extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int;
1185011853 extern "c" fn ioctl(fd: fd_t, request: c_int, ...) c_int;
1185111854 extern "c" fn msync(addr: *align(page_size) const anyopaque, len: usize, flags: c_int) c_int;
11855 extern "c" fn mremap(addr: ?*align(page_size) const anyopaque, old_len: usize, new_len: usize, flags: MREMAP, ...) *anyopaque;
1185211856 extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int;
1185311857 extern "c" fn pipe2(fds: *[2]fd_t, flags: O) c_int;
1185411858 extern "c" fn readdir(dir: *DIR) ?*dirent;
lib/std/c/serenity.zig+5
......@@ -1,10 +1,12 @@
11const std = @import("../std.zig");
22const assert = std.debug.assert;
33const builtin = @import("builtin");
4const MAP = std.c.MAP;
45const O = std.c.O;
56const clockid_t = std.c.clockid_t;
67const pid_t = std.c.pid_t;
78const timespec = std.c.timespec;
9const page_size = std.heap.page_size_min;
810
911comptime {
1012 assert(builtin.os.tag == .serenity); // Prevent access of std.c symbols on wrong OS.
......@@ -68,6 +70,9 @@ pub extern "c" fn anon_create(size: usize, options: O) c_int;
6870pub extern "c" fn getkeymap(name_buffer: [*]u8, name_buffer_size: usize, map: [*]u32, shift_map: [*]u32, alt_map: [*]u32, altgr_map: [*]u32, shift_altgr_map: [*]u32) c_int;
6971pub extern "c" fn setkeymap(name: [*]const u8, map: [*]const u32, shift_map: [*]const u32, alt_map: [*]const u32, altgr_map: [*]const u32, shift_altgr_map: [*]const u32) c_int;
7072
73// https://github.com/SerenityOS/serenity/blob/fe4f3879551f2fdd8a24de06b88f4450e2f3b93d/Userland/Libraries/LibC/sys/mman.h#L17
74pub extern "c" fn mremap(old_address: ?*align(page_size) anyopaque, old_size: usize, new_size: usize, flags: MAP) *anyopaque;
75
7176// https://github.com/SerenityOS/serenity/blob/5bd8af99be0bc4b2e14f361fd7d7590e6bcfa4d6/Kernel/API/POSIX/netinet/in.h#L29
7277pub const IP = struct {
7378 pub const TOS = 1;