mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-06 11:18:30 +00:00
Fix termios struct on Linux
The termios::c_cc field turned out to be incorrectly defined on Linux due to some confusion between the glibc and kernel definitions. We'll be using the kernel definition, since it has the strongest consensus. Fields have been have been added to struct stat for BSD compatibility such as st_birthtim, plus the GLIBC compatibility of isystem/sys/stat has been improved.
This commit is contained in:
parent
0584684a82
commit
5b60e5a37d
52 changed files with 358 additions and 296 deletions
|
@ -1,30 +1,30 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_CALLS_TERMIOS_INTERNAL_H_
|
||||
#define COSMOPOLITAN_LIBC_CALLS_TERMIOS_INTERNAL_H_
|
||||
#ifndef __STRICT_ANSI__
|
||||
#include "libc/bits/safemacros.internal.h"
|
||||
#include "libc/calls/struct/metatermios.internal.h"
|
||||
#include "libc/calls/struct/termios.h"
|
||||
#include "libc/str/str.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
#define COPY_TERMIOS(TO, FROM) \
|
||||
do { \
|
||||
memset((TO), 0, sizeof(*(TO))); \
|
||||
(TO)->c_iflag = (FROM)->c_iflag; \
|
||||
(TO)->c_oflag = (FROM)->c_oflag; \
|
||||
(TO)->c_cflag = (FROM)->c_cflag; \
|
||||
(TO)->c_lflag = (FROM)->c_lflag; \
|
||||
memcpy((TO)->c_cc, (FROM)->c_cc, \
|
||||
min(sizeof((TO)->c_cc), sizeof((FROM)->c_cc))); \
|
||||
(TO)->c_ispeed = (FROM)->c_ispeed; \
|
||||
(TO)->c_ospeed = (FROM)->c_ospeed; \
|
||||
#define COPY_TERMIOS(TO, FROM) \
|
||||
do { \
|
||||
uint32_t Cc3; \
|
||||
uint64_t Cc1, Cc2; \
|
||||
autotype((TO)->c_iflag) c_iflag = (FROM)->c_iflag; \
|
||||
autotype((TO)->c_oflag) c_oflag = (FROM)->c_oflag; \
|
||||
autotype((TO)->c_cflag) c_cflag = (FROM)->c_cflag; \
|
||||
autotype((TO)->c_lflag) c_lflag = (FROM)->c_lflag; \
|
||||
__builtin_memcpy(&Cc1, (FROM)->c_cc + 000, 8); \
|
||||
__builtin_memcpy(&Cc2, (FROM)->c_cc + 010, 8); \
|
||||
__builtin_memcpy(&Cc3, (FROM)->c_cc + 020, 4); \
|
||||
autotype((TO)->c_ispeed) c_ispeed = (FROM)->c_ispeed; \
|
||||
autotype((TO)->c_ospeed) c_ospeed = (FROM)->c_ospeed; \
|
||||
(TO)->c_iflag = c_iflag; \
|
||||
(TO)->c_oflag = c_oflag; \
|
||||
(TO)->c_cflag = c_cflag; \
|
||||
(TO)->c_lflag = c_lflag; \
|
||||
__builtin_memcpy((TO)->c_cc + 000, &Cc1, 8); \
|
||||
__builtin_memcpy((TO)->c_cc + 010, &Cc2, 8); \
|
||||
__builtin_memcpy((TO)->c_cc + 020, &Cc3, 4); \
|
||||
(TO)->c_ispeed = c_ispeed; \
|
||||
(TO)->c_ospeed = c_ospeed; \
|
||||
} while (0)
|
||||
|
||||
void *__termios2host(union metatermios *, const struct termios *) hidden;
|
||||
void __termios2linux(struct termios *, const union metatermios *) hidden;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* !ANSI */
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_TERMIOS_INTERNAL_H_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue