mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-27 11:52:03 +00:00
more
This commit is contained in:
parent
229086e790
commit
8712d1a38e
1 changed files with 6 additions and 4 deletions
|
@ -19,18 +19,21 @@
|
||||||
|
|
||||||
#include <ucontext.h>
|
#include <ucontext.h>
|
||||||
|
|
||||||
|
#define UC_M_PC 40
|
||||||
|
#define UC_M_NPC 48
|
||||||
|
|
||||||
extern int __getcontext (ucontext_t *ucp);
|
extern int __getcontext (ucontext_t *ucp);
|
||||||
extern int __setcontext (const ucontext_t *ucp, int restoremask);
|
extern int __setcontext (const ucontext_t *ucp, int restoremask);
|
||||||
|
|
||||||
int
|
int
|
||||||
__swapcontext (ucontext_t *oucp, const ucontext_t *ucp)
|
swapcontext (ucontext_t *oucp, const ucontext_t *ucp)
|
||||||
{
|
{
|
||||||
extern void __swapcontext_ret (void);
|
extern void __swapcontext_ret (void);
|
||||||
/* Save the current machine context to oucp. */
|
/* Save the current machine context to oucp. */
|
||||||
__getcontext (oucp);
|
__getcontext (oucp);
|
||||||
/* Modify oucp to skip the __setcontext call on reactivation. */
|
/* Modify oucp to skip the __setcontext call on reactivation. */
|
||||||
oucp->uc_mcontext.mc_gregs[MC_PC] = (long) __swapcontext_ret;
|
*(long*)((char*)oucp+UC_M_PC) = (long)__swapcontext_ret;
|
||||||
oucp->uc_mcontext.mc_gregs[MC_NPC] = ((long) __swapcontext_ret) + 4;
|
*(long*)((char*)oucp+UC_M_NPC) = (long)__swapcontext_ret + 4;
|
||||||
/* Restore the machine context in ucp. */
|
/* Restore the machine context in ucp. */
|
||||||
__setcontext (ucp, 1);
|
__setcontext (ucp, 1);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -45,4 +48,3 @@ __swapcontext_ret: \n\
|
||||||
.size __swapcontext_ret, .-__swapcontext_ret \n\
|
.size __swapcontext_ret, .-__swapcontext_ret \n\
|
||||||
");
|
");
|
||||||
|
|
||||||
weak_alias (__swapcontext, swapcontext)
|
|
||||||
|
|
Loading…
Reference in a new issue