zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit fbbdde41b42a3ecc3773217ae2cf4a9350d3dd00 (tree)
parent c94d926bba9344cfab9b00b2bb418ca0e7a32b51
Author: 孙冰 <sunb@qmrz.net>
Date:   Tue, 25 Mar 2025 10:30:39 +0800

std.c: android bionic C supports arc4random_buf and getentropy

1. https://android.googlesource.com/platform/bionic/+/refs/heads/main/libc/include/bits/getentropy.h
2. https://android.googlesource.com/platform/bionic/+/refs/heads/main/libc/include/stdlib.h

Diffstat:
Mlib/std/c.zig | 4+++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/std/c.zig b/lib/std/c.zig @@ -10196,10 +10196,12 @@ pub extern "c" fn sendfile64(out_fd: fd_t, in_fd: fd_t, offset: ?*i64, count: us pub extern "c" fn setrlimit64(resource: rlimit_resource, rlim: *const rlimit) c_int; pub const arc4random_buf = switch (native_os) { - .dragonfly, .netbsd, .freebsd, .solaris, .openbsd, .macos, .ios, .tvos, .watchos, .visionos, .serenity => private.arc4random_buf, + .linux => if (builtin.abi.isAndroid()) private.arc4random_buf else {}, + .dragonfly, .netbsd, .freebsd, .solaris, .openbsd, .macos, .ios, .tvos, .watchos, .visionos => private.arc4random_buf, else => {}, }; pub const getentropy = switch (native_os) { + .linux => if (builtin.abi.isAndroid() and versionCheck(.{ .major = 28, .minor = 0, .patch = 0 })) private.getentropy else {}, .emscripten => private.getentropy, else => {}, };