mirror of
https://github.com/ziglang/zig.git
synced 2025-01-10 12:11:33 +00:00
commit
66fec3a3d7
@ -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"),
|
||||
}
|
||||
}
|
||||
|
@ -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 ////
|
||||
|
@ -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;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user