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 --
9 -- Copyright (C) 1992-2001 Free Software Foundation, Inc. --
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 2, 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. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
32 ------------------------------------------------------------------------------
34 -- This package contains definitions of standard unsigned types that
35 -- correspond in size to the standard signed types declared in Standard.
36 -- and (unlike the types in Interfaces have corresponding names). It
37 -- also contains some related definitions for other specialized types
38 -- used by the compiler in connection with packed array types.
40 package System
.Unsigned_Types
is
41 pragma Pure
(Unsigned_Types
);
43 type Short_Short_Unsigned
is mod 2 ** Short_Short_Integer'Size;
44 type Short_Unsigned
is mod 2 ** Short_Integer'Size;
45 type Unsigned
is mod 2 ** Integer'Size;
46 type Long_Unsigned
is mod 2 ** Long_Integer'Size;
47 type Long_Long_Unsigned
is mod 2 ** Long_Long_Integer'Size;
49 type Float_Unsigned
is mod 2 ** Float'Size;
50 -- Used in the implementation of Is_Negative intrinsic (see Exp_Intr)
52 type Packed_Byte
is mod 2 ** 8;
53 for Packed_Byte
'Size use 8;
54 -- Component type for Packed_Butes array
56 type Packed_Bytes1
is array (Natural range <>) of Packed_Byte
;
57 for Packed_Bytes1
'Alignment use 1;
58 -- This is the type used to implement packed arrays where no alignment
59 -- is required. This includes the cases of 1,2,4 (where we use direct
60 -- masking operations), and all odd component sizes (where the clusters
61 -- are not aligned anyway, see, e.g. System.Pack_07 in file s-pack07
64 type Packed_Bytes2
is new Packed_Bytes1
;
65 for Packed_Bytes2
'Alignment use 2;
66 -- This is the type used to implement packed arrays where an alignment
67 -- of 2 is helpful for maximum efficiency of the get and set routines
68 -- in the corresponding library unit. This is true of all component
69 -- sizes that are even but not divisible by 4 (other than 2 for which
70 -- we use direct masking operations). In such cases, the clusters can
71 -- be assumed to be 2-byte aligned if the array is aligned. See for
72 -- example System.Pack_10 in file s-pack10).
74 type Packed_Bytes4
is new Packed_Bytes1
;
75 for Packed_Bytes4
'Alignment use Integer'Min (4, Standard
'Maximum_Alignment);
76 -- This is the type used to implement packed arrays where an alignment
77 -- of 4 is helpful for maximum efficiency of the get and set routines
78 -- in the corresponding library unit. This is true of all component
79 -- sizes that are divisible by 4 (other than powers of 2, which are
80 -- either handled by direct masking or not packed at all). In such cases
81 -- the clusters can be assumed to be 4-byte aligned if the array is
82 -- aligned (see System.Pack_12 in file s-pack12 as an example).
84 type Bits_1
is mod 2**1;
85 type Bits_2
is mod 2**2;
86 type Bits_4
is mod 2**4;
87 -- Types used for packed array conversions
89 subtype Bytes_F
is Packed_Bytes4
(1 .. Float'Size / 8);
90 -- Type used in implementation of Is_Negative instrinsic (see Exp_Intr)
93 (Value
: Short_Short_Unsigned
;
95 return Short_Short_Unsigned
;
98 (Value
: Short_Short_Unsigned
;
100 return Short_Short_Unsigned
;
102 function Shift_Right_Arithmetic
103 (Value
: Short_Short_Unsigned
;
105 return Short_Short_Unsigned
;
108 (Value
: Short_Short_Unsigned
;
110 return Short_Short_Unsigned
;
112 function Rotate_Right
113 (Value
: Short_Short_Unsigned
;
115 return Short_Short_Unsigned
;
118 (Value
: Short_Unsigned
;
120 return Short_Unsigned
;
123 (Value
: Short_Unsigned
;
125 return Short_Unsigned
;
127 function Shift_Right_Arithmetic
128 (Value
: Short_Unsigned
;
130 return Short_Unsigned
;
133 (Value
: Short_Unsigned
;
135 return Short_Unsigned
;
137 function Rotate_Right
138 (Value
: Short_Unsigned
;
140 return Short_Unsigned
;
152 function Shift_Right_Arithmetic
162 function Rotate_Right
168 (Value
: Long_Unsigned
;
170 return Long_Unsigned
;
173 (Value
: Long_Unsigned
;
175 return Long_Unsigned
;
177 function Shift_Right_Arithmetic
178 (Value
: Long_Unsigned
;
180 return Long_Unsigned
;
183 (Value
: Long_Unsigned
;
185 return Long_Unsigned
;
187 function Rotate_Right
188 (Value
: Long_Unsigned
;
190 return Long_Unsigned
;
193 (Value
: Long_Long_Unsigned
;
195 return Long_Long_Unsigned
;
198 (Value
: Long_Long_Unsigned
;
200 return Long_Long_Unsigned
;
202 function Shift_Right_Arithmetic
203 (Value
: Long_Long_Unsigned
;
205 return Long_Long_Unsigned
;
208 (Value
: Long_Long_Unsigned
;
210 return Long_Long_Unsigned
;
212 function Rotate_Right
213 (Value
: Long_Long_Unsigned
;
215 return Long_Long_Unsigned
;
217 pragma Import
(Intrinsic
, Shift_Left
);
218 pragma Import
(Intrinsic
, Shift_Right
);
219 pragma Import
(Intrinsic
, Shift_Right_Arithmetic
);
220 pragma Import
(Intrinsic
, Rotate_Left
);
221 pragma Import
(Intrinsic
, Rotate_Right
);
223 -- The following definitions are obsolsecent. They were needed by the
224 -- previous version of the compiler and runtime, but are not needed
225 -- by the current version. We retain them to help with bootstrap path
226 -- problems. Also they seem harmless, and if any user programs have
227 -- been (rather improperly) using these types, why discombobulate them?
229 subtype Packed_Bytes
is Packed_Bytes4
;
230 subtype Packed_Bytes_Unaligned
is Packed_Bytes1
;
232 end System
.Unsigned_Types
;