Source
pub const T = switch (native_os) {
.linux => linux.T,
.macos, .ios, .tvos, .watchos, .visionos => struct {
pub const IOCGWINSZ = ior(0x40000000, 't', 104, @sizeOf(winsize));
fn ior(inout: u32, group: usize, num: usize, len: usize) usize {
return (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num));
}
},
.freebsd => struct {
pub const IOCEXCL = 0x2000740d;
pub const IOCNXCL = 0x2000740e;
pub const IOCSCTTY = 0x20007461;
pub const IOCGPGRP = 0x40047477;
pub const IOCSPGRP = 0x80047476;
pub const IOCOUTQ = 0x40047473;
pub const IOCSTI = 0x80017472;
pub const IOCGWINSZ = 0x40087468;
pub const IOCSWINSZ = 0x80087467;
pub const IOCMGET = 0x4004746a;
pub const IOCMBIS = 0x8004746c;
pub const IOCMBIC = 0x8004746b;
pub const IOCMSET = 0x8004746d;
pub const FIONREAD = 0x4004667f;
pub const IOCCONS = 0x80047462;
pub const IOCPKT = 0x80047470;
pub const FIONBIO = 0x8004667e;
pub const IOCNOTTY = 0x20007471;
pub const IOCSETD = 0x8004741b;
pub const IOCGETD = 0x4004741a;
pub const IOCSBRK = 0x2000747b;
pub const IOCCBRK = 0x2000747a;
pub const IOCGSID = 0x40047463;
pub const IOCGPTN = 0x4004740f;
pub const IOCSIG = 0x2004745f;
},
.solaris, .illumos => struct {
pub const CGETA = tioc('T', 1);
pub const CSETA = tioc('T', 2);
pub const CSETAW = tioc('T', 3);
pub const CSETAF = tioc('T', 4);
pub const CSBRK = tioc('T', 5);
pub const CXONC = tioc('T', 6);
pub const CFLSH = tioc('T', 7);
pub const IOCGWINSZ = tioc('T', 104);
pub const IOCSWINSZ = tioc('T', 103);
// Softcarrier ioctls
pub const IOCGSOFTCAR = tioc('T', 105);
pub const IOCSSOFTCAR = tioc('T', 106);
// termios ioctls
pub const CGETS = tioc('T', 13);
pub const CSETS = tioc('T', 14);
pub const CSANOW = tioc('T', 14);
pub const CSETSW = tioc('T', 15);
pub const CSADRAIN = tioc('T', 15);
pub const CSETSF = tioc('T', 16);
pub const IOCSETLD = tioc('T', 123);
pub const IOCGETLD = tioc('T', 124);
// NTP PPS ioctls
pub const IOCGPPS = tioc('T', 125);
pub const IOCSPPS = tioc('T', 126);
pub const IOCGPPSEV = tioc('T', 127);
pub const IOCGETD = tioc('t', 0);
pub const IOCSETD = tioc('t', 1);
pub const IOCHPCL = tioc('t', 2);
pub const IOCGETP = tioc('t', 8);
pub const IOCSETP = tioc('t', 9);
pub const IOCSETN = tioc('t', 10);
pub const IOCEXCL = tioc('t', 13);
pub const IOCNXCL = tioc('t', 14);
pub const IOCFLUSH = tioc('t', 16);
pub const IOCSETC = tioc('t', 17);
pub const IOCGETC = tioc('t', 18);
/// bis local mode bits
pub const IOCLBIS = tioc('t', 127);
/// bic local mode bits
pub const IOCLBIC = tioc('t', 126);
/// set entire local mode word
pub const IOCLSET = tioc('t', 125);
/// get local modes
pub const IOCLGET = tioc('t', 124);
/// set break bit
pub const IOCSBRK = tioc('t', 123);
/// clear break bit
pub const IOCCBRK = tioc('t', 122);
/// set data terminal ready
pub const IOCSDTR = tioc('t', 121);
/// clear data terminal ready
pub const IOCCDTR = tioc('t', 120);
/// set local special chars
pub const IOCSLTC = tioc('t', 117);
/// get local special chars
pub const IOCGLTC = tioc('t', 116);
/// driver output queue size
pub const IOCOUTQ = tioc('t', 115);
/// void tty association
pub const IOCNOTTY = tioc('t', 113);
/// get a ctty
pub const IOCSCTTY = tioc('t', 132);
/// stop output, like ^S
pub const IOCSTOP = tioc('t', 111);
/// start output, like ^Q
pub const IOCSTART = tioc('t', 110);
/// get pgrp of tty
pub const IOCGPGRP = tioc('t', 20);
/// set pgrp of tty
pub const IOCSPGRP = tioc('t', 21);
/// get session id on ctty
pub const IOCGSID = tioc('t', 22);
/// simulate terminal input
pub const IOCSTI = tioc('t', 23);
/// set all modem bits
pub const IOCMSET = tioc('t', 26);
/// bis modem bits
pub const IOCMBIS = tioc('t', 27);
/// bic modem bits
pub const IOCMBIC = tioc('t', 28);
/// get all modem bits
pub const IOCMGET = tioc('t', 29);
fn tioc(t: u16, num: u8) u16 {
return (t << 8) | num;
}
},
.netbsd => struct {
pub const IOCCBRK = 0x2000747a;
pub const IOCCDTR = 0x20007478;
pub const IOCCONS = 0x80047462;
pub const IOCDCDTIMESTAMP = 0x40107458;
pub const IOCDRAIN = 0x2000745e;
pub const IOCEXCL = 0x2000740d;
pub const IOCEXT = 0x80047460;
pub const IOCFLAG_CDTRCTS = 0x10;
pub const IOCFLAG_CLOCAL = 0x2;
pub const IOCFLAG_CRTSCTS = 0x4;
pub const IOCFLAG_MDMBUF = 0x8;
pub const IOCFLAG_SOFTCAR = 0x1;
pub const IOCFLUSH = 0x80047410;
pub const IOCGETA = 0x402c7413;
pub const IOCGETD = 0x4004741a;
pub const IOCGFLAGS = 0x4004745d;
pub const IOCGLINED = 0x40207442;
pub const IOCGPGRP = 0x40047477;
pub const IOCGQSIZE = 0x40047481;
pub const IOCGRANTPT = 0x20007447;
pub const IOCGSID = 0x40047463;
pub const IOCGSIZE = 0x40087468;
pub const IOCGWINSZ = 0x40087468;
pub const IOCMBIC = 0x8004746b;
pub const IOCMBIS = 0x8004746c;
pub const IOCMGET = 0x4004746a;
pub const IOCMSET = 0x8004746d;
pub const IOCM_CAR = 0x40;
pub const IOCM_CD = 0x40;
pub const IOCM_CTS = 0x20;
pub const IOCM_DSR = 0x100;
pub const IOCM_DTR = 0x2;
pub const IOCM_LE = 0x1;
pub const IOCM_RI = 0x80;
pub const IOCM_RNG = 0x80;
pub const IOCM_RTS = 0x4;
pub const IOCM_SR = 0x10;
pub const IOCM_ST = 0x8;
pub const IOCNOTTY = 0x20007471;
pub const IOCNXCL = 0x2000740e;
pub const IOCOUTQ = 0x40047473;
pub const IOCPKT = 0x80047470;
pub const IOCPKT_DATA = 0x0;
pub const IOCPKT_DOSTOP = 0x20;
pub const IOCPKT_FLUSHREAD = 0x1;
pub const IOCPKT_FLUSHWRITE = 0x2;
pub const IOCPKT_IOCTL = 0x40;
pub const IOCPKT_NOSTOP = 0x10;
pub const IOCPKT_START = 0x8;
pub const IOCPKT_STOP = 0x4;
pub const IOCPTMGET = 0x40287446;
pub const IOCPTSNAME = 0x40287448;
pub const IOCRCVFRAME = 0x80087445;
pub const IOCREMOTE = 0x80047469;
pub const IOCSBRK = 0x2000747b;
pub const IOCSCTTY = 0x20007461;
pub const IOCSDTR = 0x20007479;
pub const IOCSETA = 0x802c7414;
pub const IOCSETAF = 0x802c7416;
pub const IOCSETAW = 0x802c7415;
pub const IOCSETD = 0x8004741b;
pub const IOCSFLAGS = 0x8004745c;
pub const IOCSIG = 0x2000745f;
pub const IOCSLINED = 0x80207443;
pub const IOCSPGRP = 0x80047476;
pub const IOCSQSIZE = 0x80047480;
pub const IOCSSIZE = 0x80087467;
pub const IOCSTART = 0x2000746e;
pub const IOCSTAT = 0x80047465;
pub const IOCSTI = 0x80017472;
pub const IOCSTOP = 0x2000746f;
pub const IOCSWINSZ = 0x80087467;
pub const IOCUCNTL = 0x80047466;
pub const IOCXMTFRAME = 0x80087444;
},
.haiku => struct {
pub const CGETA = 0x8000;
pub const CSETA = 0x8001;
pub const CSETAF = 0x8002;
pub const CSETAW = 0x8003;
pub const CWAITEVENT = 0x8004;
pub const CSBRK = 0x8005;
pub const CFLSH = 0x8006;
pub const CXONC = 0x8007;
pub const CQUERYCONNECTED = 0x8008;
pub const CGETBITS = 0x8009;
pub const CSETDTR = 0x8010;
pub const CSETRTS = 0x8011;
pub const IOCGWINSZ = 0x8012;
pub const IOCSWINSZ = 0x8013;
pub const CVTIME = 0x8014;
pub const IOCGPGRP = 0x8015;
pub const IOCSPGRP = 0x8016;
pub const IOCSCTTY = 0x8017;
pub const IOCMGET = 0x8018;
pub const IOCMSET = 0x8019;
pub const IOCSBRK = 0x8020;
pub const IOCCBRK = 0x8021;
pub const IOCMBIS = 0x8022;
pub const IOCMBIC = 0x8023;
pub const IOCGSID = 0x8024;
pub const FIONREAD = 0xbe000001;
pub const FIONBIO = 0xbe000000;
},
.openbsd => struct {
pub const IOCCBRK = 0x2000747a;
pub const IOCCDTR = 0x20007478;
pub const IOCCONS = 0x80047462;
pub const IOCDCDTIMESTAMP = 0x40107458;
pub const IOCDRAIN = 0x2000745e;
pub const IOCEXCL = 0x2000740d;
pub const IOCEXT = 0x80047460;
pub const IOCFLAG_CDTRCTS = 0x10;
pub const IOCFLAG_CLOCAL = 0x2;
pub const IOCFLAG_CRTSCTS = 0x4;
pub const IOCFLAG_MDMBUF = 0x8;
pub const IOCFLAG_SOFTCAR = 0x1;
pub const IOCFLUSH = 0x80047410;
pub const IOCGETA = 0x402c7413;
pub const IOCGETD = 0x4004741a;
pub const IOCGFLAGS = 0x4004745d;
pub const IOCGLINED = 0x40207442;
pub const IOCGPGRP = 0x40047477;
pub const IOCGQSIZE = 0x40047481;
pub const IOCGRANTPT = 0x20007447;
pub const IOCGSID = 0x40047463;
pub const IOCGSIZE = 0x40087468;
pub const IOCGWINSZ = 0x40087468;
pub const IOCMBIC = 0x8004746b;
pub const IOCMBIS = 0x8004746c;
pub const IOCMGET = 0x4004746a;
pub const IOCMSET = 0x8004746d;
pub const IOCM_CAR = 0x40;
pub const IOCM_CD = 0x40;
pub const IOCM_CTS = 0x20;
pub const IOCM_DSR = 0x100;
pub const IOCM_DTR = 0x2;
pub const IOCM_LE = 0x1;
pub const IOCM_RI = 0x80;
pub const IOCM_RNG = 0x80;
pub const IOCM_RTS = 0x4;
pub const IOCM_SR = 0x10;
pub const IOCM_ST = 0x8;
pub const IOCNOTTY = 0x20007471;
pub const IOCNXCL = 0x2000740e;
pub const IOCOUTQ = 0x40047473;
pub const IOCPKT = 0x80047470;
pub const IOCPKT_DATA = 0x0;
pub const IOCPKT_DOSTOP = 0x20;
pub const IOCPKT_FLUSHREAD = 0x1;
pub const IOCPKT_FLUSHWRITE = 0x2;
pub const IOCPKT_IOCTL = 0x40;
pub const IOCPKT_NOSTOP = 0x10;
pub const IOCPKT_START = 0x8;
pub const IOCPKT_STOP = 0x4;
pub const IOCPTMGET = 0x40287446;
pub const IOCPTSNAME = 0x40287448;
pub const IOCRCVFRAME = 0x80087445;
pub const IOCREMOTE = 0x80047469;
pub const IOCSBRK = 0x2000747b;
pub const IOCSCTTY = 0x20007461;
pub const IOCSDTR = 0x20007479;
pub const IOCSETA = 0x802c7414;
pub const IOCSETAF = 0x802c7416;
pub const IOCSETAW = 0x802c7415;
pub const IOCSETD = 0x8004741b;
pub const IOCSFLAGS = 0x8004745c;
pub const IOCSIG = 0x2000745f;
pub const IOCSLINED = 0x80207443;
pub const IOCSPGRP = 0x80047476;
pub const IOCSQSIZE = 0x80047480;
pub const IOCSSIZE = 0x80087467;
pub const IOCSTART = 0x2000746e;
pub const IOCSTAT = 0x80047465;
pub const IOCSTI = 0x80017472;
pub const IOCSTOP = 0x2000746f;
pub const IOCSWINSZ = 0x80087467;
pub const IOCUCNTL = 0x80047466;
pub const IOCXMTFRAME = 0x80087444;
},
.dragonfly => struct {
pub const IOCMODG = 0x40047403;
pub const IOCMODS = 0x80047404;
pub const IOCM_LE = 0x00000001;
pub const IOCM_DTR = 0x00000002;
pub const IOCM_RTS = 0x00000004;
pub const IOCM_ST = 0x00000008;
pub const IOCM_SR = 0x00000010;
pub const IOCM_CTS = 0x00000020;
pub const IOCM_CAR = 0x00000040;
pub const IOCM_CD = 0x00000040;
pub const IOCM_RNG = 0x00000080;
pub const IOCM_RI = 0x00000080;
pub const IOCM_DSR = 0x00000100;
pub const IOCEXCL = 0x2000740d;
pub const IOCNXCL = 0x2000740e;
pub const IOCFLUSH = 0x80047410;
pub const IOCGETA = 0x402c7413;
pub const IOCSETA = 0x802c7414;
pub const IOCSETAW = 0x802c7415;
pub const IOCSETAF = 0x802c7416;
pub const IOCGETD = 0x4004741a;
pub const IOCSETD = 0x8004741b;
pub const IOCSBRK = 0x2000747b;
pub const IOCCBRK = 0x2000747a;
pub const IOCSDTR = 0x20007479;
pub const IOCCDTR = 0x20007478;
pub const IOCGPGRP = 0x40047477;
pub const IOCSPGRP = 0x80047476;
pub const IOCOUTQ = 0x40047473;
pub const IOCSTI = 0x80017472;
pub const IOCNOTTY = 0x20007471;
pub const IOCPKT = 0x80047470;
pub const IOCPKT_DATA = 0x00000000;
pub const IOCPKT_FLUSHREAD = 0x00000001;
pub const IOCPKT_FLUSHWRITE = 0x00000002;
pub const IOCPKT_STOP = 0x00000004;
pub const IOCPKT_START = 0x00000008;
pub const IOCPKT_NOSTOP = 0x00000010;
pub const IOCPKT_DOSTOP = 0x00000020;
pub const IOCPKT_IOCTL = 0x00000040;
pub const IOCSTOP = 0x2000746f;
pub const IOCSTART = 0x2000746e;
pub const IOCMSET = 0x8004746d;
pub const IOCMBIS = 0x8004746c;
pub const IOCMBIC = 0x8004746b;
pub const IOCMGET = 0x4004746a;
pub const IOCREMOTE = 0x80047469;
pub const IOCGWINSZ = 0x40087468;
pub const IOCSWINSZ = 0x80087467;
pub const IOCUCNTL = 0x80047466;
pub const IOCSTAT = 0x20007465;
pub const IOCGSID = 0x40047463;
pub const IOCCONS = 0x80047462;
pub const IOCSCTTY = 0x20007461;
pub const IOCEXT = 0x80047460;
pub const IOCSIG = 0x2000745f;
pub const IOCDRAIN = 0x2000745e;
pub const IOCMSDTRWAIT = 0x8004745b;
pub const IOCMGDTRWAIT = 0x4004745a;
pub const IOCTIMESTAMP = 0x40107459;
pub const IOCDCDTIMESTAMP = 0x40107458;
pub const IOCSDRAINWAIT = 0x80047457;
pub const IOCGDRAINWAIT = 0x40047456;
pub const IOCISPTMASTER = 0x20007455;
},
// https://github.com/SerenityOS/serenity/blob/cb10f70394fb7e9cfc77f827adb2e46d199bc3a5/Kernel/API/Ioctl.h#L84-L96
.serenity => struct {
pub const IOCGPGRP = 0;
pub const IOCSPGRP = 1;
pub const CGETS = 2;
pub const CSETS = 3;
pub const CSETSW = 4;
pub const CSETSF = 5;
pub const CFLSH = 6;
pub const IOCGWINSZ = 7;
pub const IOCSCTTY = 8;
pub const IOCSTI = 9;
pub const IOCNOTTY = 10;
pub const IOCSWINSZ = 11;
pub const IOCGPTN = 12;
},
else => void,
}