diff options
Diffstat (limited to 'vendor/gmp-6.3.0/tests/mpf')
30 files changed, 5921 insertions, 0 deletions
diff --git a/vendor/gmp-6.3.0/tests/mpf/Makefile.am b/vendor/gmp-6.3.0/tests/mpf/Makefile.am new file mode 100644 index 0000000..da0e92b --- /dev/null +++ b/vendor/gmp-6.3.0/tests/mpf/Makefile.am @@ -0,0 +1,32 @@ +## Process this file with automake to generate Makefile.in + +# Copyright 1996, 1999-2004, 2015 Free Software Foundation, Inc. +# +# This file is part of the GNU MP Library test suite. +# +# The GNU MP Library test suite 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. +# +# The GNU MP Library test suite 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 +# the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. + + +AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/tests +AM_LDFLAGS = -no-install +LDADD = $(top_builddir)/tests/libtests.la $(top_builddir)/libgmp.la + +check_PROGRAMS = t-dm2exp t-conv t-add t-sub t-sqrt t-sqrt_ui t-muldiv reuse \ + t-cmp_d t-cmp_si t-div t-fits t-get_d t-get_d_2exp \ + t-get_si t-get_ui t-gsprec t-inp_str t-int_p t-mul_ui \ + t-set t-set_q t-set_si t-set_ui t-trunc t-ui_div t-eq t-pow_ui +TESTS = $(check_PROGRAMS) + +$(top_builddir)/tests/libtests.la: + cd $(top_builddir)/tests; $(MAKE) $(AM_MAKEFLAGS) libtests.la diff --git a/vendor/gmp-6.3.0/tests/mpf/Makefile.in b/vendor/gmp-6.3.0/tests/mpf/Makefile.in new file mode 100644 index 0000000..de2aeab --- /dev/null +++ b/vendor/gmp-6.3.0/tests/mpf/Makefile.in @@ -0,0 +1,1452 @@ +# Makefile.in generated by automake 1.15 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2014 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# Copyright 1996, 1999-2004, 2015 Free Software Foundation, Inc. +# +# This file is part of the GNU MP Library test suite. +# +# The GNU MP Library test suite 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. +# +# The GNU MP Library test suite 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 +# the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +check_PROGRAMS = t-dm2exp$(EXEEXT) t-conv$(EXEEXT) t-add$(EXEEXT) \ + t-sub$(EXEEXT) t-sqrt$(EXEEXT) t-sqrt_ui$(EXEEXT) \ + t-muldiv$(EXEEXT) reuse$(EXEEXT) t-cmp_d$(EXEEXT) \ + t-cmp_si$(EXEEXT) t-div$(EXEEXT) t-fits$(EXEEXT) \ + t-get_d$(EXEEXT) t-get_d_2exp$(EXEEXT) t-get_si$(EXEEXT) \ + t-get_ui$(EXEEXT) t-gsprec$(EXEEXT) t-inp_str$(EXEEXT) \ + t-int_p$(EXEEXT) t-mul_ui$(EXEEXT) t-set$(EXEEXT) \ + t-set_q$(EXEEXT) t-set_si$(EXEEXT) t-set_ui$(EXEEXT) \ + t-trunc$(EXEEXT) t-ui_div$(EXEEXT) t-eq$(EXEEXT) \ + t-pow_ui$(EXEEXT) +subdir = tests/mpf +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +reuse_SOURCES = reuse.c +reuse_OBJECTS = reuse.$(OBJEXT) +reuse_LDADD = $(LDADD) +reuse_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ + $(top_builddir)/libgmp.la +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +t_add_SOURCES = t-add.c +t_add_OBJECTS = t-add.$(OBJEXT) +t_add_LDADD = $(LDADD) +t_add_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ + $(top_builddir)/libgmp.la +t_cmp_d_SOURCES = t-cmp_d.c +t_cmp_d_OBJECTS = t-cmp_d.$(OBJEXT) +t_cmp_d_LDADD = $(LDADD) +t_cmp_d_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ + $(top_builddir)/libgmp.la +t_cmp_si_SOURCES = t-cmp_si.c +t_cmp_si_OBJECTS = t-cmp_si.$(OBJEXT) +t_cmp_si_LDADD = $(LDADD) +t_cmp_si_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ + $(top_builddir)/libgmp.la +t_conv_SOURCES = t-conv.c +t_conv_OBJECTS = t-conv.$(OBJEXT) +t_conv_LDADD = $(LDADD) +t_conv_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ + $(top_builddir)/libgmp.la +t_div_SOURCES = t-div.c +t_div_OBJECTS = t-div.$(OBJEXT) +t_div_LDADD = $(LDADD) +t_div_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ + $(top_builddir)/libgmp.la +t_dm2exp_SOURCES = t-dm2exp.c +t_dm2exp_OBJECTS = t-dm2exp.$(OBJEXT) +t_dm2exp_LDADD = $(LDADD) +t_dm2exp_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ + $(top_builddir)/libgmp.la +t_eq_SOURCES = t-eq.c +t_eq_OBJECTS = t-eq.$(OBJEXT) +t_eq_LDADD = $(LDADD) +t_eq_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ + $(top_builddir)/libgmp.la +t_fits_SOURCES = t-fits.c +t_fits_OBJECTS = t-fits.$(OBJEXT) +t_fits_LDADD = $(LDADD) +t_fits_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ + $(top_builddir)/libgmp.la +t_get_d_SOURCES = t-get_d.c +t_get_d_OBJECTS = t-get_d.$(OBJEXT) +t_get_d_LDADD = $(LDADD) +t_get_d_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ + $(top_builddir)/libgmp.la +t_get_d_2exp_SOURCES = t-get_d_2exp.c +t_get_d_2exp_OBJECTS = t-get_d_2exp.$(OBJEXT) +t_get_d_2exp_LDADD = $(LDADD) +t_get_d_2exp_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ + $(top_builddir)/libgmp.la +t_get_si_SOURCES = t-get_si.c +t_get_si_OBJECTS = t-get_si.$(OBJEXT) +t_get_si_LDADD = $(LDADD) +t_get_si_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ + $(top_builddir)/libgmp.la +t_get_ui_SOURCES = t-get_ui.c +t_get_ui_OBJECTS = t-get_ui.$(OBJEXT) +t_get_ui_LDADD = $(LDADD) +t_get_ui_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ + $(top_builddir)/libgmp.la +t_gsprec_SOURCES = t-gsprec.c +t_gsprec_OBJECTS = t-gsprec.$(OBJEXT) +t_gsprec_LDADD = $(LDADD) +t_gsprec_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ + $(top_builddir)/libgmp.la +t_inp_str_SOURCES = t-inp_str.c +t_inp_str_OBJECTS = t-inp_str.$(OBJEXT) +t_inp_str_LDADD = $(LDADD) +t_inp_str_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ + $(top_builddir)/libgmp.la +t_int_p_SOURCES = t-int_p.c +t_int_p_OBJECTS = t-int_p.$(OBJEXT) +t_int_p_LDADD = $(LDADD) +t_int_p_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ + $(top_builddir)/libgmp.la +t_mul_ui_SOURCES = t-mul_ui.c +t_mul_ui_OBJECTS = t-mul_ui.$(OBJEXT) +t_mul_ui_LDADD = $(LDADD) +t_mul_ui_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ + $(top_builddir)/libgmp.la +t_muldiv_SOURCES = t-muldiv.c +t_muldiv_OBJECTS = t-muldiv.$(OBJEXT) +t_muldiv_LDADD = $(LDADD) +t_muldiv_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ + $(top_builddir)/libgmp.la +t_pow_ui_SOURCES = t-pow_ui.c +t_pow_ui_OBJECTS = t-pow_ui.$(OBJEXT) +t_pow_ui_LDADD = $(LDADD) +t_pow_ui_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ + $(top_builddir)/libgmp.la +t_set_SOURCES = t-set.c +t_set_OBJECTS = t-set.$(OBJEXT) +t_set_LDADD = $(LDADD) +t_set_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ + $(top_builddir)/libgmp.la +t_set_q_SOURCES = t-set_q.c +t_set_q_OBJECTS = t-set_q.$(OBJEXT) +t_set_q_LDADD = $(LDADD) +t_set_q_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ + $(top_builddir)/libgmp.la +t_set_si_SOURCES = t-set_si.c +t_set_si_OBJECTS = t-set_si.$(OBJEXT) +t_set_si_LDADD = $(LDADD) +t_set_si_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ + $(top_builddir)/libgmp.la +t_set_ui_SOURCES = t-set_ui.c +t_set_ui_OBJECTS = t-set_ui.$(OBJEXT) +t_set_ui_LDADD = $(LDADD) +t_set_ui_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ + $(top_builddir)/libgmp.la +t_sqrt_SOURCES = t-sqrt.c +t_sqrt_OBJECTS = t-sqrt.$(OBJEXT) +t_sqrt_LDADD = $(LDADD) +t_sqrt_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ + $(top_builddir)/libgmp.la +t_sqrt_ui_SOURCES = t-sqrt_ui.c +t_sqrt_ui_OBJECTS = t-sqrt_ui.$(OBJEXT) +t_sqrt_ui_LDADD = $(LDADD) +t_sqrt_ui_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ + $(top_builddir)/libgmp.la +t_sub_SOURCES = t-sub.c +t_sub_OBJECTS = t-sub.$(OBJEXT) +t_sub_LDADD = $(LDADD) +t_sub_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ + $(top_builddir)/libgmp.la +t_trunc_SOURCES = t-trunc.c +t_trunc_OBJECTS = t-trunc.$(OBJEXT) +t_trunc_LDADD = $(LDADD) +t_trunc_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ + $(top_builddir)/libgmp.la +t_ui_div_SOURCES = t-ui_div.c +t_ui_div_OBJECTS = t-ui_div.$(OBJEXT) +t_ui_div_LDADD = $(LDADD) +t_ui_div_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ + $(top_builddir)/libgmp.la +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = +am__depfiles_maybe = +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = reuse.c t-add.c t-cmp_d.c t-cmp_si.c t-conv.c t-div.c \ + t-dm2exp.c t-eq.c t-fits.c t-get_d.c t-get_d_2exp.c t-get_si.c \ + t-get_ui.c t-gsprec.c t-inp_str.c t-int_p.c t-mul_ui.c \ + t-muldiv.c t-pow_ui.c t-set.c t-set_q.c t-set_si.c t-set_ui.c \ + t-sqrt.c t-sqrt_ui.c t-sub.c t-trunc.c t-ui_div.c +DIST_SOURCES = reuse.c t-add.c t-cmp_d.c t-cmp_si.c t-conv.c t-div.c \ + t-dm2exp.c t-eq.c t-fits.c t-get_d.c t-get_d_2exp.c t-get_si.c \ + t-get_ui.c t-gsprec.c t-inp_str.c t-int_p.c t-mul_ui.c \ + t-muldiv.c t-pow_ui.c t-set.c t-set_q.c t-set_si.c t-set_ui.c \ + t-sqrt.c t-sqrt_ui.c t-sub.c t-trunc.c t-ui_div.c +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +am__tty_colors_dummy = \ + mgn= red= grn= lgn= blu= brg= std=; \ + am__color_tests=no +am__tty_colors = { \ + $(am__tty_colors_dummy); \ + if test "X$(AM_COLOR_TESTS)" = Xno; then \ + am__color_tests=no; \ + elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ + am__color_tests=yes; \ + elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ + am__color_tests=yes; \ + fi; \ + if test $$am__color_tests = yes; then \ + red='[0;31m'; \ + grn='[0;32m'; \ + lgn='[1;32m'; \ + blu='[1;34m'; \ + mgn='[0;35m'; \ + brg='[1m'; \ + std='[m'; \ + fi; \ +} +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__recheck_rx = ^[ ]*:recheck:[ ]* +am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* +am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* +# A command that, given a newline-separated list of test names on the +# standard input, print the name of the tests that are to be re-run +# upon "make recheck". +am__list_recheck_tests = $(AWK) '{ \ + recheck = 1; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + { \ + if ((getline line2 < ($$0 ".log")) < 0) \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ + { \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ + { \ + break; \ + } \ + }; \ + if (recheck) \ + print $$0; \ + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' +# A command that, given a newline-separated list of test names on the +# standard input, create the global log from their .trs and .log files. +am__create_global_log = $(AWK) ' \ +function fatal(msg) \ +{ \ + print "fatal: making $@: " msg | "cat >&2"; \ + exit 1; \ +} \ +function rst_section(header) \ +{ \ + print header; \ + len = length(header); \ + for (i = 1; i <= len; i = i + 1) \ + printf "="; \ + printf "\n\n"; \ +} \ +{ \ + copy_in_global_log = 1; \ + global_test_result = "RUN"; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".trs"); \ + if (line ~ /$(am__global_test_result_rx)/) \ + { \ + sub("$(am__global_test_result_rx)", "", line); \ + sub("[ ]*$$", "", line); \ + global_test_result = line; \ + } \ + else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ + copy_in_global_log = 0; \ + }; \ + if (copy_in_global_log) \ + { \ + rst_section(global_test_result ": " $$0); \ + while ((rc = (getline line < ($$0 ".log"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".log"); \ + print line; \ + }; \ + printf "\n"; \ + }; \ + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' +# Restructured Text title. +am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } +# Solaris 10 'make', and several other traditional 'make' implementations, +# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it +# by disabling -e (using the XSI extension "set +e") if it's set. +am__sh_e_setup = case $$- in *e*) set +e;; esac +# Default flags passed to test drivers. +am__common_driver_flags = \ + --color-tests "$$am__color_tests" \ + --enable-hard-errors "$$am__enable_hard_errors" \ + --expect-failure "$$am__expect_failure" +# To be inserted before the command running the test. Creates the +# directory for the log if needed. Stores in $dir the directory +# containing $f, in $tst the test, in $log the log. Executes the +# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and +# passes TESTS_ENVIRONMENT. Set up options for the wrapper that +# will run the test scripts (or their associated LOG_COMPILER, if +# thy have one). +am__check_pre = \ +$(am__sh_e_setup); \ +$(am__vpath_adj_setup) $(am__vpath_adj) \ +$(am__tty_colors); \ +srcdir=$(srcdir); export srcdir; \ +case "$@" in \ + */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ + *) am__odir=.;; \ +esac; \ +test "x$$am__odir" = x"." || test -d "$$am__odir" \ + || $(MKDIR_P) "$$am__odir" || exit $$?; \ +if test -f "./$$f"; then dir=./; \ +elif test -f "$$f"; then dir=; \ +else dir="$(srcdir)/"; fi; \ +tst=$$dir$$f; log='$@'; \ +if test -n '$(DISABLE_HARD_ERRORS)'; then \ + am__enable_hard_errors=no; \ +else \ + am__enable_hard_errors=yes; \ +fi; \ +case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ + am__expect_failure=yes;; \ + *) \ + am__expect_failure=no;; \ +esac; \ +$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) +# A shell command to get the names of the tests scripts with any registered +# extension removed (i.e., equivalently, the names of the test logs, with +# the '.log' extension removed). The result is saved in the shell variable +# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, +# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", +# since that might cause problem with VPATH rewrites for suffix-less tests. +# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. +am__set_TESTS_bases = \ + bases='$(TEST_LOGS)'; \ + bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ + bases=`echo $$bases` +RECHECK_LOGS = $(TEST_LOGS) +AM_RECURSIVE_TARGETS = check recheck +TEST_SUITE_LOG = test-suite.log +TEST_EXTENSIONS = @EXEEXT@ .test +LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver +LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) +am__set_b = \ + case '$@' in \ + */*) \ + case '$*' in \ + */*) b='$*';; \ + *) b=`echo '$@' | sed 's/\.log$$//'`; \ + esac;; \ + *) \ + b='$*';; \ + esac +am__test_logs1 = $(TESTS:=.log) +am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) +TEST_LOGS = $(am__test_logs2:.test.log=.log) +TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver +TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ + $(TEST_LOG_FLAGS) +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/test-driver +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ABI = @ABI@ +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AS = @AS@ +ASMFLAGS = @ASMFLAGS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CALLING_CONVENTIONS_OBJS = @CALLING_CONVENTIONS_OBJS@ +CC = @CC@ +CCAS = @CCAS@ +CC_FOR_BUILD = @CC_FOR_BUILD@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CPP_FOR_BUILD = @CPP_FOR_BUILD@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFN_LONG_LONG_LIMB = @DEFN_LONG_LONG_LIMB@ +DEFS = @DEFS@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXEEXT_FOR_BUILD = @EXEEXT_FOR_BUILD@ +FGREP = @FGREP@ +GMP_LDFLAGS = @GMP_LDFLAGS@ +GMP_LIMB_BITS = @GMP_LIMB_BITS@ +GMP_NAIL_BITS = @GMP_NAIL_BITS@ +GREP = @GREP@ +HAVE_CLOCK_01 = @HAVE_CLOCK_01@ +HAVE_CPUTIME_01 = @HAVE_CPUTIME_01@ +HAVE_GETRUSAGE_01 = @HAVE_GETRUSAGE_01@ +HAVE_GETTIMEOFDAY_01 = @HAVE_GETTIMEOFDAY_01@ +HAVE_HOST_CPU_FAMILY_power = @HAVE_HOST_CPU_FAMILY_power@ +HAVE_HOST_CPU_FAMILY_powerpc = @HAVE_HOST_CPU_FAMILY_powerpc@ +HAVE_SIGACTION_01 = @HAVE_SIGACTION_01@ +HAVE_SIGALTSTACK_01 = @HAVE_SIGALTSTACK_01@ +HAVE_SIGSTACK_01 = @HAVE_SIGSTACK_01@ +HAVE_STACK_T_01 = @HAVE_STACK_T_01@ +HAVE_SYS_RESOURCE_H_01 = @HAVE_SYS_RESOURCE_H_01@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBCURSES = @LIBCURSES@ +LIBGMPXX_LDFLAGS = @LIBGMPXX_LDFLAGS@ +LIBGMP_DLL = @LIBGMP_DLL@ +LIBGMP_LDFLAGS = @LIBGMP_LDFLAGS@ +LIBM = @LIBM@ +LIBM_FOR_BUILD = @LIBM_FOR_BUILD@ +LIBOBJS = @LIBOBJS@ +LIBREADLINE = @LIBREADLINE@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +M4 = @M4@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SPEED_CYCLECOUNTER_OBJ = @SPEED_CYCLECOUNTER_OBJ@ +STRIP = @STRIP@ +TAL_OBJECT = @TAL_OBJECT@ +TUNE_LIBS = @TUNE_LIBS@ +TUNE_SQR_OBJ = @TUNE_SQR_OBJ@ +U_FOR_BUILD = @U_FOR_BUILD@ +VERSION = @VERSION@ +WITH_READLINE_01 = @WITH_READLINE_01@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__leading_dot = @am__leading_dot@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +gmp_srclinks = @gmp_srclinks@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +mpn_objects = @mpn_objects@ +mpn_objs_in_libgmp = @mpn_objs_in_libgmp@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/tests +AM_LDFLAGS = -no-install +LDADD = $(top_builddir)/tests/libtests.la $(top_builddir)/libgmp.la +TESTS = $(check_PROGRAMS) +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps tests/mpf/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu --ignore-deps tests/mpf/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-checkPROGRAMS: + @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list + +reuse$(EXEEXT): $(reuse_OBJECTS) $(reuse_DEPENDENCIES) $(EXTRA_reuse_DEPENDENCIES) + @rm -f reuse$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(reuse_OBJECTS) $(reuse_LDADD) $(LIBS) + +t-add$(EXEEXT): $(t_add_OBJECTS) $(t_add_DEPENDENCIES) $(EXTRA_t_add_DEPENDENCIES) + @rm -f t-add$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_add_OBJECTS) $(t_add_LDADD) $(LIBS) + +t-cmp_d$(EXEEXT): $(t_cmp_d_OBJECTS) $(t_cmp_d_DEPENDENCIES) $(EXTRA_t_cmp_d_DEPENDENCIES) + @rm -f t-cmp_d$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_cmp_d_OBJECTS) $(t_cmp_d_LDADD) $(LIBS) + +t-cmp_si$(EXEEXT): $(t_cmp_si_OBJECTS) $(t_cmp_si_DEPENDENCIES) $(EXTRA_t_cmp_si_DEPENDENCIES) + @rm -f t-cmp_si$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_cmp_si_OBJECTS) $(t_cmp_si_LDADD) $(LIBS) + +t-conv$(EXEEXT): $(t_conv_OBJECTS) $(t_conv_DEPENDENCIES) $(EXTRA_t_conv_DEPENDENCIES) + @rm -f t-conv$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_conv_OBJECTS) $(t_conv_LDADD) $(LIBS) + +t-div$(EXEEXT): $(t_div_OBJECTS) $(t_div_DEPENDENCIES) $(EXTRA_t_div_DEPENDENCIES) + @rm -f t-div$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_div_OBJECTS) $(t_div_LDADD) $(LIBS) + +t-dm2exp$(EXEEXT): $(t_dm2exp_OBJECTS) $(t_dm2exp_DEPENDENCIES) $(EXTRA_t_dm2exp_DEPENDENCIES) + @rm -f t-dm2exp$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_dm2exp_OBJECTS) $(t_dm2exp_LDADD) $(LIBS) + +t-eq$(EXEEXT): $(t_eq_OBJECTS) $(t_eq_DEPENDENCIES) $(EXTRA_t_eq_DEPENDENCIES) + @rm -f t-eq$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_eq_OBJECTS) $(t_eq_LDADD) $(LIBS) + +t-fits$(EXEEXT): $(t_fits_OBJECTS) $(t_fits_DEPENDENCIES) $(EXTRA_t_fits_DEPENDENCIES) + @rm -f t-fits$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_fits_OBJECTS) $(t_fits_LDADD) $(LIBS) + +t-get_d$(EXEEXT): $(t_get_d_OBJECTS) $(t_get_d_DEPENDENCIES) $(EXTRA_t_get_d_DEPENDENCIES) + @rm -f t-get_d$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_get_d_OBJECTS) $(t_get_d_LDADD) $(LIBS) + +t-get_d_2exp$(EXEEXT): $(t_get_d_2exp_OBJECTS) $(t_get_d_2exp_DEPENDENCIES) $(EXTRA_t_get_d_2exp_DEPENDENCIES) + @rm -f t-get_d_2exp$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_get_d_2exp_OBJECTS) $(t_get_d_2exp_LDADD) $(LIBS) + +t-get_si$(EXEEXT): $(t_get_si_OBJECTS) $(t_get_si_DEPENDENCIES) $(EXTRA_t_get_si_DEPENDENCIES) + @rm -f t-get_si$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_get_si_OBJECTS) $(t_get_si_LDADD) $(LIBS) + +t-get_ui$(EXEEXT): $(t_get_ui_OBJECTS) $(t_get_ui_DEPENDENCIES) $(EXTRA_t_get_ui_DEPENDENCIES) + @rm -f t-get_ui$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_get_ui_OBJECTS) $(t_get_ui_LDADD) $(LIBS) + +t-gsprec$(EXEEXT): $(t_gsprec_OBJECTS) $(t_gsprec_DEPENDENCIES) $(EXTRA_t_gsprec_DEPENDENCIES) + @rm -f t-gsprec$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_gsprec_OBJECTS) $(t_gsprec_LDADD) $(LIBS) + +t-inp_str$(EXEEXT): $(t_inp_str_OBJECTS) $(t_inp_str_DEPENDENCIES) $(EXTRA_t_inp_str_DEPENDENCIES) + @rm -f t-inp_str$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_inp_str_OBJECTS) $(t_inp_str_LDADD) $(LIBS) + +t-int_p$(EXEEXT): $(t_int_p_OBJECTS) $(t_int_p_DEPENDENCIES) $(EXTRA_t_int_p_DEPENDENCIES) + @rm -f t-int_p$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_int_p_OBJECTS) $(t_int_p_LDADD) $(LIBS) + +t-mul_ui$(EXEEXT): $(t_mul_ui_OBJECTS) $(t_mul_ui_DEPENDENCIES) $(EXTRA_t_mul_ui_DEPENDENCIES) + @rm -f t-mul_ui$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_mul_ui_OBJECTS) $(t_mul_ui_LDADD) $(LIBS) + +t-muldiv$(EXEEXT): $(t_muldiv_OBJECTS) $(t_muldiv_DEPENDENCIES) $(EXTRA_t_muldiv_DEPENDENCIES) + @rm -f t-muldiv$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_muldiv_OBJECTS) $(t_muldiv_LDADD) $(LIBS) + +t-pow_ui$(EXEEXT): $(t_pow_ui_OBJECTS) $(t_pow_ui_DEPENDENCIES) $(EXTRA_t_pow_ui_DEPENDENCIES) + @rm -f t-pow_ui$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_pow_ui_OBJECTS) $(t_pow_ui_LDADD) $(LIBS) + +t-set$(EXEEXT): $(t_set_OBJECTS) $(t_set_DEPENDENCIES) $(EXTRA_t_set_DEPENDENCIES) + @rm -f t-set$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_set_OBJECTS) $(t_set_LDADD) $(LIBS) + +t-set_q$(EXEEXT): $(t_set_q_OBJECTS) $(t_set_q_DEPENDENCIES) $(EXTRA_t_set_q_DEPENDENCIES) + @rm -f t-set_q$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_set_q_OBJECTS) $(t_set_q_LDADD) $(LIBS) + +t-set_si$(EXEEXT): $(t_set_si_OBJECTS) $(t_set_si_DEPENDENCIES) $(EXTRA_t_set_si_DEPENDENCIES) + @rm -f t-set_si$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_set_si_OBJECTS) $(t_set_si_LDADD) $(LIBS) + +t-set_ui$(EXEEXT): $(t_set_ui_OBJECTS) $(t_set_ui_DEPENDENCIES) $(EXTRA_t_set_ui_DEPENDENCIES) + @rm -f t-set_ui$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_set_ui_OBJECTS) $(t_set_ui_LDADD) $(LIBS) + +t-sqrt$(EXEEXT): $(t_sqrt_OBJECTS) $(t_sqrt_DEPENDENCIES) $(EXTRA_t_sqrt_DEPENDENCIES) + @rm -f t-sqrt$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_sqrt_OBJECTS) $(t_sqrt_LDADD) $(LIBS) + +t-sqrt_ui$(EXEEXT): $(t_sqrt_ui_OBJECTS) $(t_sqrt_ui_DEPENDENCIES) $(EXTRA_t_sqrt_ui_DEPENDENCIES) + @rm -f t-sqrt_ui$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_sqrt_ui_OBJECTS) $(t_sqrt_ui_LDADD) $(LIBS) + +t-sub$(EXEEXT): $(t_sub_OBJECTS) $(t_sub_DEPENDENCIES) $(EXTRA_t_sub_DEPENDENCIES) + @rm -f t-sub$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_sub_OBJECTS) $(t_sub_LDADD) $(LIBS) + +t-trunc$(EXEEXT): $(t_trunc_OBJECTS) $(t_trunc_DEPENDENCIES) $(EXTRA_t_trunc_DEPENDENCIES) + @rm -f t-trunc$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_trunc_OBJECTS) $(t_trunc_LDADD) $(LIBS) + +t-ui_div$(EXEEXT): $(t_ui_div_OBJECTS) $(t_ui_div_DEPENDENCIES) $(EXTRA_t_ui_div_DEPENDENCIES) + @rm -f t-ui_div$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_ui_div_OBJECTS) $(t_ui_div_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +.c.o: + $(AM_V_CC)$(COMPILE) -c -o $@ $< + +.c.obj: + $(AM_V_CC)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: + $(AM_V_CC)$(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +# Recover from deleted '.trs' file; this should ensure that +# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create +# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells +# to avoid problems with "make -n". +.log.trs: + rm -f $< $@ + $(MAKE) $(AM_MAKEFLAGS) $< + +# Leading 'am--fnord' is there to ensure the list of targets does not +# expand to empty, as could happen e.g. with make check TESTS=''. +am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) +am--force-recheck: + @: + +$(TEST_SUITE_LOG): $(TEST_LOGS) + @$(am__set_TESTS_bases); \ + am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ + redo_bases=`for i in $$bases; do \ + am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ + done`; \ + if test -n "$$redo_bases"; then \ + redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ + redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ + if $(am__make_dryrun); then :; else \ + rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ + fi; \ + fi; \ + if test -n "$$am__remaking_logs"; then \ + echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ + "recursion detected" >&2; \ + elif test -n "$$redo_logs"; then \ + am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ + fi; \ + if $(am__make_dryrun); then :; else \ + st=0; \ + errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ + for i in $$redo_bases; do \ + test -f $$i.trs && test -r $$i.trs \ + || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ + test -f $$i.log && test -r $$i.log \ + || { echo "$$errmsg $$i.log" >&2; st=1; }; \ + done; \ + test $$st -eq 0 || exit 1; \ + fi + @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ + ws='[ ]'; \ + results=`for b in $$bases; do echo $$b.trs; done`; \ + test -n "$$results" || results=/dev/null; \ + all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ + pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ + fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ + skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ + xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ + xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ + error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ + if test `expr $$fail + $$xpass + $$error` -eq 0; then \ + success=true; \ + else \ + success=false; \ + fi; \ + br='==================='; br=$$br$$br$$br$$br; \ + result_count () \ + { \ + if test x"$$1" = x"--maybe-color"; then \ + maybe_colorize=yes; \ + elif test x"$$1" = x"--no-color"; then \ + maybe_colorize=no; \ + else \ + echo "$@: invalid 'result_count' usage" >&2; exit 4; \ + fi; \ + shift; \ + desc=$$1 count=$$2; \ + if test $$maybe_colorize = yes && test $$count -gt 0; then \ + color_start=$$3 color_end=$$std; \ + else \ + color_start= color_end=; \ + fi; \ + echo "$${color_start}# $$desc $$count$${color_end}"; \ + }; \ + create_testsuite_report () \ + { \ + result_count $$1 "TOTAL:" $$all "$$brg"; \ + result_count $$1 "PASS: " $$pass "$$grn"; \ + result_count $$1 "SKIP: " $$skip "$$blu"; \ + result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ + result_count $$1 "FAIL: " $$fail "$$red"; \ + result_count $$1 "XPASS:" $$xpass "$$red"; \ + result_count $$1 "ERROR:" $$error "$$mgn"; \ + }; \ + { \ + echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ + $(am__rst_title); \ + create_testsuite_report --no-color; \ + echo; \ + echo ".. contents:: :depth: 2"; \ + echo; \ + for b in $$bases; do echo $$b; done \ + | $(am__create_global_log); \ + } >$(TEST_SUITE_LOG).tmp || exit 1; \ + mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ + if $$success; then \ + col="$$grn"; \ + else \ + col="$$red"; \ + test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ + fi; \ + echo "$${col}$$br$${std}"; \ + echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ + echo "$${col}$$br$${std}"; \ + create_testsuite_report --maybe-color; \ + echo "$$col$$br$$std"; \ + if $$success; then :; else \ + echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ + if test -n "$(PACKAGE_BUGREPORT)"; then \ + echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ + fi; \ + echo "$$col$$br$$std"; \ + fi; \ + $$success || exit 1 + +check-TESTS: + @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list + @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list + @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @set +e; $(am__set_TESTS_bases); \ + log_list=`for i in $$bases; do echo $$i.log; done`; \ + trs_list=`for i in $$bases; do echo $$i.trs; done`; \ + log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ + $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ + exit $$?; +recheck: all $(check_PROGRAMS) + @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @set +e; $(am__set_TESTS_bases); \ + bases=`for i in $$bases; do echo $$i; done \ + | $(am__list_recheck_tests)` || exit 1; \ + log_list=`for i in $$bases; do echo $$i.log; done`; \ + log_list=`echo $$log_list`; \ + $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ + am__force_recheck=am--force-recheck \ + TEST_LOGS="$$log_list"; \ + exit $$? +t-dm2exp.log: t-dm2exp$(EXEEXT) + @p='t-dm2exp$(EXEEXT)'; \ + b='t-dm2exp'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +t-conv.log: t-conv$(EXEEXT) + @p='t-conv$(EXEEXT)'; \ + b='t-conv'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +t-add.log: t-add$(EXEEXT) + @p='t-add$(EXEEXT)'; \ + b='t-add'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +t-sub.log: t-sub$(EXEEXT) + @p='t-sub$(EXEEXT)'; \ + b='t-sub'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +t-sqrt.log: t-sqrt$(EXEEXT) + @p='t-sqrt$(EXEEXT)'; \ + b='t-sqrt'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +t-sqrt_ui.log: t-sqrt_ui$(EXEEXT) + @p='t-sqrt_ui$(EXEEXT)'; \ + b='t-sqrt_ui'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +t-muldiv.log: t-muldiv$(EXEEXT) + @p='t-muldiv$(EXEEXT)'; \ + b='t-muldiv'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +reuse.log: reuse$(EXEEXT) + @p='reuse$(EXEEXT)'; \ + b='reuse'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +t-cmp_d.log: t-cmp_d$(EXEEXT) + @p='t-cmp_d$(EXEEXT)'; \ + b='t-cmp_d'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +t-cmp_si.log: t-cmp_si$(EXEEXT) + @p='t-cmp_si$(EXEEXT)'; \ + b='t-cmp_si'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +t-div.log: t-div$(EXEEXT) + @p='t-div$(EXEEXT)'; \ + b='t-div'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +t-fits.log: t-fits$(EXEEXT) + @p='t-fits$(EXEEXT)'; \ + b='t-fits'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +t-get_d.log: t-get_d$(EXEEXT) + @p='t-get_d$(EXEEXT)'; \ + b='t-get_d'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +t-get_d_2exp.log: t-get_d_2exp$(EXEEXT) + @p='t-get_d_2exp$(EXEEXT)'; \ + b='t-get_d_2exp'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +t-get_si.log: t-get_si$(EXEEXT) + @p='t-get_si$(EXEEXT)'; \ + b='t-get_si'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +t-get_ui.log: t-get_ui$(EXEEXT) + @p='t-get_ui$(EXEEXT)'; \ + b='t-get_ui'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +t-gsprec.log: t-gsprec$(EXEEXT) + @p='t-gsprec$(EXEEXT)'; \ + b='t-gsprec'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +t-inp_str.log: t-inp_str$(EXEEXT) + @p='t-inp_str$(EXEEXT)'; \ + b='t-inp_str'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +t-int_p.log: t-int_p$(EXEEXT) + @p='t-int_p$(EXEEXT)'; \ + b='t-int_p'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +t-mul_ui.log: t-mul_ui$(EXEEXT) + @p='t-mul_ui$(EXEEXT)'; \ + b='t-mul_ui'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +t-set.log: t-set$(EXEEXT) + @p='t-set$(EXEEXT)'; \ + b='t-set'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +t-set_q.log: t-set_q$(EXEEXT) + @p='t-set_q$(EXEEXT)'; \ + b='t-set_q'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +t-set_si.log: t-set_si$(EXEEXT) + @p='t-set_si$(EXEEXT)'; \ + b='t-set_si'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +t-set_ui.log: t-set_ui$(EXEEXT) + @p='t-set_ui$(EXEEXT)'; \ + b='t-set_ui'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +t-trunc.log: t-trunc$(EXEEXT) + @p='t-trunc$(EXEEXT)'; \ + b='t-trunc'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +t-ui_div.log: t-ui_div$(EXEEXT) + @p='t-ui_div$(EXEEXT)'; \ + b='t-ui_div'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +t-eq.log: t-eq$(EXEEXT) + @p='t-eq$(EXEEXT)'; \ + b='t-eq'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +t-pow_ui.log: t-pow_ui$(EXEEXT) + @p='t-pow_ui$(EXEEXT)'; \ + b='t-pow_ui'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +.test.log: + @p='$<'; \ + $(am__set_b); \ + $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +@am__EXEEXT_TRUE@.test$(EXEEXT).log: +@am__EXEEXT_TRUE@ @p='$<'; \ +@am__EXEEXT_TRUE@ $(am__set_b); \ +@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ +@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ +@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ +@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) + -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) + -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ + mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: check-am install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \ + clean-checkPROGRAMS clean-generic clean-libtool cscopelist-am \ + ctags ctags-am distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + recheck tags tags-am uninstall uninstall-am + +.PRECIOUS: Makefile + + +$(top_builddir)/tests/libtests.la: + cd $(top_builddir)/tests; $(MAKE) $(AM_MAKEFLAGS) libtests.la + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/vendor/gmp-6.3.0/tests/mpf/reuse.c b/vendor/gmp-6.3.0/tests/mpf/reuse.c new file mode 100644 index 0000000..86db5b3 --- /dev/null +++ b/vendor/gmp-6.3.0/tests/mpf/reuse.c @@ -0,0 +1,218 @@ +/* Test that routines allow reusing a source variable as destination. + +Copyright 1996, 2000-2002, 2012 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite 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. + +The GNU MP Library test suite 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 +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "gmp-impl.h" +#include "tests.h" + +#if __GMP_LIBGMP_DLL + +/* FIXME: When linking to a DLL libgmp, mpf_add etc can't be used as + initializers for global variables because they're effectively global + variables (function pointers) themselves. Perhaps calling a test + function successively with mpf_add etc would be better. */ + +int +main (void) +{ + printf ("Test suppressed for windows DLL\n"); + exit (0); +} + + +#else /* ! DLL_EXPORT */ + +#ifndef SIZE +#define SIZE 16 +#endif + +#ifndef EXPO +#define EXPO 32 +#endif + +void dump_abort (const char *, mpf_t, mpf_t); + +typedef void (*dss_func) (mpf_ptr, mpf_srcptr, mpf_srcptr); + +dss_func dss_funcs[] = +{ + mpf_div, mpf_add, mpf_mul, mpf_sub, +}; + +const char *dss_func_names[] = +{ + "mpf_div", "mpf_add", "mpf_mul", "mpf_sub", +}; + +typedef void (*dsi_func) (mpf_ptr, mpf_srcptr, unsigned long int); + +dsi_func dsi_funcs[] = +{ + mpf_div_ui, mpf_add_ui, mpf_mul_ui, mpf_sub_ui, + mpf_mul_2exp, mpf_div_2exp, mpf_pow_ui +}; + +const char *dsi_func_names[] = +{ + "mpf_div_ui", "mpf_add_ui", "mpf_mul_ui", "mpf_sub_ui", + "mpf_mul_2exp", "mpf_div_2exp", "mpf_pow_ui" +}; + +typedef void (*dis_func) (mpf_ptr, unsigned long int, mpf_srcptr); + +dis_func dis_funcs[] = +{ + mpf_ui_div, mpf_ui_sub, +}; + +const char *dis_func_names[] = +{ + "mpf_ui_div", "mpf_ui_sub", +}; + +int +main (int argc, char **argv) +{ + int i; + int pass, reps = 10000; + mpf_t in1, in2, out1; + unsigned long int in1i, in2i; + mpf_t res1, res2, res3; + mp_size_t bprec = 100; + + tests_start (); + + if (argc > 1) + { + reps = strtol (argv[1], 0, 0); + if (argc > 2) + bprec = strtol (argv[2], 0, 0); + } + + mpf_set_default_prec (bprec); + + mpf_init (in1); + mpf_init (in2); + mpf_init (out1); + mpf_init (res1); + mpf_init (res2); + mpf_init (res3); + + for (pass = 1; pass <= reps; pass++) + { + mpf_random2 (in1, urandom () % SIZE - SIZE/2, urandom () % EXPO); + mpf_random2 (in2, urandom () % SIZE - SIZE/2, urandom () % EXPO); + + for (i = 0; i < sizeof (dss_funcs) / sizeof (dss_func); i++) + { + /* Don't divide by 0. */ + if (i == 0 && mpf_cmp_ui (in2, 0) == 0) + continue; + + (dss_funcs[i]) (res1, in1, in2); + + mpf_set (out1, in1); + (dss_funcs[i]) (out1, out1, in2); + mpf_set (res2, out1); + + mpf_set (out1, in2); + (dss_funcs[i]) (out1, in1, out1); + mpf_set (res3, out1); + + if (mpf_cmp (res1, res2) != 0) + dump_abort (dss_func_names[i], res1, res2); + if (mpf_cmp (res1, res3) != 0) + dump_abort (dss_func_names[i], res1, res3); + } + + in2i = urandom (); + for (i = 0; i < sizeof (dsi_funcs) / sizeof (dsi_func); i++) + { + unsigned long this_in2i = in2i; + + /* Don't divide by 0. */ + if (i == 0 && this_in2i == 0) /* dsi_funcs[i] == mpf_div_ui */ + continue; + + /* Avoid overflow/underflow in the exponent. */ + if (dsi_funcs[i] == mpf_mul_2exp || dsi_funcs[i] == mpf_div_2exp) + this_in2i %= 0x100000; + else if (dsi_funcs[i] == mpf_pow_ui) + this_in2i %= 0x1000; + + (dsi_funcs[i]) (res1, in1, this_in2i); + + mpf_set (out1, in1); + (dsi_funcs[i]) (out1, out1, this_in2i); + mpf_set (res2, out1); + + if (mpf_cmp (res1, res2) != 0) + dump_abort (dsi_func_names[i], res1, res2); + } + + in1i = urandom (); + for (i = 0; i < sizeof (dis_funcs) / sizeof (dis_func); i++) + { + /* Don't divide by 0. */ + if (i == 0 /* dis_funcs[i] == mpf_ui_div */ + && mpf_cmp_ui (in2, 0) == 0) + continue; + + (dis_funcs[i]) (res1, in1i, in2); + + mpf_set (out1, in2); + (dis_funcs[i]) (out1, in1i, out1); + mpf_set (res2, out1); + + if (mpf_cmp (res1, res2) != 0) + dump_abort (dis_func_names[i], res1, res2); + } + + } + + mpf_clear (in1); + mpf_clear (in2); + mpf_clear (out1); + mpf_clear (res1); + mpf_clear (res2); + mpf_clear (res3); + + tests_end (); + exit (0); +} + +void +dump_abort (const char *name, mpf_t res1, mpf_t res2) +{ + printf ("failure in %s:\n", name); + mpf_dump (res1); + mpf_dump (res2); + abort (); +} + +#if 0 +void mpf_abs (mpf_ptr, mpf_srcptr); +void mpf_sqrt (mpf_ptr, mpf_srcptr); +void mpf_neg (mpf_ptr, mpf_srcptr); +#endif + +#endif /* ! DLL_EXPORT */ diff --git a/vendor/gmp-6.3.0/tests/mpf/t-add.c b/vendor/gmp-6.3.0/tests/mpf/t-add.c new file mode 100644 index 0000000..eb8bbdc --- /dev/null +++ b/vendor/gmp-6.3.0/tests/mpf/t-add.c @@ -0,0 +1,107 @@ +/* Test mpf_add. + +Copyright 1996, 2001 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite 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. + +The GNU MP Library test suite 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 +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + +#include <stdio.h> +#include <stdlib.h> + +#include "gmp-impl.h" +#include "tests.h" + +#ifndef SIZE +#define SIZE 16 +#endif + +int +main (int argc, char **argv) +{ + mp_size_t size; + mp_exp_t exp; + int reps = 20000; + int i; + mpf_t u, v, w, wref; + mp_size_t bprec = 100; + mpf_t rerr, max_rerr, limit_rerr; + + tests_start (); + + if (argc > 1) + { + reps = strtol (argv[1], 0, 0); + if (argc > 2) + bprec = strtol (argv[2], 0, 0); + } + + mpf_set_default_prec (bprec); + + mpf_init_set_ui (limit_rerr, 1); + mpf_div_2exp (limit_rerr, limit_rerr, bprec); +#if VERBOSE + mpf_dump (limit_rerr); +#endif + mpf_init (rerr); + mpf_init_set_ui (max_rerr, 0); + + mpf_init (u); + mpf_init (v); + mpf_init (w); + mpf_init (wref); + for (i = 0; i < reps; i++) + { + size = urandom () % (2 * SIZE) - SIZE; + exp = urandom () % SIZE; + mpf_random2 (u, size, exp); + + size = urandom () % (2 * SIZE) - SIZE; + exp = urandom () % SIZE; + mpf_random2 (v, size, exp); + + mpf_add (w, u, v); + refmpf_add (wref, u, v); + + mpf_reldiff (rerr, w, wref); + if (mpf_cmp (rerr, max_rerr) > 0) + { + mpf_set (max_rerr, rerr); +#if VERBOSE + mpf_dump (max_rerr); +#endif + if (mpf_cmp (rerr, limit_rerr) > 0) + { + printf ("ERROR after %d tests\n", i); + printf (" u = "); mpf_dump (u); + printf (" v = "); mpf_dump (v); + printf ("wref = "); mpf_dump (wref); + printf (" w = "); mpf_dump (w); + abort (); + } + } + } + + mpf_clear (limit_rerr); + mpf_clear (rerr); + mpf_clear (max_rerr); + + mpf_clear (u); + mpf_clear (v); + mpf_clear (w); + mpf_clear (wref); + + tests_end (); + exit (0); +} diff --git a/vendor/gmp-6.3.0/tests/mpf/t-cmp_d.c b/vendor/gmp-6.3.0/tests/mpf/t-cmp_d.c new file mode 100644 index 0000000..213c091 --- /dev/null +++ b/vendor/gmp-6.3.0/tests/mpf/t-cmp_d.c @@ -0,0 +1,103 @@ +/* Test mpf_cmp_d. + +Copyright 2001, 2003, 2003, 2005 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite 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. + +The GNU MP Library test suite 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 +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "gmp-impl.h" +#include "tests.h" + + +#define SGN(n) ((n) > 0 ? 1 : (n) < 0 ? -1 : 0) + +void +check_one (const char *name, mpf_srcptr x, double y, int cmp) +{ + int got; + + got = mpf_cmp_d (x, y); + if (SGN(got) != cmp) + { + int i; + printf ("mpf_cmp_d wrong (from %s)\n", name); + printf (" got %d\n", got); + printf (" want %d\n", cmp); + mpf_trace (" x", x); + printf (" y %g\n", y); + mp_trace_base=-16; + mpf_trace (" x", x); + printf (" y %g\n", y); + printf (" y"); + for (i = 0; i < sizeof(y); i++) + printf (" %02X", (unsigned) ((unsigned char *) &y)[i]); + printf ("\n"); + abort (); + } +} + +void +check_infinity (void) +{ + mpf_t x; + double y = tests_infinity_d (); + if (y == 0.0) + return; + + mpf_init (x); + + /* 0 cmp inf */ + mpf_set_ui (x, 0L); + check_one ("check_infinity", x, y, -1); + check_one ("check_infinity", x, -y, 1); + + /* 123 cmp inf */ + mpf_set_ui (x, 123L); + check_one ("check_infinity", x, y, -1); + check_one ("check_infinity", x, -y, 1); + + /* -123 cmp inf */ + mpf_set_si (x, -123L); + check_one ("check_infinity", x, y, -1); + check_one ("check_infinity", x, -y, 1); + + /* 2^5000 cmp inf */ + mpf_set_ui (x, 1L); + mpf_mul_2exp (x, x, 5000L); + check_one ("check_infinity", x, y, -1); + check_one ("check_infinity", x, -y, 1); + + /* -2^5000 cmp inf */ + mpf_neg (x, x); + check_one ("check_infinity", x, y, -1); + check_one ("check_infinity", x, -y, 1); + + mpf_clear (x); +} + +int +main (int argc, char *argv[]) +{ + tests_start (); + + check_infinity (); + + tests_end (); + exit (0); +} diff --git a/vendor/gmp-6.3.0/tests/mpf/t-cmp_si.c b/vendor/gmp-6.3.0/tests/mpf/t-cmp_si.c new file mode 100644 index 0000000..29f7cdb --- /dev/null +++ b/vendor/gmp-6.3.0/tests/mpf/t-cmp_si.c @@ -0,0 +1,134 @@ +/* Test mpf_cmp_si and mpf_cmp_z. + +Copyright 2000, 2001, 2004, 2015 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite 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. + +The GNU MP Library test suite 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 +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + +#include <stdio.h> +#include <stdlib.h> +#include "gmp-impl.h" +#include "tests.h" + +#define SGN(x) ((x) < 0 ? -1 : (x) == 0 ? 0 : 1) + +void +check_data (void) +{ + static const struct { + int a_base; + const char *a; + const char *b; + int want; + } data[] = { + { 10, "0", "1", -1 }, + { 10, "0", "0", 0 }, + { 10, "0", "-1", 1 }, + + { 10, "1", "1", 0 }, + { 10, "1", "0", 1 }, + { 10, "1", "-1", 1 }, + + { 10, "-1", "1", -1 }, + { 10, "-1", "0", -1 }, + { 10, "-1", "-1", 0 }, + + { 10, "1.5", "2", -1 }, + { 10, "1.5", "1", 1 }, + { 10, "0.5", "1", -1 }, + + { 10, "-1.5", "-2", 1 }, + { 10, "-1.5", "-1", -1 }, + { 10, "-0.5", "-1", 1 }, + + { 16, "0", "-0x80000000", 1 }, + { 16, "80000000", "-0x80000000", 1 }, + { 16, "80000001", "-0x80000000", 1 }, + { 16, "-80000000", "-0x80000000", 0 }, + { 16, "-80000001", "-0x80000000", -1 }, + { 16, "-FF0080000001", "-0x80000000", -1 }, + + { 16, "0", "-0x8000000000000000", 1 }, + { 16, "8000000000000000", "-0x8000000000000000", 1 }, + { 16, "8000000000000001", "-0x8000000000000000", 1 }, + { 16, "-8000000000000000", "-0x8000000000000000", 0 }, + { 16, "-8000000000000000.1", "-0x8000000000000000", -1 }, + { 16, "-FF008000000000000001", "-0x8000000000000000", -1 }, + + { 16, "0", "-0x876543210FEDCBA9876543210000000", 1 }, + { 16, "876543210FEDCBA9876543210000000", "-0x876543210FEDCBA9876543210000000", 1 }, + { 16, "876543210FEDCBA9876543210000001", "-0x876543210FEDCBA9876543210000000", 1 }, + { 16, "-876543210FEDCBA9876543210000000", "-0x876543210FEDCBA9876543210000000", 0 }, + { 16, "-876543210FEDCBA9876543210000000.1", "-0x876543210FEDCBA9876543210000000", -1 }, + { 16, "-FF00876543210FEDCBA9876543210000000", "-0x876543210FEDCBA9876543210000000", -1 }, + }; + + mpf_t a; + mpz_t bz; + long b; + int got; + int i; + + mpf_init2 (a, 128); + mpz_init (bz); + for (i = 0; i < numberof (data); i++) + { + mpf_set_str_or_abort (a, data[i].a, data[i].a_base); + mpz_set_str_or_abort (bz, data[i].b, 0); + + if (mpz_fits_slong_p (bz)) + { + b = mpz_get_si (bz); + got = mpf_cmp_si (a, b); + if (SGN (got) != data[i].want) + { + printf ("mpf_cmp_si wrong on data[%d]\n", i); + printf (" a="); mpf_out_str (stdout, 10, 0, a); + printf (" (%s)\n", data[i].a); + printf (" b=%ld (%s)\n", b, data[i].b); + printf (" got=%d\n", got); + printf (" want=%d\n", data[i].want); + abort(); + } + } + + got = mpf_cmp_z (a, bz); + if (SGN (got) != data[i].want) + { + b = mpz_get_si (bz); + printf ("mpf_cmp_z wrong on data[%d]\n", i); + printf (" a="); mpf_out_str (stdout, 10, 0, a); + printf (" (%s)\n", data[i].a); + printf (" b=%ld (%s)\n", b, data[i].b); + printf (" got=%d\n", got); + printf (" want=%d\n", data[i].want); + abort(); + } + } + + mpf_clear (a); + mpz_clear (bz); +} + +int +main (void) +{ + tests_start (); + + check_data (); + + tests_end (); + exit (0); +} diff --git a/vendor/gmp-6.3.0/tests/mpf/t-conv.c b/vendor/gmp-6.3.0/tests/mpf/t-conv.c new file mode 100644 index 0000000..2f992af --- /dev/null +++ b/vendor/gmp-6.3.0/tests/mpf/t-conv.c @@ -0,0 +1,261 @@ +/* Test mpf_get_str and mpf_set_str. + +Copyright 1996, 2000, 2001, 2008, 2019, 2020 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite 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. + +The GNU MP Library test suite 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 +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> /* for strlen */ + +#include "gmp-impl.h" +#include "tests.h" + +#ifndef SIZE +#define SIZE 10 +#endif + +#ifndef EXPO +#define EXPO 200 +#endif + +int +main (int argc, char **argv) +{ + mpf_t x, y; + int reps = 20000; + int i; + mp_size_t bprec = 100; + mpf_t d, rerr, max_rerr, limit_rerr; + char *str; + mp_exp_t bexp; + long size, exp; + int base; + char buf[SIZE * GMP_LIMB_BITS + 5]; + + tests_start (); + + if (argc > 1) + { + reps = strtol (argv[1], 0, 0); + if (argc > 2) + bprec = strtol (argv[2], 0, 0); + } + + mpf_set_default_prec (bprec); + + mpf_init_set_ui (limit_rerr, 1); + mpf_div_2exp (limit_rerr, limit_rerr, bprec); +#if VERBOSE + mpf_dump (limit_rerr); +#endif + mpf_init (rerr); + mpf_init_set_ui (max_rerr, 0); + + mpf_init (x); + mpf_init (y); + mpf_init (d); + + /* First test some specific values. */ + + mpf_set_str (y, "1.23456", 0); + mpf_set_str (x, "1.23456", 10); + MPF_CHECK_FORMAT (x); + if (mpf_cmp (x, y) != 0) + abort (); + mpf_set_str (x, "00000000000000000000000000000000000000001.23456", 10); + MPF_CHECK_FORMAT (x); + if (mpf_cmp (x, y) != 0) + abort (); + mpf_set_str (x, "0.000000000000000000000000000000000000000123456e40", 10); + MPF_CHECK_FORMAT (x); + if (mpf_cmp (x, y) != 0) + abort (); + mpf_set_str (x, ".000000000000000000000000000000000000000123456e40", 10); + MPF_CHECK_FORMAT (x); + if (mpf_cmp (x, y) != 0) + abort (); + mpf_set_str (x, "00000000000000000000.00000000000000000000123456e21", 10); + MPF_CHECK_FORMAT (x); + if (mpf_cmp (x, y) != 0) + abort (); + + mpf_set_str (y, "1.23456e1000", 0); + mpf_set_str (x, "1.23456e1000", 10); + if (mpf_cmp (x, y) != 0) + abort (); + mpf_set_str (x, "1.23456e+1000", 0); + if (mpf_cmp (x, y) != 0) + abort (); + mpf_set_str (x, "1.23456e+1000", 10); + if (mpf_cmp (x, y) != 0) + abort (); + mpf_set_str (x, "00000000000000000000000000000000000000001.23456e+1000", 10); + MPF_CHECK_FORMAT (x); + if (mpf_cmp (x, y) != 0) + abort (); + mpf_set_str (x, "0.000000000000000000000000000000000000000123456e+1040", 10); + MPF_CHECK_FORMAT (x); + if (mpf_cmp (x, y) != 0) + abort (); + mpf_set_str (x, ".000000000000000000000000000000000000000123456e+1040", 10); + MPF_CHECK_FORMAT (x); + if (mpf_cmp (x, y) != 0) + abort (); + mpf_set_str (x, "00000000000000000000.00000000000000000000123456e+1021", 10); + MPF_CHECK_FORMAT (x); + if (mpf_cmp (x, y) != 0) + abort (); + + mpf_set_str (y, "1.23456", 16); + mpf_set_str (x, "00000000000000000000000000000000000000001.23456", 16); + MPF_CHECK_FORMAT (x); + if (mpf_cmp (x, y) != 0) + abort (); + mpf_set_str (x, "0.000000000000000000000000000000000000000123456@28", 16); + MPF_CHECK_FORMAT (x); + if (mpf_cmp (x, y) != 0) + abort (); + mpf_set_str (x, ".000000000000000000000000000000000000000123456@28", 16); + MPF_CHECK_FORMAT (x); + if (mpf_cmp (x, y) != 0) + abort (); + mpf_set_str (x, "00000000000000000000.00000000000000000000123456@15", 16); + MPF_CHECK_FORMAT (x); + if (mpf_cmp (x, y) != 0) + abort (); + + mpf_set_str (y, " 0", 10); + mpf_set_str (x, "00000000000000000000000000000000000000000000000000000", 10); + MPF_CHECK_FORMAT (x); + if (mpf_cmp (x, y) != 0) + abort (); + mpf_set_str (x, "0000000000000000000000000000000000000000000000000000.", 10); + MPF_CHECK_FORMAT (x); + if (mpf_cmp (x, y) != 0) + abort (); + mpf_set_str (x, "000000000000000000000000000000000000000000000000000.0", 10); + MPF_CHECK_FORMAT (x); + if (mpf_cmp (x, y) != 0) + abort (); + mpf_set_str (x, ".0000000000000000000000000000000000000000000000000000", 10); + MPF_CHECK_FORMAT (x); + if (mpf_cmp (x, y) != 0) + abort (); + mpf_set_str (x, "0.000000000000000000000000000000000000000000000000000", 10); + MPF_CHECK_FORMAT (x); + if (mpf_cmp (x, y) != 0) + abort (); + + mpf_set_str (x, "00000000000000000000000000000000000000000000000000000", 16); + MPF_CHECK_FORMAT (x); + if (mpf_cmp (x, y) != 0) + abort (); + mpf_set_str (x, "0000000000000000000000000000000000000000000000000000.", 16); + MPF_CHECK_FORMAT (x); + if (mpf_cmp (x, y) != 0) + abort (); + mpf_set_str (x, "000000000000000000000000000000000000000000000000000.0", 16); + MPF_CHECK_FORMAT (x); + if (mpf_cmp (x, y) != 0) + abort (); + mpf_set_str (x, ".0000000000000000000000000000000000000000000000000000", 16); + MPF_CHECK_FORMAT (x); + if (mpf_cmp (x, y) != 0) + abort (); + mpf_set_str (x, "0.000000000000000000000000000000000000000000000000000", 16); + MPF_CHECK_FORMAT (x); + if (mpf_cmp (x, y) != 0) + abort (); + mpf_set_str (x, "+00000000000000000000000000000000000000000000000000000e-345", 9); + MPF_CHECK_FORMAT (x); + if (mpf_cmp (x, y) != 0) + abort (); + mpf_set_str (x, "-0000000000000000000000000000000000000000000000000000.@AB", 26); + MPF_CHECK_FORMAT (x); + if (mpf_cmp (x, y) != 0) + abort (); + mpf_set_str (x, "000000000000000000000000000000000000000000000000000.0@78", 19); + MPF_CHECK_FORMAT (x); + if (mpf_cmp (x, y) != 0) + abort (); + mpf_set_str (x, "+.0000000000000000000000000000000000000000000000000000e555", 6); + MPF_CHECK_FORMAT (x); + if (mpf_cmp (x, y) != 0) + abort (); + mpf_set_str (x, "-0.000000000000000000000000000000000000000000000000000@-AAAAAAAAAAAAAAAAAAAAAAAA", 17); + MPF_CHECK_FORMAT (x); + if (mpf_cmp (x, y) != 0) + abort (); + + /* Now test random values. */ + + for (i = 0; i < reps; i++) + { + if (i == 0) + { + /* exercise the special case in get_str for for x==0 */ + mpf_set_ui (x, 0L); + base = 0; + } + else + { + size = urandom () % (2 * SIZE) - SIZE; + exp = urandom () % EXPO; + mpf_random2 (x, size, exp); + base = urandom () % 62; + base += base > 0; + } + + str = mpf_get_str (0, &bexp, base, 0, x); + + if (str[0] == '-') + sprintf (buf, "-0.%s@%ld", str + 1, bexp); + else + sprintf (buf, "0.%s@%ld", str, bexp); + + mpf_set_str_or_abort (y, buf, -base); + (*__gmp_free_func) (str, strlen (str) + 1); + + mpf_reldiff (rerr, x, y); + if (mpf_cmp (rerr, max_rerr) > 0) + { + mpf_set (max_rerr, rerr); +#if VERBOSE + mpf_dump (max_rerr); +#endif + if (mpf_cmp (rerr, limit_rerr) > 0) + { + printf ("ERROR after %d tests\n", i); + printf ("base = %d\n", base); + printf (" x = "); mpf_dump (x); + printf (" y = "); mpf_dump (y); + abort (); + } + } + } + + mpf_clear (limit_rerr); + mpf_clear (rerr); + mpf_clear (max_rerr); + + mpf_clear (x); + mpf_clear (y); + mpf_clear (d); + + tests_end (); + exit (0); +} diff --git a/vendor/gmp-6.3.0/tests/mpf/t-div.c b/vendor/gmp-6.3.0/tests/mpf/t-div.c new file mode 100644 index 0000000..3214592 --- /dev/null +++ b/vendor/gmp-6.3.0/tests/mpf/t-div.c @@ -0,0 +1,185 @@ +/* Test mpf_div. + +Copyright 2004 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite 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. + +The GNU MP Library test suite 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 +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + +#include <stdio.h> +#include <stdlib.h> +#include "gmp-impl.h" +#include "tests.h" + + +void +check_one (const char *desc, mpf_ptr got, mpf_srcptr u, mpf_srcptr v) +{ + if (! refmpf_validate_division ("mpf_div", got, u, v)) + { + mp_trace_base = -16; + mpf_trace (" u", u); + mpf_trace (" v", v); + printf (" %s\n", desc); + abort (); + } +} + +void +check_rand (void) +{ + unsigned long min_prec = __GMPF_BITS_TO_PREC (1); + gmp_randstate_ptr rands = RANDS; + unsigned long prec; + mpf_t got, u, v; + int i; + + mpf_init (got); + mpf_init (u); + mpf_init (v); + + /* separate */ + for (i = 0; i < 100; i++) + { + /* got precision */ + prec = min_prec + gmp_urandomm_ui (rands, 15L); + refmpf_set_prec_limbs (got, prec); + + /* u */ + prec = min_prec + gmp_urandomm_ui (rands, 15L); + refmpf_set_prec_limbs (u, prec); + do { + mpf_random2 (u, PREC(u), (mp_exp_t) 20); + } while (SIZ(u) == 0); + if (gmp_urandomb_ui (rands, 1L)) + mpf_neg (u, u); + + /* v */ + prec = min_prec + gmp_urandomm_ui (rands, 15L); + refmpf_set_prec_limbs (v, prec); + do { + mpf_random2 (v, PREC(v), (mp_exp_t) 20); + } while (SIZ(v) == 0); + if (gmp_urandomb_ui (rands, 1L)) + mpf_neg (v, v); + + switch (i % 3) { + case 0: + mpf_div (got, u, v); + check_one ("separate", got, u, v); + break; + case 1: + prec = refmpf_set_overlap (got, u); + mpf_div (got, got, v); + check_one ("dst == u", got, u, v); + mpf_set_prec_raw (got, prec); + break; + case 2: + prec = refmpf_set_overlap (got, v); + mpf_div (got, u, got); + check_one ("dst == v", got, u, v); + mpf_set_prec_raw (got, prec); + break; + } + } + + mpf_clear (got); + mpf_clear (u); + mpf_clear (v); +} + +/* Exercise calls mpf(x,x,x) */ +void +check_reuse_three (void) +{ + unsigned long min_prec = __GMPF_BITS_TO_PREC (1); + gmp_randstate_ptr rands = RANDS; + unsigned long result_prec, input_prec, set_prec; + mpf_t got; + int i; + + mpf_init (got); + + for (i = 0; i < 8; i++) + { + result_prec = min_prec + gmp_urandomm_ui (rands, 15L); + input_prec = min_prec + gmp_urandomm_ui (rands, 15L); + + set_prec = MAX (result_prec, input_prec); + refmpf_set_prec_limbs (got, set_prec); + + /* input, non-zero, possibly negative */ + PREC(got) = input_prec; + do { + mpf_random2 (got, input_prec, (mp_exp_t) 20); + } while (SIZ(got) == 0); + if (gmp_urandomb_ui (rands, 1L)) + mpf_neg (got, got); + + PREC(got) = result_prec; + + mpf_div (got, got, got); + + /* expect exactly 1.0 always */ + ASSERT_ALWAYS (mpf_cmp_ui (got, 1L) == 0); + + PREC(got) = set_prec; + } + + mpf_clear (got); +} + +void +check_various (void) +{ + mpf_t got, u, v; + + mpf_init (got); + mpf_init (u); + mpf_init (v); + + /* 100/4 == 25 */ + mpf_set_prec (got, 20L); + mpf_set_ui (u, 100L); + mpf_set_ui (v, 4L); + mpf_div (got, u, v); + MPF_CHECK_FORMAT (got); + ASSERT_ALWAYS (mpf_cmp_ui (got, 25L) == 0); + + /* 1/(2^n+1), a case where truncating the divisor would be wrong */ + mpf_set_prec (got, 500L); + mpf_set_prec (v, 900L); + mpf_set_ui (v, 1L); + mpf_mul_2exp (v, v, 800L); + mpf_add_ui (v, v, 1L); + mpf_div (got, u, v); + check_one ("1/2^n+1, separate", got, u, v); + + mpf_clear (got); + mpf_clear (u); + mpf_clear (v); +} + +int +main (void) +{ + tests_start (); + + check_various (); + check_rand (); + check_reuse_three (); + + tests_end (); + exit (0); +} diff --git a/vendor/gmp-6.3.0/tests/mpf/t-dm2exp.c b/vendor/gmp-6.3.0/tests/mpf/t-dm2exp.c new file mode 100644 index 0000000..d17c9fa --- /dev/null +++ b/vendor/gmp-6.3.0/tests/mpf/t-dm2exp.c @@ -0,0 +1,118 @@ +/* Test mpf_div, mpf_div_2exp, mpf_mul_2exp. + +Copyright 1996, 2000, 2001 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite 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. + +The GNU MP Library test suite 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 +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + +#include <stdio.h> +#include <stdlib.h> + +#include "gmp-impl.h" +#include "tests.h" + +#ifndef SIZE +#define SIZE 16 +#endif + +int +main (int argc, char **argv) +{ + int reps = 100000; + int i; + mpf_t u, v, w1, w2, w3; + mp_size_t bprec = 100; + mpf_t rerr, limit_rerr; + mp_size_t un; + mp_exp_t ue; + + tests_start (); + + if (argc > 1) + { + reps = strtol (argv[1], 0, 0); + if (argc > 2) + bprec = strtol (argv[2], 0, 0); + } + + mpf_set_default_prec (bprec); + + mpf_init (rerr); + mpf_init (limit_rerr); + + mpf_init (u); + mpf_init (v); + mpf_init (w1); + mpf_init (w2); + mpf_init (w3); + + for (i = 0; i < reps; i++) + { + unsigned long int res_prec; + unsigned long int pow2; + + res_prec = urandom () % (bprec + 100); + mpf_set_prec (w1, res_prec); + mpf_set_prec (w2, res_prec); + mpf_set_prec (w3, res_prec); + + mpf_set_ui (limit_rerr, 1); + mpf_div_2exp (limit_rerr, limit_rerr, res_prec); + + pow2 = urandom () % 0x10000; + mpf_set_ui (v, 1); + mpf_mul_2exp (v, v, pow2); + + un = urandom () % (2 * SIZE) - SIZE; + ue = urandom () % SIZE; + mpf_random2 (u, un, ue); + + mpf_div_2exp (w1, u, pow2); + mpf_div (w2, u, v); + mpf_reldiff (rerr, w1, w2); + if (mpf_cmp (rerr, limit_rerr) > 0) + { + printf ("ERROR in mpf_div or mpf_div_2exp after %d tests\n", i); + printf (" u = "); mpf_dump (u); + printf (" v = "); mpf_dump (v); + printf (" w1 = "); mpf_dump (w1); + printf (" w2 = "); mpf_dump (w2); + abort (); + } + mpf_mul_2exp (w3, w1, pow2); + mpf_reldiff (rerr, u, w3); + if (mpf_cmp (rerr, limit_rerr) > 0) + { + printf ("ERROR in mpf_mul_2exp after %d tests\n", i); + printf (" u = "); mpf_dump (u); + printf (" v = "); mpf_dump (v); + printf (" w1 = "); mpf_dump (w1); + printf (" w3 = "); mpf_dump (w3); + abort (); + } + } + + mpf_clear (rerr); + mpf_clear (limit_rerr); + + mpf_clear (u); + mpf_clear (v); + mpf_clear (w1); + mpf_clear (w2); + mpf_clear (w3); + + tests_end (); + exit (0); +} diff --git a/vendor/gmp-6.3.0/tests/mpf/t-eq.c b/vendor/gmp-6.3.0/tests/mpf/t-eq.c new file mode 100644 index 0000000..7b80b02 --- /dev/null +++ b/vendor/gmp-6.3.0/tests/mpf/t-eq.c @@ -0,0 +1,217 @@ +/* Test mpf_eq. + +Copyright 2009, 2012 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite 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. + +The GNU MP Library test suite 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 +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + +#include <stdio.h> +#include <stdlib.h> + +#include "gmp-impl.h" +#include "tests.h" + +#define SZ (2 * sizeof(mp_limb_t)) + +void insert_random_low_zero_limbs (mpf_t, gmp_randstate_ptr); +void dump_abort (mpf_t, mpf_t, int, int, int, int, int, long); +void hexdump (mpf_t); + +void +check_data (void) +{ + static const struct + { + struct { + int exp, size; + mp_limb_t d[10]; + } x, y; + mp_bitcnt_t bits; + int want; + + } data[] = { + { { 0, 0, { 0 } }, { 0, 0, { 0 } }, 0, 1 }, + + { { 0, 1, { 7 } }, { 0, 1, { 7 } }, 0, 1 }, + { { 0, 1, { 7 } }, { 0, 1, { 7 } }, 17, 1 }, + { { 0, 1, { 7 } }, { 0, 1, { 7 } }, 4711, 1 }, + + { { 0, 1, { 7 } }, { 0, 1, { 6 } }, 0, 1 }, + { { 0, 1, { 7 } }, { 0, 1, { 6 } }, 2, 1 }, + { { 0, 1, { 7 } }, { 0, 1, { 6 } }, 3, 0 }, + + { { 0, 0, { 0 } }, { 0, 1, { 1 } }, 0, 0 }, + { { 0, 1, { 1 } }, { 0,-1 ,{ 1 } }, 0, 0 }, + { { 1, 1, { 1 } }, { 0, 1, { 1 } }, 0, 0 }, + + { { 0, 1, { 8 } }, { 0, 1, { 4 } }, 0, 0 }, + + { { 0, 2, { 0, 3 } }, { 0, 1, { 3 } }, 1000, 1 }, + }; + + mpf_t x, y; + int got, got_swapped; + int i; + mp_trace_base = 16; + + for (i = 0; i < numberof (data); i++) + { + PTR(x) = (mp_ptr) data[i].x.d; + SIZ(x) = data[i].x.size; + EXP(x) = data[i].x.exp; + PREC(x) = numberof (data[i].x.d); + MPF_CHECK_FORMAT (x); + + PTR(y) = (mp_ptr) data[i].y.d; + SIZ(y) = data[i].y.size; + EXP(y) = data[i].y.exp; + PREC(y) = numberof (data[i].y.d); + MPF_CHECK_FORMAT (y); + + got = mpf_eq (x, y, data[i].bits); + got_swapped = mpf_eq (y, x, data[i].bits); + + if (got != got_swapped || got != data[i].want) + { + printf ("check_data() wrong result at data[%d]\n", i); + mpf_trace ("x ", x); + mpf_trace ("y ", y); + printf ("got %d\n", got); + printf ("got_swapped %d\n", got_swapped); + printf ("want %d\n", data[i].want); + abort (); + } + } +} + +void +check_random (long reps) +{ + unsigned long test; + gmp_randstate_ptr rands = RANDS; + mpf_t a, b, x; + mpz_t ds; + int hibits, lshift1, lshift2; + int xtra; + +#define HIBITS 10 +#define LSHIFT1 10 +#define LSHIFT2 10 + + mpf_set_default_prec ((1 << HIBITS) + (1 << LSHIFT1) + (1 << LSHIFT2)); + + mpz_init (ds); + mpf_inits (a, b, x, NULL); + + for (test = 0; test < reps; test++) + { + mpz_urandomb (ds, rands, HIBITS); + hibits = mpz_get_ui (ds) + 1; + mpz_urandomb (ds, rands, hibits); + mpz_setbit (ds, hibits - 1); /* make sure msb is set */ + mpf_set_z (a, ds); + mpf_set_z (b, ds); + + mpz_urandomb (ds, rands, LSHIFT1); + lshift1 = mpz_get_ui (ds); + mpf_mul_2exp (a, a, lshift1 + 1); + mpf_mul_2exp (b, b, lshift1 + 1); + mpf_add_ui (a, a, 1); /* make a one-bit difference */ + + mpz_urandomb (ds, rands, LSHIFT2); + lshift2 = mpz_get_ui (ds); + mpf_mul_2exp (a, a, lshift2); + mpf_mul_2exp (b, b, lshift2); + mpz_urandomb (ds, rands, lshift2); + mpf_set_z (x, ds); + mpf_add (a, a, x); + mpf_add (b, b, x); + + insert_random_low_zero_limbs (a, rands); + insert_random_low_zero_limbs (b, rands); + + if (mpf_eq (a, b, lshift1 + hibits) == 0 || + mpf_eq (b, a, lshift1 + hibits) == 0) + { + dump_abort (a, b, lshift1 + hibits, lshift1, lshift2, hibits, 1, test); + } + for (xtra = 1; xtra < 100; xtra++) + if (mpf_eq (a, b, lshift1 + hibits + xtra) != 0 || + mpf_eq (b, a, lshift1 + hibits + xtra) != 0) + { + dump_abort (a, b, lshift1 + hibits + xtra, lshift1, lshift2, hibits, 0, test); + } + } + + mpf_clears (a, b, x, NULL); + mpz_clear (ds); +} + +void +insert_random_low_zero_limbs (mpf_t x, gmp_randstate_ptr rands) +{ + mp_size_t max = PREC(x) - SIZ(x); + mp_size_t s; + mpz_t ds; mpz_init (ds); + mpz_urandomb (ds, rands, 32); + s = mpz_get_ui (ds) % (max + 1); + MPN_COPY_DECR (PTR(x) + s, PTR(x), SIZ(x)); + MPN_ZERO (PTR(x), s); + SIZ(x) += s; + mpz_clear (ds); +} + +void +dump_abort (mpf_t a, mpf_t b, int cmp_prec, int lshift1, int lshift2, int hibits, int want, long test) +{ + printf ("ERROR in test %ld\n", test); + printf ("want %d got %d from mpf_eq\n", want, 1-want); + printf ("cmp_prec = %d\n", cmp_prec); + printf ("lshift1 = %d\n", lshift1); + printf ("lshift2 = %d\n", lshift2); + printf ("hibits = %d\n", hibits); + hexdump (a); puts (""); + hexdump (b); puts (""); + abort (); +} + +void +hexdump (mpf_t x) +{ + mp_size_t i; + for (i = ABSIZ(x) - 1; i >= 0; i--) + { + gmp_printf ("%0*MX", SZ, PTR(x)[i]); + if (i != 0) + printf (" "); + } +} + +int +main (int argc, char *argv[]) +{ + long reps = 10000; + + if (argc == 2) + reps = strtol (argv[1], 0, 0); + + tests_start (); + + check_data (); + check_random (reps); + + tests_end (); + exit (0); +} diff --git a/vendor/gmp-6.3.0/tests/mpf/t-fits.c b/vendor/gmp-6.3.0/tests/mpf/t-fits.c new file mode 100644 index 0000000..937e4e6 --- /dev/null +++ b/vendor/gmp-6.3.0/tests/mpf/t-fits.c @@ -0,0 +1,327 @@ +/* Test mpf_fits_*_p + +Copyright 2001, 2002, 2013 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite 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. + +The GNU MP Library test suite 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 +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + +#include <stdio.h> +#include <stdlib.h> +#include "gmp-impl.h" +#include "tests.h" + + +/* Nothing sophisticated here, just exercise mpf_fits_*_p on a small amount + of data. */ + +#define EXPECT_S(fun,name,answer) \ + got = fun (f); \ + if (got != answer) \ + { \ + printf ("%s (%s) got %d want %d\n", name, expr, got, answer); \ + printf (" f size %d exp %ld\n", SIZ(f), EXP(f)); \ + printf (" f dec "); mpf_out_str (stdout, 10, 0, f); printf ("\n"); \ + printf (" f hex "); mpf_out_str (stdout, 16, 0, f); printf ("\n"); \ + error = 1; \ + } + +#define EXPECT(fun,answer) EXPECT_S(fun,#fun,answer) + +int +main (void) +{ + mpf_t f, f0p5; + int got; + const char *expr; + int error = 0; + + tests_start (); + mpf_init2 (f, 200L); + mpf_init2 (f0p5, 200L); + + /* 0.5 */ + mpf_set_ui (f0p5, 1L); + mpf_div_2exp (f0p5, f0p5, 1L); + + mpf_set_ui (f, 0L); + expr = "0"; + EXPECT (mpf_fits_ulong_p, 1); + EXPECT (mpf_fits_uint_p, 1); + EXPECT (mpf_fits_ushort_p, 1); + EXPECT (mpf_fits_slong_p, 1); + EXPECT (mpf_fits_sint_p, 1); + EXPECT (mpf_fits_sshort_p, 1); + + mpf_set_ui (f, 1L); + expr = "1"; + EXPECT (mpf_fits_ulong_p, 1); + EXPECT (mpf_fits_uint_p, 1); + EXPECT (mpf_fits_ushort_p, 1); + EXPECT (mpf_fits_slong_p, 1); + EXPECT (mpf_fits_sint_p, 1); + EXPECT (mpf_fits_sshort_p, 1); + + mpf_set_si (f, -1L); + expr = "-1"; + EXPECT (mpf_fits_ulong_p, 0); + EXPECT (mpf_fits_uint_p, 0); + EXPECT (mpf_fits_ushort_p, 0); + EXPECT (mpf_fits_slong_p, 1); + EXPECT (mpf_fits_sint_p, 1); + EXPECT (mpf_fits_sshort_p, 1); + + + mpf_set_ui (f, (unsigned long) USHRT_MAX); + expr = "USHRT_MAX"; + EXPECT (mpf_fits_ulong_p, 1); + EXPECT (mpf_fits_uint_p, 1); + EXPECT (mpf_fits_ushort_p, 1); + + mpf_set_ui (f, (unsigned long) USHRT_MAX); + mpf_add (f, f, f0p5); + expr = "USHRT_MAX + 0.5"; + EXPECT (mpf_fits_ulong_p, 1); + EXPECT (mpf_fits_uint_p, 1); + EXPECT (mpf_fits_ushort_p, 1); + + mpf_set_ui (f, (unsigned long) USHRT_MAX); + mpf_add_ui (f, f, 1L); + expr = "USHRT_MAX + 1"; + EXPECT (mpf_fits_ushort_p, 0); + + + mpf_set_ui (f, (unsigned long) UINT_MAX); + expr = "UINT_MAX"; + EXPECT (mpf_fits_ulong_p, 1); + EXPECT (mpf_fits_uint_p, 1); + + mpf_set_ui (f, (unsigned long) UINT_MAX); + mpf_add (f, f, f0p5); + expr = "UINT_MAX + 0.5"; + EXPECT (mpf_fits_ulong_p, 1); + EXPECT (mpf_fits_uint_p, 1); + + mpf_set_ui (f, (unsigned long) UINT_MAX); + mpf_add_ui (f, f, 1L); + expr = "UINT_MAX + 1"; + EXPECT (mpf_fits_uint_p, 0); + + + mpf_set_ui (f, ULONG_MAX); + expr = "ULONG_MAX"; + EXPECT (mpf_fits_ulong_p, 1); + + mpf_set_ui (f, ULONG_MAX); + mpf_add (f, f, f0p5); + expr = "ULONG_MAX + 0.5"; + EXPECT (mpf_fits_ulong_p, 1); + + mpf_set_ui (f, ULONG_MAX); + mpf_add_ui (f, f, 1L); + expr = "ULONG_MAX + 1"; + EXPECT (mpf_fits_ulong_p, 0); + + + mpf_set_si (f, (long) SHRT_MAX); + expr = "SHRT_MAX"; + EXPECT (mpf_fits_slong_p, 1); + EXPECT (mpf_fits_sint_p, 1); + EXPECT (mpf_fits_sshort_p, 1); + + mpf_set_si (f, (long) SHRT_MAX); + expr = "SHRT_MAX + 0.5"; + mpf_add (f, f, f0p5); + EXPECT (mpf_fits_slong_p, 1); + EXPECT (mpf_fits_sint_p, 1); + EXPECT (mpf_fits_sshort_p, 1); + + mpf_set_si (f, (long) SHRT_MAX); + mpf_add_ui (f, f, 1L); + expr = "SHRT_MAX + 1"; + EXPECT (mpf_fits_sshort_p, 0); + + + mpf_set_si (f, (long) INT_MAX); + expr = "INT_MAX"; + EXPECT (mpf_fits_slong_p, 1); + EXPECT (mpf_fits_sint_p, 1); + + mpf_set_si (f, (long) INT_MAX); + mpf_add (f, f, f0p5); + expr = "INT_MAX + 0.5"; + EXPECT (mpf_fits_slong_p, 1); + EXPECT (mpf_fits_sint_p, 1); + + mpf_set_si (f, (long) INT_MAX); + mpf_add_ui (f, f, 1L); + expr = "INT_MAX + 1"; + EXPECT (mpf_fits_sint_p, 0); + + + mpf_set_si (f, LONG_MAX); + expr = "LONG_MAX"; + EXPECT (mpf_fits_slong_p, 1); + + mpf_set_si (f, LONG_MAX); + mpf_add (f, f, f0p5); + expr = "LONG_MAX + 0.5"; + EXPECT (mpf_fits_slong_p, 1); + + mpf_set_si (f, LONG_MAX); + mpf_add_ui (f, f, 1L); + expr = "LONG_MAX + 1"; + EXPECT (mpf_fits_slong_p, 0); + + + mpf_set_si (f, (long) SHRT_MIN); + expr = "SHRT_MIN"; + EXPECT (mpf_fits_slong_p, 1); + EXPECT (mpf_fits_sint_p, 1); + EXPECT (mpf_fits_sshort_p, 1); + + mpf_set_si (f, (long) SHRT_MIN); + mpf_sub (f, f, f0p5); + expr = "SHRT_MIN - 0.5"; + EXPECT (mpf_fits_slong_p, 1); + EXPECT (mpf_fits_sint_p, 1); + EXPECT (mpf_fits_sshort_p, 1); + + mpf_set_si (f, (long) SHRT_MIN); + mpf_sub_ui (f, f, 1L); + expr = "SHRT_MIN - 1"; + EXPECT (mpf_fits_sshort_p, 0); + + + mpf_set_si (f, (long) INT_MIN); + expr = "INT_MIN"; + EXPECT (mpf_fits_slong_p, 1); + EXPECT (mpf_fits_sint_p, 1); + + mpf_set_si (f, (long) INT_MIN); + mpf_sub (f, f, f0p5); + expr = "INT_MIN - 0.5"; + EXPECT (mpf_fits_slong_p, 1); + EXPECT (mpf_fits_sint_p, 1); + + mpf_set_si (f, (long) INT_MIN); + mpf_sub_ui (f, f, 1L); + expr = "INT_MIN - 1"; + EXPECT (mpf_fits_sint_p, 0); + + + mpf_set_si (f, LONG_MIN); + expr = "LONG_MIN"; + EXPECT (mpf_fits_slong_p, 1); + + mpf_set_si (f, LONG_MIN); + mpf_sub (f, f, f0p5); + expr = "LONG_MIN - 0.5"; + EXPECT (mpf_fits_slong_p, 1); + + mpf_set_si (f, LONG_MIN); + mpf_sub_ui (f, f, 1L); + expr = "LONG_MIN - 1"; + EXPECT (mpf_fits_slong_p, 0); + + + mpf_set_str_or_abort (f, "0.5", 10); + expr = "0.5"; + EXPECT (mpf_fits_ulong_p, 1); + EXPECT (mpf_fits_uint_p, 1); + EXPECT (mpf_fits_ushort_p, 1); + EXPECT (mpf_fits_slong_p, 1); + EXPECT (mpf_fits_sint_p, 1); + EXPECT (mpf_fits_sshort_p, 1); + + mpf_set_str_or_abort (f, "-0.5", 10); + expr = "-0.5"; + EXPECT (mpf_fits_ulong_p, 1); + EXPECT (mpf_fits_uint_p, 1); + EXPECT (mpf_fits_ushort_p, 1); + EXPECT (mpf_fits_slong_p, 1); + EXPECT (mpf_fits_sint_p, 1); + EXPECT (mpf_fits_sshort_p, 1); + + mpf_set_str_or_abort (f, "-1.5", 10); + expr = "-1.5"; + EXPECT (mpf_fits_ulong_p, 0); + EXPECT (mpf_fits_uint_p, 0); + EXPECT (mpf_fits_ushort_p, 0); + EXPECT (mpf_fits_slong_p, 1); + EXPECT (mpf_fits_sint_p, 1); + EXPECT (mpf_fits_sshort_p, 1); + + + mpf_set_str_or_abort (f, "1.000000000000000000000000000000000001", 16); + expr = "1.000000000000000000000000000000000001 base 16"; + EXPECT (mpf_fits_ulong_p, 1); + EXPECT (mpf_fits_uint_p, 1); + EXPECT (mpf_fits_ushort_p, 1); + EXPECT (mpf_fits_slong_p, 1); + EXPECT (mpf_fits_sint_p, 1); + EXPECT (mpf_fits_sshort_p, 1); + + mpf_set_str_or_abort (f, "1@1000", 16); + expr = "1@1000 base 16"; + EXPECT (mpf_fits_ulong_p, 0); + EXPECT (mpf_fits_uint_p, 0); + EXPECT (mpf_fits_ushort_p, 0); + EXPECT (mpf_fits_slong_p, 0); + EXPECT (mpf_fits_sint_p, 0); + EXPECT (mpf_fits_sshort_p, 0); + + + mpf_set_ui (f, 1L); + mpf_mul_2exp (f, f, BITS_PER_ULONG + 1); + mpf_sub_ui (f, f, 1L); + expr = "2^(BITS_PER_ULONG+1) - 1"; + EXPECT (mpf_fits_ulong_p, 0); + EXPECT (mpf_fits_uint_p, 0); + EXPECT (mpf_fits_ushort_p, 0); + EXPECT (mpf_fits_slong_p, 0); + EXPECT (mpf_fits_sint_p, 0); + EXPECT (mpf_fits_sshort_p, 0); + + mpf_set_ui (f, 1L); + mpf_mul_2exp (f, f, BITS_PER_ULONG + 1); + mpf_ui_sub (f, 1L, f); + expr = "- (2^(BITS_PER_ULONG+1) - 1)"; + EXPECT (mpf_fits_ulong_p, 0); + EXPECT (mpf_fits_uint_p, 0); + EXPECT (mpf_fits_ushort_p, 0); + EXPECT (mpf_fits_slong_p, 0); + EXPECT (mpf_fits_sint_p, 0); + EXPECT (mpf_fits_sshort_p, 0); + + mpf_set_ui (f, 1L); + mpf_mul_2exp (f, f, BITS_PER_ULONG + 5); + mpf_sub_ui (f, f, 1L); + expr = "2^(BITS_PER_ULONG+5) - 1"; + EXPECT (mpf_fits_ulong_p, 0); + EXPECT (mpf_fits_uint_p, 0); + EXPECT (mpf_fits_ushort_p, 0); + EXPECT (mpf_fits_slong_p, 0); + EXPECT (mpf_fits_sint_p, 0); + EXPECT (mpf_fits_sshort_p, 0); + + + if (error) + abort (); + + mpf_clear (f); + mpf_clear (f0p5); + tests_end (); + exit (0); +} diff --git a/vendor/gmp-6.3.0/tests/mpf/t-get_d.c b/vendor/gmp-6.3.0/tests/mpf/t-get_d.c new file mode 100644 index 0000000..4e4c741 --- /dev/null +++ b/vendor/gmp-6.3.0/tests/mpf/t-get_d.c @@ -0,0 +1,106 @@ +/* Test mpf_get_d and mpf_set_d. + +Copyright 1996, 1999-2001, 2009 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite 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. + +The GNU MP Library test suite 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 +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + +#include <stdio.h> +#include <stdlib.h> +#include "gmp-impl.h" +#include "tests.h" + +#if defined (__vax) || defined (__vax__) +#define LOW_BOUND 1e-38 +#define HIGH_BOUND 8e37 +#endif + +#if defined (_CRAY) && ! defined (_CRAYIEEE) +/* The range varies mysteriously between Cray version. On an SV1, + the range seem to be 1e-600..1e603, but a cfp (non-ieee) T90 + has a much smaller range of 1e-240..1e240. */ +#define LOW_BOUND 1e-240 +#define HIGH_BOUND 1e240 +#endif + +#if ! defined (LOW_BOUND) +#define LOW_BOUND 1e-300 +#define HIGH_BOUND 1e300 +#endif + +void +test_denorms (int prc) +{ +#ifdef _GMP_IEEE_FLOATS + double d1, d2; + mpf_t f; + int i; + + mpf_set_default_prec (prc); + + mpf_init (f); + + d1 = 1.9; + for (i = 0; i < 820; i++) + { + mpf_set_d (f, d1); + d2 = mpf_get_d (f); + if (d1 != d2) + abort (); + d1 *= 0.4; + } + + mpf_clear (f); +#endif +} + +int +main (int argc, char **argv) +{ + double d, e, r; + mpf_t u, v; + + tests_start (); + mpf_init (u); + mpf_init (v); + + mpf_set_d (u, LOW_BOUND); + for (d = 2.0 * LOW_BOUND; d < HIGH_BOUND; d *= 1.01) + { + mpf_set_d (v, d); + if (mpf_cmp (u, v) >= 0) + abort (); + e = mpf_get_d (v); + r = e/d; + if (r < 0.99999999999999 || r > 1.00000000000001) + { + fprintf (stderr, "should be one ulp from 1: %.16f\n", r); + abort (); + } + mpf_set (u, v); + } + + mpf_clear (u); + mpf_clear (v); + + test_denorms (10); + test_denorms (32); + test_denorms (64); + test_denorms (100); + test_denorms (200); + + tests_end (); + exit (0); +} diff --git a/vendor/gmp-6.3.0/tests/mpf/t-get_d_2exp.c b/vendor/gmp-6.3.0/tests/mpf/t-get_d_2exp.c new file mode 100644 index 0000000..b716cf8 --- /dev/null +++ b/vendor/gmp-6.3.0/tests/mpf/t-get_d_2exp.c @@ -0,0 +1,136 @@ +/* Test mpf_get_d_2exp. + +Copyright 2002, 2003, 2017, 2020 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite 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. + +The GNU MP Library test suite 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 +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + +#include <stdio.h> +#include <stdlib.h> +#include "gmp-impl.h" +#include "tests.h" + + +static void +check_data (void) +{ + mpf_t f; + double got, want; + long got_exp; + long exp; + struct { + int base; + int shift; + } data[] = { + {-1, 1}, {-3, 2}, {-5, 3}, {-7, 3}, { 1, 1}, { 3, 2}, { 5, 3}, { 7, 3} + }; + + mpf_init2 (f, 3); + + got = mpf_get_d_2exp (&got_exp, f); + if (got != 0 || got_exp != 0) + { + printf ("mpf_get_d_2exp wrong on zero\n"); + mpf_trace (" f ", f); + d_trace (" got ", got); + printf (" got exp %ld\n", got_exp); + abort(); + } + + for (exp = -513; exp <= 513; exp++) + { + size_t i; + for (i = 0; i < numberof (data); i++) + { + want = (double) data[i].base / (1 << data[i].shift); + mpf_set_d (f, want); + + if (exp >= 0) + mpf_mul_2exp (f, f, exp); + else + mpf_div_2exp (f, f, -exp); + + got = mpf_get_d_2exp (&got_exp, f); + if (got != want || got_exp != exp) + { + printf ("mpf_get_d_2exp wrong on 2**%ld\n", exp); + mpf_trace (" f ", f); + d_trace (" want ", want); + d_trace (" got ", got); + printf (" want exp %ld\n", exp); + printf (" got exp %ld\n", got_exp); + abort(); + } + } + } + mpf_clear (f); +} + +/* Check that hardware rounding doesn't make mpf_get_d_2exp return a value + outside its defined range. */ +static void +check_round (void) +{ + static const unsigned long data[] = { 1, 32, 53, 54, 64, 128, 256, 512 }; + mpf_t f; + double got; + long got_exp; + int i, rnd_mode, old_rnd_mode; + + mpf_init2 (f, 1024L); + old_rnd_mode = tests_hardware_getround (); + + for (rnd_mode = 0; rnd_mode < 4; rnd_mode++) + { + tests_hardware_setround (rnd_mode); + + for (i = 0; i < numberof (data); i++) + { + mpf_set_ui (f, 1L); + mpf_mul_2exp (f, f, data[i]); + mpf_sub_ui (f, f, 1L); + + got = mpf_get_d_2exp (&got_exp, f); + if (got < 0.5 || got >= 1.0) + { + printf ("mpf_get_d_2exp bad on 2**%lu-1\n", data[i]); + printf ("result out of range, expect 0.5 <= got < 1.0\n"); + printf (" rnd_mode = %d\n", rnd_mode); + printf (" data[i] = %lu\n", data[i]); + mpf_trace (" f ", f); + d_trace (" got ", got); + printf (" got exp %ld\n", got_exp); + abort(); + } + } + } + + mpf_clear (f); + tests_hardware_setround (old_rnd_mode); +} + + +int +main (void) +{ + tests_start (); + mp_trace_base = 16; + + check_data (); + check_round (); + + tests_end (); + exit (0); +} diff --git a/vendor/gmp-6.3.0/tests/mpf/t-get_si.c b/vendor/gmp-6.3.0/tests/mpf/t-get_si.c new file mode 100644 index 0000000..5510b04 --- /dev/null +++ b/vendor/gmp-6.3.0/tests/mpf/t-get_si.c @@ -0,0 +1,222 @@ +/* Exercise mpz_get_si. + +Copyright 2000, 2001 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite 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. + +The GNU MP Library test suite 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 +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + +#include <stdio.h> +#include <stdlib.h> +#include "gmp-impl.h" +#include "tests.h" + + +void +check_data (void) +{ + static const struct { + int base; + const char *f; + long want; + } data[] = { + { 10, "0", 0L }, + { 10, "1", 1L }, + { 10, "-1", -1L }, + { 10, "2", 2L }, + { 10, "-2", -2L }, + { 10, "12345", 12345L }, + { 10, "-12345", -12345L }, + + /* fraction bits ignored */ + { 10, "0.5", 0L }, + { 10, "-0.5", 0L }, + { 10, "1.1", 1L }, + { 10, "-1.1", -1L }, + { 10, "1.9", 1L }, + { 10, "-1.9", -1L }, + { 16, "1.000000000000000000000000000000000000000000000000001", 1L }, + { 16, "-1.000000000000000000000000000000000000000000000000001", -1L }, + + /* low bits extracted (this is undocumented) */ + { 16, "1000000000000000000000000000000000000000000000000001", 1L }, + { 16, "-1000000000000000000000000000000000000000000000000001", -1L }, + }; + + int i; + mpf_t f; + long got; + + mpf_init2 (f, 2000L); + for (i = 0; i < numberof (data); i++) + { + mpf_set_str_or_abort (f, data[i].f, data[i].base); + + got = mpf_get_si (f); + if (got != data[i].want) + { + printf ("mpf_get_si wrong at data[%d]\n", i); + printf (" f \"%s\"\n", data[i].f); + printf (" dec "); mpf_out_str (stdout, 10, 0, f); printf ("\n"); + printf (" hex "); mpf_out_str (stdout, 16, 0, f); printf ("\n"); + printf (" size %ld\n", (long) SIZ(f)); + printf (" exp %ld\n", (long) EXP(f)); + printf (" got %ld (0x%lX)\n", got, got); + printf (" want %ld (0x%lX)\n", data[i].want, data[i].want); + abort(); + } + } + mpf_clear (f); +} + + +void +check_max (void) +{ + mpf_t f; + long want; + long got; + + mpf_init2 (f, 200L); + +#define CHECK_MAX(name) \ + if (got != want) \ + { \ + printf ("mpf_get_si wrong on %s\n", name); \ + printf (" f "); \ + mpf_out_str (stdout, 10, 0, f); printf (", hex "); \ + mpf_out_str (stdout, 16, 0, f); printf ("\n"); \ + printf (" got %ld, hex %lX\n", got, got); \ + printf (" want %ld, hex %lX\n", want, want); \ + abort(); \ + } + + want = LONG_MAX; + mpf_set_si (f, want); + got = mpf_get_si (f); + CHECK_MAX ("LONG_MAX"); + + want = LONG_MIN; + mpf_set_si (f, want); + got = mpf_get_si (f); + CHECK_MAX ("LONG_MIN"); + + mpf_clear (f); +} + + +void +check_limbdata (void) +{ +#define M GMP_NUMB_MAX + + static const struct { + mp_exp_t exp; + mp_size_t size; + mp_limb_t d[10]; + unsigned long want; + + } data[] = { + + /* in the comments here, a "_" indicates a digit (ie. limb) position not + included in the d data, and therefore zero */ + + { 0, 0, { 0 }, 0L }, /* 0 */ + + { 1, 1, { 1 }, 1L }, /* 1 */ + { 1, -1, { 1 }, -1UL }, /* -1 */ + + { 0, 1, { 1 }, 0L }, /* .1 */ + { 0, -1, { 1 }, 0L }, /* -.1 */ + + { -1, 1, { 1 }, 0L }, /* ._1 */ + { -1, -1, { 1 }, 0L }, /* -._1 */ + + { -999, 1, { 1 }, 0L }, /* .___1 small */ + { MP_EXP_T_MIN, 1, { 1 }, 0L }, /* .____1 very small */ + + { 999, 1, { 1 }, 0L }, /* 1____. big */ + { MP_EXP_T_MAX, 1, { 1 }, 0L }, /* 1_____. very big */ + + { 1, 2, { 999, 2 }, 2L }, /* 2.9 */ + { 5, 8, { 7, 8, 9, 3, 0, 0, 0, 1 }, 3L }, /* 10003.987 */ + + { 2, 2, { M, M }, LONG_MAX }, /* FF. */ + { 2, 2, { M, M, M }, LONG_MAX }, /* FF.F */ + { 3, 3, { M, M, M }, LONG_MAX }, /* FFF. */ + +#if GMP_NUMB_BITS >= BITS_PER_ULONG + /* normal case, numb bigger than long */ + { 2, 1, { 1 }, 0L }, /* 1_. */ + { 2, 2, { 0, 1 }, 0L }, /* 10. */ + { 2, 2, { 999, 1 }, 999L }, /* 19. */ + { 3, 2, { 999, 1 }, 0L }, /* 19_. */ + +#else + /* nails case, numb smaller than long */ + { 2, 1, { 1 }, 1L << GMP_NUMB_BITS }, /* 1_. */ + { 3, 1, { 1 }, 0L }, /* 1__. */ + + { 2, 2, { 99, 1 }, 99L + (1L << GMP_NUMB_BITS) }, /* 19. */ + { 3, 2, { 1, 99 }, 1L << GMP_NUMB_BITS }, /* 91_. */ + { 3, 3, { 0, 1, 99 }, 1L << GMP_NUMB_BITS }, /* 910. */ + +#endif + }; + + mpf_t f; + unsigned long got; + int i; + mp_limb_t buf[20 + numberof(data[i].d)]; + + for (i = 0; i < numberof (data); i++) + { + refmpn_fill (buf, 10, CNST_LIMB(0xDEADBEEF)); + refmpn_copy (buf+10, data[i].d, ABS(data[i].size)); + refmpn_fill (buf+10+ABS(data[i].size), 10, CNST_LIMB(0xDEADBEEF)); + + PTR(f) = buf+10; + EXP(f) = data[i].exp; + SIZ(f) = data[i].size; + PREC(f) = numberof (data[i].d); + MPF_CHECK_FORMAT (f); + + got = mpf_get_si (f); + if (got != data[i].want) + { + printf ("mpf_get_si wrong at limb data[%d]\n", i); + mpf_trace (" f", f); + mpn_trace (" d", data[i].d, data[i].size); + printf (" size %ld\n", (long) data[i].size); + printf (" exp %ld\n", (long) data[i].exp); + printf (" got %lu (0x%lX)\n", got, got); + printf (" want %lu (0x%lX)\n", data[i].want, data[i].want); + abort(); + } + } +} + + +int +main (void) +{ + tests_start (); + + check_data (); + check_max (); + check_limbdata (); + + tests_end (); + exit (0); +} diff --git a/vendor/gmp-6.3.0/tests/mpf/t-get_ui.c b/vendor/gmp-6.3.0/tests/mpf/t-get_ui.c new file mode 100644 index 0000000..6011b0f --- /dev/null +++ b/vendor/gmp-6.3.0/tests/mpf/t-get_ui.c @@ -0,0 +1,127 @@ +/* Exercise mpf_get_ui. + +Copyright 2004 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite 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. + +The GNU MP Library test suite 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 +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + +#include <stdio.h> +#include <stdlib.h> +#include "gmp-impl.h" +#include "tests.h" + + +void +check_limbdata (void) +{ +#define M GMP_NUMB_MAX + + static const struct { + mp_exp_t exp; + mp_size_t size; + mp_limb_t d[10]; + unsigned long want; + + } data[] = { + + /* in the comments here, a "_" indicates a digit (ie. limb) position not + included in the d data, and therefore zero */ + + { 0, 0, { 0 }, 0L }, /* 0 */ + + { 1, 1, { 1 }, 1L }, /* 1 */ + { 1, -1, { 1 }, 1L }, /* -1 */ + + { 0, 1, { 1 }, 0L }, /* .1 */ + { 0, -1, { 1 }, 0L }, /* -.1 */ + + { -1, 1, { 1 }, 0L }, /* ._1 */ + { -1, -1, { 1 }, 0L }, /* -._1 */ + + { -999, 1, { 1 }, 0L }, /* .___1 small */ + { MP_EXP_T_MIN, 1, { 1 }, 0L }, /* .____1 very small */ + + { 999, 1, { 1 }, 0L }, /* 1____. big */ + { MP_EXP_T_MAX, 1, { 1 }, 0L }, /* 1_____. very big */ + + { 1, 2, { 999, 2 }, 2L }, /* 2.9 */ + { 5, 8, { 7, 8, 9, 3, 0, 0, 0, 1 }, 3L }, /* 10003.987 */ + + { 2, 2, { M, M }, ULONG_MAX }, /* FF. */ + { 2, 2, { M, M, M }, ULONG_MAX }, /* FF.F */ + { 3, 3, { M, M, M }, ULONG_MAX }, /* FFF. */ + +#if GMP_NUMB_BITS >= BITS_PER_ULONG + /* normal case, numb bigger than long */ + { 2, 1, { 1 }, 0L }, /* 1_. */ + { 2, 2, { 0, 1 }, 0L }, /* 10. */ + { 2, 2, { 999, 1 }, 999L }, /* 19. */ + { 3, 2, { 999, 1 }, 0L }, /* 19_. */ + +#else + /* nails case, numb smaller than long */ + { 2, 1, { 1 }, 1L << GMP_NUMB_BITS }, /* 1_. */ + { 3, 1, { 1 }, 0L }, /* 1__. */ + + { 2, 2, { 99, 1 }, 99L + (1L << GMP_NUMB_BITS) }, /* 19. */ + { 3, 2, { 1, 99 }, 1L << GMP_NUMB_BITS }, /* 91_. */ + { 3, 3, { 0, 1, 99 }, 1L << GMP_NUMB_BITS }, /* 910. */ + +#endif + }; + + mpf_t f; + unsigned long got; + int i; + mp_limb_t buf[20 + numberof(data[i].d)]; + + for (i = 0; i < numberof (data); i++) + { + refmpn_fill (buf, 10, CNST_LIMB(0xDEADBEEF)); + refmpn_copy (buf+10, data[i].d, ABS(data[i].size)); + refmpn_fill (buf+10+ABS(data[i].size), 10, CNST_LIMB(0xDEADBEEF)); + + PTR(f) = buf+10; + EXP(f) = data[i].exp; + SIZ(f) = data[i].size; + PREC(f) = numberof (data[i].d); + MPF_CHECK_FORMAT (f); + + got = mpf_get_ui (f); + if (got != data[i].want) + { + printf ("mpf_get_ui wrong at limb data[%d]\n", i); + mpf_trace (" f", f); + mpn_trace (" d", data[i].d, data[i].size); + printf (" size %ld\n", (long) data[i].size); + printf (" exp %ld\n", (long) data[i].exp); + printf (" got %lu (0x%lX)\n", got, got); + printf (" want %lu (0x%lX)\n", data[i].want, data[i].want); + abort(); + } + } +} + +int +main (void) +{ + tests_start (); + mp_trace_base = 16; + + check_limbdata (); + + tests_end (); + exit (0); +} diff --git a/vendor/gmp-6.3.0/tests/mpf/t-gsprec.c b/vendor/gmp-6.3.0/tests/mpf/t-gsprec.c new file mode 100644 index 0000000..da07f3e --- /dev/null +++ b/vendor/gmp-6.3.0/tests/mpf/t-gsprec.c @@ -0,0 +1,61 @@ +/* Test mpf_get_prec and mpf_set_prec. + +Copyright 2000, 2001 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite 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. + +The GNU MP Library test suite 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 +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + +#include <stdio.h> +#include <stdlib.h> +#include "gmp-impl.h" +#include "tests.h" + +void +check_consistency (void) +{ + mpf_t x; + unsigned long i, a, b; + + mpf_init (x); + + for (i = 1; i < 2000; i++) + { + mpf_set_prec (x, i); + a = mpf_get_prec (x); + mpf_set_prec (x, a); + b = mpf_get_prec (x); + if (a != b) + { + printf ("mpf_get_prec / mpf_set_prec inconsistent\n"); + printf (" set %lu gives %lu, but then set %lu gives %lu\n", + i, a, + a, b); + abort (); + } + } + + mpf_clear (x); +} + +int +main (void) +{ + tests_start (); + + check_consistency (); + + tests_end (); + exit (0); +} diff --git a/vendor/gmp-6.3.0/tests/mpf/t-inp_str.c b/vendor/gmp-6.3.0/tests/mpf/t-inp_str.c new file mode 100644 index 0000000..bcc0b26 --- /dev/null +++ b/vendor/gmp-6.3.0/tests/mpf/t-inp_str.c @@ -0,0 +1,191 @@ +/* Test mpf_inp_str. + +Copyright 2001, 2002 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite 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. + +The GNU MP Library test suite 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 +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + +#include "config.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#if HAVE_UNISTD_H +#include <unistd.h> /* for unlink */ +#endif + +#include "gmp-impl.h" +#include "tests.h" + + +#define FILENAME "t-inp_str.tmp" + + +void +check_data (void) +{ + static const struct { + const char *inp; + int base; + const char *want; + int want_nread; + + } data[] = { + + { "0", 10, "0", 1 }, + + { "abc", 10, "0", 0 }, + { "ghi", 16, "0", 0 }, + + { "125", 10, "125", 3 }, + { "125e1", 10, "1250", 5 }, + { "12e+2", 10, "1200", 5 }, + { "125e-1", 10, "12.5", 6 }, + + { "ff", 16, "255", 2 }, + { "-ff", 16, "-255", 3 }, + { "FF", 16, "255", 2 }, + { "-FF", 16, "-255", 3 }, + + { "100", 16, "256", 3 }, + { "100@1", 16, "4096", 5 }, + { "100@10", 16, "4722366482869645213696", 6 }, + { "100@10", -16, "281474976710656", 6 }, + { "100@-1", 16, "16", 6 }, + { "10000000000000000@-10", 16, "1", 21 }, + { "10000000000@-10", -16, "1", 15 }, + + { "z", 36, "35", 1 }, + { "Z", 36, "35", 1 }, + { "z@1", 36, "1260", 3 }, + { "Z@1", 36, "1260", 3 }, + + { "0", 0, "0", 1 }, + }; + + mpf_t got, want; + long ftell_nread; + int i, pre, post, j, got_nread, want_nread; + FILE *fp; + + mpf_init (got); + mpf_init (want); + + for (i = 0; i < numberof (data); i++) + { + for (pre = 0; pre <= 3; pre++) + { + for (post = 0; post <= 2; post++) + { + mpf_set_str_or_abort (want, data[i].want, 10); + MPF_CHECK_FORMAT (want); + + /* create the file new each time to ensure its length is what + we want */ + fp = fopen (FILENAME, "w+"); + ASSERT_ALWAYS (fp != NULL); + for (j = 0; j < pre; j++) + putc (' ', fp); + fputs (data[i].inp, fp); + for (j = 0; j < post; j++) + putc (' ', fp); + fflush (fp); + ASSERT_ALWAYS (! ferror(fp)); + + rewind (fp); + got_nread = mpf_inp_str (got, fp, data[i].base); + + if (got_nread != 0) + { + ftell_nread = ftell (fp); + if (got_nread != ftell_nread) + { + printf ("mpf_inp_str nread wrong\n"); + printf (" inp \"%s\"\n", data[i].inp); + printf (" base %d\n", data[i].base); + printf (" pre %d\n", pre); + printf (" post %d\n", post); + printf (" got_nread %d\n", got_nread); + printf (" ftell_nread %ld\n", ftell_nread); + abort (); + } + } + + /* if data[i].inp is a whole string to read and there's no post + whitespace then expect to have EOF */ + if (post == 0 && data[i].want_nread == strlen(data[i].inp)) + { + int c = getc(fp); + if (c != EOF) + { + printf ("mpf_inp_str didn't read to EOF\n"); + printf (" inp \"%s\"\n", data[i].inp); + printf (" base %d\n", data[i].base); + printf (" pre %d\n", pre); + printf (" post %d\n", post); + printf (" c '%c' %#x\n", c, c); + abort (); + } + } + + /* only expect "pre" included in the count when non-zero */ + want_nread = data[i].want_nread; + if (want_nread != 0) + want_nread += pre; + + if (got_nread != want_nread) + { + printf ("mpf_inp_str nread wrong\n"); + printf (" inp \"%s\"\n", data[i].inp); + printf (" base %d\n", data[i].base); + printf (" pre %d\n", pre); + printf (" post %d\n", post); + printf (" got_nread %d\n", got_nread); + printf (" want_nread %d\n", want_nread); + abort (); + } + + MPF_CHECK_FORMAT (got); + + if (mpf_cmp (got, want) != 0) + { + printf ("mpf_inp_str wrong result\n"); + printf (" inp \"%s\"\n", data[i].inp); + printf (" base %d\n", data[i].base); + mpf_trace (" got ", got); + mpf_trace (" want", want); + abort (); + } + + ASSERT_ALWAYS (fclose (fp) == 0); + } + } + } + + mpf_clear (got); + mpf_clear (want); +} + +int +main (void) +{ + tests_start (); + + check_data (); + + unlink (FILENAME); + tests_end (); + exit (0); +} diff --git a/vendor/gmp-6.3.0/tests/mpf/t-int_p.c b/vendor/gmp-6.3.0/tests/mpf/t-int_p.c new file mode 100644 index 0000000..3e536db --- /dev/null +++ b/vendor/gmp-6.3.0/tests/mpf/t-int_p.c @@ -0,0 +1,90 @@ +/* Test mpf_integer_p. + +Copyright 2001, 2014 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite 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. + +The GNU MP Library test suite 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 +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + +#include <stdio.h> +#include <stdlib.h> +#include "gmp-impl.h" +#include "tests.h" + + +void +one (mpf_srcptr f, int want) +{ + int got; + got = mpf_integer_p (f); + if (got != want) + { + printf ("mpf_integer_p got %d want %d\n", got, want); + mpf_trace (" f", f); + abort (); + } +} + +void +all (mpf_ptr f, int want) +{ + one (f, want); + mpf_neg (f, f); + one (f, want); +} + +int +main (void) +{ + mpf_t f; + + tests_start (); + mpf_init2 (f, 200L); + + mpf_set_ui (f, 0L); + one (f, 1); + + mpf_set_ui (f, 1L); + all (f, 1); + + mpf_set_ui (f, 1L); + mpf_div_2exp (f, f, 1L); + all (f, 0); + + mpf_set_ui (f, 1L); + mpf_div_2exp (f, f, 5000L); + all (f, 0); + + mpf_set_ui (f, 1L); + mpf_mul_2exp (f, f, 5000L); + all (f, 1); + + mpf_set_str (f, "0.5", 10); + all (f, 0); + + mpf_set_str (f, "2.5", 10); + all (f, 0); + + mpf_set_ui (f, 1L); + mpf_div_ui (f, f, 3L); + all (f, 0); + + mpf_set_ui (f, 7L); + mpf_div_ui (f, f, 3L); + all (f, 0); + + mpf_clear (f); + tests_end (); + exit (0); +} diff --git a/vendor/gmp-6.3.0/tests/mpf/t-mul_ui.c b/vendor/gmp-6.3.0/tests/mpf/t-mul_ui.c new file mode 100644 index 0000000..f362bb2 --- /dev/null +++ b/vendor/gmp-6.3.0/tests/mpf/t-mul_ui.c @@ -0,0 +1,164 @@ +/* Exercise mpf_mul_ui. + +Copyright 2004 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite 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. + +The GNU MP Library test suite 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 +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + +#include <stdio.h> +#include <stdlib.h> +#include "gmp-impl.h" +#include "tests.h" + + +void +check_one (const char *desc, mpf_ptr got, mpf_srcptr u, unsigned long v) +{ + mp_size_t usize, usign; + mp_ptr wp; + mpf_t want; + + MPF_CHECK_FORMAT (got); + + /* this code not nailified yet */ + ASSERT_ALWAYS (BITS_PER_ULONG <= GMP_NUMB_BITS); + usign = SIZ (u); + usize = ABS (usign); + wp = refmpn_malloc_limbs (usize + 1); + wp[usize] = mpn_mul_1 (wp, PTR(u), usize, (mp_limb_t) v); + + PTR(want) = wp; + SIZ(want) = (usign >= 0 ? usize+1 : -(usize+1)); + EXP(want) = EXP(u) + 1; + refmpf_normalize (want); + + if (! refmpf_validate ("mpf_mul_ui", got, want)) + { + mp_trace_base = -16; + printf (" %s\n", desc); + mpf_trace (" u", u); + printf (" v %ld 0x%lX\n", v, v); + abort (); + } + + free (wp); +} + +void +check_rand (void) +{ + unsigned long min_prec = __GMPF_BITS_TO_PREC (1); + gmp_randstate_ptr rands = RANDS; + mpf_t got, u; + unsigned long prec, v; + int i; + + /* The nails code in mpf_mul_ui currently isn't exact, so suppress these + tests for now. */ + if (BITS_PER_ULONG > GMP_NUMB_BITS) + return; + + mpf_init (got); + mpf_init (u); + + for (i = 0; i < 200; i++) + { + /* got precision */ + prec = min_prec + gmp_urandomm_ui (rands, 15L); + refmpf_set_prec_limbs (got, prec); + + /* u precision */ + prec = min_prec + gmp_urandomm_ui (rands, 15L); + refmpf_set_prec_limbs (u, prec); + + /* u, possibly negative */ + mpf_random2 (u, PREC(u), (mp_exp_t) 20); + if (gmp_urandomb_ui (rands, 1L)) + mpf_neg (u, u); + + /* v, 0 to BITS_PER_ULONG bits (inclusive) */ + prec = gmp_urandomm_ui (rands, BITS_PER_ULONG+1); + v = gmp_urandomb_ui (rands, prec); + + if ((i % 2) == 0) + { + /* separate */ + mpf_mul_ui (got, u, v); + check_one ("separate", got, u, v); + } + else + { + /* overlap */ + prec = refmpf_set_overlap (got, u); + mpf_mul_ui (got, got, v); + check_one ("overlap src==dst", got, u, v); + + mpf_set_prec_raw (got, prec); + } + } + + mpf_clear (got); + mpf_clear (u); +} + +void +check_various (void) +{ + mpf_t u, got, want; + const char *s; + + mpf_init2 (u, 2*8*sizeof(long)); + mpf_init2 (got, 2*8*sizeof(long)); + mpf_init2 (want, 2*8*sizeof(long)); + + s = "0 * ULONG_MAX"; + mpf_set_ui (u, 0L); + mpf_mul_ui (got, u, ULONG_MAX); + MPF_CHECK_FORMAT (got); + mpf_set_ui (want, 0L); + if (mpf_cmp (got, want) != 0) + { + error: + printf ("Wrong result from %s\n", s); + mpf_trace ("u ", u); + mpf_trace ("got ", got); + mpf_trace ("want", want); + abort (); + } + + s = "1 * ULONG_MAX"; + mpf_set_ui (u, 1L); + mpf_mul_ui (got, u, ULONG_MAX); + MPF_CHECK_FORMAT (got); + mpf_set_ui (want, ULONG_MAX); + if (mpf_cmp (got, want) != 0) + goto error; + + mpf_clear (u); + mpf_clear (got); + mpf_clear (want); +} + +int +main (void) +{ + tests_start (); + + check_various (); + check_rand (); + + tests_end (); + exit (0); +} diff --git a/vendor/gmp-6.3.0/tests/mpf/t-muldiv.c b/vendor/gmp-6.3.0/tests/mpf/t-muldiv.c new file mode 100644 index 0000000..86dca57 --- /dev/null +++ b/vendor/gmp-6.3.0/tests/mpf/t-muldiv.c @@ -0,0 +1,158 @@ +/* Test mpf_mul, mpf_div, mpf_ui_div, and mpf_div_ui. + +Copyright 1996, 2000, 2001, 2003 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite 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. + +The GNU MP Library test suite 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 +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + +#include <stdio.h> +#include <stdlib.h> + +#include "gmp-impl.h" +#include "tests.h" + +#ifndef SIZE +#define SIZE 16 +#endif + +int +main (int argc, char **argv) +{ + mp_size_t size; + mp_exp_t exp; + int reps = 10000; + int i; + mpf_t u, v, w, x; + mp_size_t bprec = SIZE * GMP_LIMB_BITS; + mpf_t rerr, limit_rerr; + unsigned long ulimb, vlimb; + int single_flag; + + tests_start (); + + if (argc > 1) + { + reps = strtol (argv[1], 0, 0); + if (argc > 2) + bprec = strtol (argv[2], 0, 0); + } + + mpf_set_default_prec (bprec); + + mpf_init (rerr); + mpf_init (limit_rerr); + + mpf_init (u); + mpf_init (v); + mpf_init (w); + mpf_init (x); + + for (i = 0; i < reps; i++) + { + mp_size_t res_prec; + + res_prec = urandom () % bprec + 1; + mpf_set_prec (w, res_prec); + mpf_set_prec (x, res_prec); + + mpf_set_ui (limit_rerr, 1); + mpf_div_2exp (limit_rerr, limit_rerr, res_prec - 1); + + single_flag = 0; + + if ((urandom () & 1) != 0) + { + size = urandom () % (2 * SIZE) - SIZE; + exp = urandom () % SIZE; + mpf_random2 (u, size, exp); + } + else + { + ulimb = urandom (); + mpf_set_ui (u, ulimb); + single_flag = 1; + } + + if ((urandom () & 1) != 0) + { + size = urandom () % (2 * SIZE) - SIZE; + exp = urandom () % SIZE; + mpf_random2 (v, size, exp); + } + else + { + vlimb = urandom (); + mpf_set_ui (v, vlimb); + single_flag = 2; + } + + if (mpf_sgn (v) == 0) + continue; + + mpf_div (w, u, v); + mpf_mul (x, w, v); + mpf_reldiff (rerr, u, x); + if (mpf_cmp (rerr, limit_rerr) > 0) + { + printf ("ERROR in mpf_mul or mpf_div after %d tests\n", i); + printf (" u = "); mpf_dump (u); + printf (" v = "); mpf_dump (v); + printf (" x = "); mpf_dump (x); + printf (" w = "); mpf_dump (w); + abort (); + } + + if (single_flag == 2) + { + mpf_div_ui (x, u, vlimb); + mpf_reldiff (rerr, w, x); + if (mpf_cmp (rerr, limit_rerr) > 0) + { + printf ("ERROR in mpf_div or mpf_div_ui after %d tests\n", i); + printf (" u = "); mpf_dump (u); + printf (" v = "); mpf_dump (v); + printf (" x = "); mpf_dump (x); + printf (" w = "); mpf_dump (w); + abort (); + } + } + + if (single_flag == 1) + { + mpf_ui_div (x, ulimb, v); + mpf_reldiff (rerr, w, x); + if (mpf_cmp (rerr, limit_rerr) > 0) + { + printf ("ERROR in mpf_div or mpf_ui_div after %d tests\n", i); + printf (" u = "); mpf_dump (u); + printf (" v = "); mpf_dump (v); + printf (" x = "); mpf_dump (x); + printf (" w = "); mpf_dump (w); + abort (); + } + } + } + + mpf_clear (rerr); + mpf_clear (limit_rerr); + + mpf_clear (u); + mpf_clear (v); + mpf_clear (w); + mpf_clear (x); + + tests_end (); + exit (0); +} diff --git a/vendor/gmp-6.3.0/tests/mpf/t-pow_ui.c b/vendor/gmp-6.3.0/tests/mpf/t-pow_ui.c new file mode 100644 index 0000000..f005301 --- /dev/null +++ b/vendor/gmp-6.3.0/tests/mpf/t-pow_ui.c @@ -0,0 +1,69 @@ +/* Test mpf_pow_ui + +Copyright 2015 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite 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. + +The GNU MP Library test suite 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 +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + +#include <stdio.h> +#include <stdlib.h> + +#include "gmp-impl.h" +#include "tests.h" + +void +check_data (void) +{ + unsigned int b, e; + mpf_t b1, r, r2, limit; + + mpf_inits (b1, r, r2, NULL); + mpf_init_set_ui (limit, 1); + mpf_mul_2exp (limit, limit, MAX (GMP_NUMB_BITS, 53)); + + /* This test just test integers with results that fit in a single + limb or 53 bits. This avoids any rounding. */ + + for (b = 0; b <= 400; b++) + { + mpf_set_ui (b1, b); + mpf_set_ui (r2, 1); + for (e = 0; e <= GMP_LIMB_BITS; e++) + { + mpf_pow_ui (r, b1, e); + + if (mpf_cmp (r, r2)) + abort (); + + mpf_mul_ui (r2, r2, b); + + if (mpf_cmp (r2, limit) >= 0) + break; + } + } + + mpf_clears (b1, r, r2, limit, NULL); +} + +int +main (int argc, char **argv) +{ + tests_start (); + + check_data (); + + tests_end (); + exit (0); +} diff --git a/vendor/gmp-6.3.0/tests/mpf/t-set.c b/vendor/gmp-6.3.0/tests/mpf/t-set.c new file mode 100644 index 0000000..2510748 --- /dev/null +++ b/vendor/gmp-6.3.0/tests/mpf/t-set.c @@ -0,0 +1,112 @@ +/* Test mpf_set, mpf_init_set. + +Copyright 2004, 2012 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite 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. + +The GNU MP Library test suite 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 +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + +#include <stdio.h> +#include <stdlib.h> +#include "gmp-impl.h" +#include "tests.h" + +void +check_reuse (void) +{ + /* Try mpf_set(f,f) when f is bigger than prec. In the past this had + resulted in an MPN_COPY with invalid operand overlap. */ + mpf_t f; + mp_size_t limbs = 20; + unsigned long bits = limbs * GMP_NUMB_BITS; + mpf_init2 (f, bits); + refmpf_fill (f, limbs, GMP_NUMB_MAX); + mpf_set_prec_raw (f, bits / 2); + mpf_set (f, f); + MPF_CHECK_FORMAT (f); + mpf_set_prec_raw (f, bits); + mpf_clear (f); +} + +void +check_random (long reps) +{ + unsigned long test; + gmp_randstate_ptr rands; + mpf_t a, b; + mpz_t z; + int precbits; + +#define PRECBITS 10 + + rands = RANDS; + + mpz_init (z); + mpf_init2 (a, 1 << PRECBITS); + + for (test = 0; test < reps; test++) + { + mpz_urandomb (z, rands, PRECBITS + 1); + precbits = mpz_get_ui (z) + 1; + mpz_urandomb (z, rands, precbits); + mpz_setbit (z, precbits - 1); /* make sure msb is set */ + mpf_set_z (a, z); + if (precbits & 1) + mpf_neg (a, a); + mpz_urandomb (z, rands, PRECBITS); + mpf_div_2exp (a, a, mpz_get_ui (z) + 1); + mpz_urandomb (z, rands, PRECBITS); + precbits -= mpz_get_ui (z); + if (precbits <= 0) + precbits = 1 - precbits; + mpf_set_default_prec (precbits); + + mpf_init_set (b, a); + MPF_CHECK_FORMAT (b); + if (!mpf_eq (a, b, precbits)) + { + printf ("mpf_init_set wrong.\n"); + abort(); + } + + mpf_set_ui (b, 0); + mpf_set (b, a); + MPF_CHECK_FORMAT (b); + if (!mpf_eq (a, b, precbits)) + { + printf ("mpf_set wrong.\n"); + abort(); + } + + mpf_clear (b); + } + + mpf_clear (a); + mpz_clear (z); +} + +int +main (int argc, char *argv[]) +{ + long reps = 10000; + + tests_start (); + TESTS_REPS (reps, argv, argc); + + check_reuse (); + check_random (reps); + + tests_end (); + exit (0); +} diff --git a/vendor/gmp-6.3.0/tests/mpf/t-set_q.c b/vendor/gmp-6.3.0/tests/mpf/t-set_q.c new file mode 100644 index 0000000..86dec6e --- /dev/null +++ b/vendor/gmp-6.3.0/tests/mpf/t-set_q.c @@ -0,0 +1,126 @@ +/* Test mpf_set_q. + +Copyright 2004 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite 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. + +The GNU MP Library test suite 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 +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + +#include <stdio.h> +#include <stdlib.h> +#include "gmp-impl.h" +#include "tests.h" + + +void +check_one (mpf_ptr got, mpq_srcptr q) +{ + mpf_t n, d; + + mpf_set_q (got, q); + + PTR(n) = PTR(&q->_mp_num); + SIZ(n) = SIZ(&q->_mp_num); + EXP(n) = ABSIZ(&q->_mp_num); + + PTR(d) = PTR(&q->_mp_den); + SIZ(d) = SIZ(&q->_mp_den); + EXP(d) = ABSIZ(&q->_mp_den); + + if (! refmpf_validate_division ("mpf_set_q", got, n, d)) + { + mp_trace_base = -16; + mpq_trace (" q", q); + abort (); + } +} + +void +check_rand (void) +{ + unsigned long min_prec = __GMPF_BITS_TO_PREC (1); + gmp_randstate_ptr rands = RANDS; + unsigned long prec; + mpf_t got; + mpq_t q; + int i; + + mpf_init (got); + mpq_init (q); + + for (i = 0; i < 400; i++) + { + /* result precision */ + prec = min_prec + gmp_urandomm_ui (rands, 20L); + refmpf_set_prec_limbs (got, prec); + + /* num */ + prec = gmp_urandomm_ui (rands, 20L * GMP_NUMB_BITS); + mpz_rrandomb (mpq_numref(q), rands, prec); + + /* possibly negative num */ + if (gmp_urandomb_ui (rands, 1L)) + mpz_neg (mpq_numref(q), mpq_numref(q)); + + /* den, non-zero */ + do { + prec = gmp_urandomm_ui (rands, 20L * GMP_NUMB_BITS); + mpz_rrandomb (mpq_denref(q), rands, prec); + } while (mpz_sgn (mpq_denref(q)) <= 0); + + check_one (got, q); + } + + mpf_clear (got); + mpq_clear (q); +} + +void +check_various (void) +{ + mpf_t got; + mpq_t q; + + mpf_init (got); + mpq_init (q); + + /* 1/1 == 1 */ + mpf_set_prec (got, 20L); + mpq_set_ui (q, 1L, 1L); + mpf_set_q (got, q); + MPF_CHECK_FORMAT (got); + ASSERT_ALWAYS (mpf_cmp_ui (got, 1L) == 0); + + /* 1/(2^n+1), a case where truncating the divisor would be wrong */ + mpf_set_prec (got, 500L); + mpq_set_ui (q, 1L, 1L); + mpz_mul_2exp (mpq_denref(q), mpq_denref(q), 800L); + mpz_add_ui (mpq_denref(q), mpq_denref(q), 1L); + check_one (got, q); + + mpf_clear (got); + mpq_clear (q); +} + +int +main (void) +{ + tests_start (); + + check_various (); + check_rand (); + + tests_end (); + exit (0); +} diff --git a/vendor/gmp-6.3.0/tests/mpf/t-set_si.c b/vendor/gmp-6.3.0/tests/mpf/t-set_si.c new file mode 100644 index 0000000..5cd6c89 --- /dev/null +++ b/vendor/gmp-6.3.0/tests/mpf/t-set_si.c @@ -0,0 +1,90 @@ +/* Test mpf_set_si and mpf_init_set_si. + +Copyright 2000, 2001, 2003 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite 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. + +The GNU MP Library test suite 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 +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + +#include <stdio.h> +#include <stdlib.h> +#include "gmp-impl.h" +#include "tests.h" + +void +check_data (void) +{ + static const struct { + long x; + mp_size_t want_size; + mp_limb_t want_data[2]; + } data[] = { + + { 0L, 0 }, + { 1L, 1, { 1 } }, + { -1L, -1, { 1 } }, + +#if GMP_NUMB_BITS >= BITS_PER_ULONG + { LONG_MAX, 1, { LONG_MAX, 0 } }, + { -LONG_MAX, -1, { LONG_MAX, 0 } }, + { LONG_HIGHBIT, -1, { ULONG_HIGHBIT, 0 } }, +#else + { LONG_MAX, 2, { LONG_MAX & GMP_NUMB_MASK, LONG_MAX >> GMP_NUMB_BITS } }, + { -LONG_MAX, -2, { LONG_MAX & GMP_NUMB_MASK, LONG_MAX >> GMP_NUMB_BITS }}, + { LONG_HIGHBIT, -2, { 0, ULONG_HIGHBIT >> GMP_NUMB_BITS } }, +#endif + }; + + mpf_t x; + int i; + + for (i = 0; i < numberof (data); i++) + { + mpf_init (x); + mpf_set_si (x, data[i].x); + MPF_CHECK_FORMAT (x); + if (x->_mp_size != data[i].want_size + || refmpn_cmp_allowzero (x->_mp_d, data[i].want_data, + ABS (data[i].want_size)) != 0 + || x->_mp_exp != ABS (data[i].want_size)) + { + printf ("mpf_set_si wrong on data[%d]\n", i); + abort(); + } + mpf_clear (x); + + mpf_init_set_si (x, data[i].x); + MPF_CHECK_FORMAT (x); + if (x->_mp_size != data[i].want_size + || refmpn_cmp_allowzero (x->_mp_d, data[i].want_data, + ABS (data[i].want_size)) != 0 + || x->_mp_exp != ABS (data[i].want_size)) + { + printf ("mpf_init_set_si wrong on data[%d]\n", i); + abort(); + } + mpf_clear (x); + } +} + +int +main (void) +{ + tests_start (); + + check_data (); + + tests_end (); + exit (0); +} diff --git a/vendor/gmp-6.3.0/tests/mpf/t-set_ui.c b/vendor/gmp-6.3.0/tests/mpf/t-set_ui.c new file mode 100644 index 0000000..828067c --- /dev/null +++ b/vendor/gmp-6.3.0/tests/mpf/t-set_ui.c @@ -0,0 +1,89 @@ +/* Test mpf_set_ui and mpf_init_set_ui. + +Copyright 2000, 2001, 2003 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite 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. + +The GNU MP Library test suite 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 +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + +#include <stdio.h> +#include <stdlib.h> +#include "gmp-impl.h" +#include "tests.h" + +void +check_data (void) +{ + static const struct { + unsigned long x; + mp_size_t want_size; + mp_limb_t want_data[2]; + } data[] = { + + { 0L, 0 }, + { 1L, 1, { 1 } }, + +#if GMP_NUMB_BITS >= BITS_PER_ULONG + { ULONG_MAX, 1, { ULONG_MAX, 0 } }, + { ULONG_HIGHBIT, 1, { ULONG_HIGHBIT, 0 } }, +#else + { ULONG_MAX, 2, { ULONG_MAX & GMP_NUMB_MASK, + ULONG_MAX >> GMP_NUMB_BITS } }, + { ULONG_HIGHBIT, 2, { 0, + ULONG_HIGHBIT >> GMP_NUMB_BITS } }, +#endif + }; + + mpf_t x; + int i; + + for (i = 0; i < numberof (data); i++) + { + mpf_init (x); + mpf_set_ui (x, data[i].x); + MPF_CHECK_FORMAT (x); + if (x->_mp_size != data[i].want_size + || refmpn_cmp_allowzero (x->_mp_d, data[i].want_data, + ABS (data[i].want_size)) != 0 + || x->_mp_exp != ABS (data[i].want_size)) + { + printf ("mpf_set_ui wrong on data[%d]\n", i); + abort(); + } + mpf_clear (x); + + mpf_init_set_ui (x, data[i].x); + MPF_CHECK_FORMAT (x); + if (x->_mp_size != data[i].want_size + || refmpn_cmp_allowzero (x->_mp_d, data[i].want_data, + ABS (data[i].want_size)) != 0 + || x->_mp_exp != ABS (data[i].want_size)) + { + printf ("mpf_init_set_ui wrong on data[%d]\n", i); + abort(); + } + mpf_clear (x); + } +} + +int +main (void) +{ + tests_start (); + + check_data (); + + tests_end (); + exit (0); +} diff --git a/vendor/gmp-6.3.0/tests/mpf/t-sqrt.c b/vendor/gmp-6.3.0/tests/mpf/t-sqrt.c new file mode 100644 index 0000000..5e93aba --- /dev/null +++ b/vendor/gmp-6.3.0/tests/mpf/t-sqrt.c @@ -0,0 +1,193 @@ +/* Test mpf_sqrt, mpf_mul. + +Copyright 1996, 2001, 2004 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite 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. + +The GNU MP Library test suite 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 +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + +#include <stdio.h> +#include <stdlib.h> + +#include "gmp-impl.h" +#include "tests.h" + +#ifndef SIZE +#define SIZE 16 +#endif + +void +check_rand1 (int argc, char **argv) +{ + mp_size_t size; + mp_exp_t exp; + int reps = 20000; + int i; + mpf_t x, y, y2; + mp_size_t bprec = 100; + mpf_t rerr, max_rerr, limit_rerr; + + if (argc > 1) + { + reps = strtol (argv[1], 0, 0); + if (argc > 2) + bprec = strtol (argv[2], 0, 0); + } + + mpf_set_default_prec (bprec); + + mpf_init_set_ui (limit_rerr, 1); + mpf_div_2exp (limit_rerr, limit_rerr, bprec); +#if VERBOSE + mpf_dump (limit_rerr); +#endif + mpf_init (rerr); + mpf_init_set_ui (max_rerr, 0); + + mpf_init (x); + mpf_init (y); + mpf_init (y2); + for (i = 0; i < reps; i++) + { + size = urandom () % SIZE; + exp = urandom () % SIZE; + mpf_random2 (x, size, exp); + + mpf_sqrt (y, x); + MPF_CHECK_FORMAT (y); + mpf_mul (y2, y, y); + + mpf_reldiff (rerr, x, y2); + if (mpf_cmp (rerr, max_rerr) > 0) + { + mpf_set (max_rerr, rerr); +#if VERBOSE + mpf_dump (max_rerr); +#endif + if (mpf_cmp (rerr, limit_rerr) > 0) + { + printf ("ERROR after %d tests\n", i); + printf (" x = "); mpf_dump (x); + printf (" y = "); mpf_dump (y); + printf (" y2 = "); mpf_dump (y2); + printf (" rerr = "); mpf_dump (rerr); + printf (" limit_rerr = "); mpf_dump (limit_rerr); + printf ("in hex:\n"); + mp_trace_base = 16; + mpf_trace (" x ", x); + mpf_trace (" y ", y); + mpf_trace (" y2 ", y2); + mpf_trace (" rerr ", rerr); + mpf_trace (" limit_rerr", limit_rerr); + abort (); + } + } + } + + mpf_clear (limit_rerr); + mpf_clear (rerr); + mpf_clear (max_rerr); + + mpf_clear (x); + mpf_clear (y); + mpf_clear (y2); +} + +void +check_rand2 (void) +{ + unsigned long max_prec = 20; + unsigned long min_prec = __GMPF_BITS_TO_PREC (1); + gmp_randstate_ptr rands = RANDS; + unsigned long x_prec, r_prec; + mpf_t x, r, s; + int i; + + mpf_init (x); + mpf_init (r); + mpf_init (s); + refmpf_set_prec_limbs (s, 2*max_prec+10); + + for (i = 0; i < 500; i++) + { + /* input precision */ + x_prec = gmp_urandomm_ui (rands, max_prec-min_prec) + min_prec; + refmpf_set_prec_limbs (x, x_prec); + + /* result precision */ + r_prec = gmp_urandomm_ui (rands, max_prec-min_prec) + min_prec; + refmpf_set_prec_limbs (r, r_prec); + + mpf_random2 (x, x_prec, 1000); + + mpf_sqrt (r, x); + MPF_CHECK_FORMAT (r); + + /* Expect to prec limbs of result. + In the current implementation there's no stripping of low zero + limbs in mpf_sqrt, so size should be exactly prec. */ + if (SIZ(r) != r_prec) + { + printf ("mpf_sqrt wrong number of result limbs\n"); + mpf_trace (" x", x); + mpf_trace (" r", r); + printf (" r_prec=%lu\n", r_prec); + printf (" SIZ(r) %ld\n", (long) SIZ(r)); + printf (" PREC(r) %ld\n", (long) PREC(r)); + abort (); + } + + /* Must have r^2 <= x, since r has been truncated. */ + mpf_mul (s, r, r); + if (! (mpf_cmp (s, x) <= 0)) + { + printf ("mpf_sqrt result too big\n"); + mpf_trace (" x", x); + printf (" r_prec=%lu\n", r_prec); + mpf_trace (" r", r); + mpf_trace (" s", s); + abort (); + } + + /* Must have (r+ulp)^2 > x, or else r is too small. */ + refmpf_add_ulp (r); + mpf_mul (s, r, r); + if (! (mpf_cmp (s, x) > 0)) + { + printf ("mpf_sqrt result too small\n"); + mpf_trace (" x", x); + printf (" r_prec=%lu\n", r_prec); + mpf_trace (" r+ulp", r); + mpf_trace (" s", s); + abort (); + } + } + + mpf_clear (x); + mpf_clear (r); + mpf_clear (s); +} + +int +main (int argc, char **argv) +{ + tests_start (); + mp_trace_base = -16; + + check_rand1 (argc, argv); + check_rand2 (); + + tests_end (); + exit (0); +} diff --git a/vendor/gmp-6.3.0/tests/mpf/t-sqrt_ui.c b/vendor/gmp-6.3.0/tests/mpf/t-sqrt_ui.c new file mode 100644 index 0000000..31c587f --- /dev/null +++ b/vendor/gmp-6.3.0/tests/mpf/t-sqrt_ui.c @@ -0,0 +1,125 @@ +/* Test mpf_sqrt_ui. + +Copyright 2004, 2015 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite 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. + +The GNU MP Library test suite 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 +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + +#include <stdio.h> +#include <stdlib.h> + +#include "gmp-impl.h" +#include "tests.h" + + +void +check_rand (void) +{ + unsigned long max_prec = 15; + unsigned long min_prec = __GMPF_BITS_TO_PREC (1); + gmp_randstate_ptr rands = RANDS; + unsigned long x, prec; + mpf_t r, s; + int i; + + mpf_init (r); + mpf_init (s); + refmpf_set_prec_limbs (s, 2*max_prec+10); + + for (x = 0; x < 2; x++) + { + mpf_sqrt_ui (r, x); + MPF_CHECK_FORMAT (r); + if (mpf_cmp_ui (r, x) != 0) + { + printf ("mpf_sqrt_ui wrong for special case:\n"); + printf (" x=%lu\n", x); + mpf_trace (" r", r); + abort (); + } + } + + for (i = 0; i < 50; i++) + { + /* input, a random non-zero ulong, exponentially distributed */ + do { + x = gmp_urandomb_ui (rands, + gmp_urandomm_ui (rands, BITS_PER_ULONG) + 1); + } while (x <= 1); + + /* result precision */ + prec = gmp_urandomm_ui (rands, max_prec-min_prec) + min_prec; + refmpf_set_prec_limbs (r, prec); + + mpf_sqrt_ui (r, x); + MPF_CHECK_FORMAT (r); + + /* Expect to prec limbs of result. + In the current implementation there's no stripping of low zero + limbs in mpf_sqrt_ui, not even on perfect squares, so size should + be exactly prec. */ + if (SIZ(r) != prec) + { + printf ("mpf_sqrt_ui result not enough result limbs\n"); + printf (" x=%lu\n", x); + printf (" want prec=%lu\n", prec); + mpf_trace (" r", r); + printf (" r size %ld\n", (long) SIZ(r)); + printf (" r prec %ld\n", (long) PREC(r)); + abort (); + } + + /* Must have r^2 <= x, since r has been truncated. */ + mpf_mul (s, r, r); + if (! (mpf_cmp_ui (s, x) <= 0)) + { + printf ("mpf_sqrt_ui result too big\n"); + printf (" x=%lu\n", x); + printf (" want prec=%lu\n", prec); + mpf_trace (" r", r); + mpf_trace (" s", s); + abort (); + } + + /* Must have (r+ulp)^2 > x. + No overflow from refmpf_add_ulp since r is only prec limbs. */ + refmpf_add_ulp (r); + mpf_mul (s, r, r); + if (! (mpf_cmp_ui (s, x) > 0)) + { + printf ("mpf_sqrt_ui result too small\n"); + printf (" x=%lu\n", x); + printf (" want prec=%lu\n", prec); + mpf_trace (" r+ulp", r); + mpf_trace (" s", s); + abort (); + } + } + + mpf_clear (r); + mpf_clear (s); +} + +int +main (int argc, char **argv) +{ + tests_start (); + mp_trace_base = -16; + + check_rand (); + + tests_end (); + exit (0); +} diff --git a/vendor/gmp-6.3.0/tests/mpf/t-sub.c b/vendor/gmp-6.3.0/tests/mpf/t-sub.c new file mode 100644 index 0000000..3872264 --- /dev/null +++ b/vendor/gmp-6.3.0/tests/mpf/t-sub.c @@ -0,0 +1,287 @@ +/* Test mpf_sub. + +Copyright 1996, 2001, 2004, 2014 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite 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. + +The GNU MP Library test suite 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 +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + +#include <stdio.h> +#include <stdlib.h> + +#include "gmp-impl.h" +#include "tests.h" + +#ifndef SIZE +#define SIZE 16 +#endif + +void +check_rand (int argc, char **argv) +{ + mp_size_t size; + mp_exp_t exp; + int reps = 20000; + int i; + mpf_t u, v, w, wref; + mp_size_t bprec = 100; + mpf_t rerr, max_rerr, limit_rerr; + + if (argc > 1) + { + reps = strtol (argv[1], 0, 0); + if (argc > 2) + bprec = strtol (argv[2], 0, 0); + } + + mpf_set_default_prec (bprec); + + mpf_init_set_ui (limit_rerr, 1); + mpf_div_2exp (limit_rerr, limit_rerr, bprec); +#if VERBOSE + mpf_dump (limit_rerr); +#endif + mpf_init (rerr); + mpf_init_set_ui (max_rerr, 0); + + mpf_init (u); + mpf_init (v); + mpf_init (w); + mpf_init (wref); + for (i = 0; i < reps; i++) + { + size = urandom () % (2 * SIZE) - SIZE; + exp = urandom () % SIZE; + mpf_random2 (u, size, exp); + + size = urandom () % (2 * SIZE) - SIZE; + exp = urandom () % SIZE; + mpf_random2 (v, size, exp); + + if ((urandom () & 1) != 0) + mpf_add_ui (u, v, 1); + else if ((urandom () & 1) != 0) + mpf_sub_ui (u, v, 1); + + mpf_sub (w, u, v); + refmpf_sub (wref, u, v); + + mpf_reldiff (rerr, w, wref); + if (mpf_cmp (rerr, max_rerr) > 0) + { + mpf_set (max_rerr, rerr); +#if VERBOSE + mpf_dump (max_rerr); +#endif + if (mpf_cmp (rerr, limit_rerr) > 0) + { + printf ("ERROR after %d tests\n", i); + printf (" u = "); mpf_dump (u); + printf (" v = "); mpf_dump (v); + printf ("wref = "); mpf_dump (wref); + printf (" w = "); mpf_dump (w); + abort (); + } + } + } + + mpf_clear (limit_rerr); + mpf_clear (rerr); + mpf_clear (max_rerr); + + mpf_clear (u); + mpf_clear (v); + mpf_clear (w); + mpf_clear (wref); +} + +#define W GMP_NUMB_MAX + +void +check_data (void) +{ + static const struct { + struct { + int exp, size; + mp_limb_t d[10]; + } x, y, want; + + } data[] = { + { { 123, 2, { 8, 9 } }, { 123, 1, { 9 } }, { 122, 1, { 8 } } }, + { { 1, 1, { 9 } }, { 1, 1, { 8 } }, { 1, 1, { 1 } } }, + { { 1, 1, { 9 } }, { 1, -1, { 6 } }, { 1, 1, { 15 } } }, + { { 1, 2, { 8, 9 } }, { 1, 1, { 8 } }, { 1, 2, { 8, 1 } } }, + { { 2, 2, { 8, 1 } }, { 1, 1, { 9 } }, { 1, 1, { W } } }, + { { 2, 2, { 9, 8 } }, { 1, 1, { 9 } }, { 2, 1, { 8 } } }, + { { 2, 1, { 1 } }, { 1, 1, { 1 } }, { 1, 1, { W } } }, + { { 2, 1, { 9 } }, { 1, 1, { W } }, { 2, 2, { 1, 8 } } }, + + { { 1, 2, { W, 8 } }, { 1, 1, { 9 } }, { 0, -1, { 1 } } }, + { { 1, 2, { W, 7 } }, { 1, 1, { 9 } }, { 1, -2, { 1, 1 } } }, + { { 1, 2, { 1, 8 } }, { 1, 1, { 9 } }, { 0, -1, { W } } }, + { { 1, 2, { 1, 7 } }, { 1, 1, { 9 } }, { 1, -2, { W, 1 } } }, + { { 1, 2, { 0, 8 } }, { 1, 1, { 9 } }, { 1, -1, { 1 } } }, + { { 2, 3, { 5, 8, 1 } }, { 1, 1, { 9 } }, { 1, 2, { 5, W } } }, + { { 3, 1, { 1 } }, { 1, 1, { 1 } }, { 2, 2, { W, W } } }, + { { 1, 6, { W, W, W, W, W, 8 } }, { 1, 1, { 9 } }, { -4, -1, { 1 } } }, + { { 5, 5, { W-6, W, W, W, W } }, { 6, 1, { 1 } }, { 1, -1, { 7 } } }, + + /* f - f == 0, various sizes. + These exercise a past problem (gmp 4.1.3 and earlier) where the + result exponent was not zeroed on a zero result like this. */ + { { 0, 0 }, { 0, 0 }, { 0, 0 } }, + { { 99, 3, { 0, 0, 1 } }, { 99, 1, { 1 } }, { 0, 0 } }, + { { 99, 3, { 0, 123, 456 } }, { 99, 2, { 123, 456 } }, { 0, 0 } }, + { { 99, 3, { 123, 456, 789 } }, { 99, 3, { 123, 456, 789 } }, { 0, 0 } }, + + /* High limbs cancel, leaving just the low limbs of the longer operand. + This exercises a past problem (gmp 4.1.3 and earlier) where high zero + limbs on the remainder were not stripped before truncating to the + destination, causing loss of precision. */ + { { 123, 2, { 8, 9 } }, { 123, 1, { 9 } }, { 122, 1, { 8 } } }, + { { 123, 3, { 8, 0, 9 } }, { 123, 1, { 9 } }, { 121, 1, { 8 } } }, + { { 123, 4, { 8, 0, 0, 9 } }, { 123, 1, { 9 } }, { 120, 1, { 8 } } }, + { { 123, 5, { 8, 0, 0, 0, 9 } }, { 123, 1, { 9 } }, { 119, 1, { 8 } } }, + { { 123, 6, { 8, 0, 0, 0, 0, 9 } }, { 123, 1, { 9 } }, { 118, 1, { 8 } } }, + /* { { 123, 6, { 8, 0, 0, 0, 0, 9 } }, { 123, 6, { 9, 0, 0, 0, 0, 8 } }, { 122, 5, { W, W, W, W, W } } }, */ + + }; + + mpf_t x, y, got, want; + int i, swap, fail; + + fail = 0; + mp_trace_base = 16; + mpf_init (got); + + for (i = 0; i < numberof (data); i++) + { + for (swap = 0; swap <= 7; swap++) + { + PTR(x) = (mp_ptr) data[i].x.d; + SIZ(x) = data[i].x.size; + EXP(x) = data[i].x.exp; + PREC(x) = numberof (data[i].x.d); + MPF_CHECK_FORMAT (x); + + PTR(y) = (mp_ptr) data[i].y.d; + SIZ(y) = data[i].y.size; + EXP(y) = data[i].y.exp; + PREC(y) = numberof (data[i].y.d); + MPF_CHECK_FORMAT (y); + + PTR(want) = (mp_ptr) data[i].want.d; + SIZ(want) = data[i].want.size; + EXP(want) = data[i].want.exp; + PREC(want) = numberof (data[i].want.d); + MPF_CHECK_FORMAT (want); + + if (swap & 4) + { + mpf_swap (want, y); + } + + if ((SIZ (x) ^ SIZ (y)) < 0) + continue; /* It's an addition, not a subtraction (TO BE REMOVED) */ + + if (swap & 1) + { + mpf_swap (x, y); + SIZ(want) = - SIZ(want); + } + + if (swap & 2) + { + SIZ(want) = - SIZ(want); + SIZ(x) = - SIZ(x); + SIZ(y) = - SIZ(y); + } + + mpf_sub (got, x, y); +/* MPF_CHECK_FORMAT (got); */ + + if (! refmpf_validate ("mpf_sub", got, want)) + { + printf ("check_data() wrong result at data[%d] (operands%s swapped)\n", i, swap ? "" : " not"); + mpf_trace ("x ", x); + mpf_trace ("y ", y); + mpf_trace ("got ", got); + mpf_trace ("want", want); + fail = 1; + } + + if (SIZ (x) == 1 || SIZ (x) == 0 ) + { + if (SIZ (y)) EXP (y) -= EXP (x) - (mp_exp_t) SIZ (x); + if (SIZ (want)) EXP (want) -= EXP (x) - (mp_exp_t) SIZ (x); + EXP (x) = (mp_exp_t) SIZ (x); + + if (mpf_fits_uint_p (x)) + { + mpf_ui_sub (got, mpf_get_ui (x), y); + + if (! refmpf_validate ("mpf_ui_sub", got, want)) + { + printf ("check_data() wrong result at data[%d] (operands%s swapped)\n", i, swap ? "" : " not"); + mpf_trace ("x ", x); + mpf_trace ("y ", y); + mpf_trace ("got ", got); + mpf_trace ("want", want); + fail = 1; + } + } + } + + if (SIZ (y) == 1 || SIZ (y) == 0) + { + if (SIZ (x)) EXP (x) -= EXP (y) - (mp_exp_t) SIZ (y); + if (SIZ (want)) EXP (want) -= EXP (y) - (mp_exp_t) SIZ (y); + EXP (y) = (mp_exp_t) SIZ (y); + + if (mpf_fits_uint_p (x)) + { + mpf_sub_ui (got, x, mpf_get_ui (y)); + + if (! refmpf_validate ("mpf_sub_ui", got, want)) + { + printf ("check_data() wrong result at data[%d] (operands%s swapped)\n", i, swap ? "" : " not"); + mpf_trace ("x ", x); + mpf_trace ("y ", y); + mpf_trace ("got ", got); + mpf_trace ("want", want); + fail = 1; + } + } + } + + } + } + + mpf_clear (got); + if (fail) + abort (); +} + + +int +main (int argc, char **argv) +{ + tests_start (); + + check_data (); + check_rand (argc, argv); + + tests_end (); + exit (0); +} diff --git a/vendor/gmp-6.3.0/tests/mpf/t-trunc.c b/vendor/gmp-6.3.0/tests/mpf/t-trunc.c new file mode 100644 index 0000000..6543a1e --- /dev/null +++ b/vendor/gmp-6.3.0/tests/mpf/t-trunc.c @@ -0,0 +1,270 @@ +/* Test mpf_trunc, mpf_ceil, mpf_floor. + +Copyright 2001, 2002, 2020 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite 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. + +The GNU MP Library test suite 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 +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + +#include <stdio.h> +#include <stdlib.h> +#include "gmp-impl.h" +#include "tests.h" + + +void +check_print (mpf_srcptr src, mpf_srcptr got, mpf_srcptr want) +{ + mp_trace_base = 16; + mpf_trace ("src ", src); + mpf_trace ("got ", got); + mpf_trace ("want", want); + + printf ("got size=%d exp=%ld\n", SIZ(got), EXP(got)); + mpn_trace (" limbs=", PTR(got), (mp_size_t) ABSIZ(got)); + + printf ("want size=%d exp=%ld\n", SIZ(want), EXP(want)); + mpn_trace (" limbs=", PTR(want), (mp_size_t) ABSIZ(want)); +} + +void +check_one (mpf_srcptr src, mpf_srcptr trunc, mpf_srcptr ceil, mpf_srcptr floor) +{ + mpf_t got; + + mpf_init2 (got, mpf_get_prec (trunc)); + ASSERT_ALWAYS (PREC(got) == PREC(trunc)); + ASSERT_ALWAYS (PREC(got) == PREC(ceil)); + ASSERT_ALWAYS (PREC(got) == PREC(floor)); + +#define CHECK_SEP(name, fun, want) \ + mpf_set_ui (got, 54321L); /* initial junk */ \ + fun (got, src); \ + MPF_CHECK_FORMAT (got); \ + if (mpf_cmp (got, want) != 0) \ + { \ + printf ("%s wrong\n", name); \ + check_print (src, got, want); \ + abort (); \ + } + + CHECK_SEP ("mpf_trunc", mpf_trunc, trunc); + CHECK_SEP ("mpf_ceil", mpf_ceil, ceil); + CHECK_SEP ("mpf_floor", mpf_floor, floor); + +#define CHECK_INPLACE(name, fun, want) \ + mpf_set (got, src); \ + fun (got, got); \ + MPF_CHECK_FORMAT (got); \ + if (mpf_cmp (got, want) != 0) \ + { \ + printf ("%s wrong\n", name); \ + check_print (src, got, want); \ + abort (); \ + } + + CHECK_INPLACE ("mpf_trunc", mpf_trunc, trunc); + + /* Can't do these unconditionally in case truncation by mpf_set strips + some low non-zero limbs which would have rounded the result. */ + if (mpf_size (src) <= PREC(trunc)+1) + { + CHECK_INPLACE ("mpf_ceil", mpf_ceil, ceil); + CHECK_INPLACE ("mpf_floor", mpf_floor, floor); + } + + mpf_clear (got); +} + +void +check_all (mpf_ptr src, mpf_ptr trunc, mpf_ptr ceil, mpf_ptr floor) +{ + /* some of these values are generated with direct field assignments */ + MPF_CHECK_FORMAT (src); + MPF_CHECK_FORMAT (trunc); + MPF_CHECK_FORMAT (ceil); + MPF_CHECK_FORMAT (floor); + + check_one (src, trunc, ceil, floor); + + mpf_neg (src, src); + mpf_neg (trunc, trunc); + mpf_neg (ceil, ceil); + mpf_neg (floor, floor); + check_one (src, trunc, floor, ceil); +} + +void +check_various (void) +{ + mpf_t src, trunc, ceil, floor; + int n, i; + + mpf_init2 (src, 512L); + mpf_init2 (trunc, 256L); + mpf_init2 (ceil, 256L); + mpf_init2 (floor, 256L); + + /* 0 */ + mpf_set_ui (src, 0L); + mpf_set_ui (trunc, 0L); + mpf_set_ui (ceil, 0L); + mpf_set_ui (floor, 0L); + check_all (src, trunc, ceil, floor); + + /* 1 */ + mpf_set_ui (src, 1L); + mpf_set_ui (trunc, 1L); + mpf_set_ui (ceil, 1L); + mpf_set_ui (floor, 1L); + check_all (src, trunc, ceil, floor); + + /* 2^1024 */ + mpf_set_ui (src, 1L); + mpf_mul_2exp (src, src, 1024L); + mpf_set (trunc, src); + mpf_set (ceil, src); + mpf_set (floor, src); + check_all (src, trunc, ceil, floor); + + /* 1/2^1024, fraction only */ + mpf_set_ui (src, 1L); + mpf_div_2exp (src, src, 1024L); + mpf_set_si (trunc, 0L); + mpf_set_si (ceil, 1L); + mpf_set_si (floor, 0L); + check_all (src, trunc, ceil, floor); + + /* 1/2 */ + mpf_set_ui (src, 1L); + mpf_div_2exp (src, src, 1L); + mpf_set_si (trunc, 0L); + mpf_set_si (ceil, 1L); + mpf_set_si (floor, 0L); + check_all (src, trunc, ceil, floor); + + /* 123+1/2^64 */ + mpf_set_ui (src, 1L); + mpf_div_2exp (src, src, 64L); + mpf_add_ui (src, src, 123L); + mpf_set_si (trunc, 123L); + mpf_set_si (ceil, 124L); + mpf_set_si (floor, 123L); + check_all (src, trunc, ceil, floor); + + /* integer of full prec+1 limbs, unchanged */ + n = PREC(trunc)+1; + ASSERT_ALWAYS (n <= PREC(src)+1); + EXP(src) = n; + SIZ(src) = n; + for (i = 0; i < SIZ(src); i++) + PTR(src)[i] = i+100; + mpf_set (trunc, src); + mpf_set (ceil, src); + mpf_set (floor, src); + check_all (src, trunc, ceil, floor); + + /* full prec+1 limbs, 1 trimmed for integer */ + n = PREC(trunc)+1; + ASSERT_ALWAYS (n <= PREC(src)+1); + EXP(src) = n-1; + SIZ(src) = n; + for (i = 0; i < SIZ(src); i++) + PTR(src)[i] = i+200; + EXP(trunc) = n-1; + SIZ(trunc) = n-1; + for (i = 0; i < SIZ(trunc); i++) + PTR(trunc)[i] = i+201; + mpf_set (floor, trunc); + mpf_add_ui (ceil, trunc, 1L); + check_all (src, trunc, ceil, floor); + + /* prec+3 limbs, 2 trimmed for size */ + n = PREC(trunc)+3; + ASSERT_ALWAYS (n <= PREC(src)+1); + EXP(src) = n; + SIZ(src) = n; + for (i = 0; i < SIZ(src); i++) + PTR(src)[i] = i+300; + EXP(trunc) = n; + SIZ(trunc) = n-2; + for (i = 0; i < SIZ(trunc); i++) + PTR(trunc)[i] = i+302; + mpf_set (floor, trunc); + mpf_set (ceil, trunc); + PTR(ceil)[0]++; + check_all (src, trunc, ceil, floor); + + /* prec+4 limbs, 2 trimmed for size, 1 trimmed for integer */ + n = PREC(trunc)+4; + ASSERT_ALWAYS (n <= PREC(src)+1); + EXP(src) = n-1; + SIZ(src) = n; + for (i = 0; i < SIZ(src); i++) + PTR(src)[i] = i+400; + EXP(trunc) = n-1; + SIZ(trunc) = n-3; + for (i = 0; i < SIZ(trunc); i++) + PTR(trunc)[i] = i+403; + mpf_set (floor, trunc); + mpf_set (ceil, trunc); + PTR(ceil)[0]++; + check_all (src, trunc, ceil, floor); + + /* F.F, carry out of ceil */ + EXP(src) = 1; + SIZ(src) = 2; + PTR(src)[0] = GMP_NUMB_MAX; + PTR(src)[1] = GMP_NUMB_MAX; + EXP(trunc) = 1; + SIZ(trunc) = 1; + PTR(trunc)[0] = GMP_NUMB_MAX; + mpf_set (floor, trunc); + EXP(ceil) = 2; + SIZ(ceil) = 1; + PTR(ceil)[0] = 1; + check_all (src, trunc, ceil, floor); + + /* FF.F, carry out of ceil */ + EXP(src) = 2; + SIZ(src) = 3; + PTR(src)[0] = GMP_NUMB_MAX; + PTR(src)[1] = GMP_NUMB_MAX; + PTR(src)[2] = GMP_NUMB_MAX; + EXP(trunc) = 2; + SIZ(trunc) = 2; + PTR(trunc)[0] = GMP_NUMB_MAX; + PTR(trunc)[1] = GMP_NUMB_MAX; + mpf_set (floor, trunc); + EXP(ceil) = 3; + SIZ(ceil) = 1; + PTR(ceil)[0] = 1; + check_all (src, trunc, ceil, floor); + + mpf_clear (src); + mpf_clear (trunc); + mpf_clear (ceil); + mpf_clear (floor); +} + +int +main (void) +{ + tests_start (); + + check_various (); + + tests_end (); + exit (0); +} diff --git a/vendor/gmp-6.3.0/tests/mpf/t-ui_div.c b/vendor/gmp-6.3.0/tests/mpf/t-ui_div.c new file mode 100644 index 0000000..4b86215 --- /dev/null +++ b/vendor/gmp-6.3.0/tests/mpf/t-ui_div.c @@ -0,0 +1,151 @@ +/* Test mpf_ui_div. + +Copyright 2004 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite 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. + +The GNU MP Library test suite 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 +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + +#include <stdio.h> +#include <stdlib.h> +#include "gmp-impl.h" +#include "tests.h" + + +void +check_one (const char *desc, mpf_ptr got, unsigned long u, mpf_srcptr v) +{ + mpf_t uf; + mp_limb_t ulimbs[2]; + mp_size_t usize; + + ulimbs[0] = u & GMP_NUMB_MASK; + usize = (u != 0); +#if BITS_PER_ULONG > GMP_NUMB_BITS + u >>= GMP_NUMB_BITS; + ulimbs[1] = u; + usize += (u != 0); +#endif + PTR(uf) = ulimbs; + SIZ(uf) = usize; + EXP(uf) = usize; + + if (! refmpf_validate_division ("mpf_ui_div", got, uf, v)) + { + mp_trace_base = -16; + printf (" u 0x%lX (%lu)\n", u, u); + mpf_trace (" v", v); + printf (" %s\n", desc); + abort (); + } +} + +void +check_rand (void) +{ + unsigned long min_prec = __GMPF_BITS_TO_PREC (1); + gmp_randstate_ptr rands = RANDS; + unsigned long prec, u; + mpf_t got, v; + int i; + + mpf_init (got); + mpf_init (v); + + for (i = 0; i < 200; i++) + { + /* got precision */ + prec = min_prec + gmp_urandomm_ui (rands, 15L); + refmpf_set_prec_limbs (got, prec); + + /* u */ + prec = gmp_urandomm_ui (rands, BITS_PER_ULONG+1); + u = gmp_urandomb_ui (rands, prec); + + /* v precision */ + prec = min_prec + gmp_urandomm_ui (rands, 15L); + refmpf_set_prec_limbs (v, prec); + + /* v, non-zero */ + do { + mpf_random2 (v, PREC(v), (mp_exp_t) 20); + } while (SIZ(v) == 0); + + /* v possibly negative */ + if (gmp_urandomb_ui (rands, 1L)) + mpf_neg (v, v); + + if ((i % 2) == 0) + { + /* src != dst */ + mpf_ui_div (got, u, v); + check_one ("separate", got, u, v); + } + else + { + /* src == dst */ + prec = refmpf_set_overlap (got, v); + mpf_ui_div (got, u, got); + check_one ("overlap src==dst", got, u, v); + + mpf_set_prec_raw (got, prec); + } + } + + mpf_clear (got); + mpf_clear (v); +} + +void +check_various (void) +{ + mpf_t got, v; + + mpf_init (got); + mpf_init (v); + + /* 100/4 == 25 */ + mpf_set_prec (got, 20L); + mpf_set_ui (v, 4L); + mpf_ui_div (got, 100L, v); + MPF_CHECK_FORMAT (got); + ASSERT_ALWAYS (mpf_cmp_ui (got, 25L) == 0); + + { + /* 1/(2^n+1), a case where truncating the divisor would be wrong */ + unsigned long u = 1L; + mpf_set_prec (got, 500L); + mpf_set_prec (v, 900L); + mpf_set_ui (v, 1L); + mpf_mul_2exp (v, v, 800L); + mpf_add_ui (v, v, 1L); + mpf_ui_div (got, u, v); + check_one ("1/2^n+1, separate", got, u, v); + } + + mpf_clear (got); + mpf_clear (v); +} + +int +main (void) +{ + tests_start (); + + check_various (); + check_rand (); + + tests_end (); + exit (0); +} |