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-2013, 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 for Packed_Byte'Size use 8; 54 -- Component type for Packed_Bytes array 55 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. 64 65 type Packed_Bytes2 is new Packed_Bytes1; 66 for Packed_Bytes2'Alignment use Integer'Min (2, Standard'Maximum_Alignment); 67 -- This is the type used to implement packed arrays where an alignment 68 -- of 2 (is possible) is helpful for maximum efficiency of the get and 69 -- set routines in the corresponding library unit. This is true of all 70 -- component sizes that are even but not divisible by 4 (other than 2 for 71 -- which we use direct masking operations). In such cases, the clusters 72 -- can be assumed to be 2-byte aligned if the array is aligned. See for 73 -- example System.Pack_10 in file s-pack10). 74 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 (if possible) is helpful for maximum efficiency of the get and 79 -- set routines in the corresponding library unit. This is true of all 80 -- component sizes that are divisible by 4 (other than powers of 2, which 81 -- are either handled by direct masking or not packed at all). In such 82 -- cases the clusters can be assumed to be 4-byte aligned if the array 83 -- is aligned (see System.Pack_12 in file s-pack12 as an example). 84 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 89 90 subtype Bytes_F is Packed_Bytes4 (1 .. Float'Size / 8); 91 -- Type used in implementation of Is_Negative intrinsic (see Exp_Intr) 92 93 function Shift_Left 94 (Value : Short_Short_Unsigned; 95 Amount : Natural) return Short_Short_Unsigned; 96 97 function Shift_Right 98 (Value : Short_Short_Unsigned; 99 Amount : Natural) return Short_Short_Unsigned; 100 101 function Shift_Right_Arithmetic 102 (Value : Short_Short_Unsigned; 103 Amount : Natural) return Short_Short_Unsigned; 104 105 function Rotate_Left 106 (Value : Short_Short_Unsigned; 107 Amount : Natural) return Short_Short_Unsigned; 108 109 function Rotate_Right 110 (Value : Short_Short_Unsigned; 111 Amount : Natural) return Short_Short_Unsigned; 112 113 function Shift_Left 114 (Value : Short_Unsigned; 115 Amount : Natural) return Short_Unsigned; 116 117 function Shift_Right 118 (Value : Short_Unsigned; 119 Amount : Natural) return Short_Unsigned; 120 121 function Shift_Right_Arithmetic 122 (Value : Short_Unsigned; 123 Amount : Natural) return Short_Unsigned; 124 125 function Rotate_Left 126 (Value : Short_Unsigned; 127 Amount : Natural) return Short_Unsigned; 128 129 function Rotate_Right 130 (Value : Short_Unsigned; 131 Amount : Natural) return Short_Unsigned; 132 133 function Shift_Left 134 (Value : Unsigned; 135 Amount : Natural) return Unsigned; 136 137 function Shift_Right 138 (Value : Unsigned; 139 Amount : Natural) return Unsigned; 140 141 function Shift_Right_Arithmetic 142 (Value : Unsigned; 143 Amount : Natural) return Unsigned; 144 145 function Rotate_Left 146 (Value : Unsigned; 147 Amount : Natural) return Unsigned; 148 149 function Rotate_Right 150 (Value : Unsigned; 151 Amount : Natural) return Unsigned; 152 153 function Shift_Left 154 (Value : Long_Unsigned; 155 Amount : Natural) return Long_Unsigned; 156 157 function Shift_Right 158 (Value : Long_Unsigned; 159 Amount : Natural) return Long_Unsigned; 160 161 function Shift_Right_Arithmetic 162 (Value : Long_Unsigned; 163 Amount : Natural) return Long_Unsigned; 164 165 function Rotate_Left 166 (Value : Long_Unsigned; 167 Amount : Natural) return Long_Unsigned; 168 169 function Rotate_Right 170 (Value : Long_Unsigned; 171 Amount : Natural) return Long_Unsigned; 172 173 function Shift_Left 174 (Value : Long_Long_Unsigned; 175 Amount : Natural) return Long_Long_Unsigned; 176 177 function Shift_Right 178 (Value : Long_Long_Unsigned; 179 Amount : Natural) return Long_Long_Unsigned; 180 181 function Shift_Right_Arithmetic 182 (Value : Long_Long_Unsigned; 183 Amount : Natural) return Long_Long_Unsigned; 184 185 function Rotate_Left 186 (Value : Long_Long_Unsigned; 187 Amount : Natural) return Long_Long_Unsigned; 188 189 function Rotate_Right 190 (Value : Long_Long_Unsigned; 191 Amount : Natural) return Long_Long_Unsigned; 192 193 pragma Import (Intrinsic, Shift_Left); 194 pragma Import (Intrinsic, Shift_Right); 195 pragma Import (Intrinsic, Shift_Right_Arithmetic); 196 pragma Import (Intrinsic, Rotate_Left); 197 pragma Import (Intrinsic, Rotate_Right); 198 199 -- The following definitions are obsolescent. They were needed by the 200 -- previous version of the compiler and runtime, but are not needed 201 -- by the current version. We retain them to help with bootstrap path 202 -- problems. Also they seem harmless, and if any user programs have 203 -- been (rather improperly) using these types, why discombobulate them? 204 205 subtype Packed_Bytes is Packed_Bytes4; 206 subtype Packed_Bytes_Unaligned is Packed_Bytes1; 207 208end System.Unsigned_Types; 209