modernc.org/cc@v1.0.1/v2/headers/linux_386/usr/include/i386-linux-gnu/sys/ucontext.h (about) 1 /* Copyright (C) 2001-2018 Free Software Foundation, Inc. 2 This file is part of the GNU C Library. 3 4 The GNU C Library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Lesser General Public 6 License as published by the Free Software Foundation; either 7 version 2.1 of the License, or (at your option) any later version. 8 9 The GNU C Library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 14 You should have received a copy of the GNU Lesser General Public 15 License along with the GNU C Library; if not, see 16 <http://www.gnu.org/licenses/>. */ 17 18 #ifndef _SYS_UCONTEXT_H 19 #define _SYS_UCONTEXT_H 1 20 21 #include <features.h> 22 23 #include <bits/types.h> 24 #include <bits/types/sigset_t.h> 25 #include <bits/types/stack_t.h> 26 27 #ifdef __USE_MISC 28 # define __ctx(fld) fld 29 #else 30 # define __ctx(fld) __ ## fld 31 #endif 32 33 #ifdef __x86_64__ 34 35 /* Type for general register. */ 36 __extension__ typedef long long int greg_t; 37 38 /* Number of general registers. */ 39 #define __NGREG 23 40 #ifdef __USE_MISC 41 # define NGREG __NGREG 42 #endif 43 44 /* Container for all general registers. */ 45 typedef greg_t gregset_t[__NGREG]; 46 47 #ifdef __USE_GNU 48 /* Number of each register in the `gregset_t' array. */ 49 enum { 50 REG_R8 = 0, 51 # define REG_R8 REG_R8 52 REG_R9, 53 # define REG_R9 REG_R9 54 REG_R10, 55 # define REG_R10 REG_R10 56 REG_R11, 57 # define REG_R11 REG_R11 58 REG_R12, 59 # define REG_R12 REG_R12 60 REG_R13, 61 # define REG_R13 REG_R13 62 REG_R14, 63 # define REG_R14 REG_R14 64 REG_R15, 65 # define REG_R15 REG_R15 66 REG_RDI, 67 # define REG_RDI REG_RDI 68 REG_RSI, 69 # define REG_RSI REG_RSI 70 REG_RBP, 71 # define REG_RBP REG_RBP 72 REG_RBX, 73 # define REG_RBX REG_RBX 74 REG_RDX, 75 # define REG_RDX REG_RDX 76 REG_RAX, 77 # define REG_RAX REG_RAX 78 REG_RCX, 79 # define REG_RCX REG_RCX 80 REG_RSP, 81 # define REG_RSP REG_RSP 82 REG_RIP, 83 # define REG_RIP REG_RIP 84 REG_EFL, 85 # define REG_EFL REG_EFL 86 REG_CSGSFS, /* Actually short cs, gs, fs, __pad0. */ 87 # define REG_CSGSFS REG_CSGSFS 88 REG_ERR, 89 # define REG_ERR REG_ERR 90 REG_TRAPNO, 91 # define REG_TRAPNO REG_TRAPNO 92 REG_OLDMASK, 93 # define REG_OLDMASK REG_OLDMASK 94 REG_CR2 95 # define REG_CR2 REG_CR2 96 }; 97 #endif 98 99 struct _libc_fpxreg { 100 unsigned short int __ctx(significand)[4]; 101 unsigned short int __ctx(exponent); 102 unsigned short int __glibc_reserved1[3]; 103 }; 104 105 struct _libc_xmmreg { 106 __uint32_t __ctx(element)[4]; 107 }; 108 109 struct _libc_fpstate { 110 /* 64-bit FXSAVE format. */ 111 __uint16_t __ctx(cwd); 112 __uint16_t __ctx(swd); 113 __uint16_t __ctx(ftw); 114 __uint16_t __ctx(fop); 115 __uint64_t __ctx(rip); 116 __uint64_t __ctx(rdp); 117 __uint32_t __ctx(mxcsr); 118 __uint32_t __ctx(mxcr_mask); 119 struct _libc_fpxreg _st[8]; 120 struct _libc_xmmreg _xmm[16]; 121 __uint32_t __glibc_reserved1[24]; 122 }; 123 124 /* Structure to describe FPU registers. */ 125 typedef struct _libc_fpstate *fpregset_t; 126 127 /* Context to describe whole processor state. */ 128 typedef struct { 129 gregset_t __ctx(gregs); 130 /* Note that fpregs is a pointer. */ 131 fpregset_t __ctx(fpregs); 132 __extension__ unsigned long long __reserved1[8]; 133 } mcontext_t; 134 135 /* Userlevel context. */ 136 typedef struct ucontext_t { 137 unsigned long int __ctx(uc_flags); 138 struct ucontext_t *uc_link; 139 stack_t uc_stack; 140 mcontext_t uc_mcontext; 141 sigset_t uc_sigmask; 142 struct _libc_fpstate __fpregs_mem; 143 } ucontext_t; 144 145 #else /* !__x86_64__ */ 146 147 /* Type for general register. */ 148 typedef int greg_t; 149 150 /* Number of general registers. */ 151 #define __NGREG 19 152 #ifdef __USE_MISC 153 # define NGREG __NGREG 154 #endif 155 156 /* Container for all general registers. */ 157 typedef greg_t gregset_t[__NGREG]; 158 159 #ifdef __USE_GNU 160 /* Number of each register is the `gregset_t' array. */ 161 enum { 162 REG_GS = 0, 163 # define REG_GS REG_GS 164 REG_FS, 165 # define REG_FS REG_FS 166 REG_ES, 167 # define REG_ES REG_ES 168 REG_DS, 169 # define REG_DS REG_DS 170 REG_EDI, 171 # define REG_EDI REG_EDI 172 REG_ESI, 173 # define REG_ESI REG_ESI 174 REG_EBP, 175 # define REG_EBP REG_EBP 176 REG_ESP, 177 # define REG_ESP REG_ESP 178 REG_EBX, 179 # define REG_EBX REG_EBX 180 REG_EDX, 181 # define REG_EDX REG_EDX 182 REG_ECX, 183 # define REG_ECX REG_ECX 184 REG_EAX, 185 # define REG_EAX REG_EAX 186 REG_TRAPNO, 187 # define REG_TRAPNO REG_TRAPNO 188 REG_ERR, 189 # define REG_ERR REG_ERR 190 REG_EIP, 191 # define REG_EIP REG_EIP 192 REG_CS, 193 # define REG_CS REG_CS 194 REG_EFL, 195 # define REG_EFL REG_EFL 196 REG_UESP, 197 # define REG_UESP REG_UESP 198 REG_SS 199 # define REG_SS REG_SS 200 }; 201 #endif 202 203 /* Definitions taken from the kernel headers. */ 204 struct _libc_fpreg { 205 unsigned short int __ctx(significand)[4]; 206 unsigned short int __ctx(exponent); 207 }; 208 209 struct _libc_fpstate { 210 unsigned long int __ctx(cw); 211 unsigned long int __ctx(sw); 212 unsigned long int __ctx(tag); 213 unsigned long int __ctx(ipoff); 214 unsigned long int __ctx(cssel); 215 unsigned long int __ctx(dataoff); 216 unsigned long int __ctx(datasel); 217 struct _libc_fpreg _st[8]; 218 unsigned long int __ctx(status); 219 }; 220 221 /* Structure to describe FPU registers. */ 222 typedef struct _libc_fpstate *fpregset_t; 223 224 /* Context to describe whole processor state. */ 225 typedef struct { 226 gregset_t __ctx(gregs); 227 /* Due to Linux's history we have to use a pointer here. The SysV/i386 228 ABI requires a struct with the values. */ 229 fpregset_t __ctx(fpregs); 230 unsigned long int __ctx(oldmask); 231 unsigned long int __ctx(cr2); 232 } mcontext_t; 233 234 /* Userlevel context. */ 235 typedef struct ucontext_t { 236 unsigned long int __ctx(uc_flags); 237 struct ucontext_t *uc_link; 238 stack_t uc_stack; 239 mcontext_t uc_mcontext; 240 sigset_t uc_sigmask; 241 struct _libc_fpstate __fpregs_mem; 242 } ucontext_t; 243 244 #endif /* !__x86_64__ */ 245 246 #undef __ctx 247 248 #endif /* sys/ucontext.h */