Fix sys/ucontext.h namespace from signal.h etc. inclusion (bug 21457).
[glibc.git] / sysdeps / unix / sysv / linux / sparc / sys / ucontext.h
blob7ce5f2b881a89ac446e2495d760f8cf657e8a414
1 /* Copyright (C) 1998-2017 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>
23 #include <bits/types/sigset_t.h>
24 #include <bits/sigcontext.h>
25 #include <bits/types/stack_t.h>
27 #include <bits/wordsize.h>
30 #if __WORDSIZE == 64
32 #define MC_TSTATE 0
33 #define MC_PC 1
34 #define MC_NPC 2
35 #define MC_Y 3
36 #define MC_G1 4
37 #define MC_G2 5
38 #define MC_G3 6
39 #define MC_G4 7
40 #define MC_G5 8
41 #define MC_G6 9
42 #define MC_G7 10
43 #define MC_O0 11
44 #define MC_O1 12
45 #define MC_O2 13
46 #define MC_O3 14
47 #define MC_O4 15
48 #define MC_O5 16
49 #define MC_O6 17
50 #define MC_O7 18
51 #define MC_NGREG 19
53 typedef unsigned long mc_greg_t;
54 typedef mc_greg_t mc_gregset_t[MC_NGREG];
56 #define MC_MAXFPQ 16
57 struct mc_fq {
58 unsigned long *mcfq_addr;
59 unsigned int mcfq_insn;
62 struct mc_fpu {
63 union {
64 unsigned int sregs[32];
65 unsigned long dregs[32];
66 long double qregs[16];
67 } mcfpu_fregs;
68 unsigned long mcfpu_fsr;
69 unsigned long mcfpu_fprs;
70 unsigned long mcfpu_gsr;
71 struct mc_fq *mcfpu_fq;
72 unsigned char mcfpu_qcnt;
73 unsigned char mcfpu_qentsz;
74 unsigned char mcfpu_enab;
76 typedef struct mc_fpu mc_fpu_t;
78 typedef struct {
79 mc_gregset_t mc_gregs;
80 mc_greg_t mc_fp;
81 mc_greg_t mc_i7;
82 mc_fpu_t mc_fpregs;
83 } mcontext_t;
85 typedef struct ucontext {
86 struct ucontext *uc_link;
87 unsigned long uc_flags;
88 unsigned long __uc_sigmask;
89 mcontext_t uc_mcontext;
90 stack_t uc_stack;
91 sigset_t uc_sigmask;
92 } ucontext_t;
94 #endif /* __WORDISIZE == 64 */
97 * Location of the users' stored registers relative to R0.
98 * Usage is as an index into a gregset_t array or as u.u_ar0[XX].
100 #define REG_PSR (0)
101 #define REG_PC (1)
102 #define REG_nPC (2)
103 #define REG_Y (3)
104 #define REG_G1 (4)
105 #define REG_G2 (5)
106 #define REG_G3 (6)
107 #define REG_G4 (7)
108 #define REG_G5 (8)
109 #define REG_G6 (9)
110 #define REG_G7 (10)
111 #define REG_O0 (11)
112 #define REG_O1 (12)
113 #define REG_O2 (13)
114 #define REG_O3 (14)
115 #define REG_O4 (15)
116 #define REG_O5 (16)
117 #define REG_O6 (17)
118 #define REG_O7 (18)
121 * A gregset_t is defined as an array type for compatibility with the reference
122 * source. This is important due to differences in the way the C language
123 * treats arrays and structures as parameters.
125 * Note that NGREG is really (sizeof (struct regs) / sizeof (greg_t)),
126 * but that the ABI defines it absolutely to be 21 (resp. 19).
129 #if __WORDSIZE == 64
131 #define REG_ASI (19)
132 #define REG_FPRS (20)
134 #define NGREG 21
135 typedef long greg_t;
137 #else /* __WORDSIZE == 32 */
139 #define NGREG 19
140 typedef int greg_t;
142 #endif /* __WORDSIZE == 32 */
144 typedef greg_t gregset_t[NGREG];
147 * The following structures define how a register window can appear on the
148 * stack. This structure is available (when required) through the `gwins'
149 * field of an mcontext (nested within ucontext). SPARC_MAXWINDOW is the
150 * maximum number of outstanding regiters window defined in the SPARC
151 * architecture (*not* implementation).
153 #define SPARC_MAXREGWINDOW 31 /* max windows in SPARC arch. */
154 struct rwindow
156 greg_t rw_local[8]; /* locals */
157 greg_t rw_in[8]; /* ins */
160 #define rw_fp rw_in[6] /* frame pointer */
161 #define rw_rtn rw_in[7] /* return address */
163 typedef struct gwindows
165 int wbcnt;
166 int *spbuf[SPARC_MAXREGWINDOW];
167 struct rwindow wbuf[SPARC_MAXREGWINDOW];
168 } gwindows_t;
171 * Floating point definitions.
174 #define MAXFPQ 16 /* max # of fpu queue entries currently supported */
177 * struct fq defines the minimal format of a floating point instruction queue
178 * entry. The size of entries in the floating point queue are implementation
179 * dependent. The union FQu is guarenteed to be the first field in any ABI
180 * conformant system implementation. Any additional fields provided by an
181 * implementation should not be used applications designed to be ABI conformant. */
183 struct fpq
185 unsigned long *fpq_addr; /* address */
186 unsigned long fpq_instr; /* instruction */
189 struct fq
191 union /* FPU inst/addr queue */
193 double whole;
194 struct fpq fpq;
195 } FQu;
198 #define FPU_REGS_TYPE unsigned
199 #define FPU_DREGS_TYPE unsigned long long
200 #define V7_FPU_FSR_TYPE unsigned
201 #define V9_FPU_FSR_TYPE unsigned long long
202 #define V9_FPU_FPRS_TYPE unsigned
204 #if __WORDSIZE == 64
206 typedef struct fpu
208 union { /* FPU floating point regs */
209 unsigned fpu_regs[32]; /* 32 singles */
210 double fpu_dregs[32]; /* 32 doubles */
211 long double fpu_qregs[16]; /* 16 quads */
212 } fpu_fr;
213 struct fq *fpu_q; /* ptr to array of FQ entries */
214 unsigned long fpu_fsr; /* FPU status register */
215 unsigned char fpu_qcnt; /* # of entries in saved FQ */
216 unsigned char fpu_q_entrysize; /* # of bytes per FQ entry */
217 unsigned char fpu_en; /* flag signifying fpu in use */
218 } fpregset_t;
220 #else /* __WORDSIZE == 32 */
222 typedef struct fpu
224 union { /* FPU floating point regs */
225 __extension__ unsigned long long fpu_regs[32]; /* 32 singles */
226 double fpu_dregs[16]; /* 16 doubles */
227 } fpu_fr;
228 struct fq *fpu_q; /* ptr to array of FQ entries */
229 unsigned fpu_fsr; /* FPU status register */
230 unsigned char fpu_qcnt; /* # of entries in saved FQ */
231 unsigned char fpu_q_entrysize; /* # of bytes per FQ entry */
232 unsigned char fpu_en; /* flag signifying fpu in use */
233 } fpregset_t;
236 * The following structure is for associating extra register state with
237 * the ucontext structure and is kept within the uc_mcontext filler area.
239 * If (xrs_id == XRS_ID) then the xrs_ptr field is a valid pointer to
240 * extra register state. The exact format of the extra register state
241 * pointed to by xrs_ptr is platform-dependent.
243 * Note: a platform may or may not manage extra register state.
245 typedef struct
247 unsigned int xrs_id; /* indicates xrs_ptr validity */
248 void * xrs_ptr; /* ptr to extra reg state */
249 } xrs_t;
251 #define XRS_ID 0x78727300 /* the string "xrs" */
253 typedef struct
255 gregset_t gregs; /* general register set */
256 gwindows_t *gwins; /* POSSIBLE pointer to register windows */
257 fpregset_t fpregs; /* floating point register set */
258 xrs_t xrs; /* POSSIBLE extra register state association */
259 long filler[19];
260 } mcontext_t;
263 /* Userlevel context. */
264 typedef struct ucontext
266 unsigned long uc_flags;
267 struct ucontext *uc_link;
268 sigset_t uc_sigmask;
269 stack_t uc_stack;
270 mcontext_t uc_mcontext;
271 } ucontext_t;
273 #endif /* __WORDSIZE == 32 */
274 #endif /* sys/ucontext.h */