| 1 |
------------------------------------------------------------------------------ |
| 2 |
-- -- |
| 3 |
-- GNAT COMPILER COMPONENTS -- |
| 4 |
-- -- |
| 5 |
-- I N T E R F A C E S -- |
| 6 |
-- -- |
| 7 |
-- S p e c -- |
| 8 |
-- -- |
| 9 |
-- Copyright (C) 2002-2025, Free Software Foundation, Inc. -- |
| 10 |
-- -- |
| 11 |
-- This specification is derived from the Ada Reference Manual for use with -- |
| 12 |
-- GNAT. The copyright notice above, and the license provisions that follow -- |
| 13 |
-- apply solely to the implementation dependent sections of this file. -- |
| 14 |
-- -- |
| 15 |
-- GNAT is free software; you can redistribute it and/or modify it under -- |
| 16 |
-- terms of the GNU General Public License as published by the Free Soft- -- |
| 17 |
-- ware Foundation; either version 3, or (at your option) any later ver- -- |
| 18 |
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- |
| 19 |
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- |
| 20 |
-- or FITNESS FOR A PARTICULAR PURPOSE. -- |
| 21 |
-- -- |
| 22 |
-- As a special exception under Section 7 of GPL version 3, you are granted -- |
| 23 |
-- additional permissions described in the GCC Runtime Library Exception, -- |
| 24 |
-- version 3.1, as published by the Free Software Foundation. -- |
| 25 |
-- -- |
| 26 |
-- You should have received a copy of the GNU General Public License and -- |
| 27 |
-- a copy of the GCC Runtime Library Exception along with this program; -- |
| 28 |
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- |
| 29 |
-- <http://www.gnu.org/licenses/>. -- |
| 30 |
-- -- |
| 31 |
-- GNAT was originally developed by the GNAT team at New York University. -- |
| 32 |
-- Extensive contributions were provided by Ada Core Technologies Inc. -- |
| 33 |
-- -- |
| 34 |
------------------------------------------------------------------------------ |
| 35 |
|
| 36 |
-- This is the runtime version of this unit (not used during GNAT build) |
| 37 |
|
| 38 |
-- ``Interfaces`` is the parent of several library packages that declare types |
| 39 |
-- and other entities useful for interfacing to foreign languages as defined |
| 40 |
-- by ARM B.2. |
| 41 |
-- |
| 42 |
-- It defines signed and modular integer types of 8, 16, 32, 64 and 128 bits. |
| 43 |
-- For each such modular type, shifting and rotating intrinsic subprograms |
| 44 |
-- are specified. There is also the definition of IEEE 754 floating point |
| 45 |
-- types (``IEEE_Float_32``, ``IEEE_Float_64``, and ``IEEE_Extended_Float``). |
| 46 |
|
| 47 |
package Interfaces with |
| 48 |
Always_Terminates |
| 49 |
is |
| 50 |
pragma No_Elaboration_Code_All; |
| 51 |
pragma Pure; |
| 52 |
|
| 53 |
pragma Implementation_Defined; |
| 54 |
-- All identifiers in this unit are implementation defined |
| 55 |
|
| 56 |
-- Definitions of 8, 16, 24, 32, 64 and 128 bit signed and unsigned integer |
| 57 |
-- types. |
| 58 |
|
| 59 |
type Integer_8 is range -2 ** 7 .. 2 ** 7 - 1; |
| 60 |
for Integer_8'Size use 8; |
| 61 |
|
| 62 |
type Integer_16 is range -2 ** 15 .. 2 ** 15 - 1; |
| 63 |
for Integer_16'Size use 16; |
| 64 |
|
| 65 |
type Integer_32 is range -2 ** 31 .. 2 ** 31 - 1; |
| 66 |
for Integer_32'Size use 32; |
| 67 |
|
| 68 |
type Integer_64 is new Long_Long_Integer; |
| 69 |
for Integer_64'Size use 64; |
| 70 |
-- We use Long_Long_Integer'First instead of -2 ** 63 to allow this unit to |
| 71 |
-- compile when using custom target configuration files where the maximum |
| 72 |
-- integer is 32 bits. This is useful for static analysis tools such as |
| 73 |
-- SPARK or CodePeer. In the normal case Long_Long_Integer is 64-bits so we |
| 74 |
-- get the desired 64-bit type. |
| 75 |
|
| 76 |
type Integer_128 is new Long_Long_Long_Integer; |
| 77 |
-- We use Long_Long_Long_Integer instead of literal bounds to allow this |
| 78 |
-- unit to be compiled with compilers not supporting 128-bit integers. |
| 79 |
-- We do not put a confirming size clause of 128 bits for the same reason. |
| 80 |
|
| 81 |
type Unsigned_8 is mod 2 ** 8; |
| 82 |
for Unsigned_8'Size use 8; |
| 83 |
|
| 84 |
type Unsigned_16 is mod 2 ** 16; |
| 85 |
for Unsigned_16'Size use 16; |
| 86 |
|
| 87 |
type Unsigned_24 is mod 2 ** 24; |
| 88 |
for Unsigned_24'Size use 24; |
| 89 |
-- Declare this type for compatibility with legacy Ada compilers. |
| 90 |
-- This is particularly useful in the context of CodePeer analysis. |
| 91 |
|
| 92 |
type Unsigned_32 is mod 2 ** 32; |
| 93 |
for Unsigned_32'Size use 32; |
| 94 |
|
| 95 |
type Unsigned_64 is mod 2 ** Long_Long_Integer'Size; |
| 96 |
for Unsigned_64'Size use 64; |
| 97 |
-- See comment on Integer_64 above |
| 98 |
|
| 99 |
type Unsigned_128 is mod 2 ** Long_Long_Long_Integer'Size; |
| 100 |
-- See comment on Integer_128 above |
| 101 |
|
| 102 |
-- Compiler intrinsics implemented by the compiler |
| 103 |
|
| 104 |
function Shift_Left |
| 105 |
(Value : Unsigned_8; |
| 106 |
Amount : Natural) return Unsigned_8 |
| 107 |
with Import, Convention => Intrinsic, Static; |
| 108 |
|
| 109 |
function Shift_Right |
| 110 |
(Value : Unsigned_8; |
| 111 |
Amount : Natural) return Unsigned_8 |
| 112 |
with Import, Convention => Intrinsic, Static; |
| 113 |
|
| 114 |
function Shift_Right_Arithmetic |
| 115 |
(Value : Unsigned_8; |
| 116 |
Amount : Natural) return Unsigned_8 |
| 117 |
with Import, Convention => Intrinsic, Static; |
| 118 |
|
| 119 |
function Rotate_Left |
| 120 |
(Value : Unsigned_8; |
| 121 |
Amount : Natural) return Unsigned_8 |
| 122 |
with Import, Convention => Intrinsic, Static; |
| 123 |
|
| 124 |
function Rotate_Right |
| 125 |
(Value : Unsigned_8; |
| 126 |
Amount : Natural) return Unsigned_8 |
| 127 |
with Import, Convention => Intrinsic, Static; |
| 128 |
|
| 129 |
function Shift_Left |
| 130 |
(Value : Unsigned_16; |
| 131 |
Amount : Natural) return Unsigned_16 |
| 132 |
with Import, Convention => Intrinsic, Static; |
| 133 |
|
| 134 |
function Shift_Right |
| 135 |
(Value : Unsigned_16; |
| 136 |
Amount : Natural) return Unsigned_16 |
| 137 |
with Import, Convention => Intrinsic, Static; |
| 138 |
|
| 139 |
function Shift_Right_Arithmetic |
| 140 |
(Value : Unsigned_16; |
| 141 |
Amount : Natural) return Unsigned_16 |
| 142 |
with Import, Convention => Intrinsic, Static; |
| 143 |
|
| 144 |
function Rotate_Left |
| 145 |
(Value : Unsigned_16; |
| 146 |
Amount : Natural) return Unsigned_16 |
| 147 |
with Import, Convention => Intrinsic, Static; |
| 148 |
|
| 149 |
function Rotate_Right |
| 150 |
(Value : Unsigned_16; |
| 151 |
Amount : Natural) return Unsigned_16 |
| 152 |
with Import, Convention => Intrinsic, Static; |
| 153 |
|
| 154 |
function Shift_Left |
| 155 |
(Value : Unsigned_32; |
| 156 |
Amount : Natural) return Unsigned_32 |
| 157 |
with Import, Convention => Intrinsic, Static; |
| 158 |
|
| 159 |
function Shift_Right |
| 160 |
(Value : Unsigned_32; |
| 161 |
Amount : Natural) return Unsigned_32 |
| 162 |
with Import, Convention => Intrinsic, Static; |
| 163 |
|
| 164 |
function Shift_Right_Arithmetic |
| 165 |
(Value : Unsigned_32; |
| 166 |
Amount : Natural) return Unsigned_32 |
| 167 |
with Import, Convention => Intrinsic, Static; |
| 168 |
|
| 169 |
function Rotate_Left |
| 170 |
(Value : Unsigned_32; |
| 171 |
Amount : Natural) return Unsigned_32 |
| 172 |
with Import, Convention => Intrinsic, Static; |
| 173 |
|
| 174 |
function Rotate_Right |
| 175 |
(Value : Unsigned_32; |
| 176 |
Amount : Natural) return Unsigned_32 |
| 177 |
with Import, Convention => Intrinsic, Static; |
| 178 |
|
| 179 |
function Shift_Left |
| 180 |
(Value : Unsigned_64; |
| 181 |
Amount : Natural) return Unsigned_64 |
| 182 |
with Import, Convention => Intrinsic, Static; |
| 183 |
|
| 184 |
function Shift_Right |
| 185 |
(Value : Unsigned_64; |
| 186 |
Amount : Natural) return Unsigned_64 |
| 187 |
with Import, Convention => Intrinsic, Static; |
| 188 |
|
| 189 |
function Shift_Right_Arithmetic |
| 190 |
(Value : Unsigned_64; |
| 191 |
Amount : Natural) return Unsigned_64 |
| 192 |
with Import, Convention => Intrinsic, Static; |
| 193 |
|
| 194 |
function Rotate_Left |
| 195 |
(Value : Unsigned_64; |
| 196 |
Amount : Natural) return Unsigned_64 |
| 197 |
with Import, Convention => Intrinsic, Static; |
| 198 |
|
| 199 |
function Rotate_Right |
| 200 |
(Value : Unsigned_64; |
| 201 |
Amount : Natural) return Unsigned_64 |
| 202 |
with Import, Convention => Intrinsic, Static; |
| 203 |
|
| 204 |
function Shift_Left |
| 205 |
(Value : Unsigned_128; |
| 206 |
Amount : Natural) return Unsigned_128 |
| 207 |
with Import, Convention => Intrinsic, Static; |
| 208 |
|
| 209 |
function Shift_Right |
| 210 |
(Value : Unsigned_128; |
| 211 |
Amount : Natural) return Unsigned_128 |
| 212 |
with Import, Convention => Intrinsic, Static; |
| 213 |
|
| 214 |
function Shift_Right_Arithmetic |
| 215 |
(Value : Unsigned_128; |
| 216 |
Amount : Natural) return Unsigned_128 |
| 217 |
with Import, Convention => Intrinsic, Static; |
| 218 |
|
| 219 |
function Rotate_Left |
| 220 |
(Value : Unsigned_128; |
| 221 |
Amount : Natural) return Unsigned_128 |
| 222 |
with Import, Convention => Intrinsic, Static; |
| 223 |
|
| 224 |
function Rotate_Right |
| 225 |
(Value : Unsigned_128; |
| 226 |
Amount : Natural) return Unsigned_128 |
| 227 |
with Import, Convention => Intrinsic, Static; |
| 228 |
|
| 229 |
-- IEEE Floating point types |
| 230 |
|
| 231 |
type IEEE_Float_32 is digits 6; |
| 232 |
for IEEE_Float_32'Size use 32; |
| 233 |
|
| 234 |
type IEEE_Float_64 is digits 15; |
| 235 |
for IEEE_Float_64'Size use 64; |
| 236 |
|
| 237 |
-- If there is an IEEE extended float available on the machine, we |
| 238 |
-- assume that it is available as Long_Long_Float. |
| 239 |
-- |
| 240 |
-- Note: it is harmless, and explicitly permitted, to include additional |
| 241 |
-- types in interfaces, so it is not wrong to have IEEE_Extended_Float |
| 242 |
-- defined even if the extended format is not available. |
| 243 |
-- See RM-B.2(11). |
| 244 |
|
| 245 |
type IEEE_Extended_Float is new Long_Long_Float; |
| 246 |
|
| 247 |
end Interfaces; |