1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
5 -- S Y S T E M . B I G N U M S --
9 -- Copyright (C) 2012-2020, Free Software Foundation, Inc. --
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. --
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. --
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/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 ------------------------------------------------------------------------------
32 with System.Generic_Bignums;
33 with Ada.Unchecked_Conversion;
35 package body System.Bignums is
37 package Sec_Stack_Bignums is new
38 System.Generic_Bignums (Use_Secondary_Stack => True);
39 use Sec_Stack_Bignums;
41 function "+" is new Ada.Unchecked_Conversion
42 (Bignum, Sec_Stack_Bignums.Bignum);
44 function "-" is new Ada.Unchecked_Conversion
45 (Sec_Stack_Bignums.Bignum, Bignum);
47 function Big_Add (X, Y : Bignum) return Bignum is
48 (-Sec_Stack_Bignums.Big_Add (+X, +Y));
50 function Big_Sub (X, Y : Bignum) return Bignum is
51 (-Sec_Stack_Bignums.Big_Sub (+X, +Y));
53 function Big_Mul (X, Y : Bignum) return Bignum is
54 (-Sec_Stack_Bignums.Big_Mul (+X, +Y));
56 function Big_Div (X, Y : Bignum) return Bignum is
57 (-Sec_Stack_Bignums.Big_Div (+X, +Y));
59 function Big_Exp (X, Y : Bignum) return Bignum is
60 (-Sec_Stack_Bignums.Big_Exp (+X, +Y));
62 function Big_Mod (X, Y : Bignum) return Bignum is
63 (-Sec_Stack_Bignums.Big_Mod (+X, +Y));
65 function Big_Rem (X, Y : Bignum) return Bignum is
66 (-Sec_Stack_Bignums.Big_Rem (+X, +Y));
68 function Big_Neg (X : Bignum) return Bignum is
69 (-Sec_Stack_Bignums.Big_Neg (+X));
71 function Big_Abs (X : Bignum) return Bignum is
72 (-Sec_Stack_Bignums.Big_Abs (+X));
74 function Big_EQ (X, Y : Bignum) return Boolean is
75 (Sec_Stack_Bignums.Big_EQ (+X, +Y));
76 function Big_NE (X, Y : Bignum) return Boolean is
77 (Sec_Stack_Bignums.Big_NE (+X, +Y));
78 function Big_GE (X, Y : Bignum) return Boolean is
79 (Sec_Stack_Bignums.Big_GE (+X, +Y));
80 function Big_LE (X, Y : Bignum) return Boolean is
81 (Sec_Stack_Bignums.Big_LE (+X, +Y));
82 function Big_GT (X, Y : Bignum) return Boolean is
83 (Sec_Stack_Bignums.Big_GT (+X, +Y));
84 function Big_LT (X, Y : Bignum) return Boolean is
85 (Sec_Stack_Bignums.Big_LT (+X, +Y));
87 function Bignum_In_LLI_Range (X : Bignum) return Boolean is
88 (Sec_Stack_Bignums.Bignum_In_LLI_Range (+X));
90 function To_Bignum (X : Long_Long_Integer) return Bignum is
91 (-Sec_Stack_Bignums.To_Bignum (X));
93 function From_Bignum (X : Bignum) return Long_Long_Integer is
94 (Sec_Stack_Bignums.From_Bignum (+X));