1 /* Machine-dependent signal context structure for GNU Hurd. x86_64 version.
2 Copyright (C) 1991-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19 #ifndef _BITS_SIGCONTEXT_H
20 #define _BITS_SIGCONTEXT_H 1
21
22 #if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
23 # error "Never use <bits/sigcontext.h> directly; include <signal.h> instead."
24 #endif
25
26 /* Signal handlers are actually called:
27 void handler (int sig, int code, struct sigcontext *scp); */
28
29 #include <bits/types/__sigset_t.h>
30 #include <mach/machine/fp_reg.h>
31
32 /* State of this thread when the signal was taken. */
33 struct sigcontext
34 {
35 /* These first members are machine-independent. */
36
37 int sc_onstack; /* Nonzero if running on sigstack. */
38 __sigset_t sc_mask; /* Blocked signals to restore. */
39
40 /* MiG reply port this thread is using. */
41 unsigned int sc_reply_port;
42
43 /* Port this thread is doing an interruptible RPC on. */
44 unsigned int sc_intr_port;
45
46 /* Error code associated with this signal (interpreted as `error_t'). */
47 int sc_error;
48
49 /* Make sure the below members are properly aligned, and not packed
50 together with sc_error -- otherwise the layout won't match that of
51 i386_thread_state. */
52 int sc_pad1;
53
54 /* All following members are machine-dependent. The rest of this
55 structure is written to be laid out identically to:
56 {
57 struct i386_thread_state basic;
58 struct i386_float_state fpu;
59 }
60 trampoline.c knows this, so it must be changed if this changes. */
61
62 #define sc_i386_thread_state sc_gs /* Beginning of correspondence. */
63 /* Segment registers. */
64 int sc_gs;
65 int sc_fs;
66 int sc_es;
67 int sc_ds;
68
69 long sc_r8;
70 long sc_r9;
71 long sc_r10;
72 long sc_r11;
73 long sc_r12;
74 long sc_r13;
75 long sc_r14;
76 long sc_r15;
77 long sc_rdi;
78 long sc_rsi;
79 long sc_rbp;
80 long sc_rsp; /* Not used; sc_ursp is used instead. */
81 long sc_rbx;
82 long sc_rdx;
83 long sc_rcx;
84 long sc_rax;
85 long sc_rip; /* Instruction pointer. */
86
87 int sc_cs; /* Code segment register. */
88
89 long sc_rfl; /* Processor flags. */
90
91 long sc_ursp; /* This stack pointer is used. */
92 int sc_ss; /* Stack segment register. */
93
94 /* Make sure the below has the same layout as i386_float_state. */
95 int sc_pad2;
96
97 /* Following mimics struct i386_float_state. Structures and symbolic
98 values can be found in <mach/i386/fp_reg.h>. */
99 #define sc_i386_float_state sc_fpkind
100 int sc_fpkind; /* FP_NO, FP_387, etc. */
101 int sc_fpused; /* If zero, ignore rest of float state. */
102 struct i386_fp_save sc_fpsave;
103 struct i386_fp_regs sc_fpregs;
104 int sc_fpexcsr; /* FPSR including exception bits. */
105 };
106
107 /* Traditional BSD names for some members. */
108 #define sc_sp sc_ursp /* Stack pointer. */
109 #define sc_fp sc_rbp /* Frame pointer. */
110 #define sc_pc sc_rip /* Process counter. */
111 #define sc_ps sc_rfl
112
113
114 /* The deprecated sigcode values below are passed as an extra, non-portable
115 argument to regular signal handlers. You should use SA_SIGINFO handlers
116 instead, which use the standard POSIX signal codes. */
117
118 /* Codes for SIGFPE. */
119 #define FPE_INTOVF_TRAP 0x1 /* integer overflow */
120 #define FPE_INTDIV_FAULT 0x2 /* integer divide by zero */
121 #define FPE_FLTOVF_FAULT 0x3 /* floating overflow */
122 #define FPE_FLTDIV_FAULT 0x4 /* floating divide by zero */
123 #define FPE_FLTUND_FAULT 0x5 /* floating underflow */
124 #define FPE_SUBRNG_FAULT 0x7 /* BOUNDS instruction failed */
125 #define FPE_FLTDNR_FAULT 0x8 /* denormalized operand */
126 #define FPE_FLTINX_FAULT 0x9 /* floating loss of precision */
127 #define FPE_EMERR_FAULT 0xa /* mysterious emulation error 33 */
128 #define FPE_EMBND_FAULT 0xb /* emulation BOUNDS instruction failed */
129
130 /* Codes for SIGILL. */
131 #define ILL_INVOPR_FAULT 0x1 /* invalid operation */
132 #define ILL_STACK_FAULT 0x2 /* fault on microkernel stack access */
133 #define ILL_FPEOPR_FAULT 0x3 /* invalid floating operation */
134
135 /* Codes for SIGTRAP. */
136 #define DBG_SINGLE_TRAP 0x1 /* single step */
137 #define DBG_BRKPNT_FAULT 0x2 /* breakpoint instruction */
138
139 #endif /* bits/sigcontext.h */