Make more progress on aarch64

This commit is contained in:
Justine Tunney 2023-05-03 00:00:09 -07:00
parent 135080fd3e
commit aef9a69a60
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
42 changed files with 563 additions and 387 deletions

View file

@ -53,6 +53,7 @@ int fesetround(int);
int fetestexcept(int);
int feupdateenv(const fenv_t *);
int __flt_rounds(void);
int __fesetround(int);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */

View file

@ -26,23 +26,13 @@
* @param mode may be FE_TONEAREST, FE_DOWNWARD, FE_UPWARD, or FE_TOWARDZERO
* @return 0 on success, or -1 on error
*/
int fesetround(int mode) {
uint16_t x87cw;
uint32_t ssecw;
switch (mode) {
int fesetround(int r) {
switch (r) {
case FE_TONEAREST:
case FE_DOWNWARD:
case FE_UPWARD:
case FE_TOWARDZERO:
asm("fnstcw\t%0" : "=m"(x87cw));
x87cw &= ~0x0c00;
x87cw |= mode;
asm volatile("fldcw\t%0" : /* no outputs */ : "m"(x87cw));
asm("stmxcsr\t%0" : "=m"(ssecw));
ssecw &= ~(0x0c00 << 3);
ssecw |= (mode << 3);
asm volatile("ldmxcsr\t%0" : /* no outputs */ : "m"(ssecw));
return 0;
return __fesetround(r);
default:
return -1;
}

View file

@ -46,7 +46,7 @@ static inline int __morph_rt_sigprocmask(int h, const sigset_t *s, sigset_t *o,
register long r2 asm("x2") = (long)o;
register long r3 asm("x3") = (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"(135), "r"(r0), "r"(r1), "r"(r2), "r"(r3)
@ -90,7 +90,7 @@ static privileged void __morph_mprotect(void *addr, size_t size, int prot,
register long r1 asm("x1") = (long)size;
register long r2 asm("x2") = (long)prot;
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"(226), "r"(r0), "r"(r1), "r"(r2)