std.c.NCSS: consolidate and correct

This commit is contained in:
Andrew Kelley 2024-02-12 15:52:13 -07:00
parent 9bdf1ebe36
commit 9a64318554
8 changed files with 19 additions and 19 deletions

View File

@ -781,6 +781,15 @@ pub const cc_t = switch (native_os) {
else => @compileError("target libc does not have cc_t"),
};
pub const NCCS = switch (native_os) {
.linux => std.os.linux.NCCS,
.macos, .ios, .tvos, .watchos, .freebsd, .kfreebsd, .netbsd, .openbsd, .dragonfly => 20,
.haiku => 11,
.solaris, .illumos => 19,
.emscripten, .wasi => 32,
else => @compileError("target libc does not have NCCS"),
};
pub const whence_t = if (native_os == .wasi) std.os.wasi.whence_t else c_int;
// Unix-like systems

View File

@ -2692,8 +2692,6 @@ pub const SHUT = struct {
pub const RDWR = 2;
};
pub const NCCS = 20; // 2 spares (7, 19)
pub const speed_t = u64;
pub const tcflag_t = u64;
@ -2836,7 +2834,7 @@ pub const termios = extern struct {
oflag: tcflag_t, // output flags
cflag: tcflag_t, // control flags
lflag: tcflag_t, // local flags
cc: [NCCS]std.c.cc_t, // control chars
cc: [std.c.NCCS]std.c.cc_t, // control chars
ispeed: speed_t align(8), // input speed
ospeed: speed_t, // output speed
};

View File

@ -182,15 +182,13 @@ pub const dirent = struct {
pub const speed_t = u32;
pub const tcflag_t = u32;
pub const NCCS = 32;
pub const termios = extern struct {
iflag: tcflag_t,
oflag: tcflag_t,
cflag: tcflag_t,
lflag: tcflag_t,
line: std.c.cc_t,
cc: [NCCS]std.c.cc_t,
cc: [std.c.NCCS]std.c.cc_t,
ispeed: speed_t,
ospeed: speed_t,
};

View File

@ -953,8 +953,6 @@ pub const directory_which = enum(c_int) {
pub const speed_t = u8;
pub const tcflag_t = u32;
pub const NCCS = 11;
pub const termios = extern struct {
c_iflag: tcflag_t,
c_oflag: tcflag_t,
@ -963,7 +961,7 @@ pub const termios = extern struct {
c_line: std.c.cc_t,
c_ispeed: speed_t,
c_ospeed: speed_t,
cc_t: [NCCS]std.c.cc_t,
cc_t: [std.c.NCCS]std.c.cc_t,
};
pub const MSG_NOSIGNAL = 0x0800;

View File

@ -853,14 +853,12 @@ pub const CHWFLOW: tcflag_t = (MDMBUF | CRTSCTS | CDTRCTS); // all types of hw f
pub const tcflag_t = c_uint;
pub const speed_t = c_uint;
pub const NCCS = 20;
pub const termios = extern struct {
iflag: tcflag_t, // input flags
oflag: tcflag_t, // output flags
cflag: tcflag_t, // control flags
lflag: tcflag_t, // local flags
cc: [NCCS]std.c.cc_t, // control chars
cc: [std.c.NCCS]std.c.cc_t, // control chars
ispeed: c_int, // input speed
ospeed: c_int, // output speed
};

View File

@ -771,8 +771,6 @@ pub const AUTH = struct {
pub const tcflag_t = c_uint;
pub const speed_t = c_uint;
pub const NCCS = 20;
// Input flags - software input processing
pub const IGNBRK: tcflag_t = 0x00000001; // ignore BREAK condition
pub const BRKINT: tcflag_t = 0x00000002; // map BREAK to SIGINT
@ -823,7 +821,7 @@ pub const termios = extern struct {
oflag: tcflag_t, // output flags
cflag: tcflag_t, // control flags
lflag: tcflag_t, // local flags
cc: [NCCS]std.c.cc_t, // control chars
cc: [std.c.NCCS]std.c.cc_t, // control chars
ispeed: c_int, // input speed
ospeed: c_int, // output speed
};

View File

@ -701,14 +701,12 @@ pub const SEEK = struct {
pub const tcflag_t = c_uint;
pub const speed_t = c_uint;
pub const NCCS = 19;
pub const termios = extern struct {
c_iflag: tcflag_t,
c_oflag: tcflag_t,
c_cflag: tcflag_t,
c_lflag: tcflag_t,
c_cc: [NCCS]std.c.cc_t,
c_cc: [std.c.NCCS]std.c.cc_t,
};
fn tioc(t: u16, num: u8) u16 {

View File

@ -5006,7 +5006,10 @@ pub const rusage = extern struct {
pub const speed_t = u32;
pub const NCCS = 32;
pub const NCCS = switch (native_arch) {
.powerpc, .powerpcle, .powerpc64, .powerpc64le => 19,
else => 32,
};
pub const B0 = 0o0000000;
pub const B50 = 0o0000001;