2010-07-27 Paolo Carlini <paolo.carlini@oracle.com>
[official-gcc/alias-decl.git] / gcc / ada / s-rident.ads
blob110731f344764f37725b80647f209118194f2017
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- S Y S T E M . R I D E N T --
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 ------------------------------------------------------------------------------
32 -- This package defines the set of restriction identifiers. It is a generic
33 -- package that is instantiated by the compiler/binder in package Rident, and
34 -- is instantiated in package System.Restrictions for use at run-time.
36 -- The reason that we make this a generic package is so that in the case of
37 -- the instantiation in Rident for use at compile time and bind time, we can
38 -- generate normal image tables for the enumeration types, which are needed
39 -- for diagnostic and informational messages. At run-time we really do not
40 -- want to waste the space for these image tables, and they are not needed,
41 -- so we can do the instantiation under control of Discard_Names to remove
42 -- the tables.
44 generic
45 package System.Rident is
46 pragma Preelaborate;
48 -- The following enumeration type defines the set of restriction
49 -- identifiers that are implemented in GNAT.
51 -- To add a new restriction identifier, add an entry with the name to be
52 -- used in the pragma, and add calls to the Restrict.Check_Restriction
53 -- routine as appropriate.
55 type Restriction_Id is
57 -- The following cases are checked for consistency in the binder. The
58 -- binder will check that every unit either has the restriction set, or
59 -- does not violate the restriction.
61 (Simple_Barriers, -- GNAT (Ravenscar)
62 No_Abort_Statements, -- (RM D.7(5), H.4(3))
63 No_Access_Subprograms, -- (RM H.4(17))
64 No_Allocators, -- (RM H.4(7))
65 No_Asynchronous_Control, -- (RM D.7(10))
66 No_Calendar, -- GNAT
67 No_Delay, -- (RM H.4(21))
68 No_Direct_Boolean_Operators, -- GNAT
69 No_Dispatch, -- (RM H.4(19))
70 No_Dispatching_Calls, -- GNAT
71 No_Dynamic_Attachment, -- GNAT
72 No_Dynamic_Priorities, -- (RM D.9(9))
73 No_Enumeration_Maps, -- GNAT
74 No_Entry_Calls_In_Elaboration_Code, -- GNAT
75 No_Entry_Queue, -- GNAT (Ravenscar)
76 No_Exception_Handlers, -- GNAT
77 No_Exception_Propagation, -- GNAT
78 No_Exception_Registration, -- GNAT
79 No_Exceptions, -- (RM H.4(12))
80 No_Finalization, -- GNAT
81 No_Fixed_Point, -- (RM H.4(15))
82 No_Floating_Point, -- (RM H.4(14))
83 No_IO, -- (RM H.4(20))
84 No_Implicit_Conditionals, -- GNAT
85 No_Implicit_Dynamic_Code, -- GNAT
86 No_Implicit_Heap_Allocations, -- (RM D.8(8), H.4(3))
87 No_Implicit_Loops, -- GNAT
88 No_Initialize_Scalars, -- GNAT
89 No_Local_Allocators, -- (RM H.4(8))
90 No_Local_Timing_Events, -- (RM D.7(10.2/2))
91 No_Local_Protected_Objects, -- GNAT
92 No_Nested_Finalization, -- (RM D.7(4))
93 No_Protected_Type_Allocators, -- GNAT
94 No_Protected_Types, -- (RM H.4(5))
95 No_Recursion, -- (RM H.4(22))
96 No_Reentrancy, -- (RM H.4(23))
97 No_Relative_Delay, -- GNAT (Ravenscar)
98 No_Requeue_Statements, -- GNAT
99 No_Secondary_Stack, -- GNAT
100 No_Select_Statements, -- GNAT (Ravenscar)
101 No_Specific_Termination_Handlers, -- (RM D.7(10.7/2))
102 No_Standard_Storage_Pools, -- GNAT
103 No_Stream_Optimizations, -- GNAT
104 No_Streams, -- GNAT
105 No_Task_Allocators, -- (RM D.7(7))
106 No_Task_Attributes_Package, -- GNAT
107 No_Task_Hierarchy, -- (RM D.7(3), H.4(3))
108 No_Task_Termination, -- GNAT (Ravenscar)
109 No_Tasking, -- GNAT
110 No_Terminate_Alternatives, -- (RM D.7(6))
111 No_Unchecked_Access, -- (RM H.4(18))
112 No_Unchecked_Conversion, -- (RM H.4(16))
113 No_Unchecked_Deallocation, -- (RM H.4(9))
114 Static_Priorities, -- GNAT
115 Static_Storage_Size, -- GNAT
117 -- The following require consistency checking with special rules. See
118 -- individual routines in unit Bcheck for details of what is required.
120 No_Default_Initialization, -- GNAT
122 -- The following cases do not require consistency checking
124 Immediate_Reclamation, -- (RM H.4(10))
125 No_Implementation_Attributes, -- Ada 2005 AI-257
126 No_Implementation_Pragmas, -- Ada 2005 AI-257
127 No_Implementation_Restrictions, -- GNAT
128 No_Elaboration_Code, -- GNAT
129 No_Obsolescent_Features, -- Ada 2005 AI-368
130 No_Wide_Characters, -- GNAT
132 -- The following cases require a parameter value
134 -- The following entries are fully checked at compile/bind time, which
135 -- means that the compiler can in general tell the minimum value which
136 -- could be used with a restrictions pragma. The binder can deduce the
137 -- appropriate minimum value for the partition by taking the maximum
138 -- value required by any unit.
140 Max_Protected_Entries, -- (RM D.7(14))
141 Max_Select_Alternatives, -- (RM D.7(12))
142 Max_Task_Entries, -- (RM D.7(13), H.4(3))
144 -- The following entries are also fully checked at compile/bind time,
145 -- and the compiler can also at least in some cases tell the minimum
146 -- value which could be used with a restriction pragma. The difference
147 -- is that the contributions are additive, so the binder deduces this
148 -- value by adding the unit contributions.
150 Max_Tasks, -- (RM D.7(19), H.4(3))
152 -- The following entries are checked at compile time only for zero/
153 -- nonzero entries. This means that the compiler can tell at compile
154 -- time if a restriction value of zero is (would be) violated, but that
155 -- the compiler cannot distinguish between different non-zero values.
157 Max_Asynchronous_Select_Nesting, -- (RM D.7(18), H.4(3))
158 Max_Entry_Queue_Length, -- GNAT
160 -- The remaining entries are not checked at compile/bind time
162 Max_Storage_At_Blocking, -- (RM D.7(17))
164 Not_A_Restriction_Id);
166 -- Synonyms permitted for historical purposes of compatibility.
167 -- Must be coordinated with Restrict.Process_Restriction_Synonym.
169 Boolean_Entry_Barriers : Restriction_Id renames Simple_Barriers;
170 Max_Entry_Queue_Depth : Restriction_Id renames Max_Entry_Queue_Length;
171 No_Dynamic_Interrupts : Restriction_Id renames No_Dynamic_Attachment;
172 No_Requeue : Restriction_Id renames No_Requeue_Statements;
173 No_Task_Attributes : Restriction_Id renames No_Task_Attributes_Package;
175 subtype All_Restrictions is Restriction_Id range
176 Simple_Barriers .. Max_Storage_At_Blocking;
177 -- All restrictions (excluding only Not_A_Restriction_Id)
179 subtype All_Boolean_Restrictions is Restriction_Id range
180 Simple_Barriers .. No_Wide_Characters;
181 -- All restrictions which do not take a parameter
183 subtype Partition_Boolean_Restrictions is All_Boolean_Restrictions range
184 Simple_Barriers .. Static_Storage_Size;
185 -- Boolean restrictions that are checked for partition consistency.
186 -- Note that all parameter restrictions are checked for partition
187 -- consistency by default, so this distinction is only needed in the
188 -- case of Boolean restrictions.
190 subtype Cunit_Boolean_Restrictions is All_Boolean_Restrictions range
191 Immediate_Reclamation .. No_Wide_Characters;
192 -- Boolean restrictions that are not checked for partition consistency
193 -- and that thus apply only to the current unit. Note that for these
194 -- restrictions, the compiler does not apply restrictions found in
195 -- with'ed units, parent specs etc. to the main unit.
197 subtype All_Parameter_Restrictions is
198 Restriction_Id range
199 Max_Protected_Entries .. Max_Storage_At_Blocking;
200 -- All restrictions that take a parameter
202 subtype Checked_Parameter_Restrictions is
203 All_Parameter_Restrictions range
204 Max_Protected_Entries .. Max_Entry_Queue_Length;
205 -- These are the parameter restrictions that can be at least partially
206 -- checked at compile/binder time. Minimally, the compiler can detect
207 -- violations of a restriction pragma with a value of zero reliably.
209 subtype Checked_Max_Parameter_Restrictions is
210 Checked_Parameter_Restrictions range
211 Max_Protected_Entries .. Max_Task_Entries;
212 -- Restrictions with parameters that can be checked in some cases by
213 -- maximizing among statically detected instances where the compiler
214 -- can determine the count.
216 subtype Checked_Add_Parameter_Restrictions is
217 Checked_Parameter_Restrictions range
218 Max_Tasks .. Max_Tasks;
219 -- Restrictions with parameters that can be checked in some cases by
220 -- summing the statically detected instances where the compiler can
221 -- determine the count.
223 subtype Checked_Val_Parameter_Restrictions is
224 Checked_Parameter_Restrictions range
225 Max_Protected_Entries .. Max_Tasks;
226 -- Restrictions with parameter where the count is known at least in some
227 -- cases by the compiler/binder.
229 subtype Checked_Zero_Parameter_Restrictions is
230 Checked_Parameter_Restrictions range
231 Max_Asynchronous_Select_Nesting .. Max_Entry_Queue_Length;
232 -- Restrictions with parameters where the compiler can detect the use of
233 -- the feature, and hence violations of a restriction specifying a value
234 -- of zero, but cannot detect specific values other than zero/nonzero.
236 subtype Unchecked_Parameter_Restrictions is
237 All_Parameter_Restrictions range
238 Max_Storage_At_Blocking .. Max_Storage_At_Blocking;
239 -- Restrictions with parameters where the compiler cannot ever detect
240 -- corresponding compile time usage, so the binder and compiler never
241 -- detect violations of any restriction.
243 -------------------------------------
244 -- Restriction Status Declarations --
245 -------------------------------------
247 -- The following declarations are used to record the current status or
248 -- restrictions (for the current unit, or related units, at compile time,
249 -- and for all units in a partition at bind time or run time).
251 type Restriction_Flags is array (All_Restrictions) of Boolean;
252 type Restriction_Values is array (All_Parameter_Restrictions) of Natural;
253 type Parameter_Flags is array (All_Parameter_Restrictions) of Boolean;
255 type Restrictions_Info is record
256 Set : Restriction_Flags;
257 -- An entry is True in the Set array if a restrictions pragma has been
258 -- encountered for the given restriction. If the value is True for a
259 -- parameter restriction, then the corresponding entry in the Value
260 -- array gives the minimum value encountered for any such restriction.
262 Value : Restriction_Values;
263 -- If the entry for a parameter restriction in Set is True (i.e. a
264 -- restrictions pragma for the restriction has been encountered), then
265 -- the corresponding entry in the Value array is the minimum value
266 -- specified by any such restrictions pragma. Note that a restrictions
267 -- pragma specifying a value greater than Int'Last is simply ignored.
269 Violated : Restriction_Flags;
270 -- An entry is True in the violations array if the compiler has detected
271 -- a violation of the restriction. For a parameter restriction, the
272 -- Count and Unknown arrays have additional information.
274 Count : Restriction_Values;
275 -- If an entry for a parameter restriction is True in Violated, the
276 -- corresponding entry in the Count array may record additional
277 -- information. If the actual minimum count is known (by taking
278 -- maximums, or sums, depending on the restriction), it will be
279 -- recorded in this array. If not, then the value will remain zero.
280 -- The value is also zero for a non-violated restriction.
282 Unknown : Parameter_Flags;
283 -- If an entry for a parameter restriction is True in Violated, the
284 -- corresponding entry in the Unknown array may record additional
285 -- information. If the actual count is not known by the compiler (but
286 -- is known to be non-zero), then the entry in Unknown will be True.
287 -- This indicates that the value in Count is not known to be exact,
288 -- and the actual violation count may be higher.
290 -- Note: If Violated (K) is True, then either Count (K) > 0 or
291 -- Unknown (K) = True. It is possible for both these to be set.
292 -- For example, if Count (K) = 3 and Unknown (K) is True, it means
293 -- that the actual violation count is at least 3 but might be higher.
294 end record;
296 No_Restrictions : constant Restrictions_Info :=
297 (Set => (others => False),
298 Value => (others => 0),
299 Violated => (others => False),
300 Count => (others => 0),
301 Unknown => (others => False));
302 -- Used to initialize Restrictions_Info variables
304 ----------------------------------
305 -- Profile Definitions and Data --
306 ----------------------------------
308 type Profile_Name is (No_Profile, Ravenscar, Restricted);
309 -- Names of recognized profiles. No_Profile is used to indicate that a
310 -- restriction came from pragma Restrictions[_Warning], as opposed to
311 -- pragma Profile[_Warning].
313 subtype Profile_Name_Actual is Profile_Name range Ravenscar .. Restricted;
314 -- Actual used profile names
316 type Profile_Data is record
317 Set : Restriction_Flags;
318 -- Set to True if given restriction must be set for the profile, and
319 -- False if it need not be set (False does not mean that it must not be
320 -- set, just that it need not be set). If the flag is True for a
321 -- parameter restriction, then the Value array gives the maximum value
322 -- permitted by the profile.
324 Value : Restriction_Values;
325 -- An entry in this array is meaningful only if the corresponding flag
326 -- in Set is True. In that case, the value in this array is the maximum
327 -- value of the parameter permitted by the profile.
328 end record;
330 Profile_Info : array (Profile_Name_Actual) of Profile_Data :=
332 -- Restricted Profile
334 (Restricted =>
336 -- Restrictions for Restricted profile
338 (Set =>
339 (No_Abort_Statements => True,
340 No_Asynchronous_Control => True,
341 No_Dynamic_Attachment => True,
342 No_Dynamic_Priorities => True,
343 No_Entry_Queue => True,
344 No_Local_Protected_Objects => True,
345 No_Protected_Type_Allocators => True,
346 No_Requeue_Statements => True,
347 No_Task_Allocators => True,
348 No_Task_Attributes_Package => True,
349 No_Task_Hierarchy => True,
350 No_Terminate_Alternatives => True,
351 Max_Asynchronous_Select_Nesting => True,
352 Max_Protected_Entries => True,
353 Max_Select_Alternatives => True,
354 Max_Task_Entries => True,
355 others => False),
357 -- Value settings for Restricted profile
359 Value =>
360 (Max_Asynchronous_Select_Nesting => 0,
361 Max_Protected_Entries => 1,
362 Max_Select_Alternatives => 0,
363 Max_Task_Entries => 0,
364 others => 0)),
366 -- Ravenscar Profile
368 -- Note: the table entries here only represent the
369 -- required restriction profile for Ravenscar. The
370 -- full Ravenscar profile also requires:
372 -- pragma Dispatching_Policy (FIFO_Within_Priorities);
373 -- pragma Locking_Policy (Ceiling_Locking);
374 -- pragma Detect_Blocking
376 Ravenscar =>
378 -- Restrictions for Ravenscar = Restricted profile ..
380 (Set =>
381 (No_Abort_Statements => True,
382 No_Asynchronous_Control => True,
383 No_Dynamic_Attachment => True,
384 No_Dynamic_Priorities => True,
385 No_Entry_Queue => True,
386 No_Local_Protected_Objects => True,
387 No_Protected_Type_Allocators => True,
388 No_Requeue_Statements => True,
389 No_Task_Allocators => True,
390 No_Task_Attributes_Package => True,
391 No_Task_Hierarchy => True,
392 No_Terminate_Alternatives => True,
393 Max_Asynchronous_Select_Nesting => True,
394 Max_Protected_Entries => True,
395 Max_Select_Alternatives => True,
396 Max_Task_Entries => True,
398 -- plus these additional restrictions:
400 No_Calendar => True,
401 No_Implicit_Heap_Allocations => True,
402 No_Relative_Delay => True,
403 No_Select_Statements => True,
404 No_Task_Termination => True,
405 Simple_Barriers => True,
406 others => False),
408 -- Value settings for Ravenscar (same as Restricted)
410 Value =>
411 (Max_Asynchronous_Select_Nesting => 0,
412 Max_Protected_Entries => 1,
413 Max_Select_Alternatives => 0,
414 Max_Task_Entries => 0,
415 others => 0)));
417 end System.Rident;