diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-02-13 05:06:52 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-13 05:06:52 -0800 |
| commit | d7563a7753393d7f0d1af445276a64b8a55cb857 (patch) | |
| tree | add529c48653e4b4525fd2fe30e0ce2503c3d703 /lib/std/os/linux.zig | |
| parent | 0c725a354a801c84100011db5eb53ae6c58086c9 (diff) | |
| parent | ce3bd515973c45ef755da04bc83585b7ce6b87b8 (diff) | |
| download | zig-d7563a7753393d7f0d1af445276a64b8a55cb857.tar.gz zig-d7563a7753393d7f0d1af445276a64b8a55cb857.zip | |
Merge pull request #18910 from ziglang/std-termios
std.os.termios: consolidate, correct, and complete API definitions
Diffstat (limited to 'lib/std/os/linux.zig')
| -rw-r--r-- | lib/std/os/linux.zig | 472 |
1 files changed, 300 insertions, 172 deletions
diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index 36932e5b19..6b092763d1 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -5004,175 +5004,291 @@ pub const rusage = extern struct { pub const THREAD = 1; }; -pub const cc_t = u8; -pub const speed_t = u32; -pub const tcflag_t = u32; - -pub const NCCS = 32; - -pub const B0 = 0o0000000; -pub const B50 = 0o0000001; -pub const B75 = 0o0000002; -pub const B110 = 0o0000003; -pub const B134 = 0o0000004; -pub const B150 = 0o0000005; -pub const B200 = 0o0000006; -pub const B300 = 0o0000007; -pub const B600 = 0o0000010; -pub const B1200 = 0o0000011; -pub const B1800 = 0o0000012; -pub const B2400 = 0o0000013; -pub const B4800 = 0o0000014; -pub const B9600 = 0o0000015; -pub const B19200 = 0o0000016; -pub const B38400 = 0o0000017; -pub const BOTHER = 0o0010000; -pub const B57600 = 0o0010001; -pub const B115200 = 0o0010002; -pub const B230400 = 0o0010003; -pub const B460800 = 0o0010004; -pub const B500000 = 0o0010005; -pub const B576000 = 0o0010006; -pub const B921600 = 0o0010007; -pub const B1000000 = 0o0010010; -pub const B1152000 = 0o0010011; -pub const B1500000 = 0o0010012; -pub const B2000000 = 0o0010013; -pub const B2500000 = 0o0010014; -pub const B3000000 = 0o0010015; -pub const B3500000 = 0o0010016; -pub const B4000000 = 0o0010017; - -pub const V = switch (native_arch) { - .powerpc, .powerpc64, .powerpc64le => struct { - pub const INTR = 0; - pub const QUIT = 1; - pub const ERASE = 2; - pub const KILL = 3; - pub const EOF = 4; - pub const MIN = 5; - pub const EOL = 6; - pub const TIME = 7; - pub const EOL2 = 8; - pub const SWTC = 9; - pub const WERASE = 10; - pub const REPRINT = 11; - pub const SUSP = 12; - pub const START = 13; - pub const STOP = 14; - pub const LNEXT = 15; - pub const DISCARD = 16; +pub const NCCS = switch (native_arch) { + .powerpc, .powerpcle, .powerpc64, .powerpc64le => 19, + else => 32, +}; + +pub const speed_t = switch (native_arch) { + .powerpc, .powerpcle, .powerpc64, .powerpc64le => enum(u32) { + B0 = 0o0000000, + B50 = 0o0000001, + B75 = 0o0000002, + B110 = 0o0000003, + B134 = 0o0000004, + B150 = 0o0000005, + B200 = 0o0000006, + B300 = 0o0000007, + B600 = 0o0000010, + B1200 = 0o0000011, + B1800 = 0o0000012, + B2400 = 0o0000013, + B4800 = 0o0000014, + B9600 = 0o0000015, + B19200 = 0o0000016, + B38400 = 0o0000017, + + B57600 = 0o00020, + B115200 = 0o00021, + B230400 = 0o00022, + B460800 = 0o00023, + B500000 = 0o00024, + B576000 = 0o00025, + B921600 = 0o00026, + B1000000 = 0o00027, + B1152000 = 0o00030, + B1500000 = 0o00031, + B2000000 = 0o00032, + B2500000 = 0o00033, + B3000000 = 0o00034, + B3500000 = 0o00035, + B4000000 = 0o00036, }, - .sparc, .sparc64 => struct { - pub const INTR = 0; - pub const QUIT = 1; - pub const ERASE = 2; - pub const KILL = 3; - pub const EOF = 4; - pub const EOL = 5; - pub const EOL2 = 6; - pub const SWTC = 7; - pub const START = 8; - pub const STOP = 9; - pub const SUSP = 10; - pub const DSUSP = 11; - pub const REPRINT = 12; - pub const DISCARD = 13; - pub const WERASE = 14; - pub const LNEXT = 15; - pub const MIN = EOF; - pub const TIME = EOL; + else => enum(u32) { + B0 = 0o0000000, + B50 = 0o0000001, + B75 = 0o0000002, + B110 = 0o0000003, + B134 = 0o0000004, + B150 = 0o0000005, + B200 = 0o0000006, + B300 = 0o0000007, + B600 = 0o0000010, + B1200 = 0o0000011, + B1800 = 0o0000012, + B2400 = 0o0000013, + B4800 = 0o0000014, + B9600 = 0o0000015, + B19200 = 0o0000016, + B38400 = 0o0000017, + + B57600 = 0o0010001, + B115200 = 0o0010002, + B230400 = 0o0010003, + B460800 = 0o0010004, + B500000 = 0o0010005, + B576000 = 0o0010006, + B921600 = 0o0010007, + B1000000 = 0o0010010, + B1152000 = 0o0010011, + B1500000 = 0o0010012, + B2000000 = 0o0010013, + B2500000 = 0o0010014, + B3000000 = 0o0010015, + B3500000 = 0o0010016, + B4000000 = 0o0010017, }, - .mips, .mipsel, .mips64, .mips64el => struct { - pub const INTR = 0; - pub const QUIT = 1; - pub const ERASE = 2; - pub const KILL = 3; - pub const MIN = 4; - pub const TIME = 5; - pub const EOL2 = 6; - pub const SWTC = 7; - pub const SWTCH = 7; - pub const START = 8; - pub const STOP = 9; - pub const SUSP = 10; - pub const REPRINT = 12; - pub const DISCARD = 13; - pub const WERASE = 14; - pub const LNEXT = 15; - pub const EOF = 16; - pub const EOL = 17; +}; + +pub const tc_iflag_t = switch (native_arch) { + .powerpc, .powerpcle, .powerpc64, .powerpc64le => packed struct(u32) { + IGNBRK: bool = false, + BRKINT: bool = false, + IGNPAR: bool = false, + PARMRK: bool = false, + INPCK: bool = false, + ISTRIP: bool = false, + INLCR: bool = false, + IGNCR: bool = false, + ICRNL: bool = false, + IXON: bool = false, + IXOFF: bool = false, + IXANY: bool = false, + IUCLC: bool = false, + IMAXBEL: bool = false, + IUTF8: bool = false, + _: u17 = 0, }, - else => struct { - pub const INTR = 0; - pub const QUIT = 1; - pub const ERASE = 2; - pub const KILL = 3; - pub const EOF = 4; - pub const TIME = 5; - pub const MIN = 6; - pub const SWTC = 7; - pub const START = 8; - pub const STOP = 9; - pub const SUSP = 10; - pub const EOL = 11; - pub const REPRINT = 12; - pub const DISCARD = 13; - pub const WERASE = 14; - pub const LNEXT = 15; - pub const EOL2 = 16; + else => packed struct(u32) { + IGNBRK: bool = false, + BRKINT: bool = false, + IGNPAR: bool = false, + PARMRK: bool = false, + INPCK: bool = false, + ISTRIP: bool = false, + INLCR: bool = false, + IGNCR: bool = false, + ICRNL: bool = false, + IUCLC: bool = false, + IXON: bool = false, + IXANY: bool = false, + IXOFF: bool = false, + IMAXBEL: bool = false, + IUTF8: bool = false, + _: u17 = 0, + }, +}; + +pub const tc_oflag_t = switch (native_arch) { + .powerpc, .powerpcle, .powerpc64, .powerpc64le => packed struct(u32) { + OPOST: bool = false, + ONLCR: bool = false, + OLCUC: bool = false, + OCRNL: bool = false, + ONOCR: bool = false, + ONLRET: bool = false, + OFILL: bool = false, + OFDEL: bool = false, + NLDLY: u2 = 0, + TABDLY: u2 = 0, + CRDLY: u2 = 0, + FFDLY: u1 = 0, + BSDLY: u1 = 0, + VTDLY: u1 = 0, + _: u15 = 0, + }, + else => packed struct(u32) { + OPOST: bool = false, + OLCUC: bool = false, + ONLCR: bool = false, + OCRNL: bool = false, + ONOCR: bool = false, + ONLRET: bool = false, + OFILL: bool = false, + OFDEL: bool = false, + NLDLY: u1 = 0, + CRDLY: u2 = 0, + TABDLY: u2 = 0, + BSDLY: u1 = 0, + VTDLY: u1 = 0, + FFDLY: u1 = 0, + _: u16 = 0, + }, +}; + +pub const CSIZE = enum(u2) { CS5, CS6, CS7, CS8 }; + +pub const tc_cflag_t = switch (native_arch) { + .powerpc, .powerpcle, .powerpc64, .powerpc64le => packed struct(u32) { + _0: u8 = 0, + CSIZE: CSIZE = .CS5, + CSTOPB: bool = false, + CREAD: bool = false, + PARENB: bool = false, + PARODD: bool = false, + HUPCL: bool = false, + CLOCAL: bool = false, + _: u16 = 0, + }, + else => packed struct(u32) { + _0: u4 = 0, + CSIZE: CSIZE = .CS5, + CSTOPB: bool = false, + CREAD: bool = false, + PARENB: bool = false, + PARODD: bool = false, + HUPCL: bool = false, + CLOCAL: bool = false, + _: u20 = 0, }, }; -pub const IGNBRK: tcflag_t = 1; -pub const BRKINT: tcflag_t = 2; -pub const IGNPAR: tcflag_t = 4; -pub const PARMRK: tcflag_t = 8; -pub const INPCK: tcflag_t = 16; -pub const ISTRIP: tcflag_t = 32; -pub const INLCR: tcflag_t = 64; -pub const IGNCR: tcflag_t = 128; -pub const ICRNL: tcflag_t = 256; -pub const IUCLC: tcflag_t = 512; -pub const IXON: tcflag_t = 1024; -pub const IXANY: tcflag_t = 2048; -pub const IXOFF: tcflag_t = 4096; -pub const IMAXBEL: tcflag_t = 8192; -pub const IUTF8: tcflag_t = 16384; - -pub const OPOST: tcflag_t = 1; -pub const OLCUC: tcflag_t = 2; -pub const ONLCR: tcflag_t = 4; -pub const OCRNL: tcflag_t = 8; -pub const ONOCR: tcflag_t = 16; -pub const ONLRET: tcflag_t = 32; -pub const OFILL: tcflag_t = 64; -pub const OFDEL: tcflag_t = 128; -pub const VTDLY: tcflag_t = 16384; -pub const VT0: tcflag_t = 0; -pub const VT1: tcflag_t = 16384; - -pub const CSIZE: tcflag_t = 48; -pub const CS5: tcflag_t = 0; -pub const CS6: tcflag_t = 16; -pub const CS7: tcflag_t = 32; -pub const CS8: tcflag_t = 48; -pub const CSTOPB: tcflag_t = 64; -pub const CREAD: tcflag_t = 128; -pub const PARENB: tcflag_t = 256; -pub const PARODD: tcflag_t = 512; -pub const HUPCL: tcflag_t = 1024; -pub const CLOCAL: tcflag_t = 2048; - -pub const ISIG: tcflag_t = 1; -pub const ICANON: tcflag_t = 2; -pub const ECHO: tcflag_t = 8; -pub const ECHOE: tcflag_t = 16; -pub const ECHOK: tcflag_t = 32; -pub const ECHONL: tcflag_t = 64; -pub const NOFLSH: tcflag_t = 128; -pub const TOSTOP: tcflag_t = 256; -pub const IEXTEN: tcflag_t = 32768; +pub const tc_lflag_t = switch (native_arch) { + .powerpc, .powerpcle, .powerpc64, .powerpc64le => packed struct(u32) { + _0: u1 = 0, + ECHOE: bool = false, + ECHOK: bool = false, + ECHO: bool = false, + ECHONL: bool = false, + _5: u2 = 0, + ISIG: bool = false, + ICANON: bool = false, + _9: u1 = 0, + IEXTEN: bool = false, + _11: u11 = 0, + TOSTOP: bool = false, + _23: u8 = 0, + NOFLSH: bool = false, + }, + .mips, .mipsel, .mips64, .mips64el => packed struct(u32) { + ISIG: bool = false, + ICANON: bool = false, + _2: u1 = 0, + ECHO: bool = false, + ECHOE: bool = false, + ECHOK: bool = false, + ECHONL: bool = false, + NOFLSH: bool = false, + IEXTEN: bool = false, + _9: u6 = 0, + TOSTOP: bool = false, + _: u16 = 0, + }, + else => packed struct(u32) { + ISIG: bool = false, + ICANON: bool = false, + _2: u1 = 0, + ECHO: bool = false, + ECHOE: bool = false, + ECHOK: bool = false, + ECHONL: bool = false, + NOFLSH: bool = false, + TOSTOP: bool = false, + _9: u6 = 0, + IEXTEN: bool = false, + _: u16 = 0, + }, +}; + +pub const cc_t = switch (native_arch) { + .mips, .mipsel, .mips64, .mips64el => enum(u8) { + VINTR = 0, + VQUIT = 1, + VERASE = 2, + VKILL = 3, + VMIN = 4, + VTIME = 5, + VEOL2 = 6, + VSWTC = 7, + VSTART = 8, + VSTOP = 9, + VSUSP = 10, + VREPRINT = 12, + VDISCARD = 13, + VWERASE = 14, + VLNEXT = 15, + VEOF = 16, + VEOL = 17, + }, + .powerpc, .powerpcle, .powerpc64, .powerpc64le => enum(u8) { + VINTR = 0, + VQUIT = 1, + VERASE = 2, + VKILL = 3, + VEOF = 4, + VMIN = 5, + VEOL = 6, + VTIME = 7, + VEOL2 = 8, + VSWTC = 9, + VWERASE = 10, + VREPRINT = 11, + VSUSP = 12, + VSTART = 13, + VSTOP = 14, + VLNEXT = 15, + VDISCARD = 16, + }, + else => enum(u8) { + VINTR = 0, + VQUIT = 1, + VERASE = 2, + VKILL = 3, + VEOF = 4, + VTIME = 5, + VMIN = 6, + VSWTC = 7, + VSTART = 8, + VSTOP = 9, + VSUSP = 10, + VEOL = 11, + VREPRINT = 12, + VDISCARD = 13, + VWERASE = 14, + VLNEXT = 15, + VEOL2 = 16, + }, +}; pub const TCSA = enum(c_uint) { NOW, @@ -5181,15 +5297,27 @@ pub const TCSA = enum(c_uint) { _, }; -pub const termios = extern struct { - iflag: tcflag_t, - oflag: tcflag_t, - cflag: tcflag_t, - lflag: tcflag_t, - line: cc_t, - cc: [NCCS]cc_t, - ispeed: speed_t, - ospeed: speed_t, +pub const termios = switch (native_arch) { + .powerpc, .powerpcle, .powerpc64, .powerpc64le => extern struct { + iflag: tc_iflag_t, + oflag: tc_oflag_t, + cflag: tc_cflag_t, + lflag: tc_lflag_t, + cc: [NCCS]cc_t, + line: cc_t, + ispeed: speed_t, + ospeed: speed_t, + }, + else => extern struct { + iflag: tc_iflag_t, + oflag: tc_oflag_t, + cflag: tc_cflag_t, + lflag: tc_lflag_t, + line: cc_t, + cc: [NCCS]cc_t, + ispeed: speed_t, + ospeed: speed_t, + }, }; pub const SIOCGIFINDEX = 0x8933; |
