Back to index

glibc  2.9
ucontext.h
Go to the documentation of this file.
00001 /* Copyright (C) 2001, 2002 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 #ifndef _SYS_UCONTEXT_H
00020 #define _SYS_UCONTEXT_H     1
00021 
00022 #include <features.h>
00023 #include <signal.h>
00024 #include <bits/wordsize.h>
00025 
00026 /* We need the signal context definitions even if they are not used
00027    included in <signal.h>.  */
00028 #include <bits/sigcontext.h>
00029 
00030 #if __WORDSIZE == 64
00031 
00032 /* Type for general register.  */
00033 typedef long int greg_t;
00034 
00035 /* Number of general registers.  */
00036 #define NGREG 23
00037 
00038 /* Container for all general registers.  */
00039 typedef greg_t gregset_t[NGREG];
00040 
00041 #ifdef __USE_GNU
00042 /* Number of each register in the `gregset_t' array.  */
00043 enum
00044 {
00045   REG_R8 = 0,
00046 # define REG_R8             REG_R8
00047   REG_R9,
00048 # define REG_R9             REG_R9
00049   REG_R10,
00050 # define REG_R10     REG_R10
00051   REG_R11,
00052 # define REG_R11     REG_R11
00053   REG_R12,
00054 # define REG_R12     REG_R12
00055   REG_R13,
00056 # define REG_R13     REG_R13
00057   REG_R14,
00058 # define REG_R14     REG_R14
00059   REG_R15,
00060 # define REG_R15     REG_R15
00061   REG_RDI,
00062 # define REG_RDI     REG_RDI
00063   REG_RSI,
00064 # define REG_RSI     REG_RSI
00065   REG_RBP,
00066 # define REG_RBP     REG_RBP
00067   REG_RBX,
00068 # define REG_RBX     REG_RBX
00069   REG_RDX,
00070 # define REG_RDX     REG_RDX
00071   REG_RAX,
00072 # define REG_RAX     REG_RAX
00073   REG_RCX,
00074 # define REG_RCX     REG_RCX
00075   REG_RSP,
00076 # define REG_RSP     REG_RSP
00077   REG_RIP,
00078 # define REG_RIP     REG_RIP
00079   REG_EFL,
00080 # define REG_EFL     REG_EFL
00081   REG_CSGSFS,        /* Actually short cs, gs, fs, __pad0.  */
00082 # define REG_CSGSFS  REG_CSGSFS
00083   REG_ERR,
00084 # define REG_ERR     REG_ERR
00085   REG_TRAPNO,
00086 # define REG_TRAPNO  REG_TRAPNO
00087   REG_OLDMASK,
00088 # define REG_OLDMASK REG_OLDMASK
00089   REG_CR2
00090 # define REG_CR2     REG_CR2
00091 };
00092 #endif
00093 
00094 struct _libc_fpxreg
00095 {
00096   unsigned short int significand[4];
00097   unsigned short int exponent;
00098   unsigned short int padding[3];
00099 };
00100 
00101 struct _libc_xmmreg
00102 {
00103   __uint32_t  element[4];
00104 };
00105 
00106 struct _libc_fpstate
00107 {
00108   /* 64-bit FXSAVE format.  */
00109   __uint16_t         cwd;
00110   __uint16_t         swd;
00111   __uint16_t         ftw;
00112   __uint16_t         fop;
00113   __uint64_t         rip;
00114   __uint64_t         rdp;
00115   __uint32_t         mxcsr;
00116   __uint32_t         mxcr_mask;
00117   struct _libc_fpxreg       _st[8];
00118   struct _libc_xmmreg       _xmm[16];
00119   __uint32_t         padding[24];
00120 };
00121 
00122 /* Structure to describe FPU registers.  */
00123 typedef struct _libc_fpstate *fpregset_t;
00124 
00125 /* Context to describe whole processor state.  */
00126 typedef struct
00127   {
00128     gregset_t gregs;
00129     /* Note that fpregs is a pointer.  */
00130     fpregset_t fpregs;
00131     unsigned long __reserved1 [8];
00132 } mcontext_t;
00133 
00134 /* Userlevel context.  */
00135 typedef struct ucontext
00136   {
00137     unsigned long int uc_flags;
00138     struct ucontext *uc_link;
00139     stack_t uc_stack;
00140     mcontext_t uc_mcontext;
00141     __sigset_t uc_sigmask;
00142     struct _libc_fpstate __fpregs_mem;
00143   } ucontext_t;
00144 
00145 #else /* __WORDSIZE == 32 */
00146 
00147 /* Type for general register.  */
00148 typedef int greg_t;
00149 
00150 /* Number of general registers.  */
00151 #define NGREG 19
00152 
00153 /* Container for all general registers.  */
00154 typedef greg_t gregset_t[NGREG];
00155 
00156 #ifdef __USE_GNU
00157 /* Number of each register is the `gregset_t' array.  */
00158 enum
00159 {
00160   REG_GS = 0,
00161 # define REG_GS             REG_GS
00162   REG_FS,
00163 # define REG_FS             REG_FS
00164   REG_ES,
00165 # define REG_ES             REG_ES
00166   REG_DS,
00167 # define REG_DS             REG_DS
00168   REG_EDI,
00169 # define REG_EDI     REG_EDI
00170   REG_ESI,
00171 # define REG_ESI     REG_ESI
00172   REG_EBP,
00173 # define REG_EBP     REG_EBP
00174   REG_ESP,
00175 # define REG_ESP     REG_ESP
00176   REG_EBX,
00177 # define REG_EBX     REG_EBX
00178   REG_EDX,
00179 # define REG_EDX     REG_EDX
00180   REG_ECX,
00181 # define REG_ECX     REG_ECX
00182   REG_EAX,
00183 # define REG_EAX     REG_EAX
00184   REG_TRAPNO,
00185 # define REG_TRAPNO  REG_TRAPNO
00186   REG_ERR,
00187 # define REG_ERR     REG_ERR
00188   REG_EIP,
00189 # define REG_EIP     REG_EIP
00190   REG_CS,
00191 # define REG_CS             REG_CS
00192   REG_EFL,
00193 # define REG_EFL     REG_EFL
00194   REG_UESP,
00195 # define REG_UESP    REG_UESP
00196   REG_SS
00197 # define REG_SS      REG_SS
00198 };
00199 #endif
00200 
00201 /* Definitions taken from the kernel headers.  */
00202 struct _libc_fpreg
00203 {
00204   unsigned short int significand[4];
00205   unsigned short int exponent;
00206 };
00207 
00208 struct _libc_fpstate
00209 {
00210   unsigned long int cw;
00211   unsigned long int sw;
00212   unsigned long int tag;
00213   unsigned long int ipoff;
00214   unsigned long int cssel;
00215   unsigned long int dataoff;
00216   unsigned long int datasel;
00217   struct _libc_fpreg _st[8];
00218   unsigned long int status;
00219 };
00220 
00221 /* Structure to describe FPU registers.  */
00222 typedef struct _libc_fpstate *fpregset_t;
00223 
00224 /* Context to describe whole processor state.  */
00225 typedef struct
00226   {
00227     gregset_t gregs;
00228     /* Due to Linux's history we have to use a pointer here.  The SysV/i386
00229        ABI requires a struct with the values.  */
00230     fpregset_t fpregs;
00231     unsigned long int oldmask;
00232     unsigned long int cr2;
00233   } mcontext_t;
00234 
00235 /* Userlevel context.  */
00236 typedef struct ucontext
00237   {
00238     unsigned long int uc_flags;
00239     struct ucontext *uc_link;
00240     stack_t uc_stack;
00241     mcontext_t uc_mcontext;
00242     __sigset_t uc_sigmask;
00243     struct _libc_fpstate __fpregs_mem;
00244   } ucontext_t;
00245 
00246 #endif /* __WORDSIZE == 32 */
00247 
00248 #endif /* sys/ucontext.h */