Merge from mainline (167278:168000).
[official-gcc/graphite-test-results.git] / gcc / ada / s-arit64.ads
blob8ecbfede1b71e29fa52231ee0c0ecbcc0a4cb024
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-2009, 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 with Interfaces;
38 package System.Arith_64 is
39 pragma Pure;
41 subtype Int64 is Interfaces.Integer_64;
43 function Add_With_Ovflo_Check (X, Y : Int64) return Int64;
44 -- Raises Constraint_Error if sum of operands overflows 64 bits,
45 -- otherwise returns the 64-bit signed integer sum.
47 function Subtract_With_Ovflo_Check (X, Y : Int64) return Int64;
48 -- Raises Constraint_Error if difference of operands overflows 64
49 -- bits, otherwise returns the 64-bit signed integer difference.
51 function Multiply_With_Ovflo_Check (X, Y : Int64) return Int64;
52 -- Raises Constraint_Error if product of operands overflows 64
53 -- bits, otherwise returns the 64-bit signed integer product.
55 procedure Scaled_Divide
56 (X, Y, Z : Int64;
57 Q, R : out Int64;
58 Round : Boolean);
59 -- Performs the division of (X * Y) / Z, storing the quotient in Q
60 -- and the remainder in R. Constraint_Error is raised if Z is zero,
61 -- or if the quotient does not fit in 64-bits. Round indicates if
62 -- the result should be rounded. If Round is False, then Q, R are
63 -- the normal quotient and remainder from a truncating division.
64 -- If Round is True, then Q is the rounded quotient. The remainder
65 -- R is not affected by the setting of the Round flag.
67 procedure Double_Divide
68 (X, Y, Z : Int64;
69 Q, R : out Int64;
70 Round : Boolean);
71 -- Performs the division X / (Y * Z), storing the quotient in Q and
72 -- the remainder in R. Constraint_Error is raised if Y or Z is zero,
73 -- or if the quotient does not fit in 64-bits. Round indicates if the
74 -- result should be rounded. If Round is False, then Q, R are the normal
75 -- quotient and remainder from a truncating division. If Round is True,
76 -- then Q is the rounded quotient. The remainder R is not affected by the
77 -- setting of the Round flag.
79 end System.Arith_64;