OSDN Git Service

Fix aliasing bug that also caused memory usage problems.
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-rident.ads
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-2004 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 2,  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.  See the GNU General Public License --
17 -- for  more details.  You should have  received  a copy of the GNU General --
18 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
19 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
20 -- MA 02111-1307, USA.                                                      --
21 --                                                                          --
22 -- As a special exception,  if other files  instantiate  generics from this --
23 -- unit, or you link  this unit with other files  to produce an executable, --
24 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
25 -- covered  by the  GNU  General  Public  License.  This exception does not --
26 -- however invalidate  any other reasons why  the executable file  might be --
27 -- covered by the GNU Public License.                                       --
28 --                                                                          --
29 -- GNAT was originally developed  by the GNAT team at  New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
31 --                                                                          --
32 ------------------------------------------------------------------------------
33
34 --  This package defines the set of restriction identifiers. It is a generic
35 --  package that is instantiated by the compiler/binder in package Rident, and
36 --  is instantiated in package System.Restrictions for use at run-time.
37
38 --  The reason that we make this a generic package is so that in the case of
39 --  the instantiation in Rident for use at compile time and bind time, we can
40 --  generate normal image tables for the enumeration types, which are needed
41 --  for diagnostic and informational messages. At run-time we really do not
42 --  want to waste the space for these image tables, and they are not needed,
43 --  so we can do the instantiation under control of Discard_Names to remove
44 --  the tables.
45
46 generic
47 package System.Rident is
48
49    --  The following enumeration type defines the set of restriction
50    --  identifiers that are implemented in GNAT.
51
52    --  To add a new restriction identifier, add an entry with the name
53    --  to be used in the pragma, and add appropriate calls to the
54    --  Restrict.Check_Restriction routine.
55
56    type Restriction_Id is
57
58       --  The following cases are checked for consistency in the binder
59
60      (Simple_Barriers,                         -- GNAT (Ravenscar)
61       No_Abort_Statements,                     -- (RM D.7(5), H.4(3))
62       No_Access_Subprograms,                   -- (RM H.4(17))
63       No_Allocators,                           -- (RM H.4(7))
64       No_Asynchronous_Control,                 -- (RM D.7(10))
65       No_Calendar,                             -- GNAT
66       No_Delay,                                -- (RM H.4(21))
67       No_Direct_Boolean_Operators,             -- GNAT
68       No_Dispatch,                             -- (RM H.4(19))
69       No_Dynamic_Attachment,                   -- GNAT
70       No_Dynamic_Priorities,                   -- (RM D.9(9))
71       No_Enumeration_Maps,                     -- GNAT
72       No_Entry_Calls_In_Elaboration_Code,      -- GNAT
73       No_Entry_Queue,                          -- GNAT (Ravenscar)
74       No_Exception_Handlers,                   -- GNAT
75       No_Exception_Registration,               -- GNAT
76       No_Exceptions,                           -- (RM H.4(12))
77       No_Finalization,                         -- GNAT
78       No_Fixed_Point,                          -- (RM H.4(15))
79       No_Floating_Point,                       -- (RM H.4(14))
80       No_IO,                                   -- (RM H.4(20))
81       No_Implicit_Conditionals,                -- GNAT
82       No_Implicit_Dynamic_Code,                -- GNAT
83       No_Implicit_Heap_Allocations,            -- (RM D.8(8), H.4(3))
84       No_Implicit_Loops,                       -- GNAT
85       No_Initialize_Scalars,                   -- GNAT
86       No_Local_Allocators,                     -- (RM H.4(8))
87       No_Local_Protected_Objects,              -- GNAT
88       No_Nested_Finalization,                  -- (RM D.7(4))
89       No_Protected_Type_Allocators,            -- GNAT
90       No_Protected_Types,                      -- (RM H.4(5))
91       No_Recursion,                            -- (RM H.4(22))
92       No_Reentrancy,                           -- (RM H.4(23))
93       No_Relative_Delay,                       -- GNAT (Ravenscar)
94       No_Requeue_Statements,                   -- GNAT
95       No_Secondary_Stack,                      -- GNAT
96       No_Select_Statements,                    -- GNAT (Ravenscar)
97       No_Standard_Storage_Pools,               -- GNAT
98       No_Streams,                              -- GNAT
99       No_Task_Allocators,                      -- (RM D.7(7))
100       No_Task_Attributes_Package,              -- GNAT
101       No_Task_Hierarchy,                       -- (RM D.7(3), H.4(3))
102       No_Task_Termination,                     -- GNAT (Ravenscar)
103       No_Tasking,                              -- GNAT
104       No_Terminate_Alternatives,               -- (RM D.7(6))
105       No_Unchecked_Access,                     -- (RM H.4(18))
106       No_Unchecked_Conversion,                 -- (RM H.4(16))
107       No_Unchecked_Deallocation,               -- (RM H.4(9))
108       No_Wide_Characters,                      -- GNAT
109       Static_Priorities,                       -- GNAT
110       Static_Storage_Size,                     -- GNAT
111
112       --  The following cases do not require partition-wide checks
113
114       Immediate_Reclamation,                   -- (RM H.4(10))
115       No_Implementation_Attributes,            -- GNAT
116       No_Implementation_Pragmas,               -- GNAT
117       No_Implementation_Restrictions,          -- GNAT
118       No_Elaboration_Code,                     -- GNAT
119
120       --  The following cases require a parameter value
121
122       --  The following entries are fully checked at compile/bind time,
123       --  which means that the compiler can in general tell the minimum
124       --  value which could be used with a restrictions pragma. The binder
125       --  can deduce the appropriate minimum value for the partition by
126       --  taking the maximum value required by any unit.
127
128       Max_Protected_Entries,                   -- (RM D.7(14))
129       Max_Select_Alternatives,                 -- (RM D.7(12))
130       Max_Task_Entries,                        -- (RM D.7(13), H.4(3))
131
132       --  The following entries are also fully checked at compile/bind
133       --  time, and the compiler can also at least in some cases tell
134       --  the minimum value which could be used with a restriction pragma.
135       --  The difference is that the contributions are additive, so the
136       --  binder deduces this value by adding the unit contributions.
137
138       Max_Tasks,                               -- (RM D.7(19), H.4(3))
139
140       --  The following entries are checked at compile time only for
141       --  zero/nonzero entries. This means that the compiler can tell
142       --  at compile time if a restriction value of zero is (would be)
143       --  violated, but that is all. The compiler cannot distinguish
144       --  between different non-zero values.
145
146       Max_Asynchronous_Select_Nesting,         -- (RM D.7(18), H.4(3))
147       Max_Entry_Queue_Length,                  -- GNAT
148
149       --  The remaining entries are not checked at compile/bind time
150
151       Max_Storage_At_Blocking,                 -- (RM D.7(17))
152
153       Not_A_Restriction_Id);
154
155    --  Synonyms permitted for historical purposes of compatibility.
156    --  Must be coordinated with Restrict.Process_Restriction_Synonym.
157
158    Boolean_Entry_Barriers : Restriction_Id renames Simple_Barriers;
159    Max_Entry_Queue_Depth  : Restriction_Id renames Max_Entry_Queue_Length;
160    No_Dynamic_Interrupts  : Restriction_Id renames No_Dynamic_Attachment;
161    No_Requeue             : Restriction_Id renames No_Requeue_Statements;
162    No_Task_Attributes     : Restriction_Id renames No_Task_Attributes_Package;
163
164    subtype All_Restrictions is Restriction_Id range
165      Simple_Barriers .. Max_Storage_At_Blocking;
166    --  All restrictions (excluding only Not_A_Restriction_Id)
167
168    subtype All_Boolean_Restrictions is Restriction_Id range
169      Simple_Barriers .. No_Elaboration_Code;
170    --  All restrictions which do not take a parameter
171
172    subtype Partition_Boolean_Restrictions is All_Boolean_Restrictions range
173      Simple_Barriers .. Static_Storage_Size;
174    --  Boolean restrictions that are checked for partition consistency.
175    --  Note that all parameter restrictions are checked for partition
176    --  consistency by default, so this distinction is only needed in the
177    --  case of Boolean restrictions.
178
179    subtype Cunit_Boolean_Restrictions is All_Boolean_Restrictions range
180      Immediate_Reclamation .. No_Elaboration_Code;
181    --  Boolean restrictions that are not checked for partition consistency
182    --  and that thus apply only to the current unit. Note that for these
183    --  restrictions, the compiler does not apply restrictions found in
184    --  with'ed units, parent specs etc to the main unit.
185
186    subtype All_Parameter_Restrictions is
187      Restriction_Id range
188        Max_Protected_Entries .. Max_Storage_At_Blocking;
189    --  All restrictions that are take a parameter
190
191    subtype Checked_Parameter_Restrictions is
192      All_Parameter_Restrictions range
193        Max_Protected_Entries .. Max_Entry_Queue_Length;
194    --  These are the parameter restrictions that can be at least partially
195    --  checked at compile/binder time. Minimally, the compiler can detect
196    --  violations of a restriction pragma with a value of zero reliably.
197
198    subtype Checked_Max_Parameter_Restrictions is
199      Checked_Parameter_Restrictions range
200        Max_Protected_Entries .. Max_Task_Entries;
201    --  Restrictions with parameters that can be checked in some cases by
202    --  maximizing among statically detected instances where the compiler
203    --  can determine the count.
204
205    subtype Checked_Add_Parameter_Restrictions is
206      Checked_Parameter_Restrictions range
207        Max_Tasks .. Max_Tasks;
208    --  Restrictions with parameters that can be checked in some cases by
209    --  summing the statically detected instances where the compiler can
210    --  determine the count.
211
212    subtype Checked_Val_Parameter_Restrictions is
213      Checked_Parameter_Restrictions range
214        Max_Protected_Entries .. Max_Tasks;
215    --  Restrictions with parameter where the count is known at least in
216    --  some cases by the compiler/binder.
217
218    subtype Checked_Zero_Parameter_Restrictions is
219      Checked_Parameter_Restrictions range
220        Max_Asynchronous_Select_Nesting .. Max_Entry_Queue_Length;
221    --  Restrictions with parameters where the compiler can detect the use of
222    --  the feature, and hence violations of a restriction specifying a value
223    --  of zero, but cannot detect specific values other than zero/nonzero.
224
225    subtype Unchecked_Parameter_Restrictions is
226      All_Parameter_Restrictions range
227        Max_Storage_At_Blocking .. Max_Storage_At_Blocking;
228    --  Restrictions with parameters where the compiler cannot ever detect
229    --  corresponding compile time usage, so the binder and compiler never
230    --  detect violations of any restriction.
231
232    -------------------------------------
233    -- Restriction Status Declarations --
234    -------------------------------------
235
236    --  The following declarations are used to record the current status
237    --  or restrictions (for the current unit, or related units, at compile
238    --  time, and for all units in a partition at bind time or run time).
239
240    type Restriction_Flags  is array (All_Restrictions)           of Boolean;
241    type Restriction_Values is array (All_Parameter_Restrictions) of Natural;
242    type Parameter_Flags    is array (All_Parameter_Restrictions) of Boolean;
243
244    type Restrictions_Info is record
245       Set : Restriction_Flags := (others => False);
246       --  An entry is True in the Set array if a restrictions pragma has
247       --  been encountered for the given restriction. If the value is
248       --  True for a parameter restriction, then the corresponding entry
249       --  in the Value array gives the minimum value encountered for any
250       --  such restriction.
251
252       Value : Restriction_Values;
253       --  If the entry for a parameter restriction in Set is True (i.e. a
254       --  restrictions pragma for the restriction has been encountered), then
255       --  the corresponding entry in the Value array is the minimum value
256       --  specified by any such restrictions pragma. Note that a restrictions
257       --  pragma specifying a value greater than Int'Last is simply ignored.
258
259       Violated : Restriction_Flags := (others => False);
260       --  An entry is True in the violations array if the compiler has
261       --  detected a violation of the restriction. For a parameter
262       --  restriction, the Count and Unknown arrays have additional
263       --  information.
264
265       Count : Restriction_Values := (others => 0);
266       --  If an entry for a parameter restriction is True in Violated,
267       --  the corresponding entry in the Count array may record additional
268       --  information. If the actual minimum count is known (by taking
269       --  maximums, or sums, depending on the restriction), it will be
270       --  recorded in this array. If not, then the value will remain zero.
271
272       Unknown : Parameter_Flags := (others => False);
273       --  If an entry for a parameter restriction is True in Violated,
274       --  the corresponding entry in the Unknown array may record additional
275       --  information. If the actual count is not known by the compiler (but
276       --  is known to be non-zero), then the entry in Unknown will be True.
277       --  This indicates that the value in Count is not known to be exact,
278       --  and the actual violation count may be higher.
279
280       --  Note: If Violated (K) is True, then either Count (K) > 0 or
281       --  Unknown (K) = True. It is possible for both these to be set.
282       --  For example, if Count (K) = 3 and Unknown (K) is True, it means
283       --  that the actual violation count is at least 3 but might be higher.
284    end record;
285
286    ----------------------------------
287    -- Profile Definitions and Data --
288    ----------------------------------
289
290    type Profile_Name is (Ravenscar, Restricted);
291    --  Names of recognized pfofiles
292
293    type Profile_Data is record
294       Set : Restriction_Flags;
295       --  Set to True if given restriction must be set for the profile,
296       --  and False if it need not be set (False does not mean that it
297       --  must not be set, just that it need not be set). If the flag
298       --  is True for a parameter restriction, then the Value array
299       --  gives the maximum value permitted by the profile.
300
301       Value : Restriction_Values;
302       --  An entry in this array is meaningful only if the corresponding
303       --  flag in Set is True. In that case, the value in this array is
304       --  the maximum value of the parameter permitted by the profile.
305    end record;
306
307    Profile_Info : array (Profile_Name) of Profile_Data :=
308
309                      --  Restricted Profile
310
311                     (Restricted =>
312
313                         --  Restrictions for Restricted profile
314
315                        (Set   =>
316                           (No_Abort_Statements             => True,
317                            No_Asynchronous_Control         => True,
318                            No_Dynamic_Attachment           => True,
319                            No_Dynamic_Priorities           => True,
320                            No_Entry_Queue                  => True,
321                            No_Local_Protected_Objects      => True,
322                            No_Protected_Type_Allocators    => True,
323                            No_Requeue_Statements           => True,
324                            No_Task_Allocators              => True,
325                            No_Task_Attributes_Package      => True,
326                            No_Task_Hierarchy               => True,
327                            No_Terminate_Alternatives       => True,
328                            Max_Asynchronous_Select_Nesting => True,
329                            Max_Protected_Entries           => True,
330                            Max_Select_Alternatives         => True,
331                            Max_Task_Entries                => True,
332                            others                          => False),
333
334                         --  Value settings for Restricted profile
335
336                         Value =>
337                           (Max_Asynchronous_Select_Nesting => 0,
338                            Max_Protected_Entries           => 1,
339                            Max_Select_Alternatives         => 0,
340                            Max_Task_Entries                => 0,
341                            others                          => 0)),
342
343                      --  Ravenscar Profile
344
345                      --  Note: the table entries here only represent the
346                      --  required restriction profile for Ravenscar. The
347                      --  full Ravenscar profile also requires:
348
349                      --    pragma Dispatching_Policy (FIFO_Within_Priorities);
350                      --    pragma Locking_Policy (Ceiling_Locking);
351                      --    pragma Detect_Blocking
352
353                      Ravenscar  =>
354
355                      --  Restrictions for Ravenscar = Restricted profile ..
356
357                        (Set   =>
358                           (No_Abort_Statements             => True,
359                            No_Asynchronous_Control         => True,
360                            No_Dynamic_Attachment           => True,
361                            No_Dynamic_Priorities           => True,
362                            No_Entry_Queue                  => True,
363                            No_Local_Protected_Objects      => True,
364                            No_Protected_Type_Allocators    => True,
365                            No_Requeue_Statements           => True,
366                            No_Task_Allocators              => True,
367                            No_Task_Attributes_Package      => True,
368                            No_Task_Hierarchy               => True,
369                            No_Terminate_Alternatives       => True,
370                            Max_Asynchronous_Select_Nesting => True,
371                            Max_Protected_Entries           => True,
372                            Max_Select_Alternatives         => True,
373                            Max_Task_Entries                => True,
374
375                            --  plus these additional restrictions:
376
377                            No_Calendar                     => True,
378                            No_Implicit_Heap_Allocations    => True,
379                            No_Relative_Delay               => True,
380                            No_Select_Statements            => True,
381                            No_Task_Termination             => True,
382                            Simple_Barriers                 => True,
383                            others                          => False),
384
385                         --  Value settings for Ravenscar (same as Restricted)
386
387                         Value =>
388                           (Max_Asynchronous_Select_Nesting => 0,
389                            Max_Protected_Entries           => 1,
390                            Max_Select_Alternatives         => 0,
391                            Max_Task_Entries                => 0,
392                            others                          => 0)));
393
394 end System.Rident;