-- --
-- 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- --
-- 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.
-- 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