annotate gcc/ada/libgnat/s-finmas.ads @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- S Y S T E M . F I N A L I Z A T I O N _ M A S T E R S --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 2011-2018, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
kono
parents:
diff changeset
17 -- --
kono
parents:
diff changeset
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
19 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
20 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
21 -- --
kono
parents:
diff changeset
22 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
23 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
25 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
26 -- --
kono
parents:
diff changeset
27 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
29 -- --
kono
parents:
diff changeset
30 ------------------------------------------------------------------------------
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 with Ada.Finalization;
kono
parents:
diff changeset
33 with System.Storage_Elements;
kono
parents:
diff changeset
34 with System.Storage_Pools;
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 pragma Compiler_Unit_Warning;
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 package System.Finalization_Masters is
kono
parents:
diff changeset
39 pragma Preelaborate;
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 -- A reference to primitive Finalize_Address. The expander generates an
kono
parents:
diff changeset
42 -- implementation of this procedure for each controlled and class-wide
kono
parents:
diff changeset
43 -- type. Since controlled objects are simply viewed as addresses once
kono
parents:
diff changeset
44 -- allocated through a master, Finalize_Address provides a backward
kono
parents:
diff changeset
45 -- indirection from an address to a type-specific context.
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 type Finalize_Address_Ptr is access procedure (Obj : System.Address);
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 -- Heterogeneous collection type structure
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 type FM_Node is private;
kono
parents:
diff changeset
52 type FM_Node_Ptr is access all FM_Node;
kono
parents:
diff changeset
53 pragma No_Strict_Aliasing (FM_Node_Ptr);
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 -- A reference to any derivation from Root_Storage_Pool. Since this type
kono
parents:
diff changeset
56 -- may not be used to allocate objects, its storage size is zero.
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 type Any_Storage_Pool_Ptr is
kono
parents:
diff changeset
59 access System.Storage_Pools.Root_Storage_Pool'Class;
kono
parents:
diff changeset
60 for Any_Storage_Pool_Ptr'Storage_Size use 0;
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 -- Finalization master type structure. A unique master is associated with
kono
parents:
diff changeset
63 -- each access-to-controlled or access-to-class-wide type. Masters also act
kono
parents:
diff changeset
64 -- as components of subpools. By default, a master contains objects of the
kono
parents:
diff changeset
65 -- same designated type but it may also accommodate heterogeneous objects.
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 type Finalization_Master is
kono
parents:
diff changeset
68 new Ada.Finalization.Limited_Controlled with private;
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 -- A reference to a finalization master. Since this type may not be used
kono
parents:
diff changeset
71 -- to allocate objects, its storage size is zero.
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 type Finalization_Master_Ptr is access all Finalization_Master;
kono
parents:
diff changeset
74 for Finalization_Master_Ptr'Storage_Size use 0;
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 procedure Attach (N : not null FM_Node_Ptr; L : not null FM_Node_Ptr);
kono
parents:
diff changeset
77 -- Compiler interface, do not call from withing the run-time. Prepend a
kono
parents:
diff changeset
78 -- node to a specific finalization master.
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 procedure Attach_Unprotected
kono
parents:
diff changeset
81 (N : not null FM_Node_Ptr;
kono
parents:
diff changeset
82 L : not null FM_Node_Ptr);
kono
parents:
diff changeset
83 -- Prepend a node to a specific finalization master
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 procedure Delete_Finalize_Address_Unprotected (Obj : System.Address);
kono
parents:
diff changeset
86 -- Destroy the relation pair object - Finalize_Address from the internal
kono
parents:
diff changeset
87 -- hash table.
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 procedure Detach (N : not null FM_Node_Ptr);
kono
parents:
diff changeset
90 -- Compiler interface, do not call from within the run-time. Remove a node
kono
parents:
diff changeset
91 -- from an arbitrary finalization master.
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 procedure Detach_Unprotected (N : not null FM_Node_Ptr);
kono
parents:
diff changeset
94 -- Remove a node from an arbitrary finalization master
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 overriding procedure Finalize (Master : in out Finalization_Master);
kono
parents:
diff changeset
97 -- Lock the master to prevent allocations during finalization. Iterate over
kono
parents:
diff changeset
98 -- the list of allocated controlled objects, finalizing each one by calling
kono
parents:
diff changeset
99 -- its specific Finalize_Address. In the end, deallocate the dummy head.
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 function Finalize_Address
kono
parents:
diff changeset
102 (Master : Finalization_Master) return Finalize_Address_Ptr;
kono
parents:
diff changeset
103 -- Return a reference to the TSS primitive Finalize_Address associated with
kono
parents:
diff changeset
104 -- a master.
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 function Finalize_Address_Unprotected
kono
parents:
diff changeset
107 (Obj : System.Address) return Finalize_Address_Ptr;
kono
parents:
diff changeset
108 -- Retrieve the Finalize_Address primitive associated with a particular
kono
parents:
diff changeset
109 -- object.
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111 function Finalization_Started (Master : Finalization_Master) return Boolean;
kono
parents:
diff changeset
112 -- Return the finalization status of a master
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 function Header_Size return System.Storage_Elements.Storage_Count;
kono
parents:
diff changeset
115 -- Return the size of type FM_Node as Storage_Count
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 function Is_Homogeneous (Master : Finalization_Master) return Boolean;
kono
parents:
diff changeset
118 -- Return the behavior flag of a master
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 function Objects (Master : Finalization_Master) return FM_Node_Ptr;
kono
parents:
diff changeset
121 -- Return the header of the doubly-linked list of controlled objects
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 procedure Print_Master (Master : Finalization_Master);
kono
parents:
diff changeset
124 -- Debug routine, outputs the contents of a master
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 procedure Set_Finalize_Address
kono
parents:
diff changeset
127 (Master : in out Finalization_Master;
kono
parents:
diff changeset
128 Fin_Addr_Ptr : Finalize_Address_Ptr);
kono
parents:
diff changeset
129 -- Compiler interface, do not call from within the run-time. Set the clean
kono
parents:
diff changeset
130 -- up routine of a finalization master
kono
parents:
diff changeset
131
kono
parents:
diff changeset
132 procedure Set_Finalize_Address_Unprotected
kono
parents:
diff changeset
133 (Master : in out Finalization_Master;
kono
parents:
diff changeset
134 Fin_Addr_Ptr : Finalize_Address_Ptr);
kono
parents:
diff changeset
135 -- Set the clean up routine of a finalization master
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137 procedure Set_Heterogeneous_Finalize_Address_Unprotected
kono
parents:
diff changeset
138 (Obj : System.Address;
kono
parents:
diff changeset
139 Fin_Addr_Ptr : Finalize_Address_Ptr);
kono
parents:
diff changeset
140 -- Add a relation pair object - Finalize_Address to the internal hash
kono
parents:
diff changeset
141 -- table. This is done in the context of allocation on a heterogeneous
kono
parents:
diff changeset
142 -- finalization master where a single master services multiple anonymous
kono
parents:
diff changeset
143 -- access-to-controlled types.
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 procedure Set_Is_Heterogeneous (Master : in out Finalization_Master);
kono
parents:
diff changeset
146 -- Mark the master as being a heterogeneous collection of objects
kono
parents:
diff changeset
147
kono
parents:
diff changeset
148 private
kono
parents:
diff changeset
149 -- Heterogeneous collection type structure
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151 type FM_Node is record
kono
parents:
diff changeset
152 Prev : FM_Node_Ptr := null;
kono
parents:
diff changeset
153 Next : FM_Node_Ptr := null;
kono
parents:
diff changeset
154 end record;
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156 -- Finalization master type structure. A unique master is associated with
kono
parents:
diff changeset
157 -- each access-to-controlled or access-to-class-wide type. Masters also act
kono
parents:
diff changeset
158 -- as components of subpools. By default, a master contains objects of the
kono
parents:
diff changeset
159 -- same designated type but it may also accommodate heterogeneous objects.
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161 type Finalization_Master is
kono
parents:
diff changeset
162 new Ada.Finalization.Limited_Controlled with
kono
parents:
diff changeset
163 record
kono
parents:
diff changeset
164 Is_Homogeneous : Boolean := True;
kono
parents:
diff changeset
165 -- A flag which controls the behavior of the master. A value of False
kono
parents:
diff changeset
166 -- denotes a heterogeneous collection.
kono
parents:
diff changeset
167
kono
parents:
diff changeset
168 Base_Pool : Any_Storage_Pool_Ptr := null;
kono
parents:
diff changeset
169 -- A reference to the pool which this finalization master services. This
kono
parents:
diff changeset
170 -- field is used in conjunction with the build-in-place machinery.
kono
parents:
diff changeset
171
kono
parents:
diff changeset
172 Objects : aliased FM_Node;
kono
parents:
diff changeset
173 -- A doubly linked list which contains the headers of all controlled
kono
parents:
diff changeset
174 -- objects allocated in a [sub]pool.
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 Finalize_Address : Finalize_Address_Ptr := null;
kono
parents:
diff changeset
177 -- A reference to the routine reponsible for object finalization. This
kono
parents:
diff changeset
178 -- is used only when the master is in homogeneous mode.
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 Finalization_Started : Boolean := False;
kono
parents:
diff changeset
181 -- A flag used to detect allocations which occur during the finalization
kono
parents:
diff changeset
182 -- of a master. The allocations must raise Program_Error. This scenario
kono
parents:
diff changeset
183 -- may arise in a multitask environment.
kono
parents:
diff changeset
184 end record;
kono
parents:
diff changeset
185
kono
parents:
diff changeset
186 -- Since RTSfind cannot contain names of the form RE_"+", the following
kono
parents:
diff changeset
187 -- routine serves as a wrapper around System.Storage_Elements."+".
kono
parents:
diff changeset
188
kono
parents:
diff changeset
189 function Add_Offset_To_Address
kono
parents:
diff changeset
190 (Addr : System.Address;
kono
parents:
diff changeset
191 Offset : System.Storage_Elements.Storage_Offset) return System.Address;
kono
parents:
diff changeset
192
kono
parents:
diff changeset
193 function Base_Pool
kono
parents:
diff changeset
194 (Master : Finalization_Master) return Any_Storage_Pool_Ptr;
kono
parents:
diff changeset
195 -- Return a reference to the underlying storage pool on which the master
kono
parents:
diff changeset
196 -- operates.
kono
parents:
diff changeset
197
kono
parents:
diff changeset
198 overriding procedure Initialize (Master : in out Finalization_Master);
kono
parents:
diff changeset
199 -- Initialize the dummy head of a finalization master
kono
parents:
diff changeset
200
kono
parents:
diff changeset
201 procedure Set_Base_Pool
kono
parents:
diff changeset
202 (Master : in out Finalization_Master;
kono
parents:
diff changeset
203 Pool_Ptr : Any_Storage_Pool_Ptr);
kono
parents:
diff changeset
204 -- Set the underlying pool of a finalization master
kono
parents:
diff changeset
205
kono
parents:
diff changeset
206 end System.Finalization_Masters;