diff -Nru libgmpada-1.0/changelog libgmpada-1.1/changelog --- libgmpada-1.0/changelog 2016-04-28 16:52:33.000000000 +0000 +++ libgmpada-1.1/changelog 2017-07-06 13:14:53.000000000 +0000 @@ -1,4 +1,4 @@ The full activity log is available on a public HTML view of the monotone repository: -http://mtn-host.prjek.net/viewmtn/libgmpada/branch/changes/net.prjek.mtn-host.libgmpada +http://www.ada-france.org:8081/branch/changes/net.prjek.mtn-host.libgmpada diff -Nru libgmpada-1.0/debian/ada_libraries libgmpada-1.1/debian/ada_libraries --- libgmpada-1.0/debian/ada_libraries 1970-01-01 00:00:00.000000000 +0000 +++ libgmpada-1.1/debian/ada_libraries 2017-08-09 17:53:16.000000000 +0000 @@ -0,0 +1 @@ +debian/fake.gpr diff -Nru libgmpada-1.0/debian/changelog libgmpada-1.1/debian/changelog --- libgmpada-1.0/debian/changelog 2017-04-07 13:28:38.000000000 +0000 +++ libgmpada-1.1/debian/changelog 2017-08-09 17:54:28.000000000 +0000 @@ -1,14 +1,20 @@ -libgmpada (1.0-3build2) zesty; urgency=medium +libgmpada (1.1-2) unstable; urgency=medium - * No-change rebuild for ada transition. + * Upload to unstable. Change versions: SO (runtime) and ALI (-dev). + * Standards-Version: 4.0.1. Priority: optional. + * Drop explicit rules targets confusing dh. - -- Adam Conrad Fri, 07 Apr 2017 07:28:38 -0600 + -- Nicolas Boulenguez Wed, 09 Aug 2017 19:54:28 +0200 -libgmpada (1.0-3build1) zesty; urgency=medium +libgmpada (1.1-1) experimental; urgency=medium - * No-change rebuild for gnat transition. + * New upstream built with gnat-7. No ALI/SO change in experimental. + Drop dependency on mpfr and kfreebsd-amd64-gnat6-bug-in-test.diff. + * Drop -pie from explicit hardening flags. + * Standards-Version: 4.0.0. HTTPS version of copyright-format URL. + * Debhelper 10. - -- Adam Conrad Tue, 04 Apr 2017 02:28:23 -0600 + -- Nicolas Boulenguez Thu, 06 Jul 2017 12:56:40 +0200 libgmpada (1.0-3) unstable; urgency=medium diff -Nru libgmpada-1.0/debian/compat libgmpada-1.1/debian/compat --- libgmpada-1.0/debian/compat 2016-05-16 14:55:13.000000000 +0000 +++ libgmpada-1.1/debian/compat 2017-08-09 17:53:16.000000000 +0000 @@ -1 +1 @@ -9 +10 diff -Nru libgmpada-1.0/debian/control libgmpada-1.1/debian/control --- libgmpada-1.0/debian/control 2016-05-16 14:55:13.000000000 +0000 +++ libgmpada-1.1/debian/control 2017-08-09 17:54:28.000000000 +0000 @@ -1,32 +1,32 @@ Source: libgmpada Section: libdevel -Priority: extra +Priority: optional Maintainer: Nicolas Boulenguez -Build-Depends: dpkg-dev (>= 1.16.1), debhelper (>= 9), - gnat, gnat-6, +Build-Depends: dpkg-dev (>= 1.16.1), debhelper (>= 10), + gnat, gnat-7, +# This line is parsed by debian/rules. dh-ada-library (>= 6.7), # dh-ada-library >= 6.7 stops requiring -dbg packages. - libgmp-dev, libmpfr-dev + libgmp-dev # dpkg-dev >= 1.16.1 provides /usr/share/dpkg/default.mk. -Standards-Version: 3.9.8 +Standards-Version: 4.0.1 Vcs-Browser: http://www.ada-france.org:8081/branch/changes/org.debian.libgmpada Vcs-Mtn: www.ada-france.org org.debian.libgmpada Homepage: http://nicolas.boulenguez.free.fr -Package: libgmpada6-dev +Package: libgmpada7-dev Architecture: any Depends: ${misc:Depends}, ${ada:Depends}, - libgmp-dev, libmpfr-dev + libgmp-dev Description: Ada binding to the GNU MultiPrecision library: development GMPAda allows programmers to use the GNU MultiPrecision library within the Ada language: unbounded integers, rationals and - floats. Experimental support for mpfr's better float rounding is - provided. + floats. . Install this package if you want to write programs that use libgmpada. -Package: libgmpada4 +Package: libgmpada5 Section: libs Architecture: any Multi-Arch: same @@ -35,7 +35,6 @@ Description: Ada binding to the GNU MultiPrecision library: shared library GMPAda allows programmers to use the GNU MultiPrecision library within the Ada language: unbounded integers, rationals and - floats. Experimental support for mpfr's better float rounding is - provided. + floats. . This package contains the runtime shared library. diff -Nru libgmpada-1.0/debian/copyright libgmpada-1.1/debian/copyright --- libgmpada-1.0/debian/copyright 2016-05-16 14:55:13.000000000 +0000 +++ libgmpada-1.1/debian/copyright 2017-08-09 17:53:16.000000000 +0000 @@ -1,8 +1,8 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: libgmpada Upstream-Contact: http://nicolas.boulenguez.free.fr Files: * -Copyright: Copyright (C) 2007-2016 Nicolas Boulenguez +Copyright: Copyright (C) 2007-2017 Nicolas Boulenguez License: GPL-3+ GNU GPL v3 or later; see /usr/share/common-licenses/GPL-3. diff -Nru libgmpada-1.0/debian/examples libgmpada-1.1/debian/examples --- libgmpada-1.0/debian/examples 2016-05-16 14:55:13.000000000 +0000 +++ libgmpada-1.1/debian/examples 2017-08-09 17:53:16.000000000 +0000 @@ -1 +1 @@ -demo/demo.adb +demo.adb diff -Nru libgmpada-1.0/debian/fake.gpr libgmpada-1.1/debian/fake.gpr --- libgmpada-1.0/debian/fake.gpr 2016-05-16 14:55:13.000000000 +0000 +++ libgmpada-1.1/debian/fake.gpr 2017-08-09 17:53:16.000000000 +0000 @@ -6,5 +6,5 @@ for Source_Dirs use ("../src"); for Library_Dir use "../obj"; -- shared library for Object_Dir use "../obj-dynamic"; -- ALI files - for Library_Options use External_As_List ("LDLIBS", " "); + for Library_Options use ("-lgmp"); end Fake; diff -Nru libgmpada-1.0/debian/patches/buildflags-for-demo.diff libgmpada-1.1/debian/patches/buildflags-for-demo.diff --- libgmpada-1.0/debian/patches/buildflags-for-demo.diff 2016-05-16 15:31:44.000000000 +0000 +++ libgmpada-1.1/debian/patches/buildflags-for-demo.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -Description: Pass build flags to gnatmake when building the project demo. - This is quite useful in order to activate assertions. -Author: Nicolas Boulenguez - ---- a/Makefile -+++ b/Makefile -@@ -146,7 +146,9 @@ - - # This test will fail once gnatmake drops project support, but for - # now we can test projects without gprbuild. -- gnatmake -aPdemo-install/$(GPR_DIR) -Pdemo/demo.gpr -+ gnatmake -aPdemo-install/$(GPR_DIR) -Pdemo/demo.gpr $(GNATMAKE_OPTIONS) \ -+ -cargs $(ADAFLAGS) \ -+ -largs $(LDFLAGS) - LD_LIBRARY_PATH=demo-install/$(LIB_DIR) demo/obj-project/demo - - gnatmake demo/demo.adb -o demo/obj-static/demo -D demo/obj-static $(GNATMAKE_OPTIONS) \ diff -Nru libgmpada-1.0/debian/patches/kfreebds-amd64-gnat6-bug-in-test.diff libgmpada-1.1/debian/patches/kfreebds-amd64-gnat6-bug-in-test.diff --- libgmpada-1.0/debian/patches/kfreebds-amd64-gnat6-bug-in-test.diff 2016-05-16 15:30:49.000000000 +0000 +++ libgmpada-1.1/debian/patches/kfreebds-amd64-gnat6-bug-in-test.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -Description: Fix test for gnat-6 on kfreebsd-amd64. - If the objects are not available when building demo.adb, - the produced executable crashes with a segmentation fault. - . - This is probably a bug in gnat-6, as the same test has been compiling - for years on the same architecture, and the problem disappears when - some generics are replaced with copies, or when some types finalized - without Ada.Finalization, or when assertions are enabled. -Author: Nicolas Boulenguez - ---- a/Makefile -+++ b/Makefile -@@ -137,6 +137,8 @@ - mkdir -p demo-install - $(MAKE) install DESTDIR=demo-install - -+ cp obj-dynamic/*.o demo-install/$(ALI_DIR)/$(LIB_NAME) -+ - gnatmake demo/demo.adb -o demo/obj-dynamic/demo -D demo/obj-dynamic $(GNATMAKE_OPTIONS) \ - -aIdemo-install/$(SRC_DIR)/$(LIB_NAME) \ - -aOdemo-install/$(ALI_DIR)/$(LIB_NAME) \ diff -Nru libgmpada-1.0/debian/patches/series libgmpada-1.1/debian/patches/series --- libgmpada-1.0/debian/patches/series 2016-05-16 15:11:28.000000000 +0000 +++ libgmpada-1.1/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -buildflags-for-demo.diff -kfreebds-amd64-gnat6-bug-in-test.diff diff -Nru libgmpada-1.0/debian/rules libgmpada-1.1/debian/rules --- libgmpada-1.0/debian/rules 2016-05-16 16:05:03.000000000 +0000 +++ libgmpada-1.1/debian/rules 2017-08-09 17:53:16.000000000 +0000 @@ -5,7 +5,7 @@ ############## # Copyright (c) 2003-2009 Ludovic Brenta -# Copyright (c) 2009-2016 Nicolas Boulenguez +# Copyright (c) 2009-2017 Nicolas Boulenguez # This build script is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as @@ -27,32 +27,31 @@ # Set some variables # ###################### -DEB_BUILD_MAINT_OPTIONS=hardening=+all,-pie +define new_line := + + +endef +$(eval $(addsuffix $(new_line),$(shell sed -n '\ + s/^ gnat, gnat-\([0-9.]\+\),$$/ \ + GNAT_VERSION:=\1 \ + /p;\ + s/^Package: lib[a-z-]\+\([0-9.]\+\)$$/ \ + SOVERSION:=\1 \ + /p;\ + ' debian/control))) + +DEB_BUILD_MAINT_OPTIONS := hardening=+all include /usr/share/dpkg/default.mk -include /usr/share/ada/debian_packaging*.mk +include /usr/share/ada/debian_packaging-$(GNAT_VERSION).mk ADAFLAGS += -gnatn # This is very useful for the thin binding. -LIB_NAME := $(patsubst lib%,%,$(DEB_SOURCE)) - -SOVERSION := $(shell sed -n -e "s/^Package: lib$(LIB_NAME)\([[:digit:]]\+\)$$/\1/p" debian/control) -ifndef SOVERSION - $(warning Could not guess SOVERSION from debian/control) - # Not error. Policy defines targets that may be run from outside build dir. -endif - ###################### # debhelper overrides ###################### -# Uncomment this to turn on verbose mode. -# export DH_VERBOSE=1 - -POLICY_TARGETS := binary binary-arch binary-indep build build-arch \ - build-indep clean -.PHONY: $(POLICY_TARGETS) -$(POLICY_TARGETS): +%: dh $@ --with ada-library OPTIONS_FOR_UPSTREAM_MAKE = $(foreach var,\ @@ -67,16 +66,6 @@ # Ignore this target from upstream Makefile. .PHONY: override_dh_auto_install -.PHONY: override_dh_ada_library -override_dh_ada_library: - dh_ada_library \ - LDLIBS="`sed -n '/^LDLIBS := /{s///;p;q}' Makefile`" debian/fake.gpr - .PHONY: override_dh_compress override_dh_compress: - dh_compress --all \ - --exclude=.ads \ - --exclude=.adb \ - --exclude=Makefile \ - --exclude=.c \ - --exclude=.h + dh_compress --all $(addprefix --exclude=,.ads .adb Makefile .c .h) diff -Nru libgmpada-1.0/debian/tests/link-with-shared libgmpada-1.1/debian/tests/link-with-shared --- libgmpada-1.0/debian/tests/link-with-shared 2016-05-16 16:13:52.000000000 +0000 +++ libgmpada-1.1/debian/tests/link-with-shared 2017-08-09 17:53:16.000000000 +0000 @@ -7,7 +7,7 @@ cat > p.gpr < --- --- This program is free software: you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation, either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program. If not, see . - -with Ada.Directories; -with Ada.Text_IO; -with GNU_Multiple_Precision; use GNU_Multiple_Precision; -with GNU_Multiple_Precision.Big_Integers; -use GNU_Multiple_Precision.Big_Integers; -with GNU_Multiple_Precision.Big_Floats; -use GNU_Multiple_Precision.Big_Floats; -with GNU_Multiple_Precision.Big_Rationals; -with GNU_Multiple_Precision.Text_IO; -with GNU_Multiple_Precision.Random_Numbers; -with Ada.Integer_Text_IO; -with Ada.Streams.Stream_IO; -with Ada.Float_Text_IO; - -procedure Demo is - - Output_File : constant String := "output_file"; - - procedure Stream_IO_Random_Demo; - procedure Text_IO_Demo; - procedure Rationals_Demo; - procedure Float_Demo; - procedure Arithmetic_Demo; - procedure Mpfr_Demo; - - package IIC is new Big_Integers.Integer_Conversions (Integer); - package RIC is new Big_Rationals.Integer_Conversions (Integer); - package RFC is new Big_Rationals.Float_Conversions (Float); - package FIC is new Big_Floats.Integer_Conversions (Integer); - package FFC is new Big_Floats.Float_Conversions (Float); - - procedure Stream_IO_Random_Demo - is - -- Generates random numbers in -50 .. +50, outputs them, then - -- inputs and checks them. - use Random_Numbers, Ada.Streams.Stream_IO, IIC, FFC, RFC, Big_Rationals; - File : File_Type; - G : Generator; - Fifty : constant Big_Integer := To_Big_Integer (50); - Hundred_And_One : constant Big_Integer := To_Big_Integer (101); - Z : Big_Integer; - begin - Create (File, Out_File, Output_File); - Reset (G, 0); - for I in 1 .. 10 loop - Random (Z, G, Hundred_And_One); - Subtract (Z, Z, Fifty); - Big_Integer'Output (Stream (File), Z); - end loop; - Big_Rational'Write (Stream (File), To_Big_Rational (314159.0)); - Big_Float'Write (Stream (File), To_Big_Float (0.000000314)); - Close (File); - Open (File, In_File, Output_File); - Reset (G, 0); - for I in 1 .. 10 loop - Random (Z, G, Hundred_And_One); - pragma Assert (Big_Integer'Input (Stream (File)) + Fifty = Z); - end loop; - pragma Assert (Big_Rational'Input (Stream (File)) - = To_Big_Rational (314159.0)); - pragma Assert (Big_Float'Input (Stream (File)) - = To_Big_Float (0.000000314)); - Close (File); - Ada.Directories.Delete_File (Output_File); - exception - when others => - if Is_Open (File) then - Close (File); - end if; - if Ada.Directories.Exists (Output_File) then - Ada.Directories.Delete_File (Output_File); - end if; - raise; - end Stream_IO_Random_Demo; - - procedure Text_IO_Demo - is - use Ada.Text_IO, Ada.Integer_Text_IO, Text_IO, IIC, FFC, - Ada.Float_Text_IO; - File : File_Type; - Buffer, Buffer2 : String (1 .. 20); - Last : Positive; - Z : Big_Integer; - F : Big_Float; - begin - Get ("0", Z, Last); - pragma Assert (Last = 1 and Image (Z) = " 0" and Z = Value (" 0")); - Get (" -23+z", Z, Last); - pragma Assert (Last = 4 and Image (Z) = "-23" and Z = Value (" -23 ")); - Put (Buffer, -23); - Put (Buffer2, Z); - pragma Assert (Buffer = Buffer2); - Put (Buffer, -23, 16); - Put (Buffer2, Z, 16); - pragma Assert (Buffer = Buffer2); - Get (" +1_6#F_F#e2G", Z, Last); - pragma Assert (Last = 12 and Image (Z) = " 25500" - and Z = Value (" 25500 ")); - Get ("-10#2#E4z", F, Last); - pragma Assert (Last = 8 and Value (" -2.0E+4 ") = F); - Get ("-10#2.0#E4z", F, Last); - pragma Assert (Last = 10 and Value (" -2.0E+4 ") = F); - Put (Buffer, -10#2.0#E4, Aft => 0, Exp => 0); - Put (Buffer2, F, Aft => 0, Exp => 0); - pragma Assert (Buffer = Buffer2); - Put (Buffer, -10#2.0#E4, Aft => 8, Exp => 0); - Put (Buffer2, F, Aft => 8, Exp => 0); - pragma Assert (Buffer = Buffer2); - Get (".25s", F, Last); - pragma Assert (Last = 3 and Value (" 2.5E-1 ") = F); - Put (Buffer, F); - Put (Buffer2, 0.25); - pragma Assert (Buffer = Buffer2); - Get ("-2#011.1#E+3s", F, Last); - pragma Assert (Last = 12 and Value (" -28 ") = F); - Put (Buffer, F, Aft => 0, Exp => 3); - Put (Buffer2, -2#011.1#E+3, Aft => 0, Exp => 3); - pragma Assert (Buffer = Buffer2); - Create (File, Out_File, Output_File); - for I in -2 .. 2 loop - Set (Z, 10 * I); - pragma Assert (Integer'Image (10 * I) = Image (Z)); - Put (Buffer, 10 * I); - Put (Buffer2, Z); - pragma Assert (Buffer = Buffer2); - Put (File, 10 * I, 10); Put (File, Z, 10); - Put (File, ' '); Put (File, 10 * I); - New_Line (File); - Put (File, Z); - New_Line (File); - Set (F, Float (I) * 0.1); - Put (Buffer, Float (I) * 0.1, Aft => 6, Exp => 0); - Put (Buffer2, F, Aft => 6, Exp => 0); - pragma Assert (Buffer = Buffer2); - Put (Buffer, Float (I) * 0.1, Aft => 0); - Put (Buffer2, F, Aft => 0); - pragma Assert (Buffer = Buffer2); - Put (Buffer, Float (I) * 0.1, Aft => 6, Exp => 1); - Put (Buffer2, F, Aft => 6, Exp => 1); - pragma Assert (Buffer = Buffer2); - end loop; - Close (File); - Open (File, In_File, Output_File); - for I in -2 .. 2 loop - Get (File, Z, 10); pragma Assert (To_Num (Z) = 10 * I); - Get (File, Z, 10); pragma Assert (To_Num (Z) = 10 * I); - Get (File, Z); pragma Assert (To_Num (Z) = 10 * I); - Get (File, Z); pragma Assert (To_Num (Z) = 10 * I); - Skip_Line (File); - end loop; - Close (File); - Ada.Directories.Delete_File (Output_File); - exception - when others => - if Is_Open (File) then - Close (File); - end if; - if Ada.Directories.Exists (Output_File) then - Ada.Directories.Delete_File (Output_File); - end if; - raise; - end Text_IO_Demo; - - procedure Rationals_Demo - is - use Big_Rationals, RIC, Text_IO; - S : String (1 .. 8); - Q : Big_Rational; - begin - Set (Q, -1, 2); - pragma Assert (Image (Q) = "-1/2"); - Put (S, Q); pragma Assert (S = " -1/2"); - Put (S, Q, 2); pragma Assert (S = "-2#1/10#"); - Set (Q, 1, 2); - pragma Assert (Image (Q) = " 1/2"); - Put (S, Q); pragma Assert (S = " 1/2"); - Put (S, Q, 16); pragma Assert (S = " 16#1/2#"); - Invert (Q, Q); - pragma Assert (Image (Q) = " 2"); - Put (S, Q); pragma Assert (S = " 2"); - Put (S, Q, 16); pragma Assert (S = " 16#2#"); - Exponentiate (Q, Q, -3); - pragma Assert (Image (Q) = " 1/8"); - Put (S, Q); pragma Assert (S = " 1/8"); - Put (S, Q, 4); pragma Assert (S = " 4#1/20#"); - Set (Q, 0, 2); - pragma Assert (Image (Q) = " 0"); - end Rationals_Demo; - - procedure Float_Demo - is - use FIC, FFC; - F : Big_Float; - begin - Set (F, 2.0); - pragma Assert (To_Num (F) = 2.0); - pragma Assert (F /= To_Big_Float (1)); - pragma Assert (F = To_Big_Float (2)); - -- Check if (predefined) inequality is correctly handled. - end Float_Demo; - - procedure Arithmetic_Demo is - use IIC; - A, B, C : Big_Integer; - begin - Factorial (A, 5); - Set (B, 120); - Set (C, 1); - Subtract_A_Product (A, B, C); - pragma Assert (Is_Even (A) and Image (A) = " 0"); - end Arithmetic_Demo; - - procedure Mpfr_Demo is - F : Big_Float_Rounded; - begin - pragma Unreferenced (F); - -- We just test that init and clear are well linked for now. - null; - end Mpfr_Demo; - - use Ada.Text_IO; -begin - Put ("Testing Stream_IO_Random_Demo... "); - Stream_IO_Random_Demo; - Put_Line ("done."); - Put ("Testing Text_IO_Demo... "); - Text_IO_Demo; - Put_Line ("done."); - Put ("Testing Rationals_Demo... "); - Rationals_Demo; - Put_Line ("done."); - Put ("Testing Float_Demo... "); - Float_Demo; - Put_Line ("done."); - Put ("Testing Arithmetic_Demo... "); - Arithmetic_Demo; - Put_Line ("done."); - Put ("Testing MPFR_Demo... "); - Mpfr_Demo; - Put_Line ("done."); -end Demo; diff -Nru libgmpada-1.0/demo/demo.gpr libgmpada-1.1/demo/demo.gpr --- libgmpada-1.0/demo/demo.gpr 2016-04-28 16:52:33.000000000 +0000 +++ libgmpada-1.1/demo/demo.gpr 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -with "gmpada"; -project Demo is - for Object_Dir use "obj-project"; - for Main use ("demo.adb"); -end Demo; diff -Nru libgmpada-1.0/demo.adb libgmpada-1.1/demo.adb --- libgmpada-1.0/demo.adb 1970-01-01 00:00:00.000000000 +0000 +++ libgmpada-1.1/demo.adb 2017-07-06 13:14:53.000000000 +0000 @@ -0,0 +1,245 @@ +-- GMPAda, binding to the Ada Language for the GNU MultiPrecision library. +-- Copyright (C) 2007-2017 Nicolas Boulenguez +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . + +with Ada.Directories; +with Ada.Text_IO; +with GNU_Multiple_Precision; use GNU_Multiple_Precision; +with GNU_Multiple_Precision.Big_Integers; +use GNU_Multiple_Precision.Big_Integers; +with GNU_Multiple_Precision.Big_Floats; +use GNU_Multiple_Precision.Big_Floats; +with GNU_Multiple_Precision.Big_Rationals; +with GNU_Multiple_Precision.Text_IO; +with GNU_Multiple_Precision.Random_Numbers; +with Ada.Integer_Text_IO; +with Ada.Streams.Stream_IO; +with Ada.Float_Text_IO; + +procedure Demo is + + Output_File : constant String := "output_file"; + + procedure Stream_IO_Random_Demo; + procedure Text_IO_Demo; + procedure Rationals_Demo; + procedure Float_Demo; + procedure Arithmetic_Demo; + + package IIC is new Big_Integers.Integer_Conversions (Integer); + package RIC is new Big_Rationals.Integer_Conversions (Integer); + package RFC is new Big_Rationals.Float_Conversions (Float); + package FIC is new Big_Floats.Integer_Conversions (Integer); + package FFC is new Big_Floats.Float_Conversions (Float); + + procedure Stream_IO_Random_Demo + is + -- Generates random numbers in -50 .. +50, outputs them, then + -- inputs and checks them. + use Random_Numbers, Ada.Streams.Stream_IO, IIC, FFC, RFC, Big_Rationals; + File : File_Type; + G : Generator; + Fifty : constant Big_Integer := To_Big_Integer (50); + Hundred_And_One : constant Big_Integer := To_Big_Integer (101); + Z : Big_Integer; + begin + Create (File, Out_File, Output_File); + Reset (G, 0); + for I in 1 .. 10 loop + Random (Z, G, Hundred_And_One); + Subtract (Z, Z, Fifty); + Big_Integer'Output (Stream (File), Z); + end loop; + Big_Rational'Write (Stream (File), To_Big_Rational (314159.0)); + Big_Float'Write (Stream (File), To_Big_Float (0.000000314)); + Close (File); + Open (File, In_File, Output_File); + Reset (G, 0); + for I in 1 .. 10 loop + Random (Z, G, Hundred_And_One); + pragma Assert (Big_Integer'Input (Stream (File)) + Fifty = Z); + end loop; + pragma Assert (Big_Rational'Input (Stream (File)) + = To_Big_Rational (314159.0)); + pragma Assert (Big_Float'Input (Stream (File)) + = To_Big_Float (0.000000314)); + Close (File); + Ada.Directories.Delete_File (Output_File); + exception + when others => + if Is_Open (File) then + Close (File); + end if; + if Ada.Directories.Exists (Output_File) then + Ada.Directories.Delete_File (Output_File); + end if; + raise; + end Stream_IO_Random_Demo; + + procedure Text_IO_Demo + is + use Ada.Text_IO, Ada.Integer_Text_IO, Text_IO, IIC, FFC, + Ada.Float_Text_IO; + File : File_Type; + Buffer, Buffer2 : String (1 .. 20); + Last : Positive; + Z : Big_Integer; + F : Big_Float; + begin + Get ("0", Z, Last); + pragma Assert (Last = 1 and Image (Z) = " 0" and Z = Value (" 0")); + Get (" -23+z", Z, Last); + pragma Assert (Last = 4 and Image (Z) = "-23" and Z = Value (" -23 ")); + Put (Buffer, -23); + Put (Buffer2, Z); + pragma Assert (Buffer = Buffer2); + Put (Buffer, -23, 16); + Put (Buffer2, Z, 16); + pragma Assert (Buffer = Buffer2); + Get (" +1_6#F_F#e2G", Z, Last); + pragma Assert (Last = 12 and Image (Z) = " 25500" + and Z = Value (" 25500 ")); + Get ("-10#2#E4z", F, Last); + pragma Assert (Last = 8 and Value (" -2.0E+4 ") = F); + Get ("-10#2.0#E4z", F, Last); + pragma Assert (Last = 10 and Value (" -2.0E+4 ") = F); + Put (Buffer, -10#2.0#E4, Aft => 0, Exp => 0); + Put (Buffer2, F, Aft => 0, Exp => 0); + pragma Assert (Buffer = Buffer2); + Put (Buffer, -10#2.0#E4, Aft => 8, Exp => 0); + Put (Buffer2, F, Aft => 8, Exp => 0); + pragma Assert (Buffer = Buffer2); + Get (".25s", F, Last); + pragma Assert (Last = 3 and Value (" 2.5E-1 ") = F); + Put (Buffer, F); + Put (Buffer2, 0.25); + pragma Assert (Buffer = Buffer2); + Get ("-2#011.1#E+3s", F, Last); + pragma Assert (Last = 12 and Value (" -28 ") = F); + Put (Buffer, F, Aft => 0, Exp => 3); + Put (Buffer2, -2#011.1#E+3, Aft => 0, Exp => 3); + pragma Assert (Buffer = Buffer2); + Create (File, Out_File, Output_File); + for I in -2 .. 2 loop + Set (Z, 10 * I); + pragma Assert (Integer'Image (10 * I) = Image (Z)); + Put (Buffer, 10 * I); + Put (Buffer2, Z); + pragma Assert (Buffer = Buffer2); + Put (File, 10 * I, 10); Put (File, Z, 10); + Put (File, ' '); Put (File, 10 * I); + New_Line (File); + Put (File, Z); + New_Line (File); + Set (F, Float (I) * 0.1); + Put (Buffer, Float (I) * 0.1, Aft => 6, Exp => 0); + Put (Buffer2, F, Aft => 6, Exp => 0); + pragma Assert (Buffer = Buffer2); + Put (Buffer, Float (I) * 0.1, Aft => 0); + Put (Buffer2, F, Aft => 0); + pragma Assert (Buffer = Buffer2); + Put (Buffer, Float (I) * 0.1, Aft => 6, Exp => 1); + Put (Buffer2, F, Aft => 6, Exp => 1); + pragma Assert (Buffer = Buffer2); + end loop; + Close (File); + Open (File, In_File, Output_File); + for I in -2 .. 2 loop + Get (File, Z, 10); pragma Assert (To_Num (Z) = 10 * I); + Get (File, Z, 10); pragma Assert (To_Num (Z) = 10 * I); + Get (File, Z); pragma Assert (To_Num (Z) = 10 * I); + Get (File, Z); pragma Assert (To_Num (Z) = 10 * I); + Skip_Line (File); + end loop; + Close (File); + Ada.Directories.Delete_File (Output_File); + exception + when others => + if Is_Open (File) then + Close (File); + end if; + if Ada.Directories.Exists (Output_File) then + Ada.Directories.Delete_File (Output_File); + end if; + raise; + end Text_IO_Demo; + + procedure Rationals_Demo + is + use Big_Rationals, RIC, Text_IO; + S : String (1 .. 8); + Q : Big_Rational; + begin + Set (Q, -1, 2); + pragma Assert (Image (Q) = "-1/2"); + Put (S, Q); pragma Assert (S = " -1/2"); + Put (S, Q, 2); pragma Assert (S = "-2#1/10#"); + Set (Q, 1, 2); + pragma Assert (Image (Q) = " 1/2"); + Put (S, Q); pragma Assert (S = " 1/2"); + Put (S, Q, 16); pragma Assert (S = " 16#1/2#"); + Invert (Q, Q); + pragma Assert (Image (Q) = " 2"); + Put (S, Q); pragma Assert (S = " 2"); + Put (S, Q, 16); pragma Assert (S = " 16#2#"); + Exponentiate (Q, Q, -3); + pragma Assert (Image (Q) = " 1/8"); + Put (S, Q); pragma Assert (S = " 1/8"); + Put (S, Q, 4); pragma Assert (S = " 4#1/20#"); + Set (Q, 0, 2); + pragma Assert (Image (Q) = " 0"); + end Rationals_Demo; + + procedure Float_Demo + is + use FIC, FFC; + F : Big_Float; + begin + Set (F, 2.0); + pragma Assert (To_Num (F) = 2.0); + pragma Assert (F /= To_Big_Float (1)); + pragma Assert (F = To_Big_Float (2)); + -- Check if (predefined) inequality is correctly handled. + end Float_Demo; + + procedure Arithmetic_Demo is + use IIC; + A, B, C : Big_Integer; + begin + Factorial (A, 5); + Set (B, 120); + Set (C, 1); + Subtract_A_Product (A, B, C); + pragma Assert (Is_Even (A) and Image (A) = " 0"); + end Arithmetic_Demo; + + use Ada.Text_IO; +begin + Put ("Testing Stream_IO_Random_Demo... "); + Stream_IO_Random_Demo; + Put_Line ("done."); + Put ("Testing Text_IO_Demo... "); + Text_IO_Demo; + Put_Line ("done."); + Put ("Testing Rationals_Demo... "); + Rationals_Demo; + Put_Line ("done."); + Put ("Testing Float_Demo... "); + Float_Demo; + Put_Line ("done."); + Put ("Testing Arithmetic_Demo... "); + Arithmetic_Demo; + Put_Line ("done."); +end Demo; diff -Nru libgmpada-1.0/generate_constants.c libgmpada-1.1/generate_constants.c --- libgmpada-1.0/generate_constants.c 2016-04-28 16:52:33.000000000 +0000 +++ libgmpada-1.1/generate_constants.c 2017-07-06 13:14:53.000000000 +0000 @@ -1,5 +1,5 @@ // GMPAda, binding to the Ada Language for the GNU MultiPrecision library. -// Copyright (C) 2009-2011 Nicolas Boulenguez +// Copyright (C) 2009-2017 Nicolas Boulenguez // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -17,8 +17,6 @@ #include #include #include -#include -#include // The size of the result of sizeof(...) and of some integer constants @@ -39,16 +37,19 @@ { const __mpz_struct z; - if (argc != 1) - error (EXIT_FAILURE, 0, "no argument expected."); + if (argc != 1) { + fprintf (stderr,"no argument expected.\n"); + exit (EXIT_FAILURE); + } if (sizeof(z._mp_alloc) != sizeof(int) || sizeof(z._mp_size) != sizeof(int) || sizeof(z._mp_d) != sizeof(mp_limb_t*) || sizeof(z._mp_alloc)+sizeof(z._mp_size)+sizeof(z._mp_d) != sizeof(mpz_t)) { - error (EXIT_FAILURE, 0, "\n\ + fprintf (stderr, "\n\ An incompatible change of mpz_t has been detected in gmp.h.\n\ Please report this to the Ada binding author.\n"); + exit (EXIT_FAILURE); } printf ("-- Generated by the C program %s.c.\n", argv[0]); printf ("-- Do not edit this file directly.\n"); @@ -74,15 +75,6 @@ print_u ("Sizeof_Mpq_T", sizeof(mpq_t)); print_u ("Sizeof_Mpf_T", sizeof(mpf_t)); print_u ("Sizeof_Gmp_Randstate_T", sizeof(gmp_randstate_t)); - print_u ("Sizeof_Mpfr_T", sizeof(mpfr_t)); - print_u ("Mp_Prec_T_Size", 8*sizeof(mp_prec_t)); - print_u ("Mpfr_Prec_Min", MPFR_PREC_MIN); - print_u ("Mpfr_Prec_Max", MPFR_PREC_MAX); - print_u ("Mp_Rnd_T_Size", 8*sizeof(mp_rnd_t)); - print_i ("Gmp_Rndn", GMP_RNDN); - print_i ("Gmp_Rndz", GMP_RNDZ); - print_i ("Gmp_Rndu", GMP_RNDU); - print_i ("Gmp_Rndd", GMP_RNDD); printf ("end GMP.Constants;\n"); exit (EXIT_SUCCESS); diff -Nru libgmpada-1.0/INSTALL libgmpada-1.1/INSTALL --- libgmpada-1.0/INSTALL 2016-04-28 16:52:33.000000000 +0000 +++ libgmpada-1.1/INSTALL 2017-07-06 13:14:53.000000000 +0000 @@ -1,6 +1,5 @@ GMPAda should compile on any linux-like system with the GCC/GNAT -compiler. Of course, you'll also need the GMP and MPFR libraries -installed. +compiler. Of course, you'll also need the GMP library installed. ------- INSTALL ------- diff -Nru libgmpada-1.0/Makefile libgmpada-1.1/Makefile --- libgmpada-1.0/Makefile 2016-04-28 16:52:33.000000000 +0000 +++ libgmpada-1.1/Makefile 2017-07-06 13:14:53.000000000 +0000 @@ -1,5 +1,5 @@ # GMPAda, binding to the Ada Language for the GNU MultiPrecision library. -# Copyright (C) 2007-2015 Nicolas Boulenguez +# Copyright (C) 2007-2017 Nicolas Boulenguez # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -38,11 +38,11 @@ GNATMAKE_OPTIONS := -j$(shell getconf _NPROCESSORS_ONLN) ifdef ALL_CHECKS - CFLAGS += -Wall -Wextra -Wformat -Wformat-security -g + CFLAGS += -Wall -Wextra -pedantic -Wformat-security -g ADAFLAGS += -Wall -Wextra -g -gnataEfoqQ -gnatVa -gnatw.eH.Y \ - -gnatyBdIoOSuxy -fstack-check -Wunused -Wuninitialized + -gnatyBdIoOSuxy -fstack-check LDFLAGS += -Wl,--as-needed -Wl,-z,defs - GNATMAKE_OPTIONS += -s -v -we + GNATMAKE_OPTIONS := -s -v endif # We want the same compiler for C and Ada sources. @@ -53,7 +53,7 @@ $(error Failed to set CC from gnatmake output.) endif -LDLIBS := -lgmp -lmpfr +LDLIBS := -lgmp ############################## # Installation configuration # @@ -66,7 +66,7 @@ SRC_DIR := usr/share/ada/adainclude # A LIB_NAME.gpr project convenient for library usage is installed into -GPR_DIR := usr/share/ada/adainclude +GPR_DIR := usr/share/gpr # The content of this file ignores DESTDIR. # The GNAT ALI files are installed into a LIB_NAME subdirectory of @@ -79,7 +79,10 @@ # Rules # ######### -ADA_SOURCES := $(wildcard src/*.ad[bs]) src/gmp-constants.ads +ada_bodies := $(wildcard src/*.adb) +ada_specs := src/gmp-constants.ads \ + $(filter-out src/gmp-constants.ads,$(wildcard src/*.ads)) +ada_units := $(ada_bodies) $(filter-out $(ada_bodies:b=s),$(ada_specs)) C_SOURCES := $(wildcard src/*.c) C_OBJ_DYNAMIC := $(patsubst src/%.c,obj-dynamic/%.o,$(C_SOURCES)) C_OBJ_STATIC := $(patsubst src/%.c,obj-static/%.o, $(C_SOURCES)) @@ -90,22 +93,22 @@ obj/lib$(LIB_NAME).a \ obj/$(LIB_NAME).gpr -obj/lib$(LIB_NAME).so.$(SOVERSION): $(ADA_SOURCES) $(C_OBJ_DYNAMIC) - gnatmake -c src/*.ad[bs] -D obj-dynamic $(GNATMAKE_OPTIONS) \ +obj/lib$(LIB_NAME).so.$(SOVERSION): $(ada_bodies) $(ada_specs) $(C_OBJ_DYNAMIC) | obj + gnatmake -c $(ada_units) -D obj-dynamic $(GNATMAKE_OPTIONS) \ -cargs $(ADAFLAGS) -fPIC - gcc -shared -o $@ -Wl,-soname,lib$(LIB_NAME).so.$(SOVERSION) \ - obj-dynamic/*.o $(LDFLAGS) $(LDLIBS) -lgnat-$(subst gcc-,,$(CC)) + $(CC) -shared -o $@ -Wl,-soname,lib$(LIB_NAME).so.$(SOVERSION) \ + obj-dynamic/*.o $(LDFLAGS) $(LDLIBS) -lgnat -obj/lib$(LIB_NAME).a: $(ADA_SOURCES) $(C_OBJ_STATIC) - gnatmake -c src/*.ad[bs] -D obj-static $(GNATMAKE_OPTIONS) \ +obj/lib$(LIB_NAME).a: $(ada_bodies) $(ada_specs) $(C_OBJ_STATIC) | obj + gnatmake -c $(ada_units) -D obj-static $(GNATMAKE_OPTIONS) \ -cargs $(ADAFLAGS) ar cr $@ obj-static/*.o ranlib $@ -$(C_OBJ_DYNAMIC): obj-dynamic/%.o: src/%.c +$(C_OBJ_DYNAMIC): obj-dynamic/%.o: src/%.c | obj-dynamic $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ -fPIC -$(C_OBJ_STATIC): obj-static/%.o: src/%.c +$(C_OBJ_STATIC): obj-static/%.o: src/%.c | obj-static $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ obj/$(LIB_NAME).gpr: template_for_installed_project @@ -116,58 +119,50 @@ ,-e "s|@$(d)_DIR@|`realpath -m $($(d)_DIR) --relative-to=$(GPR_DIR)`|") \ $< > $@ -src/gmp-constants.ads: obj/generate_constants +src/gmp-constants.ads: obj/generate_constants | obj $< > $@ - # If caller has set SOURCE_DATE_EPOCH, avoid generating - # unreproducible timestamps in ALI files. - ifdef SOURCE_DATE_EPOCH - touch -d "@$(SOURCE_DATE_EPOCH)" $@ - endif - -obj/generate_constants: generate_constants.c +obj/generate_constants: generate_constants.c | obj $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $< $(LDLIBS) -o $@ +obj obj-dynamic obj-static: + mkdir $@ clean:: - rm -f src/gmp-constants.ads obj/* obj-dynamic/* obj-static/* + rm -f src/gmp-constants.ads + rm -fr obj obj-dynamic obj-static find -name "*~" -delete ###################################################################### .PHONY: test -test: - mkdir -p demo-install +test: | demo-dynamic demo-static $(MAKE) install DESTDIR=demo-install - gnatmake demo/demo.adb -o demo/obj-dynamic/demo -D demo/obj-dynamic $(GNATMAKE_OPTIONS) \ + gnatmake demo.adb -o demo-dynamic/demo -D demo-dynamic $(GNATMAKE_OPTIONS) \ -aIdemo-install/$(SRC_DIR)/$(LIB_NAME) \ -aOdemo-install/$(ALI_DIR)/$(LIB_NAME) \ -cargs $(ADAFLAGS) \ -largs $(LDFLAGS) -Ldemo-install/$(LIB_DIR) -l$(LIB_NAME) $(LDLIBS) - LD_LIBRARY_PATH=demo-install/$(LIB_DIR) demo/obj-dynamic/demo - - # This test will fail once gnatmake drops project support, but for - # now we can test projects without gprbuild. - gnatmake -aPdemo-install/$(GPR_DIR) -Pdemo/demo.gpr - LD_LIBRARY_PATH=demo-install/$(LIB_DIR) demo/obj-project/demo + LD_LIBRARY_PATH=demo-install/$(LIB_DIR) demo-dynamic/demo - gnatmake demo/demo.adb -o demo/obj-static/demo -D demo/obj-static $(GNATMAKE_OPTIONS) \ + gnatmake demo.adb -o demo-static/demo -D demo-static $(GNATMAKE_OPTIONS) \ -aIdemo-install/$(SRC_DIR)/$(LIB_NAME) \ -aOdemo-install/$(ALI_DIR)/$(LIB_NAME) \ -cargs $(ADAFLAGS) \ -largs $(LDFLAGS) demo-install/$(LIB_DIR)/lib$(LIB_NAME).a $(LDLIBS) - demo/obj-static/demo + demo-static/demo $(MAKE) uninstall DESTDIR=demo-install test `find demo-install -type f | wc -l` = 0 +demo-dynamic demo-static: + mkdir $@ clean:: - rm -f demo/obj-dynamic/* demo/obj-project/* demo/obj-static/* - rm -fr demo-install + rm -fr demo-dynamic demo-install demo-static ###################################################################### .PHONY: install install: build install --directory $(DESTDIR)/$(SRC_DIR)/$(LIB_NAME) - install --mode=644 src/*.ad[sb] src/*.[ch] $(DESTDIR)/$(SRC_DIR)/$(LIB_NAME) + install --mode=644 $(ada_bodies) $(ada_specs) $(C_SOURCES) $(DESTDIR)/$(SRC_DIR)/$(LIB_NAME) install --directory $(DESTDIR)/$(GPR_DIR) install --mode=644 obj/$(LIB_NAME).gpr $(DESTDIR)/$(GPR_DIR) install --directory $(DESTDIR)/$(ALI_DIR)/$(LIB_NAME) diff -Nru libgmpada-1.0/README libgmpada-1.1/README --- libgmpada-1.0/README 2016-04-28 16:52:33.000000000 +0000 +++ libgmpada-1.1/README 2017-07-06 13:14:53.000000000 +0000 @@ -4,8 +4,7 @@ Extensive documentation about the GMP original C library can be found at http://gmplib.org/manual. -The latest source is available on -http://mtn-host.prjek.net/projects/libgmpada. +The latest source is available on https://nicolas.boulenguez.free.fr. --------------------- Usage -------------------------- @@ -24,8 +23,7 @@ -------------------- Status --------------------- Big_Integer and Big_Float operations are available and coherent. -Big_Rationals operations are usable. A Mpfr binding has started but is -still far from complete. +Big_Rationals operations are usable. --------------- What is GMPAda? --------------- @@ -167,9 +165,6 @@ GNU_Multiple_Precision http://www.chiark.greenend.org.uk/~mroe/Ada/GMP/index.html -https://github.com/ytomino/gmp-ada -Yuta Tomino uses a C header parser to generate the thin binding. - http://code.google.com/p/adabindinggmpmpfr/ Vincent Diemunsch has written a similar work, focusing on MPFR. diff -Nru libgmpada-1.0/src/gmp-binding.ads libgmpada-1.1/src/gmp-binding.ads --- libgmpada-1.0/src/gmp-binding.ads 2016-04-26 00:00:00.000000000 +0000 +++ libgmpada-1.1/src/gmp-binding.ads 2017-07-06 13:14:53.000000000 +0000 @@ -1,5 +1,5 @@ -- GMPAda, binding to the Ada Language for the GNU MultiPrecision library. --- Copyright (C) 2007-2013 Nicolas Boulenguez +-- Copyright (C) 2007-2017 Nicolas Boulenguez -- -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -1761,194 +1761,6 @@ N : in unsigned_long); pragma Import (C, Gmp_Urandomm_Ui, "mp_urandomm_ui", "__gmp_urandomm_ui"); - --------------------------------- - -- Formatted Output and Input -- - --------------------------------- - -- Not implemented yet (and may well never be). - -- function Gmp_Printf (Fmt : Char) - -- return int; - - -- function Gmp_Vprintf (Fmt : Char; - -- Ap : Va_List) - -- return int; - - -- function Gmp_Fprintf (Fp : FILE; - -- Fmt : Char) - -- return int; - - -- function Gmp_Vfprintf (Fp : FILE; - -- Fmt : Char; - -- Ap : Va_List) - -- return int; - - -- function Gmp_Sprintf (Buf : Char; - -- Fmt : Char) - -- return int; - - -- function Gmp_Vsprintf (Buf : Char; - -- Fmt : Char; - -- Ap : Va_List) - -- return int; - - -- function Gmp_Snprintf (Buf : Char; - -- Size : size_t; - -- Fmt : Char) - -- return int; - - -- function Gmp_Vsnprintf (Buf : Char; - -- Size : size_t; - -- Fmt : Char; - -- Ap : Va_List) - -- return int; - - -- function Gmp_Asprintf (Pp : Char; - -- Fmt : Char) - -- return int; - - -- function Gmp_Vasprintf (Pp : Char; - -- Fmt : Char; - -- Ap : Va_List) - -- return int; - - -- function Gmp_Obstack_Printf (Ob : Obstack; - -- Fmt : Char) - -- return int; - - -- function Gmp_Obstack_Vprintf (Ob : Obstack; - -- Fmt : Char; - -- Ap : Va_List) - -- return int; - - -- function Gmp_Scanf (Fmt : Char) - -- return int; - - -- function Gmp_Vscanf (Fmt : Char; - -- Ap : Va_List) - -- return int; - - -- function Gmp_Fscanf (Fp : FILE; - -- Fmt : Char) - -- return int; - - -- function Gmp_Vfscanf (Fp : FILE; - -- Fmt : Char; - -- Ap : Va_List) - -- return int; - - -- function Gmp_Sscanf (S : Char; - -- Fmt : Char) - -- return int; - - -- function Gmp_Vsscanf (S : Char; - -- Fmt : Char; - -- Ap : Va_List) - -- return int; - -- pragma Import (C, Gmp_Printf, "mp_printf", "__gmp_printf"); - -- pragma Import (C, Gmp_Vprintf, "mp_vprintf", "__gmp_vprintf"); - -- pragma Import (C, Gmp_Fprintf, "mp_fprintf", "__gmp_fprintf"); - -- pragma Import (C, Gmp_Vfprintf, "mp_vfprintf", "__gmp_vfprintf"); - -- pragma Import (C, Gmp_Sprintf, "mp_sprintf", "__gmp_sprintf"); - -- pragma Import (C, Gmp_Vsprintf, "mp_vsprintf", "__gmp_vsprintf"); - -- pragma Import (C, Gmp_Snprintf, "mp_snprintf", "__gmp_snprintf"); - -- pragma Import (C, Gmp_Vsnprintf, "mp_vsnprintf", "__gmp_vsnprintf"); - -- pragma Import (C, Gmp_Asprintf, "mp_asprintf", "__gmp_asprintf"); - -- pragma Import (C, Gmp_Vasprintf, "mp_vasprintf", "__gmp_vasprintf"); - -- pragma Import (C, Gmp_Obstack_Printf, "mp_obstack_printf", - -- "__gmp_obstack_printf"); - -- pragma Import (C, Gmp_Obstack_Vprintf, "mp_obstack_vprintf", - -- "__gmp_obstack_vprintf"); - -- pragma Import (C, Gmp_Scanf, "mp_scanf", "__gmp_scanf"); - -- pragma Import (C, Gmp_Vscanf, "mp_vscanf", "__gmp_vscanf"); - -- pragma Import (C, Gmp_Fscanf, "mp_fscanf", "__gmp_fscanf"); - -- pragma Import (C, Gmp_Vfscanf, "mp_vfscanf", "__gmp_vfscanf"); - -- pragma Import (C, Gmp_Sscanf, "mp_sscanf", "__gmp_sscanf"); - -- pragma Import (C, Gmp_Vsscanf, "mp_vsscanf", "__gmp_vsscanf"); - - ----------------------- - -- MPFR - ----------------------- - - type Mpfr_T is private; - type Mp_Prec_T is range GMP.Constants.Mpfr_Prec_Min - .. GMP.Constants.Mpfr_Prec_Max; - for Mp_Prec_T'Size use GMP.Constants.Mp_Prec_T_Size; - - type Mp_Rnd_T is (Gmp_Rndn, Gmp_Rndz, Gmp_Rndu, Gmp_Rndd); - for Mp_Rnd_T use - (Gmp_Rndn => GMP.Constants.Gmp_Rndn, - Gmp_Rndz => GMP.Constants.Gmp_Rndz, - Gmp_Rndu => GMP.Constants.Gmp_Rndu, - Gmp_Rndd => GMP.Constants.Gmp_Rndd); - for Mp_Rnd_T'Size use GMP.Constants.Mp_Rnd_T_Size; - - procedure Mpfr_Init2 (X : out Mpfr_T; - Prec : in Mp_Prec_T); - pragma Import (C, Mpfr_Init2, "mpfr_init2", "mpfr_init2"); - - procedure Mpfr_Clear (X : in out Mpfr_T); - pragma Import (C, Mpfr_Clear, "mpfr_clear", "mpfr_clear"); - - procedure Mpfr_Init (X : out Mpfr_T); - pragma Import (C, Mpfr_Init, "mpfr_init", "mpfr_init"); - - procedure Mpfr_Set_Default_Prec (Prec : in Mp_Prec_T); - pragma Import (C, Mpfr_Set_Default_Prec, "mpfr_set_default_prec", - "mpfr_set_default_prec"); - - function Mpfr_Get_Default_Prec return Mp_Prec_T; - pragma Import (C, Mpfr_Get_Default_Prec, "mpfr_get_default_prec", - "mpfr_get_default_prec"); - - procedure Mpfr_Set_Prec (Rop : in out Mpfr_T; - Prec : in Mp_Prec_T); - pragma Import (C, Mpfr_Set_Prec, "mpfr_set_prec", "mpfr_set_prec"); - - function Mpfr_Get_Prec (Op : in Mpfr_T) - return Mp_Prec_T; - pragma Import (C, Mpfr_Get_Prec, "mpfr_get_prec", "mpfr_get_prec"); - - -- Assignment - - procedure Mpfr_Set (Rop : in out Mpfr_T; - Op : in Mpfr_T; - Rnd : in Mp_Rnd_T); - pragma Import (C, Mpfr_Set, "mpfr_set", "mpfr_set"); - - procedure Mpfr_Set_Ui (Rop : in out Mpfr_T; - Op : in unsigned_long; - Rnd : in Mp_Rnd_T); - pragma Import (C, Mpfr_Set_Ui, "mpfr_set_ui", "mpfr_set_ui"); - - procedure Mpfr_Set_Si (Rop : in out Mpfr_T; - Op : in long; - Rnd : in Mp_Rnd_T); - pragma Import (C, Mpfr_Set_Si, "mpfr_set_si", "mpfr_set_si"); - - procedure Mpfr_Set_D (Rop : in out Mpfr_T; - Op : in double; - Rnd : in Mp_Rnd_T); - pragma Import (C, Mpfr_Set_D, "mpfr_set_d", "mpfr_set_d"); - - procedure Mpfr_Set_Z (Rop : in out Mpfr_T; - Op : in Mpz_T; - Rnd : in Mp_Rnd_T); - pragma Import (C, Mpfr_Set_Z, "mpfr_set_z", "mpfr_set_z"); - - procedure Mpfr_Set_Q (Rop : in out Mpfr_T; - Op : in Mpq_T; - Rnd : in Mp_Rnd_T); - pragma Import (C, Mpfr_Set_Q, "mpfr_set_q", "mpfr_set_q"); - - procedure Mpfr_Set_F (Rop : in out Mpfr_T; - Op : in Mpf_T; - Rnd : in Mp_Rnd_T); - pragma Import (C, Mpfr_Set_F, "mpfr_set_f", "mpfr_set_f"); - - procedure Mpfr_Init_Set (Rop : in out Mpfr_T; - Op : in Mpfr_T; - Rnd : in Mp_Rnd_T); - pragma Import (C, Mpfr_Init_Set, "mpfr_init_set", "mpfr_init_set"); - private type Mp_Limb_T_Array is array (size_t range <>) of aliased Mp_Limb_T; @@ -1984,6 +1796,5 @@ type Mpf_T is new char_array (1 .. GMP.Constants.Sizeof_Mpf_T); type Gmp_Randstate_t is new char_array (1 .. GMP.Constants.Sizeof_Gmp_Randstate_T); - type Mpfr_T is new char_array (1 .. GMP.Constants.Sizeof_Mpfr_T); end GMP.Binding; diff -Nru libgmpada-1.0/src/gnu_multiple_precision.adb libgmpada-1.1/src/gnu_multiple_precision.adb --- libgmpada-1.0/src/gnu_multiple_precision.adb 2016-04-26 00:00:00.000000000 +0000 +++ libgmpada-1.1/src/gnu_multiple_precision.adb 2017-07-06 13:14:53.000000000 +0000 @@ -1,5 +1,5 @@ -- GMPAda, binding to the Ada Language for the GNU MultiPrecision library. --- Copyright (C) 2007-2013 Nicolas Boulenguez +-- Copyright (C) 2007-2017 Nicolas Boulenguez -- -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -33,7 +33,7 @@ end Adjust; overriding procedure Finalize (Object : in out Big_Integer) - is + is begin Mpz_Clear (Object.Value); end Finalize; @@ -161,45 +161,6 @@ pragma Unreferenced (Z); end Write; - overriding procedure Initialize (Object : in out Big_Float_Rounded) - is - begin - Mpfr_Init (Object.Value); - end Initialize; - - -- overriding procedure Adjust (Object : in out Big_Float_Rounded) - -- is - -- begin - -- null; - -- end Adjust; - - overriding procedure Finalize (Object : in out Big_Float_Rounded) - is - begin - Mpfr_Clear (Object.Value); - end Finalize; - - -- overriding function "=" (Left, Right : Big_Float_Rounded) - -- return Boolean - -- is - -- begin - -- return True; - -- end "="; - - -- procedure Read (Stream : access Ada.Streams.Root_Stream_Type'Class; - -- Item : out Big_Float_Rounded) - -- is - -- begin - -- null; - -- end Read; - - -- procedure Write (Stream : access Ada.Streams.Root_Stream_Type'Class; - -- Item : in Big_Float_Rounded) - -- is - -- begin - -- null; - -- end Write; - function Identity (Item : in Character) return Character is diff -Nru libgmpada-1.0/src/gnu_multiple_precision.ads libgmpada-1.1/src/gnu_multiple_precision.ads --- libgmpada-1.0/src/gnu_multiple_precision.ads 2016-04-26 00:00:00.000000000 +0000 +++ libgmpada-1.1/src/gnu_multiple_precision.ads 2017-07-06 13:14:53.000000000 +0000 @@ -1,5 +1,5 @@ -- GMPAda, binding to the Ada Language for the GNU MultiPrecision library. --- Copyright (C) 2007-2010 Nicolas Boulenguez +-- Copyright (C) 2007-2017 Nicolas Boulenguez -- -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -29,7 +29,6 @@ type Big_Integer is private; type Big_Rational is private; type Big_Float is private; - type Big_Float_Rounded is private; -- Input, Output, Read and Write are handled by representation -- clauses. @@ -58,7 +57,7 @@ overriding procedure Initialize (Object : in out Big_Integer); overriding procedure Adjust (Object : in out Big_Integer); overriding procedure Finalize (Object : in out Big_Integer); - overriding function "=" (Left, Right : Big_Integer) return Boolean; + overriding function "=" (Left, Right : in Big_Integer) return Boolean; -- "/=" is automatically defined. -- Stream attributes are correctly inherited from Mpz_T, thanks to @@ -71,12 +70,10 @@ overriding procedure Initialize (Object : in out Big_Rational); overriding procedure Adjust (Object : in out Big_Rational); overriding procedure Finalize (Object : in out Big_Rational); - overriding function "=" (Left, Right : Big_Rational) return Boolean; - + overriding function "=" (Left, Right : Big_Rational) return Boolean; procedure Read (Stream : access Ada.Streams.Root_Stream_Type'Class; Item : out Big_Rational); for Big_Rational'Read use Read; - procedure Write (Stream : access Ada.Streams.Root_Stream_Type'Class; Item : in Big_Rational); for Big_Rational'Write use Write; @@ -88,7 +85,7 @@ overriding procedure Initialize (Object : in out Big_Float); overriding procedure Adjust (Object : in out Big_Float); overriding procedure Finalize (Object : in out Big_Float); - overriding function "=" (Left, Right : Big_Float) return Boolean; + overriding function "=" (Left, Right : Big_Float) return Boolean; procedure Read (Stream : access Ada.Streams.Root_Stream_Type'Class; Item : out Big_Float); @@ -98,24 +95,6 @@ for Big_Float'Read use Read; for Big_Float'Write use Write; - type Big_Float_Rounded is new Ada.Finalization.Controlled with record - Value : GMP.Binding.Mpfr_T; - end record; - - overriding procedure Initialize (Object : in out Big_Float_Rounded); - -- overriding procedure Adjust (Object : in out Big_Float_Rounded); - overriding procedure Finalize (Object : in out Big_Float_Rounded); - -- overriding function "=" (Left, Right : Big_Float_Rounded) - -- return Boolean; - - -- procedure Read (Stream : access Ada.Streams.Root_Stream_Type'Class; - -- Item : out Big_Float_Rounded); - -- procedure Write (Stream : access Ada.Streams.Root_Stream_Type'Class; - -- Item : in Big_Float_Rounded); - - -- for Big_Float_Rounded'Read use Read; - -- for Big_Float_Rounded'Write use Write; - pragma Inline ("="); pragma Inline (Adjust); pragma Inline (Finalize); diff -Nru libgmpada-1.0/TODO libgmpada-1.1/TODO --- libgmpada-1.0/TODO 2016-04-28 16:52:33.000000000 +0000 +++ libgmpada-1.1/TODO 2017-07-06 13:14:53.000000000 +0000 @@ -7,25 +7,13 @@ make clean ; grep -ir todo . -Compare with a similar project based on the very promising headmaster -tool, gathering information from C headers. -https://github.com/ytomino/gmp-ada. - -GCC-5 seems to be able to generate something similar to the thin -binding from C headers. - -Replace mpz_t with mpfr_t from libmpfr. Easy at this stage but -boring. That would make a wide range of new numerical functions -available (cos, sin, exp, ln,...). Please look at the end of -gmp-binding.ads if you're interested. Vincent Diemunsch's work -at http://code.google.com/p/adabindinggmpmpfr/ may help a lot. +See if gcc -dump-ada-spec can generate the thin binding. Port to other operating systems. This should not be very difficult as long as the GNAT Ada compiler and the GMP library are ported on that platform. It may be convenient to use pragma Import (Foo, "mpz_foo", -GMP_Prefix & "mpz_foor"); and something similar with MPFR_Prefix, but -it may be more complex than it seems, since there are MANY prefixes -used by the GCC version of GMP... +GMP_Prefix & "mpz_foor");, but it may be more complex than it seems, +since there are MANY prefixes used by the GCC version of GMP... Add the complex type provided by libmpc, with conventions from the ARM.