annotate gcc/ada/libgnat/s-auxdec.ads @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
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 . A U X _ D E C --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 1996-2018, Free Software Foundation, Inc. --
111
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 contains definitions that are designed to be compatible
kono
parents:
diff changeset
33 -- with the extra definitions in package System for DEC Ada implementations.
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 -- These definitions can be used directly by withing this package, or merged
kono
parents:
diff changeset
36 -- with System using pragma Extend_System (Aux_DEC)
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 with Ada.Unchecked_Conversion;
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 package System.Aux_DEC is
kono
parents:
diff changeset
41 pragma Preelaborate;
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 subtype Short_Address is Address;
kono
parents:
diff changeset
44 -- For compatibility with systems having short and long addresses
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 type Integer_8 is range -2 ** (8 - 1) .. +2 ** (8 - 1) - 1;
kono
parents:
diff changeset
47 for Integer_8'Size use 8;
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 type Integer_16 is range -2 ** (16 - 1) .. +2 ** (16 - 1) - 1;
kono
parents:
diff changeset
50 for Integer_16'Size use 16;
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 type Integer_32 is range -2 ** (32 - 1) .. +2 ** (32 - 1) - 1;
kono
parents:
diff changeset
53 for Integer_32'Size use 32;
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 type Integer_64 is range -2 ** (64 - 1) .. +2 ** (64 - 1) - 1;
kono
parents:
diff changeset
56 for Integer_64'Size use 64;
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 type Integer_8_Array is array (Integer range <>) of Integer_8;
kono
parents:
diff changeset
59 type Integer_16_Array is array (Integer range <>) of Integer_16;
kono
parents:
diff changeset
60 type Integer_32_Array is array (Integer range <>) of Integer_32;
kono
parents:
diff changeset
61 type Integer_64_Array is array (Integer range <>) of Integer_64;
kono
parents:
diff changeset
62 -- These array types are not in all versions of DEC System, and in fact it
kono
parents:
diff changeset
63 -- is not quite clear why they are in some and not others, but since they
kono
parents:
diff changeset
64 -- definitely appear in some versions, we include them unconditionally.
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 type Largest_Integer is range Min_Int .. Max_Int;
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 type AST_Handler is private;
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 No_AST_Handler : constant AST_Handler;
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 type Type_Class is
kono
parents:
diff changeset
73 (Type_Class_Enumeration,
kono
parents:
diff changeset
74 Type_Class_Integer,
kono
parents:
diff changeset
75 Type_Class_Fixed_Point,
kono
parents:
diff changeset
76 Type_Class_Floating_Point,
kono
parents:
diff changeset
77 Type_Class_Array,
kono
parents:
diff changeset
78 Type_Class_Record,
kono
parents:
diff changeset
79 Type_Class_Access,
kono
parents:
diff changeset
80 Type_Class_Task, -- also in Ada 95 protected
kono
parents:
diff changeset
81 Type_Class_Address);
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 function "not" (Left : Largest_Integer) return Largest_Integer;
kono
parents:
diff changeset
84 function "and" (Left, Right : Largest_Integer) return Largest_Integer;
kono
parents:
diff changeset
85 function "or" (Left, Right : Largest_Integer) return Largest_Integer;
kono
parents:
diff changeset
86 function "xor" (Left, Right : Largest_Integer) return Largest_Integer;
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 Address_Zero : constant Address;
kono
parents:
diff changeset
89 No_Addr : constant Address;
kono
parents:
diff changeset
90 Address_Size : constant := Standard'Address_Size;
kono
parents:
diff changeset
91 Short_Address_Size : constant := Standard'Address_Size;
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 function "+" (Left : Address; Right : Integer) return Address;
kono
parents:
diff changeset
94 function "+" (Left : Integer; Right : Address) return Address;
kono
parents:
diff changeset
95 function "-" (Left : Address; Right : Address) return Integer;
kono
parents:
diff changeset
96 function "-" (Left : Address; Right : Integer) return Address;
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 generic
kono
parents:
diff changeset
99 type Target is private;
kono
parents:
diff changeset
100 function Fetch_From_Address (A : Address) return Target;
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 generic
kono
parents:
diff changeset
103 type Target is private;
kono
parents:
diff changeset
104 procedure Assign_To_Address (A : Address; T : Target);
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 -- Floating point type declarations for VAX floating point data types
kono
parents:
diff changeset
107
kono
parents:
diff changeset
108 type F_Float is digits 6;
kono
parents:
diff changeset
109 type D_Float is digits 9;
kono
parents:
diff changeset
110 type G_Float is digits 15;
kono
parents:
diff changeset
111 -- We provide the type names, but these will be IEEE format, not VAX format
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 -- Floating point type declarations for IEEE floating point data types
kono
parents:
diff changeset
114
kono
parents:
diff changeset
115 type IEEE_Single_Float is digits 6;
kono
parents:
diff changeset
116 type IEEE_Double_Float is digits 15;
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 Non_Ada_Error : exception;
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 -- Hardware-oriented types and functions
kono
parents:
diff changeset
121
kono
parents:
diff changeset
122 type Bit_Array is array (Integer range <>) of Boolean;
kono
parents:
diff changeset
123 pragma Pack (Bit_Array);
kono
parents:
diff changeset
124
kono
parents:
diff changeset
125 subtype Bit_Array_8 is Bit_Array (0 .. 7);
kono
parents:
diff changeset
126 subtype Bit_Array_16 is Bit_Array (0 .. 15);
kono
parents:
diff changeset
127 subtype Bit_Array_32 is Bit_Array (0 .. 31);
kono
parents:
diff changeset
128 subtype Bit_Array_64 is Bit_Array (0 .. 63);
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 type Unsigned_Byte is range 0 .. 255;
kono
parents:
diff changeset
131 for Unsigned_Byte'Size use 8;
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133 function "not" (Left : Unsigned_Byte) return Unsigned_Byte;
kono
parents:
diff changeset
134 function "and" (Left, Right : Unsigned_Byte) return Unsigned_Byte;
kono
parents:
diff changeset
135 function "or" (Left, Right : Unsigned_Byte) return Unsigned_Byte;
kono
parents:
diff changeset
136 function "xor" (Left, Right : Unsigned_Byte) return Unsigned_Byte;
kono
parents:
diff changeset
137
kono
parents:
diff changeset
138 function To_Unsigned_Byte (X : Bit_Array_8) return Unsigned_Byte;
kono
parents:
diff changeset
139 function To_Bit_Array_8 (X : Unsigned_Byte) return Bit_Array_8;
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 type Unsigned_Byte_Array is array (Integer range <>) of Unsigned_Byte;
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143 type Unsigned_Word is range 0 .. 65535;
kono
parents:
diff changeset
144 for Unsigned_Word'Size use 16;
kono
parents:
diff changeset
145
kono
parents:
diff changeset
146 function "not" (Left : Unsigned_Word) return Unsigned_Word;
kono
parents:
diff changeset
147 function "and" (Left, Right : Unsigned_Word) return Unsigned_Word;
kono
parents:
diff changeset
148 function "or" (Left, Right : Unsigned_Word) return Unsigned_Word;
kono
parents:
diff changeset
149 function "xor" (Left, Right : Unsigned_Word) return Unsigned_Word;
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151 function To_Unsigned_Word (X : Bit_Array_16) return Unsigned_Word;
kono
parents:
diff changeset
152 function To_Bit_Array_16 (X : Unsigned_Word) return Bit_Array_16;
kono
parents:
diff changeset
153
kono
parents:
diff changeset
154 type Unsigned_Word_Array is array (Integer range <>) of Unsigned_Word;
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156 type Unsigned_Longword is range -2_147_483_648 .. 2_147_483_647;
kono
parents:
diff changeset
157 for Unsigned_Longword'Size use 32;
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 function "not" (Left : Unsigned_Longword) return Unsigned_Longword;
kono
parents:
diff changeset
160 function "and" (Left, Right : Unsigned_Longword) return Unsigned_Longword;
kono
parents:
diff changeset
161 function "or" (Left, Right : Unsigned_Longword) return Unsigned_Longword;
kono
parents:
diff changeset
162 function "xor" (Left, Right : Unsigned_Longword) return Unsigned_Longword;
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164 function To_Unsigned_Longword (X : Bit_Array_32) return Unsigned_Longword;
kono
parents:
diff changeset
165 function To_Bit_Array_32 (X : Unsigned_Longword) return Bit_Array_32;
kono
parents:
diff changeset
166
kono
parents:
diff changeset
167 type Unsigned_Longword_Array is
kono
parents:
diff changeset
168 array (Integer range <>) of Unsigned_Longword;
kono
parents:
diff changeset
169
kono
parents:
diff changeset
170 type Unsigned_32 is range 0 .. 4_294_967_295;
kono
parents:
diff changeset
171 for Unsigned_32'Size use 32;
kono
parents:
diff changeset
172
kono
parents:
diff changeset
173 function "not" (Left : Unsigned_32) return Unsigned_32;
kono
parents:
diff changeset
174 function "and" (Left, Right : Unsigned_32) return Unsigned_32;
kono
parents:
diff changeset
175 function "or" (Left, Right : Unsigned_32) return Unsigned_32;
kono
parents:
diff changeset
176 function "xor" (Left, Right : Unsigned_32) return Unsigned_32;
kono
parents:
diff changeset
177
kono
parents:
diff changeset
178 function To_Unsigned_32 (X : Bit_Array_32) return Unsigned_32;
kono
parents:
diff changeset
179 function To_Bit_Array_32 (X : Unsigned_32) return Bit_Array_32;
kono
parents:
diff changeset
180
kono
parents:
diff changeset
181 type Unsigned_Quadword is record
kono
parents:
diff changeset
182 L0 : Unsigned_Longword;
kono
parents:
diff changeset
183 L1 : Unsigned_Longword;
kono
parents:
diff changeset
184 end record;
kono
parents:
diff changeset
185
kono
parents:
diff changeset
186 for Unsigned_Quadword'Size use 64;
kono
parents:
diff changeset
187 for Unsigned_Quadword'Alignment use
kono
parents:
diff changeset
188 Integer'Min (8, Standard'Maximum_Alignment);
kono
parents:
diff changeset
189
kono
parents:
diff changeset
190 function "not" (Left : Unsigned_Quadword) return Unsigned_Quadword;
kono
parents:
diff changeset
191 function "and" (Left, Right : Unsigned_Quadword) return Unsigned_Quadword;
kono
parents:
diff changeset
192 function "or" (Left, Right : Unsigned_Quadword) return Unsigned_Quadword;
kono
parents:
diff changeset
193 function "xor" (Left, Right : Unsigned_Quadword) return Unsigned_Quadword;
kono
parents:
diff changeset
194
kono
parents:
diff changeset
195 function To_Unsigned_Quadword (X : Bit_Array_64) return Unsigned_Quadword;
kono
parents:
diff changeset
196 function To_Bit_Array_64 (X : Unsigned_Quadword) return Bit_Array_64;
kono
parents:
diff changeset
197
kono
parents:
diff changeset
198 type Unsigned_Quadword_Array is
kono
parents:
diff changeset
199 array (Integer range <>) of Unsigned_Quadword;
kono
parents:
diff changeset
200
kono
parents:
diff changeset
201 function To_Address (X : Integer) return Address;
kono
parents:
diff changeset
202 pragma Pure_Function (To_Address);
kono
parents:
diff changeset
203
kono
parents:
diff changeset
204 function To_Address_Long (X : Unsigned_Longword) return Address;
kono
parents:
diff changeset
205 pragma Pure_Function (To_Address_Long);
kono
parents:
diff changeset
206
kono
parents:
diff changeset
207 function To_Integer (X : Address) return Integer;
kono
parents:
diff changeset
208
kono
parents:
diff changeset
209 function To_Unsigned_Longword (X : Address) return Unsigned_Longword;
kono
parents:
diff changeset
210 function To_Unsigned_Longword (X : AST_Handler) return Unsigned_Longword;
kono
parents:
diff changeset
211
kono
parents:
diff changeset
212 -- Conventional names for static subtypes of type UNSIGNED_LONGWORD
kono
parents:
diff changeset
213
kono
parents:
diff changeset
214 subtype Unsigned_1 is Unsigned_Longword range 0 .. 2** 1 - 1;
kono
parents:
diff changeset
215 subtype Unsigned_2 is Unsigned_Longword range 0 .. 2** 2 - 1;
kono
parents:
diff changeset
216 subtype Unsigned_3 is Unsigned_Longword range 0 .. 2** 3 - 1;
kono
parents:
diff changeset
217 subtype Unsigned_4 is Unsigned_Longword range 0 .. 2** 4 - 1;
kono
parents:
diff changeset
218 subtype Unsigned_5 is Unsigned_Longword range 0 .. 2** 5 - 1;
kono
parents:
diff changeset
219 subtype Unsigned_6 is Unsigned_Longword range 0 .. 2** 6 - 1;
kono
parents:
diff changeset
220 subtype Unsigned_7 is Unsigned_Longword range 0 .. 2** 7 - 1;
kono
parents:
diff changeset
221 subtype Unsigned_8 is Unsigned_Longword range 0 .. 2** 8 - 1;
kono
parents:
diff changeset
222 subtype Unsigned_9 is Unsigned_Longword range 0 .. 2** 9 - 1;
kono
parents:
diff changeset
223 subtype Unsigned_10 is Unsigned_Longword range 0 .. 2**10 - 1;
kono
parents:
diff changeset
224 subtype Unsigned_11 is Unsigned_Longword range 0 .. 2**11 - 1;
kono
parents:
diff changeset
225 subtype Unsigned_12 is Unsigned_Longword range 0 .. 2**12 - 1;
kono
parents:
diff changeset
226 subtype Unsigned_13 is Unsigned_Longword range 0 .. 2**13 - 1;
kono
parents:
diff changeset
227 subtype Unsigned_14 is Unsigned_Longword range 0 .. 2**14 - 1;
kono
parents:
diff changeset
228 subtype Unsigned_15 is Unsigned_Longword range 0 .. 2**15 - 1;
kono
parents:
diff changeset
229 subtype Unsigned_16 is Unsigned_Longword range 0 .. 2**16 - 1;
kono
parents:
diff changeset
230 subtype Unsigned_17 is Unsigned_Longword range 0 .. 2**17 - 1;
kono
parents:
diff changeset
231 subtype Unsigned_18 is Unsigned_Longword range 0 .. 2**18 - 1;
kono
parents:
diff changeset
232 subtype Unsigned_19 is Unsigned_Longword range 0 .. 2**19 - 1;
kono
parents:
diff changeset
233 subtype Unsigned_20 is Unsigned_Longword range 0 .. 2**20 - 1;
kono
parents:
diff changeset
234 subtype Unsigned_21 is Unsigned_Longword range 0 .. 2**21 - 1;
kono
parents:
diff changeset
235 subtype Unsigned_22 is Unsigned_Longword range 0 .. 2**22 - 1;
kono
parents:
diff changeset
236 subtype Unsigned_23 is Unsigned_Longword range 0 .. 2**23 - 1;
kono
parents:
diff changeset
237 subtype Unsigned_24 is Unsigned_Longword range 0 .. 2**24 - 1;
kono
parents:
diff changeset
238 subtype Unsigned_25 is Unsigned_Longword range 0 .. 2**25 - 1;
kono
parents:
diff changeset
239 subtype Unsigned_26 is Unsigned_Longword range 0 .. 2**26 - 1;
kono
parents:
diff changeset
240 subtype Unsigned_27 is Unsigned_Longword range 0 .. 2**27 - 1;
kono
parents:
diff changeset
241 subtype Unsigned_28 is Unsigned_Longword range 0 .. 2**28 - 1;
kono
parents:
diff changeset
242 subtype Unsigned_29 is Unsigned_Longword range 0 .. 2**29 - 1;
kono
parents:
diff changeset
243 subtype Unsigned_30 is Unsigned_Longword range 0 .. 2**30 - 1;
kono
parents:
diff changeset
244 subtype Unsigned_31 is Unsigned_Longword range 0 .. 2**31 - 1;
kono
parents:
diff changeset
245
kono
parents:
diff changeset
246 -- Function for obtaining global symbol values
kono
parents:
diff changeset
247
kono
parents:
diff changeset
248 function Import_Value (Symbol : String) return Unsigned_Longword;
kono
parents:
diff changeset
249 function Import_Address (Symbol : String) return Address;
kono
parents:
diff changeset
250 function Import_Largest_Value (Symbol : String) return Largest_Integer;
kono
parents:
diff changeset
251
kono
parents:
diff changeset
252 pragma Import (Intrinsic, Import_Value);
kono
parents:
diff changeset
253 pragma Import (Intrinsic, Import_Address);
kono
parents:
diff changeset
254 pragma Import (Intrinsic, Import_Largest_Value);
kono
parents:
diff changeset
255
kono
parents:
diff changeset
256 -- For the following declarations, note that the declaration without a
kono
parents:
diff changeset
257 -- Retry_Count parameter means to retry infinitely. A value of zero for
kono
parents:
diff changeset
258 -- the Retry_Count parameter means do not retry.
kono
parents:
diff changeset
259
kono
parents:
diff changeset
260 -- Interlocked-instruction procedures
kono
parents:
diff changeset
261
kono
parents:
diff changeset
262 procedure Clear_Interlocked
kono
parents:
diff changeset
263 (Bit : in out Boolean;
kono
parents:
diff changeset
264 Old_Value : out Boolean);
kono
parents:
diff changeset
265
kono
parents:
diff changeset
266 procedure Set_Interlocked
kono
parents:
diff changeset
267 (Bit : in out Boolean;
kono
parents:
diff changeset
268 Old_Value : out Boolean);
kono
parents:
diff changeset
269
kono
parents:
diff changeset
270 type Aligned_Word is record
kono
parents:
diff changeset
271 Value : Short_Integer;
kono
parents:
diff changeset
272 end record;
kono
parents:
diff changeset
273
kono
parents:
diff changeset
274 for Aligned_Word'Alignment use Integer'Min (2, Standard'Maximum_Alignment);
kono
parents:
diff changeset
275
kono
parents:
diff changeset
276 procedure Clear_Interlocked
kono
parents:
diff changeset
277 (Bit : in out Boolean;
kono
parents:
diff changeset
278 Old_Value : out Boolean;
kono
parents:
diff changeset
279 Retry_Count : Natural;
kono
parents:
diff changeset
280 Success_Flag : out Boolean);
kono
parents:
diff changeset
281
kono
parents:
diff changeset
282 procedure Set_Interlocked
kono
parents:
diff changeset
283 (Bit : in out Boolean;
kono
parents:
diff changeset
284 Old_Value : out Boolean;
kono
parents:
diff changeset
285 Retry_Count : Natural;
kono
parents:
diff changeset
286 Success_Flag : out Boolean);
kono
parents:
diff changeset
287
kono
parents:
diff changeset
288 procedure Add_Interlocked
kono
parents:
diff changeset
289 (Addend : Short_Integer;
kono
parents:
diff changeset
290 Augend : in out Aligned_Word;
kono
parents:
diff changeset
291 Sign : out Integer);
kono
parents:
diff changeset
292
kono
parents:
diff changeset
293 type Aligned_Integer is record
kono
parents:
diff changeset
294 Value : Integer;
kono
parents:
diff changeset
295 end record;
kono
parents:
diff changeset
296
kono
parents:
diff changeset
297 for Aligned_Integer'Alignment use
kono
parents:
diff changeset
298 Integer'Min (4, Standard'Maximum_Alignment);
kono
parents:
diff changeset
299
kono
parents:
diff changeset
300 type Aligned_Long_Integer is record
kono
parents:
diff changeset
301 Value : Long_Integer;
kono
parents:
diff changeset
302 end record;
kono
parents:
diff changeset
303
kono
parents:
diff changeset
304 for Aligned_Long_Integer'Alignment use
kono
parents:
diff changeset
305 Integer'Min (8, Standard'Maximum_Alignment);
kono
parents:
diff changeset
306
kono
parents:
diff changeset
307 -- For the following declarations, note that the declaration without a
kono
parents:
diff changeset
308 -- Retry_Count parameter mean to retry infinitely. A value of zero for
kono
parents:
diff changeset
309 -- the Retry_Count means do not retry.
kono
parents:
diff changeset
310
kono
parents:
diff changeset
311 procedure Add_Atomic
kono
parents:
diff changeset
312 (To : in out Aligned_Integer;
kono
parents:
diff changeset
313 Amount : Integer);
kono
parents:
diff changeset
314
kono
parents:
diff changeset
315 procedure Add_Atomic
kono
parents:
diff changeset
316 (To : in out Aligned_Integer;
kono
parents:
diff changeset
317 Amount : Integer;
kono
parents:
diff changeset
318 Retry_Count : Natural;
kono
parents:
diff changeset
319 Old_Value : out Integer;
kono
parents:
diff changeset
320 Success_Flag : out Boolean);
kono
parents:
diff changeset
321
kono
parents:
diff changeset
322 procedure Add_Atomic
kono
parents:
diff changeset
323 (To : in out Aligned_Long_Integer;
kono
parents:
diff changeset
324 Amount : Long_Integer);
kono
parents:
diff changeset
325
kono
parents:
diff changeset
326 procedure Add_Atomic
kono
parents:
diff changeset
327 (To : in out Aligned_Long_Integer;
kono
parents:
diff changeset
328 Amount : Long_Integer;
kono
parents:
diff changeset
329 Retry_Count : Natural;
kono
parents:
diff changeset
330 Old_Value : out Long_Integer;
kono
parents:
diff changeset
331 Success_Flag : out Boolean);
kono
parents:
diff changeset
332
kono
parents:
diff changeset
333 procedure And_Atomic
kono
parents:
diff changeset
334 (To : in out Aligned_Integer;
kono
parents:
diff changeset
335 From : Integer);
kono
parents:
diff changeset
336
kono
parents:
diff changeset
337 procedure And_Atomic
kono
parents:
diff changeset
338 (To : in out Aligned_Integer;
kono
parents:
diff changeset
339 From : Integer;
kono
parents:
diff changeset
340 Retry_Count : Natural;
kono
parents:
diff changeset
341 Old_Value : out Integer;
kono
parents:
diff changeset
342 Success_Flag : out Boolean);
kono
parents:
diff changeset
343
kono
parents:
diff changeset
344 procedure And_Atomic
kono
parents:
diff changeset
345 (To : in out Aligned_Long_Integer;
kono
parents:
diff changeset
346 From : Long_Integer);
kono
parents:
diff changeset
347
kono
parents:
diff changeset
348 procedure And_Atomic
kono
parents:
diff changeset
349 (To : in out Aligned_Long_Integer;
kono
parents:
diff changeset
350 From : Long_Integer;
kono
parents:
diff changeset
351 Retry_Count : Natural;
kono
parents:
diff changeset
352 Old_Value : out Long_Integer;
kono
parents:
diff changeset
353 Success_Flag : out Boolean);
kono
parents:
diff changeset
354
kono
parents:
diff changeset
355 procedure Or_Atomic
kono
parents:
diff changeset
356 (To : in out Aligned_Integer;
kono
parents:
diff changeset
357 From : Integer);
kono
parents:
diff changeset
358
kono
parents:
diff changeset
359 procedure Or_Atomic
kono
parents:
diff changeset
360 (To : in out Aligned_Integer;
kono
parents:
diff changeset
361 From : Integer;
kono
parents:
diff changeset
362 Retry_Count : Natural;
kono
parents:
diff changeset
363 Old_Value : out Integer;
kono
parents:
diff changeset
364 Success_Flag : out Boolean);
kono
parents:
diff changeset
365
kono
parents:
diff changeset
366 procedure Or_Atomic
kono
parents:
diff changeset
367 (To : in out Aligned_Long_Integer;
kono
parents:
diff changeset
368 From : Long_Integer);
kono
parents:
diff changeset
369
kono
parents:
diff changeset
370 procedure Or_Atomic
kono
parents:
diff changeset
371 (To : in out Aligned_Long_Integer;
kono
parents:
diff changeset
372 From : Long_Integer;
kono
parents:
diff changeset
373 Retry_Count : Natural;
kono
parents:
diff changeset
374 Old_Value : out Long_Integer;
kono
parents:
diff changeset
375 Success_Flag : out Boolean);
kono
parents:
diff changeset
376
kono
parents:
diff changeset
377 type Insq_Status is (Fail_No_Lock, OK_Not_First, OK_First);
kono
parents:
diff changeset
378
kono
parents:
diff changeset
379 for Insq_Status use
kono
parents:
diff changeset
380 (Fail_No_Lock => -1,
kono
parents:
diff changeset
381 OK_Not_First => 0,
kono
parents:
diff changeset
382 OK_First => +1);
kono
parents:
diff changeset
383
kono
parents:
diff changeset
384 type Remq_Status is (
kono
parents:
diff changeset
385 Fail_No_Lock,
kono
parents:
diff changeset
386 Fail_Was_Empty,
kono
parents:
diff changeset
387 OK_Not_Empty,
kono
parents:
diff changeset
388 OK_Empty);
kono
parents:
diff changeset
389
kono
parents:
diff changeset
390 for Remq_Status use
kono
parents:
diff changeset
391 (Fail_No_Lock => -1,
kono
parents:
diff changeset
392 Fail_Was_Empty => 0,
kono
parents:
diff changeset
393 OK_Not_Empty => +1,
kono
parents:
diff changeset
394 OK_Empty => +2);
kono
parents:
diff changeset
395
kono
parents:
diff changeset
396 procedure Insqhi
kono
parents:
diff changeset
397 (Item : Address;
kono
parents:
diff changeset
398 Header : Address;
kono
parents:
diff changeset
399 Status : out Insq_Status);
kono
parents:
diff changeset
400
kono
parents:
diff changeset
401 procedure Remqhi
kono
parents:
diff changeset
402 (Header : Address;
kono
parents:
diff changeset
403 Item : out Address;
kono
parents:
diff changeset
404 Status : out Remq_Status);
kono
parents:
diff changeset
405
kono
parents:
diff changeset
406 procedure Insqti
kono
parents:
diff changeset
407 (Item : Address;
kono
parents:
diff changeset
408 Header : Address;
kono
parents:
diff changeset
409 Status : out Insq_Status);
kono
parents:
diff changeset
410
kono
parents:
diff changeset
411 procedure Remqti
kono
parents:
diff changeset
412 (Header : Address;
kono
parents:
diff changeset
413 Item : out Address;
kono
parents:
diff changeset
414 Status : out Remq_Status);
kono
parents:
diff changeset
415
kono
parents:
diff changeset
416 private
kono
parents:
diff changeset
417
kono
parents:
diff changeset
418 Address_Zero : constant Address := Null_Address;
kono
parents:
diff changeset
419 No_Addr : constant Address := Null_Address;
kono
parents:
diff changeset
420
kono
parents:
diff changeset
421 -- An AST_Handler value is from a typing point of view simply a pointer
kono
parents:
diff changeset
422 -- to a procedure taking a single 64 bit parameter. However, this
kono
parents:
diff changeset
423 -- is a bit misleading, because the data that this pointer references is
kono
parents:
diff changeset
424 -- highly stylized. See body of System.AST_Handling for full details.
kono
parents:
diff changeset
425
kono
parents:
diff changeset
426 type AST_Handler is access procedure (Param : Long_Integer);
kono
parents:
diff changeset
427 No_AST_Handler : constant AST_Handler := null;
kono
parents:
diff changeset
428
kono
parents:
diff changeset
429 -- Other operators have incorrect profiles. It would be nice to make
kono
parents:
diff changeset
430 -- them intrinsic, since the backend can handle them, but the front
kono
parents:
diff changeset
431 -- end is not prepared to deal with them, so at least inline them.
kono
parents:
diff changeset
432
kono
parents:
diff changeset
433 pragma Inline_Always ("+");
kono
parents:
diff changeset
434 pragma Inline_Always ("-");
kono
parents:
diff changeset
435 pragma Inline_Always ("not");
kono
parents:
diff changeset
436 pragma Inline_Always ("and");
kono
parents:
diff changeset
437 pragma Inline_Always ("or");
kono
parents:
diff changeset
438 pragma Inline_Always ("xor");
kono
parents:
diff changeset
439
kono
parents:
diff changeset
440 -- Other inlined subprograms
kono
parents:
diff changeset
441
kono
parents:
diff changeset
442 pragma Inline_Always (Fetch_From_Address);
kono
parents:
diff changeset
443 pragma Inline_Always (Assign_To_Address);
kono
parents:
diff changeset
444
kono
parents:
diff changeset
445 -- Synchronization related subprograms. Mechanism is explicitly set
kono
parents:
diff changeset
446 -- so that the critical parameters are passed by reference.
kono
parents:
diff changeset
447 -- Without this, the parameters are passed by copy, creating load/store
kono
parents:
diff changeset
448 -- race conditions. We also inline them, since this seems more in the
kono
parents:
diff changeset
449 -- spirit of the original (hardware intrinsic) routines.
kono
parents:
diff changeset
450
kono
parents:
diff changeset
451 pragma Export_Procedure
kono
parents:
diff changeset
452 (Clear_Interlocked,
kono
parents:
diff changeset
453 External => "system__aux_dec__clear_interlocked__1",
kono
parents:
diff changeset
454 Parameter_Types => (Boolean, Boolean),
kono
parents:
diff changeset
455 Mechanism => (Reference, Reference));
kono
parents:
diff changeset
456 pragma Export_Procedure
kono
parents:
diff changeset
457 (Clear_Interlocked,
kono
parents:
diff changeset
458 External => "system__aux_dec__clear_interlocked__2",
kono
parents:
diff changeset
459 Parameter_Types => (Boolean, Boolean, Natural, Boolean),
kono
parents:
diff changeset
460 Mechanism => (Reference, Reference, Value, Reference));
kono
parents:
diff changeset
461 pragma Inline_Always (Clear_Interlocked);
kono
parents:
diff changeset
462
kono
parents:
diff changeset
463 pragma Export_Procedure
kono
parents:
diff changeset
464 (Set_Interlocked,
kono
parents:
diff changeset
465 External => "system__aux_dec__set_interlocked__1",
kono
parents:
diff changeset
466 Parameter_Types => (Boolean, Boolean),
kono
parents:
diff changeset
467 Mechanism => (Reference, Reference));
kono
parents:
diff changeset
468 pragma Export_Procedure
kono
parents:
diff changeset
469 (Set_Interlocked,
kono
parents:
diff changeset
470 External => "system__aux_dec__set_interlocked__2",
kono
parents:
diff changeset
471 Parameter_Types => (Boolean, Boolean, Natural, Boolean),
kono
parents:
diff changeset
472 Mechanism => (Reference, Reference, Value, Reference));
kono
parents:
diff changeset
473 pragma Inline_Always (Set_Interlocked);
kono
parents:
diff changeset
474
kono
parents:
diff changeset
475 pragma Export_Procedure
kono
parents:
diff changeset
476 (Add_Interlocked,
kono
parents:
diff changeset
477 External => "system__aux_dec__add_interlocked__1",
kono
parents:
diff changeset
478 Mechanism => (Value, Reference, Reference));
kono
parents:
diff changeset
479 pragma Inline_Always (Add_Interlocked);
kono
parents:
diff changeset
480
kono
parents:
diff changeset
481 pragma Export_Procedure
kono
parents:
diff changeset
482 (Add_Atomic,
kono
parents:
diff changeset
483 External => "system__aux_dec__add_atomic__1",
kono
parents:
diff changeset
484 Parameter_Types => (Aligned_Integer, Integer),
kono
parents:
diff changeset
485 Mechanism => (Reference, Value));
kono
parents:
diff changeset
486 pragma Export_Procedure
kono
parents:
diff changeset
487 (Add_Atomic,
kono
parents:
diff changeset
488 External => "system__aux_dec__add_atomic__2",
kono
parents:
diff changeset
489 Parameter_Types => (Aligned_Integer, Integer, Natural, Integer, Boolean),
kono
parents:
diff changeset
490 Mechanism => (Reference, Value, Value, Reference, Reference));
kono
parents:
diff changeset
491 pragma Export_Procedure
kono
parents:
diff changeset
492 (Add_Atomic,
kono
parents:
diff changeset
493 External => "system__aux_dec__add_atomic__3",
kono
parents:
diff changeset
494 Parameter_Types => (Aligned_Long_Integer, Long_Integer),
kono
parents:
diff changeset
495 Mechanism => (Reference, Value));
kono
parents:
diff changeset
496 pragma Export_Procedure
kono
parents:
diff changeset
497 (Add_Atomic,
kono
parents:
diff changeset
498 External => "system__aux_dec__add_atomic__4",
kono
parents:
diff changeset
499 Parameter_Types => (Aligned_Long_Integer, Long_Integer, Natural,
kono
parents:
diff changeset
500 Long_Integer, Boolean),
kono
parents:
diff changeset
501 Mechanism => (Reference, Value, Value, Reference, Reference));
kono
parents:
diff changeset
502 pragma Inline_Always (Add_Atomic);
kono
parents:
diff changeset
503
kono
parents:
diff changeset
504 pragma Export_Procedure
kono
parents:
diff changeset
505 (And_Atomic,
kono
parents:
diff changeset
506 External => "system__aux_dec__and_atomic__1",
kono
parents:
diff changeset
507 Parameter_Types => (Aligned_Integer, Integer),
kono
parents:
diff changeset
508 Mechanism => (Reference, Value));
kono
parents:
diff changeset
509 pragma Export_Procedure
kono
parents:
diff changeset
510 (And_Atomic,
kono
parents:
diff changeset
511 External => "system__aux_dec__and_atomic__2",
kono
parents:
diff changeset
512 Parameter_Types => (Aligned_Integer, Integer, Natural, Integer, Boolean),
kono
parents:
diff changeset
513 Mechanism => (Reference, Value, Value, Reference, Reference));
kono
parents:
diff changeset
514 pragma Export_Procedure
kono
parents:
diff changeset
515 (And_Atomic,
kono
parents:
diff changeset
516 External => "system__aux_dec__and_atomic__3",
kono
parents:
diff changeset
517 Parameter_Types => (Aligned_Long_Integer, Long_Integer),
kono
parents:
diff changeset
518 Mechanism => (Reference, Value));
kono
parents:
diff changeset
519 pragma Export_Procedure
kono
parents:
diff changeset
520 (And_Atomic,
kono
parents:
diff changeset
521 External => "system__aux_dec__and_atomic__4",
kono
parents:
diff changeset
522 Parameter_Types => (Aligned_Long_Integer, Long_Integer, Natural,
kono
parents:
diff changeset
523 Long_Integer, Boolean),
kono
parents:
diff changeset
524 Mechanism => (Reference, Value, Value, Reference, Reference));
kono
parents:
diff changeset
525 pragma Inline_Always (And_Atomic);
kono
parents:
diff changeset
526
kono
parents:
diff changeset
527 pragma Export_Procedure
kono
parents:
diff changeset
528 (Or_Atomic,
kono
parents:
diff changeset
529 External => "system__aux_dec__or_atomic__1",
kono
parents:
diff changeset
530 Parameter_Types => (Aligned_Integer, Integer),
kono
parents:
diff changeset
531 Mechanism => (Reference, Value));
kono
parents:
diff changeset
532 pragma Export_Procedure
kono
parents:
diff changeset
533 (Or_Atomic,
kono
parents:
diff changeset
534 External => "system__aux_dec__or_atomic__2",
kono
parents:
diff changeset
535 Parameter_Types => (Aligned_Integer, Integer, Natural, Integer, Boolean),
kono
parents:
diff changeset
536 Mechanism => (Reference, Value, Value, Reference, Reference));
kono
parents:
diff changeset
537 pragma Export_Procedure
kono
parents:
diff changeset
538 (Or_Atomic,
kono
parents:
diff changeset
539 External => "system__aux_dec__or_atomic__3",
kono
parents:
diff changeset
540 Parameter_Types => (Aligned_Long_Integer, Long_Integer),
kono
parents:
diff changeset
541 Mechanism => (Reference, Value));
kono
parents:
diff changeset
542 pragma Export_Procedure
kono
parents:
diff changeset
543 (Or_Atomic,
kono
parents:
diff changeset
544 External => "system__aux_dec__or_atomic__4",
kono
parents:
diff changeset
545 Parameter_Types => (Aligned_Long_Integer, Long_Integer, Natural,
kono
parents:
diff changeset
546 Long_Integer, Boolean),
kono
parents:
diff changeset
547 Mechanism => (Reference, Value, Value, Reference, Reference));
kono
parents:
diff changeset
548 pragma Inline_Always (Or_Atomic);
kono
parents:
diff changeset
549
kono
parents:
diff changeset
550 -- Provide proper unchecked conversion definitions for transfer
kono
parents:
diff changeset
551 -- functions. Note that we need this level of indirection because
kono
parents:
diff changeset
552 -- the formal parameter name is X and not Source (and this is indeed
kono
parents:
diff changeset
553 -- detectable by a program)
kono
parents:
diff changeset
554
kono
parents:
diff changeset
555 function To_Unsigned_Byte_A is new
kono
parents:
diff changeset
556 Ada.Unchecked_Conversion (Bit_Array_8, Unsigned_Byte);
kono
parents:
diff changeset
557
kono
parents:
diff changeset
558 function To_Unsigned_Byte (X : Bit_Array_8) return Unsigned_Byte
kono
parents:
diff changeset
559 renames To_Unsigned_Byte_A;
kono
parents:
diff changeset
560
kono
parents:
diff changeset
561 function To_Bit_Array_8_A is new
kono
parents:
diff changeset
562 Ada.Unchecked_Conversion (Unsigned_Byte, Bit_Array_8);
kono
parents:
diff changeset
563
kono
parents:
diff changeset
564 function To_Bit_Array_8 (X : Unsigned_Byte) return Bit_Array_8
kono
parents:
diff changeset
565 renames To_Bit_Array_8_A;
kono
parents:
diff changeset
566
kono
parents:
diff changeset
567 function To_Unsigned_Word_A is new
kono
parents:
diff changeset
568 Ada.Unchecked_Conversion (Bit_Array_16, Unsigned_Word);
kono
parents:
diff changeset
569
kono
parents:
diff changeset
570 function To_Unsigned_Word (X : Bit_Array_16) return Unsigned_Word
kono
parents:
diff changeset
571 renames To_Unsigned_Word_A;
kono
parents:
diff changeset
572
kono
parents:
diff changeset
573 function To_Bit_Array_16_A is new
kono
parents:
diff changeset
574 Ada.Unchecked_Conversion (Unsigned_Word, Bit_Array_16);
kono
parents:
diff changeset
575
kono
parents:
diff changeset
576 function To_Bit_Array_16 (X : Unsigned_Word) return Bit_Array_16
kono
parents:
diff changeset
577 renames To_Bit_Array_16_A;
kono
parents:
diff changeset
578
kono
parents:
diff changeset
579 function To_Unsigned_Longword_A is new
kono
parents:
diff changeset
580 Ada.Unchecked_Conversion (Bit_Array_32, Unsigned_Longword);
kono
parents:
diff changeset
581
kono
parents:
diff changeset
582 function To_Unsigned_Longword (X : Bit_Array_32) return Unsigned_Longword
kono
parents:
diff changeset
583 renames To_Unsigned_Longword_A;
kono
parents:
diff changeset
584
kono
parents:
diff changeset
585 function To_Bit_Array_32_A is new
kono
parents:
diff changeset
586 Ada.Unchecked_Conversion (Unsigned_Longword, Bit_Array_32);
kono
parents:
diff changeset
587
kono
parents:
diff changeset
588 function To_Bit_Array_32 (X : Unsigned_Longword) return Bit_Array_32
kono
parents:
diff changeset
589 renames To_Bit_Array_32_A;
kono
parents:
diff changeset
590
kono
parents:
diff changeset
591 function To_Unsigned_32_A is new
kono
parents:
diff changeset
592 Ada.Unchecked_Conversion (Bit_Array_32, Unsigned_32);
kono
parents:
diff changeset
593
kono
parents:
diff changeset
594 function To_Unsigned_32 (X : Bit_Array_32) return Unsigned_32
kono
parents:
diff changeset
595 renames To_Unsigned_32_A;
kono
parents:
diff changeset
596
kono
parents:
diff changeset
597 function To_Bit_Array_32_A is new
kono
parents:
diff changeset
598 Ada.Unchecked_Conversion (Unsigned_32, Bit_Array_32);
kono
parents:
diff changeset
599
kono
parents:
diff changeset
600 function To_Bit_Array_32 (X : Unsigned_32) return Bit_Array_32
kono
parents:
diff changeset
601 renames To_Bit_Array_32_A;
kono
parents:
diff changeset
602
kono
parents:
diff changeset
603 function To_Unsigned_Quadword_A is new
kono
parents:
diff changeset
604 Ada.Unchecked_Conversion (Bit_Array_64, Unsigned_Quadword);
kono
parents:
diff changeset
605
kono
parents:
diff changeset
606 function To_Unsigned_Quadword (X : Bit_Array_64) return Unsigned_Quadword
kono
parents:
diff changeset
607 renames To_Unsigned_Quadword_A;
kono
parents:
diff changeset
608
kono
parents:
diff changeset
609 function To_Bit_Array_64_A is new
kono
parents:
diff changeset
610 Ada.Unchecked_Conversion (Unsigned_Quadword, Bit_Array_64);
kono
parents:
diff changeset
611
kono
parents:
diff changeset
612 function To_Bit_Array_64 (X : Unsigned_Quadword) return Bit_Array_64
kono
parents:
diff changeset
613 renames To_Bit_Array_64_A;
kono
parents:
diff changeset
614
kono
parents:
diff changeset
615 pragma Warnings (Off);
kono
parents:
diff changeset
616 -- Turn warnings off. This is needed for systems with 64-bit integers,
kono
parents:
diff changeset
617 -- where some of these operations are of dubious meaning, but we do not
kono
parents:
diff changeset
618 -- want warnings when we compile on such systems.
kono
parents:
diff changeset
619
kono
parents:
diff changeset
620 function To_Address_A is new
kono
parents:
diff changeset
621 Ada.Unchecked_Conversion (Integer, Address);
kono
parents:
diff changeset
622 pragma Pure_Function (To_Address_A);
kono
parents:
diff changeset
623
kono
parents:
diff changeset
624 function To_Address (X : Integer) return Address
kono
parents:
diff changeset
625 renames To_Address_A;
kono
parents:
diff changeset
626 pragma Pure_Function (To_Address);
kono
parents:
diff changeset
627
kono
parents:
diff changeset
628 function To_Address_Long_A is new
kono
parents:
diff changeset
629 Ada.Unchecked_Conversion (Unsigned_Longword, Address);
kono
parents:
diff changeset
630 pragma Pure_Function (To_Address_Long_A);
kono
parents:
diff changeset
631
kono
parents:
diff changeset
632 function To_Address_Long (X : Unsigned_Longword) return Address
kono
parents:
diff changeset
633 renames To_Address_Long_A;
kono
parents:
diff changeset
634 pragma Pure_Function (To_Address_Long);
kono
parents:
diff changeset
635
kono
parents:
diff changeset
636 function To_Integer_A is new
kono
parents:
diff changeset
637 Ada.Unchecked_Conversion (Address, Integer);
kono
parents:
diff changeset
638
kono
parents:
diff changeset
639 function To_Integer (X : Address) return Integer
kono
parents:
diff changeset
640 renames To_Integer_A;
kono
parents:
diff changeset
641
kono
parents:
diff changeset
642 function To_Unsigned_Longword_A is new
kono
parents:
diff changeset
643 Ada.Unchecked_Conversion (Address, Unsigned_Longword);
kono
parents:
diff changeset
644
kono
parents:
diff changeset
645 function To_Unsigned_Longword (X : Address) return Unsigned_Longword
kono
parents:
diff changeset
646 renames To_Unsigned_Longword_A;
kono
parents:
diff changeset
647
kono
parents:
diff changeset
648 function To_Unsigned_Longword_A is new
kono
parents:
diff changeset
649 Ada.Unchecked_Conversion (AST_Handler, Unsigned_Longword);
kono
parents:
diff changeset
650
kono
parents:
diff changeset
651 function To_Unsigned_Longword (X : AST_Handler) return Unsigned_Longword
kono
parents:
diff changeset
652 renames To_Unsigned_Longword_A;
kono
parents:
diff changeset
653
kono
parents:
diff changeset
654 pragma Warnings (On);
kono
parents:
diff changeset
655
kono
parents:
diff changeset
656 end System.Aux_DEC;