1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME 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-2005 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, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, 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
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 for Packed_Bytes1
'Component_Size use Packed_Byte
'Size;
59 -- This is the type used to implement packed arrays where no alignment
60 -- is required. This includes the cases of 1,2,4 (where we use direct
61 -- masking operations), and all odd component sizes (where the clusters
62 -- are not aligned anyway, see, e.g. System.Pack_07 in file s-pack07
65 type Packed_Bytes2
is new Packed_Bytes1
;
66 for Packed_Bytes2
'Alignment use 2;
67 -- This is the type used to implement packed arrays where an alignment
68 -- of 2 is helpful for maximum efficiency of the get and set routines
69 -- in the corresponding library unit. This is true of all component
70 -- sizes that are even but not divisible by 4 (other than 2 for which
71 -- we use direct masking operations). In such cases, the clusters can
72 -- be assumed to be 2-byte aligned if the array is aligned. See for
73 -- example System.Pack_10 in file s-pack10).
75 type Packed_Bytes4
is new Packed_Bytes1
;
76 for Packed_Bytes4
'Alignment use Integer'Min (4, Standard
'Maximum_Alignment);
77 -- This is the type used to implement packed arrays where an alignment
78 -- of 4 is helpful for maximum efficiency of the get and set routines
79 -- in the corresponding library unit. This is true of all component
80 -- sizes that are divisible by 4 (other than powers of 2, which are
81 -- either handled by direct masking or not packed at all). In such cases
82 -- the clusters can be assumed to be 4-byte aligned if the array is
83 -- aligned (see System.Pack_12 in file s-pack12 as an example).
85 type Bits_1
is mod 2**1;
86 type Bits_2
is mod 2**2;
87 type Bits_4
is mod 2**4;
88 -- Types used for packed array conversions
90 subtype Bytes_F
is Packed_Bytes4
(1 .. Float'Size / 8);
91 -- Type used in implementation of Is_Negative intrinsic (see Exp_Intr)
94 (Value
: Short_Short_Unsigned
;
96 return Short_Short_Unsigned
;
99 (Value
: Short_Short_Unsigned
;
101 return Short_Short_Unsigned
;
103 function Shift_Right_Arithmetic
104 (Value
: Short_Short_Unsigned
;
106 return Short_Short_Unsigned
;
109 (Value
: Short_Short_Unsigned
;
111 return Short_Short_Unsigned
;
113 function Rotate_Right
114 (Value
: Short_Short_Unsigned
;
116 return Short_Short_Unsigned
;
119 (Value
: Short_Unsigned
;
121 return Short_Unsigned
;
124 (Value
: Short_Unsigned
;
126 return Short_Unsigned
;
128 function Shift_Right_Arithmetic
129 (Value
: Short_Unsigned
;
131 return Short_Unsigned
;
134 (Value
: Short_Unsigned
;
136 return Short_Unsigned
;
138 function Rotate_Right
139 (Value
: Short_Unsigned
;
141 return Short_Unsigned
;
153 function Shift_Right_Arithmetic
163 function Rotate_Right
169 (Value
: Long_Unsigned
;
171 return Long_Unsigned
;
174 (Value
: Long_Unsigned
;
176 return Long_Unsigned
;
178 function Shift_Right_Arithmetic
179 (Value
: Long_Unsigned
;
181 return Long_Unsigned
;
184 (Value
: Long_Unsigned
;
186 return Long_Unsigned
;
188 function Rotate_Right
189 (Value
: Long_Unsigned
;
191 return Long_Unsigned
;
194 (Value
: Long_Long_Unsigned
;
196 return Long_Long_Unsigned
;
199 (Value
: Long_Long_Unsigned
;
201 return Long_Long_Unsigned
;
203 function Shift_Right_Arithmetic
204 (Value
: Long_Long_Unsigned
;
206 return Long_Long_Unsigned
;
209 (Value
: Long_Long_Unsigned
;
211 return Long_Long_Unsigned
;
213 function Rotate_Right
214 (Value
: Long_Long_Unsigned
;
216 return Long_Long_Unsigned
;
218 pragma Import
(Intrinsic
, Shift_Left
);
219 pragma Import
(Intrinsic
, Shift_Right
);
220 pragma Import
(Intrinsic
, Shift_Right_Arithmetic
);
221 pragma Import
(Intrinsic
, Rotate_Left
);
222 pragma Import
(Intrinsic
, Rotate_Right
);
224 -- The following definitions are obsolsecent. They were needed by the
225 -- previous version of the compiler and runtime, but are not needed
226 -- by the current version. We retain them to help with bootstrap path
227 -- problems. Also they seem harmless, and if any user programs have
228 -- been (rather improperly) using these types, why discombobulate them?
230 subtype Packed_Bytes
is Packed_Bytes4
;
231 subtype Packed_Bytes_Unaligned
is Packed_Bytes1
;
233 end System
.Unsigned_Types
;