typedef struct ucontext_t { unsigned long int __uc_flags; struct ucontext_t *uc_link; /* 其中有stack的基地址(ss_sp),大小(ss_size)和flag(ss_flags) */ stack_t uc_stack; sigset_t uc_sigmask; /* There's some padding here to allow sigset_t to be expanded in the future. Though this is unlikely, other architectures put uc_sigmask at the end of this structure and explicitly state it can be expanded, so we didn't want to box ourselves in here. */ char __glibc_reserved[1024 / 8 - sizeof (sigset_t)]; /* We can't put uc_sigmask at the end of this structure because we need to be able to expand sigcontext in the future. For example, the vector ISA extension will almost certainly add ISA state. We want to ensure all user-visible ISA state can be saved and restored via a ucontext, so we're putting this at the end in order to allow for infinite extensibility. Since we know this will be extended and we assume sigset_t won't be extended an extreme amount, we're prioritizing this. */ /* 其中定义riscv的通用寄存器和浮点寄存器 */ mcontext_t uc_mcontext; } ucontext_t;
/* Get user context and store it in variable pointed to by UCP. */ extern int getcontext (ucontext_t *__ucp) __THROWNL;
/* Set user context from information of variable pointed to by UCP. */ extern int setcontext (const ucontext_t *__ucp) __THROWNL;
/* Save current context in context variable pointed to by OUCP and set context from variable pointed to by UCP. */ extern int swapcontext (ucontext_t *__restrict __oucp, const ucontext_t *__restrict __ucp) __THROWNL __INDIRECT_RETURN;
/* Manipulate user context UCP to continue with calling functions FUNC and the ARGC-1 parameters following ARGC when the context is used the next time in `setcontext' or `swapcontext'.
We cannot say anything about the parameters FUNC takes; `void' is as good as any other choice. */ extern void makecontext (ucontext_t *__ucp, void (*__func) (void), int __argc, ...) __THROW;