OSDN Git Service

* 5ataprop.adb, 5atpopsp.adb, 5ftaprop.adb, 5gmastop.adb,
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-stalib.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --              S Y S T E M . S T A N D A R D _ L I B R A R Y               --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --                            $Revision: 1.1 $
10 --                                                                          --
11 --          Copyright (C) 1992-2001 Free Software Foundation, Inc.          --
12 --                                                                          --
13 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
14 -- terms of the  GNU General Public License as published  by the Free Soft- --
15 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
16 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
19 -- for  more details.  You should have  received  a copy of the GNU General --
20 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
21 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
22 -- MA 02111-1307, USA.                                                      --
23 --                                                                          --
24 -- As a special exception,  if other files  instantiate  generics from this --
25 -- unit, or you link  this unit with other files  to produce an executable, --
26 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
27 -- covered  by the  GNU  General  Public  License.  This exception does not --
28 -- however invalidate  any other reasons why  the executable file  might be --
29 -- covered by the  GNU Public License.                                      --
30 --                                                                          --
31 -- GNAT was originally developed  by the GNAT team at  New York University. --
32 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
33 --                                                                          --
34 ------------------------------------------------------------------------------
35
36 --  This package is included in all programs. It contains declarations that
37 --  are required to be part of every Ada program. A special mechanism is
38 --  required to ensure that these are loaded, since it may be the case in
39 --  some programs that the only references to these required packages are
40 --  from C code or from code generated directly by Gigi, an in both cases
41 --  the binder is not aware of such references.
42
43 --  System.Standard_Library also includes data that must be present in every
44 --  program, in particular the definitions of all the standard and also some
45 --  subprograms that must be present in every program.
46
47 --  The binder unconditionally includes s-stalib.ali, which ensures that this
48 --  package and the packages it references are included in all Ada programs,
49 --  together with the included data.
50
51 pragma Polling (Off);
52 --  We must turn polling off for this unit, because otherwise we get
53 --  elaboration circularities with Ada.Exceptions if polling is on.
54
55 with System;
56 with Unchecked_Conversion;
57
58 package System.Standard_Library is
59
60    pragma Suppress (All_Checks);
61    --  Suppress explicitly all the checks to work around the Solaris linker
62    --  bug when using gnatmake -f -a (but without -gnatp). This is not needed
63    --  with Solaris 2.6, so eventually can be removed ???
64
65    type Big_String_Ptr is access all String (Positive);
66    --  A non-fat pointer type for null terminated strings
67
68    function To_Ptr is
69      new Unchecked_Conversion (System.Address, Big_String_Ptr);
70
71    ---------------------------------------------
72    -- Type For Enumeration Image Index Tables --
73    ---------------------------------------------
74
75    --  Note: these types are declared at the start of this unit, since
76    --  they must appear before any enumeration types declared in this
77    --  unit. Note that the spec of system is already elaborated at
78    --  this point (since we are a child of system), which means that
79    --  enumeration types in package System cannot use these types.
80
81    type Image_Index_Table_8 is
82      array (Integer range <>) of Short_Short_Integer;
83    type Image_Index_Table_16 is
84      array (Integer range <>) of Short_Integer;
85    type Image_Index_Table_32 is
86      array (Integer range <>) of Integer;
87    --  These types are used to generate the index vector used for enumeration
88    --  type image tables. See spec of Exp_Imgv in the main GNAT sources for a
89    --  full description of the data structures that are used here.
90
91    -------------------------------------
92    -- Exception Declarations and Data --
93    -------------------------------------
94
95    type Exception_Data;
96    type Exception_Data_Ptr is access all Exception_Data;
97    --  An equivalent of Exception_Id that is public
98
99    --  The following record defines the underlying representation of exceptions
100
101    --  WARNING! Any changes to this may need to be reflectd in the following
102    --  locations in the compiler and runtime code:
103
104    --    1. The Internal_Exception routine in s-exctab.adb
105    --    2. The processing in gigi that tests Not_Handled_By_Others
106    --    3. Expand_N_Exception_Declaration in Exp_Ch11
107    --    4. The construction of the exception type in Cstand
108
109    type Exception_Data is record
110       Not_Handled_By_Others : Boolean;
111       --  Normally set False, indicating that the exception is handled in the
112       --  usual way by others (i.e. an others handler handles the exception).
113       --  Set True to indicate that this exception is not caught by others
114       --  handlers, but must be explicitly named in a handler. This latter
115       --  setting is currently used by the Abort_Signal.
116
117       Lang : Character;
118       --  A character indicating the language raising the exception.
119       --  Set to "A" for exceptions defined by an Ada program.
120       --  Set to "V" for imported VMS exceptions.
121
122       Name_Length : Natural;
123       --  Length of fully expanded name of exception
124
125       Full_Name : Big_String_Ptr;
126       --  Fully expanded name of exception, null terminated
127
128       HTable_Ptr : Exception_Data_Ptr;
129       --  Hash table pointer used to link entries together in the hash table
130       --  built (by Register_Exception in s-exctab.adb) for converting between
131       --  identities and names.
132
133       Import_Code : Integer;
134       --  Value for imported exceptions. Needed only for the handling of
135       --  Import/Export_Exception for the VMS case, but present in all
136       --  implementations (we might well extend this mechanism for other
137       --  systems in the future).
138
139    end record;
140
141    --  Definitions for standard predefined exceptions defined in Standard,
142
143    --  Why are the Nul's necessary here, seems like they should not be
144    --  required, since Gigi is supposed to add a Nul to each name ???
145
146    Constraint_Error_Name : constant String := "CONSTRAINT_ERROR" & ASCII.NUL;
147    Program_Error_Name    : constant String := "PROGRAM_ERROR"    & ASCII.NUL;
148    Storage_Error_Name    : constant String := "STORAGE_ERROR"    & ASCII.NUL;
149    Tasking_Error_Name    : constant String := "TASKING_ERROR"    & ASCII.NUL;
150    Abort_Signal_Name     : constant String := "_ABORT_SIGNAL"    & ASCII.NUL;
151
152    Numeric_Error_Name    : constant String := "NUMERIC_ERROR"    & ASCII.NUL;
153    --  This is used only in the Ada 83 case, but it is not worth having a
154    --  separate version of s-stalib.ads for use in Ada 83 mode.
155
156    Constraint_Error_Def : aliased Exception_Data :=
157      (Not_Handled_By_Others => False,
158       Lang                  => 'A',
159       Name_Length           => Constraint_Error_Name'Length,
160       Full_Name             => To_Ptr (Constraint_Error_Name'Address),
161       HTable_Ptr            => null,
162       Import_Code           => 0);
163
164    Numeric_Error_Def : aliased Exception_Data :=
165      (Not_Handled_By_Others => False,
166       Lang                  => 'A',
167       Name_Length           => Numeric_Error_Name'Length,
168       Full_Name             => To_Ptr (Numeric_Error_Name'Address),
169       HTable_Ptr            => null,
170       Import_Code           => 0);
171
172    Program_Error_Def : aliased Exception_Data :=
173      (Not_Handled_By_Others => False,
174       Lang                  => 'A',
175       Name_Length           => Program_Error_Name'Length,
176       Full_Name             => To_Ptr (Program_Error_Name'Address),
177       HTable_Ptr            => null,
178       Import_Code           => 0);
179
180    Storage_Error_Def : aliased Exception_Data :=
181      (Not_Handled_By_Others => False,
182       Lang                  => 'A',
183       Name_Length           => Storage_Error_Name'Length,
184       Full_Name             => To_Ptr (Storage_Error_Name'Address),
185       HTable_Ptr            => null,
186       Import_Code           => 0);
187
188    Tasking_Error_Def : aliased Exception_Data :=
189      (Not_Handled_By_Others => False,
190       Lang                  => 'A',
191       Name_Length           => Tasking_Error_Name'Length,
192       Full_Name             => To_Ptr (Tasking_Error_Name'Address),
193       HTable_Ptr            => null,
194       Import_Code           => 0);
195
196    Abort_Signal_Def : aliased Exception_Data :=
197      (Not_Handled_By_Others => True,
198       Lang                  => 'A',
199       Name_Length           => Abort_Signal_Name'Length,
200       Full_Name             => To_Ptr (Abort_Signal_Name'Address),
201       HTable_Ptr            => null,
202       Import_Code           => 0);
203
204    pragma Export (C, Constraint_Error_Def, "constraint_error");
205    pragma Export (C, Numeric_Error_Def,    "numeric_error");
206    pragma Export (C, Program_Error_Def,    "program_error");
207    pragma Export (C, Storage_Error_Def,    "storage_error");
208    pragma Export (C, Tasking_Error_Def,    "tasking_error");
209    pragma Export (C, Abort_Signal_Def,     "_abort_signal");
210
211    Local_Partition_ID : Natural := 0;
212    --  This variable contains the local Partition_ID that will be used when
213    --  building exception occurrences. In distributed mode, it will be
214    --  set by each partition to the correct value during the elaboration.
215
216    type Exception_Trace_Kind is
217      (RM_Convention,
218       --  No particular trace is requested, only unhandled exceptions
219       --  in the environment task (following the RM) will be printed.
220       --  This is the default behavior.
221
222       Every_Raise,
223       --  Denotes every possible raise event, either explicit or due to
224       --  a specific language rule, within the context of a task or not.
225
226       Unhandled_Raise
227       --  Denotes the raise events corresponding to exceptions for which
228       --  there is no user defined handler.
229      );
230    --  Provide a way to denote different kinds of automatic traces related
231    --  to exceptions that can be requested.
232
233    Exception_Trace : Exception_Trace_Kind := RM_Convention;
234    pragma Atomic (Exception_Trace);
235    --  By default, follow the RM convention.
236
237    -----------------
238    -- Subprograms --
239    -----------------
240
241    procedure Abort_Undefer_Direct;
242    pragma Inline (Abort_Undefer_Direct);
243    --  A little procedure that just calls Abort_Undefer.all, for use in
244    --  clean up procedures, which only permit a simple subprogram name.
245
246    procedure Adafinal;
247    --  Performs the Ada Runtime finalization the first time it is invoked.
248    --  All subsequent calls are ignored.
249
250 end System.Standard_Library;