modernc.org/cc@v1.0.1/v2/headers/linux_amd64/usr/include/sys/ucontext.h (about) 1 /* Copyright (C) 2001-2015 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 #include <signal.h> 23 24 /* We need the signal context definitions even if they are not used 25 included in <signal.h>. */ 26 #include <bits/sigcontext.h> 27 28 #ifdef __x86_64__ 29 30 /* Type for general register. */ 31 __extension__ typedef long long int greg_t; 32 33 /* Number of general registers. */ 34 #define NGREG 23 35 36 /* Container for all general registers. */ 37 typedef greg_t gregset_t[NGREG]; 38 39 #ifdef __USE_GNU 40 /* Number of each register in the `gregset_t' array. */ 41 enum { 42 REG_R8 = 0, 43 # define REG_R8 REG_R8 44 REG_R9, 45 # define REG_R9 REG_R9 46 REG_R10, 47 # define REG_R10 REG_R10 48 REG_R11, 49 # define REG_R11 REG_R11 50 REG_R12, 51 # define REG_R12 REG_R12 52 REG_R13, 53 # define REG_R13 REG_R13 54 REG_R14, 55 # define REG_R14 REG_R14 56 REG_R15, 57 # define REG_R15 REG_R15 58 REG_RDI, 59 # define REG_RDI REG_RDI 60 REG_RSI, 61 # define REG_RSI REG_RSI 62 REG_RBP, 63 # define REG_RBP REG_RBP 64 REG_RBX, 65 # define REG_RBX REG_RBX 66 REG_RDX, 67 # define REG_RDX REG_RDX 68 REG_RAX, 69 # define REG_RAX REG_RAX 70 REG_RCX, 71 # define REG_RCX REG_RCX 72 REG_RSP, 73 # define REG_RSP REG_RSP 74 REG_RIP, 75 # define REG_RIP REG_RIP 76 REG_EFL, 77 # define REG_EFL REG_EFL 78 REG_CSGSFS, /* Actually short cs, gs, fs, __pad0. */ 79 # define REG_CSGSFS REG_CSGSFS 80 REG_ERR, 81 # define REG_ERR REG_ERR 82 REG_TRAPNO, 83 # define REG_TRAPNO REG_TRAPNO 84 REG_OLDMASK, 85 # define REG_OLDMASK REG_OLDMASK 86 REG_CR2 87 # define REG_CR2 REG_CR2 88 }; 89 #endif 90 91 struct _libc_fpxreg { 92 unsigned short int significand[4]; 93 unsigned short int exponent; 94 unsigned short int padding[3]; 95 }; 96 97 struct _libc_xmmreg { 98 __uint32_t element[4]; 99 }; 100 101 struct _libc_fpstate { 102 /* 64-bit FXSAVE format. */ 103 __uint16_t cwd; 104 __uint16_t swd; 105 __uint16_t ftw; 106 __uint16_t fop; 107 __uint64_t rip; 108 __uint64_t rdp; 109 __uint32_t mxcsr; 110 __uint32_t mxcr_mask; 111 struct _libc_fpxreg _st[8]; 112 struct _libc_xmmreg _xmm[16]; 113 __uint32_t padding[24]; 114 }; 115 116 /* Structure to describe FPU registers. */ 117 typedef struct _libc_fpstate *fpregset_t; 118 119 /* Context to describe whole processor state. */ 120 typedef struct { 121 gregset_t gregs; 122 /* Note that fpregs is a pointer. */ 123 fpregset_t fpregs; 124 __extension__ unsigned long long __reserved1[8]; 125 } mcontext_t; 126 127 /* Userlevel context. */ 128 typedef struct ucontext { 129 unsigned long int uc_flags; 130 struct ucontext *uc_link; 131 stack_t uc_stack; 132 mcontext_t uc_mcontext; 133 __sigset_t uc_sigmask; 134 struct _libc_fpstate __fpregs_mem; 135 } ucontext_t; 136 137 #else /* !__x86_64__ */ 138 139 /* Type for general register. */ 140 typedef int greg_t; 141 142 /* Number of general registers. */ 143 #define NGREG 19 144 145 /* Container for all general registers. */ 146 typedef greg_t gregset_t[NGREG]; 147 148 #ifdef __USE_GNU 149 /* Number of each register is the `gregset_t' array. */ 150 enum { 151 REG_GS = 0, 152 # define REG_GS REG_GS 153 REG_FS, 154 # define REG_FS REG_FS 155 REG_ES, 156 # define REG_ES REG_ES 157 REG_DS, 158 # define REG_DS REG_DS 159 REG_EDI, 160 # define REG_EDI REG_EDI 161 REG_ESI, 162 # define REG_ESI REG_ESI 163 REG_EBP, 164 # define REG_EBP REG_EBP 165 REG_ESP, 166 # define REG_ESP REG_ESP 167 REG_EBX, 168 # define REG_EBX REG_EBX 169 REG_EDX, 170 # define REG_EDX REG_EDX 171 REG_ECX, 172 # define REG_ECX REG_ECX 173 REG_EAX, 174 # define REG_EAX REG_EAX 175 REG_TRAPNO, 176 # define REG_TRAPNO REG_TRAPNO 177 REG_ERR, 178 # define REG_ERR REG_ERR 179 REG_EIP, 180 # define REG_EIP REG_EIP 181 REG_CS, 182 # define REG_CS REG_CS 183 REG_EFL, 184 # define REG_EFL REG_EFL 185 REG_UESP, 186 # define REG_UESP REG_UESP 187 REG_SS 188 # define REG_SS REG_SS 189 }; 190 #endif 191 192 /* Definitions taken from the kernel headers. */ 193 struct _libc_fpreg { 194 unsigned short int significand[4]; 195 unsigned short int exponent; 196 }; 197 198 struct _libc_fpstate { 199 unsigned long int cw; 200 unsigned long int sw; 201 unsigned long int tag; 202 unsigned long int ipoff; 203 unsigned long int cssel; 204 unsigned long int dataoff; 205 unsigned long int datasel; 206 struct _libc_fpreg _st[8]; 207 unsigned long int status; 208 }; 209 210 /* Structure to describe FPU registers. */ 211 typedef struct _libc_fpstate *fpregset_t; 212 213 /* Context to describe whole processor state. */ 214 typedef struct { 215 gregset_t gregs; 216 /* Due to Linux's history we have to use a pointer here. The SysV/i386 217 ABI requires a struct with the values. */ 218 fpregset_t fpregs; 219 unsigned long int oldmask; 220 unsigned long int cr2; 221 } mcontext_t; 222 223 /* Userlevel context. */ 224 typedef struct ucontext { 225 unsigned long int uc_flags; 226 struct ucontext *uc_link; 227 stack_t uc_stack; 228 mcontext_t uc_mcontext; 229 __sigset_t uc_sigmask; 230 struct _libc_fpstate __fpregs_mem; 231 } ucontext_t; 232 233 #endif /* !__x86_64__ */ 234 235 #endif /* sys/ucontext.h */