| ... | ... | @@ -2749,6 +2749,7 @@ pub const libc = struct { |
| 2749 | 2749 | pub extern fn sendfile(out_fd: c_int, in_fd: c_int, offset: ?*const off_t, count: usize) isize; |
| 2750 | 2750 | pub extern fn getdents(dirfd: c_int, buf: [*]u8, nbytes: usize) c_int; |
| 2751 | 2751 | pub extern fn sched_getaffinity(pid: pid_t, cpusetsize: usize, mask: *cpu_set_t) c_int; |
| 2752 | pub extern fn getrandom(buf: [*]u8, size: usize, flags: c_uint) isize; |
| 2752 | 2753 | }; |
| 2753 | 2754 | |
| 2754 | 2755 | pub const clock_t = c_long; |
| ... | ... | @@ -3199,6 +3200,12 @@ pub const DT = enum(u8) { |
| 3199 | 3200 | WHT = 14, |
| 3200 | 3201 | }; |
| 3201 | 3202 | |
| 3203 | pub const GRND = struct { |
| 3204 | pub const NONBLOCK = 0x0001; |
| 3205 | pub const RANDOM = 0x0002; |
| 3206 | pub const INSECURE = 0x0004; |
| 3207 | }; |
| 3208 | |
| 3202 | 3209 | pub fn getpid() pid_t { |
| 3203 | 3210 | return libc.getpid(); |
| 3204 | 3211 | } |
| ... | ... | @@ -3486,3 +3493,9 @@ pub fn mkdtemp(template: [*:0]u8) ![*:0]u8 { |
| 3486 | 3493 | if (rc == null) return errno.fromInt(errno.fromLibC()); |
| 3487 | 3494 | return rc.?; |
| 3488 | 3495 | } |
| 3496 | pub fn getrandom(buf: []u8, flags: c_uint) ![]u8 { |
| 3497 | const rc = libc.getrandom(buf.ptr, buf.len, flags); |
| 3498 | if (rc == -1) return errno.fromInt(errno.fromLibC()); |
| 3499 | std.debug.assert(rc >= 0); |
| 3500 | return buf[0..@intCast(rc)]; |
| 3501 | } |