Commit 69553d60da

Michael Dusan <michael.dusan@gmail.com>
2023-01-03 01:18:33
dragonfly: add `std.c.arc4random_buf`
This allows for a more optimal std.crypto.tlcsprng codepath. Without it a an "incorrect alignment" panic is triggered from crypto.tlcsprng which aligns a threadlocal but it's actually not aligned, thus detected by the safety check. It appears that LLVM-IR does attribute the storage with alignment but it is ultimately not respected in the final binary for netbsd and dragonfly.
1 parent ef08894
Changed files (1)
lib
lib/std/c/dragonfly.zig
@@ -12,6 +12,7 @@ pub extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) usize;
 pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int;
 pub extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) isize;
 pub extern "c" fn pipe2(fds: *[2]fd_t, flags: u32) c_int;
+pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void;
 
 pub const dl_iterate_phdr_callback = *const fn (info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.C) c_int;
 pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*anyopaque) c_int;