1 /* Copyright (C) 1997-2022 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3 
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.
8 
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.
13 
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/>.  */
17 
18 /* System V/m68k ABI compliant context switching support.  */
19 
20 #ifndef _SYS_UCONTEXT_H
21 #define _SYS_UCONTEXT_H	1
22 
23 #include <features.h>
24 
25 #include <bits/types/sigset_t.h>
26 #include <bits/types/stack_t.h>
27 
28 
29 /* Type for general register.  */
30 typedef int greg_t;
31 
32 /* Number of general registers.  */
33 #define __NGREG	18
34 #ifdef __USE_MISC
35 # define NGREG	__NGREG
36 #endif
37 
38 /* Container for all general registers.  */
39 typedef greg_t gregset_t[__NGREG];
40 
41 #ifdef __USE_MISC
42 /* Number of each register is the `gregset_t' array.  */
43 enum
44 {
45   R_D0 = 0,
46 # define R_D0	R_D0
47   R_D1 = 1,
48 # define R_D1	R_D1
49   R_D2 = 2,
50 # define R_D2	R_D2
51   R_D3 = 3,
52 # define R_D3	R_D3
53   R_D4 = 4,
54 # define R_D4	R_D4
55   R_D5 = 5,
56 # define R_D5	R_D5
57   R_D6 = 6,
58 # define R_D6	R_D6
59   R_D7 = 7,
60 # define R_D7	R_D7
61   R_A0 = 8,
62 # define R_A0	R_A0
63   R_A1 = 9,
64 # define R_A1	R_A1
65   R_A2 = 10,
66 # define R_A2	R_A2
67   R_A3 = 11,
68 # define R_A3	R_A3
69   R_A4 = 12,
70 # define R_A4	R_A4
71   R_A5 = 13,
72 # define R_A5	R_A5
73   R_A6 = 14,
74 # define R_A6	R_A6
75   R_A7 = 15,
76 # define R_A7	R_A7
77   R_SP = 15,
78 # define R_SP	R_SP
79   R_PC = 16,
80 # define R_PC	R_PC
81   R_PS = 17
82 # define R_PS	R_PS
83 };
84 #endif
85 
86 #ifdef __USE_MISC
87 # define __ctx(fld) fld
88 #else
89 # define __ctx(fld) __ ## fld
90 #endif
91 
92 /* Structure to describe FPU registers.  */
93 typedef struct
94 {
95   int __ctx(f_pcr);
96   int __ctx(f_psr);
97   int __ctx(f_fpiaddr);
98 #ifdef __mcoldfire__
99   int __ctx(f_fpregs)[8][2];
100 #else
101   int __ctx(f_fpregs)[8][3];
102 #endif
103 } fpregset_t;
104 
105 /* Context to describe whole processor state.  */
106 typedef struct
107 {
108   int __ctx(version);
109   gregset_t __ctx(gregs);
110   fpregset_t __ctx(fpregs);
111 } mcontext_t;
112 
113 #ifdef __USE_MISC
114 # define MCONTEXT_VERSION 2
115 #endif
116 
117 /* Userlevel context.  */
118 typedef struct ucontext_t
119 {
120   unsigned long __ctx(uc_flags);
121   struct ucontext_t *uc_link;
122   stack_t uc_stack;
123   mcontext_t uc_mcontext;
124   unsigned long __glibc_reserved1[80];
125   sigset_t uc_sigmask;
126 } ucontext_t;
127 
128 #undef __ctx
129 
130 #endif /* sys/ucontext.h */
131