mirror of
https://github.com/ziglang/zig.git
synced 2026-01-02 11:33:21 +00:00
wasi: implement getRandomBytes
This commit is contained in:
parent
79a139ac63
commit
1fabd6bbf3
@ -146,6 +146,12 @@ pub fn getRandomBytes(buf: []u8) !void {
|
||||
};
|
||||
}
|
||||
},
|
||||
Os.wasi => {
|
||||
const random_get_result = os.wasi.random_get(buf.ptr, buf.len);
|
||||
if (random_get_result != os.wasi.ESUCCESS) {
|
||||
return error.Unknown;
|
||||
}
|
||||
},
|
||||
Os.zen => {
|
||||
const randomness = []u8{ 42, 1, 7, 12, 22, 17, 99, 16, 26, 87, 41, 45 };
|
||||
var i: usize = 0;
|
||||
|
||||
@ -20,3 +20,5 @@ pub extern "wasi_unstable" fn proc_raise(sig: signal_t) errno_t;
|
||||
pub extern "wasi_unstable" fn proc_exit(rval: exitcode_t) noreturn;
|
||||
|
||||
pub extern "wasi_unstable" fn fd_write(fd: fd_t, iovs: *const ciovec_t, iovs_len: usize, nwritten: *usize) errno_t;
|
||||
|
||||
pub extern "wasi_unstable" fn random_get(buf: [*]u8, buf_len: usize) errno_t;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user