Skip to content

Commit 4184f75

Browse files
committed
Updated the FSF GCC 6/GNAT GPL 2016 patches.
* s-tarest.ads-gcc6: copied the sequential elaboration changes. * s-tarest.adb-gcc6: likewise.
1 parent 607fd75 commit 4184f75

File tree

2 files changed

+127
-26
lines changed

2 files changed

+127
-26
lines changed

common/s-tarest.adb-gcc6

Lines changed: 67 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
-- -*- ada -*-
2-
31
------------------------------------------------------------------------------
42
-- --
53
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
@@ -47,6 +45,8 @@ with System.Memory;
4745

4846
package body System.Tasking.Restricted.Stages is
4947

48+
Sequential_Elaboration_Started : Boolean := False;
49+
5050
procedure Wrapper (Arg1 : System.Address) with Convention => C;
5151
-- This is the procedure passed to
5252
-- FreeRTOS.Tasks.Create_Task. Arg1 is the address of its
@@ -93,17 +93,17 @@ package body System.Tasking.Restricted.Stages is
9393
-- Null_Task_Name : constant String := (1 => ASCII.NUL);
9494

9595
procedure Create_Restricted_Task
96-
(Priority : Integer;
97-
Stack_Address : System.Address;
98-
Size : System.Parameters.Size_Type;
99-
Task_Info : System.Task_Info.Task_Info_Type;
100-
CPU : Integer;
101-
State : Task_Procedure_Access;
102-
Discriminants : System.Address;
103-
Elaborated : Access_Boolean;
104-
Chain : in out Activation_Chain;
105-
Task_Image : String;
106-
Created_Task : Task_Id) is
96+
(Priority : Integer;
97+
Stack_Address : System.Address;
98+
Size : System.Parameters.Size_Type;
99+
Task_Info : System.Task_Info.Task_Info_Type;
100+
CPU : Integer;
101+
State : Task_Procedure_Access;
102+
Discriminants : System.Address;
103+
Elaborated : Access_Boolean;
104+
Chain : in out Activation_Chain;
105+
Task_Image : String;
106+
Created_Task : Task_Id) is
107107

108108
pragma Unreferenced (Stack_Address);
109109
pragma Unreferenced (Task_Info);
@@ -146,13 +146,67 @@ package body System.Tasking.Restricted.Stages is
146146
Elaborated.all := Created_Task.Common.Thread /= null;
147147
end Create_Restricted_Task;
148148

149+
procedure Create_Restricted_Task_Sequential
150+
(Priority : Integer;
151+
Stack_Address : System.Address;
152+
Size : System.Parameters.Size_Type;
153+
Task_Info : System.Task_Info.Task_Info_Type;
154+
CPU : Integer;
155+
State : Task_Procedure_Access;
156+
Discriminants : System.Address;
157+
Elaborated : Access_Boolean;
158+
Task_Image : String;
159+
Created_Task : Task_Id)
160+
is
161+
-- Create_Restricted_Task requires a Chain parameter; however,
162+
-- in this RTS it's ignored, because all tasks are activated as
163+
-- they are elaborated (i.e., concurrently).
164+
Dummy_Activation_Chain : Activation_Chain;
165+
begin
166+
167+
-- If we're called at all, it's because sequential activation
168+
-- has been requested. If this is the first call, suspend
169+
-- tasking (awaiting a call to Activate_All_Tasks_Sequential).
170+
pragma Assert (Partition_Elaboration_Policy = 'S',
171+
"Partition_Elaboration_Policy not sequential");
172+
if not Sequential_Elaboration_Started then
173+
Sequential_Elaboration_Started := True;
174+
FreeRTOS.Tasks.Suspend_All_Tasks;
175+
end if;
176+
177+
Create_Restricted_Task
178+
(Priority => Priority,
179+
Stack_Address => Stack_Address,
180+
Size => Size,
181+
Task_Info => Task_Info,
182+
CPU => CPU,
183+
State => State,
184+
Discriminants => Discriminants,
185+
Elaborated => Elaborated,
186+
Chain => Dummy_Activation_Chain, -- <<<
187+
Task_Image => Task_Image,
188+
Created_Task => Created_Task);
189+
end Create_Restricted_Task_Sequential;
190+
149191
procedure Activate_Restricted_Tasks
150192
(Chain_Access : Activation_Chain_Access) is
151193
pragma Unreferenced (Chain_Access);
152194
begin
195+
-- This can get called even with sequential elaboration,
196+
-- because if the RTS was compiled with concurrent activation
197+
-- (almost certainly the case) any tasks in the RTS (e.g. for
198+
-- Timing_Events) will call here at the end of package
199+
-- elaboration.
153200
null;
154201
end Activate_Restricted_Tasks;
155202

203+
procedure Activate_All_Tasks_Sequential is
204+
begin
205+
pragma Assert (Partition_Elaboration_Policy = 'S',
206+
"Partition_Elaboration_Policy not sequential");
207+
FreeRTOS.Tasks.Resume_All_Tasks;
208+
end Activate_All_Tasks_Sequential;
209+
156210
procedure Complete_Restricted_Activation is
157211
begin
158212
null;

common/s-tarest.ads-gcc6

Lines changed: 60 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
-- -*- ada -*-
2-
31
------------------------------------------------------------------------------
42
-- --
53
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
@@ -47,6 +45,17 @@
4745

4846
-- Modified for the Cortex GNAT RTS, by leaving out parts that aren't
4947
-- called.
48+
--
49+
-- If the user compiles with Partition_Elaboration_Policy set to
50+
-- Sequential, the compiled code calls
51+
-- Create_Restricted_Task_Sequential instead of
52+
-- Create_Restricted_Task, and at the end calls
53+
-- Activate_All_Tasks_Sequential. This RTS only actually supports
54+
-- Concurrent activation (that is, each task is activated as soon as
55+
-- it's created), and so Create_Restricted_Task_Sequential just calls
56+
-- Create_Restricted_Task (with a dummy Chain, which
57+
-- Create_Restricted_Task ignores anyway, since FreeRTOS doesn't
58+
-- provide a way to create a task without activating it).
5059

5160
pragma Restrictions (No_Elaboration_Code);
5261

@@ -56,18 +65,30 @@ with System.Task_Info;
5665
package System.Tasking.Restricted.Stages is
5766
pragma Preelaborate;
5867

68+
Partition_Elaboration_Policy : Character := 'C';
69+
pragma Export (C, Partition_Elaboration_Policy,
70+
"__gnat_partition_elaboration_policy");
71+
-- Partition elaboration policy. Value can be either 'C' for
72+
-- concurrent, which is the default or 'S' for sequential. This
73+
-- value can be modified by the binder generated code in
74+
-- adainit(), before calling elaboration code, if task activation
75+
-- is supposed to be Sequential. Unfortunately, that's too late
76+
-- for this RTS. The variable is provided because the
77+
-- binder-generated code expects it if the user has specified
78+
-- sequential elaboration.
79+
5980
procedure Create_Restricted_Task
60-
(Priority : Integer;
61-
Stack_Address : System.Address;
62-
Size : System.Parameters.Size_Type;
63-
Task_Info : System.Task_Info.Task_Info_Type;
64-
CPU : Integer;
65-
State : Task_Procedure_Access;
66-
Discriminants : System.Address;
67-
Elaborated : Access_Boolean;
68-
Chain : in out Activation_Chain;
69-
Task_Image : String;
70-
Created_Task : Task_Id);
81+
(Priority : Integer;
82+
Stack_Address : System.Address;
83+
Size : System.Parameters.Size_Type;
84+
Task_Info : System.Task_Info.Task_Info_Type;
85+
CPU : Integer;
86+
State : Task_Procedure_Access;
87+
Discriminants : System.Address;
88+
Elaborated : Access_Boolean;
89+
Chain : in out Activation_Chain;
90+
Task_Image : String;
91+
Created_Task : Task_Id);
7192
-- Compiler interface only. Do not call from within the RTS. This
7293
-- must be called to create a new task, when the partition
7394
-- elaboration policy is not specified (or is concurrent).
@@ -114,6 +135,25 @@ package System.Tasking.Restricted.Stages is
114135
-- This procedure can raise Storage_Error if the task creation
115136
-- fails
116137

138+
procedure Create_Restricted_Task_Sequential
139+
(Priority : Integer;
140+
Stack_Address : System.Address;
141+
Size : System.Parameters.Size_Type;
142+
Task_Info : System.Task_Info.Task_Info_Type;
143+
CPU : Integer;
144+
State : Task_Procedure_Access;
145+
Discriminants : System.Address;
146+
Elaborated : Access_Boolean;
147+
Task_Image : String;
148+
Created_Task : Task_Id);
149+
-- Compiler interface only. Do not call from within the RTS.
150+
-- This must be called to create a new task, when the sequential partition
151+
-- elaboration policy is used.
152+
--
153+
-- The parameters are the same as Create_Restricted_Task except there is
154+
-- no Chain parameter (for the activation chain), as there is only one
155+
-- global activation chain, which is declared in the body of this package.
156+
117157
procedure Activate_Restricted_Tasks
118158
(Chain_Access : Activation_Chain_Access);
119159
-- Compiler interface only. Do not call from within the RTS. This
@@ -135,6 +175,13 @@ package System.Tasking.Restricted.Stages is
135175
-- procedure does nothing, tasks will be activated at end of
136176
-- elaboration.
137177

178+
procedure Activate_All_Tasks_Sequential;
179+
pragma Export (C, Activate_All_Tasks_Sequential,
180+
"__gnat_activate_all_tasks");
181+
-- Binder interface only. Do not call from within the RTS. This must be
182+
-- called an the end of the elaboration to activate all tasks, in order
183+
-- to implement the sequential elaboration policy.
184+
138185
procedure Complete_Restricted_Activation;
139186
-- Compiler interface only. Do not call from within the RTS. This
140187
-- should be called from the task body at the end of the

0 commit comments

Comments
 (0)