-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path902-Ada-build-fix-for-GCC-8-building-GCC-7.patch
232 lines (217 loc) · 10.3 KB
/
902-Ada-build-fix-for-GCC-8-building-GCC-7.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
From 685f1f510d39a000fe35f8fc542995af40869a72 Mon Sep 17 00:00:00 2001
From: Tim Stahlhut <stahta01@gmail.com>
Date: Tue, 6 Sep 2022 19:48:28 -0400
Subject: Ada build fix for GCC 8 building GCC 7
This patch is to be used only to create an GCC Compiler with Ada;
then that compiler needs to be rebuilt without this patch.
---
gcc/ada/s-parame.ads | 2 +
gcc/ada/s-secsta.adb | 53 ------------------------
gcc/ada/s-secsta.ads | 99 +++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 100 insertions(+), 54 deletions(-)
diff --git a/gcc/ada/s-parame.ads b/gcc/ada/s-parame.ads
index 2c2a2fadac9..28308cc6953 100644
--- a/gcc/ada/s-parame.ads
+++ b/gcc/ada/s-parame.ads
@@ -103,6 +103,8 @@ package System.Parameters is
-- down (True) in memory as functions are called. It is used for
-- proper implementation of the stack overflow check.
+ Runtime_Default_Sec_Stack_Size : constant Size_Type := 10 * 1024;
+
----------------------------------------------
-- Characteristics of types in Interfaces.C --
----------------------------------------------
diff --git a/gcc/ada/s-secsta.adb b/gcc/ada/s-secsta.adb
index b55556f73ed..054012e71f0 100644
--- a/gcc/ada/s-secsta.adb
+++ b/gcc/ada/s-secsta.adb
@@ -32,7 +32,6 @@
pragma Compiler_Unit_Warning;
with System.Soft_Links;
-with System.Parameters;
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
@@ -55,58 +54,6 @@ package body System.Secondary_Stack is
-- then the secondary stack is allocated statically by grabbing a
-- section of the primary stack and using it for this purpose.
- type Memory is array (SS_Ptr range <>) of SSE.Storage_Element;
- for Memory'Alignment use Standard'Maximum_Alignment;
- -- This is the type used for actual allocation of secondary stack
- -- areas. We require maximum alignment for all such allocations.
-
- ---------------------------------------------------------------
- -- Data Structures for Dynamically Allocated Secondary Stack --
- ---------------------------------------------------------------
-
- -- The following is a diagram of the data structures used for the
- -- case of a dynamically allocated secondary stack, where the stack
- -- is allocated as a linked list of chunks allocated from the heap.
-
- -- +------------------+
- -- | Next |
- -- +------------------+
- -- | | Last (200)
- -- | |
- -- | |
- -- | |
- -- | |
- -- | |
- -- | | First (101)
- -- +------------------+
- -- +----------> | | |
- -- | +--------- | ------+
- -- | ^ |
- -- | | |
- -- | | V
- -- | +------ | ---------+
- -- | | | |
- -- | +------------------+
- -- | | | Last (100)
- -- | | C |
- -- | | H |
- -- +-----------------+ | +------->| U |
- -- | Current_Chunk ----+ | | N |
- -- +-----------------+ | | K |
- -- | Top --------+ | | First (1)
- -- +-----------------+ +------------------+
- -- | Default_Size | | Prev |
- -- +-----------------+ +------------------+
- --
-
- type Chunk_Id (First, Last : SS_Ptr);
- type Chunk_Ptr is access all Chunk_Id;
-
- type Chunk_Id (First, Last : SS_Ptr) is record
- Prev, Next : Chunk_Ptr;
- Mem : Memory (First .. Last);
- end record;
-
type Stack_Id is record
Top : SS_Ptr;
Default_Size : SSE.Storage_Count;
diff --git a/gcc/ada/s-secsta.ads b/gcc/ada/s-secsta.ads
index c5a0eadf29f..33082d067cb 100644
--- a/gcc/ada/s-secsta.ads
+++ b/gcc/ada/s-secsta.ads
@@ -31,16 +31,23 @@
pragma Compiler_Unit_Warning;
+with System.Parameters;
with System.Storage_Elements;
package System.Secondary_Stack is
+ package SP renames System.Parameters;
package SSE renames System.Storage_Elements;
Default_Secondary_Stack_Size : Natural := 10 * 1024;
-- Default size of a secondary stack. May be modified by binder -D switch
-- which causes the binder to generate an appropriate assignment in the
-- binder generated file.
+ type SS_Stack (Size : SP.Size_Type) is private;
+ -- Data structure for secondary stacks
+
+ type SS_Stack_Ptr is access all SS_Stack;
+ -- Pointer to secondary stack objects
function Minimum_Secondary_Stack_Size return Natural;
-- The minimum size of the secondary stack so that the internal
@@ -109,9 +116,84 @@ private
-- Unused entity that is just present to ease the sharing of the pool
-- mechanism for specific allocation/deallocation in the compiler
- type SS_Ptr is new SSE.Integer_Address;
+ subtype SS_Ptr is SP.Size_Type;
-- Stack pointer value for secondary stack
+ type Memory is array (SS_Ptr range <>) of SSE.Storage_Element;
+ for Memory'Alignment use Standard'Maximum_Alignment;
+ -- This is the type used for actual allocation of secondary stack
+ -- areas. We require maximum alignment for all such allocations.
+
+ ---------------------------------------------------------------
+ -- Data Structures for Dynamically Allocated Secondary Stack --
+ ---------------------------------------------------------------
+
+ -- The following is a diagram of the data structures used for the
+ -- case of a dynamically allocated secondary stack, where the stack
+ -- is allocated as a linked list of chunks allocated from the heap.
+
+ -- +------------------+
+ -- | Next |
+ -- +------------------+
+ -- | | Last (200)
+ -- | |
+ -- | |
+ -- | |
+ -- | |
+ -- | |
+ -- | | First (101)
+ -- +------------------+
+ -- +----------> | | |
+ -- | +--------- | ------+
+ -- | ^ |
+ -- | | |
+ -- | | V
+ -- | +------ | ---------+
+ -- | | | |
+ -- | +------------------+
+ -- | | | Last (100)
+ -- | | C |
+ -- | | H |
+ -- +-----------------+ | +------->| U |
+ -- | Current_Chunk ----+ | | N |
+ -- +-----------------+ | | K |
+ -- | Top --------+ | | First (1)
+ -- +-----------------+ +------------------+
+ -- | Default_Size | | Prev |
+ -- +-----------------+ +------------------+
+ --
+
+ type Chunk_Id (First, Last : SS_Ptr);
+ type Chunk_Ptr is access all Chunk_Id;
+
+ type Chunk_Id (First, Last : SS_Ptr) is record
+ Prev, Next : Chunk_Ptr;
+ Mem : Memory (First .. Last);
+ end record;
+
+ -- Secondary stack data structure
+
+ type SS_Stack (Size : SP.Size_Type) is record
+ Top : SS_Ptr;
+ -- Index of next available location in the stack. Initialized to 1 and
+ -- then incremented on Allocate and decremented on Release.
+
+ Max : SS_Ptr;
+ -- Contains the high-water mark of Top. Initialized to 1 and then
+ -- may be incremented on Allocate but never decremented. Since
+ -- Top = Size + 1 represents a fully used stack, Max - 1 indicates
+ -- the size of the stack used in bytes.
+
+ Current_Chunk : Chunk_Ptr;
+ -- A link to the chunk containing the highest range of the stack
+
+ Freeable : Boolean;
+ -- Indicates if an object of this type can be freed
+
+ Internal_Chunk : aliased Chunk_Id (1, Size);
+ -- Initial memory allocation of the secondary stack
+ end record;
+
type Mark_Id is record
Sstk : System.Address;
Sptr : SS_Ptr;
@@ -120,4 +202,19 @@ private
-- as returned by System.Soft_Links.Get_Sec_Stack_Addr, and a stack
-- pointer value corresponding to the point of the mark call.
+ Binder_SS_Count : Natural;
+ pragma Export (Ada, Binder_SS_Count, "__gnat_binder_ss_count");
+ -- The number of default sized secondary stacks allocated by the binder
+
+ Default_SS_Size : SP.Size_Type;
+ pragma Export (Ada, Default_SS_Size, "__gnat_default_ss_size");
+ -- The default size for secondary stacks. Defined here and not in init.c/
+ -- System.Init because these locations are not present on ZFP or
+ -- Ravenscar-SFP run-times.
+
+ Default_Sized_SS_Pool : System.Address;
+ pragma Export (Ada, Default_Sized_SS_Pool, "__gnat_default_ss_pool");
+ -- Address to the secondary stack pool generated by the binder that
+ -- contains default sized stacks.
+
end System.Secondary_Stack;
--