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

@ -9,6 +9,12 @@
* @fileoverview PKZIP Data Structures.
*/
#ifdef __ASSEMBLER__
#define ZM_(x) x
#else
#define ZM_(x) ~VEIL("r", ~x) /* prevent magic from appearing in binary */
#endif
#define kZipOk 0
#define kZipErrorEocdNotFound -1
#define kZipErrorEocdOffsetOverflow -2
@ -24,8 +30,6 @@
#define kZipErrorMapFailed -12
#define kZipErrorOpenFailed -13
#define kZipAlign 2
#define kZipCosmopolitanVersion kZipEra2001
#define kZipOsDos 0
@ -59,10 +63,9 @@
#define kZipCompressionNone 0
#define kZipCompressionDeflate 8
#define kZipCdirHdrMagic 0x06054b50 /* PK♣♠ "PK\5\6" */
#define kZipCdirHdrMagicTodo 0x19184b50 /* PK♣♠ "PK\30\31" */
#define kZipCdirHdrMagic ZM_(0x06054b50) /* PK♣♠ "PK\5\6" */
#define kZipCdirHdrMagicTodo ZM_(0x19184b50) /* PK♣♠ "PK\30\31" */
#define kZipCdirHdrMinSize 22
#define kZipCdirAlign kZipAlign
#define kZipCdirHdrLinkableSize 294
#define kZipCdirDiskOffset 4
#define kZipCdirStartingDiskOffset 6
@ -72,12 +75,12 @@
#define kZipCdirOffsetOffset 16
#define kZipCdirCommentSizeOffset 20
#define kZipCdir64HdrMagic 0x06064b50 /* PK♣♠ "PK\6\6" */
#define kZipCdir64HdrMagic ZM_(0x06064b50) /* PK♣♠ "PK\6\6" */
#define kZipCdir64HdrMinSize 56
#define kZipCdir64LocatorMagic 0x07064b50 /* PK♠• "PK\6\7" */
#define kZipCdir64LocatorMagic ZM_(0x07064b50) /* PK♠• "PK\6\7" */
#define kZipCdir64LocatorSize 20
#define kZipCfileHdrMagic 0x02014b50 /* PK☺☻ "PK\1\2" */
#define kZipCfileHdrMagic ZM_(0x02014b50) /* PK☺☻ "PK\1\2" */
#define kZipCfileHdrMinSize 46
#define kZipCfileOffsetGeneralflag 8
#define kZipCfileOffsetCompressionmethod 10
@ -89,7 +92,7 @@
#define kZipCfileOffsetExternalattributes 38
#define kZipCfileOffsetOffset 42
#define kZipLfileHdrMagic 0x04034b50 /* PK♥♦ "PK\3\4" */
#define kZipLfileHdrMagic ZM_(0x04034b50) /* PK♥♦ "PK\3\4" */
#define kZipLfileHdrMinSize 30
#define kZipLfileOffsetGeneralflag 6
#define kZipLfileOffsetCompressionmethod 8