Patchwork [Ada] Improve finalization of global controlled objects (2)

login
register
mail settings
Submitter Arnaud Charlet
Date Aug. 4, 2011, 7:55 a.m.
Message ID <20110804075507.GA2431@adacore.com>
Download mbox | patch
Permalink /patch/108364/
State New
Headers show

Comments

Arnaud Charlet - Aug. 4, 2011, 7:55 a.m.
This changes the type of the elaboration counter from Integer to Short_Integer
to avoid wasting space in the data segment.  No functional changes.

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

2011-08-04  Eric Botcazou  <ebotcazou@adacore.com>

	* sem_elab.adb (Check_Internal_Call_Continue): Change the type of the
	elaboration counter to Standard_Short_Integer.
	* sem_util.adb (Build_Elaboration_Entity): Likewise.
	* bindgen.adb (Gen_Elab_Externals_Ada): Adjust to above change.
	(Gen_Elab_Externals_C): Likewise.

Patch

Index: bindgen.adb
===================================================================
--- bindgen.adb	(revision 177320)
+++ bindgen.adb	(working copy)
@@ -1241,9 +1241,9 @@ 
 
                case VM_Target is
                   when No_VM | JVM_Target =>
-                     Set_String (" : Integer; pragma Import (Ada, ");
+                     Set_String (" : Short_Integer; pragma Import (Ada, ");
                   when CLI_Target =>
-                     Set_String (" : Integer; pragma Import (CIL, ");
+                     Set_String (" : Short_Integer; pragma Import (CIL, ");
                end case;
 
                Set_String ("E");
@@ -1320,7 +1320,7 @@ 
                 (No_Run_Time_Mode
                   and then Is_Predefined_File_Name (U.Sfile))
             then
-               Set_String ("extern int ");
+               Set_String ("extern short int ");
                Get_Name_String (U.Uname);
                Set_Unit_Name;
                Set_String ("_E;");
Index: sem_util.adb
===================================================================
--- sem_util.adb	(revision 177320)
+++ sem_util.adb	(working copy)
@@ -954,7 +954,7 @@ 
       Name_Buffer (Name_Len + 2) := 'E';
       Name_Len := Name_Len + 2;
 
-      --  Create elaboration flag
+      --  Create elaboration counter
 
       Elab_Ent := Make_Defining_Identifier (Loc, Chars => Name_Find);
       Set_Elaboration_Entity (Spec_Id, Elab_Ent);
@@ -962,8 +962,10 @@ 
       Decl :=
         Make_Object_Declaration (Loc,
           Defining_Identifier => Elab_Ent,
-          Object_Definition   => New_Occurrence_Of (Standard_Integer, Loc),
-          Expression          => Make_Integer_Literal (Loc, Uint_0));
+          Object_Definition   =>
+            New_Occurrence_Of (Standard_Short_Integer, Loc),
+          Expression          =>
+            Make_Integer_Literal (Loc, Uint_0));
 
       Push_Scope (Standard_Standard);
       Add_Global_Declaration (Decl);
Index: sem_elab.adb
===================================================================
--- sem_elab.adb	(revision 177320)
+++ sem_elab.adb	(working copy)
@@ -2158,7 +2158,7 @@ 
                     Make_Object_Declaration (Loce,
                       Defining_Identifier => Ent,
                       Object_Definition   =>
-                        New_Occurrence_Of (Standard_Integer, Loce),
+                        New_Occurrence_Of (Standard_Short_Integer, Loce),
                       Expression          =>
                         Make_Integer_Literal (Loc, Uint_0)));