From 69553d60daf1462079a8b5ff995014539c7ad32c Mon Sep 17 00:00:00 2001 From: Michael Dusan Date: Mon, 2 Jan 2023 19:18:33 -0500 Subject: [PATCH] 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. --- lib/std/c/dragonfly.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/std/c/dragonfly.zig b/lib/std/c/dragonfly.zig index bfe7806c14..26c0b34abe 100644 --- a/lib/std/c/dragonfly.zig +++ b/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;