authorgravatar for bblack@wikimedia.orgBrandon Black <bblack@wikimedia.org> 2025-09-09 16:37:59-05:00
committergravatar for bblack@wikimedia.orgBrandon Black <bblack@wikimedia.org> 2025-09-09 16:59:50-05:00
logc70521e7b1d09d70ecf7dac9638f02a3961249de
tree416725dda038075bfc58eb6bfe95c6c793478d09
parentf63cd9194c81459d113a57dc7e8ce357f8029728

std: Add SCM constants for socket control messages


4 files changed, 63 insertions(+), 7 deletions(-)

lib/std/c.zig+56-1
......@@ -6741,6 +6741,62 @@ pub const SOMAXCONN = switch (native_os) {
67416741 .freebsd, .dragonfly, .netbsd, .openbsd, .driverkit, .macos, .ios, .tvos, .watchos, .visionos => 128,
67426742 else => void,
67436743};
6744pub const SCM = switch (native_os) {
6745 .linux, .emscripten => linux.SCM,
6746 // https://github.com/kofemann/opensolaris/blob/80192cd83bf665e708269dae856f9145f7190f74/usr/src/uts/common/sys/socket.h#L172
6747 // https://github.com/illumos/illumos-gate/blob/489f6310fe8952e87fc1dce8af87990fcfd90f18/usr/src/uts/common/sys/socket.h#L196
6748 .solaris, .illumos => struct {
6749 pub const RIGHTS = 0x1010;
6750 pub const UCRED = 0x1012;
6751 pub const TIMESTAMP = SO.TIMESTAMP;
6752 },
6753 // https://github.com/haiku/haiku/blob/e3d01e53a25446d5ba4999d0ff6dff29a2418657/headers/posix/sys/socket.h#L156
6754 .haiku => struct {
6755 pub const RIGHTS = 1;
6756 },
6757 // https://github.com/SerenityOS/serenity/blob/c6618f36bf0949bd76177f202659b1f3079e0792/Kernel/API/POSIX/sys/socket.h#L171
6758 .serenity => struct {
6759 pub const TIMESTAMP = 0;
6760 pub const RIGHTS = 1;
6761 },
6762 // https://github.com/freebsd/freebsd-src/blob/614e9b33bf5594d9d09b5d296afa4f3aa6971823/sys/sys/socket.h#L593
6763 .freebsd => struct {
6764 pub const RIGHTS = 1;
6765 pub const TIMESTAMP = 2;
6766 pub const CREDS = 3;
6767 pub const BINTIME = 4;
6768 pub const REALTIME = 5;
6769 pub const MONOTONIC = 6;
6770 pub const TIME_INFO = 7;
6771 pub const CREDS2 = 8;
6772 },
6773 // https://github.com/DragonFlyBSD/DragonFlyBSD/blob/6098912863ed4c7b3f70d7483910ce2956cf4ed3/sys/sys/socket.h#L520
6774 .dragonfly => struct {
6775 pub const RIGHTS = 1;
6776 pub const TIMESTAMP = 2;
6777 pub const CREDS = 3;
6778 },
6779 // https://github.com/NetBSD/src/blob/3311177ea898ab8322292ba0e48faa9b2e834cb6/sys/sys/socket.h#L578
6780 .netbsd => struct {
6781 pub const RIGHTS = 0x01;
6782 pub const TIMESTAMP = 0x08;
6783 pub const CREDS = 0x10;
6784 },
6785 // https://github.com/openbsd/src/blob/1b1dd04c9634112eb763374379af99a68ace4328/sys/sys/socket.h#L566
6786 .openbsd => struct {
6787 pub const RIGHTS = 0x01;
6788 pub const TIMESTAMP = 0x04;
6789 },
6790 // https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/sys/socket.h#L1114
6791 .driverkit, .macos, .ios, .tvos, .watchos, .visionos => struct {
6792 pub const RIGHTS = 1;
6793 pub const TIMESTAMP = 2;
6794 pub const CREDS = 3;
6795 pub const TIMESTAMP_MONOTONIC = 4;
6796 },
6797 else => void,
6798};
6799
67446800pub const IFNAMESIZE = switch (native_os) {
67456801 .linux => linux.IFNAMESIZE,
67466802 .emscripten => emscripten.IFNAMESIZE,
......@@ -11052,7 +11108,6 @@ pub const GETUSTACK = solaris.GETUSTACK;
1105211108pub const PORT_ALERT = solaris.PORT_ALERT;
1105311109pub const PORT_SOURCE = solaris.PORT_SOURCE;
1105411110pub const POSIX_FADV = solaris.POSIX_FADV;
11055pub const SCM = solaris.SCM;
1105611111pub const SETCONTEXT = solaris.SETCONTEXT;
1105711112pub const SETUSTACK = solaris.GETUSTACK;
1105811113pub const SFD = solaris.SFD;
lib/std/c/solaris.zig-6
......@@ -31,12 +31,6 @@ pub const poolid_t = id_t;
3131pub const zoneid_t = id_t;
3232pub const ctid_t = id_t;
3333
34pub const SCM = struct {
35 pub const UCRED = 0x1012;
36 pub const RIGHTS = 0x1010;
37 pub const TIMESTAMP = SO.TIMESTAMP;
38};
39
4034pub const fpregset_t = extern union {
4135 regs: [130]u32,
4236 chip_state: extern struct {
lib/std/os/linux.zig+6
......@@ -4335,6 +4335,12 @@ pub const SO = if (is_mips) struct {
43354335};
43364336
43374337pub const SCM = struct {
4338 // https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/socket.h?id=f777d1112ee597d7f7dd3ca232220873a34ad0c8#n178
4339 pub const RIGHTS = 1;
4340 pub const CREDENTIALS = 2;
4341 pub const SECURITY = 3;
4342 pub const PIDFD = 4;
4343
43384344 pub const WIFI_STATUS = SO.WIFI_STATUS;
43394345 pub const TIMESTAMPING_OPT_STATS = 54;
43404346 pub const TIMESTAMPING_PKTINFO = 58;
lib/std/posix.zig+1
......@@ -101,6 +101,7 @@ pub const RR = system.RR;
101101pub const S = system.S;
102102pub const SA = system.SA;
103103pub const SC = system.SC;
104pub const SCM = system.SCM;
104105pub const SEEK = system.SEEK;
105106pub const SHUT = system.SHUT;
106107pub const SIG = system.SIG;