2.9
[glibc/nacl-glibc.git] / sysdeps / unix / sysv / linux / sparc / sys / ucontext.h
blobb1102b04c40cc6fe4303ff7fb4d167c26c164451
1 /* Copyright (C) 1998, 1999 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, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
19 #ifndef _SYS_UCONTEXT_H
20 #define _SYS_UCONTEXT_H 1
22 #include <features.h>
23 #include <signal.h>
24 #include <bits/wordsize.h>
26 #if __WORDSIZE == 64
28 #define MC_TSTATE 0
29 #define MC_PC 1
30 #define MC_NPC 2
31 #define MC_Y 3
32 #define MC_G1 4
33 #define MC_G2 5
34 #define MC_G3 6
35 #define MC_G4 7
36 #define MC_G5 8
37 #define MC_G6 9
38 #define MC_G7 10
39 #define MC_O0 11
40 #define MC_O1 12
41 #define MC_O2 13
42 #define MC_O3 14
43 #define MC_O4 15
44 #define MC_O5 16
45 #define MC_O6 17
46 #define MC_O7 18
47 #define MC_NGREG 19
49 typedef unsigned long mc_greg_t;
50 typedef mc_greg_t mc_gregset_t[MC_NGREG];
52 #define MC_MAXFPQ 16
53 struct mc_fq {
54 unsigned long *mcfq_addr;
55 unsigned int mcfq_insn;
58 struct mc_fpu {
59 union {
60 unsigned int sregs[32];
61 unsigned long dregs[32];
62 long double qregs[16];
63 } mcfpu_fregs;
64 unsigned long mcfpu_fsr;
65 unsigned long mcfpu_fprs;
66 unsigned long mcfpu_gsr;
67 struct mc_fq *mcfpu_fq;
68 unsigned char mcfpu_qcnt;
69 unsigned char mcfpu_qentsz;
70 unsigned char mcfpu_enab;
72 typedef struct mc_fpu mc_fpu_t;
74 typedef struct {
75 mc_gregset_t mc_gregs;
76 mc_greg_t mc_fp;
77 mc_greg_t mc_i7;
78 mc_fpu_t mc_fpregs;
79 } mcontext_t;
81 typedef struct ucontext {
82 struct ucontext *uc_link;
83 unsigned long uc_flags;
84 unsigned long __uc_sigmask;
85 mcontext_t uc_mcontext;
86 stack_t uc_stack;
87 __sigset_t uc_sigmask;
88 } ucontext_t;
90 #endif /* __WORDISIZE == 64 */
93 * Location of the users' stored registers relative to R0.
94 * Usage is as an index into a gregset_t array or as u.u_ar0[XX].
96 #define REG_PSR (0)
97 #define REG_PC (1)
98 #define REG_nPC (2)
99 #define REG_Y (3)
100 #define REG_G1 (4)
101 #define REG_G2 (5)
102 #define REG_G3 (6)
103 #define REG_G4 (7)
104 #define REG_G5 (8)
105 #define REG_G6 (9)
106 #define REG_G7 (10)
107 #define REG_O0 (11)
108 #define REG_O1 (12)
109 #define REG_O2 (13)
110 #define REG_O3 (14)
111 #define REG_O4 (15)
112 #define REG_O5 (16)
113 #define REG_O6 (17)
114 #define REG_O7 (18)
117 * A gregset_t is defined as an array type for compatibility with the reference
118 * source. This is important due to differences in the way the C language
119 * treats arrays and structures as parameters.
121 * Note that NGREG is really (sizeof (struct regs) / sizeof (greg_t)),
122 * but that the ABI defines it absolutely to be 21 (resp. 19).
125 #if __WORDSIZE == 64
127 #define REG_ASI (19)
128 #define REG_FPRS (20)
130 #define NGREG 21
131 typedef long greg_t;
133 #else /* __WORDSIZE == 32 */
135 #define NGREG 19
136 typedef int greg_t;
138 #endif /* __WORDSIZE == 32 */
140 typedef greg_t gregset_t[NGREG];
143 * The following structures define how a register window can appear on the
144 * stack. This structure is available (when required) through the `gwins'
145 * field of an mcontext (nested within ucontext). SPARC_MAXWINDOW is the
146 * maximum number of outstanding regiters window defined in the SPARC
147 * architecture (*not* implementation).
149 #define SPARC_MAXREGWINDOW 31 /* max windows in SPARC arch. */
150 struct rwindow
152 greg_t rw_local[8]; /* locals */
153 greg_t rw_in[8]; /* ins */
156 #define rw_fp rw_in[6] /* frame pointer */
157 #define rw_rtn rw_in[7] /* return address */
159 typedef struct gwindows
161 int wbcnt;
162 int *spbuf[SPARC_MAXREGWINDOW];
163 struct rwindow wbuf[SPARC_MAXREGWINDOW];
164 } gwindows_t;
167 * Floating point definitions.
170 #define MAXFPQ 16 /* max # of fpu queue entries currently supported */
173 * struct fq defines the minimal format of a floating point instruction queue
174 * entry. The size of entries in the floating point queue are implementation
175 * dependent. The union FQu is guarenteed to be the first field in any ABI
176 * conformant system implementation. Any additional fields provided by an
177 * implementation should not be used applications designed to be ABI conformant. */
179 struct fpq
181 unsigned long *fpq_addr; /* address */
182 unsigned long fpq_instr; /* instruction */
185 struct fq
187 union /* FPU inst/addr queue */
189 double whole;
190 struct fpq fpq;
191 } FQu;
194 #define FPU_REGS_TYPE unsigned
195 #define FPU_DREGS_TYPE unsigned long long
196 #define V7_FPU_FSR_TYPE unsigned
197 #define V9_FPU_FSR_TYPE unsigned long long
198 #define V9_FPU_FPRS_TYPE unsigned
200 #if __WORDSIZE == 64
202 typedef struct fpu
204 union { /* FPU floating point regs */
205 unsigned fpu_regs[32]; /* 32 singles */
206 double fpu_dregs[16]; /* 32 doubles */
207 long double fpu_qregs[16]; /* 16 quads */
208 } fpu_fr;
209 struct fq *fpu_q; /* ptr to array of FQ entries */
210 unsigned long fpu_fsr; /* FPU status register */
211 unsigned char fpu_qcnt; /* # of entries in saved FQ */
212 unsigned char fpu_q_entrysize; /* # of bytes per FQ entry */
213 unsigned char fpu_en; /* flag signifying fpu in use */
214 } fpregset_t;
216 #else /* __WORDSIZE == 32 */
218 typedef struct fpu
220 union { /* FPU floating point regs */
221 unsigned long long fpu_regs[32]; /* 32 singles */
222 double fpu_dregs[16]; /* 16 doubles */
223 } fpu_fr;
224 struct fq *fpu_q; /* ptr to array of FQ entries */
225 unsigned fpu_fsr; /* FPU status register */
226 unsigned char fpu_qcnt; /* # of entries in saved FQ */
227 unsigned char fpu_q_entrysize; /* # of bytes per FQ entry */
228 unsigned char fpu_en; /* flag signifying fpu in use */
229 } fpregset_t;
232 * The following structure is for associating extra register state with
233 * the ucontext structure and is kept within the uc_mcontext filler area.
235 * If (xrs_id == XRS_ID) then the xrs_ptr field is a valid pointer to
236 * extra register state. The exact format of the extra register state
237 * pointed to by xrs_ptr is platform-dependent.
239 * Note: a platform may or may not manage extra register state.
241 typedef struct
243 unsigned int xrs_id; /* indicates xrs_ptr validity */
244 void * xrs_ptr; /* ptr to extra reg state */
245 } xrs_t;
247 #define XRS_ID 0x78727300 /* the string "xrs" */
249 typedef struct
251 gregset_t gregs; /* general register set */
252 gwindows_t *gwins; /* POSSIBLE pointer to register windows */
253 fpregset_t fpregs; /* floating point register set */
254 xrs_t xrs; /* POSSIBLE extra register state association */
255 long filler[19];
256 } mcontext_t;
259 /* Userlevel context. */
260 typedef struct ucontext
262 unsigned long uc_flags;
263 struct ucontext *uc_link;
264 __sigset_t uc_sigmask;
265 stack_t uc_stack;
266 mcontext_t uc_mcontext;
267 } ucontext_t;
269 #endif /* __WORDSIZE == 32 */
270 #endif /* sys/ucontext.h */