signal.h (2537B)
1 /* -*-comment-start: "//";comment-end:""-*- 2 * GNU Mes --- Maxwell Equations of Software 3 * Copyright © 2024 Ekaitz Zarraga <ekaitz@elenq.tech> 4 * 5 * This file is part of GNU Mes. 6 * 7 * GNU Mes is free software; you can redistribute it and/or modify it 8 * under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 3 of the License, or (at 10 * your option) any later version. 11 * 12 * GNU Mes is distributed in the hope that it will be useful, but 13 * WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 // Taken from musl libc (4a16ddf5) and simplified 22 23 #define REG_R8 0 24 #define REG_R9 1 25 #define REG_R10 2 26 #define REG_R11 3 27 #define REG_R12 4 28 #define REG_R13 5 29 #define REG_R14 6 30 #define REG_R15 7 31 #define REG_RDI 8 32 #define REG_RSI 9 33 #define REG_RBP 10 34 #define REG_RBX 11 35 #define REG_RDX 12 36 #define REG_RAX 13 37 #define REG_RCX 14 38 #define REG_RSP 15 39 #define REG_RIP 16 40 #define REG_EFL 17 41 #define REG_CSGSFS 18 42 #define REG_ERR 19 43 #define REG_TRAPNO 20 44 #define REG_OLDMASK 21 45 #define REG_CR2 22 46 47 typedef long long greg_t; 48 typedef long long gregset_t[23]; 49 50 struct __st 51 { 52 unsigned short significand[4], exponent, padding[3]; 53 }; 54 55 struct _xmm 56 { 57 unsigned element[4]; 58 }; 59 60 typedef struct _fpstate 61 { 62 unsigned short cwd, swd, ftw, fop; 63 unsigned long long rip, rdp; 64 unsigned mxcsr, mxcr_mask; 65 struct __st _st[8]; 66 struct _xmm _xmm[16]; 67 unsigned padding[24]; 68 } *fpregset_t; 69 70 struct sigcontext 71 { 72 unsigned long r8, r9, r10, r11, r12, r13, r14, r15; 73 unsigned long rdi, rsi, rbp, rbx, rdx, rax, rcx, rsp, rip, eflags; 74 unsigned short cs, gs, fs, __pad0; 75 unsigned long err, trapno, oldmask, cr2; 76 struct _fpstate *fpstate; 77 unsigned long __reserved1[8]; 78 }; 79 80 typedef struct 81 { 82 gregset_t gregs; 83 fpregset_t fpregs; 84 unsigned long long __reserved1[8]; 85 } mcontext_t; 86 87 struct sigaltstack 88 { 89 void *ss_sp; 90 int ss_flags; 91 size_t ss_size; 92 }; 93 94 typedef struct __ucontext 95 { 96 unsigned long uc_flags; 97 struct __ucontext *uc_link; 98 stack_t uc_stack; 99 mcontext_t uc_mcontext; 100 sigset_t uc_sigmask; 101 unsigned long __fpregs_mem[64]; 102 } ucontext_t;