mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-01 16:58:30 +00:00
Make more progress on aarch64
This commit is contained in:
parent
135080fd3e
commit
aef9a69a60
42 changed files with 563 additions and 387 deletions
|
@ -30,11 +30,7 @@
|
|||
int32_t sys_fstat(int32_t fd, struct stat *st) {
|
||||
void *p;
|
||||
union metastat ms;
|
||||
if (IsLinux()) {
|
||||
_Static_assert(sizeof(*st) == sizeof(ms.linux), "assumption broken");
|
||||
if (IsAsan() && !__asan_is_valid(st, sizeof(*st))) return efault();
|
||||
p = st;
|
||||
} else if (st) {
|
||||
if (st) {
|
||||
p = &ms;
|
||||
} else {
|
||||
p = 0;
|
||||
|
|
|
@ -32,11 +32,7 @@ int32_t sys_fstatat(int32_t dirfd, const char *path, struct stat *st,
|
|||
void *p;
|
||||
union metastat ms;
|
||||
if (IsAsan() && !__asan_is_valid_str(path)) return efault();
|
||||
if (IsLinux()) {
|
||||
_Static_assert(sizeof(*st) == sizeof(ms.linux), "assumption broken");
|
||||
if (IsAsan() && (st && !__asan_is_valid(st, sizeof(*st)))) return efault();
|
||||
p = st;
|
||||
} else if (st) {
|
||||
if (st) {
|
||||
p = &ms;
|
||||
} else {
|
||||
p = 0;
|
||||
|
|
|
@ -78,7 +78,7 @@ privileged int getpriority(int which, unsigned who) {
|
|||
register long r0 asm("x0") = (long)which;
|
||||
register long r1 asm("x1") = (long)who;
|
||||
register long res_x0 asm("x0");
|
||||
asm volatile("mov\tx8,%1\n"
|
||||
asm volatile("mov\tx8,%1\n\t"
|
||||
"svc\t0"
|
||||
: "=r"(res_x0)
|
||||
: "i"(141), "r"(r0), "r"(r1)
|
||||
|
|
|
@ -72,7 +72,7 @@ privileged void *sys_mremap(void *p, size_t n, size_t m, int f, void *q) {
|
|||
register long r3 asm("x3") = (long)f;
|
||||
register long r4 asm("x4") = (long)q;
|
||||
register long res_x0 asm("x0");
|
||||
asm volatile("mov\tx8,%1\n"
|
||||
asm volatile("mov\tx8,%1\n\t"
|
||||
"svc\t0"
|
||||
: "=r"(res_x0)
|
||||
: "i"(216), "r"(r0), "r"(r1), "r"(r2), "r"(r3), "r"(r4)
|
||||
|
|
|
@ -61,7 +61,7 @@ privileged int prctl(int operation, ...) {
|
|||
register long r3 asm("x3") = (long)c;
|
||||
register long r4 asm("x4") = (long)d;
|
||||
register long res_x0 asm("x0");
|
||||
asm volatile("mov\tx8,%1\n"
|
||||
asm volatile("mov\tx8,%1\n\t"
|
||||
"svc\t0"
|
||||
: "=r"(res_x0)
|
||||
: "i"(167), "r"(r0), "r"(r1), "r"(r2), "r"(r3), "r"(r4)
|
||||
|
|
|
@ -69,7 +69,7 @@ privileged int seccomp(unsigned operation, unsigned flags, void *args) {
|
|||
register long r1 asm("x1") = (long)flags;
|
||||
register long r2 asm("x2") = (long)args;
|
||||
register long res_x0 asm("x0");
|
||||
asm volatile("mov\tx8,%1\n"
|
||||
asm volatile("mov\tx8,%1\n\t"
|
||||
"svc\t0"
|
||||
: "=r"(res_x0)
|
||||
: "i"(211), "r"(r0), "r"(r1), "r"(r2)
|
||||
|
|
|
@ -22,6 +22,20 @@
|
|||
void __stat2cosmo(struct stat *restrict st, const union metastat *ms) {
|
||||
if (st) {
|
||||
if (IsLinux()) {
|
||||
st->st_dev = ms->linux.st_dev;
|
||||
st->st_ino = ms->linux.st_ino;
|
||||
st->st_nlink = ms->linux.st_nlink;
|
||||
st->st_mode = ms->linux.st_mode;
|
||||
st->st_uid = ms->linux.st_uid;
|
||||
st->st_gid = ms->linux.st_gid;
|
||||
st->st_flags = 0;
|
||||
st->st_rdev = ms->linux.st_rdev;
|
||||
st->st_size = ms->linux.st_size;
|
||||
st->st_blksize = ms->linux.st_blksize;
|
||||
st->st_blocks = ms->linux.st_blocks;
|
||||
st->st_atim = ms->linux.st_atim;
|
||||
st->st_mtim = ms->linux.st_mtim;
|
||||
st->st_ctim = ms->linux.st_ctim;
|
||||
st->st_birthtim = st->st_ctim;
|
||||
if (st->st_atim.tv_sec < st->st_ctim.tv_sec)
|
||||
st->st_birthtim = st->st_atim;
|
||||
|
|
|
@ -16,6 +16,7 @@ COSMOPOLITAN_C_START_
|
|||
struct stat_linux {
|
||||
uint64_t st_dev;
|
||||
uint64_t st_ino;
|
||||
#ifdef __x86_64__
|
||||
uint64_t st_nlink;
|
||||
uint32_t st_mode;
|
||||
uint32_t st_uid;
|
||||
|
@ -29,6 +30,23 @@ struct stat_linux {
|
|||
struct timespec st_mtim;
|
||||
struct timespec st_ctim;
|
||||
int64_t __unused[3];
|
||||
#elif defined(__aarch64__)
|
||||
uint32_t st_mode;
|
||||
uint32_t st_nlink;
|
||||
uint32_t st_uid;
|
||||
uint32_t st_gid;
|
||||
uint64_t st_rdev;
|
||||
uint64_t __pad1;
|
||||
int64_t st_size;
|
||||
int32_t st_blksize;
|
||||
int32_t __pad2;
|
||||
int64_t st_blocks;
|
||||
struct timespec st_atim;
|
||||
struct timespec st_mtim;
|
||||
struct timespec st_ctim;
|
||||
uint32_t __unused4;
|
||||
uint32_t __unused5;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct stat_xnu {
|
||||
|
|
|
@ -150,7 +150,7 @@ static inline ssize_t sys_write(int f, const void *b, size_t c) {
|
|||
register long r1 asm("x1") = (long)b;
|
||||
register long r2 asm("x2") = (long)c;
|
||||
register long res_x0 asm("x0");
|
||||
asm volatile("mov\tx8,%1\n"
|
||||
asm volatile("mov\tx8,%1\n\t"
|
||||
"svc\t0"
|
||||
: "=r"(res_x0)
|
||||
: "i"(64), "r"(r0), "r"(r1), "r"(r2)
|
||||
|
@ -172,7 +172,7 @@ static inline int sys_ioctl(int d, int r, ...) {
|
|||
register long r1 asm("x1") = (long)r;
|
||||
register long r2 asm("x2") = (long)a;
|
||||
register long res_x0 asm("x0");
|
||||
asm volatile("mov\tx8,%1\n"
|
||||
asm volatile("mov\tx8,%1\n\t"
|
||||
"svc\t0"
|
||||
: "=r"(res_x0)
|
||||
: "i"(29), "r"(r0), "r"(r1), "r"(r2)
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
*/
|
||||
|
||||
#define blkcnt_t int64_t
|
||||
#define blksize_t int64_t /* int32_t on xnu */
|
||||
#define cc_t uint8_t
|
||||
#define clock_t int64_t /* uint64_t on xnu */
|
||||
#define dev_t uint64_t /* int32_t on xnu */
|
||||
|
@ -38,7 +37,14 @@
|
|||
#define uid_t uint32_t
|
||||
#define rlim_t uint64_t /* int64_t on bsd */
|
||||
#define clockid_t int32_t
|
||||
#define nlink_t uint64_t
|
||||
|
||||
#ifdef __x86_64__
|
||||
#define blksize_t int64_t /* int32_t on xnu */
|
||||
#define nlink_t uint64_t
|
||||
#elif defined(__aarch64__)
|
||||
#define blksize_t int32_t
|
||||
#define nlink_t uint32_t
|
||||
#endif
|
||||
|
||||
#define TIME_T_MAX __INT64_MAX__
|
||||
#define TIME_T_MIN (-TIME_T_MAX - 1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue