Skip to content

Commit 7204ecc

Browse files
authored
Merge pull request #18945 from mikdusan/issue-18942
std.os.termios: fix tc flag types for macos
2 parents 6fe90a9 + 2ff64c7 commit 7204ecc

File tree

5 files changed

+55
-19
lines changed

5 files changed

+55
-19
lines changed

lib/std/c.zig

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ pub const termios = switch (native_os) {
842842

843843
pub const tc_iflag_t = switch (native_os) {
844844
.linux => std.os.linux.tc_iflag_t,
845-
.macos, .ios, .tvos, .watchos => packed struct(u32) {
845+
.macos, .ios, .tvos, .watchos => packed struct(u64) {
846846
IGNBRK: bool = false,
847847
BRKINT: bool = false,
848848
IGNPAR: bool = false,
@@ -858,7 +858,7 @@ pub const tc_iflag_t = switch (native_os) {
858858
_12: u1 = 0,
859859
IMAXBEL: bool = false,
860860
IUTF8: bool = false,
861-
_: u17 = 0,
861+
_: u49 = 0,
862862
},
863863
.netbsd, .freebsd, .kfreebsd, .dragonfly => packed struct(u32) {
864864
IGNBRK: bool = false,
@@ -952,7 +952,7 @@ pub const tc_iflag_t = switch (native_os) {
952952

953953
pub const tc_oflag_t = switch (native_os) {
954954
.linux => std.os.linux.tc_oflag_t,
955-
.macos, .ios, .tvos, .watchos => packed struct(u32) {
955+
.macos, .ios, .tvos, .watchos => packed struct(u64) {
956956
OPOST: bool = false,
957957
ONLCR: bool = false,
958958
OXTABS: bool = false,
@@ -968,7 +968,7 @@ pub const tc_oflag_t = switch (native_os) {
968968
BSDLY: u1 = 0,
969969
VTDLY: u1 = 0,
970970
OFDEL: bool = false,
971-
_: u14 = 0,
971+
_: u46 = 0,
972972
},
973973
.netbsd => packed struct(u32) {
974974
OPOST: bool = false,
@@ -1049,7 +1049,7 @@ pub const CSIZE = switch (native_os) {
10491049

10501050
pub const tc_cflag_t = switch (native_os) {
10511051
.linux => std.os.linux.tc_cflag_t,
1052-
.macos, .ios, .tvos, .watchos => packed struct(u32) {
1052+
.macos, .ios, .tvos, .watchos => packed struct(u64) {
10531053
CIGNORE: bool = false,
10541054
_1: u5 = 0,
10551055
CSTOPB: bool = false,
@@ -1066,7 +1066,7 @@ pub const tc_cflag_t = switch (native_os) {
10661066
CDTR_IFLOW: bool = false,
10671067
CDSR_OFLOW: bool = false,
10681068
CCAR_OFLOW: bool = false,
1069-
_: u11 = 0,
1069+
_: u43 = 0,
10701070
},
10711071
.freebsd, .kfreebsd => packed struct(u32) {
10721072
CIGNORE: bool = false,
@@ -1185,7 +1185,31 @@ pub const tc_cflag_t = switch (native_os) {
11851185

11861186
pub const tc_lflag_t = switch (native_os) {
11871187
.linux => std.os.linux.tc_lflag_t,
1188-
.macos, .ios, .tvos, .watchos, .netbsd, .freebsd, .kfreebsd, .dragonfly => packed struct(u32) {
1188+
.macos, .ios, .tvos, .watchos => packed struct(u64) {
1189+
ECHOKE: bool = false,
1190+
ECHOE: bool = false,
1191+
ECHOK: bool = false,
1192+
ECHO: bool = false,
1193+
ECHONL: bool = false,
1194+
ECHOPRT: bool = false,
1195+
ECHOCTL: bool = false,
1196+
ISIG: bool = false,
1197+
ICANON: bool = false,
1198+
ALTWERASE: bool = false,
1199+
IEXTEN: bool = false,
1200+
EXTPROC: bool = false,
1201+
_12: u10 = 0,
1202+
TOSTOP: bool = false,
1203+
FLUSHO: bool = false,
1204+
_24: u1 = 0,
1205+
NOKERNINFO: bool = false,
1206+
_26: u3 = 0,
1207+
PENDIN: bool = false,
1208+
_30: u1 = 0,
1209+
NOFLSH: bool = false,
1210+
_: u32 = 0,
1211+
},
1212+
.netbsd, .freebsd, .kfreebsd, .dragonfly => packed struct(u32) {
11891213
ECHOKE: bool = false,
11901214
ECHOE: bool = false,
11911215
ECHOK: bool = false,

lib/std/c/dragonfly.zig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,13 @@ pub const NOTE_FFCTRLMASK = 3221225472;
557557
pub const NOTE_FFCOPY = 3221225472;
558558
pub const NOTE_PCTRLMASK = 4026531840;
559559

560+
pub const TCSA = enum(c_uint) {
561+
NOW,
562+
DRAIN,
563+
FLUSH,
564+
_,
565+
};
566+
560567
pub const stack_t = extern struct {
561568
sp: [*]u8,
562569
size: isize,

lib/std/c/freebsd.zig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,13 @@ pub const T = struct {
11531153
pub const IOCSIG = 0x2004745f;
11541154
};
11551155

1156+
pub const TCSA = enum(c_uint) {
1157+
NOW,
1158+
DRAIN,
1159+
FLUSH,
1160+
_,
1161+
};
1162+
11561163
pub const winsize = extern struct {
11571164
ws_row: u16,
11581165
ws_col: u16,

lib/std/c/netbsd.zig

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -806,12 +806,11 @@ pub const T = struct {
806806
pub const IOCXMTFRAME = 0x80087444;
807807
};
808808

809-
// Commands passed to tcsetattr() for setting the termios structure.
810-
pub const TCSA = struct {
811-
pub const NOW = 0; // make change immediate
812-
pub const DRAIN = 1; // drain output, then chage
813-
pub const FLUSH = 2; // drain output, flush input
814-
pub const SOFT = 0x10; // flag - don't alter h.w. state
809+
pub const TCSA = enum(c_uint) {
810+
NOW,
811+
DRAIN,
812+
FLUSH,
813+
_,
815814
};
816815

817816
pub const TCIFLUSH = 1;

lib/std/c/openbsd.zig

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -768,12 +768,11 @@ pub const AUTH = struct {
768768
pub const ALLOW: c_int = (OKAY | ROOTOKAY | SECURE);
769769
};
770770

771-
// Commands passed to tcsetattr() for setting the termios structure.
772-
pub const TCSA = struct {
773-
pub const NOW = 0; // make change immediate
774-
pub const DRAIN = 1; // drain output, then change
775-
pub const FLUSH = 2; // drain output, flush input
776-
pub const SOFT = 0x10; // flag - don't alter h.w. state
771+
pub const TCSA = enum(c_uint) {
772+
NOW,
773+
DRAIN,
774+
FLUSH,
775+
_,
777776
};
778777

779778
pub const TCIFLUSH = 1;

0 commit comments

Comments
 (0)