diff --git a/lib/std/c.zig b/lib/std/c.zig index 6a8e142a0ce5bc07f92cc04cf4d5ae5d6a76762d..56dbe04ba515345f7738db99ca1f0dd4c2a8fc90 100644 --- a/lib/std/c.zig +++ b/lib/std/c.zig @@ -10810,6 +10810,16 @@ pub const ptrace = switch (native_os) { else => {}, }; +pub extern "c" fn semget(key: std.posix.key_t, nsems: c_int, semflg: c_int) c_int; +pub extern "c" fn semctl(semid: c_int, semnum: c_int, op: c_int, ...) c_int; +pub extern "c" fn semop(semid: c_int, sops: [*]std.posix.sembuf, nsops: usize) c_int; +pub extern "c" fn semtimedop( + semid: c_int, + sops: [*]std.posix.sembuf, + nsops: usize, + timeout: ?*const timespec, +) c_int; + pub extern "c" fn sem_init(sem: *sem_t, pshared: c_int, value: c_uint) c_int; pub extern "c" fn sem_destroy(sem: *sem_t) c_int; pub extern "c" fn sem_open(name: [*:0]const u8, flag: c_int, mode: mode_t, value: c_uint) *sem_t; diff --git a/lib/std/posix.zig b/lib/std/posix.zig index aeed9e5d8e4816c24da7a0cb9c767344f7b9c414..879f4229374f196f3263d4024e4cf4183ebe6356 100644 --- a/lib/std/posix.zig +++ b/lib/std/posix.zig @@ -275,6 +275,99 @@ pub const LOG = struct { pub const DEBUG = 7; }; +pub const key_t = switch (native_os) { + .linux, .illumos => enum(c_int) { + IPC_PRIVATE = 0, + _, + }, + .freebsd, .netbsd, .openbsd, .dragonfly => enum(c_long) { + IPC_PRIVATE = 0, + _, + }, + .haiku, + .driverkit, + .ios, + .maccatalyst, + .macos, + .tvos, + .visionos, + .watchos, + => enum(i32) { + IPC_PRIVATE = 0, + _, + }, + else => unreachable, +}; +pub const SETVAL = switch (native_os) { + .linux => 16, + + .illumos, + .haiku, + + .freebsd, + .netbsd, + .openbsd, + .dragonfly, + + .driverkit, + .ios, + .maccatalyst, + .macos, + .tvos, + .visionos, + .watchos, + => 8, + + else => unreachable, +}; +pub const SEM_UNDO = switch (native_os) { + .linux, + .illumos, + + .freebsd, + .netbsd, + .openbsd, + .dragonfly, + + .driverkit, + .ios, + .maccatalyst, + .macos, + .tvos, + .visionos, + .watchos, + => 0x1000, + + .haiku => 10, + + else => unreachable, +}; +pub const sembuf = switch (native_os) { + .linux, + .illumos, + .haiku, + + .freebsd, + .netbsd, + .openbsd, + .dragonfly, + + .driverkit, + .ios, + .maccatalyst, + .macos, + .tvos, + .visionos, + .watchos, + => extern struct { + sem_num: c_ushort, + sem_op: c_short, + sem_flg: c_short, + }, + + else => unreachable, +}; + pub const socket_t = if (native_os == .windows) windows.ws2_32.SOCKET else fd_t; /// Obtains errno from the return value of a system function call.