OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [ada/] [s-finimp.ads] - Blame information for rev 454

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 281 jeremybenn
------------------------------------------------------------------------------
2
--                                                                          --
3
--                         GNAT COMPILER COMPONENTS                         --
4
--                                                                          --
5
--    S Y S T E M . F I N A L I Z A T I O N _ I M P L E M E N T A T I O N   --
6
--                                                                          --
7
--                                 S p e c                                  --
8
--                                                                          --
9
--          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
10
--                                                                          --
11
-- GNAT is free software;  you can  redistribute it  and/or modify it under --
12
-- terms of the  GNU General Public License as published  by the Free Soft- --
13
-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
14
-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
15
-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
16
-- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
17
--                                                                          --
18
-- As a special exception under Section 7 of GPL version 3, you are granted --
19
-- additional permissions described in the GCC Runtime Library Exception,   --
20
-- version 3.1, as published by the Free Software Foundation.               --
21
--                                                                          --
22
-- You should have received a copy of the GNU General Public License and    --
23
-- a copy of the GCC Runtime Library Exception along with this program;     --
24
-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
25
-- <http://www.gnu.org/licenses/>.                                          --
26
--                                                                          --
27
-- GNAT was originally developed  by the GNAT team at  New York University. --
28
-- Extensive contributions were provided by Ada Core Technologies Inc.      --
29
--                                                                          --
30
------------------------------------------------------------------------------
31
 
32
with Ada.Unchecked_Conversion;
33
 
34
with System.Storage_Elements;
35
with System.Finalization_Root;
36
 
37
package System.Finalization_Implementation is
38
   pragma Elaborate_Body;
39
 
40
   package SSE renames System.Storage_Elements;
41
   package SFR renames System.Finalization_Root;
42
 
43
   ------------------------------------------------
44
   -- Finalization Management Abstract Interface --
45
   ------------------------------------------------
46
 
47
   function To_Finalizable_Ptr is new Ada.Unchecked_Conversion
48
     (Source => System.Address, Target => SFR.Finalizable_Ptr);
49
 
50
   Collection_Finalization_Started : constant SFR.Finalizable_Ptr :=
51
                                       To_Finalizable_Ptr (SSE.To_Address (1));
52
   --  This is used to implement the rule in RM 4.8(10.2/2) that requires an
53
   --  allocator to raise Program_Error if the collection finalization has
54
   --  already started. See also Ada.Finalization.List_Controller. Finalize on
55
   --  List_Controller first sets the list to Collection_Finalization_Started,
56
   --  to indicate that finalization has started. An allocator will call
57
   --  Attach_To_Final_List, which checks for the special value and raises
58
   --  Program_Error if appropriate. The Collection_Finalization_Started value
59
   --  must be different from 'Access of any finalizable object, and different
60
   --  from null. See AI-280.
61
 
62
   Global_Final_List : SFR.Finalizable_Ptr;
63
   --  This list stores the controlled objects defined in library-level
64
   --  packages. They will be finalized after the main program completion.
65
 
66
   procedure Finalize_Global_List;
67
   --  The procedure to be called in order to finalize the global list
68
 
69
   procedure Attach_To_Final_List
70
     (L       : in out SFR.Finalizable_Ptr;
71
      Obj     : in out SFR.Finalizable;
72
      Nb_Link : Short_Short_Integer);
73
   --  Attach finalizable object Obj to the linked list L. Nb_Link controls the
74
   --  number of link of the linked_list, and is one of: 0 for no attachment, 1
75
   --  for simple linked lists or 2 for doubly linked lists or even 3 for a
76
   --  simple attachment of a whole array of elements. Attachment to a simply
77
   --  linked list is not protected against concurrent access and should only
78
   --  be used in contexts where it doesn't matter, such as for objects
79
   --  allocated on the stack. In the case of an attachment on a doubly linked
80
   --  list, L must not be null and Obj will be inserted AFTER the first
81
   --  element and the attachment is protected against concurrent call.
82
   --  Typically used to attach to a dynamically allocated object to a
83
   --  List_Controller (whose first element is always a dummy element)
84
 
85
   type Finalizable_Ptr_Ptr is access all SFR.Finalizable_Ptr;
86
   --  A pointer to a finalization list. This is used as the type of the extra
87
   --  implicit formal which are passed to build-in-place functions that return
88
   --  controlled types (see Sem_Ch6). That extra formal is then passed on to
89
   --  Move_Final_List (below).
90
 
91
   procedure Move_Final_List
92
     (From : in out SFR.Finalizable_Ptr;
93
      To   : Finalizable_Ptr_Ptr);
94
   --  Move all objects on From list to To list. This is used to implement
95
   --  build-in-place function returns. The return object is initially placed
96
   --  on a finalization list local to the return statement, in case the
97
   --  return statement is left prematurely (due to raising an exception,
98
   --  being aborted, or a goto or exit statement). Once the return statement
99
   --  has completed successfully, Move_Final_List is called to move the
100
   --  return object to the caller's finalization list.
101
 
102
   procedure Finalize_List (L : SFR.Finalizable_Ptr);
103
   --  Call Finalize on each element of the list L
104
 
105
   procedure Finalize_One (Obj  : in out SFR.Finalizable);
106
   --  Call Finalize on Obj and remove its final list
107
 
108
   ---------------------
109
   -- Deep Procedures --
110
   ---------------------
111
 
112
   procedure Deep_Tag_Attach
113
     (L : in out SFR.Finalizable_Ptr;
114
      A : System.Address;
115
      B : Short_Short_Integer);
116
   --  Generic attachment for tagged objects with controlled components.
117
   --  A is the address of the object, L the finalization list when it needs
118
   --  to be attached and B the attachment level (see Attach_To_Final_List).
119
 
120
   -----------------------------
121
   -- Record Controller Types --
122
   -----------------------------
123
 
124
   --  Definition of the types of the controller component that is included
125
   --  in records containing controlled components. This controller is
126
   --  attached to the finalization chain of the upper-level and carries
127
   --  the pointer of the finalization chain for the lower level.
128
 
129
   type Limited_Record_Controller is new SFR.Root_Controlled with record
130
      F : SFR.Finalizable_Ptr;
131
   end record;
132
 
133
   overriding procedure Initialize (Object : in out Limited_Record_Controller);
134
   --  Does nothing currently
135
 
136
   overriding procedure Finalize (Object : in out Limited_Record_Controller);
137
   --  Finalize the controlled components of the enclosing record by following
138
   --  the list starting at Object.F.
139
 
140
   type Record_Controller is
141
      new Limited_Record_Controller with record
142
         My_Address : System.Address;
143
      end record;
144
 
145
   overriding procedure Initialize (Object : in out Record_Controller);
146
   --  Initialize the field My_Address to the Object'Address
147
 
148
   overriding procedure Adjust (Object : in out Record_Controller);
149
   --  Adjust the components and their finalization pointers by subtracting by
150
   --  the offset of the target and the source addresses of the assignment.
151
 
152
   --  Inherit Finalize from Limited_Record_Controller
153
 
154
   procedure Detach_From_Final_List (Obj : in out SFR.Finalizable);
155
   --  Remove the specified object from its Final list, which must be a doubly
156
   --  linked list.
157
 
158
end System.Finalization_Implementation;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.