diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-02-12 16:43:51 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-02-12 16:43:51 -0700 |
| commit | 47643cc5cc4db4c0fb2aaa7f37cedb049fce7def (patch) | |
| tree | b1028914cc897c70278973d47239dfb41efb57c1 /lib/std/os/linux.zig | |
| parent | 0c88f927f161224f5c5ce2b12a76133a421af081 (diff) | |
| download | zig-47643cc5cc4db4c0fb2aaa7f37cedb049fce7def.tar.gz zig-47643cc5cc4db4c0fb2aaa7f37cedb049fce7def.zip | |
std.os.termios: add type safety to iflag field
This creates `tc_iflag_t` even though such a type is not defined by
libc.
I also collected the missing flag bits from all the operating systems.
Diffstat (limited to 'lib/std/os/linux.zig')
| -rw-r--r-- | lib/std/os/linux.zig | 61 |
1 files changed, 41 insertions, 20 deletions
diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index f2c3eaf3fd..2c3254bd06 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -5005,7 +5005,6 @@ pub const rusage = extern struct { }; pub const speed_t = u32; -pub const tcflag_t = u32; pub const NCCS = switch (native_arch) { .powerpc, .powerpcle, .powerpc64, .powerpc64le => 19, @@ -5045,23 +5044,43 @@ pub const B3000000 = 0o0010015; pub const B3500000 = 0o0010016; pub const B4000000 = 0o0010017; -pub const tc_iflag_t = 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_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 => 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 cc_t = switch (native_arch) { @@ -5124,6 +5143,8 @@ pub const cc_t = switch (native_arch) { }, }; +pub const tcflag_t = u32; + pub const OPOST: tcflag_t = 1; pub const OLCUC: tcflag_t = 2; pub const ONLCR: tcflag_t = 4; @@ -5168,7 +5189,7 @@ pub const TCSA = enum(c_uint) { pub const termios = switch (native_arch) { .powerpc, .powerpcle, .powerpc64, .powerpc64le => extern struct { - iflag: tcflag_t, + iflag: tc_iflag_t, oflag: tcflag_t, cflag: tcflag_t, lflag: tcflag_t, @@ -5178,7 +5199,7 @@ pub const termios = switch (native_arch) { ospeed: speed_t, }, else => extern struct { - iflag: tcflag_t, + iflag: tc_iflag_t, oflag: tcflag_t, cflag: tcflag_t, lflag: tcflag_t, |
