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-2007, 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 pragma Warnings
(Off
);
44 package System
.Unsigned_Types
is
47 type Short_Short_Unsigned
is mod 2 ** Short_Short_Integer'Size;
48 type Short_Unsigned
is mod 2 ** Short_Integer'Size;
49 type Unsigned
is mod 2 ** Integer'Size;
50 type Long_Unsigned
is mod 2 ** Long_Integer'Size;
51 type Long_Long_Unsigned
is mod 2 ** Long_Long_Integer'Size;
53 type Float_Unsigned
is mod 2 ** Float'Size;
54 -- Used in the implementation of Is_Negative intrinsic (see Exp_Intr)
56 type Packed_Byte
is mod 2 ** 8;
57 for Packed_Byte
'Size use 8;
58 -- Component type for Packed_Butes array
60 type Packed_Bytes1
is array (Natural range <>) of Packed_Byte
;
61 for Packed_Bytes1
'Alignment use 1;
62 for Packed_Bytes1
'Component_Size use Packed_Byte
'Size;
63 -- This is the type used to implement packed arrays where no alignment
64 -- is required. This includes the cases of 1,2,4 (where we use direct
65 -- masking operations), and all odd component sizes (where the clusters
66 -- are not aligned anyway, see, e.g. System.Pack_07 in file s-pack07
69 type Packed_Bytes2
is new Packed_Bytes1
;
70 for Packed_Bytes2
'Alignment use Integer'Min (2, Standard
'Maximum_Alignment);
71 -- This is the type used to implement packed arrays where an alignment
72 -- of 2 (is possible) is helpful for maximum efficiency of the get and
73 -- set routines in the corresponding library unit. This is true of all
74 -- component sizes that are even but not divisible by 4 (other than 2 for
75 -- which we use direct masking operations). In such cases, the clusters
76 -- can be assumed to be 2-byte aligned if the array is aligned. See for
77 -- example System.Pack_10 in file s-pack10).
79 type Packed_Bytes4
is new Packed_Bytes1
;
80 for Packed_Bytes4
'Alignment use Integer'Min (4, Standard
'Maximum_Alignment);
81 -- This is the type used to implement packed arrays where an alignment
82 -- of 4 (if possible) is helpful for maximum efficiency of the get and
83 -- set routines in the corresponding library unit. This is true of all
84 -- component sizes that are divisible by 4 (other than powers of 2, which
85 -- are either handled by direct masking or not packed at all). In such
86 -- cases the clusters can be assumed to be 4-byte aligned if the array
87 -- is aligned (see System.Pack_12 in file s-pack12 as an example).
89 type Bits_1
is mod 2**1;
90 type Bits_2
is mod 2**2;
91 type Bits_4
is mod 2**4;
92 -- Types used for packed array conversions
94 subtype Bytes_F
is Packed_Bytes4
(1 .. Float'Size / 8);
95 -- Type used in implementation of Is_Negative intrinsic (see Exp_Intr)
98 (Value
: Short_Short_Unsigned
;
99 Amount
: Natural) return Short_Short_Unsigned
;
102 (Value
: Short_Short_Unsigned
;
103 Amount
: Natural) return Short_Short_Unsigned
;
105 function Shift_Right_Arithmetic
106 (Value
: Short_Short_Unsigned
;
107 Amount
: Natural) return Short_Short_Unsigned
;
110 (Value
: Short_Short_Unsigned
;
111 Amount
: Natural) return Short_Short_Unsigned
;
113 function Rotate_Right
114 (Value
: Short_Short_Unsigned
;
115 Amount
: Natural) return Short_Short_Unsigned
;
118 (Value
: Short_Unsigned
;
119 Amount
: Natural) return Short_Unsigned
;
122 (Value
: Short_Unsigned
;
123 Amount
: Natural) return Short_Unsigned
;
125 function Shift_Right_Arithmetic
126 (Value
: Short_Unsigned
;
127 Amount
: Natural) return Short_Unsigned
;
130 (Value
: Short_Unsigned
;
131 Amount
: Natural) return Short_Unsigned
;
133 function Rotate_Right
134 (Value
: Short_Unsigned
;
135 Amount
: Natural) return Short_Unsigned
;
139 Amount
: Natural) return Unsigned
;
143 Amount
: Natural) return Unsigned
;
145 function Shift_Right_Arithmetic
147 Amount
: Natural) return Unsigned
;
151 Amount
: Natural) return Unsigned
;
153 function Rotate_Right
155 Amount
: Natural) return Unsigned
;
158 (Value
: Long_Unsigned
;
159 Amount
: Natural) return Long_Unsigned
;
162 (Value
: Long_Unsigned
;
163 Amount
: Natural) return Long_Unsigned
;
165 function Shift_Right_Arithmetic
166 (Value
: Long_Unsigned
;
167 Amount
: Natural) return Long_Unsigned
;
170 (Value
: Long_Unsigned
;
171 Amount
: Natural) return Long_Unsigned
;
173 function Rotate_Right
174 (Value
: Long_Unsigned
;
175 Amount
: Natural) return Long_Unsigned
;
178 (Value
: Long_Long_Unsigned
;
179 Amount
: Natural) return Long_Long_Unsigned
;
182 (Value
: Long_Long_Unsigned
;
183 Amount
: Natural) return Long_Long_Unsigned
;
185 function Shift_Right_Arithmetic
186 (Value
: Long_Long_Unsigned
;
187 Amount
: Natural) return Long_Long_Unsigned
;
190 (Value
: Long_Long_Unsigned
;
191 Amount
: Natural) return Long_Long_Unsigned
;
193 function Rotate_Right
194 (Value
: Long_Long_Unsigned
;
195 Amount
: Natural) return Long_Long_Unsigned
;
197 pragma Import
(Intrinsic
, Shift_Left
);
198 pragma Import
(Intrinsic
, Shift_Right
);
199 pragma Import
(Intrinsic
, Shift_Right_Arithmetic
);
200 pragma Import
(Intrinsic
, Rotate_Left
);
201 pragma Import
(Intrinsic
, Rotate_Right
);
203 -- The following definitions are obsolsecent. They were needed by the
204 -- previous version of the compiler and runtime, but are not needed
205 -- by the current version. We retain them to help with bootstrap path
206 -- problems. Also they seem harmless, and if any user programs have
207 -- been (rather improperly) using these types, why discombobulate them?
209 subtype Packed_Bytes
is Packed_Bytes4
;
210 subtype Packed_Bytes_Unaligned
is Packed_Bytes1
;
212 end System
.Unsigned_Types
;