| 1 | /* Copyright (C) 1997-2026 Free Software Foundation, Inc. This file is part of the GNU C Library. |
| 2 | |
| 3 | The GNU C Library is free software; you can redistribute it and/or |
| 4 | modify it under the terms of the GNU Lesser General Public |
| 5 | License as published by the Free Software Foundation; either |
| 6 | version 2.1 of the License, or (at your option) any later version. |
| 7 | |
| 8 | The GNU C Library is distributed in the hope that it will be useful, |
| 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 | Lesser General Public License for more details. |
| 12 | |
| 13 | You should have received a copy of the GNU Lesser General Public |
| 14 | License along with the GNU C Library. If not, see |
| 15 | <https://www.gnu.org/licenses/>. */ |
| 16 | |
| 17 | /* Don't rely on this, the interface is currently messed up and may need to |
| 18 | be broken to be fixed. */ |
| 19 | #ifndef _SYS_UCONTEXT_H |
| 20 | #define _SYS_UCONTEXT_H	1 |
| 21 | |
| 22 | #include <features.h> |
| 23 | |
| 24 | #include <bits/types/sigset_t.h> |
| 25 | #include <bits/types/stack_t.h> |
| 26 | |
| 27 | #include <sgidefs.h> |
| 28 | |
| 29 | |
| 30 | /* Type for general register. Even in o32 we assume 64-bit registers, |
| 31 | like the kernel. */ |
| 32 | __extension__ typedef unsigned long long int greg_t; |
| 33 | |
| 34 | /* Number of general registers. */ |
| 35 | #define __NGREG	32 |
| 36 | #define __NFPREG	32 |
| 37 | #ifdef __USE_MISC |
| 38 | # define NGREG	__NGREG |
| 39 | # define NFPREG	__NFPREG |
| 40 | #endif |
| 41 | |
| 42 | /* Container for all general registers. */ |
| 43 | typedef greg_t gregset_t[__NGREG]; |
| 44 | |
| 45 | #ifdef __USE_MISC |
| 46 | # define __ctx(fld) fld |
| 47 | #else |
| 48 | # define __ctx(fld) __ ## fld |
| 49 | #endif |
| 50 | |
| 51 | /* Container for all FPU registers. */ |
| 52 | typedef struct { |
| 53 | 	union { |
| 54 | 		double	__ctx(fp_dregs)[__NFPREG]; |
| 55 | 		struct { |
| 56 | 			float		_fp_fregs; |
| 57 | 			unsigned int	_fp_pad; |
| 58 | 		} __ctx(fp_fregs)[__NFPREG]; |
| 59 | 	} __ctx(fp_r); |
| 60 | } fpregset_t; |
| 61 | |
| 62 | |
| 63 | /* Context to describe whole processor state. */ |
| 64 | #if _MIPS_SIM == _ABIO32 |
| 65 | /* Earlier versions of glibc for mips had an entirely different |
| 66 | definition of mcontext_t, that didn't even resemble the |
| 67 | corresponding kernel data structure. Fortunately, makecontext, |
| 68 | [gs]etcontext et all were not implemented back then, so this can |
| 69 | still be rectified. */ |
| 70 | typedef struct |
| 71 | { |
| 72 | unsigned int __ctx(regmask); |
| 73 | unsigned int __ctx(status); |
| 74 | greg_t __ctx(pc); |
| 75 | gregset_t __ctx(gregs); |
| 76 | fpregset_t __ctx(fpregs); |
| 77 | unsigned int __ctx(fp_owned); |
| 78 | unsigned int __ctx(fpc_csr); |
| 79 | unsigned int __ctx(fpc_eir); |
| 80 | unsigned int __ctx(used_math); |
| 81 | unsigned int __ctx(dsp); |
| 82 | greg_t __ctx(mdhi); |
| 83 | greg_t __ctx(mdlo); |
| 84 | unsigned long __ctx(hi1); |
| 85 | unsigned long __ctx(lo1); |
| 86 | unsigned long __ctx(hi2); |
| 87 | unsigned long __ctx(lo2); |
| 88 | unsigned long __ctx(hi3); |
| 89 | unsigned long __ctx(lo3); |
| 90 | } mcontext_t; |
| 91 | #else |
| 92 | typedef struct |
| 93 | { |
| 94 | gregset_t __ctx(gregs); |
| 95 | fpregset_t __ctx(fpregs); |
| 96 | greg_t __ctx(mdhi); |
| 97 | greg_t __ctx(hi1); |
| 98 | greg_t __ctx(hi2); |
| 99 | greg_t __ctx(hi3); |
| 100 | greg_t __ctx(mdlo); |
| 101 | greg_t __ctx(lo1); |
| 102 | greg_t __ctx(lo2); |
| 103 | greg_t __ctx(lo3); |
| 104 | greg_t __ctx(pc); |
| 105 | unsigned int __ctx(fpc_csr); |
| 106 | unsigned int __ctx(used_math); |
| 107 | unsigned int __ctx(dsp); |
| 108 | unsigned int __glibc_reserved1; |
| 109 | } mcontext_t; |
| 110 | #endif |
| 111 | |
| 112 | /* Userlevel context. */ |
| 113 | typedef struct ucontext_t |
| 114 | { |
| 115 | unsigned long int __ctx(uc_flags); |
| 116 | struct ucontext_t *uc_link; |
| 117 | stack_t uc_stack; |
| 118 | mcontext_t uc_mcontext; |
| 119 | sigset_t uc_sigmask; |
| 120 | } ucontext_t; |
| 121 | |
| 122 | #undef __ctx |
| 123 | |
| 124 | #endif /* sys/ucontext.h */ |