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