diff --git a/lib/std/c.zig b/lib/std/c.zig index c9d4265c74..53f11f58b3 100644 --- a/lib/std/c.zig +++ b/lib/std/c.zig @@ -6741,6 +6741,62 @@ pub const SOMAXCONN = switch (native_os) { .freebsd, .dragonfly, .netbsd, .openbsd, .driverkit, .macos, .ios, .tvos, .watchos, .visionos => 128, else => void, }; +pub const SCM = switch (native_os) { + .linux, .emscripten => linux.SCM, + // https://github.com/kofemann/opensolaris/blob/80192cd83bf665e708269dae856f9145f7190f74/usr/src/uts/common/sys/socket.h#L172 + // https://github.com/illumos/illumos-gate/blob/489f6310fe8952e87fc1dce8af87990fcfd90f18/usr/src/uts/common/sys/socket.h#L196 + .solaris, .illumos => struct { + pub const RIGHTS = 0x1010; + pub const UCRED = 0x1012; + pub const TIMESTAMP = SO.TIMESTAMP; + }, + // https://github.com/haiku/haiku/blob/e3d01e53a25446d5ba4999d0ff6dff29a2418657/headers/posix/sys/socket.h#L156 + .haiku => struct { + pub const RIGHTS = 1; + }, + // https://github.com/SerenityOS/serenity/blob/c6618f36bf0949bd76177f202659b1f3079e0792/Kernel/API/POSIX/sys/socket.h#L171 + .serenity => struct { + pub const TIMESTAMP = 0; + pub const RIGHTS = 1; + }, + // https://github.com/freebsd/freebsd-src/blob/614e9b33bf5594d9d09b5d296afa4f3aa6971823/sys/sys/socket.h#L593 + .freebsd => struct { + pub const RIGHTS = 1; + pub const TIMESTAMP = 2; + pub const CREDS = 3; + pub const BINTIME = 4; + pub const REALTIME = 5; + pub const MONOTONIC = 6; + pub const TIME_INFO = 7; + pub const CREDS2 = 8; + }, + // https://github.com/DragonFlyBSD/DragonFlyBSD/blob/6098912863ed4c7b3f70d7483910ce2956cf4ed3/sys/sys/socket.h#L520 + .dragonfly => struct { + pub const RIGHTS = 1; + pub const TIMESTAMP = 2; + pub const CREDS = 3; + }, + // https://github.com/NetBSD/src/blob/3311177ea898ab8322292ba0e48faa9b2e834cb6/sys/sys/socket.h#L578 + .netbsd => struct { + pub const RIGHTS = 0x01; + pub const TIMESTAMP = 0x08; + pub const CREDS = 0x10; + }, + // https://github.com/openbsd/src/blob/1b1dd04c9634112eb763374379af99a68ace4328/sys/sys/socket.h#L566 + .openbsd => struct { + pub const RIGHTS = 0x01; + pub const TIMESTAMP = 0x04; + }, + // https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/sys/socket.h#L1114 + .driverkit, .macos, .ios, .tvos, .watchos, .visionos => struct { + pub const RIGHTS = 1; + pub const TIMESTAMP = 2; + pub const CREDS = 3; + pub const TIMESTAMP_MONOTONIC = 4; + }, + else => void, +}; + pub const IFNAMESIZE = switch (native_os) { .linux => linux.IFNAMESIZE, .emscripten => emscripten.IFNAMESIZE, @@ -11052,7 +11108,6 @@ pub const GETUSTACK = solaris.GETUSTACK; pub const PORT_ALERT = solaris.PORT_ALERT; pub const PORT_SOURCE = solaris.PORT_SOURCE; pub const POSIX_FADV = solaris.POSIX_FADV; -pub const SCM = solaris.SCM; pub const SETCONTEXT = solaris.SETCONTEXT; pub const SETUSTACK = solaris.GETUSTACK; pub const SFD = solaris.SFD; diff --git a/lib/std/c/solaris.zig b/lib/std/c/solaris.zig index 91d96527d9..9736309d06 100644 --- a/lib/std/c/solaris.zig +++ b/lib/std/c/solaris.zig @@ -31,12 +31,6 @@ pub const poolid_t = id_t; pub const zoneid_t = id_t; pub const ctid_t = id_t; -pub const SCM = struct { - pub const UCRED = 0x1012; - pub const RIGHTS = 0x1010; - pub const TIMESTAMP = SO.TIMESTAMP; -}; - pub const fpregset_t = extern union { regs: [130]u32, chip_state: extern struct { diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index f5ff7767a8..564bdb5b22 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -4335,6 +4335,12 @@ pub const SO = if (is_mips) struct { }; pub const SCM = struct { + // https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/socket.h?id=f777d1112ee597d7f7dd3ca232220873a34ad0c8#n178 + pub const RIGHTS = 1; + pub const CREDENTIALS = 2; + pub const SECURITY = 3; + pub const PIDFD = 4; + pub const WIFI_STATUS = SO.WIFI_STATUS; pub const TIMESTAMPING_OPT_STATS = 54; pub const TIMESTAMPING_PKTINFO = 58; diff --git a/lib/std/posix.zig b/lib/std/posix.zig index e0fd68db24..ad826d205d 100644 --- a/lib/std/posix.zig +++ b/lib/std/posix.zig @@ -101,6 +101,7 @@ pub const RR = system.RR; pub const S = system.S; pub const SA = system.SA; pub const SC = system.SC; +pub const SCM = system.SCM; pub const SEEK = system.SEEK; pub const SHUT = system.SHUT; pub const SIG = system.SIG;