Update concepts branch to revision 131834
[official-gcc.git] / gcc / ada / s-vmexta.adb
blob8f225c4559fa426d28c30fba096c2868b221b47f
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- S Y S T E M . V M S _ E X C E P T I O N _ T A B L E --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1997-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, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, 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 ------------------------------------------------------------------------------
34 -- This is an Alpha/VMS package.
36 with System.HTable;
37 pragma Elaborate_All (System.HTable);
39 package body System.VMS_Exception_Table is
41 use type SSL.Exception_Code;
43 type HTable_Headers is range 1 .. 37;
45 type Exception_Code_Data;
46 type Exception_Code_Data_Ptr is access all Exception_Code_Data;
48 -- The following record maps an imported VMS condition to an
49 -- Ada exception.
51 type Exception_Code_Data is record
52 Code : SSL.Exception_Code;
53 Except : SSL.Exception_Data_Ptr;
54 HTable_Ptr : Exception_Code_Data_Ptr;
55 end record;
57 procedure Set_HT_Link
58 (T : Exception_Code_Data_Ptr;
59 Next : Exception_Code_Data_Ptr);
61 function Get_HT_Link (T : Exception_Code_Data_Ptr)
62 return Exception_Code_Data_Ptr;
64 function Hash (F : SSL.Exception_Code) return HTable_Headers;
65 function Get_Key (T : Exception_Code_Data_Ptr) return SSL.Exception_Code;
67 package Exception_Code_HTable is new System.HTable.Static_HTable (
68 Header_Num => HTable_Headers,
69 Element => Exception_Code_Data,
70 Elmt_Ptr => Exception_Code_Data_Ptr,
71 Null_Ptr => null,
72 Set_Next => Set_HT_Link,
73 Next => Get_HT_Link,
74 Key => SSL.Exception_Code,
75 Get_Key => Get_Key,
76 Hash => Hash,
77 Equal => "=");
79 ------------------
80 -- Base_Code_In --
81 ------------------
83 function Base_Code_In
84 (Code : SSL.Exception_Code) return SSL.Exception_Code
86 begin
87 return Code and not 2#0111#;
88 end Base_Code_In;
90 ---------------------
91 -- Coded_Exception --
92 ---------------------
94 function Coded_Exception
95 (X : SSL.Exception_Code) return SSL.Exception_Data_Ptr
97 Res : Exception_Code_Data_Ptr;
99 begin
100 Res := Exception_Code_HTable.Get (X);
102 if Res /= null then
103 return Res.Except;
104 else
105 return null;
106 end if;
108 end Coded_Exception;
110 -----------------
111 -- Get_HT_Link --
112 -----------------
114 function Get_HT_Link
115 (T : Exception_Code_Data_Ptr) return Exception_Code_Data_Ptr
117 begin
118 return T.HTable_Ptr;
119 end Get_HT_Link;
121 -------------
122 -- Get_Key --
123 -------------
125 function Get_Key (T : Exception_Code_Data_Ptr)
126 return SSL.Exception_Code
128 begin
129 return T.Code;
130 end Get_Key;
132 ----------
133 -- Hash --
134 ----------
136 function Hash
137 (F : SSL.Exception_Code) return HTable_Headers
139 Headers_Magnitude : constant SSL.Exception_Code :=
140 SSL.Exception_Code (HTable_Headers'Last - HTable_Headers'First + 1);
142 begin
143 return HTable_Headers (F mod Headers_Magnitude + 1);
144 end Hash;
146 ----------------------------
147 -- Register_VMS_Exception --
148 ----------------------------
150 procedure Register_VMS_Exception
151 (Code : SSL.Exception_Code;
152 E : SSL.Exception_Data_Ptr)
154 -- We bind the exception data with the base code found in the
155 -- input value, that is with the severity bits masked off.
157 Excode : constant SSL.Exception_Code := Base_Code_In (Code);
159 begin
160 -- The exception data registered here is mostly filled prior to this
161 -- call and by __gnat_error_handler when the exception is raised. We
162 -- still need to fill a couple of components for exceptions that will
163 -- be used as propagation filters (exception data pointer registered
164 -- as choices in the unwind tables): in some import/export cases, the
165 -- exception pointers for the choice and the propagated occurrence may
166 -- indeed be different for a single import code, and the personality
167 -- routine attempts to match the import codes in this case.
169 E.Lang := 'V';
170 E.Import_Code := Excode;
172 if Exception_Code_HTable.Get (Excode) = null then
173 Exception_Code_HTable.Set (new Exception_Code_Data'(Excode, E, null));
174 end if;
175 end Register_VMS_Exception;
177 -----------------
178 -- Set_HT_Link --
179 -----------------
181 procedure Set_HT_Link
182 (T : Exception_Code_Data_Ptr;
183 Next : Exception_Code_Data_Ptr)
185 begin
186 T.HTable_Ptr := Next;
187 end Set_HT_Link;
189 end System.VMS_Exception_Table;