mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-07 03:38:31 +00:00
Work on magic numbers for aarch64
This commit is contained in:
parent
59766efd3e
commit
5a455eaa0b
2070 changed files with 4567 additions and 4200 deletions
|
@ -95,13 +95,19 @@ int clock_gettime(int clock, struct timespec *ts) {
|
|||
return rc;
|
||||
}
|
||||
|
||||
#ifdef __aarch64__
|
||||
#define CGT_VDSO __vdsosym("LINUX_2.6.39", "__kernel_clock_gettime")
|
||||
#else
|
||||
#define CGT_VDSO __vdsosym("LINUX_2.6", "__vdso_clock_gettime")
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns pointer to fastest clock_gettime().
|
||||
*/
|
||||
clock_gettime_f *__clock_gettime_get(bool *opt_out_isfast) {
|
||||
bool isfast;
|
||||
clock_gettime_f *res;
|
||||
if (IsLinux() && (res = __vdsosym("LINUX_2.6", "__vdso_clock_gettime"))) {
|
||||
if (IsLinux() && (res = CGT_VDSO)) {
|
||||
isfast = true;
|
||||
} else if (IsXnu()) {
|
||||
isfast = false;
|
||||
|
|
|
@ -41,6 +41,8 @@
|
|||
#include "libc/sysv/consts/prot.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
#define MAP_ANONYMOUS_linux 0x00000020
|
||||
#define MAP_FIXED_linux 0x00000010
|
||||
#define MAP_SHARED_linux 0x00000001
|
||||
|
@ -73,3 +75,5 @@ textstartup noasan void InitializeMetalFile(void) {
|
|||
__ape_com_size = size;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* __x86_64__ */
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
#include "libc/nt/struct/context.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
// TODO(jart): uc_sigmask support
|
||||
|
||||
privileged void _ntcontext2linux(ucontext_t *ctx, const struct NtContext *cr) {
|
||||
|
@ -75,3 +77,5 @@ privileged void _ntlinux2context(struct NtContext *cr, const ucontext_t *ctx) {
|
|||
cr->SegFs = ctx->uc_mcontext.fs;
|
||||
__repmovsb(&cr->FltSave, &ctx->__fpustate, sizeof(ctx->__fpustate));
|
||||
}
|
||||
|
||||
#endif /* __x86_64__ */
|
||||
|
|
|
@ -240,7 +240,7 @@ static const struct thatispacked SyscallName {
|
|||
{__NR_linux_capget, "capget"}, //
|
||||
{__NR_linux_capset, "capset"}, //
|
||||
{__NR_linux_sigtimedwait, "sigtimedwait"}, //
|
||||
{__NR_linux_rt_sigqueueinfo, "rt_sigqueueinfo"}, //
|
||||
{__NR_linux_sigqueueinfo, "sigqueueinfo"}, //
|
||||
{__NR_linux_personality, "personality"}, //
|
||||
{__NR_linux_ustat, "ustat"}, //
|
||||
{__NR_linux_sysfs, "sysfs"}, //
|
||||
|
@ -359,7 +359,7 @@ static const struct thatispacked SyscallName {
|
|||
{__NR_linux_epoll_create1, "epoll_create1"}, //
|
||||
{__NR_linux_perf_event_open, "perf_event_open"}, //
|
||||
{__NR_linux_inotify_init1, "inotify_init1"}, //
|
||||
{__NR_linux_rt_tgsigqueueinfo, "rt_tgsigqueueinfo"}, //
|
||||
{__NR_linux_tgsigqueueinfo, "tgsigqueueinfo"}, //
|
||||
{__NR_linux_signalfd, "signalfd"}, //
|
||||
{__NR_linux_signalfd4, "signalfd4"}, //
|
||||
{__NR_linux_eventfd, "eventfd"}, //
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/sa.h"
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
privileged void __sigenter_freebsd(int sig, struct siginfo_freebsd *freebsdinfo,
|
||||
struct ucontext_freebsd *ctx) {
|
||||
int rva, flags;
|
||||
|
@ -114,3 +116,5 @@ privileged void __sigenter_freebsd(int sig, struct siginfo_freebsd *freebsdinfo,
|
|||
* function, and 2) calls sys_sigreturn() once this returns.
|
||||
*/
|
||||
}
|
||||
|
||||
#endif /* __x86_64__ */
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/sa.h"
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
privileged void __sigenter_wsl(int sig, struct siginfo *info, ucontext_t *ctx) {
|
||||
int i, rva, flags;
|
||||
rva = __sighandrvas[sig & (NSIG - 1)];
|
||||
|
@ -45,3 +47,5 @@ privileged void __sigenter_wsl(int sig, struct siginfo *info, ucontext_t *ctx) {
|
|||
((sigaction_f)(_base + rva))(sig, info, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* __x86_64__ */
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/sa.h"
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
privileged void __sigenter_netbsd(int sig, struct siginfo_netbsd *si,
|
||||
struct ucontext_netbsd *ctx) {
|
||||
int rva, flags;
|
||||
|
@ -109,3 +111,5 @@ privileged void __sigenter_netbsd(int sig, struct siginfo_netbsd *si,
|
|||
* function, and 2) calls sys_sigreturn() once this returns.
|
||||
*/
|
||||
}
|
||||
|
||||
#endif /* __x86_64__ */
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/sa.h"
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
privileged void __sigenter_openbsd(int sig, struct siginfo_openbsd *openbsdinfo,
|
||||
struct ucontext_openbsd *ctx) {
|
||||
int rva, flags;
|
||||
|
@ -108,3 +110,5 @@ privileged void __sigenter_openbsd(int sig, struct siginfo_openbsd *openbsdinfo,
|
|||
* function, and 2) calls sys_sigreturn() once this returns.
|
||||
*/
|
||||
}
|
||||
|
||||
#endif /* __x86_64__ */
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
COSMOPOLITAN_C_START_
|
||||
// clang-format off
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
#define __UCONTEXT_SIZE 784
|
||||
#define _UC_SIGMASK 0x01
|
||||
#define _UC_STACK 0x02
|
||||
|
@ -78,6 +80,8 @@ struct ucontext_netbsd {
|
|||
};
|
||||
};
|
||||
|
||||
#endif /* __x86_64__ */
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_UCONTEXT_NETBSD_INTERNAL_H_ */
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
struct XmmRegister {
|
||||
uint64_t u64[2];
|
||||
};
|
||||
|
@ -33,7 +35,10 @@ typedef uint64_t greg_t;
|
|||
typedef greg_t gregset_t[23];
|
||||
typedef struct FpuState *fpregset_t;
|
||||
|
||||
struct MachineContext {
|
||||
#endif /* __x86_64__ */
|
||||
|
||||
struct sigcontext {
|
||||
#ifdef __x86_64__
|
||||
union {
|
||||
struct {
|
||||
uint64_t r8;
|
||||
|
@ -67,18 +72,32 @@ struct MachineContext {
|
|||
};
|
||||
struct FpuState *fpregs; /* zero when no fpu context */
|
||||
uint64_t __pad1[8];
|
||||
#elif defined(__aarch64__)
|
||||
uint64_t fault_address;
|
||||
uint64_t regs[31];
|
||||
uint64_t sp;
|
||||
uint64_t pc;
|
||||
uint64_t pstate;
|
||||
uint8_t __reserved[4096] __attribute__((__aligned__(16)));
|
||||
#endif /* __x86_64__ */
|
||||
};
|
||||
|
||||
typedef struct MachineContext mcontext_t;
|
||||
typedef struct sigcontext mcontext_t;
|
||||
|
||||
struct ucontext {
|
||||
uint64_t uc_flags; /* don't use this */
|
||||
struct ucontext *uc_link;
|
||||
stack_t uc_stack;
|
||||
mcontext_t uc_mcontext; /* use this */
|
||||
#ifdef __x86_64__
|
||||
struct sigcontext uc_mcontext;
|
||||
sigset_t uc_sigmask;
|
||||
uint64_t __pad;
|
||||
struct FpuState __fpustate; /* for cosmo on non-linux */
|
||||
#elif defined(__aarch64__)
|
||||
sigset_t uc_sigmask;
|
||||
uint8_t __unused[1024 / 8 - sizeof(sigset_t)];
|
||||
struct sigcontext uc_mcontext;
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef struct ucontext ucontext_t;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue