File : s-stalib-raven.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 -- Copyright (C) 2003-2014, 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 -- --
19 -- --
20 -- --
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 -- This package is included in all programs. It contains declarations that
33 -- are required to be part of every Ada program. A special mechanism is
34 -- required to ensure that these are loaded, since it may be the case in
35 -- some programs that the only references to these required packages are
36 -- from C code or from code generated directly by Gigi, and in both cases
37 -- the binder is not aware of such references.
38
39 -- System.Standard_Library also includes data that must be present in every
40 -- program, in particular data for all the standard exceptions, and also some
41 -- subprograms that must be present in every program.
42
43 -- The binder unconditionally includes s-stalib.ali, which ensures that this
44 -- package and the packages it references are included in all Ada programs,
45 -- together with the included data.
46
47 pragma Polling (Off);
48 -- We must turn polling off for this unit, because otherwise we get
49 -- elaboration circularities with Ada.Exceptions if polling is on.
50
51 with Unchecked_Conversion;
52
53 package System.Standard_Library is
54 pragma Preelaborate;
55
56 subtype Big_String is String (1 .. Positive'Last);
57 pragma Suppress_Initialization (Big_String);
58 -- Type used to obtain string access to given address. Initialization is
59 -- suppressed, since we never want to have variables of this type, and
60 -- we never want to attempt initialiazation of virtual variables of this
61 -- type (e.g. when pragma Normalize_Scalars is used).
62
63 type Big_String_Ptr is access all Big_String;
64 for Big_String_Ptr'Storage_Size use 0;
65 -- We use this access type to pass a pointer to an area of storage to be
66 -- accessed as a string. Of course when this pointer is used, it is the
67 -- responsibility of the accessor to ensure proper bounds. The storage
68 -- size clause ensures we do not allocate variables of this type.
69
70 function To_Ptr is
71 new Unchecked_Conversion (System.Address, Big_String_Ptr);
72
73 -------------------------------------
74 -- Exception Declarations and Data --
75 -------------------------------------
76
77 type Raise_Action is access procedure;
78 -- A pointer to a procedure used in the Raise_Hook field
79
80 type Exception_Data;
81 type Exception_Data_Ptr is access all Exception_Data;
82 -- An equivalent of Exception_Id that is public
83
84 -- The following record defines the underlying representation of exceptions
85
86 -- WARNING: Any changes to this may need to be reflectd in the following
87 -- locations in the compiler and runtime code:
88
89 -- 1. The Internal_Exception routine in s-exctab.adb
90 -- 2. The processing in gigi that tests Not_Handled_By_Others
91 -- 3. Expand_N_Exception_Declaration in Exp_Ch11
92 -- 4. The construction of the exception type in Cstand
93
94 type Exception_Data is record
95 Not_Handled_By_Others : Boolean;
96 -- Normally set False, indicating that the exception is handled in the
97 -- usual way by others (i.e. an others handler handles the exception).
98 -- Set True to indicate that this exception is not caught by others
99 -- handlers, but must be explicitly named in a handler. This latter
100 -- setting is currently used by the Abort_Signal.
101
102 Lang : Character;
103 -- A character indicating the language raising the exception.
104 -- Set to "A" for exceptions defined by an Ada program.
105 -- Set to "C" for imported C++ exceptions.
106
107 Name_Length : Natural;
108 -- Length of fully expanded name of exception
109
110 Full_Name : System.Address;
111 -- Fully expanded name of exception, null terminated
112 -- You can use To_Ptr to convert this to a string.
113
114 HTable_Ptr : Exception_Data_Ptr;
115 -- Hash table pointer used to link entries together in the hash table
116 -- built (by Register_Exception in s-exctab.adb) for converting between
117 -- identities and names.
118
119 Foreign_Data : Address;
120 -- Data for imported exceptions. Not used in the Ada case. This
121 -- represents the address of the RTTI for the C++ case.
122
123 Raise_Hook : Raise_Action;
124 -- This field can be used to place a "hook" on an exception. If the
125 -- value is non-null, then it points to a procedure which is called
126 -- whenever the exception is raised. This call occurs immediately,
127 -- before any other actions taken by the raise (and in particular
128 -- before any unwinding of the stack occurs).
129 end record;
130
131 -- Definitions for standard predefined exceptions defined in Standard,
132
133 Constraint_Error_Name : constant String := "CONSTRAINT_ERROR" & ASCII.NUL;
134 Program_Error_Name : constant String := "PROGRAM_ERROR" & ASCII.NUL;
135 Storage_Error_Name : constant String := "STORAGE_ERROR" & ASCII.NUL;
136 Tasking_Error_Name : constant String := "TASKING_ERROR" & ASCII.NUL;
137
138 Numeric_Error_Name : constant String := "NUMERIC_ERROR" & ASCII.NUL;
139 -- This is used only in the Ada 83 case, but it is not worth having a
140 -- separate version of s-stalib.ads for use in Ada 83 mode.
141
142 Constraint_Error_Def : aliased Exception_Data :=
143 (Not_Handled_By_Others => False,
144 Lang => 'A',
145 Name_Length => Constraint_Error_Name'Length,
146 Full_Name => Constraint_Error_Name'Address,
147 HTable_Ptr => null,
148 Foreign_Data => Null_Address,
149 Raise_Hook => null);
150
151 Numeric_Error_Def : aliased Exception_Data :=
152 (Not_Handled_By_Others => False,
153 Lang => 'A',
154 Name_Length => Numeric_Error_Name'Length,
155 Full_Name => Numeric_Error_Name'Address,
156 HTable_Ptr => null,
157 Foreign_Data => Null_Address,
158 Raise_Hook => null);
159
160 Program_Error_Def : aliased Exception_Data :=
161 (Not_Handled_By_Others => False,
162 Lang => 'A',
163 Name_Length => Program_Error_Name'Length,
164 Full_Name => Program_Error_Name'Address,
165 HTable_Ptr => null,
166 Foreign_Data => Null_Address,
167 Raise_Hook => null);
168
169 Storage_Error_Def : aliased Exception_Data :=
170 (Not_Handled_By_Others => False,
171 Lang => 'A',
172 Name_Length => Storage_Error_Name'Length,
173 Full_Name => Storage_Error_Name'Address,
174 HTable_Ptr => null,
175 Foreign_Data => Null_Address,
176 Raise_Hook => null);
177
178 Tasking_Error_Def : aliased Exception_Data :=
179 (Not_Handled_By_Others => False,
180 Lang => 'A',
181 Name_Length => Tasking_Error_Name'Length,
182 Full_Name => Tasking_Error_Name'Address,
183 HTable_Ptr => null,
184 Foreign_Data => Null_Address,
185 Raise_Hook => null);
186
187 pragma Export (C, Constraint_Error_Def, "constraint_error");
188 pragma Export (C, Numeric_Error_Def, "numeric_error");
189 pragma Export (C, Program_Error_Def, "program_error");
190 pragma Export (C, Storage_Error_Def, "storage_error");
191 pragma Export (C, Tasking_Error_Def, "tasking_error");
192
193 -----------------
194 -- Subprograms --
195 -----------------
196
197 procedure Adafinal;
198 -- Performs the Ada Runtime finalization the first time it is invoked.
199 -- All subsequent calls are ignored.
200
201 end System.Standard_Library;