| ... | ... | @@ -2750,6 +2750,7 @@ pub const libc = struct { |
| 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 | 2752 | pub extern fn getrandom(buf: [*]u8, size: usize, flags: c_uint) isize; |
| 2753 | pub extern fn flock(fd: c_int, op: c_int) c_int; |
| 2753 | 2754 | }; |
| 2754 | 2755 | |
| 2755 | 2756 | pub const clock_t = c_long; |
| ... | ... | @@ -3206,6 +3207,13 @@ pub const GRND = struct { |
| 3206 | 3207 | pub const INSECURE = 0x0004; |
| 3207 | 3208 | }; |
| 3208 | 3209 | |
| 3210 | pub const LOCK = struct { |
| 3211 | pub const SH = 1; |
| 3212 | pub const EX = 2; |
| 3213 | pub const NB = 4; |
| 3214 | pub const UN = 8; |
| 3215 | }; |
| 3216 | |
| 3209 | 3217 | pub fn getpid() pid_t { |
| 3210 | 3218 | return libc.getpid(); |
| 3211 | 3219 | } |
| ... | ... | @@ -3499,3 +3507,8 @@ pub fn getrandom(buf: []u8, flags: c_uint) ![]u8 { |
| 3499 | 3507 | std.debug.assert(rc >= 0); |
| 3500 | 3508 | return buf[0..@intCast(rc)]; |
| 3501 | 3509 | } |
| 3510 | pub fn flock(fd: c_int, op: c_int) !void { |
| 3511 | const rc = libc.flock(fd, op); |
| 3512 | if (rc == -1) return errno.fromInt(errno.fromLibC()); |
| 3513 | std.debug.assert(rc == 0); |
| 3514 | } |