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 extern int swapcontext(ucontext_t*, ucontext_t*); 7 extern void makecontext(ucontext_t*, void(*)(), int, ...); 8 extern int getmcontext(mcontext_t*); 9 extern void setmcontext(mcontext_t*); 10 11 /*- 12 * Copyright (c) 1999 Marcel Moolenaar 13 * All rights reserved. 14 * 15 * Redistribution and use in source and binary forms, with or without 16 * modification, are permitted provided that the following conditions 17 * are met: 18 * 1. Redistributions of source code must retain the above copyright 19 * notice, this list of conditions and the following disclaimer 20 * in this position and unchanged. 21 * 2. Redistributions in binary form must reproduce the above copyright 22 * notice, this list of conditions and the following disclaimer in the 23 * documentation and/or other materials provided with the distribution. 24 * 3. The name of the author may not be used to endorse or promote products 25 * derived from this software without specific prior written permission. 26 * 27 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 28 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 29 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 30 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 31 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 32 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 36 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 * 38 * $FreeBSD: src/sys/sys/ucontext.h,v 1.4 1999/10/11 20:33:17 luoqi Exp $ 39 */ 40 41 /* #include <machine/ucontext.h> */ 42 43 /*- 44 * Copyright (c) 1999 Marcel Moolenaar 45 * All rights reserved. 46 * 47 * Redistribution and use in source and binary forms, with or without 48 * modification, are permitted provided that the following conditions 49 * are met: 50 * 1. Redistributions of source code must retain the above copyright 51 * notice, this list of conditions and the following disclaimer 52 * in this position and unchanged. 53 * 2. Redistributions in binary form must reproduce the above copyright 54 * notice, this list of conditions and the following disclaimer in the 55 * documentation and/or other materials provided with the distribution. 56 * 3. The name of the author may not be used to endorse or promote products 57 * derived from this software without specific prior written permission. 58 * 59 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 60 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 61 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 62 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 63 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 64 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 65 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 66 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 67 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 68 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 69 * 70 * $FreeBSD: src/sys/i386/include/ucontext.h,v 1.4 1999/10/11 20:33:09 luoqi Exp $ 71 */ 72 73 struct mcontext { 74 /* 75 * The first 20 fields must match the definition of 76 * sigcontext. So that we can support sigcontext 77 * and ucontext_t at the same time. 78 */ 79 int mc_onstack; /* XXX - sigcontext compat. */ 80 int mc_gs; 81 int mc_fs; 82 int mc_es; 83 int mc_ds; 84 int mc_edi; 85 int mc_esi; 86 int mc_ebp; 87 int mc_isp; 88 int mc_ebx; 89 int mc_edx; 90 int mc_ecx; 91 int mc_eax; 92 int mc_trapno; 93 int mc_err; 94 int mc_eip; 95 int mc_cs; 96 int mc_eflags; 97 int mc_esp; /* machine state */ 98 int mc_ss; 99 100 int mc_fpregs[28]; /* env87 + fpacc87 + u_long */ 101 int __spare__[17]; 102 }; 103 104 struct ucontext { 105 /* 106 * Keep the order of the first two fields. Also, 107 * keep them the first two fields in the structure. 108 * This way we can have a union with struct 109 * sigcontext and ucontext_t. This allows us to 110 * support them both at the same time. 111 * note: the union is not defined, though. 112 */ 113 sigset_t uc_sigmask; 114 mcontext_t uc_mcontext; 115 116 struct __ucontext *uc_link; 117 stack_t uc_stack; 118 int __spare__[8]; 119 }; 120