diff options
author | Jonathan Mini <mini@FreeBSD.org> | 2002-09-16 19:23:35 +0000 |
---|---|---|
committer | Jonathan Mini <mini@FreeBSD.org> | 2002-09-16 19:23:35 +0000 |
commit | b3466b3fe0de26be46280e72646a742c1d89a42f (patch) | |
tree | 2f584b9bb7764091a75bb599ec028bf34ccd43bf /lib | |
parent | 7b0881024329c67f07c7f519adb1db6eae5fe88e (diff) | |
download | src-b3466b3fe0de26be46280e72646a742c1d89a42f.tar.gz src-b3466b3fe0de26be46280e72646a742c1d89a42f.zip |
Add signalcontext(), which lays down a signal frame onto a ucontext_t.
Reviewed by: deischen, julian
Approved by: -arch
Notes
Notes:
svn path=/head/; revision=103405
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/gen/swapcontext.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/lib/libc/gen/swapcontext.c b/lib/libc/gen/swapcontext.c index d58ae6dc6d30..eeb2f782a3f5 100644 --- a/lib/libc/gen/swapcontext.c +++ b/lib/libc/gen/swapcontext.c @@ -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); } |