OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-unstyp.ads
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-2008, 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,  51  Franklin  Street,  Fifth  Floor, --
20 -- Boston, MA 02110-1301, 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 ------------------------------------------------------------------------------
33
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.
39
40 pragma Warnings (Off);
41 pragma Compiler_Unit;
42 pragma Warnings (On);
43
44 package System.Unsigned_Types is
45    pragma Pure;
46
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;
52
53    type Float_Unsigned       is mod 2 ** Float'Size;
54    --  Used in the implementation of Is_Negative intrinsic (see Exp_Intr)
55
56    type Packed_Byte is mod 2 ** 8;
57    for Packed_Byte'Size use 8;
58    --  Component type for Packed_Bytes array
59
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
67    --  for details.
68
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).
78
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).
88
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
93
94    subtype Bytes_F is Packed_Bytes4 (1 .. Float'Size / 8);
95    --  Type used in implementation of Is_Negative intrinsic (see Exp_Intr)
96
97    function Shift_Left
98      (Value  : Short_Short_Unsigned;
99       Amount : Natural) return Short_Short_Unsigned;
100
101    function Shift_Right
102      (Value  : Short_Short_Unsigned;
103       Amount : Natural) return Short_Short_Unsigned;
104
105    function Shift_Right_Arithmetic
106      (Value  : Short_Short_Unsigned;
107       Amount : Natural) return Short_Short_Unsigned;
108
109    function Rotate_Left
110      (Value  : Short_Short_Unsigned;
111       Amount : Natural) return Short_Short_Unsigned;
112
113    function Rotate_Right
114      (Value  : Short_Short_Unsigned;
115       Amount : Natural) return Short_Short_Unsigned;
116
117    function Shift_Left
118      (Value  : Short_Unsigned;
119       Amount : Natural) return Short_Unsigned;
120
121    function Shift_Right
122      (Value  : Short_Unsigned;
123       Amount : Natural) return Short_Unsigned;
124
125    function Shift_Right_Arithmetic
126      (Value  : Short_Unsigned;
127       Amount : Natural) return Short_Unsigned;
128
129    function Rotate_Left
130      (Value  : Short_Unsigned;
131       Amount : Natural) return Short_Unsigned;
132
133    function Rotate_Right
134      (Value  : Short_Unsigned;
135       Amount : Natural) return Short_Unsigned;
136
137    function Shift_Left
138      (Value  : Unsigned;
139       Amount : Natural) return Unsigned;
140
141    function Shift_Right
142      (Value  : Unsigned;
143       Amount : Natural) return Unsigned;
144
145    function Shift_Right_Arithmetic
146      (Value  : Unsigned;
147       Amount : Natural) return Unsigned;
148
149    function Rotate_Left
150      (Value  : Unsigned;
151       Amount : Natural) return Unsigned;
152
153    function Rotate_Right
154      (Value  : Unsigned;
155       Amount : Natural) return Unsigned;
156
157    function Shift_Left
158      (Value  : Long_Unsigned;
159       Amount : Natural) return Long_Unsigned;
160
161    function Shift_Right
162      (Value  : Long_Unsigned;
163       Amount : Natural) return Long_Unsigned;
164
165    function Shift_Right_Arithmetic
166      (Value  : Long_Unsigned;
167       Amount : Natural) return Long_Unsigned;
168
169    function Rotate_Left
170      (Value  : Long_Unsigned;
171       Amount : Natural) return Long_Unsigned;
172
173    function Rotate_Right
174      (Value  : Long_Unsigned;
175       Amount : Natural) return Long_Unsigned;
176
177    function Shift_Left
178      (Value  : Long_Long_Unsigned;
179       Amount : Natural) return Long_Long_Unsigned;
180
181    function Shift_Right
182      (Value  : Long_Long_Unsigned;
183       Amount : Natural) return Long_Long_Unsigned;
184
185    function Shift_Right_Arithmetic
186      (Value  : Long_Long_Unsigned;
187       Amount : Natural) return Long_Long_Unsigned;
188
189    function Rotate_Left
190      (Value  : Long_Long_Unsigned;
191       Amount : Natural) return Long_Long_Unsigned;
192
193    function Rotate_Right
194      (Value  : Long_Long_Unsigned;
195       Amount : Natural) return Long_Long_Unsigned;
196
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);
202
203    --  The following definitions are obsolescent. 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?
208
209    subtype Packed_Bytes           is Packed_Bytes4;
210    subtype Packed_Bytes_Unaligned is Packed_Bytes1;
211
212 end System.Unsigned_Types;