annotate gcc/ada/libgnat/s-stalib.ads @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
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 . S T A N D A R D _ L I B R A R Y --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
kono
parents:
diff changeset
9 -- Copyright (C) 1992-2017, Free Software Foundation, Inc. --
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 -- This package is included in all programs. It contains declarations that
kono
parents:
diff changeset
33 -- are required to be part of every Ada program. A special mechanism is
kono
parents:
diff changeset
34 -- required to ensure that these are loaded, since it may be the case in
kono
parents:
diff changeset
35 -- some programs that the only references to these required packages are
kono
parents:
diff changeset
36 -- from C code or from code generated directly by Gigi, and in both cases
kono
parents:
diff changeset
37 -- the binder is not aware of such references.
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 -- System.Standard_Library also includes data that must be present in every
kono
parents:
diff changeset
40 -- program, in particular data for all the standard exceptions, and also some
kono
parents:
diff changeset
41 -- subprograms that must be present in every program.
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 -- The binder unconditionally includes s-stalib.ali, which ensures that this
kono
parents:
diff changeset
44 -- package and the packages it references are included in all Ada programs,
kono
parents:
diff changeset
45 -- together with the included data.
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 pragma Compiler_Unit_Warning;
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 pragma Polling (Off);
kono
parents:
diff changeset
50 -- We must turn polling off for this unit, because otherwise we get
kono
parents:
diff changeset
51 -- elaboration circularities with Ada.Exceptions if polling is on.
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 with Ada.Unchecked_Conversion;
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 package System.Standard_Library is
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 -- Historical note: pragma Preelaborate was surrounded by a pair of pragma
kono
parents:
diff changeset
58 -- Warnings (Off/On) to circumvent a bootstrap issue.
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 pragma Preelaborate;
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 subtype Big_String is String (1 .. Positive'Last);
kono
parents:
diff changeset
63 pragma Suppress_Initialization (Big_String);
kono
parents:
diff changeset
64 -- Type used to obtain string access to given address. Initialization is
kono
parents:
diff changeset
65 -- suppressed, since we never want to have variables of this type, and
kono
parents:
diff changeset
66 -- we never want to attempt initialiazation of virtual variables of this
kono
parents:
diff changeset
67 -- type (e.g. when pragma Normalize_Scalars is used).
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 type Big_String_Ptr is access all Big_String;
kono
parents:
diff changeset
70 for Big_String_Ptr'Storage_Size use 0;
kono
parents:
diff changeset
71 -- We use this access type to pass a pointer to an area of storage to be
kono
parents:
diff changeset
72 -- accessed as a string. Of course when this pointer is used, it is the
kono
parents:
diff changeset
73 -- responsibility of the accessor to ensure proper bounds. The storage
kono
parents:
diff changeset
74 -- size clause ensures we do not allocate variables of this type.
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 function To_Ptr is
kono
parents:
diff changeset
77 new Ada.Unchecked_Conversion (System.Address, Big_String_Ptr);
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 -------------------------------------
kono
parents:
diff changeset
80 -- Exception Declarations and Data --
kono
parents:
diff changeset
81 -------------------------------------
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 type Raise_Action is access procedure;
kono
parents:
diff changeset
84 -- A pointer to a procedure used in the Raise_Hook field
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 type Exception_Data;
kono
parents:
diff changeset
87 type Exception_Data_Ptr is access all Exception_Data;
kono
parents:
diff changeset
88 -- An equivalent of Exception_Id that is public
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 -- The following record defines the underlying representation of exceptions
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 -- WARNING: Any changes to this may need to be reflected in the following
kono
parents:
diff changeset
93 -- locations in the compiler and runtime code:
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 -- 1. The Internal_Exception routine in s-exctab.adb
kono
parents:
diff changeset
96 -- 2. The processing in gigi that tests Not_Handled_By_Others
kono
parents:
diff changeset
97 -- 3. Expand_N_Exception_Declaration in Exp_Ch11
kono
parents:
diff changeset
98 -- 4. The construction of the exception type in Cstand
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 type Exception_Data is record
kono
parents:
diff changeset
101 Not_Handled_By_Others : Boolean;
kono
parents:
diff changeset
102 -- Normally set False, indicating that the exception is handled in the
kono
parents:
diff changeset
103 -- usual way by others (i.e. an others handler handles the exception).
kono
parents:
diff changeset
104 -- Set True to indicate that this exception is not caught by others
kono
parents:
diff changeset
105 -- handlers, but must be explicitly named in a handler. This latter
kono
parents:
diff changeset
106 -- setting is currently used by the Abort_Signal.
kono
parents:
diff changeset
107
kono
parents:
diff changeset
108 Lang : Character;
kono
parents:
diff changeset
109 -- A character indicating the language raising the exception.
kono
parents:
diff changeset
110 -- Set to "A" for exceptions defined by an Ada program.
kono
parents:
diff changeset
111 -- Set to "C" for imported C++ exceptions.
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 Name_Length : Natural;
kono
parents:
diff changeset
114 -- Length of fully expanded name of exception
kono
parents:
diff changeset
115
kono
parents:
diff changeset
116 Full_Name : System.Address;
kono
parents:
diff changeset
117 -- Fully expanded name of exception, null terminated
kono
parents:
diff changeset
118 -- You can use To_Ptr to convert this to a string.
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 HTable_Ptr : Exception_Data_Ptr;
kono
parents:
diff changeset
121 -- Hash table pointer used to link entries together in the hash table
kono
parents:
diff changeset
122 -- built (by Register_Exception in s-exctab.adb) for converting between
kono
parents:
diff changeset
123 -- identities and names.
kono
parents:
diff changeset
124
kono
parents:
diff changeset
125 Foreign_Data : Address;
kono
parents:
diff changeset
126 -- Data for imported exceptions. Not used in the Ada case. This
kono
parents:
diff changeset
127 -- represents the address of the RTTI for the C++ case.
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129 Raise_Hook : Raise_Action;
kono
parents:
diff changeset
130 -- This field can be used to place a "hook" on an exception. If the
kono
parents:
diff changeset
131 -- value is non-null, then it points to a procedure which is called
kono
parents:
diff changeset
132 -- whenever the exception is raised. This call occurs immediately,
kono
parents:
diff changeset
133 -- before any other actions taken by the raise (and in particular
kono
parents:
diff changeset
134 -- before any unwinding of the stack occurs).
kono
parents:
diff changeset
135 end record;
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137 -- Definitions for standard predefined exceptions defined in Standard,
kono
parents:
diff changeset
138
kono
parents:
diff changeset
139 -- Why are the NULs necessary here, seems like they should not be
kono
parents:
diff changeset
140 -- required, since Gigi is supposed to add a Nul to each name ???
kono
parents:
diff changeset
141
kono
parents:
diff changeset
142 Constraint_Error_Name : constant String := "CONSTRAINT_ERROR" & ASCII.NUL;
kono
parents:
diff changeset
143 Program_Error_Name : constant String := "PROGRAM_ERROR" & ASCII.NUL;
kono
parents:
diff changeset
144 Storage_Error_Name : constant String := "STORAGE_ERROR" & ASCII.NUL;
kono
parents:
diff changeset
145 Tasking_Error_Name : constant String := "TASKING_ERROR" & ASCII.NUL;
kono
parents:
diff changeset
146 Abort_Signal_Name : constant String := "_ABORT_SIGNAL" & ASCII.NUL;
kono
parents:
diff changeset
147
kono
parents:
diff changeset
148 Numeric_Error_Name : constant String := "NUMERIC_ERROR" & ASCII.NUL;
kono
parents:
diff changeset
149 -- This is used only in the Ada 83 case, but it is not worth having a
kono
parents:
diff changeset
150 -- separate version of s-stalib.ads for use in Ada 83 mode.
kono
parents:
diff changeset
151
kono
parents:
diff changeset
152 Constraint_Error_Def : aliased Exception_Data :=
kono
parents:
diff changeset
153 (Not_Handled_By_Others => False,
kono
parents:
diff changeset
154 Lang => 'A',
kono
parents:
diff changeset
155 Name_Length => Constraint_Error_Name'Length,
kono
parents:
diff changeset
156 Full_Name => Constraint_Error_Name'Address,
kono
parents:
diff changeset
157 HTable_Ptr => null,
kono
parents:
diff changeset
158 Foreign_Data => Null_Address,
kono
parents:
diff changeset
159 Raise_Hook => null);
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161 Numeric_Error_Def : aliased Exception_Data :=
kono
parents:
diff changeset
162 (Not_Handled_By_Others => False,
kono
parents:
diff changeset
163 Lang => 'A',
kono
parents:
diff changeset
164 Name_Length => Numeric_Error_Name'Length,
kono
parents:
diff changeset
165 Full_Name => Numeric_Error_Name'Address,
kono
parents:
diff changeset
166 HTable_Ptr => null,
kono
parents:
diff changeset
167 Foreign_Data => Null_Address,
kono
parents:
diff changeset
168 Raise_Hook => null);
kono
parents:
diff changeset
169
kono
parents:
diff changeset
170 Program_Error_Def : aliased Exception_Data :=
kono
parents:
diff changeset
171 (Not_Handled_By_Others => False,
kono
parents:
diff changeset
172 Lang => 'A',
kono
parents:
diff changeset
173 Name_Length => Program_Error_Name'Length,
kono
parents:
diff changeset
174 Full_Name => Program_Error_Name'Address,
kono
parents:
diff changeset
175 HTable_Ptr => null,
kono
parents:
diff changeset
176 Foreign_Data => Null_Address,
kono
parents:
diff changeset
177 Raise_Hook => null);
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179 Storage_Error_Def : aliased Exception_Data :=
kono
parents:
diff changeset
180 (Not_Handled_By_Others => False,
kono
parents:
diff changeset
181 Lang => 'A',
kono
parents:
diff changeset
182 Name_Length => Storage_Error_Name'Length,
kono
parents:
diff changeset
183 Full_Name => Storage_Error_Name'Address,
kono
parents:
diff changeset
184 HTable_Ptr => null,
kono
parents:
diff changeset
185 Foreign_Data => Null_Address,
kono
parents:
diff changeset
186 Raise_Hook => null);
kono
parents:
diff changeset
187
kono
parents:
diff changeset
188 Tasking_Error_Def : aliased Exception_Data :=
kono
parents:
diff changeset
189 (Not_Handled_By_Others => False,
kono
parents:
diff changeset
190 Lang => 'A',
kono
parents:
diff changeset
191 Name_Length => Tasking_Error_Name'Length,
kono
parents:
diff changeset
192 Full_Name => Tasking_Error_Name'Address,
kono
parents:
diff changeset
193 HTable_Ptr => null,
kono
parents:
diff changeset
194 Foreign_Data => Null_Address,
kono
parents:
diff changeset
195 Raise_Hook => null);
kono
parents:
diff changeset
196
kono
parents:
diff changeset
197 Abort_Signal_Def : aliased Exception_Data :=
kono
parents:
diff changeset
198 (Not_Handled_By_Others => True,
kono
parents:
diff changeset
199 Lang => 'A',
kono
parents:
diff changeset
200 Name_Length => Abort_Signal_Name'Length,
kono
parents:
diff changeset
201 Full_Name => Abort_Signal_Name'Address,
kono
parents:
diff changeset
202 HTable_Ptr => null,
kono
parents:
diff changeset
203 Foreign_Data => Null_Address,
kono
parents:
diff changeset
204 Raise_Hook => null);
kono
parents:
diff changeset
205
kono
parents:
diff changeset
206 pragma Export (C, Constraint_Error_Def, "constraint_error");
kono
parents:
diff changeset
207 pragma Export (C, Numeric_Error_Def, "numeric_error");
kono
parents:
diff changeset
208 pragma Export (C, Program_Error_Def, "program_error");
kono
parents:
diff changeset
209 pragma Export (C, Storage_Error_Def, "storage_error");
kono
parents:
diff changeset
210 pragma Export (C, Tasking_Error_Def, "tasking_error");
kono
parents:
diff changeset
211 pragma Export (C, Abort_Signal_Def, "_abort_signal");
kono
parents:
diff changeset
212
kono
parents:
diff changeset
213 Local_Partition_ID : Natural := 0;
kono
parents:
diff changeset
214 -- This variable contains the local Partition_ID that will be used when
kono
parents:
diff changeset
215 -- building exception occurrences. In distributed mode, it will be
kono
parents:
diff changeset
216 -- set by each partition to the correct value during the elaboration.
kono
parents:
diff changeset
217
kono
parents:
diff changeset
218 type Exception_Trace_Kind is
kono
parents:
diff changeset
219 (RM_Convention,
kono
parents:
diff changeset
220 -- No particular trace is requested, only unhandled exceptions
kono
parents:
diff changeset
221 -- in the environment task (following the RM) will be printed.
kono
parents:
diff changeset
222 -- This is the default behavior.
kono
parents:
diff changeset
223
kono
parents:
diff changeset
224 Every_Raise,
kono
parents:
diff changeset
225 -- Denotes the initial raise event for any exception occurrence, either
kono
parents:
diff changeset
226 -- explicit or due to a specific language rule, within the context of a
kono
parents:
diff changeset
227 -- task or not.
kono
parents:
diff changeset
228
kono
parents:
diff changeset
229 Unhandled_Raise,
kono
parents:
diff changeset
230 -- Denotes the raise events corresponding to exceptions for which there
kono
parents:
diff changeset
231 -- is no user defined handler. This includes unhandled exceptions in
kono
parents:
diff changeset
232 -- task bodies.
kono
parents:
diff changeset
233
kono
parents:
diff changeset
234 Unhandled_Raise_In_Main
kono
parents:
diff changeset
235 -- Same as Unhandled_Raise, except exceptions in task bodies are not
kono
parents:
diff changeset
236 -- included. Same as RM_Convention, except (1) the message is printed as
kono
parents:
diff changeset
237 -- soon as the environment task completes due to an unhandled exception
kono
parents:
diff changeset
238 -- (before awaiting the termination of dependent tasks, and before
kono
parents:
diff changeset
239 -- library-level finalization), and (2) a symbolic traceback is given
kono
parents:
diff changeset
240 -- if possible. This is the default behavior if the binder switch -E is
kono
parents:
diff changeset
241 -- used.
kono
parents:
diff changeset
242 );
kono
parents:
diff changeset
243 -- Provide a way to denote different kinds of automatic traces related
kono
parents:
diff changeset
244 -- to exceptions that can be requested.
kono
parents:
diff changeset
245
kono
parents:
diff changeset
246 Exception_Trace : Exception_Trace_Kind := RM_Convention;
kono
parents:
diff changeset
247 pragma Atomic (Exception_Trace);
kono
parents:
diff changeset
248 -- By default, follow the RM convention
kono
parents:
diff changeset
249
kono
parents:
diff changeset
250 -----------------
kono
parents:
diff changeset
251 -- Subprograms --
kono
parents:
diff changeset
252 -----------------
kono
parents:
diff changeset
253
kono
parents:
diff changeset
254 procedure Abort_Undefer_Direct;
kono
parents:
diff changeset
255 pragma Inline (Abort_Undefer_Direct);
kono
parents:
diff changeset
256 -- A little procedure that just calls Abort_Undefer.all, for use in
kono
parents:
diff changeset
257 -- clean up procedures, which only permit a simple subprogram name.
kono
parents:
diff changeset
258
kono
parents:
diff changeset
259 procedure Adafinal;
kono
parents:
diff changeset
260 -- Performs the Ada Runtime finalization the first time it is invoked.
kono
parents:
diff changeset
261 -- All subsequent calls are ignored.
kono
parents:
diff changeset
262
kono
parents:
diff changeset
263 end System.Standard_Library;