OSDN Git Service

2006-10-31 Ed Schonberg <schonberg@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-finimp.ads
index d83670a..8366e95 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2003 Free Software Foundation, Inc.          --
+--          Copyright (C) 1992-2006 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- --
@@ -16,8 +16,8 @@
 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
 -- for  more details.  You should have  received  a copy of the GNU General --
 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
--- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
--- MA 02111-1307, USA.                                                      --
+-- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
+-- Boston, MA 02110-1301, USA.                                              --
 --                                                                          --
 -- As a special exception,  if other files  instantiate  generics from this --
 -- unit, or you link  this unit with other files  to produce an executable, --
 --                                                                          --
 ------------------------------------------------------------------------------
 
+with Ada.Unchecked_Conversion;
+
+with System.Storage_Elements;
 with System.Finalization_Root;
 
 package System.Finalization_Implementation is
-pragma Elaborate_Body (Finalization_Implementation);
+   pragma Elaborate_Body;
 
+   package SSE renames System.Storage_Elements;
    package SFR renames System.Finalization_Root;
 
    ------------------------------------------------
    -- Finalization Management Abstract Interface --
    ------------------------------------------------
 
+   function To_Finalizable_Ptr is new Ada.Unchecked_Conversion
+     (Source => System.Address, Target => SFR.Finalizable_Ptr);
+
+   Collection_Finalization_Started : constant SFR.Finalizable_Ptr :=
+                                       To_Finalizable_Ptr (SSE.To_Address (1));
+   --  This is used to implement the rule in RM-4.8(10.2/2) that requires an
+   --  allocator to raise Program_Error if the collection finalization has
+   --  already started. See also Ada.Finalization.List_Controller. Finalize on
+   --  List_Controller first sets the list to Collection_Finalization_Started,
+   --  to indicate that finalization has started. An allocator will call
+   --  Attach_To_Final_List, which checks for the special value and raises
+   --  Program_Error if appropriate. The value of
+   --  Collection_Finalization_Started must be different from 'Access of any
+   --  finalizable object, and different from null. See AI-280.
+
    Global_Final_List : SFR.Finalizable_Ptr;
    --  This list stores the controlled objects defined in library-level
    --  packages. They will be finalized after the main program completion.
@@ -137,7 +156,7 @@ pragma Elaborate_Body (Finalization_Implementation);
    --  Initialize the field My_Address to the Object'Address
 
    procedure Adjust (Object : in out Record_Controller);
-   --  Adjust the components and their finalization pointers by substracting
+   --  Adjust the components and their finalization pointers by subtracting
    --  by the offset of the target and the source addresses of the assignment.
 
    --  Inherit Finalize from Limited_Record_Controller