1 ------------------------------------------------------------------------------
3 -- GNAT RUNTIME COMPONENTS --
5 -- S Y S T E M . U N S I G N E D _ T Y P E S --
11 -- Copyright (C) 1992-2001 Free Software Foundation, Inc. --
13 -- GNAT is free software; you can redistribute it and/or modify it under --
14 -- terms of the GNU General Public License as published by the Free Soft- --
15 -- ware Foundation; either version 2, or (at your option) any later ver- --
16 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
19 -- for more details. You should have received a copy of the GNU General --
20 -- Public License distributed with GNAT; see file COPYING. If not, write --
21 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
22 -- MA 02111-1307, USA. --
24 -- As a special exception, if other files instantiate generics from this --
25 -- unit, or you link this unit with other files to produce an executable, --
26 -- this unit does not by itself cause the resulting executable to be --
27 -- covered by the GNU General Public License. This exception does not --
28 -- however invalidate any other reasons why the executable file might be --
29 -- covered by the GNU Public License. --
31 -- GNAT was originally developed by the GNAT team at New York University. --
32 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
34 ------------------------------------------------------------------------------
36 -- This package contains definitions of standard unsigned types that
37 -- correspond in size to the standard signed types declared in Standard.
38 -- and (unlike the types in Interfaces have corresponding names). It
39 -- also contains some related definitions for other specialized types
40 -- used only by the expander.
42 package System
.Unsigned_Types
is
43 pragma Pure
(Unsigned_Types
);
45 type Short_Short_Unsigned
is mod 2 ** Short_Short_Integer'Size;
46 type Short_Unsigned
is mod 2 ** Short_Integer'Size;
47 type Unsigned
is mod 2 ** Integer'Size;
48 type Long_Unsigned
is mod 2 ** Long_Integer'Size;
49 type Long_Long_Unsigned
is mod 2 ** Long_Long_Integer'Size;
51 type Float_Unsigned
is mod 2 ** Float'Size;
52 -- Used in the implementation of Is_Negative intrinsic (see Exp_Intr)
54 type Packed_Byte
is mod 2 ** 8;
55 for Packed_Byte
'Size use 8;
56 -- Component type for Packed_Butes array
58 type Packed_Bytes1
is array (Natural range <>) of Packed_Byte
;
59 for Packed_Bytes1
'Alignment use 1;
60 -- This is the type used to implement packed arrays where no alignment
61 -- is required. This includes the cases of 1,2,4 (where we use direct
62 -- masking operations), and all odd component sizes (where the clusters
63 -- are not aligned anyway, see, e.g. System.Pack_07 in file s-pack07
66 type Packed_Bytes2
is new Packed_Bytes1
;
67 for Packed_Bytes2
'Alignment use 2;
68 -- This is the type used to implement packed arrays where an alignment
69 -- of 2 is helpful for maximum efficiency of the get and set routines
70 -- in the corresponding library unit. This is true of all component
71 -- sizes that are even but not divisible by 4 (other than 2 for which
72 -- we use direct masking operations). In such cases, the clusters can
73 -- be assumed to be 2-byte aligned if the array is aligned. See for
74 -- example System.Pack_10 in file s-pack10).
76 type Packed_Bytes4
is new Packed_Bytes1
;
77 for Packed_Bytes4
'Alignment use Integer'Min (4, Standard
'Maximum_Alignment);
78 -- This is the type used to implement packed arrays where an alignment
79 -- of 4 is helpful for maximum efficiency of the get and set routines
80 -- in the corresponding library unit. This is true of all component
81 -- sizes that are divisible by 4 (other than powers of 2, which are
82 -- either handled by direct masking or not packed at all). In such cases
83 -- the clusters can be assumed to be 4-byte aligned if the array is
84 -- aligned (see System.Pack_12 in file s-pack12 as an example).
86 type Bits_1
is mod 2**1;
87 type Bits_2
is mod 2**2;
88 type Bits_4
is mod 2**4;
89 -- Types used for packed array conversions
91 subtype Bytes_F
is Packed_Bytes4
(1 .. Float'Size / 8);
92 -- Type used in implementation of Is_Negative instrinsic (see Exp_Intr)
95 (Value
: Short_Short_Unsigned
;
97 return Short_Short_Unsigned
;
100 (Value
: Short_Short_Unsigned
;
102 return Short_Short_Unsigned
;
104 function Shift_Right_Arithmetic
105 (Value
: Short_Short_Unsigned
;
107 return Short_Short_Unsigned
;
110 (Value
: Short_Short_Unsigned
;
112 return Short_Short_Unsigned
;
114 function Rotate_Right
115 (Value
: Short_Short_Unsigned
;
117 return Short_Short_Unsigned
;
120 (Value
: Short_Unsigned
;
122 return Short_Unsigned
;
125 (Value
: Short_Unsigned
;
127 return Short_Unsigned
;
129 function Shift_Right_Arithmetic
130 (Value
: Short_Unsigned
;
132 return Short_Unsigned
;
135 (Value
: Short_Unsigned
;
137 return Short_Unsigned
;
139 function Rotate_Right
140 (Value
: Short_Unsigned
;
142 return Short_Unsigned
;
154 function Shift_Right_Arithmetic
164 function Rotate_Right
170 (Value
: Long_Unsigned
;
172 return Long_Unsigned
;
175 (Value
: Long_Unsigned
;
177 return Long_Unsigned
;
179 function Shift_Right_Arithmetic
180 (Value
: Long_Unsigned
;
182 return Long_Unsigned
;
185 (Value
: Long_Unsigned
;
187 return Long_Unsigned
;
189 function Rotate_Right
190 (Value
: Long_Unsigned
;
192 return Long_Unsigned
;
195 (Value
: Long_Long_Unsigned
;
197 return Long_Long_Unsigned
;
200 (Value
: Long_Long_Unsigned
;
202 return Long_Long_Unsigned
;
204 function Shift_Right_Arithmetic
205 (Value
: Long_Long_Unsigned
;
207 return Long_Long_Unsigned
;
210 (Value
: Long_Long_Unsigned
;
212 return Long_Long_Unsigned
;
214 function Rotate_Right
215 (Value
: Long_Long_Unsigned
;
217 return Long_Long_Unsigned
;
219 pragma Import
(Intrinsic
, Shift_Left
);
220 pragma Import
(Intrinsic
, Shift_Right
);
221 pragma Import
(Intrinsic
, Shift_Right_Arithmetic
);
222 pragma Import
(Intrinsic
, Rotate_Left
);
223 pragma Import
(Intrinsic
, Rotate_Right
);
225 -- The following definitions are obsolsecent. They were needed by the
226 -- previous version of the compiler and runtime, but are not needed
227 -- by the current version. We retain them to help with bootstrap path
228 -- problems. Also they seem harmless, and if any user programs have
229 -- been (rather improperly) using these types, why discombobulate them?
231 subtype Packed_Bytes
is Packed_Bytes4
;
232 subtype Packed_Bytes_Unaligned
is Packed_Bytes1
;
234 end System
.Unsigned_Types
;