mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +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
|
@ -39,7 +39,7 @@
|
|||
*
|
||||
* @return stack bottom address on success, or null w/ errno
|
||||
*/
|
||||
void *_mapstack(void) {
|
||||
void *NewCosmoStack(void) {
|
||||
char *p;
|
||||
if ((p = mmap(0, GetStackSize(), PROT_READ | PROT_WRITE,
|
||||
MAP_STACK | MAP_ANONYMOUS, -1, 0)) != MAP_FAILED) {
|
||||
|
@ -56,8 +56,8 @@ void *_mapstack(void) {
|
|||
/**
|
||||
* Frees stack.
|
||||
*
|
||||
* @param stk was allocated by _mapstack()
|
||||
* @param stk was allocated by NewCosmoStack()
|
||||
*/
|
||||
int _freestack(void *stk) {
|
||||
int FreeCosmoStack(void *stk) {
|
||||
return munmap(stk, GetStackSize());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue