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