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-2014, 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 package System
.Unsigned_Types
is
41 type Short_Short_Unsigned
is mod 2 ** Short_Short_Integer'Size;
42 type Short_Unsigned
is mod 2 ** Short_Integer'Size;
43 type Unsigned
is mod 2 ** Integer'Size;
44 type Long_Unsigned
is mod 2 ** Long_Integer'Size;
45 type Long_Long_Unsigned
is mod 2 ** Long_Long_Integer'Size;
47 type Float_Unsigned
is mod 2 ** Float'Size;
48 -- Used in the implementation of Is_Negative intrinsic (see Exp_Intr)
50 type Packed_Byte
is mod 2 ** 8;
51 pragma Universal_Aliasing
(Packed_Byte
);
52 for Packed_Byte
'Size use 8;
53 -- Component type for Packed_Bytes1, Packed_Bytes2 and Packed_Byte4 arrays.
54 -- As this type is used by the compiler to implement operations on user
55 -- packed array, it needs to be able to alias any type.
57 type Packed_Bytes1
is array (Natural range <>) of aliased Packed_Byte
;
58 for Packed_Bytes1
'Alignment use 1;
59 for Packed_Bytes1
'Component_Size use Packed_Byte
'Size;
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 Integer'Min (2, Standard
'Maximum_Alignment);
68 -- This is the type used to implement packed arrays where an alignment
69 -- of 2 (is possible) is helpful for maximum efficiency of the get and
70 -- set routines in the corresponding library unit. This is true of all
71 -- component sizes that are even but not divisible by 4 (other than 2 for
72 -- which we use direct masking operations). In such cases, the clusters
73 -- can 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 (if possible) is helpful for maximum efficiency of the get and
80 -- set routines in the corresponding library unit. This is true of all
81 -- component sizes that are divisible by 4 (other than powers of 2, which
82 -- are either handled by direct masking or not packed at all). In such
83 -- cases the clusters can be assumed to be 4-byte aligned if the array
84 -- is 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 intrinsic (see Exp_Intr)
95 (Value
: Short_Short_Unsigned
;
96 Amount
: Natural) return Short_Short_Unsigned
;
99 (Value
: Short_Short_Unsigned
;
100 Amount
: Natural) return Short_Short_Unsigned
;
102 function Shift_Right_Arithmetic
103 (Value
: Short_Short_Unsigned
;
104 Amount
: Natural) return Short_Short_Unsigned
;
107 (Value
: Short_Short_Unsigned
;
108 Amount
: Natural) return Short_Short_Unsigned
;
110 function Rotate_Right
111 (Value
: Short_Short_Unsigned
;
112 Amount
: Natural) return Short_Short_Unsigned
;
115 (Value
: Short_Unsigned
;
116 Amount
: Natural) return Short_Unsigned
;
119 (Value
: Short_Unsigned
;
120 Amount
: Natural) return Short_Unsigned
;
122 function Shift_Right_Arithmetic
123 (Value
: Short_Unsigned
;
124 Amount
: Natural) return Short_Unsigned
;
127 (Value
: Short_Unsigned
;
128 Amount
: Natural) return Short_Unsigned
;
130 function Rotate_Right
131 (Value
: Short_Unsigned
;
132 Amount
: Natural) return Short_Unsigned
;
136 Amount
: Natural) return Unsigned
;
140 Amount
: Natural) return Unsigned
;
142 function Shift_Right_Arithmetic
144 Amount
: Natural) return Unsigned
;
148 Amount
: Natural) return Unsigned
;
150 function Rotate_Right
152 Amount
: Natural) return Unsigned
;
155 (Value
: Long_Unsigned
;
156 Amount
: Natural) return Long_Unsigned
;
159 (Value
: Long_Unsigned
;
160 Amount
: Natural) return Long_Unsigned
;
162 function Shift_Right_Arithmetic
163 (Value
: Long_Unsigned
;
164 Amount
: Natural) return Long_Unsigned
;
167 (Value
: Long_Unsigned
;
168 Amount
: Natural) return Long_Unsigned
;
170 function Rotate_Right
171 (Value
: Long_Unsigned
;
172 Amount
: Natural) return Long_Unsigned
;
175 (Value
: Long_Long_Unsigned
;
176 Amount
: Natural) return Long_Long_Unsigned
;
179 (Value
: Long_Long_Unsigned
;
180 Amount
: Natural) return Long_Long_Unsigned
;
182 function Shift_Right_Arithmetic
183 (Value
: Long_Long_Unsigned
;
184 Amount
: Natural) return Long_Long_Unsigned
;
187 (Value
: Long_Long_Unsigned
;
188 Amount
: Natural) return Long_Long_Unsigned
;
190 function Rotate_Right
191 (Value
: Long_Long_Unsigned
;
192 Amount
: Natural) return Long_Long_Unsigned
;
194 pragma Import
(Intrinsic
, Shift_Left
);
195 pragma Import
(Intrinsic
, Shift_Right
);
196 pragma Import
(Intrinsic
, Shift_Right_Arithmetic
);
197 pragma Import
(Intrinsic
, Rotate_Left
);
198 pragma Import
(Intrinsic
, Rotate_Right
);
200 -- The following definitions are obsolescent. They were needed by the
201 -- previous version of the compiler and runtime, but are not needed
202 -- by the current version. We retain them to help with bootstrap path
203 -- problems. Also they seem harmless, and if any user programs have
204 -- been using these types, why discombobulate them?
206 subtype Packed_Bytes
is Packed_Bytes4
;
207 subtype Packed_Bytes_Unaligned
is Packed_Bytes1
;
209 end System
.Unsigned_Types
;