Skip to content

Commit

Permalink
std.c: adding mincore for freebsd
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen authored and andrewrk committed Apr 25, 2023
1 parent f780a6b commit 8d88dcd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/std/c/freebsd.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2273,3 +2273,21 @@ pub const sigevent = extern struct {
__spare__: [8]c_long,
},
};

pub const MIN = struct {
pub const INCORE = 0x1;
pub const REFERENCED = 0x2;
pub const MODIFIED = 0x4;
pub const REFERENCED_OTHER = 0x8;
pub const MODIFIED_OTHER = 0x10;
pub const SUPER = 0x60;
pub fn PSIND(i: u32) u32 {
return (i << 5) & SUPER;
}
};

pub extern "c" fn mincore(
addr: *align(std.mem.page_size) const anyopaque,
length: usize,
vec: [*]u8,
) c_int;

1 comment on commit 8d88dcd

@devnexen
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Implemented only to address the os.mincore wrapper.
  • Tested with the following
    `const std = @import("std");
    const os = std.os;

pub fn main() !void {
var p: [std.mem.page_size]u8 = undefined;
var pg = try os.mmap(null, std.mem.page_size, os.PROT.READ | os.PROT.WRITE, os.MAP.PRIVATE | os.MAP.ANONYMOUS, -1, 0);
defer os.munmap(pg);
try os.mincore(pg.ptr, std.mem.page_size / 2, &p);
}`

Please sign in to comment.