authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-02-12 15:52:13-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-02-12 15:52:13-07:00
log9a643185540a3bba31e449fdf6f25643a2ea3394
treeffbc4462da517a8970fd396faf5bc5a995581ab3
parent9bdf1ebe3644ee965aab152dd46534a036deaaa8

std.c.NCSS: consolidate and correct


8 files changed, 19 insertions(+), 19 deletions(-)

lib/std/c.zig+9
...@@ -781,6 +781,15 @@ pub const cc_t = switch (native_os) {...@@ -781,6 +781,15 @@ pub const cc_t = switch (native_os) {
781 else => @compileError("target libc does not have cc_t"),781 else => @compileError("target libc does not have cc_t"),
782};782};
783783
784pub const NCCS = switch (native_os) {
785 .linux => std.os.linux.NCCS,
786 .macos, .ios, .tvos, .watchos, .freebsd, .kfreebsd, .netbsd, .openbsd, .dragonfly => 20,
787 .haiku => 11,
788 .solaris, .illumos => 19,
789 .emscripten, .wasi => 32,
790 else => @compileError("target libc does not have NCCS"),
791};
792
784pub const whence_t = if (native_os == .wasi) std.os.wasi.whence_t else c_int;793pub const whence_t = if (native_os == .wasi) std.os.wasi.whence_t else c_int;
785794
786// Unix-like systems795// Unix-like systems
lib/std/c/darwin.zig+1-3
...@@ -2692,8 +2692,6 @@ pub const SHUT = struct {...@@ -2692,8 +2692,6 @@ pub const SHUT = struct {
2692 pub const RDWR = 2;2692 pub const RDWR = 2;
2693};2693};
26942694
2695pub const NCCS = 20; // 2 spares (7, 19)
2696
2697pub const speed_t = u64;2695pub const speed_t = u64;
2698pub const tcflag_t = u64;2696pub const tcflag_t = u64;
26992697
...@@ -2836,7 +2834,7 @@ pub const termios = extern struct {...@@ -2836,7 +2834,7 @@ pub const termios = extern struct {
2836 oflag: tcflag_t, // output flags2834 oflag: tcflag_t, // output flags
2837 cflag: tcflag_t, // control flags2835 cflag: tcflag_t, // control flags
2838 lflag: tcflag_t, // local flags2836 lflag: tcflag_t, // local flags
2839 cc: [NCCS]std.c.cc_t, // control chars2837 cc: [std.c.NCCS]std.c.cc_t, // control chars
2840 ispeed: speed_t align(8), // input speed2838 ispeed: speed_t align(8), // input speed
2841 ospeed: speed_t, // output speed2839 ospeed: speed_t, // output speed
2842};2840};
lib/std/c/emscripten.zig+1-3
...@@ -182,15 +182,13 @@ pub const dirent = struct {...@@ -182,15 +182,13 @@ pub const dirent = struct {
182pub const speed_t = u32;182pub const speed_t = u32;
183pub const tcflag_t = u32;183pub const tcflag_t = u32;
184184
185pub const NCCS = 32;
186
187pub const termios = extern struct {185pub const termios = extern struct {
188 iflag: tcflag_t,186 iflag: tcflag_t,
189 oflag: tcflag_t,187 oflag: tcflag_t,
190 cflag: tcflag_t,188 cflag: tcflag_t,
191 lflag: tcflag_t,189 lflag: tcflag_t,
192 line: std.c.cc_t,190 line: std.c.cc_t,
193 cc: [NCCS]std.c.cc_t,191 cc: [std.c.NCCS]std.c.cc_t,
194 ispeed: speed_t,192 ispeed: speed_t,
195 ospeed: speed_t,193 ospeed: speed_t,
196};194};
lib/std/c/haiku.zig+1-3
...@@ -953,8 +953,6 @@ pub const directory_which = enum(c_int) {...@@ -953,8 +953,6 @@ pub const directory_which = enum(c_int) {
953pub const speed_t = u8;953pub const speed_t = u8;
954pub const tcflag_t = u32;954pub const tcflag_t = u32;
955955
956pub const NCCS = 11;
957
958pub const termios = extern struct {956pub const termios = extern struct {
959 c_iflag: tcflag_t,957 c_iflag: tcflag_t,
960 c_oflag: tcflag_t,958 c_oflag: tcflag_t,
...@@ -963,7 +961,7 @@ pub const termios = extern struct {...@@ -963,7 +961,7 @@ pub const termios = extern struct {
963 c_line: std.c.cc_t,961 c_line: std.c.cc_t,
964 c_ispeed: speed_t,962 c_ispeed: speed_t,
965 c_ospeed: speed_t,963 c_ospeed: speed_t,
966 cc_t: [NCCS]std.c.cc_t,964 cc_t: [std.c.NCCS]std.c.cc_t,
967};965};
968966
969pub const MSG_NOSIGNAL = 0x0800;967pub const MSG_NOSIGNAL = 0x0800;
lib/std/c/netbsd.zig+1-3
...@@ -853,14 +853,12 @@ pub const CHWFLOW: tcflag_t = (MDMBUF | CRTSCTS | CDTRCTS); // all types of hw f...@@ -853,14 +853,12 @@ pub const CHWFLOW: tcflag_t = (MDMBUF | CRTSCTS | CDTRCTS); // all types of hw f
853pub const tcflag_t = c_uint;853pub const tcflag_t = c_uint;
854pub const speed_t = c_uint;854pub const speed_t = c_uint;
855855
856pub const NCCS = 20;
857
858pub const termios = extern struct {856pub const termios = extern struct {
859 iflag: tcflag_t, // input flags857 iflag: tcflag_t, // input flags
860 oflag: tcflag_t, // output flags858 oflag: tcflag_t, // output flags
861 cflag: tcflag_t, // control flags859 cflag: tcflag_t, // control flags
862 lflag: tcflag_t, // local flags860 lflag: tcflag_t, // local flags
863 cc: [NCCS]std.c.cc_t, // control chars861 cc: [std.c.NCCS]std.c.cc_t, // control chars
864 ispeed: c_int, // input speed862 ispeed: c_int, // input speed
865 ospeed: c_int, // output speed863 ospeed: c_int, // output speed
866};864};
lib/std/c/openbsd.zig+1-3
...@@ -771,8 +771,6 @@ pub const AUTH = struct {...@@ -771,8 +771,6 @@ pub const AUTH = struct {
771pub const tcflag_t = c_uint;771pub const tcflag_t = c_uint;
772pub const speed_t = c_uint;772pub const speed_t = c_uint;
773773
774pub const NCCS = 20;
775
776// Input flags - software input processing774// Input flags - software input processing
777pub const IGNBRK: tcflag_t = 0x00000001; // ignore BREAK condition775pub const IGNBRK: tcflag_t = 0x00000001; // ignore BREAK condition
778pub const BRKINT: tcflag_t = 0x00000002; // map BREAK to SIGINT776pub const BRKINT: tcflag_t = 0x00000002; // map BREAK to SIGINT
...@@ -823,7 +821,7 @@ pub const termios = extern struct {...@@ -823,7 +821,7 @@ pub const termios = extern struct {
823 oflag: tcflag_t, // output flags821 oflag: tcflag_t, // output flags
824 cflag: tcflag_t, // control flags822 cflag: tcflag_t, // control flags
825 lflag: tcflag_t, // local flags823 lflag: tcflag_t, // local flags
826 cc: [NCCS]std.c.cc_t, // control chars824 cc: [std.c.NCCS]std.c.cc_t, // control chars
827 ispeed: c_int, // input speed825 ispeed: c_int, // input speed
828 ospeed: c_int, // output speed826 ospeed: c_int, // output speed
829};827};
lib/std/c/solaris.zig+1-3
...@@ -701,14 +701,12 @@ pub const SEEK = struct {...@@ -701,14 +701,12 @@ pub const SEEK = struct {
701pub const tcflag_t = c_uint;701pub const tcflag_t = c_uint;
702pub const speed_t = c_uint;702pub const speed_t = c_uint;
703703
704pub const NCCS = 19;
705
706pub const termios = extern struct {704pub const termios = extern struct {
707 c_iflag: tcflag_t,705 c_iflag: tcflag_t,
708 c_oflag: tcflag_t,706 c_oflag: tcflag_t,
709 c_cflag: tcflag_t,707 c_cflag: tcflag_t,
710 c_lflag: tcflag_t,708 c_lflag: tcflag_t,
711 c_cc: [NCCS]std.c.cc_t,709 c_cc: [std.c.NCCS]std.c.cc_t,
712};710};
713711
714fn tioc(t: u16, num: u8) u16 {712fn tioc(t: u16, num: u8) u16 {
lib/std/os/linux.zig+4-1
...@@ -5006,7 +5006,10 @@ pub const rusage = extern struct {...@@ -5006,7 +5006,10 @@ pub const rusage = extern struct {
50065006
5007pub const speed_t = u32;5007pub const speed_t = u32;
50085008
5009pub const NCCS = 32;5009pub const NCCS = switch (native_arch) {
5010 .powerpc, .powerpcle, .powerpc64, .powerpc64le => 19,
5011 else => 32,
5012};
50105013
5011pub const B0 = 0o0000000;5014pub const B0 = 0o0000000;
5012pub const B50 = 0o0000001;5015pub const B50 = 0o0000001;