const std = #import("std"); const FileDescriptor = s32; const ProcessId = s32; const MAP_FAILED = 0xffffffffffffffff; const MapFlags = struct(u32){ shared: bool, private: bool, reserved: u2 = 0, fixed: bool, reserved0: bool = 0, noreserve: bool, reserved1: u2 = 0, has_semaphore: bool, no_cache: bool, reserved2: u1 = 0, anonymous: bool, reserved3: u19 = 0, }; const ProtectionFlags = struct(u32) { read: bool, write: bool, execute: bool, }; const get_protection_flags = fn(flags: std.os.ProtectionFlags) ProtectionFlags { return ProtectionFlags{ .read = flags.read, .write = flags.write, .execute = flags.execute, }; } const get_map_flags = fn(flags: std.os.MapFlags) MapFlags{ return MapFlags{ .shared = false, .private = true, .fixed = false, .noreserve = false, .has_semaphore = false, .no_cache = false, .anonymous = true, }; } const write :: extern = fn (file_descriptor: FileDescriptor, bytes_ptr: [&]const u8, bytes_len: usize) ssize; const exit :: extern = fn (exit_code: s32) noreturn; const fork :: extern = fn () ProcessId; const mmap :: extern = fn (address: ?[&]const u8, length: usize, protection_flags: ProtectionFlags, map_flags: MapFlags, file_descriptor: FileDescriptor, offset: u64) usize; const munmap :: extern = fn (address: [&]const u8, length: usize) s32; const execve :: extern = fn(path: [&:0]const u8, argv: [&:null]const ?[&:0]const u8, env: [&:null]const ?[&:null]const u8) s32; const realpath :: extern = fn(path: [&:0]const u8, resolved_path: [&:0]u8) [&:0]u8; const waitpid :: extern = fn(pid: ProcessId, status: &s32, flags: s32) s32; const _NSGetExecutablePath :: extern = fn (buffer: [&:0]u8, buffer_size: &u32) s32;