mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-08 04:08:32 +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,7 +1,7 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_METASTAT_H_
|
||||
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_METASTAT_H_
|
||||
#ifndef __STRICT_ANSI__
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/calls/struct/timespec.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
|
@ -13,6 +13,24 @@ COSMOPOLITAN_C_START_
|
|||
: IsNetbsd() ? x.netbsd.field \
|
||||
: 0)
|
||||
|
||||
struct stat_linux {
|
||||
uint64_t st_dev;
|
||||
uint64_t st_ino;
|
||||
uint64_t st_nlink;
|
||||
uint32_t st_mode;
|
||||
uint32_t st_uid;
|
||||
uint32_t st_gid;
|
||||
uint32_t __pad0;
|
||||
uint64_t st_rdev;
|
||||
int64_t st_size;
|
||||
int64_t st_blksize;
|
||||
int64_t st_blocks;
|
||||
struct timespec st_atim;
|
||||
struct timespec st_mtim;
|
||||
struct timespec st_ctim;
|
||||
int64_t __unused[3];
|
||||
};
|
||||
|
||||
struct stat_xnu {
|
||||
int32_t st_dev;
|
||||
uint16_t st_mode, st_nlink;
|
||||
|
@ -52,7 +70,7 @@ struct stat_openbsd {
|
|||
int64_t st_size, st_blocks;
|
||||
int32_t st_blksize;
|
||||
uint32_t st_flags, st_gen;
|
||||
struct timespec __st_birthtim;
|
||||
struct timespec st_birthtim;
|
||||
};
|
||||
|
||||
struct stat_netbsd {
|
||||
|
@ -68,7 +86,8 @@ struct stat_netbsd {
|
|||
};
|
||||
|
||||
union metastat {
|
||||
struct stat linux;
|
||||
struct stat cosmo;
|
||||
struct stat_linux linux;
|
||||
struct stat_xnu xnu;
|
||||
struct stat_freebsd freebsd;
|
||||
struct stat_openbsd openbsd;
|
||||
|
@ -77,5 +96,4 @@ union metastat {
|
|||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* !ANSI */
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_METASTAT_H_ */
|
||||
|
|
|
@ -3,25 +3,23 @@
|
|||
#include "libc/calls/struct/timespec.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
struct stat { /* linux abi */
|
||||
int64_t st_dev; /* 0: id of device with file */
|
||||
int64_t st_ino; /* 8: inode number in disk b-tree */
|
||||
int64_t st_nlink; /* 16: hard link count */
|
||||
int32_t st_mode; /* 24: octal file mask thing */
|
||||
int32_t st_uid; /* 28: user id of owner */
|
||||
int32_t st_gid; /* group id of owning group */
|
||||
int32_t __pad; /* ignore this */
|
||||
int64_t st_rdev; /* id of device if a special file */
|
||||
int64_t st_size; /* bytes in file */
|
||||
int64_t st_blksize; /* preferred chunking for underlying filesystem */
|
||||
int64_t st_blocks; /* number of 512-byte pages allocated to file */
|
||||
struct timespec st_atim; /* access time (consider noatime) */
|
||||
struct timespec st_mtim; /* modified time */
|
||||
struct timespec st_ctim; /* complicated time */
|
||||
int64_t __future[3 + 10]; /* reserved for future use */
|
||||
#define st_atime st_atim.tv_sec
|
||||
#define st_mtime st_mtim.tv_sec
|
||||
#define st_ctime st_ctim.tv_sec
|
||||
struct stat { /* cosmo abi */
|
||||
uint64_t st_dev; /* 0: id of device with file */
|
||||
uint64_t st_ino; /* 8: inode number in disk b-tree */
|
||||
uint64_t st_nlink; /* 16: hard link count */
|
||||
uint32_t st_mode; /* 24: octal file mask thing */
|
||||
uint32_t st_uid; /* 28: user id of owner */
|
||||
uint32_t st_gid; /* group id of owning group */
|
||||
uint32_t st_flags; /* flags (bsd-only) */
|
||||
uint64_t st_rdev; /* id of device if a special file */
|
||||
int64_t st_size; /* bytes in file */
|
||||
int64_t st_blksize; /* preferred chunking for underlying filesystem */
|
||||
int64_t st_blocks; /* number of 512-byte pages allocated to file */
|
||||
struct timespec st_atim; /* access time */
|
||||
struct timespec st_mtim; /* modified time */
|
||||
struct timespec st_ctim; /* complicated time */
|
||||
struct timespec st_birthtim;
|
||||
uint64_t st_gen;
|
||||
};
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
24
libc/calls/struct/stat.macros.h
Normal file
24
libc/calls/struct/stat.macros.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_STAT_MACROS_H_
|
||||
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_STAT_MACROS_H_
|
||||
|
||||
#define STAT_HAVE_NSEC 1
|
||||
|
||||
#define st_atime st_atim.tv_sec
|
||||
#define st_mtime st_mtim.tv_sec
|
||||
#define st_ctime st_ctim.tv_sec
|
||||
|
||||
#define st_atime_nsec st_atim.tv_nsec
|
||||
#define st_mtime_nsec st_mtim.tv_nsec
|
||||
#define st_ctime_nsec st_ctim.tv_nsec
|
||||
|
||||
#define st_atimensec st_atim.tv_nsec
|
||||
#define st_mtimensec st_mtim.tv_nsec
|
||||
#define st_ctimensec st_ctim.tv_nsec
|
||||
#define st_birthtime st_birthtim.tv_sec
|
||||
#define st_birthtimensec st_birthtim.tv_nsec
|
||||
|
||||
#define st_file_attributes st_flags
|
||||
|
||||
#define INIT_STRUCT_STAT_PADDING(st) (void)st
|
||||
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_STAT_MACROS_H_ */
|
|
@ -8,11 +8,13 @@ struct termios { /* GNU/Systemd ABI */
|
|||
uint32_t c_oflag; /* output modes */
|
||||
uint32_t c_cflag; /* control modes */
|
||||
uint32_t c_lflag; /* local modes */
|
||||
uint8_t c_cc[32]; /* code mappings */
|
||||
uint8_t c_cc[20]; /* code mappings */
|
||||
uint32_t c_ispeed; /* input speed */
|
||||
uint32_t c_ospeed; /* output speed */
|
||||
};
|
||||
|
||||
#define c_line c_cc[0] /* line discipline */
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_TERMIOS_H_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue