PR middle-end/61455
[official-gcc.git] / gcc / ada / s-arit64.ads
blob4eb115305bad059968fc5e07a8a1b9ed094a87f9
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- S Y S T E M . A R I T H _ 6 4 --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2012, 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 ------------------------------------------------------------------------------
32 -- This unit provides software routines for doing arithmetic on 64-bit
33 -- signed integer values in cases where either overflow checking is
34 -- required, or intermediate results are longer than 64 bits.
36 pragma Restrictions (No_Elaboration_Code);
37 -- Allow direct call from gigi generated code
39 with Interfaces;
41 package System.Arith_64 is
42 pragma Pure;
44 subtype Int64 is Interfaces.Integer_64;
46 function Add_With_Ovflo_Check (X, Y : Int64) return Int64;
47 -- Raises Constraint_Error if sum of operands overflows 64 bits,
48 -- otherwise returns the 64-bit signed integer sum.
50 function Subtract_With_Ovflo_Check (X, Y : Int64) return Int64;
51 -- Raises Constraint_Error if difference of operands overflows 64
52 -- bits, otherwise returns the 64-bit signed integer difference.
54 function Multiply_With_Ovflo_Check (X, Y : Int64) return Int64;
55 pragma Export (C, Multiply_With_Ovflo_Check, "__gnat_mulv64");
56 -- Raises Constraint_Error if product of operands overflows 64
57 -- bits, otherwise returns the 64-bit signed integer product.
58 -- GIGI may also call this routine directly.
60 procedure Scaled_Divide
61 (X, Y, Z : Int64;
62 Q, R : out Int64;
63 Round : Boolean);
64 -- Performs the division of (X * Y) / Z, storing the quotient in Q
65 -- and the remainder in R. Constraint_Error is raised if Z is zero,
66 -- or if the quotient does not fit in 64-bits. Round indicates if
67 -- the result should be rounded. If Round is False, then Q, R are
68 -- the normal quotient and remainder from a truncating division.
69 -- If Round is True, then Q is the rounded quotient. The remainder
70 -- R is not affected by the setting of the Round flag.
72 procedure Double_Divide
73 (X, Y, Z : Int64;
74 Q, R : out Int64;
75 Round : Boolean);
76 -- Performs the division X / (Y * Z), storing the quotient in Q and
77 -- the remainder in R. Constraint_Error is raised if Y or Z is zero,
78 -- or if the quotient does not fit in 64-bits. Round indicates if the
79 -- result should be rounded. If Round is False, then Q, R are the normal
80 -- quotient and remainder from a truncating division. If Round is True,
81 -- then Q is the rounded quotient. The remainder R is not affected by the
82 -- setting of the Round flag.
84 end System.Arith_64;