1 #define setcontext(u) setmcontext(&(u)->uc_mcontext) 2 #define getcontext(u) getmcontext(&(u)->uc_mcontext) 3 typedef struct mcontext mcontext_t; 4 typedef struct ucontext ucontext_t; 5 6 7 extern int swapcontext(ucontext_t*, const ucontext_t*); 8 extern void makecontext(ucontext_t*, void(*)(void), int, ...); 9 extern int getmcontext(mcontext_t*); 10 extern void setmcontext(const mcontext_t*); 11 12 /*- 13 * Copyright (c) 1999 Marcel Moolenaar 14 * All rights reserved. 15 * 16 * Redistribution and use in source and binary forms, with or without 17 * modification, are permitted provided that the following conditions 18 * are met: 19 * 1. Redistributions of source code must retain the above copyright 20 * notice, this list of conditions and the following disclaimer 21 * in this position and unchanged. 22 * 2. Redistributions in binary form must reproduce the above copyright 23 * notice, this list of conditions and the following disclaimer in the 24 * documentation and/or other materials provided with the distribution. 25 * 3. The name of the author may not be used to endorse or promote products 26 * derived from this software without specific prior written permission. 27 * 28 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 29 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 30 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 31 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 33 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 34 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 35 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 36 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 37 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 * 39 * $FreeBSD: src/sys/sys/ucontext.h,v 1.4 1999/10/11 20:33:17 luoqi Exp $ 40 */ 41 42 /* #include <machine/ucontext.h> */ 43 44 /*- 45 * Copyright (c) 1999 Marcel Moolenaar 46 * All rights reserved. 47 * 48 * Redistribution and use in source and binary forms, with or without 49 * modification, are permitted provided that the following conditions 50 * are met: 51 * 1. Redistributions of source code must retain the above copyright 52 * notice, this list of conditions and the following disclaimer 53 * in this position and unchanged. 54 * 2. Redistributions in binary form must reproduce the above copyright 55 * notice, this list of conditions and the following disclaimer in the 56 * documentation and/or other materials provided with the distribution. 57 * 3. The name of the author may not be used to endorse or promote products 58 * derived from this software without specific prior written permission. 59 * 60 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 61 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 62 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 63 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 64 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 65 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 66 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 67 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 68 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 69 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 70 * 71 * $FreeBSD: src/sys/i386/include/ucontext.h,v 1.4 1999/10/11 20:33:09 luoqi Exp $ 72 */ 73 74 struct mcontext { 75 /* 76 * The first 20 fields must match the definition of 77 * sigcontext. So that we can support sigcontext 78 * and ucontext_t at the same time. 79 */ 80 long mc_onstack; /* XXX - sigcontext compat. */ 81 long mc_rdi; /* machine state (struct trapframe) */ 82 long mc_rsi; 83 long mc_rdx; 84 long mc_rcx; 85 long mc_r8; 86 long mc_r9; 87 long mc_rax; 88 long mc_rbx; 89 long mc_rbp; 90 long mc_r10; 91 long mc_r11; 92 long mc_r12; 93 long mc_r13; 94 long mc_r14; 95 long mc_r15; 96 long mc_trapno; 97 long mc_addr; 98 long mc_flags; 99 long mc_err; 100 long mc_rip; 101 long mc_cs; 102 long mc_rflags; 103 long mc_rsp; 104 long mc_ss; 105 106 long mc_len; /* sizeof(mcontext_t) */ 107 #define _MC_FPFMT_NODEV 0x10000 /* device not present or configured */ 108 #define _MC_FPFMT_XMM 0x10002 109 long mc_fpformat; 110 #define _MC_FPOWNED_NONE 0x20000 /* FP state not used */ 111 #define _MC_FPOWNED_FPU 0x20001 /* FP state came from FPU */ 112 #define _MC_FPOWNED_PCB 0x20002 /* FP state came from PCB */ 113 long mc_ownedfp; 114 /* 115 * See <machine/fpu.h> for the internals of mc_fpstate[]. 116 */ 117 long mc_fpstate[64]; 118 long mc_spare[8]; 119 }; 120 121 struct ucontext { 122 /* 123 * Keep the order of the first two fields. Also, 124 * keep them the first two fields in the structure. 125 * This way we can have a union with struct 126 * sigcontext and ucontext_t. This allows us to 127 * support them both at the same time. 128 * note: the union is not defined, though. 129 */ 130 sigset_t uc_sigmask; 131 mcontext_t uc_mcontext; 132 133 struct __ucontext *uc_link; 134 stack_t uc_stack; 135 int __spare__[8]; 136 }; 137 138 139