Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 161 additions & 2 deletions lib/std/c.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3991,6 +3991,17 @@ pub const W = switch (native_os) {
},
else => void,
};
pub const accept_filter_arg = switch (native_os) {
// https://github.com/freebsd/freebsd-src/blob/2024887abc7d1b931e00fbb0697658e98adf048d/sys/sys/socket.h#L205
// https://github.com/DragonFlyBSD/DragonFlyBSD/blob/6098912863ed4c7b3f70d7483910ce2956cf4ed3/sys/sys/socket.h#L164
// https://github.com/NetBSD/src/blob/cad5c68a8524927f65e22ad651de3905382be6e0/sys/sys/socket.h#L188
// https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/sys/socket.h#L504
.freebsd, .dragonfly, .netbsd, .macos, .driverkit, .ios, .tvos, .watchos, .visionos => extern struct {
name: [16]u8,
arg: [240]u8,
},
else => void,
};
pub const clock_t = switch (native_os) {
.linux => linux.clock_t,
.emscripten => emscripten.clock_t,
Expand Down Expand Up @@ -4076,6 +4087,35 @@ pub const ifreq = switch (native_os) {
},
else => void,
};
pub const in_pktinfo = switch (native_os) {
.linux => linux.in_pktinfo,
// https://github.com/kofemann/opensolaris/blob/80192cd83bf665e708269dae856f9145f7190f74/usr/src/uts/common/netinet/in.h#L1084
// https://github.com/illumos/illumos-gate/blob/608eb926e14f4ba4736b2d59e891335f1cba9e1e/usr/src/uts/common/netinet/in.h#L1132
// https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/netinet/in.h#L696
.solaris, .illumos, .driverkit, .ios, .macos, .tvos, .watchos, .visionos => extern struct {
ifindex: u32,
spec_dst: u32,
addr: u32,
},
else => void,
};
pub const in6_pktinfo = switch (native_os) {
.linux => linux.in6_pktinfo,
// https://github.com/freebsd/freebsd-src/blob/9bfbc6826f72eb385bf52f4cde8080bccf7e3ebd/sys/netinet6/in6.h#L547
// https://github.com/DragonFlyBSD/DragonFlyBSD/blob/6098912863ed4c7b3f70d7483910ce2956cf4ed3/sys/netinet6/in6.h#L575
// https://github.com/NetBSD/src/blob/80bf25a5691072d4755e84567ccbdf0729370dea/sys/netinet6/in6.h#L468
// https://github.com/openbsd/src/blob/718a31b40d39fc6064de6355eb144e74633133fc/sys/netinet6/in6.h#L365
// https://github.com/kofemann/opensolaris/blob/80192cd83bf665e708269dae856f9145f7190f74/usr/src/uts/common/netinet/in.h#L1093
// https://github.com/illumos/illumos-gate/blob/608eb926e14f4ba4736b2d59e891335f1cba9e1e/usr/src/uts/common/netinet/in.h#L114IP1
// https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/netinet6/in6.h#L737
// https://github.com/haiku/haiku/blob/2aab5f5f14aeb3f34c3a3d9a9064cc3c0d914bea/headers/posix/netinet6/in6.h#L63
// https://github.com/SerenityOS/serenity/blob/5bd8af99be0bc4b2e14f361fd7d7590e6bcfa4d6/Kernel/API/POSIX/sys/socket.h#L122
.freebsd, .dragonfly, .netbsd, .openbsd, .solaris, .illumos, .driverkit, .ios, .macos, .tvos, .watchos, .visionos, .haiku, .serenity => extern struct {
addr: [16]u8,
ifindex: u32,
},
else => void,
};
pub const itimerspec = switch (native_os) {
.linux => linux.itimerspec,
.haiku => extern struct {
Expand All @@ -4084,6 +4124,37 @@ pub const itimerspec = switch (native_os) {
},
else => void,
};
pub const linger = switch (native_os) {
.linux => linux.linger,
// https://github.com/freebsd/freebsd-src/blob/46347b3619757e3d683a87ca03efaf2ae242335f/sys/sys/socket.h#L200
.freebsd,
// https://github.com/DragonFlyBSD/DragonFlyBSD/blob/6098912863ed4c7b3f70d7483910ce2956cf4ed3/sys/sys/socket.h#L158
.dragonfly,
// https://github.com/NetBSD/src/blob/80bf25a5691072d4755e84567ccbdf0729370dea/sys/sys/socket.h#L183
.netbsd,
// https://github.com/openbsd/src/blob/718a31b40d39fc6064de6355eb144e74633133fc/sys/sys/socket.h#L126
.openbsd,
// https://github.com/kofemann/opensolaris/blob/80192cd83bf665e708269dae856f9145f7190f74/usr/src/uts/common/sys/socket.h#L214
.solaris,
// https://github.com/illumos/illumos-gate/blob/608eb926e14f4ba4736b2d59e891335f1cba9e1e/usr/src/uts/common/sys/socket.h#L250
.illumos,
// https://github.com/haiku/haiku/blob/2aab5f5f14aeb3f34c3a3d9a9064cc3c0d914bea/headers/posix/sys/socket.h#L87
.haiku,
// https://github.com/SerenityOS/serenity/blob/5bd8af99be0bc4b2e14f361fd7d7590e6bcfa4d6/Kernel/API/POSIX/sys/socket.h#L122
.serenity,
// https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/sys/socket.h#L498
.driverkit,
.ios,
.macos,
.tvos,
.watchos,
.visionos,
=> extern struct {
onoff: i32, // non-zero to linger on close
linger: i32, // time to linger in seconds
},
else => void,
};
pub const msghdr = switch (native_os) {
.linux => linux.msghdr,
.openbsd,
Expand Down Expand Up @@ -6388,7 +6459,7 @@ pub const IPPROTO = switch (native_os) {
/// dummy for IP
pub const IP = 0;
/// IP6 hop-by-hop options
pub const HOPOPTS = IP;
pub const HOPOPTS = IPPROTO.IP;
/// control message protocol
pub const ICMP = 1;
/// group mgmt protocol
Expand Down Expand Up @@ -6470,6 +6541,39 @@ pub const IPPROTO = switch (native_os) {
},
else => void,
};
pub const IP = switch (native_os) {
.linux => linux.IP,
.freebsd => freebsd.IP,
.dragonfly => dragonfly.IP,
.netbsd => netbsd.IP,
.openbsd => openbsd.IP,
.solaris, .illumos => solaris.IP,
.haiku => haiku.IP,
.serenity => serenity.IP,
else => void,
};
pub const IPV6 = switch (native_os) {
.linux => linux.IPV6,
.freebsd => freebsd.IPV6,
.dragonfly => dragonfly.IPV6,
.netbsd => netbsd.IPV6,
.openbsd => openbsd.IPV6,
.solaris, .illumos => solaris.IPV6,
.haiku => haiku.IPV6,
.serenity => serenity.IPV6,
else => void,
};
pub const IPTOS = switch (native_os) {
.linux => linux.IPTOS,
.freebsd => freebsd.IPTOS,
.dragonfly => dragonfly.IPTOS,
.netbsd => netbsd.IPTOS,
.openbsd => openbsd.IPTOS,
.solaris, .illumos => solaris.IPTOS,
.haiku => haiku.IPTOS,
.serenity => serenity.IPTOS,
else => void,
};
pub const SOL = switch (native_os) {
.linux => linux.SOL,
.emscripten => emscripten.SOL,
Expand Down Expand Up @@ -6741,6 +6845,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,
Expand Down Expand Up @@ -11052,7 +11212,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;
Expand Down
162 changes: 162 additions & 0 deletions lib/std/c/darwin.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1724,3 +1724,165 @@ pub const MSG = struct {
/// Inherit upcall in sock_accept
pub const USEUPCALL = 0x80000000;
};

// https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/netinet/in.h#L454
pub const IP = struct {
pub const OPTIONS = 1;
pub const HDRINCL = 2;
pub const TOS = 3;
pub const TTL = 4;
pub const RECVOPTS = 5;
pub const RECVRETOPTS = 6;
pub const RECVDSTADDR = 7;
pub const RETOPTS = 8;
pub const MULTICAST_IF = 9;
pub const MULTICAST_TTL = 10;
pub const MULTICAST_LOOP = 11;
pub const ADD_MEMBERSHIP = 12;
pub const DROP_MEMBERSHIP = 13;
pub const MULTICAST_VIF = 14;
pub const RSVP_ON = 15;
pub const RSVP_OFF = 16;
pub const RSVP_VIF_ON = 17;
pub const RSVP_VIF_OFF = 18;
pub const PORTRANGE = 19;
pub const RECVIF = 20;
pub const IPSEC_POLICY = 21;
pub const FAITH = 22;
pub const STRIPHDR = 23;
pub const RECVTTL = 24;
pub const BOUND_IF = 25;
pub const PKTINFO = 26;
pub const RECVPKTINFO = PKTINFO;
pub const RECVTOS = 27;
pub const DONTFRAG = 28;
pub const FW_ADD = 40;
pub const FW_DEL = 41;
pub const FW_FLUSH = 42;
pub const FW_ZERO = 43;
pub const FW_GET = 44;
pub const FW_RESETLOG = 45;
pub const OLD_FW_ADD = 50;
pub const OLD_FW_DEL = 51;
pub const OLD_FW_FLUSH = 52;
pub const OLD_FW_ZERO = 53;
pub const OLD_FW_GET = 54;
pub const OLD_FW_RESETLOG = 56;
pub const DUMMYNET_CONFIGURE = 60;
pub const DUMMYNET_DEL = 61;
pub const DUMMYNET_FLUSH = 62;
pub const DUMMYNET_GET = 64;
pub const TRAFFIC_MGT_BACKGROUND = 65;
pub const MULTICAST_IFINDEX = 66;
pub const ADD_SOURCE_MEMBERSHIP = 70;
pub const DROP_SOURCE_MEMBERSHIP = 71;
pub const BLOCK_SOURCE = 72;
pub const UNBLOCK_SOURCE = 73;
pub const MSFILTER = 74;
// Same namespace, but these are arguments rather than option names
pub const DEFAULT_MULTICAST_TTL = 1;
pub const DEFAULT_MULTICAST_LOOP = 1;
pub const MIN_MEMBERSHIPS = 31;
pub const MAX_MEMBERSHIPS = 4095;
pub const MAX_GROUP_SRC_FILTER = 512;
pub const MAX_SOCK_SRC_FILTER = 128;
pub const MAX_SOCK_MUTE_FILTER = 128;
pub const PORTRANGE_DEFAULT = 0;
pub const PORTRANGE_HIGH = 1;
pub const PORTRANGE_LOW = 2;
};

// https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/netinet6/in6.h#L521
pub const IPV6 = struct {
pub const UNICAST_HOPS = 4;
pub const MULTICAST_IF = 9;
pub const MULTICAST_HOPS = 10;
pub const MULTICAST_LOOP = 11;
pub const JOIN_GROUP = 12;
pub const LEAVE_GROUP = 13;
pub const PORTRANGE = 14;
pub const @"2292PKTINFO" = 19;
pub const @"2292HOPLIMIT" = 20;
pub const @"2292NEXTHOP" = 21;
pub const @"2292HOPOPTS" = 22;
pub const @"2292DSTOPTS" = 23;
pub const @"2292RTHDR" = 24;
pub const @"2292PKTOPTIONS" = 25;
pub const CHECKSUM = 26;
pub const V6ONLY = 27;
pub const BINDV6ONLY = V6ONLY;
pub const IPSEC_POLICY = 28;
pub const FAITH = 29;
pub const FW_ADD = 30;
pub const FW_DEL = 31;
pub const FW_FLUSH = 32;
pub const FW_ZERO = 33;
pub const FW_GET = 34;
pub const RECVTCLASS = 35;
pub const TCLASS = 36;
pub const RTHDRDSTOPTS = 57;
pub const RECVPKTINFO = 61;
pub const RECVHOPLIMIT = 37;
pub const RECVRTHDR = 38;
pub const RECVHOPOPTS = 39;
pub const RECVDSTOPTS = 40;
pub const RECVRTHDRDSTOPTS = 41;
pub const USE_MIN_MTU = 42;
pub const RECVPATHMTU = 43;
pub const PATHMTU = 44;
pub const REACHCONF = 45;
pub const @"3542PKTINFO" = 46;
pub const @"3542HOPLIMIT" = 47;
pub const @"3542NEXTHOP" = 48;
pub const @"3542HOPOPTS" = 49;
pub const @"3542DSTOPTS" = 50;
pub const @"3542RTHDR" = 51;
pub const PKTINFO = @"3542PKTINFO";
pub const HOPLIMIT = @"3542HOPLIMIT";
pub const NEXTHOP = @"3542NEXTHOP";
pub const HOPOPTS = @"3542HOPOPTS";
pub const DSTOPTS = @"3542DSTOPTS";
pub const RTHDR = @"3542RTHDR";
pub const AUTOFLOWLABEL = 59;
pub const DONTFRAG = 62;
pub const PREFER_TEMPADDR = 63;
pub const MSFILTER = 74;
pub const BOUND_IF = 125;
// Same namespace, but these are arguments rather than option names
pub const RTHDR_LOOSE = 0;
pub const RTHDR_STRICT = 1;
pub const RTHDR_TYPE_0 = 0;
pub const DEFAULT_MULTICAST_HOPS = 1;
pub const DEFAULT_MULTICAST_LOOP = 1;
pub const MIN_MEMBERSHIPS = 31;
pub const MAX_MEMBERSHIPS = 4095;
pub const MAX_GROUP_SRC_FILTER = 512;
pub const MAX_SOCK_SRC_FILTER = 128;
pub const PORTRANGE_DEFAULT = 0;
pub const PORTRANGE_HIGH = 1;
pub const PORTRANGE_LOW = 2;
};

// https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/netinet/ip.h#L129
pub const IPTOS = struct {
pub const LOWDELAY = 0x10;
pub const THROUGHPUT = 0x08;
pub const RELIABILITY = 0x04;
pub const MINCOST = 0x02;
pub const CE = 0x01;
pub const ECT = 0x02;
pub const DSCP_SHIFT = 2;
pub const ECN_NOTECT = 0x00;
pub const ECN_ECT1 = 0x01;
pub const ECN_ECT0 = 0x02;
pub const ECN_CE = 0x03;
pub const ECN_MASK = 0x03;
pub const PREC_NETCONTROL = 0xe0;
pub const PREC_INTERNETCONTROL = 0xc0;
pub const PREC_CRITIC_ECP = 0xa0;
pub const PREC_FLASHOVERRIDE = 0x80;
pub const PREC_FLASH = 0x60;
pub const PREC_IMMEDIATE = 0x40;
pub const PREC_PRIORITY = 0x20;
pub const PREC_ROUTINE = 0x00;
};
Loading