| 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 |
------------------------------------------------------------------------------ |
| 31 |
|
| 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. |
| 37 |
|
| 38 |
package System.Unsigned_Types is |
| 39 |
pragma Pure; |
| 40 |
|
| 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; |
| 46 |
|
| 47 |
type Float_Unsigned is mod 2 ** Float'Size; |
| 48 |
-- Used in the implementation of Is_Negative intrinsic (see Exp_Intr) |
| 49 |
|
| 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. |
| 56 |
|
| 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 |
| 64 |
-- for details. |
| 65 |
|
| 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). |
| 75 |
|
| 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). |
| 85 |
|
| 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 |
| 90 |
|
| 91 |
subtype Bytes_F is Packed_Bytes4 (1 .. Float'Size / 8); |
| 92 |
-- Type used in implementation of Is_Negative intrinsic (see Exp_Intr) |
| 93 |
|
| 94 |
function Shift_Left |
| 95 |
(Value : Short_Short_Unsigned; |
| 96 |
Amount : Natural) return Short_Short_Unsigned; |
| 97 |
|
| 98 |
function Shift_Right |
| 99 |
(Value : Short_Short_Unsigned; |
| 100 |
Amount : Natural) return Short_Short_Unsigned; |
| 101 |
|
| 102 |
function Shift_Right_Arithmetic |
| 103 |
(Value : Short_Short_Unsigned; |
| 104 |
Amount : Natural) return Short_Short_Unsigned; |
| 105 |
|
| 106 |
function Rotate_Left |
| 107 |
(Value : Short_Short_Unsigned; |
| 108 |
Amount : Natural) return Short_Short_Unsigned; |
| 109 |
|
| 110 |
function Rotate_Right |
| 111 |
(Value : Short_Short_Unsigned; |
| 112 |
Amount : Natural) return Short_Short_Unsigned; |
| 113 |
|
| 114 |
function Shift_Left |
| 115 |
(Value : Short_Unsigned; |
| 116 |
Amount : Natural) return Short_Unsigned; |
| 117 |
|
| 118 |
function Shift_Right |
| 119 |
(Value : Short_Unsigned; |
| 120 |
Amount : Natural) return Short_Unsigned; |
| 121 |
|
| 122 |
function Shift_Right_Arithmetic |
| 123 |
(Value : Short_Unsigned; |
| 124 |
Amount : Natural) return Short_Unsigned; |
| 125 |
|
| 126 |
function Rotate_Left |
| 127 |
(Value : Short_Unsigned; |
| 128 |
Amount : Natural) return Short_Unsigned; |
| 129 |
|
| 130 |
function Rotate_Right |
| 131 |
(Value : Short_Unsigned; |
| 132 |
Amount : Natural) return Short_Unsigned; |
| 133 |
|
| 134 |
function Shift_Left |
| 135 |
(Value : Unsigned; |
| 136 |
Amount : Natural) return Unsigned; |
| 137 |
|
| 138 |
function Shift_Right |
| 139 |
(Value : Unsigned; |
| 140 |
Amount : Natural) return Unsigned; |
| 141 |
|
| 142 |
function Shift_Right_Arithmetic |
| 143 |
(Value : Unsigned; |
| 144 |
Amount : Natural) return Unsigned; |
| 145 |
|
| 146 |
function Rotate_Left |
| 147 |
(Value : Unsigned; |
| 148 |
Amount : Natural) return Unsigned; |
| 149 |
|
| 150 |
function Rotate_Right |
| 151 |
(Value : Unsigned; |
| 152 |
Amount : Natural) return Unsigned; |
| 153 |
|
| 154 |
function Shift_Left |
| 155 |
(Value : Long_Unsigned; |
| 156 |
Amount : Natural) return Long_Unsigned; |
| 157 |
|
| 158 |
function Shift_Right |
| 159 |
(Value : Long_Unsigned; |
| 160 |
Amount : Natural) return Long_Unsigned; |
| 161 |
|
| 162 |
function Shift_Right_Arithmetic |
| 163 |
(Value : Long_Unsigned; |
| 164 |
Amount : Natural) return Long_Unsigned; |
| 165 |
|
| 166 |
function Rotate_Left |
| 167 |
(Value : Long_Unsigned; |
| 168 |
Amount : Natural) return Long_Unsigned; |
| 169 |
|
| 170 |
function Rotate_Right |
| 171 |
(Value : Long_Unsigned; |
| 172 |
Amount : Natural) return Long_Unsigned; |
| 173 |
|
| 174 |
function Shift_Left |
| 175 |
(Value : Long_Long_Unsigned; |
| 176 |
Amount : Natural) return Long_Long_Unsigned; |
| 177 |
|
| 178 |
function Shift_Right |
| 179 |
(Value : Long_Long_Unsigned; |
| 180 |
Amount : Natural) return Long_Long_Unsigned; |
| 181 |
|
| 182 |
function Shift_Right_Arithmetic |
| 183 |
(Value : Long_Long_Unsigned; |
| 184 |
Amount : Natural) return Long_Long_Unsigned; |
| 185 |
|
| 186 |
function Rotate_Left |
| 187 |
(Value : Long_Long_Unsigned; |
| 188 |
Amount : Natural) return Long_Long_Unsigned; |
| 189 |
|
| 190 |
function Rotate_Right |
| 191 |
(Value : Long_Long_Unsigned; |
| 192 |
Amount : Natural) return Long_Long_Unsigned; |
| 193 |
|
| 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); |
| 199 |
|
| 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? |
| 205 |
|
| 206 |
subtype Packed_Bytes is Packed_Bytes4; |
| 207 |
subtype Packed_Bytes_Unaligned is Packed_Bytes1; |
| 208 |
|
| 209 |
end System.Unsigned_Types; |