mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-05 10:48:29 +00:00
Add siglongjmp() for aarch64
This commit is contained in:
parent
c88f95a892
commit
22cf6e11eb
13 changed files with 34 additions and 49 deletions
|
@ -20,7 +20,6 @@
|
|||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
#ifdef __x86_64__
|
||||
|
||||
// kudos rich felker for the brilliant design
|
||||
int __sigsetjmp_tail(sigjmp_buf jb, int rc) {
|
||||
|
@ -28,8 +27,6 @@ int __sigsetjmp_tail(sigjmp_buf jb, int rc) {
|
|||
sizeof(sigjmp_buf) == sizeof(jmp_buf) + 8 + 8 + sizeof(sigset_t),
|
||||
"please recompute sigjmp_buf w.r.t. sigset_t");
|
||||
void *p = (char *)jb + sizeof(jmp_buf) + 8 + 8;
|
||||
npassert(!sigprocmask(SIG_SETMASK, rc ? p : 0, rc ? 0 : p));
|
||||
sigprocmask(SIG_SETMASK, rc ? p : 0, rc ? 0 : p);
|
||||
return rc;
|
||||
}
|
||||
|
||||
#endif /* __x86_64__ */
|
||||
|
|
|
@ -8,8 +8,10 @@ COSMOPOLITAN_C_START_
|
|||
|
||||
#ifdef __x86_64__
|
||||
typedef long jmp_buf[8];
|
||||
typedef long sigjmp_buf[12];
|
||||
#elif defined(__aarch64__)
|
||||
typedef long jmp_buf[22];
|
||||
typedef long sigjmp_buf[26];
|
||||
#elif defined(__powerpc64__)
|
||||
typedef unsigned __int128 jmp_buf[32];
|
||||
#elif defined(__s390x__)
|
||||
|
@ -18,8 +20,6 @@ typedef unsigned long jmp_buf[18];
|
|||
typedef unsigned long jmp_buf[26];
|
||||
#endif
|
||||
|
||||
typedef long sigjmp_buf[12];
|
||||
|
||||
void mcount(void);
|
||||
int daemon(int, int);
|
||||
unsigned long getauxval(unsigned long);
|
||||
|
|
|
@ -112,6 +112,8 @@ o/$(MODE)/libc/runtime/zipos.o: libc/runtime/zipos.S
|
|||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
||||
o/$(MODE)/libc/runtime/switchstacks.o: libc/runtime/switchstacks.S
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
||||
o/$(MODE)/libc/runtime/sigsetjmp.o: libc/runtime/sigsetjmp.S
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
||||
|
||||
LIBC_RUNTIME_LIBS = $(foreach x,$(LIBC_RUNTIME_ARTIFACTS),$($(x)))
|
||||
LIBC_RUNTIME_SRCS = $(foreach x,$(LIBC_RUNTIME_ARTIFACTS),$($(x)_SRCS))
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
// @return eax 0 when set and !0 when longjmp'd
|
||||
// @returnstwice
|
||||
sigsetjmp:
|
||||
#ifdef __x86_64__
|
||||
test %esi,%esi
|
||||
jz setjmp
|
||||
popq 64(%rdi)
|
||||
|
@ -45,5 +46,19 @@ sigsetjmp:
|
|||
mov %eax,%esi
|
||||
mov 72(%rdi),%rbx
|
||||
jmp __sigsetjmp_tail
|
||||
#elif defined(__aarch64__)
|
||||
cbz x1,setjmp
|
||||
str x30,[x0,#176]
|
||||
str x19,[x0,#176+8+8]
|
||||
mov x19,x0
|
||||
bl setjmp
|
||||
mov w1,w0
|
||||
mov x0,x19
|
||||
ldr x30,[x0,#176]
|
||||
ldr x19,[x0,#176+8+8]
|
||||
b __sigsetjmp_tail
|
||||
#else
|
||||
#error "unsupported architecture"
|
||||
#endif
|
||||
.hidden __sigsetjmp_tail
|
||||
.endfn sigsetjmp,globl
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue