From b58ffd4bcbf0f44759d8971bdb8b7c7a0bfcd3ca Mon Sep 17 00:00:00 2001 From: Book-reader Date: Tue, 5 Aug 2025 23:21:02 +1200 Subject: [PATCH 1/5] improve & fix libc termios bindings --- lib/std/libc/os/posix.c3 | 309 ++++++++++++++++++++++++--------------- lib/std/libc/termios.c3 | 14 +- 2 files changed, 200 insertions(+), 123 deletions(-) diff --git a/lib/std/libc/os/posix.c3 b/lib/std/libc/os/posix.c3 index 2efa1a256..b7122877c 100644 --- a/lib/std/libc/os/posix.c3 +++ b/lib/std/libc/os/posix.c3 @@ -64,116 +64,194 @@ extern fn CInt sigaction(CInt signum, Sigaction *action, Sigaction *oldaction); module libc::termios @if(env::LIBC &&& env::POSIX); -typedef Cc = char; -typedef Speed = CUInt; -typedef Tcflags = CUInt; -typedef Tcactions = CInt; - -const Tcactions TCOOFF = 0; -const Tcactions TCOON = 1; -const Tcactions TCIOFF = 2; -const Tcactions TCION = 3; -const Tcactions TCIFLUSH = 0; -const Tcactions TCOFLUSH = 1; -const Tcactions TCIOFLUSH = 2; -const Tcactions TCSANOW = 0; -const Tcactions TCSADRAIN = 1; -const Tcactions TCSAFLUSH = 2; -const Speed B0 = 0000000; -const Speed B50 = 0000001; -const Speed B75 = 0000002; -const Speed B110 = 0000003; -const Speed B134 = 0000004; -const Speed B150 = 0000005; -const Speed B200 = 0000006; -const Speed B300 = 0000007; -const Speed B600 = 0000010; -const Speed B1200 = 0000011; -const Speed B1800 = 0000012; -const Speed B2400 = 0000013; -const Speed B4800 = 0000014; -const Speed B9600 = 0000015; -const Speed B19200 = 0000016; -const Speed B38400 = 0000017; -const Speed B57600 = 0010001; -const Speed B115200 = 0010002; -const Speed B230400 = 0010003; -const Speed B460800 = 0010004; -const Speed B500000 = 0010005; -const Speed B576000 = 0010006; -const Speed B921600 = 0010007; -const Speed B1000000 = 0010010; -const Speed B1152000 = 0010011; -const Speed B1500000 = 0010012; -const Speed B2000000 = 0010013; -const Speed B2500000 = 0010014; -const Speed B3000000 = 0010015; -const Speed B3500000 = 0010016; -const Speed B4000000 = 0010017; -const Speed MAX_BAUD = B4000000; -const Tcflags VINTR = 0; -const Tcflags VQUIT = 1; -const Tcflags VERASE = 2; -const Tcflags VKILL = 3; -const Tcflags VEOF = 4; -const Tcflags VTIME = 5; -const Tcflags VMIN = 6; -const Tcflags VSWTC = 7; -const Tcflags VSTART = 8; -const Tcflags VSTOP = 9; -const Tcflags VSUSP = 10; -const Tcflags VEOL = 11; -const Tcflags VREPRINT = 12; -const Tcflags VDISCARD = 13; -const Tcflags VWERASE = 14; -const Tcflags VLNEXT = 15; -const Tcflags VEOL2 = 16; -const Tcflags ISIG = 0000001; -const Tcflags ICANON = 0000002; -const Tcflags ECHO = 0000010; -const Tcflags ECHOE = 0000020; -const Tcflags ECHOK = 0000040; -const Tcflags ECHONL = 0000100; -const Tcflags NOFLSH = 0000200; -const Tcflags TOSTOP = 0000400; -const Tcflags IEXTEN = 0100000; -const Tcflags CSIZE = 0000060; -const Tcflags CS5 = 0000000; -const Tcflags CS6 = 0000020; -const Tcflags CS7 = 0000040; -const Tcflags CS8 = 0000060; -const Tcflags CSTOPB = 0000100; -const Tcflags CREAD = 0000200; -const Tcflags PARENB = 0000400; -const Tcflags PARODD = 0001000; -const Tcflags HUPCL = 0002000; -const Tcflags CLOCAL = 0004000; -const Tcflags OPOST = 0000001; -const Tcflags OLCUC = 0000002; -const Tcflags ONLCR = 0000004; -const Tcflags OCRNL = 0000010; -const Tcflags ONOCR = 0000020; -const Tcflags ONLRET = 0000040; -const Tcflags OFILL = 0000100; -const Tcflags OFDEL = 0000200; -const Tcflags VTDLY = 0040000; -const Tcflags VT0 = 0000000; -const Tcflags VT1 = 0040000; -const Tcflags IGNBRK = 0000001; -const Tcflags BRKINT = 0000002; -const Tcflags IGNPAR = 0000004; -const Tcflags PARMRK = 0000010; -const Tcflags INPCK = 0000020; -const Tcflags ISTRIP = 0000040; -const Tcflags INLCR = 0000100; -const Tcflags IGNCR = 0000200; -const Tcflags ICRNL = 0000400; -const Tcflags IUCLC = 0001000; -const Tcflags IXON = 0002000; -const Tcflags IXANY = 0004000; -const Tcflags IXOFF = 0010000; -const Tcflags IMAXBEL = 0020000; -const Tcflags IUTF8 = 0040000; +bitstruct Tc_iflags : CUInt +{ + bool ignbrk; + bool brkint; + bool ignpar; + bool parmrk; + bool inpck; + bool istrip; + bool inlcr; + bool igncr; + bool icrnl; + bool iuclc; + bool ixon; + bool ixany; + bool ixoff; + bool imaxbel; + bool iutf8; +} + +bitstruct Tc_oflags : CUInt +{ + bool opost : 0; + bool olcuc : 1; + bool onlcr : 2; + bool ocrnl : 3; + bool onocr : 4; + bool onlret : 5; + bool ofill : 6; + bool ofdel : 7; + T_nldly nldly : 8..8; + T_crdly crdly : 9..10; + T_tabdly tabdly : 11..12; + T_bsdly bsdly : 13..13; + T_vtdly vtdly : 14..14; + T_ffdly ffdly : 15..15; +} + +bitstruct Tc_cflags : CUInt +{ + T_csize csize : 4..5; + bool cstopb : 6; + bool creadb : 7; + bool parenb : 8; + bool parodd : 9; + bool hupcl : 10; + bool clocal : 11; + bool addrb : 29; +} + +bitstruct Tc_lflags : CUInt +{ + bool isig : 0; + bool icanon : 1; + bool xcase : 2; + bool echo : 3; + bool echoe : 4; + bool echok : 5; + bool echonl : 6; + bool noflsh : 7; + bool tostop : 8; + bool echoctl : 9; + bool echoprt : 10; + bool echoke : 11; + bool flusho : 12; + bool pendin : 14; + bool iexten : 15; + bool extproc : 16; +} + +enum T_nldly : const char +{ + NL0 = 0b0, + NL1 = 0b1, +} + +enum T_crdly : const char +{ + CR0 = 0b00, + CR1 = 0b01, + CR2 = 0b10, + CR3 = 0b11, +} + +enum T_tabdly : const char +{ + TAB0 = 0b00, + TAB1 = 0b01, + TAB2 = 0b10, + TAB3 = 0b11, + XTABS = TAB3, +} + +enum T_bsdly : const char +{ + BS0 = 0b0, + BS1 = 0b1, +} + +enum T_ffdly : const char +{ + FF0 = 0b0, + FF1 = 0b1, +} + +enum T_vtdly : const char +{ + VT0 = 0b0, + VT1 = 0b1, +} + +enum T_csize : const char +{ + CS5 = 0b00, + CS6 = 0b01, + CS7 = 0b10, + CS8 = 0b11, +} + +enum Speed : const CUInt +{ + B0 = 0o0000000, + B50 = 0o0000001, + B75 = 0o0000002, + B110 = 0o0000003, + B134 = 0o0000004, + B150 = 0o0000005, + B200 = 0o0000006, + B300 = 0o0000007, + B600 = 0o0000010, + B1200 = 0o0000011, + B1800 = 0o0000012, + B2400 = 0o0000013, + B4800 = 0o0000014, + B9600 = 0o0000015, + B19200 = 0o0000016, + B38400 = 0o0000017, + B57600 = 0o0010001, + B115200 = 0o0010002, + B230400 = 0o0010003, + B460800 = 0o0010004, + B500000 = 0o0010005, + B576000 = 0o0010006, + B921600 = 0o0010007, + B1000000 = 0o0010010, + B1152000 = 0o0010011, + B1500000 = 0o0010012, + B2000000 = 0o0010013, + B2500000 = 0o0010014, + B3000000 = 0o0010015, + B3500000 = 0o0010016, + B4000000 = 0o0010017, + MAX_BAUD = B4000000, +} + +enum Cc : const char +{ + VINTR = 0, + VQUIT = 1, + VERASE = 2, + VKILL = 3, + VEOF = 4, + VTIME = 5, + VMIN = 6, + VSWTC = 7, + VSTART = 8, + VSTOP = 9, + VSUSP = 10, + VEOL = 11, + VREPRINT = 12, + VDISCARD = 13, + VWERASE = 14, + VLNEXT = 15, + VEOL2 = 16, +} + +enum Tcactions : const CInt +{ + TCOOFF = 0, + TCOON = 1, + TCIOFF = 2, + TCION = 3, + TCIFLUSH = 0, + TCOFLUSH = 1, + TCIOFLUSH = 2, + TCSANOW = 0, + TCSADRAIN = 1, + TCSAFLUSH = 2, +} extern fn CInt tcgetattr(Fd fd, Termios* self); extern fn CInt tcsetattr(Fd fd, Tcactions optional_actions, Termios* self); @@ -189,13 +267,12 @@ extern fn CInt cfsetispeed(Termios* self, Speed speed); const CInt NCCS = 32; struct Termios { - Tcflags c_iflag; - Tcflags c_oflag; - Tcflags c_cflag; - Tcflags c_lflag; + Tc_iflags c_iflag; + Tc_oflags c_oflag; + Tc_cflags c_cflag; + Tc_lflags c_lflag; Cc c_line; Cc[NCCS] c_cc; Speed c_ispeed; Speed c_ospeed; -} - +} diff --git a/lib/std/libc/termios.c3 b/lib/std/libc/termios.c3 index b1730db2b..a116eb827 100644 --- a/lib/std/libc/termios.c3 +++ b/lib/std/libc/termios.c3 @@ -1,15 +1,15 @@ module libc::termios @if(env::LIBC &&& env::POSIX); -fn int sendBreak(Fd fd, int duration) => tcsendbreak(fd, duration); +fn int send_break(Fd fd, int duration) => tcsendbreak(fd, duration); fn int drain(Fd fd) => tcdrain(fd); fn int flush(Fd fd, int queue_selector) => tcflush(fd, queue_selector); fn int flow(Fd fd, int action) => tcflow(fd, action); -fn Speed Termios.getOSpeed(Termios* self) => cfgetospeed(self); -fn Speed Termios.getISpeed(Termios* self) => cfgetispeed(self); -fn int Termios.setOSpeed(Termios* self, Speed speed) => cfsetospeed(self, speed); -fn int Termios.setISpeed(Termios* self, Speed speed) => cfsetispeed(self, speed); -fn int Termios.getAttr(Termios* self, Fd fd) => tcgetattr(fd, self); -fn int Termios.setAttr(Termios* self, Fd fd, Tcactions optional_actions) => tcsetattr(fd, optional_actions, self); +fn Speed Termios.get_ospeed(Termios* self) => cfgetospeed(self); +fn Speed Termios.get_ispeed(Termios* self) => cfgetispeed(self); +fn int Termios.set_ospeed(Termios* self, Speed speed) => cfsetospeed(self, speed); +fn int Termios.set_ispeed(Termios* self, Speed speed) => cfsetispeed(self, speed); +fn int Termios.get_attr(Termios* self, Fd fd) => tcgetattr(fd, self); +fn int Termios.set_attr(Termios* self, Fd fd, Tcactions optional_actions) => tcsetattr(fd, optional_actions, self); module libc::termios @if(!env::LIBC ||| !env::POSIX); From 8a8d72d7347fd04ddc1b9ab3b8e8dd5d33887d1b Mon Sep 17 00:00:00 2001 From: Book-reader Date: Wed, 6 Aug 2025 12:37:59 +1200 Subject: [PATCH 2/5] reintroduce old termios flags for backwards compatibility (depends on #2374) --- lib/std/libc/os/posix.c3 | 124 +++++++++++++++++++++++++++++++++++++++ lib/std/libc/termios.c3 | 20 +++++-- 2 files changed, 138 insertions(+), 6 deletions(-) diff --git a/lib/std/libc/os/posix.c3 b/lib/std/libc/os/posix.c3 index b7122877c..9499cbbda 100644 --- a/lib/std/libc/os/posix.c3 +++ b/lib/std/libc/os/posix.c3 @@ -276,3 +276,127 @@ struct Termios Speed c_ispeed; Speed c_ospeed; } + +typedef Tcflags @deprecated = CUInt; + +const Tcactions TCOOFF @deprecated = 0; +const Tcactions TCOON @deprecated = 1; +const Tcactions TCIOFF @deprecated = 2; +const Tcactions TCION @deprecated = 3; +const Tcactions TCIFLUSH @deprecated = 0; +const Tcactions TCOFLUSH @deprecated = 1; +const Tcactions TCIOFLUSH @deprecated = 2; +const Tcactions TCSANOW @deprecated = 0; +const Tcactions TCSADRAIN @deprecated = 1; +const Tcactions TCSAFLUSH @deprecated = 2; +const Speed B0 @deprecated = 0o0000000; +const Speed B50 @deprecated = 0o0000001; +const Speed B75 @deprecated = 0o0000002; +const Speed B110 @deprecated = 0o0000003; +const Speed B134 @deprecated = 0o0000004; +const Speed B150 @deprecated = 0o0000005; +const Speed B200 @deprecated = 0o0000006; +const Speed B300 @deprecated = 0o0000007; +const Speed B600 @deprecated = 0o0000010; +const Speed B1200 @deprecated = 0o0000011; +const Speed B1800 @deprecated = 0o0000012; +const Speed B2400 @deprecated = 0o0000013; +const Speed B4800 @deprecated = 0o0000014; +const Speed B9600 @deprecated = 0o0000015; +const Speed B19200 @deprecated = 0o0000016; +const Speed B38400 @deprecated = 0o0000017; +const Speed B57600 @deprecated = 0o0010001; +const Speed B115200 @deprecated = 0o0010002; +const Speed B230400 @deprecated = 0o0010003; +const Speed B460800 @deprecated = 0o0010004; +const Speed B500000 @deprecated = 0o0010005; +const Speed B576000 @deprecated = 0o0010006; +const Speed B921600 @deprecated = 0o0010007; +const Speed B1000000 @deprecated = 0o0010010; +const Speed B1152000 @deprecated = 0o0010011; +const Speed B1500000 @deprecated = 0o0010012; +const Speed B2000000 @deprecated = 0o0010013; +const Speed B2500000 @deprecated = 0o0010014; +const Speed B3000000 @deprecated = 0o0010015; +const Speed B3500000 @deprecated = 0o0010016; +const Speed B4000000 @deprecated = 0o0010017; +const Speed MAX_BAUD @deprecated = B4000000; +const Tcflags VINTR @deprecated = 0o0; +const Tcflags VQUIT @deprecated = 1; +const Tcflags VERASE @deprecated = 2; +const Tcflags VKILL @deprecated = 3; +const Tcflags VEOF @deprecated = 4; +const Tcflags VTIME @deprecated = 5; +const Tcflags VMIN @deprecated = 6; +const Tcflags VSWTC @deprecated = 7; +const Tcflags VSTART @deprecated = 8; +const Tcflags VSTOP @deprecated = 9; +const Tcflags VSUSP @deprecated = 10; +const Tcflags VEOL @deprecated = 11; +const Tcflags VREPRINT @deprecated = 12; +const Tcflags VDISCARD @deprecated = 13; +const Tcflags VWERASE @deprecated = 14; +const Tcflags VLNEXT @deprecated = 15; +const Tcflags VEOL2 @deprecated = 16; +const Tcflags ISIG @deprecated = 0o0000001; +const Tcflags ICANON @deprecated = 0o0000002; +const Tcflags ECHO @deprecated = 0o0000010; +const Tcflags ECHOE @deprecated = 0o0000020; +const Tcflags ECHOK @deprecated = 0o0000040; +const Tcflags ECHONL @deprecated = 0o0000100; +const Tcflags NOFLSH @deprecated = 0o0000200; +const Tcflags TOSTOP @deprecated = 0o0000400; +const Tcflags IEXTEN @deprecated = 0o0100000; +const Tcflags CSIZE @deprecated = 0o0000060; +const Tcflags CS5 @deprecated = 0o0000000; +const Tcflags CS6 @deprecated = 0o0000020; +const Tcflags CS7 @deprecated = 0o0000040; +const Tcflags CS8 @deprecated = 0o0000060; +const Tcflags CSTOPB @deprecated = 0o0000100; +const Tcflags CREAD @deprecated = 0o0000200; +const Tcflags PARENB @deprecated = 0o0000400; +const Tcflags PARODD @deprecated = 0o0001000; +const Tcflags HUPCL @deprecated = 0o0002000; +const Tcflags CLOCAL @deprecated = 0o0004000; +const Tcflags OPOST @deprecated = 0o0000001; +const Tcflags OLCUC @deprecated = 0o0000002; +const Tcflags ONLCR @deprecated = 0o0000004; +const Tcflags OCRNL @deprecated = 0o0000010; +const Tcflags ONOCR @deprecated = 0o0000020; +const Tcflags ONLRET @deprecated = 0o0000040; +const Tcflags OFILL @deprecated = 0o0000100; +const Tcflags OFDEL @deprecated = 0o0000200; +const Tcflags VTDLY @deprecated = 0o0040000; +const Tcflags VT0 @deprecated = 0o0000000; +const Tcflags VT1 @deprecated = 0o0040000; +const Tcflags IGNBRK @deprecated = 0o0000001; +const Tcflags BRKINT @deprecated = 0o0000002; +const Tcflags IGNPAR @deprecated = 0o0000004; +const Tcflags PARMRK @deprecated = 0o0000010; +const Tcflags INPCK @deprecated = 0o0000020; +const Tcflags ISTRIP @deprecated = 0o0000040; +const Tcflags INLCR @deprecated = 0o0000100; +const Tcflags IGNCR @deprecated = 0o0000200; +const Tcflags ICRNL @deprecated = 0o0000400; +const Tcflags IUCLC @deprecated = 0o0001000; +const Tcflags IXON @deprecated = 0o0002000; +const Tcflags IXANY @deprecated = 0o0004000; +const Tcflags IXOFF @deprecated = 0o0010000; +const Tcflags IMAXBEL @deprecated = 0o0020000; +const Tcflags IUTF8 @deprecated = 0o0040000; + +fn Tc_iflags Tc_iflags.and(self, Tcflags other) @operator(&) @deprecated => (Tc_iflags)(((Tcflags)self) & other); +fn Tc_iflags Tc_iflags.or(self, Tcflags other) @operator(|) @deprecated => (Tc_iflags)(((Tcflags)self) | other); +fn Tc_iflags Tc_iflags.xor(self, Tcflags other) @operator(^) @deprecated => (Tc_iflags)(((Tcflags)self) ^ other); + +fn Tc_oflags Tc_oflags.and(self, Tcflags other) @operator(&) @deprecated => (Tc_oflags)(((Tcflags)self) & other); +fn Tc_oflags Tc_oflags.or(self, Tcflags other) @operator(|) @deprecated => (Tc_oflags)(((Tcflags)self) | other); +fn Tc_oflags Tc_oflags.xor(self, Tcflags other) @operator(^) @deprecated => (Tc_oflags)(((Tcflags)self) ^ other); + +fn Tc_cflags Tc_cflags.and(self, Tcflags other) @operator(&) @deprecated => (Tc_cflags)(((Tcflags)self) & other); +fn Tc_cflags Tc_cflags.or(self, Tcflags other) @operator(|) @deprecated => (Tc_cflags)(((Tcflags)self) | other); +fn Tc_cflags Tc_cflags.xor(self, Tcflags other) @operator(^) @deprecated => (Tc_cflags)(((Tcflags)self) ^ other); + +fn Tc_lflags Tc_lflags.and(self, Tcflags other) @operator(&) @deprecated => (Tc_lflags)(((Tcflags)self) & other); +fn Tc_lflags Tc_lflags.or(self, Tcflags other) @operator(|) @deprecated => (Tc_lflags)(((Tcflags)self) | other); +fn Tc_lflags Tc_lflags.xor(self, Tcflags other) @operator(^) @deprecated => (Tc_lflags)(((Tcflags)self) ^ other); diff --git a/lib/std/libc/termios.c3 b/lib/std/libc/termios.c3 index a116eb827..a860872bf 100644 --- a/lib/std/libc/termios.c3 +++ b/lib/std/libc/termios.c3 @@ -4,12 +4,20 @@ fn int send_break(Fd fd, int duration) => tcsendbreak(fd, duration); fn int drain(Fd fd) => tcdrain(fd); fn int flush(Fd fd, int queue_selector) => tcflush(fd, queue_selector); fn int flow(Fd fd, int action) => tcflow(fd, action); -fn Speed Termios.get_ospeed(Termios* self) => cfgetospeed(self); -fn Speed Termios.get_ispeed(Termios* self) => cfgetispeed(self); -fn int Termios.set_ospeed(Termios* self, Speed speed) => cfsetospeed(self, speed); -fn int Termios.set_ispeed(Termios* self, Speed speed) => cfsetispeed(self, speed); -fn int Termios.get_attr(Termios* self, Fd fd) => tcgetattr(fd, self); -fn int Termios.set_attr(Termios* self, Fd fd, Tcactions optional_actions) => tcsetattr(fd, optional_actions, self); +fn Speed Termios.get_ospeed(&self) => cfgetospeed(self); +fn Speed Termios.get_ispeed(&self) => cfgetispeed(self); +fn int Termios.set_ospeed(&self, Speed speed) => cfsetospeed(self, speed); +fn int Termios.set_ispeed(&self, Speed speed) => cfsetispeed(self, speed); +fn int Termios.get_attr(&self, Fd fd) => tcgetattr(fd, self); +fn int Termios.set_attr(&self, Fd fd, Tcactions optional_actions) => tcsetattr(fd, optional_actions, self); + +fn int sendBreak(Fd fd, int duration) @deprecated => send_break(fd, duration); +fn Speed Termios.getOSpeed(&self) @deprecated => self.get_ospeed(); +fn Speed Termios.getISpeed(&self) @deprecated => self.get_ispeed(); +fn int Termios.setOSpeed(&self, Speed speed) @deprecated => self.set_ospeed(speed); +fn int Termios.setISpeed(&self, Speed speed) @deprecated => self.set_ispeed(speed); +fn int Termios.getAttr(&self, Fd fd) @deprecated => self.get_attr(fd); +fn int Termios.setAttr(&self, Fd fd, Tcactions optional_actions) @deprecated => self.set_attr(fd, optional_actions); module libc::termios @if(!env::LIBC ||| !env::POSIX); From 513fbcfbf40b6132b522bf1f8e7349dcba629fa9 Mon Sep 17 00:00:00 2001 From: Book-reader Date: Wed, 6 Aug 2025 12:50:48 +1200 Subject: [PATCH 3/5] fix always present deprecation warning --- lib/std/libc/os/posix.c3 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/std/libc/os/posix.c3 b/lib/std/libc/os/posix.c3 index 9499cbbda..1d27dbdea 100644 --- a/lib/std/libc/os/posix.c3 +++ b/lib/std/libc/os/posix.c3 @@ -277,7 +277,7 @@ struct Termios Speed c_ospeed; } -typedef Tcflags @deprecated = CUInt; +typedef Tcflags = CUInt; const Tcactions TCOOFF @deprecated = 0; const Tcactions TCOON @deprecated = 1; @@ -321,7 +321,7 @@ const Speed B3000000 @deprecated = 0o0010015; const Speed B3500000 @deprecated = 0o0010016; const Speed B4000000 @deprecated = 0o0010017; const Speed MAX_BAUD @deprecated = B4000000; -const Tcflags VINTR @deprecated = 0o0; +const Tcflags VINTR @deprecated = 0; const Tcflags VQUIT @deprecated = 1; const Tcflags VERASE @deprecated = 2; const Tcflags VKILL @deprecated = 3; From e07440ea0ed6ee0e5da8bdd25a9c94a7b3eb841e Mon Sep 17 00:00:00 2001 From: Book-reader Date: Wed, 6 Aug 2025 21:54:48 +1200 Subject: [PATCH 4/5] update the deprecated termios constants to use bitstructs, fix typo --- lib/std/libc/os/posix.c3 | 145 +++++++++++++++++---------------------- 1 file changed, 64 insertions(+), 81 deletions(-) diff --git a/lib/std/libc/os/posix.c3 b/lib/std/libc/os/posix.c3 index 1d27dbdea..31854a684 100644 --- a/lib/std/libc/os/posix.c3 +++ b/lib/std/libc/os/posix.c3 @@ -105,7 +105,7 @@ bitstruct Tc_cflags : CUInt { T_csize csize : 4..5; bool cstopb : 6; - bool creadb : 7; + bool cread : 7; bool parenb : 8; bool parodd : 9; bool hupcl : 10; @@ -277,8 +277,6 @@ struct Termios Speed c_ospeed; } -typedef Tcflags = CUInt; - const Tcactions TCOOFF @deprecated = 0; const Tcactions TCOON @deprecated = 1; const Tcactions TCIOFF @deprecated = 2; @@ -321,82 +319,67 @@ const Speed B3000000 @deprecated = 0o0010015; const Speed B3500000 @deprecated = 0o0010016; const Speed B4000000 @deprecated = 0o0010017; const Speed MAX_BAUD @deprecated = B4000000; -const Tcflags VINTR @deprecated = 0; -const Tcflags VQUIT @deprecated = 1; -const Tcflags VERASE @deprecated = 2; -const Tcflags VKILL @deprecated = 3; -const Tcflags VEOF @deprecated = 4; -const Tcflags VTIME @deprecated = 5; -const Tcflags VMIN @deprecated = 6; -const Tcflags VSWTC @deprecated = 7; -const Tcflags VSTART @deprecated = 8; -const Tcflags VSTOP @deprecated = 9; -const Tcflags VSUSP @deprecated = 10; -const Tcflags VEOL @deprecated = 11; -const Tcflags VREPRINT @deprecated = 12; -const Tcflags VDISCARD @deprecated = 13; -const Tcflags VWERASE @deprecated = 14; -const Tcflags VLNEXT @deprecated = 15; -const Tcflags VEOL2 @deprecated = 16; -const Tcflags ISIG @deprecated = 0o0000001; -const Tcflags ICANON @deprecated = 0o0000002; -const Tcflags ECHO @deprecated = 0o0000010; -const Tcflags ECHOE @deprecated = 0o0000020; -const Tcflags ECHOK @deprecated = 0o0000040; -const Tcflags ECHONL @deprecated = 0o0000100; -const Tcflags NOFLSH @deprecated = 0o0000200; -const Tcflags TOSTOP @deprecated = 0o0000400; -const Tcflags IEXTEN @deprecated = 0o0100000; -const Tcflags CSIZE @deprecated = 0o0000060; -const Tcflags CS5 @deprecated = 0o0000000; -const Tcflags CS6 @deprecated = 0o0000020; -const Tcflags CS7 @deprecated = 0o0000040; -const Tcflags CS8 @deprecated = 0o0000060; -const Tcflags CSTOPB @deprecated = 0o0000100; -const Tcflags CREAD @deprecated = 0o0000200; -const Tcflags PARENB @deprecated = 0o0000400; -const Tcflags PARODD @deprecated = 0o0001000; -const Tcflags HUPCL @deprecated = 0o0002000; -const Tcflags CLOCAL @deprecated = 0o0004000; -const Tcflags OPOST @deprecated = 0o0000001; -const Tcflags OLCUC @deprecated = 0o0000002; -const Tcflags ONLCR @deprecated = 0o0000004; -const Tcflags OCRNL @deprecated = 0o0000010; -const Tcflags ONOCR @deprecated = 0o0000020; -const Tcflags ONLRET @deprecated = 0o0000040; -const Tcflags OFILL @deprecated = 0o0000100; -const Tcflags OFDEL @deprecated = 0o0000200; -const Tcflags VTDLY @deprecated = 0o0040000; -const Tcflags VT0 @deprecated = 0o0000000; -const Tcflags VT1 @deprecated = 0o0040000; -const Tcflags IGNBRK @deprecated = 0o0000001; -const Tcflags BRKINT @deprecated = 0o0000002; -const Tcflags IGNPAR @deprecated = 0o0000004; -const Tcflags PARMRK @deprecated = 0o0000010; -const Tcflags INPCK @deprecated = 0o0000020; -const Tcflags ISTRIP @deprecated = 0o0000040; -const Tcflags INLCR @deprecated = 0o0000100; -const Tcflags IGNCR @deprecated = 0o0000200; -const Tcflags ICRNL @deprecated = 0o0000400; -const Tcflags IUCLC @deprecated = 0o0001000; -const Tcflags IXON @deprecated = 0o0002000; -const Tcflags IXANY @deprecated = 0o0004000; -const Tcflags IXOFF @deprecated = 0o0010000; -const Tcflags IMAXBEL @deprecated = 0o0020000; -const Tcflags IUTF8 @deprecated = 0o0040000; - -fn Tc_iflags Tc_iflags.and(self, Tcflags other) @operator(&) @deprecated => (Tc_iflags)(((Tcflags)self) & other); -fn Tc_iflags Tc_iflags.or(self, Tcflags other) @operator(|) @deprecated => (Tc_iflags)(((Tcflags)self) | other); -fn Tc_iflags Tc_iflags.xor(self, Tcflags other) @operator(^) @deprecated => (Tc_iflags)(((Tcflags)self) ^ other); - -fn Tc_oflags Tc_oflags.and(self, Tcflags other) @operator(&) @deprecated => (Tc_oflags)(((Tcflags)self) & other); -fn Tc_oflags Tc_oflags.or(self, Tcflags other) @operator(|) @deprecated => (Tc_oflags)(((Tcflags)self) | other); -fn Tc_oflags Tc_oflags.xor(self, Tcflags other) @operator(^) @deprecated => (Tc_oflags)(((Tcflags)self) ^ other); - -fn Tc_cflags Tc_cflags.and(self, Tcflags other) @operator(&) @deprecated => (Tc_cflags)(((Tcflags)self) & other); -fn Tc_cflags Tc_cflags.or(self, Tcflags other) @operator(|) @deprecated => (Tc_cflags)(((Tcflags)self) | other); -fn Tc_cflags Tc_cflags.xor(self, Tcflags other) @operator(^) @deprecated => (Tc_cflags)(((Tcflags)self) ^ other); +const Cc VINTR @deprecated = 0; +const Cc VQUIT @deprecated = 1; +const Cc VERASE @deprecated = 2; +const Cc VKILL @deprecated = 3; +const Cc VEOF @deprecated = 4; +const Cc VTIME @deprecated = 5; +const Cc VMIN @deprecated = 6; +const Cc VSWTC @deprecated = 7; +const Cc VSTART @deprecated = 8; +const Cc VSTOP @deprecated = 9; +const Cc VSUSP @deprecated = 10; +const Cc VEOL @deprecated = 11; +const Cc VREPRINT @deprecated = 12; +const Cc VDISCARD @deprecated = 13; +const Cc VWERASE @deprecated = 14; +const Cc VLNEXT @deprecated = 15; +const Cc VEOL2 @deprecated = 16; +const Tc_lflags ISIG @deprecated = {.isig}; +const Tc_lflags ICANON @deprecated = {.icanon}; +const Tc_lflags ECHO @deprecated = {.echo}; +const Tc_lflags ECHOE @deprecated = {.echoe}; +const Tc_lflags ECHOK @deprecated = {.echok}; +const Tc_lflags ECHONL @deprecated = {.echonl}; +const Tc_lflags NOFLSH @deprecated = {.noflsh}; +const Tc_lflags TOSTOP @deprecated = {.tostop}; +const Tc_lflags IEXTEN @deprecated = {.iexten}; +const Tc_cflags CSIZE @deprecated = {.csize = CS8}; +const Tc_cflags CS5 @deprecated = {.csize = CS5}; +const Tc_cflags CS6 @deprecated = {.csize = CS6}; +const Tc_cflags CS7 @deprecated = {.csize = CS7}; +const Tc_cflags CS8 @deprecated = {.csize = CS8}; +const Tc_cflags CSTOPB @deprecated = {.cstopb}; +const Tc_cflags CREAD @deprecated = {.cread}; +const Tc_cflags PARENB @deprecated = {.parenb}; +const Tc_cflags PARODD @deprecated = {.parodd}; +const Tc_cflags HUPCL @deprecated = {.hupcl}; +const Tc_cflags CLOCAL @deprecated = {.clocal}; +const Tc_oflags OPOST @deprecated = {.opost}; +const Tc_oflags OLCUC @deprecated = {.olcuc}; +const Tc_oflags ONLCR @deprecated = {.onlcr}; +const Tc_oflags OCRNL @deprecated = {.ocrnl}; +const Tc_oflags ONOCR @deprecated = {.onocr}; +const Tc_oflags ONLRET @deprecated = {.onlret}; +const Tc_oflags OFILL @deprecated = {.ofill}; +const Tc_oflags OFDEL @deprecated = {.ofdel}; +const Tc_oflags VTDLY @deprecated = {.vtdly = VT1}; +const Tc_oflags VT0 @deprecated = {.vtdly = VT0}; +const Tc_oflags VT1 @deprecated = {.vtdly = VT1}; +const Tc_iflags IGNBRK @deprecated = {.ignbrk}; +const Tc_iflags BRKINT @deprecated = {.brkint}; +const Tc_iflags IGNPAR @deprecated = {.ignpar}; +const Tc_iflags PARMRK @deprecated = {.parmrk}; +const Tc_iflags INPCK @deprecated = {.inpck}; +const Tc_iflags ISTRIP @deprecated = {.istrip}; +const Tc_iflags INLCR @deprecated = {.inlcr}; +const Tc_iflags IGNCR @deprecated = {.igncr}; +const Tc_iflags ICRNL @deprecated = {.icrnl}; +const Tc_iflags IUCLC @deprecated = {.iuclc}; +const Tc_iflags IXON @deprecated = {.ixon}; +const Tc_iflags IXANY @deprecated = {.ixany}; +const Tc_iflags IXOFF @deprecated = {.ixoff}; +const Tc_iflags IMAXBEL @deprecated = {.imaxbel}; +const Tc_iflags IUTF8 @deprecated = {.iutf8}; -fn Tc_lflags Tc_lflags.and(self, Tcflags other) @operator(&) @deprecated => (Tc_lflags)(((Tcflags)self) & other); -fn Tc_lflags Tc_lflags.or(self, Tcflags other) @operator(|) @deprecated => (Tc_lflags)(((Tcflags)self) | other); -fn Tc_lflags Tc_lflags.xor(self, Tcflags other) @operator(^) @deprecated => (Tc_lflags)(((Tcflags)self) ^ other); From a88cdfad3214ca6f906033fdbc1172305b3db73e Mon Sep 17 00:00:00 2001 From: Book-reader Date: Sun, 10 Aug 2025 15:32:49 +1200 Subject: [PATCH 5/5] update releasenotes --- releasenotes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/releasenotes.md b/releasenotes.md index db609263b..c23ecfb2d 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -26,6 +26,7 @@ - Add `vm::mmap_file` to memory map a file. - Updated hash functions in default hash methods. - Added `FixedBlockPool` which is a memory pool for fixed size blocks. +- Updated termios bindings to use bitstructs and fixed some constants with incorrect values #2372 ## 0.7.4 Change list