Skip to content

Commit

Permalink
Fix: Unify termios types for actions & flags
Browse files Browse the repository at this point in the history
The type for `Tcflags` was used instead of the CInt (now `Tcactions`)
and vice versa.
  • Loading branch information
tomaskallup authored and lerno committed Nov 4, 2024
1 parent 8154e27 commit bdd6ed0
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 75 deletions.
149 changes: 75 additions & 74 deletions lib/std/libc/os/posix.c3
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,18 @@ module libc::termios @if(env::LIBC &&& env::POSIX);
distinct Cc = char;
distinct Speed = CUInt;
distinct Tcflags = CUInt;
distinct Tcactions = CInt;

const Tcflags TCOOFF = 0;
const Tcflags TCOON = 1;
const Tcflags TCIOFF = 2;
const Tcflags TCION = 3;
const Tcflags TCIFLUSH = 0;
const Tcflags TCOFLUSH = 1;
const Tcflags TCIOFLUSH = 2;
const Tcflags TCSANOW = 0;
const Tcflags TCSADRAIN = 1;
const Tcflags TCSAFLUSH = 2;
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;
Expand Down Expand Up @@ -105,72 +106,72 @@ const Speed B3000000 = 0010015;
const Speed B3500000 = 0010016;
const Speed B4000000 = 0010017;
const Speed MAX_BAUD = B4000000;
const CInt VINTR = 0;
const CInt VQUIT = 1;
const CInt VERASE = 2;
const CInt VKILL = 3;
const CInt VEOF = 4;
const CInt VTIME = 5;
const CInt VMIN = 6;
const CInt VSWTC = 7;
const CInt VSTART = 8;
const CInt VSTOP = 9;
const CInt VSUSP = 10;
const CInt VEOL = 11;
const CInt VREPRINT = 12;
const CInt VDISCARD = 13;
const CInt VWERASE = 14;
const CInt VLNEXT = 15;
const CInt VEOL2 = 16;
const CInt ISIG = 0000001;
const CInt ICANON = 0000002;
const CInt ECHO = 0000010;
const CInt ECHOE = 0000020;
const CInt ECHOK = 0000040;
const CInt ECHONL = 0000100;
const CInt NOFLSH = 0000200;
const CInt TOSTOP = 0000400;
const CInt IEXTEN = 0100000;
const CInt CSIZE = 0000060;
const CInt CS5 = 0000000;
const CInt CS6 = 0000020;
const CInt CS7 = 0000040;
const CInt CS8 = 0000060;
const CInt CSTOPB = 0000100;
const CInt CREAD = 0000200;
const CInt PARENB = 0000400;
const CInt PARODD = 0001000;
const CInt HUPCL = 0002000;
const CInt CLOCAL = 0004000;
const CInt OPOST = 0000001;
const CInt OLCUC = 0000002;
const CInt ONLCR = 0000004;
const CInt OCRNL = 0000010;
const CInt ONOCR = 0000020;
const CInt ONLRET = 0000040;
const CInt OFILL = 0000100;
const CInt OFDEL = 0000200;
const CInt VTDLY = 0040000;
const CInt VT0 = 0000000;
const CInt VT1 = 0040000;
const CInt IGNBRK = 0000001;
const CInt BRKINT = 0000002;
const CInt IGNPAR = 0000004;
const CInt PARMRK = 0000010;
const CInt INPCK = 0000020;
const CInt ISTRIP = 0000040;
const CInt INLCR = 0000100;
const CInt IGNCR = 0000200;
const CInt ICRNL = 0000400;
const CInt IUCLC = 0001000;
const CInt IXON = 0002000;
const CInt IXANY = 0004000;
const CInt IXOFF = 0010000;
const CInt IMAXBEL = 0020000;
const CInt IUTF8 = 0040000;
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;

extern fn CInt tcgetattr(Fd fd, Termios* self);
extern fn CInt tcsetattr(Fd fd, CInt optional_actions, Termios* self);
extern fn CInt tcsetattr(Fd fd, Tcactions optional_actions, Termios* self);
extern fn CInt tcsendbreak(Fd fd, CInt duration);
extern fn CInt tcdrain(Fd fd);
extern fn CInt tcflush(Fd fd, CInt queue_selector);
Expand Down
2 changes: 1 addition & 1 deletion lib/std/libc/termios.c3
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ 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, int optional_actions) => tcsetattr(fd, optional_actions, self);
fn int Termios.setAttr(Termios* self, Fd fd, Tcactions optional_actions) => tcsetattr(fd, optional_actions, self);

module libc::termios @if(!env::LIBC ||| !env::POSIX);

Expand Down

0 comments on commit bdd6ed0

Please sign in to comment.