| author | |
| committer | |
| log | 1811e7e6c96844a8381e6a69017948cae0b8b261 |
| tree | 4ba5e387f6cc16403a7848d73197c21463601877 |
| parent | 11ced4f99d95ec144d9dbb79ead335b571f714fe |
The system call getrandom(2) just landed on FreeBSD 12, so if we want to
support some earlier version or at least FreeBSD 11, we can't depend on
the system call.3 files changed, 2 insertions(+), 7 deletions(-)
std/c/freebsd.zig-1| ... | ... | @@ -15,7 +15,6 @@ pub extern "c" fn sysctlbyname(name: [*]const u8, oldp: ?*c_void, oldlenp: ?*usi |
| 15 | 15 | pub extern "c" fn sysctlnametomib(name: [*]const u8, mibp: ?*c_int, sizep: ?*usize) c_int; |
| 16 | 16 | pub extern "c" fn getdirentries(fd: c_int, buf_ptr: [*]u8, nbytes: usize, basep: *i64) usize; |
| 17 | 17 | pub extern "c" fn pipe2(arg0: *[2]c_int, arg1: u32) c_int; |
| 18 | pub extern "c" fn getrandom(buf: [*]u8, count: usize, flags: u32) c_int; | |
| 19 | 18 | |
| 20 | 19 | /// Renamed from `kevent` to `Kevent` to avoid conflict with function name. |
| 21 | 20 | pub const Kevent = extern struct { |
std/os/freebsd/index.zig-4| ... | ... | @@ -672,10 +672,6 @@ pub fn exit(code: i32) noreturn { |
| 672 | 672 | c.exit(code); |
| 673 | 673 | } |
| 674 | 674 | |
| 675 | pub fn getrandom(buf: [*]u8, count: usize, flags: u32) usize { | |
| 676 | return errnoWrap(c.getrandom(buf, count, flags)); | |
| 677 | } | |
| 678 | ||
| 679 | 675 | pub fn kill(pid: i32, sig: i32) usize { |
| 680 | 676 | return arch.syscall2(SYS_kill, @bitCast(usize, isize(pid)), @bitCast(usize, isize(sig))); |
| 681 | 677 | } |
std/os/index.zig+2-2| ... | ... | @@ -103,7 +103,7 @@ const math = std.math; |
| 103 | 103 | /// library implementation. |
| 104 | 104 | pub fn getRandomBytes(buf: []u8) !void { |
| 105 | 105 | switch (builtin.os) { |
| 106 | Os.linux, Os.freebsd => while (true) { | |
| 106 | Os.linux => while (true) { | |
| 107 | 107 | // TODO check libc version and potentially call c.getrandom. |
| 108 | 108 | // See #397 |
| 109 | 109 | const errno = posix.getErrno(posix.getrandom(buf.ptr, buf.len, 0)); |
| ... | ... | @@ -116,7 +116,7 @@ pub fn getRandomBytes(buf: []u8) !void { |
| 116 | 116 | else => return unexpectedErrorPosix(errno), |
| 117 | 117 | } |
| 118 | 118 | }, |
| 119 | Os.macosx, Os.ios => return getRandomBytesDevURandom(buf), | |
| 119 | Os.macosx, Os.ios, Os.freebsd => return getRandomBytesDevURandom(buf), | |
| 120 | 120 | Os.windows => { |
| 121 | 121 | // Call RtlGenRandom() instead of CryptGetRandom() on Windows |
| 122 | 122 | // https://github.com/rust-lang-nursery/rand/issues/111 |