OSDN Git Service

* config.gcc (powerpc-*-darwin*): Set config_gtfiles.
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-vmexta.adb
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 --                                                                          --
10 --          Copyright (C) 1997-2001, Free Software Foundation, Inc.         --
11 --                                                                          --
12 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
13 -- terms of the  GNU General Public License as published  by the Free Soft- --
14 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
15 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
18 -- for  more details.  You should have  received  a copy of the GNU General --
19 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
20 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
21 -- MA 02111-1307, USA.                                                      --
22 --                                                                          --
23 -- As a special exception,  if other files  instantiate  generics from this --
24 -- unit, or you link  this unit with other files  to produce an executable, --
25 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
26 -- covered  by the  GNU  General  Public  License.  This exception does not --
27 -- however invalidate  any other reasons why  the executable file  might be --
28 -- covered by the  GNU Public License.                                      --
29 --                                                                          --
30 -- GNAT was originally developed  by the GNAT team at  New York University. --
31 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
32 --                                                                          --
33 ------------------------------------------------------------------------------
34
35 --  This is an Alpha/VMS package.
36
37 with GNAT.HTable;
38 pragma Elaborate_All (GNAT.HTable);
39
40 package body System.VMS_Exception_Table is
41
42    use System.Standard_Library;
43
44    type HTable_Headers is range 1 .. 37;
45
46    type Exception_Code_Data;
47    type Exception_Code_Data_Ptr is access all Exception_Code_Data;
48
49    --  The following record maps an imported VMS condition to an
50    --  Ada exception.
51
52    type Exception_Code_Data is record
53       Code       : Natural;
54       Except     : Exception_Data_Ptr;
55       HTable_Ptr : Exception_Code_Data_Ptr;
56    end record;
57
58    procedure Set_HT_Link
59      (T    : Exception_Code_Data_Ptr;
60       Next : Exception_Code_Data_Ptr);
61
62    function Get_HT_Link (T : Exception_Code_Data_Ptr)
63      return Exception_Code_Data_Ptr;
64
65    function Hash (F : Natural) return HTable_Headers;
66    function Get_Key (T : Exception_Code_Data_Ptr) return Natural;
67
68    package Exception_Code_HTable is new GNAT.HTable.Static_HTable (
69      Header_Num => HTable_Headers,
70      Element    => Exception_Code_Data,
71      Elmt_Ptr   => Exception_Code_Data_Ptr,
72      Null_Ptr   => null,
73      Set_Next   => Set_HT_Link,
74      Next       => Get_HT_Link,
75      Key        => Natural,
76      Get_Key    => Get_Key,
77      Hash       => Hash,
78      Equal      => "=");
79
80    ---------------------
81    -- Coded_Exception --
82    ---------------------
83
84    function Coded_Exception (X : Natural) return Exception_Data_Ptr is
85       Res : Exception_Code_Data_Ptr;
86
87    begin
88       Res := Exception_Code_HTable.Get (X);
89
90       if Res /= null  then
91          return Res.Except;
92       else
93          return null;
94       end if;
95
96    end Coded_Exception;
97
98    -----------------
99    -- Get_HT_Link --
100    -----------------
101
102    function  Get_HT_Link (T : Exception_Code_Data_Ptr)
103      return Exception_Code_Data_Ptr is
104    begin
105       return T.HTable_Ptr;
106    end Get_HT_Link;
107
108    -------------
109    -- Get_Key --
110    -------------
111
112    function Get_Key (T : Exception_Code_Data_Ptr) return Natural is
113    begin
114       return T.Code;
115    end Get_Key;
116
117    ----------
118    -- Hash --
119    ----------
120
121    function Hash (F : Natural) return HTable_Headers is
122    begin
123       return HTable_Headers
124         (F mod Natural (HTable_Headers'Last - HTable_Headers'First + 1) + 1);
125    end Hash;
126
127    ----------------------------
128    -- Register_VMS_Exception --
129    ----------------------------
130
131    procedure Register_VMS_Exception (Code : Integer) is
132       --  Mask off lower 3 bits which are the severity
133
134       Excode : Integer := (Code / 8) * 8;
135    begin
136
137       --  This allocates an empty exception that gets filled in by
138       --  __gnat_error_handler when the exception is raised. Allocating
139       --  it here prevents having to allocate it each time the exception
140       --  is raised.
141
142       if Exception_Code_HTable.Get (Excode) = null then
143          Exception_Code_HTable.Set
144            (new Exception_Code_Data'
145              (Excode,
146               new Exception_Data'(False, 'V', 0, null, null, 0),
147               null));
148       end if;
149    end Register_VMS_Exception;
150
151    -----------------
152    -- Set_HT_Link --
153    -----------------
154
155    procedure Set_HT_Link
156      (T    : Exception_Code_Data_Ptr;
157       Next : Exception_Code_Data_Ptr)
158    is
159    begin
160       T.HTable_Ptr := Next;
161    end Set_HT_Link;
162
163 end System.VMS_Exception_Table;