1 /* Copyright (C) 1998-2024 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 <https://www.gnu.org/licenses/>. */
18 #ifndef _SYS_UCONTEXT_H
19 #define _SYS_UCONTEXT_H 1
23 #include <bits/types/sigset_t.h>
24 #include <bits/types/stack_t.h>
26 #include <bits/wordsize.h>
30 # define __ctx(fld) fld
32 # define __ctx(fld) __ ## fld
58 # define MC_NGREG __MC_NGREG
61 typedef unsigned long mc_greg_t
;
62 typedef mc_greg_t mc_gregset_t
[__MC_NGREG
];
68 unsigned long *__ctx(mcfq_addr
);
69 unsigned int __ctx(mcfq_insn
);
74 unsigned int __ctx(sregs
)[32];
75 unsigned long __ctx(dregs
)[32];
76 long double __ctx(qregs
)[16];
78 unsigned long __ctx(mcfpu_fsr
);
79 unsigned long __ctx(mcfpu_fprs
);
80 unsigned long __ctx(mcfpu_gsr
);
81 struct __mc_fq
*__ctx(mcfpu_fq
);
82 unsigned char __ctx(mcfpu_qcnt
);
83 unsigned char __ctx(mcfpu_qentsz
);
84 unsigned char __ctx(mcfpu_enab
);
88 mc_gregset_t
__ctx(mc_gregs
);
89 mc_greg_t
__ctx(mc_fp
);
90 mc_greg_t
__ctx(mc_i7
);
91 mc_fpu_t
__ctx(mc_fpregs
);
94 typedef struct ucontext_t
{
95 struct ucontext_t
*uc_link
;
96 unsigned long __ctx(uc_flags
);
97 unsigned long __uc_sigmask
;
98 mcontext_t uc_mcontext
;
103 #endif /* __WORDISIZE == 64 */
106 * Location of the users' stored registers relative to R0.
107 * Usage is as an index into a gregset_t array or as u.u_ar0[XX].
132 * A gregset_t is defined as an array type for compatibility with the reference
133 * source. This is important due to differences in the way the C language
134 * treats arrays and structures as parameters.
136 * Note that NGREG is really (sizeof (struct regs) / sizeof (greg_t)),
137 * but that the ABI defines it absolutely to be 21 (resp. 19).
144 # define REG_ASI (19)
145 # define REG_FPRS (20)
147 # define NGREG __NGREG
151 #else /* __WORDSIZE == 32 */
155 # define NGREG __NGREG
159 #endif /* __WORDSIZE == 32 */
161 typedef greg_t gregset_t
[__NGREG
];
164 * The following structures define how a register window can appear on the
165 * stack. This structure is available (when required) through the `gwins'
166 * field of an mcontext (nested within ucontext). SPARC_MAXWINDOW is the
167 * maximum number of outstanding registers window defined in the SPARC
168 * architecture (*not* implementation).
170 # define __SPARC_MAXREGWINDOW 31 /* max windows in SPARC arch. */
172 # define SPARC_MAXREGWINDOW __SPARC_MAXREGWINDOW
176 greg_t
__ctx(rw_local
)[8]; /* locals */
177 greg_t
__ctx(rw_in
)[8]; /* ins */
181 # define rw_fp __ctx(rw_in)[6] /* frame pointer */
182 # define rw_rtn __ctx(rw_in)[7] /* return address */
188 int *__ctx(spbuf
)[__SPARC_MAXREGWINDOW
];
189 struct __rwindow
__ctx(wbuf
)[__SPARC_MAXREGWINDOW
];
193 * Floating point definitions.
197 # define MAXFPQ 16 /* max # of fpu queue entries currently supported */
201 * struct fq defines the minimal format of a floating point instruction queue
202 * entry. The size of entries in the floating point queue are implementation
203 * dependent. The union FQu is guaranteed to be the first field in any ABI
204 * conformant system implementation. Any additional fields provided by an
205 * implementation should not be used applications designed to be ABI conformant. */
209 unsigned long *__ctx(fpq_addr
); /* address */
210 unsigned long __ctx(fpq_instr
); /* instruction */
215 union /* FPU inst/addr queue */
218 struct __fpq
__ctx(fpq
);
223 # define FPU_REGS_TYPE unsigned
224 # define FPU_DREGS_TYPE unsigned long long
225 # define V7_FPU_FSR_TYPE unsigned
226 # define V9_FPU_FSR_TYPE unsigned long long
227 # define V9_FPU_FPRS_TYPE unsigned
234 union { /* FPU floating point regs */
235 unsigned __ctx(fpu_regs
)[32]; /* 32 singles */
236 double __ctx(fpu_dregs
)[32]; /* 32 doubles */
237 long double __ctx(fpu_qregs
)[16]; /* 16 quads */
239 struct __fq
*__ctx(fpu_q
); /* ptr to array of FQ entries */
240 unsigned long __ctx(fpu_fsr
); /* FPU status register */
241 unsigned char __ctx(fpu_qcnt
); /* # of entries in saved FQ */
242 unsigned char __ctx(fpu_q_entrysize
); /* # of bytes per FQ entry */
243 unsigned char __ctx(fpu_en
); /* flag signifying fpu in use */
246 #else /* __WORDSIZE == 32 */
250 union { /* FPU floating point regs */
251 __extension__
unsigned long long __ctx(fpu_regs
)[32]; /* 32 singles */
252 double __ctx(fpu_dregs
)[16]; /* 16 doubles */
254 struct __fq
*__ctx(fpu_q
); /* ptr to array of FQ entries */
255 unsigned __ctx(fpu_fsr
); /* FPU status register */
256 unsigned char __ctx(fpu_qcnt
); /* # of entries in saved FQ */
257 unsigned char __ctx(fpu_q_entrysize
); /* # of bytes per FQ entry */
258 unsigned char __ctx(fpu_en
); /* flag signifying fpu in use */
262 * The following structure is for associating extra register state with
263 * the ucontext structure and is kept within the uc_mcontext filler area.
265 * If (xrs_id == XRS_ID) then the xrs_ptr field is a valid pointer to
266 * extra register state. The exact format of the extra register state
267 * pointed to by xrs_ptr is platform-dependent.
269 * Note: a platform may or may not manage extra register state.
273 unsigned int __ctx(xrs_id
); /* indicates xrs_ptr validity */
274 void * __ctx(xrs_ptr
); /* ptr to extra reg state */
278 # define XRS_ID 0x78727300 /* the string "xrs" */
283 gregset_t
__ctx(gregs
); /* general register set */
284 gwindows_t
*__ctx(gwins
); /* POSSIBLE pointer to register
286 fpregset_t
__ctx(fpregs
); /* floating point register set */
287 xrs_t
__ctx(xrs
); /* POSSIBLE extra register state
289 long __glibc_reserved1
[19];
293 /* Userlevel context. */
294 typedef struct ucontext_t
296 unsigned long __ctx(uc_flags
);
297 struct ucontext_t
*uc_link
;
300 mcontext_t uc_mcontext
;
303 #endif /* __WORDSIZE == 32 */
304 #endif /* sys/ucontext.h */