Fix bugs in termios library and cleanup code

This change fixes an issue with the tcflow() magic numbers that was
causing bash to freeze up on Linux. While auditing termios polyfills,
several other issues were identified with XNU/BSD compatibility.

Out of an abundance of caution this change undefines as much surface
area from libc/calls/struct/termios.h as possible, so that autoconf
scripts are less likely to detect non-POSIX teletypewriter APIs that
haven't been polyfilled by Cosmopolitan.

This is a *breaking change* for your static archives in /opt/cosmos if
you use the cosmocc toolchain. That's because this change disables the
ioctl() undiamonding trick for code outside the monorepo, specifically
because it'll lead to brittle ABI breakages like this. If you're using
the cosmocc toolchain, you'll need to rebuild libraries like ncurses,
readline, etc. Yes diamonds cause bloat. To work around that, consider
using tcgetwinsize() instead of ioctl(TIOCGWINSZ) since it'll help you
avoid pulling every single ioctl-related polyfill into the linkage.

The cosmocc script was specifying -DNDEBUG for some reason. It's fixed.
This commit is contained in:
Justine Tunney 2023-06-14 17:02:57 -07:00
parent 06b749ae03
commit 4778cd4d27
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
187 changed files with 1025 additions and 1848 deletions

View file

@ -13,7 +13,6 @@ extern const int TIOCPKT_NOSTOP;
extern const int TIOCPKT_START;
extern const int TIOCPKT_STOP;
extern const int TIOCSPTLCK;
extern const int PTMGET;
#define TIOCPKT_DATA 0x00
#define TIOCPKT_DOSTOP 0x01
@ -26,11 +25,9 @@ extern const int PTMGET;
#define TIOCPKT TIOCPKT
#define TIOCSPTLCK TIOCSPTLCK
#define PTMGET PTMGET
#define __tmpcosmo_TIOCPKT -1036987649
#define __tmpcosmo_TIOCSPTLCK 372918192
#define __tmpcosmo_PTMGET -2064878958
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */