Update copyright notices with scripts/update-copyrights
[glibc.git] / sysdeps / unix / sysv / linux / sparc / sys / ucontext.h
blobd9f1c0f1da938897fd5bcf1ce1bccb00a909a706
1 /* Copyright (C) 1998-2014 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
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.
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.
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/>. */
18 #ifndef _SYS_UCONTEXT_H
19 #define _SYS_UCONTEXT_H 1
21 #include <features.h>
22 #include <signal.h>
23 #include <bits/wordsize.h>
25 #if __WORDSIZE == 64
27 #define MC_TSTATE 0
28 #define MC_PC 1
29 #define MC_NPC 2
30 #define MC_Y 3
31 #define MC_G1 4
32 #define MC_G2 5
33 #define MC_G3 6
34 #define MC_G4 7
35 #define MC_G5 8
36 #define MC_G6 9
37 #define MC_G7 10
38 #define MC_O0 11
39 #define MC_O1 12
40 #define MC_O2 13
41 #define MC_O3 14
42 #define MC_O4 15
43 #define MC_O5 16
44 #define MC_O6 17
45 #define MC_O7 18
46 #define MC_NGREG 19
48 typedef unsigned long mc_greg_t;
49 typedef mc_greg_t mc_gregset_t[MC_NGREG];
51 #define MC_MAXFPQ 16
52 struct mc_fq {
53 unsigned long *mcfq_addr;
54 unsigned int mcfq_insn;
57 struct mc_fpu {
58 union {
59 unsigned int sregs[32];
60 unsigned long dregs[32];
61 long double qregs[16];
62 } mcfpu_fregs;
63 unsigned long mcfpu_fsr;
64 unsigned long mcfpu_fprs;
65 unsigned long mcfpu_gsr;
66 struct mc_fq *mcfpu_fq;
67 unsigned char mcfpu_qcnt;
68 unsigned char mcfpu_qentsz;
69 unsigned char mcfpu_enab;
71 typedef struct mc_fpu mc_fpu_t;
73 typedef struct {
74 mc_gregset_t mc_gregs;
75 mc_greg_t mc_fp;
76 mc_greg_t mc_i7;
77 mc_fpu_t mc_fpregs;
78 } mcontext_t;
80 typedef struct ucontext {
81 struct ucontext *uc_link;
82 unsigned long uc_flags;
83 unsigned long __uc_sigmask;
84 mcontext_t uc_mcontext;
85 stack_t uc_stack;
86 __sigset_t uc_sigmask;
87 } ucontext_t;
89 #endif /* __WORDISIZE == 64 */
92 * Location of the users' stored registers relative to R0.
93 * Usage is as an index into a gregset_t array or as u.u_ar0[XX].
95 #define REG_PSR (0)
96 #define REG_PC (1)
97 #define REG_nPC (2)
98 #define REG_Y (3)
99 #define REG_G1 (4)
100 #define REG_G2 (5)
101 #define REG_G3 (6)
102 #define REG_G4 (7)
103 #define REG_G5 (8)
104 #define REG_G6 (9)
105 #define REG_G7 (10)
106 #define REG_O0 (11)
107 #define REG_O1 (12)
108 #define REG_O2 (13)
109 #define REG_O3 (14)
110 #define REG_O4 (15)
111 #define REG_O5 (16)
112 #define REG_O6 (17)
113 #define REG_O7 (18)
116 * A gregset_t is defined as an array type for compatibility with the reference
117 * source. This is important due to differences in the way the C language
118 * treats arrays and structures as parameters.
120 * Note that NGREG is really (sizeof (struct regs) / sizeof (greg_t)),
121 * but that the ABI defines it absolutely to be 21 (resp. 19).
124 #if __WORDSIZE == 64
126 #define REG_ASI (19)
127 #define REG_FPRS (20)
129 #define NGREG 21
130 typedef long greg_t;
132 #else /* __WORDSIZE == 32 */
134 #define NGREG 19
135 typedef int greg_t;
137 #endif /* __WORDSIZE == 32 */
139 typedef greg_t gregset_t[NGREG];
142 * The following structures define how a register window can appear on the
143 * stack. This structure is available (when required) through the `gwins'
144 * field of an mcontext (nested within ucontext). SPARC_MAXWINDOW is the
145 * maximum number of outstanding regiters window defined in the SPARC
146 * architecture (*not* implementation).
148 #define SPARC_MAXREGWINDOW 31 /* max windows in SPARC arch. */
149 struct rwindow
151 greg_t rw_local[8]; /* locals */
152 greg_t rw_in[8]; /* ins */
155 #define rw_fp rw_in[6] /* frame pointer */
156 #define rw_rtn rw_in[7] /* return address */
158 typedef struct gwindows
160 int wbcnt;
161 int *spbuf[SPARC_MAXREGWINDOW];
162 struct rwindow wbuf[SPARC_MAXREGWINDOW];
163 } gwindows_t;
166 * Floating point definitions.
169 #define MAXFPQ 16 /* max # of fpu queue entries currently supported */
172 * struct fq defines the minimal format of a floating point instruction queue
173 * entry. The size of entries in the floating point queue are implementation
174 * dependent. The union FQu is guarenteed to be the first field in any ABI
175 * conformant system implementation. Any additional fields provided by an
176 * implementation should not be used applications designed to be ABI conformant. */
178 struct fpq
180 unsigned long *fpq_addr; /* address */
181 unsigned long fpq_instr; /* instruction */
184 struct fq
186 union /* FPU inst/addr queue */
188 double whole;
189 struct fpq fpq;
190 } FQu;
193 #define FPU_REGS_TYPE unsigned
194 #define FPU_DREGS_TYPE unsigned long long
195 #define V7_FPU_FSR_TYPE unsigned
196 #define V9_FPU_FSR_TYPE unsigned long long
197 #define V9_FPU_FPRS_TYPE unsigned
199 #if __WORDSIZE == 64
201 typedef struct fpu
203 union { /* FPU floating point regs */
204 unsigned fpu_regs[32]; /* 32 singles */
205 double fpu_dregs[16]; /* 32 doubles */
206 long double fpu_qregs[16]; /* 16 quads */
207 } fpu_fr;
208 struct fq *fpu_q; /* ptr to array of FQ entries */
209 unsigned long fpu_fsr; /* FPU status register */
210 unsigned char fpu_qcnt; /* # of entries in saved FQ */
211 unsigned char fpu_q_entrysize; /* # of bytes per FQ entry */
212 unsigned char fpu_en; /* flag signifying fpu in use */
213 } fpregset_t;
215 #else /* __WORDSIZE == 32 */
217 typedef struct fpu
219 union { /* FPU floating point regs */
220 __extension__ unsigned long long fpu_regs[32]; /* 32 singles */
221 double fpu_dregs[16]; /* 16 doubles */
222 } fpu_fr;
223 struct fq *fpu_q; /* ptr to array of FQ entries */
224 unsigned fpu_fsr; /* FPU status register */
225 unsigned char fpu_qcnt; /* # of entries in saved FQ */
226 unsigned char fpu_q_entrysize; /* # of bytes per FQ entry */
227 unsigned char fpu_en; /* flag signifying fpu in use */
228 } fpregset_t;
231 * The following structure is for associating extra register state with
232 * the ucontext structure and is kept within the uc_mcontext filler area.
234 * If (xrs_id == XRS_ID) then the xrs_ptr field is a valid pointer to
235 * extra register state. The exact format of the extra register state
236 * pointed to by xrs_ptr is platform-dependent.
238 * Note: a platform may or may not manage extra register state.
240 typedef struct
242 unsigned int xrs_id; /* indicates xrs_ptr validity */
243 void * xrs_ptr; /* ptr to extra reg state */
244 } xrs_t;
246 #define XRS_ID 0x78727300 /* the string "xrs" */
248 typedef struct
250 gregset_t gregs; /* general register set */
251 gwindows_t *gwins; /* POSSIBLE pointer to register windows */
252 fpregset_t fpregs; /* floating point register set */
253 xrs_t xrs; /* POSSIBLE extra register state association */
254 long filler[19];
255 } mcontext_t;
258 /* Userlevel context. */
259 typedef struct ucontext
261 unsigned long uc_flags;
262 struct ucontext *uc_link;
263 __sigset_t uc_sigmask;
264 stack_t uc_stack;
265 mcontext_t uc_mcontext;
266 } ucontext_t;
268 #endif /* __WORDSIZE == 32 */
269 #endif /* sys/ucontext.h */