00001 #ifdef HAVE_CONFIG_H 00002 # include <config.h> 00003 #endif 00004 #ifdef HAVE_STDARG_H 00005 # include <stdarg.h> 00006 #endif 00007 #ifdef HAVE_SYS_UCONTEXT_H 00008 # include <sys/ucontext.h> 00009 #endif 00010 00011 #define setcontext(u) setmcontext(&(u)->uc_mcontext) 00012 #define getcontext(u) getmcontext(&(u)->uc_mcontext) 00013 typedef struct mcontext mcontext_t; 00014 typedef struct ucontext ucontext_t; 00015 00016 typedef void (MakeContextCallback)(void); 00017 00018 /*extern*/ int swapcontext(ucontext_t *, ucontext_t *); 00019 /*extern*/ void makecontext(ucontext_t *, MakeContextCallback *, int, ...); 00020 /*extern*/ int getmcontext(mcontext_t *); 00021 /*extern*/ void setmcontext(mcontext_t *); 00022 00023 /*- 00024 * Copyright (c) 1999 Marcel Moolenaar 00025 * All rights reserved. 00026 * 00027 * Redistribution and use in source and binary forms, with or without 00028 * modification, are permitted provided that the following conditions 00029 * are met: 00030 * 1. Redistributions of source code must retain the above copyright 00031 * notice, this list of conditions and the following disclaimer 00032 * in this position and unchanged. 00033 * 2. Redistributions in binary form must reproduce the above copyright 00034 * notice, this list of conditions and the following disclaimer in the 00035 * documentation and/or other materials provided with the distribution. 00036 * 3. The name of the author may not be used to endorse or promote products 00037 * derived from this software without specific prior written permission. 00038 * 00039 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 00040 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00041 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00042 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 00043 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 00044 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00045 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00046 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00047 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00048 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00049 * 00050 * $FreeBSD: src/sys/sys/ucontext.h,v 1.4 1999/10/11 20:33:17 luoqi Exp $ 00051 */ 00052 00053 /* #include <machine/ucontext.h> */ 00054 00055 struct mcontext { 00056 /* 00057 * The first 20 fields must match the definition of 00058 * sigcontext. So that we can support sigcontext 00059 * and ucontext_t at the same time. 00060 */ 00061 long mc_onstack; /* XXX - sigcontext compat. */ 00062 long mc_gs; /* processor-control in 64-bit Windows, unused elsewhere */ 00063 long mc_fs; /* thread-specific data */ 00064 long mc_es; /* flat segment group (do not touch) */ 00065 long mc_ds; /* flat segment group (do not touch) */ 00066 long mc_edi; /* general purpose 32-bit-only register */ 00067 long mc_esi; /* general purpose 32-bit-only register */ 00068 long mc_ebp; /* Stack frame pointer */ 00069 long mc_isp; 00070 long mc_ebx; /* PIC base register, also general-purp. reg */ 00071 long mc_edx; /* UNSAVED "dividend register", general purp. */ 00072 long mc_ecx; /* UNSAVED "count register", general purp. */ 00073 long mc_eax; /* UNSAVED "accumulation register", general purp. */ 00074 long mc_trapno; 00075 long mc_err; 00076 long mc_eip; /* UNSAVED instruction pointer */ 00077 long mc_cs; /* flat segment group (do not touch) */ 00078 long mc_eflags; 00079 long mc_esp; /* machine state; stack pointer */ 00080 long mc_ss; /* flat segment group (do not touch) */ 00081 00082 long mc_fpregs[28]; /* env87 + fpacc87 + u_long */ 00083 long __spare__[17]; 00084 }; 00085 00086 struct ucontext { 00087 /* 00088 * Keep the order of the first two fields. Also, 00089 * keep them the first two fields in the structure. 00090 * This way we can have a union with struct 00091 * sigcontext and ucontext_t. This allows us to 00092 * support them both at the same time. 00093 * note: the union is not defined, though. 00094 */ 00095 sigset_t uc_sigmask; 00096 mcontext_t uc_mcontext; 00097 00098 struct __ucontext *uc_link; 00099 stack_t uc_stack; 00100 long __spare__[8]; 00101 }; 00102 00103