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