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-2009, 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 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. --
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. --
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/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 ------------------------------------------------------------------------------
32 -- This package contains definitions of standard unsigned types that
33 -- correspond in size to the standard signed types declared in Standard,
34 -- and (unlike the types in Interfaces) have corresponding names. It
35 -- also contains some related definitions for other specialized types
36 -- used by the compiler in connection with packed array types.
38 pragma Warnings (Off);
42 package System.Unsigned_Types is
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_Bytes array
58 type Packed_Bytes1 is array (Natural range <>) of Packed_Byte;
59 for Packed_Bytes1'Alignment use 1;
60 for Packed_Bytes1'Component_Size use Packed_Byte'Size;
61 -- This is the type used to implement packed arrays where no alignment
62 -- is required. This includes the cases of 1,2,4 (where we use direct
63 -- masking operations), and all odd component sizes (where the clusters
64 -- are not aligned anyway, see, e.g. System.Pack_07 in file s-pack07
67 type Packed_Bytes2 is new Packed_Bytes1;
68 for Packed_Bytes2'Alignment use Integer'Min (2, Standard'Maximum_Alignment);
69 -- This is the type used to implement packed arrays where an alignment
70 -- of 2 (is possible) is helpful for maximum efficiency of the get and
71 -- set routines in the corresponding library unit. This is true of all
72 -- component sizes that are even but not divisible by 4 (other than 2 for
73 -- which we use direct masking operations). In such cases, the clusters
74 -- can be assumed to be 2-byte aligned if the array is aligned. See for
75 -- example System.Pack_10 in file s-pack10).
77 type Packed_Bytes4 is new Packed_Bytes1;
78 for Packed_Bytes4'Alignment use Integer'Min (4, Standard'Maximum_Alignment);
79 -- This is the type used to implement packed arrays where an alignment
80 -- of 4 (if possible) is helpful for maximum efficiency of the get and
81 -- set routines in the corresponding library unit. This is true of all
82 -- component sizes that are divisible by 4 (other than powers of 2, which
83 -- are either handled by direct masking or not packed at all). In such
84 -- cases the clusters can be assumed to be 4-byte aligned if the array
85 -- is aligned (see System.Pack_12 in file s-pack12 as an example).
87 type Bits_1 is mod 2**1;
88 type Bits_2 is mod 2**2;
89 type Bits_4 is mod 2**4;
90 -- Types used for packed array conversions
92 subtype Bytes_F is Packed_Bytes4 (1 .. Float'Size / 8);
93 -- Type used in implementation of Is_Negative intrinsic (see Exp_Intr)
96 (Value : Short_Short_Unsigned;
97 Amount : Natural) return Short_Short_Unsigned;
100 (Value : Short_Short_Unsigned;
101 Amount : Natural) return Short_Short_Unsigned;
103 function Shift_Right_Arithmetic
104 (Value : Short_Short_Unsigned;
105 Amount : Natural) return Short_Short_Unsigned;
108 (Value : Short_Short_Unsigned;
109 Amount : Natural) return Short_Short_Unsigned;
111 function Rotate_Right
112 (Value : Short_Short_Unsigned;
113 Amount : Natural) return Short_Short_Unsigned;
116 (Value : Short_Unsigned;
117 Amount : Natural) return Short_Unsigned;
120 (Value : Short_Unsigned;
121 Amount : Natural) return Short_Unsigned;
123 function Shift_Right_Arithmetic
124 (Value : Short_Unsigned;
125 Amount : Natural) return Short_Unsigned;
128 (Value : Short_Unsigned;
129 Amount : Natural) return Short_Unsigned;
131 function Rotate_Right
132 (Value : Short_Unsigned;
133 Amount : Natural) return Short_Unsigned;
137 Amount : Natural) return Unsigned;
141 Amount : Natural) return Unsigned;
143 function Shift_Right_Arithmetic
145 Amount : Natural) return Unsigned;
149 Amount : Natural) return Unsigned;
151 function Rotate_Right
153 Amount : Natural) return Unsigned;
156 (Value : Long_Unsigned;
157 Amount : Natural) return Long_Unsigned;
160 (Value : Long_Unsigned;
161 Amount : Natural) return Long_Unsigned;
163 function Shift_Right_Arithmetic
164 (Value : Long_Unsigned;
165 Amount : Natural) return Long_Unsigned;
168 (Value : Long_Unsigned;
169 Amount : Natural) return Long_Unsigned;
171 function Rotate_Right
172 (Value : Long_Unsigned;
173 Amount : Natural) return Long_Unsigned;
176 (Value : Long_Long_Unsigned;
177 Amount : Natural) return Long_Long_Unsigned;
180 (Value : Long_Long_Unsigned;
181 Amount : Natural) return Long_Long_Unsigned;
183 function Shift_Right_Arithmetic
184 (Value : Long_Long_Unsigned;
185 Amount : Natural) return Long_Long_Unsigned;
188 (Value : Long_Long_Unsigned;
189 Amount : Natural) return Long_Long_Unsigned;
191 function Rotate_Right
192 (Value : Long_Long_Unsigned;
193 Amount : Natural) return Long_Long_Unsigned;
195 pragma Import (Intrinsic, Shift_Left);
196 pragma Import (Intrinsic, Shift_Right);
197 pragma Import (Intrinsic, Shift_Right_Arithmetic);
198 pragma Import (Intrinsic, Rotate_Left);
199 pragma Import (Intrinsic, Rotate_Right);
201 -- The following definitions are obsolescent. They were needed by the
202 -- previous version of the compiler and runtime, but are not needed
203 -- by the current version. We retain them to help with bootstrap path
204 -- problems. Also they seem harmless, and if any user programs have
205 -- been (rather improperly) using these types, why discombobulate them?
207 subtype Packed_Bytes is Packed_Bytes4;
208 subtype Packed_Bytes_Unaligned is Packed_Bytes1;
210 end System.Unsigned_Types;