feature. See also
. The project being documented here (as the example) is the Zig library itself.
File
Code
const std = @import("../std.zig");
const clock_t = std.c.clock_t;
const clockid_t = std.c.clockid_t;
const pid_t = std.c.pid_t;
const pthread_t = std.c.pthread_t;
const sigval_t = std.c.sigval_t;
const uid_t = std.c.uid_t;
const timespec = std.c.timespec;
pub extern "c" fn ptrace(request: c_int, pid: pid_t, addr: ?*anyopaque, data: c_int) c_int;
pub const lwpid_t = i32;
pub extern "c" fn pthread_setname_np(thread: pthread_t, name: [*:0]const u8, arg: ?*anyopaque) c_int;
pub extern "c" fn _lwp_self() lwpid_t;
pub extern "c" fn ___lwp_park60(
clock_id: clockid_t,
flags: packed struct(u32) {
ABSTIME: bool = false,
unused: u31 = 0,
},
ts: ?*timespec,
unpark: lwpid_t,
hint: ?*const anyopaque,
unpark_hint: ?*const anyopaque,
) c_int;
pub extern "c" fn _lwp_unpark(lwp: lwpid_t, hint: ?*const anyopaque) c_int;
pub extern "c" fn _lwp_unpark_all(targets: [*]const lwpid_t, ntargets: usize, hint: ?*const anyopaque) c_int;
pub const TCIFLUSH = 1;
pub const TCOFLUSH = 2;
pub const TCIOFLUSH = 3;
pub const TCOOFF = 1;
pub const TCOON = 2;
pub const TCIOFF = 3;
pub const TCION = 4;
pub const _ksiginfo = extern struct {
signo: std.c.SIG,
code: i32,
errno: i32,
// correctly aligning the reason field
reason: extern union {
rt: extern struct {
pid: pid_t,
uid: uid_t,
value: sigval_t,
},
child: extern struct {
pid: pid_t,
uid: uid_t,
status: i32,
utime: clock_t,
stime: clock_t,
},
fault: extern struct {
addr: *allowzero anyopaque,
trap: i32,
trap2: i32,
trap3: i32,
},
poll: extern struct {
band: i32,
fd: i32,
},
syscall: extern struct {
sysnum: i32,
retval: [2]i32,
@"error": i32,
args: [8]u64,
},
ptrace_state: extern struct {
pe_report_event: i32,
option: extern union {
pe_other_pid: pid_t,
pe_lwp: lwpid_t,
},
},
} align(@sizeOf(usize)),
};
pub const E = enum(u16) {
SUCCESS = 0,
PERM = 1,
NOENT = 2,
SRCH = 3,
INTR = 4,
IO = 5,
NXIO = 6,
@"2BIG" = 7,
NOEXEC = 8,
BADF = 9,
CHILD = 10,
DEADLK = 11,
// 11 was AGAIN
NOMEM = 12,
ACCES = 13,
FAULT = 14,
NOTBLK = 15,
BUSY = 16,
EXIST = 17,
XDEV = 18,
NODEV = 19,
NOTDIR = 20,
ISDIR = 21,
INVAL = 22,
NFILE = 23,
MFILE = 24,
NOTTY = 25,
TXTBSY = 26,
FBIG = 27,
NOSPC = 28,
SPIPE = 29,
ROFS = 30,
MLINK = 31,
PIPE = 32,
// math software
DOM = 33,
RANGE = 34,
// non-blocking and interrupt i/o
// also: WOULDBLOCK: operation would block
AGAIN = 35,
INPROGRESS = 36,
ALREADY = 37,
// ipc/network software -- argument errors
NOTSOCK = 38,
DESTADDRREQ = 39,
MSGSIZE = 40,
PROTOTYPE = 41,
NOPROTOOPT = 42,
PROTONOSUPPORT = 43,
SOCKTNOSUPPORT = 44,
OPNOTSUPP = 45,
PFNOSUPPORT = 46,
AFNOSUPPORT = 47,
ADDRINUSE = 48,
ADDRNOTAVAIL = 49,
// ipc/network software -- operational errors
NETDOWN = 50,
NETUNREACH = 51,
NETRESET = 52,
CONNABORTED = 53,
CONNRESET = 54,
NOBUFS = 55,
ISCONN = 56,
NOTCONN = 57,
SHUTDOWN = 58,
TOOMANYREFS = 59,
TIMEDOUT = 60,
CONNREFUSED = 61,
LOOP = 62,
NAMETOOLONG = 63,
// should be rearranged
HOSTDOWN = 64,
HOSTUNREACH = 65,
NOTEMPTY = 66,
// quotas & mush
PROCLIM = 67,
USERS = 68,
DQUOT = 69,
// Network File System
STALE = 70,
REMOTE = 71,
BADRPC = 72,
RPCMISMATCH = 73,
PROGUNAVAIL = 74,
PROGMISMATCH = 75,
PROCUNAVAIL = 76,
NOLCK = 77,
NOSYS = 78,
FTYPE = 79,
AUTH = 80,
NEEDAUTH = 81,
// SystemV IPC
IDRM = 82,
NOMSG = 83,
OVERFLOW = 84,
// Wide/multibyte-character handling, ISO/IEC 9899/AMD1:1995
ILSEQ = 85,
// From IEEE Std 1003.1-2001
// Base, Realtime, Threads or Thread Priority Scheduling option errors
NOTSUP = 86,
// Realtime option errors
CANCELED = 87,
// Realtime, XSI STREAMS option errors
BADMSG = 88,
// XSI STREAMS option errors
NODATA = 89,
NOSR = 90,
NOSTR = 91,
TIME = 92,
// File system extended attribute errors
NOATTR = 93,
// Realtime, XSI STREAMS option errors
MULTIHOP = 94,
NOLINK = 95,
PROTO = 96,
_,
};
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 PORTALGO = 18;
pub const PORTRANGE = 19;
pub const RECVIF = 20;
pub const ERRORMTU = 21;
pub const IPSEC_POLICY = 22;
pub const RECVTTL = 23;
pub const MINTTL = 24;
pub const PKTINFO = 25;
pub const RECVPKTINFO = 26;
pub const BINDANY = 27;
pub const SENDSRCADDR = RECVDSTADDR;
pub const DEFAULT_MULTICAST_TTL = 1;
pub const DEFAULT_MULTICAST_LOOP = 1;
pub const MAX_MEMBERSHIPS = 20;
pub const PORTRANGE_DEFAULT = 0;
pub const PORTRANGE_HIGH = 1;
pub const PORTRANGE_LOW = 2;
};
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 PORTALGO = 17;
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 IPSEC_POLICY = 28;
pub const FAITH = 29;
pub const RTHDRDSTOPTS = 35;
pub const RECVPKTINFO = 36;
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 PKTINFO = 46;
pub const HOPLIMIT = 47;
pub const NEXTHOP = 48;
pub const HOPOPTS = 49;
pub const DSTOPTS = 50;
pub const RTHDR = 51;
pub const RECVTCLASS = 57;
pub const OTCLASS = 58;
pub const TCLASS = 61;
pub const DONTFRAG = 62;
pub const PREFER_TEMPADDR = 63;
pub const BINDANY = 64;
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 PORTRANGE_DEFAULT = 0;
pub const PORTRANGE_HIGH = 1;
pub const PORTRANGE_LOW = 2;
};
pub const IPTOS = struct {
pub const DSCP_CS0 = 0x00;
pub const DSCP_CS1 = 0x20;
pub const DSCP_AF11 = 0x28;
pub const DSCP_AF12 = 0x30;
pub const DSCP_AF13 = 0x38;
pub const DSCP_CS2 = 0x40;
pub const DSCP_AF21 = 0x48;
pub const DSCP_AF22 = 0x50;
pub const DSCP_AF23 = 0x58;
pub const DSCP_CS3 = 0x60;
pub const DSCP_AF31 = 0x68;
pub const DSCP_AF32 = 0x70;
pub const DSCP_AF33 = 0x78;
pub const DSCP_CS4 = 0x80;
pub const DSCP_AF41 = 0x88;
pub const DSCP_AF42 = 0x90;
pub const DSCP_AF43 = 0x98;
pub const DSCP_CS5 = 0xa0;
pub const DSCP_EF = 0xb8;
pub const DSCP_CS6 = 0xc0;
pub const DSCP_CS7 = 0xe0;
pub const CLASS_CS0 = 0x00;
pub const CLASS_CS1 = 0x20;
pub const CLASS_CS2 = 0x40;
pub const CLASS_CS3 = 0x60;
pub const CLASS_CS4 = 0x80;
pub const CLASS_CS5 = 0xa0;
pub const CLASS_CS6 = 0xc0;
pub const CLASS_CS7 = 0xe0;
pub const CLASS_DEFAULT = CLASS_CS0;
pub const CLASS_MASK = 0xe0;
pub fn CLASS(t: anytype) @TypeOf(t) {
return t & CLASS_MASK;
}
pub const DSCP_MASK = 0xfc;
pub fn DSCP(t: anytype) @TypeOf(t) {
return t & DSCP_MASK;
}
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 fn ECN(t: anytype) @TypeOf(t) {
return t & ECN_MASK;
}
pub const ECN_NOT_ECT = 0x00;
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 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;
};