mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-16 10:20:30 +00:00
Add signalcontext(), which lays down a signal frame onto a ucontext_t.
Reviewed by: deischen, julian Approved by: -arch
This commit is contained in:
parent
7b08810243
commit
b3466b3fe0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=103405
@ -27,29 +27,32 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/signal.h>
|
||||
#include <sys/ucontext.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <stddef.h>
|
||||
#include <ucontext.h>
|
||||
|
||||
__weak_reference(__swapcontext, swapcontext);
|
||||
|
||||
int
|
||||
__swapcontext(ucontext_t *oucp, const ucontext_t *ucp)
|
||||
{
|
||||
volatile int swapping;
|
||||
int ret;
|
||||
|
||||
if (oucp == NULL || ucp == NULL) {
|
||||
if ((oucp == NULL) ||
|
||||
(oucp->uc_mcontext.mc_len != sizeof(mcontext_t)) ||
|
||||
(ucp == NULL) ||
|
||||
(ucp->uc_mcontext.mc_len != sizeof(mcontext_t))) {
|
||||
errno = EINVAL;
|
||||
ret = -1;
|
||||
} else {
|
||||
swapping = 0;
|
||||
ret = getcontext(oucp);
|
||||
if (ret == 0 && swapping == 0) {
|
||||
swapping = 1;
|
||||
ret = setcontext(ucp);
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
oucp->uc_flags &= ~UCF_SWAPPED;
|
||||
ret = getcontext(oucp);
|
||||
if ((ret == 0) && !(oucp->uc_flags & UCF_SWAPPED)) {
|
||||
oucp->uc_flags |= UCF_SWAPPED;
|
||||
ret = setcontext(ucp);
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user