annotate gcc/ada/libgnat/s-soflin.ads @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- S Y S T E M . S O F T _ L I N K S --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 1992-2018, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
kono
parents:
diff changeset
17 -- --
kono
parents:
diff changeset
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
19 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
20 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
21 -- --
kono
parents:
diff changeset
22 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
23 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
25 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
26 -- --
kono
parents:
diff changeset
27 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
29 -- --
kono
parents:
diff changeset
30 ------------------------------------------------------------------------------
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 -- This package contains a set of subprogram access variables that access
kono
parents:
diff changeset
33 -- some low-level primitives that are different depending whether tasking is
kono
parents:
diff changeset
34 -- involved or not (e.g. the Get/Set_Jmpbuf_Address that needs to provide a
kono
parents:
diff changeset
35 -- different value for each task). To avoid dragging in the tasking runtimes
kono
parents:
diff changeset
36 -- all the time, we use a system of soft links where the links are
kono
parents:
diff changeset
37 -- initialized to non-tasking versions, and then if the tasking support is
kono
parents:
diff changeset
38 -- initialized, they are set to the real tasking versions.
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 pragma Compiler_Unit_Warning;
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 with Ada.Exceptions;
kono
parents:
diff changeset
43 with System.Parameters;
kono
parents:
diff changeset
44 with System.Secondary_Stack;
kono
parents:
diff changeset
45 with System.Stack_Checking;
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 package System.Soft_Links is
kono
parents:
diff changeset
48 pragma Preelaborate;
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 package SST renames System.Secondary_Stack;
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 subtype EOA is Ada.Exceptions.Exception_Occurrence_Access;
kono
parents:
diff changeset
53 subtype EO is Ada.Exceptions.Exception_Occurrence;
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 function Current_Target_Exception return EO;
kono
parents:
diff changeset
56 pragma Import
kono
parents:
diff changeset
57 (Ada, Current_Target_Exception, "__gnat_current_target_exception");
kono
parents:
diff changeset
58 -- Import this subprogram from the private part of Ada.Exceptions
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 -- First we have the access subprogram types used to establish the links.
kono
parents:
diff changeset
61 -- The approach is to establish variables containing access subprogram
kono
parents:
diff changeset
62 -- values, which by default point to dummy no tasking versions of routines.
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 type No_Param_Proc is access procedure;
kono
parents:
diff changeset
65 pragma Favor_Top_Level (No_Param_Proc);
kono
parents:
diff changeset
66 pragma Suppress_Initialization (No_Param_Proc);
kono
parents:
diff changeset
67 -- Some uninitialized objects of that type are initialized by the Binder
kono
parents:
diff changeset
68 -- so it is important that such objects are not reset to null during
kono
parents:
diff changeset
69 -- elaboration.
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 type Addr_Param_Proc is access procedure (Addr : Address);
kono
parents:
diff changeset
72 pragma Favor_Top_Level (Addr_Param_Proc);
kono
parents:
diff changeset
73 type EO_Param_Proc is access procedure (Excep : EO);
kono
parents:
diff changeset
74 pragma Favor_Top_Level (EO_Param_Proc);
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 type Get_Address_Call is access function return Address;
kono
parents:
diff changeset
77 pragma Favor_Top_Level (Get_Address_Call);
kono
parents:
diff changeset
78 type Set_Address_Call is access procedure (Addr : Address);
kono
parents:
diff changeset
79 pragma Favor_Top_Level (Set_Address_Call);
kono
parents:
diff changeset
80 type Set_Address_Call2 is access procedure
kono
parents:
diff changeset
81 (Self_ID : Address; Addr : Address);
kono
parents:
diff changeset
82 pragma Favor_Top_Level (Set_Address_Call2);
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 type Get_Integer_Call is access function return Integer;
kono
parents:
diff changeset
85 pragma Favor_Top_Level (Get_Integer_Call);
kono
parents:
diff changeset
86 type Set_Integer_Call is access procedure (Len : Integer);
kono
parents:
diff changeset
87 pragma Favor_Top_Level (Set_Integer_Call);
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 type Get_EOA_Call is access function return EOA;
kono
parents:
diff changeset
90 pragma Favor_Top_Level (Get_EOA_Call);
kono
parents:
diff changeset
91 type Set_EOA_Call is access procedure (Excep : EOA);
kono
parents:
diff changeset
92 pragma Favor_Top_Level (Set_EOA_Call);
kono
parents:
diff changeset
93 type Set_EO_Call is access procedure (Excep : EO);
kono
parents:
diff changeset
94 pragma Favor_Top_Level (Set_EO_Call);
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 type Get_Stack_Call is access function return SST.SS_Stack_Ptr;
kono
parents:
diff changeset
97 pragma Favor_Top_Level (Get_Stack_Call);
kono
parents:
diff changeset
98 type Set_Stack_Call is access procedure (Stack : SST.SS_Stack_Ptr);
kono
parents:
diff changeset
99 pragma Favor_Top_Level (Set_Stack_Call);
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 type Special_EO_Call is access
kono
parents:
diff changeset
102 procedure (Excep : EO := Current_Target_Exception);
kono
parents:
diff changeset
103 pragma Favor_Top_Level (Special_EO_Call);
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105 type Timed_Delay_Call is access
kono
parents:
diff changeset
106 procedure (Time : Duration; Mode : Integer);
kono
parents:
diff changeset
107 pragma Favor_Top_Level (Timed_Delay_Call);
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 type Get_Stack_Access_Call is access
kono
parents:
diff changeset
110 function return Stack_Checking.Stack_Access;
kono
parents:
diff changeset
111 pragma Favor_Top_Level (Get_Stack_Access_Call);
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 type Task_Name_Call is access
kono
parents:
diff changeset
114 function return String;
kono
parents:
diff changeset
115 pragma Favor_Top_Level (Task_Name_Call);
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 -- Suppress checks on all these types, since we know the corresponding
kono
parents:
diff changeset
118 -- values can never be null (the soft links are always initialized).
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 pragma Suppress (Access_Check, No_Param_Proc);
kono
parents:
diff changeset
121 pragma Suppress (Access_Check, Addr_Param_Proc);
kono
parents:
diff changeset
122 pragma Suppress (Access_Check, EO_Param_Proc);
kono
parents:
diff changeset
123 pragma Suppress (Access_Check, Get_Address_Call);
kono
parents:
diff changeset
124 pragma Suppress (Access_Check, Set_Address_Call);
kono
parents:
diff changeset
125 pragma Suppress (Access_Check, Set_Address_Call2);
kono
parents:
diff changeset
126 pragma Suppress (Access_Check, Get_Integer_Call);
kono
parents:
diff changeset
127 pragma Suppress (Access_Check, Set_Integer_Call);
kono
parents:
diff changeset
128 pragma Suppress (Access_Check, Get_EOA_Call);
kono
parents:
diff changeset
129 pragma Suppress (Access_Check, Set_EOA_Call);
kono
parents:
diff changeset
130 pragma Suppress (Access_Check, Get_Stack_Call);
kono
parents:
diff changeset
131 pragma Suppress (Access_Check, Set_Stack_Call);
kono
parents:
diff changeset
132 pragma Suppress (Access_Check, Timed_Delay_Call);
kono
parents:
diff changeset
133 pragma Suppress (Access_Check, Get_Stack_Access_Call);
kono
parents:
diff changeset
134 pragma Suppress (Access_Check, Task_Name_Call);
kono
parents:
diff changeset
135
kono
parents:
diff changeset
136 -- The following one is not related to tasking/no-tasking but to the
kono
parents:
diff changeset
137 -- traceback decorators for exceptions.
kono
parents:
diff changeset
138
kono
parents:
diff changeset
139 type Traceback_Decorator_Wrapper_Call is access
kono
parents:
diff changeset
140 function (Traceback : System.Address;
kono
parents:
diff changeset
141 Len : Natural)
kono
parents:
diff changeset
142 return String;
kono
parents:
diff changeset
143 pragma Favor_Top_Level (Traceback_Decorator_Wrapper_Call);
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 -- Declarations for the no tasking versions of the required routines
kono
parents:
diff changeset
146
kono
parents:
diff changeset
147 procedure Abort_Defer_NT;
kono
parents:
diff changeset
148 -- Defer task abort (non-tasking case, does nothing)
kono
parents:
diff changeset
149
kono
parents:
diff changeset
150 procedure Abort_Undefer_NT;
kono
parents:
diff changeset
151 -- Undefer task abort (non-tasking case, does nothing)
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153 procedure Abort_Handler_NT;
kono
parents:
diff changeset
154 -- Handle task abort (non-tasking case, does nothing). Currently, no port
kono
parents:
diff changeset
155 -- makes use of this, but we retain the interface for possible future use.
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 function Check_Abort_Status_NT return Integer;
kono
parents:
diff changeset
158 -- Returns Boolean'Pos (True) iff abort signal should raise
kono
parents:
diff changeset
159 -- Standard'Abort_Signal.
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161 procedure Task_Lock_NT;
kono
parents:
diff changeset
162 -- Lock out other tasks (non-tasking case, does nothing)
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164 procedure Task_Unlock_NT;
kono
parents:
diff changeset
165 -- Release lock set by Task_Lock (non-tasking case, does nothing)
kono
parents:
diff changeset
166
kono
parents:
diff changeset
167 procedure Task_Termination_NT (Excep : EO);
kono
parents:
diff changeset
168 -- Handle task termination routines for the environment task (non-tasking
kono
parents:
diff changeset
169 -- case, does nothing).
kono
parents:
diff changeset
170
kono
parents:
diff changeset
171 procedure Adafinal_NT;
kono
parents:
diff changeset
172 -- Shuts down the runtime system (non-tasking case)
kono
parents:
diff changeset
173
kono
parents:
diff changeset
174 Abort_Defer : No_Param_Proc := Abort_Defer_NT'Access;
kono
parents:
diff changeset
175 pragma Suppress (Access_Check, Abort_Defer);
kono
parents:
diff changeset
176 -- Defer task abort (task/non-task case as appropriate)
kono
parents:
diff changeset
177
kono
parents:
diff changeset
178 Abort_Undefer : No_Param_Proc := Abort_Undefer_NT'Access;
kono
parents:
diff changeset
179 pragma Suppress (Access_Check, Abort_Undefer);
kono
parents:
diff changeset
180 -- Undefer task abort (task/non-task case as appropriate)
kono
parents:
diff changeset
181
kono
parents:
diff changeset
182 Abort_Handler : No_Param_Proc := Abort_Handler_NT'Access;
kono
parents:
diff changeset
183 -- Handle task abort (task/non-task case as appropriate)
kono
parents:
diff changeset
184
kono
parents:
diff changeset
185 Check_Abort_Status : Get_Integer_Call := Check_Abort_Status_NT'Access;
kono
parents:
diff changeset
186 -- Called when Abort_Signal is delivered to the process. Checks to
kono
parents:
diff changeset
187 -- see if signal should result in raising Standard'Abort_Signal.
kono
parents:
diff changeset
188
kono
parents:
diff changeset
189 Lock_Task : No_Param_Proc := Task_Lock_NT'Access;
kono
parents:
diff changeset
190 -- Locks out other tasks. Preceding a section of code by Task_Lock and
kono
parents:
diff changeset
191 -- following it by Task_Unlock creates a critical region. This is used
kono
parents:
diff changeset
192 -- for ensuring that a region of non-tasking code (such as code used to
kono
parents:
diff changeset
193 -- allocate memory) is tasking safe. Note that it is valid for calls to
kono
parents:
diff changeset
194 -- Task_Lock/Task_Unlock to be nested, and this must work properly, i.e.
kono
parents:
diff changeset
195 -- only the corresponding outer level Task_Unlock will actually unlock.
kono
parents:
diff changeset
196 -- This routine also prevents against asynchronous aborts (abort is
kono
parents:
diff changeset
197 -- deferred).
kono
parents:
diff changeset
198
kono
parents:
diff changeset
199 Unlock_Task : No_Param_Proc := Task_Unlock_NT'Access;
kono
parents:
diff changeset
200 -- Releases lock previously set by call to Lock_Task. In the nested case,
kono
parents:
diff changeset
201 -- all nested locks must be released before other tasks competing for the
kono
parents:
diff changeset
202 -- tasking lock are released.
kono
parents:
diff changeset
203 --
kono
parents:
diff changeset
204 -- In the non nested case, this routine terminates the protection against
kono
parents:
diff changeset
205 -- asynchronous aborts introduced by Lock_Task (unless abort was already
kono
parents:
diff changeset
206 -- deferred before the call to Lock_Task (e.g in a protected procedures).
kono
parents:
diff changeset
207 --
kono
parents:
diff changeset
208 -- Note: the recommended protocol for using Lock_Task and Unlock_Task
kono
parents:
diff changeset
209 -- is as follows:
kono
parents:
diff changeset
210 --
kono
parents:
diff changeset
211 -- Locked_Processing : begin
kono
parents:
diff changeset
212 -- System.Soft_Links.Lock_Task.all;
kono
parents:
diff changeset
213 -- ...
kono
parents:
diff changeset
214 -- System.Soft_Links.Unlock_Task.all;
kono
parents:
diff changeset
215 --
kono
parents:
diff changeset
216 -- exception
kono
parents:
diff changeset
217 -- when others =>
kono
parents:
diff changeset
218 -- System.Soft_Links.Unlock_Task.all;
kono
parents:
diff changeset
219 -- raise;
kono
parents:
diff changeset
220 -- end Locked_Processing;
kono
parents:
diff changeset
221 --
kono
parents:
diff changeset
222 -- This ensures that the lock is not left set if an exception is raised
kono
parents:
diff changeset
223 -- explicitly or implicitly during the critical locked region.
kono
parents:
diff changeset
224
kono
parents:
diff changeset
225 Task_Termination_Handler : EO_Param_Proc := Task_Termination_NT'Access;
kono
parents:
diff changeset
226 -- Handle task termination routines (task/non-task case as appropriate)
kono
parents:
diff changeset
227
kono
parents:
diff changeset
228 Finalize_Library_Objects : No_Param_Proc;
kono
parents:
diff changeset
229 pragma Export (C, Finalize_Library_Objects,
kono
parents:
diff changeset
230 "__gnat_finalize_library_objects");
kono
parents:
diff changeset
231 -- Will be initialized by the binder
kono
parents:
diff changeset
232
kono
parents:
diff changeset
233 Adafinal : No_Param_Proc := Adafinal_NT'Access;
kono
parents:
diff changeset
234 -- Performs the finalization of the Ada Runtime
kono
parents:
diff changeset
235
kono
parents:
diff changeset
236 function Get_Jmpbuf_Address_NT return Address;
kono
parents:
diff changeset
237 procedure Set_Jmpbuf_Address_NT (Addr : Address);
kono
parents:
diff changeset
238
kono
parents:
diff changeset
239 Get_Jmpbuf_Address : Get_Address_Call := Get_Jmpbuf_Address_NT'Access;
kono
parents:
diff changeset
240 Set_Jmpbuf_Address : Set_Address_Call := Set_Jmpbuf_Address_NT'Access;
kono
parents:
diff changeset
241
kono
parents:
diff changeset
242 function Get_Sec_Stack_NT return SST.SS_Stack_Ptr;
kono
parents:
diff changeset
243 procedure Set_Sec_Stack_NT (Stack : SST.SS_Stack_Ptr);
kono
parents:
diff changeset
244
kono
parents:
diff changeset
245 Get_Sec_Stack : Get_Stack_Call := Get_Sec_Stack_NT'Access;
kono
parents:
diff changeset
246 Set_Sec_Stack : Set_Stack_Call := Set_Sec_Stack_NT'Access;
kono
parents:
diff changeset
247
kono
parents:
diff changeset
248 function Get_Current_Excep_NT return EOA;
kono
parents:
diff changeset
249
kono
parents:
diff changeset
250 Get_Current_Excep : Get_EOA_Call := Get_Current_Excep_NT'Access;
kono
parents:
diff changeset
251
kono
parents:
diff changeset
252 function Get_Stack_Info_NT return Stack_Checking.Stack_Access;
kono
parents:
diff changeset
253
kono
parents:
diff changeset
254 Get_Stack_Info : Get_Stack_Access_Call := Get_Stack_Info_NT'Access;
kono
parents:
diff changeset
255
kono
parents:
diff changeset
256 --------------------------
kono
parents:
diff changeset
257 -- Master_Id Soft-Links --
kono
parents:
diff changeset
258 --------------------------
kono
parents:
diff changeset
259
kono
parents:
diff changeset
260 -- Soft-Links are used for procedures that manipulate Master_Ids because
kono
parents:
diff changeset
261 -- a Master_Id must be generated for access to limited class-wide types,
kono
parents:
diff changeset
262 -- whose root may be extended with task components.
kono
parents:
diff changeset
263
kono
parents:
diff changeset
264 function Current_Master_NT return Integer;
kono
parents:
diff changeset
265 procedure Enter_Master_NT;
kono
parents:
diff changeset
266 procedure Complete_Master_NT;
kono
parents:
diff changeset
267
kono
parents:
diff changeset
268 Current_Master : Get_Integer_Call := Current_Master_NT'Access;
kono
parents:
diff changeset
269 Enter_Master : No_Param_Proc := Enter_Master_NT'Access;
kono
parents:
diff changeset
270 Complete_Master : No_Param_Proc := Complete_Master_NT'Access;
kono
parents:
diff changeset
271
kono
parents:
diff changeset
272 ----------------------
kono
parents:
diff changeset
273 -- Delay Soft-Links --
kono
parents:
diff changeset
274 ----------------------
kono
parents:
diff changeset
275
kono
parents:
diff changeset
276 -- Soft-Links are used for procedures that manipulate time to avoid
kono
parents:
diff changeset
277 -- dragging the tasking run time when using delay statements.
kono
parents:
diff changeset
278
kono
parents:
diff changeset
279 Timed_Delay : Timed_Delay_Call;
kono
parents:
diff changeset
280
kono
parents:
diff changeset
281 --------------------------
kono
parents:
diff changeset
282 -- Task Name Soft-Links --
kono
parents:
diff changeset
283 --------------------------
kono
parents:
diff changeset
284
kono
parents:
diff changeset
285 function Task_Name_NT return String;
kono
parents:
diff changeset
286
kono
parents:
diff changeset
287 Task_Name : Task_Name_Call := Task_Name_NT'Access;
kono
parents:
diff changeset
288
kono
parents:
diff changeset
289 -------------------------------------
kono
parents:
diff changeset
290 -- Exception Tracebacks Soft-Links --
kono
parents:
diff changeset
291 -------------------------------------
kono
parents:
diff changeset
292
kono
parents:
diff changeset
293 Library_Exception : EO;
kono
parents:
diff changeset
294 -- Library-level finalization routines use this common reference to store
kono
parents:
diff changeset
295 -- the first library-level exception which occurs during finalization.
kono
parents:
diff changeset
296
kono
parents:
diff changeset
297 Library_Exception_Set : Boolean := False;
kono
parents:
diff changeset
298 -- Used in conjunction with Library_Exception, set when an exception has
kono
parents:
diff changeset
299 -- been stored.
kono
parents:
diff changeset
300
kono
parents:
diff changeset
301 Traceback_Decorator_Wrapper : Traceback_Decorator_Wrapper_Call;
kono
parents:
diff changeset
302 -- Wrapper to the possible user specified traceback decorator to be
kono
parents:
diff changeset
303 -- called during automatic output of exception data.
kono
parents:
diff changeset
304
kono
parents:
diff changeset
305 -- The null value of this wrapper correspond sto the null value of the
kono
parents:
diff changeset
306 -- current actual decorator. This is ensured first by the null initial
kono
parents:
diff changeset
307 -- value of the corresponding variables, and then by Set_Trace_Decorator
kono
parents:
diff changeset
308 -- in g-exctra.adb.
kono
parents:
diff changeset
309
kono
parents:
diff changeset
310 pragma Atomic (Traceback_Decorator_Wrapper);
kono
parents:
diff changeset
311 -- Since concurrent read/write operations may occur on this variable.
kono
parents:
diff changeset
312 -- See the body of Tailored_Exception_Traceback in Ada.Exceptions for
kono
parents:
diff changeset
313 -- a more detailed description of the potential problems.
kono
parents:
diff changeset
314
kono
parents:
diff changeset
315 procedure Save_Library_Occurrence (E : EOA);
kono
parents:
diff changeset
316 -- When invoked, this routine saves an exception occurrence into a hidden
kono
parents:
diff changeset
317 -- reference. Subsequent calls will have no effect.
kono
parents:
diff changeset
318
kono
parents:
diff changeset
319 ------------------------
kono
parents:
diff changeset
320 -- Task Specific Data --
kono
parents:
diff changeset
321 ------------------------
kono
parents:
diff changeset
322
kono
parents:
diff changeset
323 -- Here we define a single type that encapsulates the various task
kono
parents:
diff changeset
324 -- specific data. This type is used to store the necessary data into the
kono
parents:
diff changeset
325 -- Task_Control_Block or into a global variable in the non tasking case.
kono
parents:
diff changeset
326
kono
parents:
diff changeset
327 type TSD is record
kono
parents:
diff changeset
328 Pri_Stack_Info : aliased Stack_Checking.Stack_Info;
kono
parents:
diff changeset
329 -- Information on stack (Base/Limit/Size) used by System.Stack_Checking.
kono
parents:
diff changeset
330 -- If this TSD does not belong to the environment task, the Size field
kono
parents:
diff changeset
331 -- must be initialized to the tasks requested stack size before the task
kono
parents:
diff changeset
332 -- can do its first stack check.
kono
parents:
diff changeset
333
kono
parents:
diff changeset
334 Jmpbuf_Address : System.Address;
kono
parents:
diff changeset
335 -- Address of jump buffer used to store the address of the current
kono
parents:
diff changeset
336 -- longjmp/setjmp buffer for exception management. These buffers are
kono
parents:
diff changeset
337 -- threaded into a stack, and the address here is the top of the stack.
kono
parents:
diff changeset
338 -- A null address means that no exception handler is currently active.
kono
parents:
diff changeset
339
kono
parents:
diff changeset
340 Sec_Stack_Ptr : SST.SS_Stack_Ptr;
kono
parents:
diff changeset
341 -- Pointer of the allocated secondary stack
kono
parents:
diff changeset
342
kono
parents:
diff changeset
343 Current_Excep : aliased EO;
kono
parents:
diff changeset
344 -- Exception occurrence that contains the information for the current
kono
parents:
diff changeset
345 -- exception. Note that any exception in the same task destroys this
kono
parents:
diff changeset
346 -- information, so the data in this variable must be copied out before
kono
parents:
diff changeset
347 -- another exception can occur.
kono
parents:
diff changeset
348 --
kono
parents:
diff changeset
349 -- Also act as a list of the active exceptions in the case of the GCC
kono
parents:
diff changeset
350 -- exception mechanism, organized as a stack with the most recent first.
kono
parents:
diff changeset
351 end record;
kono
parents:
diff changeset
352
kono
parents:
diff changeset
353 procedure Create_TSD
kono
parents:
diff changeset
354 (New_TSD : in out TSD;
kono
parents:
diff changeset
355 Sec_Stack : SST.SS_Stack_Ptr;
kono
parents:
diff changeset
356 Sec_Stack_Size : System.Parameters.Size_Type);
kono
parents:
diff changeset
357 pragma Inline (Create_TSD);
kono
parents:
diff changeset
358 -- Called from s-tassta when a new thread is created to perform
kono
parents:
diff changeset
359 -- any required initialization of the TSD.
kono
parents:
diff changeset
360
kono
parents:
diff changeset
361 procedure Destroy_TSD (Old_TSD : in out TSD);
kono
parents:
diff changeset
362 pragma Inline (Destroy_TSD);
kono
parents:
diff changeset
363 -- Called from s-tassta just before a thread is destroyed to perform
kono
parents:
diff changeset
364 -- any required finalization.
kono
parents:
diff changeset
365
kono
parents:
diff changeset
366 function Get_GNAT_Exception return Ada.Exceptions.Exception_Id;
kono
parents:
diff changeset
367 pragma Inline (Get_GNAT_Exception);
kono
parents:
diff changeset
368 -- This function obtains the Exception_Id from the Exception_Occurrence
kono
parents:
diff changeset
369 -- referenced by the Current_Excep field of the task specific data, i.e.
kono
parents:
diff changeset
370 -- the call is equivalent to
kono
parents:
diff changeset
371 -- Exception_Identity (Get_Current_Exception.all)
kono
parents:
diff changeset
372
kono
parents:
diff changeset
373 -- Export the Get/Set routines for the various Task Specific Data (TSD)
kono
parents:
diff changeset
374 -- elements as callable subprograms instead of objects of access to
kono
parents:
diff changeset
375 -- subprogram types.
kono
parents:
diff changeset
376
kono
parents:
diff changeset
377 function Get_Jmpbuf_Address_Soft return Address;
kono
parents:
diff changeset
378 procedure Set_Jmpbuf_Address_Soft (Addr : Address);
kono
parents:
diff changeset
379 pragma Inline (Get_Jmpbuf_Address_Soft);
kono
parents:
diff changeset
380 pragma Inline (Set_Jmpbuf_Address_Soft);
kono
parents:
diff changeset
381
kono
parents:
diff changeset
382 function Get_Sec_Stack_Soft return SST.SS_Stack_Ptr;
kono
parents:
diff changeset
383 procedure Set_Sec_Stack_Soft (Stack : SST.SS_Stack_Ptr);
kono
parents:
diff changeset
384 pragma Inline (Get_Sec_Stack_Soft);
kono
parents:
diff changeset
385 pragma Inline (Set_Sec_Stack_Soft);
kono
parents:
diff changeset
386
kono
parents:
diff changeset
387 -- The following is a dummy record designed to mimic Communication_Block as
kono
parents:
diff changeset
388 -- defined in s-tpobop.ads:
kono
parents:
diff changeset
389
kono
parents:
diff changeset
390 -- type Communication_Block is record
kono
parents:
diff changeset
391 -- Self : Task_Id; -- An access type
kono
parents:
diff changeset
392 -- Enqueued : Boolean := True;
kono
parents:
diff changeset
393 -- Cancelled : Boolean := False;
kono
parents:
diff changeset
394 -- end record;
kono
parents:
diff changeset
395
kono
parents:
diff changeset
396 -- The record is used in the construction of the predefined dispatching
kono
parents:
diff changeset
397 -- primitive _disp_asynchronous_select in order to avoid the import of
kono
parents:
diff changeset
398 -- System.Tasking.Protected_Objects.Operations. Note that this package
kono
parents:
diff changeset
399 -- is always imported in the presence of interfaces since the dispatch
kono
parents:
diff changeset
400 -- table uses entities from here.
kono
parents:
diff changeset
401
kono
parents:
diff changeset
402 type Dummy_Communication_Block is record
kono
parents:
diff changeset
403 Comp_1 : Address; -- Address and access have the same size
kono
parents:
diff changeset
404 Comp_2 : Boolean;
kono
parents:
diff changeset
405 Comp_3 : Boolean;
kono
parents:
diff changeset
406 end record;
kono
parents:
diff changeset
407
kono
parents:
diff changeset
408 private
kono
parents:
diff changeset
409 NT_TSD : TSD;
kono
parents:
diff changeset
410 -- The task specific data for the main task when the Ada tasking run-time
kono
parents:
diff changeset
411 -- is not used. It relies on the default initialization of NT_TSD. It is
kono
parents:
diff changeset
412 -- placed here and not the body to ensure the default initialization does
kono
parents:
diff changeset
413 -- not clobber the secondary stack initialization that occurs as part of
kono
parents:
diff changeset
414 -- System.Soft_Links.Initialization.
kono
parents:
diff changeset
415 end System.Soft_Links;