Patchwork [Ada] Remove hardcoded magic constants in tasking-related expansion

login
register
mail settings
Submitter Arnaud Charlet
Date Sept. 10, 2010, 10:13 a.m.
Message ID <20100910101325.GA360@adacore.com>
Download mbox | patch
Permalink /patch/64367/
State New
Headers show

Comments

Arnaud Charlet - Sept. 10, 2010, 10:13 a.m.
This change removes hard-coded constants and replaces them with references
to proper named numbers from the runtime.

Minor code reorganization, no behaviour change, no test.

Tested on x86_64-pc-linux-gnu, committed on trunk

2010-09-10  Thomas Quinot  <quinot@adacore.com>

	* exp_ch9.adb, rtsfind.ads, exp_ch4.adb, exp_ch3.adb: Do not hardcode
	magic constants for task master levels (instead, reference
	named numbers from System.Tasking).

Patch

Index: exp_ch9.adb
===================================================================
--- exp_ch9.adb	(revision 164149)
+++ exp_ch9.adb	(working copy)
@@ -12133,13 +12133,14 @@  package body Exp_Ch9 is
 
          --  Master parameter. This is a reference to the _Master parameter of
          --  the initialization procedure, except in the case of the pragma
-         --  Restrictions (No_Task_Hierarchy) where the value is fixed to 3
-         --  (3 is System.Tasking.Library_Task_Level).
+         --  Restrictions (No_Task_Hierarchy) where the value is fixed to
+         --  System.Tasking.Library_Task_Level.
 
          if Restriction_Active (No_Task_Hierarchy) = False then
             Append_To (Args, Make_Identifier (Loc, Name_uMaster));
          else
-            Append_To (Args, Make_Integer_Literal (Loc, 3));
+            Append_To (Args,
+              New_Occurrence_Of (RTE (RE_Library_Task_Level), Loc));
          end if;
       end if;
 
Index: rtsfind.ads
===================================================================
--- rtsfind.ads	(revision 164149)
+++ rtsfind.ads	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2010, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -1396,6 +1396,11 @@  package Rtsfind is
      RE_Conditional_Call,                -- System.Tasking
      RE_Asynchronous_Call,               -- System.Tasking
 
+     RE_Foreign_Task_Level,              -- System.Tasking
+     RE_Environment_Task_Level,          -- System.Tasking
+     RE_Independent_Task_Level,          -- System.Tasking
+     RE_Library_Task_Level,              -- System.Tasking
+
      RE_Ada_Task_Control_Block,          -- System.Tasking
 
      RE_Task_List,                       -- System.Tasking
@@ -2561,6 +2566,11 @@  package Rtsfind is
      RE_Conditional_Call                 => System_Tasking,
      RE_Asynchronous_Call                => System_Tasking,
 
+     RE_Foreign_Task_Level               => System_Tasking,
+     RE_Environment_Task_Level           => System_Tasking,
+     RE_Independent_Task_Level           => System_Tasking,
+     RE_Library_Task_Level               => System_Tasking,
+
      RE_Ada_Task_Control_Block           => System_Tasking,
 
      RE_Task_List                        => System_Tasking,
Index: exp_ch4.adb
===================================================================
--- exp_ch4.adb	(revision 164149)
+++ exp_ch4.adb	(working copy)
@@ -3724,8 +3724,8 @@  package body Exp_Ch4 is
                   end if;
 
                   if Restriction_Active (No_Task_Hierarchy) then
-                     --  3 is System.Tasking.Library_Task_Level
-                     Append_To (Args, Make_Integer_Literal (Loc, 3));
+                     Append_To (Args,
+                       New_Occurrence_Of (RTE (RE_Library_Task_Level), Loc));
                   else
                      Append_To (Args,
                        New_Reference_To
Index: exp_ch3.adb
===================================================================
--- exp_ch3.adb	(revision 164149)
+++ exp_ch3.adb	(working copy)
@@ -1481,12 +1481,8 @@  package body Exp_Ch3 is
 
       if Has_Task (Full_Type) then
          if Restriction_Active (No_Task_Hierarchy) then
-
-            --  3 is System.Tasking.Library_Task_Level
-            --  (should be rtsfindable constant ???)
-
-            Append_To (Args, Make_Integer_Literal (Loc, 3));
-
+            Append_To (Args,
+              New_Occurrence_Of (RTE (RE_Library_Task_Level), Loc));
          else
             Append_To (Args, Make_Identifier (Loc, Name_uMaster));
          end if;
@@ -2042,10 +2038,8 @@  package body Exp_Ch3 is
 
          if Has_Task (Rec_Type) then
             if Restriction_Active (No_Task_Hierarchy) then
-
-               --  3 is System.Tasking.Library_Task_Level
-
-               Append_To (Args, Make_Integer_Literal (Loc, 3));
+               Append_To (Args,
+                 New_Occurrence_Of (RTE (RE_Library_Task_Level), Loc));
             else
                Append_To (Args, Make_Identifier (Loc, Name_uMaster));
             end if;