Commit 0c88f927f1
Changed files (10)
lib/std/c/darwin.zig
@@ -2692,9 +2692,6 @@ pub const SHUT = struct {
pub const RDWR = 2;
};
-pub const speed_t = u64;
-pub const tcflag_t = u64;
-
pub const IGNBRK: tcflag_t = 0x00000001; // ignore BREAK condition
pub const BRKINT: tcflag_t = 0x00000002; // map BREAK to SIGINTR
pub const IGNPAR: tcflag_t = 0x00000004; // ignore (discard) parity errors
@@ -2829,16 +2826,6 @@ pub const TCOON: tcflag_t = 2;
pub const TCIOFF: tcflag_t = 3;
pub const TCION: tcflag_t = 4;
-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: [std.c.NCCS]std.c.cc_t, // control chars
- ispeed: speed_t align(8), // input speed
- ospeed: speed_t, // output speed
-};
-
pub const winsize = extern struct {
ws_row: u16,
ws_col: u16,
lib/std/c/emscripten.zig
@@ -178,17 +178,3 @@ pub const dirent = struct {
type: u8,
name: [256]u8,
};
-
-pub const speed_t = u32;
-pub const tcflag_t = u32;
-
-pub const termios = extern struct {
- iflag: tcflag_t,
- oflag: tcflag_t,
- cflag: tcflag_t,
- lflag: tcflag_t,
- line: std.c.cc_t,
- cc: [std.c.NCCS]std.c.cc_t,
- ispeed: speed_t,
- ospeed: speed_t,
-};
lib/std/c/haiku.zig
@@ -950,18 +950,4 @@ pub const directory_which = enum(c_int) {
_,
};
-pub const speed_t = u8;
-pub const tcflag_t = u32;
-
-pub const termios = extern struct {
- c_iflag: tcflag_t,
- c_oflag: tcflag_t,
- c_cflag: tcflag_t,
- c_lflag: tcflag_t,
- c_line: std.c.cc_t,
- c_ispeed: speed_t,
- c_ospeed: speed_t,
- cc_t: [std.c.NCCS]std.c.cc_t,
-};
-
pub const MSG_NOSIGNAL = 0x0800;
lib/std/c/linux.zig
@@ -85,8 +85,6 @@ pub const sigset_t = linux.sigset_t;
pub const sockaddr = linux.sockaddr;
pub const socklen_t = linux.socklen_t;
pub const stack_t = linux.stack_t;
-pub const tcflag_t = linux.tcflag_t;
-pub const termios = linux.termios;
pub const time_t = linux.time_t;
pub const timespec = linux.timespec;
pub const timeval = linux.timeval;
lib/std/c/netbsd.zig
@@ -850,19 +850,6 @@ pub const CDTRCTS: tcflag_t = 0x00020000; // DTR/CTS full-duplex flow control
pub const MDMBUF: tcflag_t = 0x00100000; // DTR/DCD hardware flow control
pub const CHWFLOW: tcflag_t = (MDMBUF | CRTSCTS | CDTRCTS); // all types of hw flow control
-pub const tcflag_t = c_uint;
-pub const speed_t = c_uint;
-
-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: [std.c.NCCS]std.c.cc_t, // control chars
- ispeed: c_int, // input speed
- ospeed: c_int, // output speed
-};
-
// Commands passed to tcsetattr() for setting the termios structure.
pub const TCSA = struct {
pub const NOW = 0; // make change immediate
lib/std/c/openbsd.zig
@@ -768,9 +768,6 @@ pub const AUTH = struct {
pub const ALLOW: c_int = (OKAY | ROOTOKAY | SECURE);
};
-pub const tcflag_t = c_uint;
-pub const speed_t = c_uint;
-
// Input flags - software input processing
pub const IGNBRK: tcflag_t = 0x00000001; // ignore BREAK condition
pub const BRKINT: tcflag_t = 0x00000002; // map BREAK to SIGINT
@@ -816,16 +813,6 @@ pub const CCTS_OFLOW: tcflag_t = CRTSCTS; // XXX compat
pub const MDMBUF: tcflag_t = 0x00100000; // DTR/DCD hardware flow control
pub const CHWFLOW: tcflag_t = (MDMBUF | CRTSCTS); // all types of hw flow control
-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: [std.c.NCCS]std.c.cc_t, // control chars
- ispeed: c_int, // input speed
- ospeed: c_int, // output speed
-};
-
// Commands passed to tcsetattr() for setting the termios structure.
pub const TCSA = struct {
pub const NOW = 0; // make change immediate
lib/std/c/solaris.zig
@@ -698,17 +698,6 @@ pub const SEEK = struct {
pub const HOLE = 4;
};
-pub const tcflag_t = c_uint;
-pub const speed_t = c_uint;
-
-pub const termios = extern struct {
- c_iflag: tcflag_t,
- c_oflag: tcflag_t,
- c_cflag: tcflag_t,
- c_lflag: tcflag_t,
- c_cc: [std.c.NCCS]std.c.cc_t,
-};
-
fn tioc(t: u16, num: u8) u16 {
return (t << 8) | num;
}
lib/std/os/linux.zig
@@ -5005,6 +5005,7 @@ 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,
@@ -5044,88 +5045,7 @@ 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;
- },
- .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;
- },
- .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;
- },
- 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;
- },
-};
-
-pub const tc_iflag_t = packed struct (u32) {
+pub const tc_iflag_t = packed struct(u32) {
IGNBRK: bool = false,
BRKINT: bool = false,
IGNPAR: bool = false,
@@ -5145,42 +5065,42 @@ pub const tc_iflag_t = packed struct (u32) {
};
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,
+ .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,
+ VWERASE = 14,
+ VLNEXT = 15,
+ VEOF = 16,
+ VEOL = 17,
},
- .powerpc, .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,
+ .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,
+ VSUSP = 12,
+ VSTART = 13,
+ VSTOP = 14,
+ VLNEXT = 15,
VDISCARD = 16,
},
else => enum(u8) {
@@ -5246,15 +5166,27 @@ pub const TCSA = enum(c_uint) {
_,
};
-pub const termios = 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 termios = switch (native_arch) {
+ .powerpc, .powerpcle, .powerpc64, .powerpc64le => extern struct {
+ iflag: tcflag_t,
+ oflag: tcflag_t,
+ cflag: tcflag_t,
+ lflag: tcflag_t,
+ cc: [NCCS]cc_t,
+ line: cc_t,
+ ispeed: speed_t,
+ ospeed: speed_t,
+ },
+ else => 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 SIOCGIFINDEX = 0x8933;
lib/std/c.zig
@@ -790,6 +790,84 @@ pub const NCCS = switch (native_os) {
else => @compileError("target libc does not have NCCS"),
};
+pub const termios = switch (native_os) {
+ .linux => std.os.linux.termios,
+ .macos, .ios, .tvos, .watchos => extern struct {
+ iflag: tcflag_t,
+ oflag: tcflag_t,
+ cflag: tcflag_t,
+ lflag: tcflag_t,
+ cc: [NCCS]cc_t,
+ ispeed: speed_t align(8),
+ ospeed: speed_t,
+ },
+ .freebsd, .kfreebsd, .netbsd, .dragonfly, .openbsd => extern struct {
+ iflag: tcflag_t,
+ oflag: tcflag_t,
+ cflag: tcflag_t,
+ lflag: tcflag_t,
+ cc: [NCCS]cc_t,
+ ispeed: speed_t,
+ ospeed: speed_t,
+ },
+ .haiku => extern struct {
+ iflag: tcflag_t,
+ oflag: tcflag_t,
+ cflag: tcflag_t,
+ lflag: tcflag_t,
+ line: cc_t,
+ ispeed: speed_t,
+ ospeed: speed_t,
+ cc: [NCCS]cc_t,
+ },
+ .solaris, .illumos => extern struct {
+ iflag: tcflag_t,
+ oflag: tcflag_t,
+ cflag: tcflag_t,
+ lflag: tcflag_t,
+ cc: [NCCS]cc_t,
+ },
+ .emscripten, .wasi => extern struct {
+ iflag: tcflag_t,
+ oflag: tcflag_t,
+ cflag: tcflag_t,
+ lflag: tcflag_t,
+ line: std.c.cc_t,
+ cc: [NCCS]cc_t,
+ ispeed: speed_t,
+ ospeed: speed_t,
+ },
+ else => @compileError("target libc does not have termios"),
+};
+
+pub const tcflag_t = switch (native_os) {
+ .linux => std.os.linux.tcflag_t,
+ .macos, .ios, .tvos, .watchos => u64,
+ .freebsd, .kfreebsd => c_uint,
+ .netbsd => c_uint,
+ .dragonfly => c_uint,
+ .openbsd => c_uint,
+ .haiku => u32,
+ .solaris, .illumos => c_uint,
+ .emscripten => u32,
+ .wasi => c_uint,
+ else => @compileError("target libc does not have tcflag_t"),
+};
+
+pub const speed_t = switch (native_os) {
+ .linux => std.os.linux.speed_t,
+ .macos, .ios, .tvos, .watchos => u64,
+ .freebsd, .kfreebsd => c_uint,
+ .netbsd => c_uint,
+ .dragonfly => c_uint,
+ .openbsd => c_uint,
+ .haiku => u8,
+ .solaris, .illumos => c_uint,
+ .emscripten => u32,
+ .wasi => c_uint,
+ else => @compileError("target libc does not have speed_t"),
+};
+
pub const whence_t = if (native_os == .wasi) std.os.wasi.whence_t else c_int;
// Unix-like systems
lib/std/os.zig
@@ -106,6 +106,7 @@ pub const MFD = system.MFD;
pub const MMAP2_UNIT = system.MMAP2_UNIT;
pub const MSG = system.MSG;
pub const NAME_MAX = system.NAME_MAX;
+pub const NCCS = system.NCCS;
pub const O = system.O;
pub const PATH_MAX = system.PATH_MAX;
pub const POLL = system.POLL;
@@ -172,6 +173,7 @@ pub const siginfo_t = system.siginfo_t;
pub const sigset_t = system.sigset_t;
pub const sockaddr = system.sockaddr;
pub const socklen_t = system.socklen_t;
+pub const speed_t = system.speed_t;
pub const stack_t = system.stack_t;
pub const tcflag_t = system.tcflag_t;
pub const termios = system.termios;