aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/ada/s-excmac-arm.ads
blob: 88759b8e228117aacea22e6bf45ac4b722bc3cea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
------------------------------------------------------------------------------
--                                                                          --
--                         GNAT COMPILER COMPONENTS                         --
--                                                                          --
--              S Y S T E M . E X C E P T I O N S . M A C H I N E           --
--                                                                          --
--                                 S p e c                                  --
--                                                                          --
--            Copyright (C) 2013, Free Software Foundation, Inc.            --
--                                                                          --
-- GNAT is free software;  you can  redistribute it  and/or modify it under --
-- terms of the  GNU General Public License as published  by the Free Soft- --
-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
--                                                                          --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception,   --
-- version 3.1, as published by the Free Software Foundation.               --
--                                                                          --
-- You should have received a copy of the GNU General Public License and    --
-- a copy of the GCC Runtime Library Exception along with this program;     --
-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
-- <http://www.gnu.org/licenses/>.                                          --
--                                                                          --
-- GNAT was originally developed  by the GNAT team at  New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc.      --
--                                                                          --
------------------------------------------------------------------------------

--  Declaration of the machine exception and some associated facilities. The
--  machine exception is the object that is propagated by low level routines
--  and that contains the Ada exception occurrence.

--  This is the version using the ARM EHABI mechanism

with Ada.Unchecked_Conversion;
with Ada.Exceptions;

package System.Exceptions.Machine is
   pragma Preelaborate;

   ------------------------------------------------
   -- Entities to interface with the GCC runtime --
   ------------------------------------------------

   --  Return codes from GCC runtime functions used to propagate an exception

   type Unwind_Reason_Code is
     (URC_OK,
      URC_FOREIGN_EXCEPTION_CAUGHT,
      URC_Unused2,
      URC_Unused3,
      URC_Unused4,
      URC_Unused5,
      URC_HANDLER_FOUND,
      URC_INSTALL_CONTEXT,
      URC_CONTINUE_UNWIND,
      URC_FAILURE);

   pragma Unreferenced
     (URC_OK,
      URC_FOREIGN_EXCEPTION_CAUGHT,
      URC_Unused2,
      URC_Unused3,
      URC_Unused4,
      URC_Unused5,
      URC_HANDLER_FOUND,
      URC_INSTALL_CONTEXT,
      URC_CONTINUE_UNWIND,
      URC_FAILURE);

   pragma Convention (C, Unwind_Reason_Code);
   subtype Unwind_Action is Unwind_Reason_Code;
   --  Phase identifiers

   type uint32_t is mod 2**32;
   pragma Convention (C, uint32_t);

   type uint32_t_array is array (Natural range <>) of uint32_t;
   pragma Convention (C, uint32_t_array);

   type Unwind_State is new uint32_t;
   pragma Convention (C, Unwind_State);

   US_VIRTUAL_UNWIND_FRAME  : constant Unwind_State := 0;
   US_UNWIND_FRAME_STARTING : constant Unwind_State := 1;
   US_UNWIND_FRAME_RESUME   : constant Unwind_State := 2;

   pragma Unreferenced
     (US_VIRTUAL_UNWIND_FRAME,
      US_UNWIND_FRAME_STARTING,
      US_UNWIND_FRAME_RESUME);

   --  Mandatory common header for any exception object handled by the
   --  GCC unwinding runtime.

   type Exception_Class is array (0 .. 7) of Character;

   GNAT_Exception_Class : constant Exception_Class := "GNU-Ada" & ASCII.NUL;
   --  "GNU-Ada\0"

   type Unwinder_Cache_Type is record
      Reserved1 : uint32_t;
      Reserved2 : uint32_t;
      Reserved3 : uint32_t;
      Reserved4 : uint32_t;
      Reserved5 : uint32_t;
   end record;

   type Barrier_Cache_Type is record
      Sp         : uint32_t;
      Bitpattern : uint32_t_array (0 .. 4);
   end record;

   type Cleanup_Cache_Type is record
     Bitpattern : uint32_t_array (0 .. 3);
   end record;

   type Pr_Cache_Type is record
      Fnstart    : uint32_t;
      Ehtp       : System.Address;
      Additional : uint32_t;
      Reserved1  : uint32_t;
   end record;

   type Unwind_Control_Block is record
      Class   : Exception_Class;
      Cleanup : System.Address;

      --  Caches
      Unwinder_Cache : Unwinder_Cache_Type;
      Barrier_Cache  : Barrier_Cache_Type;
      Cleanup_Cache  : Cleanup_Cache_Type;
      Pr_Cache       : Pr_Cache_Type;
   end record;
   pragma Convention (C, Unwind_Control_Block);
   for Unwind_Control_Block'Alignment use 8;
   --  Map the GCC struct used for exception handling

   type Unwind_Control_Block_Access is access all Unwind_Control_Block;
   subtype GCC_Exception_Access is Unwind_Control_Block_Access;
   --  Pointer to a UCB

   procedure Unwind_DeleteException
     (Ucbp : not null Unwind_Control_Block_Access);
   pragma Import (C, Unwind_DeleteException, "_Unwind_DeleteException");
   --  Procedure to free any GCC exception

   --------------------------------------------------------------
   -- GNAT Specific Entities To Deal With The GCC EH Circuitry --
   --------------------------------------------------------------

   --  A GNAT exception object to be dealt with by the personality routine
   --  called by the GCC unwinding runtime.

   type GNAT_GCC_Exception is record
      Header : Unwind_Control_Block;
      --  ABI Exception header first

      Occurrence : aliased Ada.Exceptions.Exception_Occurrence;
      --  The Ada occurrence
   end record;

   pragma Convention (C, GNAT_GCC_Exception);

   type GNAT_GCC_Exception_Access is access all GNAT_GCC_Exception;

   function To_GCC_Exception is new
     Ada.Unchecked_Conversion (System.Address, GCC_Exception_Access);

   function To_GNAT_GCC_Exception is new
     Ada.Unchecked_Conversion
     (GCC_Exception_Access, GNAT_GCC_Exception_Access);

   function New_Occurrence return GNAT_GCC_Exception_Access is
      (new GNAT_GCC_Exception'
         (Header     => (Class   => GNAT_Exception_Class,
                         Unwinder_Cache => (Reserved1 => 0,
                                            others => <>),
                         others => <>),
          Occurrence => <>));
   --  Allocate and initialize a machine occurrence

end System.Exceptions.Machine;