diff --git a/std/os/index.zig b/std/os/index.zig index 7feaae0ff1..e472908c68 100644 --- a/std/os/index.zig +++ b/std/os/index.zig @@ -115,6 +115,14 @@ pub fn getRandomBytes(buf: []u8) !void { }; } }, + Os.zen => { + const randomness = []u8 {42, 1, 7, 12, 22, 17, 99, 16, 26, 87, 41, 45}; + var i: usize = 0; + while (i < buf.len) : (i += 1) { + if (i > randomness.len) return error.Unknown; + buf[i] = randomness[i]; + } + }, else => @compileError("Unsupported OS"), } } diff --git a/std/os/zen.zig b/std/os/zen.zig index 9e1944dc6d..51528ca391 100644 --- a/std/os/zen.zig +++ b/std/os/zen.zig @@ -107,14 +107,17 @@ pub fn write(fd: i32, buf: &const u8, count: usize) usize { /////////////////////////// pub const Syscall = enum(usize) { - exit = 0, - createPort = 1, - send = 2, - receive = 3, - subscribeIRQ = 4, - inb = 5, - map = 6, - createThread = 7, + exit = 0, + createPort = 1, + send = 2, + receive = 3, + subscribeIRQ = 4, + inb = 5, + map = 6, + createThread = 7, + createProcess = 8, + wait = 9, + portReady = 10, }; @@ -158,6 +161,17 @@ pub fn createThread(function: fn()void) u16 { return u16(syscall1(Syscall.createThread, @ptrToInt(function))); } +pub fn createProcess(elf_addr: usize) u16 { + return u16(syscall1(Syscall.createProcess, elf_addr)); +} + +pub fn wait(tid: u16) void { + _ = syscall1(Syscall.wait, tid); +} + +pub fn portReady(port: u16) bool { + return syscall1(Syscall.portReady, port) != 0; +} ///////////////////////// //// Syscall stubs //// diff --git a/std/special/bootstrap.zig b/std/special/bootstrap.zig index ad4d4891ed..d2c22c13e1 100644 --- a/std/special/bootstrap.zig +++ b/std/special/bootstrap.zig @@ -84,8 +84,10 @@ fn callMain() u8 { builtin.TypeId.ErrorUnion => { root.main() catch |err| { std.debug.warn("error: {}\n", @errorName(err)); - if (@errorReturnTrace()) |trace| { - std.debug.dumpStackTrace(trace); + if (builtin.os != builtin.Os.zen) { + if (@errorReturnTrace()) |trace| { + std.debug.dumpStackTrace(trace); + } } return 1; };