2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / ada / s-unstyp.ads
blob5edeeb834125448cc560b67f581cd5b62e62fc3f
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUNTIME 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-2003 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 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, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
21 -- --
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. --
28 -- --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
31 -- --
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
41 pragma Pure (Unsigned_Types);
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
63 -- for details.
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 instrinsic (see Exp_Intr)
93 function Shift_Left
94 (Value : Short_Short_Unsigned;
95 Amount : Natural)
96 return Short_Short_Unsigned;
98 function Shift_Right
99 (Value : Short_Short_Unsigned;
100 Amount : Natural)
101 return Short_Short_Unsigned;
103 function Shift_Right_Arithmetic
104 (Value : Short_Short_Unsigned;
105 Amount : Natural)
106 return Short_Short_Unsigned;
108 function Rotate_Left
109 (Value : Short_Short_Unsigned;
110 Amount : Natural)
111 return Short_Short_Unsigned;
113 function Rotate_Right
114 (Value : Short_Short_Unsigned;
115 Amount : Natural)
116 return Short_Short_Unsigned;
118 function Shift_Left
119 (Value : Short_Unsigned;
120 Amount : Natural)
121 return Short_Unsigned;
123 function Shift_Right
124 (Value : Short_Unsigned;
125 Amount : Natural)
126 return Short_Unsigned;
128 function Shift_Right_Arithmetic
129 (Value : Short_Unsigned;
130 Amount : Natural)
131 return Short_Unsigned;
133 function Rotate_Left
134 (Value : Short_Unsigned;
135 Amount : Natural)
136 return Short_Unsigned;
138 function Rotate_Right
139 (Value : Short_Unsigned;
140 Amount : Natural)
141 return Short_Unsigned;
143 function Shift_Left
144 (Value : Unsigned;
145 Amount : Natural)
146 return Unsigned;
148 function Shift_Right
149 (Value : Unsigned;
150 Amount : Natural)
151 return Unsigned;
153 function Shift_Right_Arithmetic
154 (Value : Unsigned;
155 Amount : Natural)
156 return Unsigned;
158 function Rotate_Left
159 (Value : Unsigned;
160 Amount : Natural)
161 return Unsigned;
163 function Rotate_Right
164 (Value : Unsigned;
165 Amount : Natural)
166 return Unsigned;
168 function Shift_Left
169 (Value : Long_Unsigned;
170 Amount : Natural)
171 return Long_Unsigned;
173 function Shift_Right
174 (Value : Long_Unsigned;
175 Amount : Natural)
176 return Long_Unsigned;
178 function Shift_Right_Arithmetic
179 (Value : Long_Unsigned;
180 Amount : Natural)
181 return Long_Unsigned;
183 function Rotate_Left
184 (Value : Long_Unsigned;
185 Amount : Natural)
186 return Long_Unsigned;
188 function Rotate_Right
189 (Value : Long_Unsigned;
190 Amount : Natural)
191 return Long_Unsigned;
193 function Shift_Left
194 (Value : Long_Long_Unsigned;
195 Amount : Natural)
196 return Long_Long_Unsigned;
198 function Shift_Right
199 (Value : Long_Long_Unsigned;
200 Amount : Natural)
201 return Long_Long_Unsigned;
203 function Shift_Right_Arithmetic
204 (Value : Long_Long_Unsigned;
205 Amount : Natural)
206 return Long_Long_Unsigned;
208 function Rotate_Left
209 (Value : Long_Long_Unsigned;
210 Amount : Natural)
211 return Long_Long_Unsigned;
213 function Rotate_Right
214 (Value : Long_Long_Unsigned;
215 Amount : Natural)
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;