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