mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-24 06:12:27 +00:00
Implement swapcontext() and makecontext()
This change introduces support for Linux-style uc_context manipulation that's fast and works well on all supported OSes and architectures. It also integrates with the Cosmpolitan runtime which can show backtraces comprised of multiple stacks and fibers. See the test and example code for further details. This will be used by Mold once it's been vendored
This commit is contained in:
parent
7ec84655b4
commit
197aa0d465
28 changed files with 617 additions and 355 deletions
|
@ -6,9 +6,25 @@
|
|||
COSMOPOLITAN_C_START_
|
||||
|
||||
#ifdef __x86_64__
|
||||
#define SP rsp
|
||||
#define PC rip
|
||||
#define SP rsp
|
||||
#define BP rbp
|
||||
#define ARG0 rdi
|
||||
#define ARG1 rsi
|
||||
#define ARG2 rdx
|
||||
#define ARG3 rcx
|
||||
#define ARG4 r8
|
||||
#define ARG5 r9
|
||||
#elif defined(__aarch64__)
|
||||
#define SP sp
|
||||
#define PC pc
|
||||
#define SP sp
|
||||
#define BP regs[29]
|
||||
#define ARG0 regs[0]
|
||||
#define ARG1 regs[1]
|
||||
#define ARG2 regs[2]
|
||||
#define ARG3 regs[3]
|
||||
#define ARG4 regs[4]
|
||||
#define ARG5 regs[5]
|
||||
#else
|
||||
#error "unsupported architecture"
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue