PR c++/63928
[official-gcc.git] / gcc / ada / s-unstyp.ads
blob9eefc15b59c679ddb8072efdd23fbb0ed8a21108
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- S Y S T E M . U N S I G N E D _ T Y P E S --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2014, Free Software Foundation, Inc. --
10 -- --
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. --
17 -- --
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. --
21 -- --
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/>. --
26 -- --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
29 -- --
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 Compiler_Unit_Warning;
40 package System.Unsigned_Types is
41 pragma Pure;
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 pragma Universal_Aliasing (Packed_Byte);
54 for Packed_Byte'Size use 8;
55 -- Component type for Packed_Bytes1, Packed_Bytes2 and Packed_Byte4 arrays.
56 -- As this type is used by the compiler to implement operations on user
57 -- packed array, it needs to be able to alias any type.
59 type Packed_Bytes1 is array (Natural range <>) of aliased Packed_Byte;
60 for Packed_Bytes1'Alignment use 1;
61 for Packed_Bytes1'Component_Size use Packed_Byte'Size;
62 -- This is the type used to implement packed arrays where no alignment
63 -- is required. This includes the cases of 1,2,4 (where we use direct
64 -- masking operations), and all odd component sizes (where the clusters
65 -- are not aligned anyway, see, e.g. System.Pack_07 in file s-pack07
66 -- for details.
68 type Packed_Bytes2 is new Packed_Bytes1;
69 for Packed_Bytes2'Alignment use Integer'Min (2, Standard'Maximum_Alignment);
70 -- This is the type used to implement packed arrays where an alignment
71 -- of 2 (is possible) is helpful for maximum efficiency of the get and
72 -- set routines in the corresponding library unit. This is true of all
73 -- component sizes that are even but not divisible by 4 (other than 2 for
74 -- which we use direct masking operations). In such cases, the clusters
75 -- can be assumed to be 2-byte aligned if the array is aligned. See for
76 -- example System.Pack_10 in file s-pack10).
78 type Packed_Bytes4 is new Packed_Bytes1;
79 for Packed_Bytes4'Alignment use Integer'Min (4, Standard'Maximum_Alignment);
80 -- This is the type used to implement packed arrays where an alignment
81 -- of 4 (if possible) is helpful for maximum efficiency of the get and
82 -- set routines in the corresponding library unit. This is true of all
83 -- component sizes that are divisible by 4 (other than powers of 2, which
84 -- are either handled by direct masking or not packed at all). In such
85 -- cases the clusters can be assumed to be 4-byte aligned if the array
86 -- is aligned (see System.Pack_12 in file s-pack12 as an example).
88 type Bits_1 is mod 2**1;
89 type Bits_2 is mod 2**2;
90 type Bits_4 is mod 2**4;
91 -- Types used for packed array conversions
93 subtype Bytes_F is Packed_Bytes4 (1 .. Float'Size / 8);
94 -- Type used in implementation of Is_Negative intrinsic (see Exp_Intr)
96 function Shift_Left
97 (Value : Short_Short_Unsigned;
98 Amount : Natural) return Short_Short_Unsigned;
100 function Shift_Right
101 (Value : Short_Short_Unsigned;
102 Amount : Natural) return Short_Short_Unsigned;
104 function Shift_Right_Arithmetic
105 (Value : Short_Short_Unsigned;
106 Amount : Natural) return Short_Short_Unsigned;
108 function Rotate_Left
109 (Value : Short_Short_Unsigned;
110 Amount : Natural) return Short_Short_Unsigned;
112 function Rotate_Right
113 (Value : Short_Short_Unsigned;
114 Amount : Natural) return Short_Short_Unsigned;
116 function Shift_Left
117 (Value : Short_Unsigned;
118 Amount : Natural) return Short_Unsigned;
120 function Shift_Right
121 (Value : Short_Unsigned;
122 Amount : Natural) return Short_Unsigned;
124 function Shift_Right_Arithmetic
125 (Value : Short_Unsigned;
126 Amount : Natural) return Short_Unsigned;
128 function Rotate_Left
129 (Value : Short_Unsigned;
130 Amount : Natural) return Short_Unsigned;
132 function Rotate_Right
133 (Value : Short_Unsigned;
134 Amount : Natural) return Short_Unsigned;
136 function Shift_Left
137 (Value : Unsigned;
138 Amount : Natural) return Unsigned;
140 function Shift_Right
141 (Value : Unsigned;
142 Amount : Natural) return Unsigned;
144 function Shift_Right_Arithmetic
145 (Value : Unsigned;
146 Amount : Natural) return Unsigned;
148 function Rotate_Left
149 (Value : Unsigned;
150 Amount : Natural) return Unsigned;
152 function Rotate_Right
153 (Value : Unsigned;
154 Amount : Natural) return Unsigned;
156 function Shift_Left
157 (Value : Long_Unsigned;
158 Amount : Natural) return Long_Unsigned;
160 function Shift_Right
161 (Value : Long_Unsigned;
162 Amount : Natural) return Long_Unsigned;
164 function Shift_Right_Arithmetic
165 (Value : Long_Unsigned;
166 Amount : Natural) return Long_Unsigned;
168 function Rotate_Left
169 (Value : Long_Unsigned;
170 Amount : Natural) return Long_Unsigned;
172 function Rotate_Right
173 (Value : Long_Unsigned;
174 Amount : Natural) return Long_Unsigned;
176 function Shift_Left
177 (Value : Long_Long_Unsigned;
178 Amount : Natural) return Long_Long_Unsigned;
180 function Shift_Right
181 (Value : Long_Long_Unsigned;
182 Amount : Natural) return Long_Long_Unsigned;
184 function Shift_Right_Arithmetic
185 (Value : Long_Long_Unsigned;
186 Amount : Natural) return Long_Long_Unsigned;
188 function Rotate_Left
189 (Value : Long_Long_Unsigned;
190 Amount : Natural) return Long_Long_Unsigned;
192 function Rotate_Right
193 (Value : Long_Long_Unsigned;
194 Amount : Natural) return Long_Long_Unsigned;
196 pragma Import (Intrinsic, Shift_Left);
197 pragma Import (Intrinsic, Shift_Right);
198 pragma Import (Intrinsic, Shift_Right_Arithmetic);
199 pragma Import (Intrinsic, Rotate_Left);
200 pragma Import (Intrinsic, Rotate_Right);
202 -- The following definitions are obsolescent. They were needed by the
203 -- previous version of the compiler and runtime, but are not needed
204 -- by the current version. We retain them to help with bootstrap path
205 -- problems. Also they seem harmless, and if any user programs have
206 -- been using these types, why discombobulate them?
208 subtype Packed_Bytes is Packed_Bytes4;
209 subtype Packed_Bytes_Unaligned is Packed_Bytes1;
211 end System.Unsigned_Types;