Skip to content

Commit

Permalink
std add getrandom to solato solaris based systems
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen authored and Vexu committed Apr 14, 2023
1 parent 9adee80 commit 56d800f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/std/c/solaris.zig
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,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 pipe2(fds: *[2]fd_t, flags: u32) c_int;
pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void;
pub extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) isize;
pub extern "c" fn posix_memalign(memptr: *?*anyopaque, alignment: usize, size: usize) c_int;
pub extern "c" fn sysconf(sc: c_int) i64;
pub extern "c" fn signalfd(fd: fd_t, mask: *const sigset_t, flags: u32) c_int;
Expand Down

1 comment on commit 56d800f

@devnexen
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Here on solaris/illumos is useful as it is similar to Linux and BSD api/flags wise.
  • Could be useful then for the os wrapper.
  • Tested with the following
const std = @import("std");
const c = std.c;

pub fn main() !void {
    var b: [32]u8 = undefined;
    const w = c.getrandom(&b, 32, 0);
    std.debug.assert(w == 32);
}

Please sign in to comment.