import gmp 6.2.1

This commit is contained in:
Adrien Destugues 2022-07-15 15:12:25 +02:00
parent 680f0e1112
commit b8f3cf881a
106 changed files with 4482 additions and 4201 deletions

42
gcc/gmp/.gdbinit Normal file
View File

@ -0,0 +1,42 @@
# Copyright 1999 Free Software Foundation, Inc.
#
# This file is part of the GNU MP Library.
#
# The GNU MP Library is free software; you can redistribute it and/or modify
# it under the terms of either:
#
# * the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# or
#
# * the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any
# later version.
#
# or both in parallel, as here.
#
# The GNU MP Library 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 copies of the GNU General Public License and the
# GNU Lesser General Public License along with the GNU MP Library. If not,
# see https://www.gnu.org/licenses/.
define pz
set __gmpz_dump ($)
end
define pq
set __gmpz_dump ($->_mp_num)
echo /
set __gmpz_dump ($->_mp_den)
end
define pf
set __gmpf_dump ($)
end

View File

@ -1,3 +1,204 @@
2020-11-13 Marco Bodrato <bodrato@mail.dm.unipi.it>
* Version 6.2.1 released.
* gmp-h.in (__GNU_MP_VERSION_PATCHLEVEL): Bump version info.
* Makefile.am (LIBGMP_LT_*, LIBGMPXX_LT_*): Bump revision info.
2020-11-10 Marco Bodrato <bodrato@mail.dm.unipi.it>
* configure.ac (fat_path): Add bd1, goldmont,silvermont for CPUVEC.
* mpn/x86_64/fat/fat.c: Add more CPUs.
* mpn/x86/fat/fat.c: Add more CPUs.
2020-11-01 Marco Bodrato <bodrato@mail.dm.unipi.it>
* configure.ac: X86_{,64_}PATTERN: GMP_ASM_COFF_TYPE for all ABIs;
* mpn/x86_64/x86_64-defs.m4 (COFF_TYPE): Copy from mpn/x86/x86-defs.m4
as suggested by Jeremy Drake.
* tests/misc/t-locale.c (nl_langinfo): No redefine on __TERMUX__,
spotted by Sanselme and Glisse.
* configure.ac: Consider *-*-msys as *-*-mingw* (except on arm* |
aarch64*), as suggested by Ralph Peterson.
* Makefile.am (EXTRA_DIST): Add mini-gmp/ChangeLog.
2020-10-30 Marco Bodrato <bodrato@mail.dm.unipi.it>
* tests/mpf/t-get_d_2exp.c: Test also the case zero.
* tests/mpz/t-get_d.c: Likewise.
* tests/mpf/t-trunc.c: Use mpf_size.
* tests/mpf/t-conv.c: Some more tests on zero.
2020-10-25 Marco Bodrato <bodrato@mail.dm.unipi.it>
* configfsf.guess: Updated to version 2020-10-22, from gnulib.
2020-10-17 Marco Bodrato <bodrato@mail.dm.unipi.it>
* tests/devel/Makefile.am: Remove redundancies.
* tests/mpz/io.c: Test out-of-range bases for mpz_out_str.
2020-10-15 Torbjörn Granlund <tg@gmplib.org>
* configure.ac: Recognise zen3.
* config.guess: Recognise zen3.
2020-10-14 Marco Bodrato <bodrato@mail.dm.unipi.it>
* doc/gmp.texi (Number sequences): Remove redundancy. (spotted: TonyMcC)
* configfsf.sub: Updated to version 2020-10-13, from gnulib.
* configfsf.guess: Updated to version 2020-09-19, from gnulib.
2020-10-06 Niels Möller <nisse@lysator.liu.se>
* Makefile.am: Better support for make check-mini-gmp on wine or cygwin.
2020-09-22 Torbjörn Granlund <tg@gmplib.org>
* tests/mpz/t-mul.c: Print GMP_CHECK_FFT.
* longlong.h (x86 umul_ppmm): Fix typo.
2020-09-21 Torbjörn Granlund <tg@gmplib.org>
* mpz/n_pow_ui.c: Detect and report overflow.
2020-07-04 Torbjörn Granlund <tg@gmplib.org>
* mpn/arm64/bdiv_q_1.asm: Use LEA_HI/LEA_LO
* mpn/arm64/invert_limb.asm: Likewise.
* mpn/arm64/arm64-defs.m4: New file.
* mpn/arm64/darwin.m4: New file.
* configure.ac: Use arm64/arm64-defs.m4 and arm64/darwin.m4.
2020-06-20 Torbjörn Granlund <tg@gmplib.org>
* longlong.h (add_sssaaaa arm32/arm64): Generalise allowed operands
when using adds for sub and subs for add, while disallowing 0.
(sub_ddmmss ppc64): Disallow 0 when using addic. Also disallow
constants for register-only middle addic operand.
(C add_sssaaaa and sub_ddmmss): Use more temps to make operation more
well-defined.
2020-06-18 Torbjörn Granlund <tg@gmplib.org>
* tests/devel/gen-test-longlong_h.c: New file.
* tests/devel/Makefile.am: Compile and use gen-test-longlong_h.c.
2020-06-10 Torbjörn Granlund <tg@gmplib.org>
* configure.ac: Recognise armcortexa55.
2020-05-25 Torbjörn Granlund <tg@gmplib.org>
* tests/cxx/t-assign.cc: Use reference parameter for 'catch'.
* tests/cxx/t-constr.cc: Likewise.
* tests/cxx/t-ops2z.cc: Likewise.
* tests/cxx/t-rand.cc: Likewise.
* tests/cxx/t-do-exceptions-work-at-all-with-this-compiler.cc: Likewise.
* tune/speed.c: Undo 2020-05-24 _POSIX_C_SOURCE change, it breaks on
many broken systems.
* tune/freq.c: Likewise.
* tune/time.c: Likewise.
* tune/tuneup.c: Likewise.
* tests/devel/try.c: Revert 2020-05-24 changes.
2020-05-21 Torbjörn Granlund <tg@gmplib.org>
* tune/freq.c (_POSIX_C_SOURCE): Define.
* tune/tuneup.c (print_define_with_speedup): Fall back from snprintf to
sprintf for C90.
(_POSIX_C_SOURCE): Define.
(max_opsize): Set by #define instead of const size_t to please C90.
(n_measurements): Likewise.
(speed_mpn_pre_set_str): Adhere to C90 declaration rules.
* tune/tune-gcd-p.c: Back out 2020-01-10 change to comply to C90.
* tune/time.c (speed_endtime): Cast printf args to right type.
(_POSIX_C_SOURCE): Define.
* tune/speed.h (CACHE_LINE_SIZE): Do #undef before defining.
(SPEED_ROUTINE_MPN_GCD_1): Provide dummy first argument for standard
compliance.
(SPEED_ROUTINE_MPN_HGCD2): Adhere to C90 declaration rules.
* tune/speed.c (main): Cast printf args to right type.
(_POSIX_C_SOURCE): Define.
* tests/mpz/reuse.c: Avoid using non-standard function fileno().
* tests/spinner.c: Likewise.
* tests/mpz/convert.c (str_casecmp): New function.
(main): Use it instead of non-standard strcasecmp.
* tests/misc.c (tests_start): Fall back from snprintf to sprintf for
C90.
* tests/devel/try.c: Avoid getpagesize and use POSIX sysconf instead.
(_POSIX_C_SOURCE): Define.
* mpn/generic/mod_1_1.c: Don't use C++ comments.
* mpn/generic/get_d.c: Add clarifying parens.
2020-05-18 Torbjörn Granlund <tg@gmplib.org>
* mpn/generic/toom_interpolate_12pts.c (DO_mpn_addlsh_n): Define only
when needed.
* mpn/generic/toom_interpolate_16pts.c: Likewise.
2020-05-17 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mpz/cmp.c: Avoid overflow on int even for huge sizes.
* mpq/cmp.c: Likewise.
* mpn/generic/mul_fft.c (mpn_fft_mul_modF_K):
Fully handle carry propagation in basecase multiplication.
2020-05-16 Torbjörn Granlund <tg@gmplib.org>
* mpn/generic/hgcd2.c (tabp): Combine several undefined tabp
variable definitions with a macro.
* mpn/generic/gcd_22.c: Avoid C99 constructs.
2020-05-12 Torbjörn Granlund <tg@gmplib.org>
* mpn/generic/compute_powtab.c: Avoid C99 constructs.
* mpn/generic/get_str.c: Likewise.
* mpn/generic/set_str.c: Likewise.
* gmp-impl.h (memset): Move ASSERT to before decls.
* tests/refmpn.c: Likewise.
* mpn/generic/hgcd2.c (tabp): Combine several undefined tabp variable
definitions with a macro.
* mpn/generic/strongfibo.c: Avoid defining helper function when unused.
* mpn/generic/dcpi1_bdiv_q.c (mpn_dcpi1_bdiv_q_n_itch): Disable unused
static function.
* mpz/mul.c: Add some {} to suppress warning.
* tests/mpn/t-gcd_11.c: Exit main() properly.
* tests/mpn/t-gcd_22.c: Likewise.
* tests/mpn/t-gcdext_1.c: Likewise.
2020-04-28 Torbjörn Granlund <tg@gmplib.org>
* tests/mpz/reuse.c (realloc_if_reducing): New function.
(INVOKE_RRS, etc): Use realloc_if_reducing.
2020-01-17 Torbjörn Granlund <tg@gmplib.org> 2020-01-17 Torbjörn Granlund <tg@gmplib.org>
* Version 6.2.0 released. * Version 6.2.0 released.

View File

@ -90,6 +90,7 @@
# 6.1.1 13:1:3 9:1:5 - # 6.1.1 13:1:3 9:1:5 -
# 6.1.2 13:2:3 9:2:5 - # 6.1.2 13:2:3 9:2:5 -
# 6.2.0 14:0:4 10:0:6 - # 6.2.0 14:0:4 10:0:6 -
# 6.2.1 14:1:4 10:1:6 -
# #
# Starting at 3:0:0 is a slight abuse of the versioning system, but it # Starting at 3:0:0 is a slight abuse of the versioning system, but it
# ensures we're past soname libgmp.so.2, which was used on Debian GNU/Linux # ensures we're past soname libgmp.so.2, which was used on Debian GNU/Linux
@ -103,11 +104,11 @@
# libgmpxx.so.3.0.4) incrementing, to make it clear which GMP it's from. # libgmpxx.so.3.0.4) incrementing, to make it clear which GMP it's from.
LIBGMP_LT_CURRENT = 14 LIBGMP_LT_CURRENT = 14
LIBGMP_LT_REVISION = 0 LIBGMP_LT_REVISION = 1
LIBGMP_LT_AGE = 4 LIBGMP_LT_AGE = 4
LIBGMPXX_LT_CURRENT = 10 LIBGMPXX_LT_CURRENT = 10
LIBGMPXX_LT_REVISION = 0 LIBGMPXX_LT_REVISION = 1
LIBGMPXX_LT_AGE = 6 LIBGMPXX_LT_AGE = 6
@ -412,7 +413,7 @@ EXTRA_DIST += gen-psqr.c
# Distribute mini-gmp. Test sources copied by dist-hook. # Distribute mini-gmp. Test sources copied by dist-hook.
EXTRA_DIST += mini-gmp/README mini-gmp/mini-gmp.c mini-gmp/mini-gmp.h \ EXTRA_DIST += mini-gmp/README mini-gmp/mini-gmp.c mini-gmp/mini-gmp.h \
mini-gmp/mini-mpq.c mini-gmp/mini-mpq.h \ mini-gmp/ChangeLog mini-gmp/mini-mpq.c mini-gmp/mini-mpq.h \
mini-gmp/tests/Makefile mini-gmp/tests/run-tests mini-gmp/tests/Makefile mini-gmp/tests/run-tests
# Avoid: CVS - cvs directories # Avoid: CVS - cvs directories
@ -436,7 +437,7 @@ check-mini-gmp:
abs_srcdir="`cd $(srcdir) && pwd`" ; \ abs_srcdir="`cd $(srcdir) && pwd`" ; \
$(MKDIR_P) mini-gmp/tests \ $(MKDIR_P) mini-gmp/tests \
&& cd mini-gmp/tests \ && cd mini-gmp/tests \
&& TEST_LIBRARY_PATH="../../.libs" \ && TEST_SHLIB_DIR="${abs_top_builddir}/.libs" \
$(MAKE) -f "$$abs_srcdir/mini-gmp/tests/Makefile" \ $(MAKE) -f "$$abs_srcdir/mini-gmp/tests/Makefile" \
VPATH="$$abs_srcdir/mini-gmp/tests" \ VPATH="$$abs_srcdir/mini-gmp/tests" \
srcdir="$$abs_srcdir/mini-gmp/tests" \ srcdir="$$abs_srcdir/mini-gmp/tests" \

View File

@ -101,6 +101,7 @@
# 6.1.1 13:1:3 9:1:5 - # 6.1.1 13:1:3 9:1:5 -
# 6.1.2 13:2:3 9:2:5 - # 6.1.2 13:2:3 9:2:5 -
# 6.2.0 14:0:4 10:0:6 - # 6.2.0 14:0:4 10:0:6 -
# 6.2.1 14:1:4 10:1:6 -
# #
# Starting at 3:0:0 is a slight abuse of the versioning system, but it # Starting at 3:0:0 is a slight abuse of the versioning system, but it
# ensures we're past soname libgmp.so.2, which was used on Debian GNU/Linux # ensures we're past soname libgmp.so.2, which was used on Debian GNU/Linux
@ -566,10 +567,10 @@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@ top_srcdir = @top_srcdir@
LIBGMP_LT_CURRENT = 14 LIBGMP_LT_CURRENT = 14
LIBGMP_LT_REVISION = 0 LIBGMP_LT_REVISION = 1
LIBGMP_LT_AGE = 4 LIBGMP_LT_AGE = 4
LIBGMPXX_LT_CURRENT = 10 LIBGMPXX_LT_CURRENT = 10
LIBGMPXX_LT_REVISION = 0 LIBGMPXX_LT_REVISION = 1
LIBGMPXX_LT_AGE = 6 LIBGMPXX_LT_AGE = 6
SUBDIRS = tests mpn mpz mpq mpf printf scanf rand cxx demos tune doc SUBDIRS = tests mpn mpz mpq mpf printf scanf rand cxx demos tune doc
@ -596,8 +597,9 @@ EXTRA_DIST = configfsf.guess configfsf.sub .gdbinit INSTALL.autoconf \
COPYING.LESSERv3 COPYINGv2 COPYINGv3 asl.h gmpxx.h bootstrap.c \ COPYING.LESSERv3 COPYINGv2 COPYINGv3 asl.h gmpxx.h bootstrap.c \
gen-fac.c gen-fib.c gen-bases.c gen-trialdivtab.c \ gen-fac.c gen-fib.c gen-bases.c gen-trialdivtab.c \
gen-jacobitab.c gen-psqr.c mini-gmp/README mini-gmp/mini-gmp.c \ gen-jacobitab.c gen-psqr.c mini-gmp/README mini-gmp/mini-gmp.c \
mini-gmp/mini-gmp.h mini-gmp/mini-mpq.c mini-gmp/mini-mpq.h \ mini-gmp/mini-gmp.h mini-gmp/ChangeLog mini-gmp/mini-mpq.c \
mini-gmp/tests/Makefile mini-gmp/tests/run-tests mini-gmp/mini-mpq.h mini-gmp/tests/Makefile \
mini-gmp/tests/run-tests
pkgconfigdir = $(libdir)/pkgconfig pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = gmp.pc $(am__append_1) pkgconfig_DATA = gmp.pc $(am__append_1)
@WANT_CXX_TRUE@GMPXX_HEADERS_OPTION = gmpxx.h @WANT_CXX_TRUE@GMPXX_HEADERS_OPTION = gmpxx.h
@ -1508,7 +1510,7 @@ check-mini-gmp:
abs_srcdir="`cd $(srcdir) && pwd`" ; \ abs_srcdir="`cd $(srcdir) && pwd`" ; \
$(MKDIR_P) mini-gmp/tests \ $(MKDIR_P) mini-gmp/tests \
&& cd mini-gmp/tests \ && cd mini-gmp/tests \
&& TEST_LIBRARY_PATH="../../.libs" \ && TEST_SHLIB_DIR="${abs_top_builddir}/.libs" \
$(MAKE) -f "$$abs_srcdir/mini-gmp/tests/Makefile" \ $(MAKE) -f "$$abs_srcdir/mini-gmp/tests/Makefile" \
VPATH="$$abs_srcdir/mini-gmp/tests" \ VPATH="$$abs_srcdir/mini-gmp/tests" \
srcdir="$$abs_srcdir/mini-gmp/tests" \ srcdir="$$abs_srcdir/mini-gmp/tests" \

View File

@ -3,6 +3,31 @@ Copyright 1996, 1999-2016, 2018-2020 Free Software Foundation, Inc.
Verbatim copying and distribution of this entire article is permitted in any Verbatim copying and distribution of this entire article is permitted in any
medium, provided this notice is preserved. medium, provided this notice is preserved.
Changes between GMP version 6.2.0 and 6.2.1
BUGS FIXED
* A possible overflow of type int is avoided for mpz_cmp on huge operands.
* Overflows are more carefully detected and reported for mpz_pow_ui.
* A bug in longlong.h for aarch64 sub_ddmmss, not affecting GMP, was healed.
* mini-gmp: mpz_out_str and mpq_out_str now correctly handle out of
range bases.
FEATURES
* C90 compliance.
* Initial support for Darwin on arm64, and improved portability.
* Support for more processors.
SPEEDUPS
* None, except indirectly through recognition of new CPUs.
MISC
* None.
Changes between GMP version 6.1.* and 6.2.0 Changes between GMP version 6.1.* and 6.2.0
BUGS FIXED BUGS FIXED

12
gcc/gmp/config.guess vendored
View File

@ -992,9 +992,19 @@ main ()
default: default:
modelstr = "zen2"; modelstr = "zen2";
break; break;
} }
break;
case 25: /* Zen 3 */
cpu_64bit = 1, cpu_avx = 1;
modelstr = "zen3";
break;
} }
} }
else if (strcmp (vendor_string, "HygonGenuine") == 0)
{
cpu_64bit = 1, cpu_avx = 1;
modelstr = "zen";
}
else if (strcmp (vendor_string, "CyrixInstead") == 0) else if (strcmp (vendor_string, "CyrixInstead") == 0)
{ {
/* Should recognize Cyrix' processors too. */ /* Should recognize Cyrix' processors too. */

61
gcc/gmp/configfsf.guess Normal file → Executable file
View File

@ -2,7 +2,7 @@
# Attempt to guess a canonical system name. # Attempt to guess a canonical system name.
# Copyright 1992-2020 Free Software Foundation, Inc. # Copyright 1992-2020 Free Software Foundation, Inc.
timestamp='2020-01-01' timestamp='2020-10-22'
# This file is free software; you can redistribute it and/or modify it # This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by # under the terms of the GNU General Public License as published by
@ -150,17 +150,15 @@ Linux|GNU|GNU/*)
#elif defined(__dietlibc__) #elif defined(__dietlibc__)
LIBC=dietlibc LIBC=dietlibc
#else #else
#include <stdarg.h>
#ifdef __DEFINED_va_list
LIBC=musl
#else
LIBC=gnu LIBC=gnu
#endif #endif
#endif
EOF EOF
eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`" eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`"
# If ldd exists, use it to detect musl libc.
if command -v ldd >/dev/null && \
ldd --version 2>&1 | grep -q ^musl
then
LIBC=musl
fi
;; ;;
esac esac
@ -184,6 +182,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
"/usr/sbin/$sysctl" 2>/dev/null || \ "/usr/sbin/$sysctl" 2>/dev/null || \
echo unknown)` echo unknown)`
case "$UNAME_MACHINE_ARCH" in case "$UNAME_MACHINE_ARCH" in
aarch64eb) machine=aarch64_be-unknown ;;
armeb) machine=armeb-unknown ;; armeb) machine=armeb-unknown ;;
arm*) machine=arm-unknown ;; arm*) machine=arm-unknown ;;
sh3el) machine=shl-unknown ;; sh3el) machine=shl-unknown ;;
@ -404,7 +403,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
# If there is a compiler, see if it is configured for 64-bit objects. # If there is a compiler, see if it is configured for 64-bit objects.
# Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
# This test works for both compilers. # This test works for both compilers.
if [ "$CC_FOR_BUILD" != no_compiler_found ]; then if test "$CC_FOR_BUILD" != no_compiler_found; then
if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null grep IS_64BIT_ARCH >/dev/null
@ -544,10 +543,10 @@ EOF
AViiON:dgux:*:*) AViiON:dgux:*:*)
# DG/UX returns AViiON for all architectures # DG/UX returns AViiON for all architectures
UNAME_PROCESSOR=`/usr/bin/uname -p` UNAME_PROCESSOR=`/usr/bin/uname -p`
if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ] if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110
then then
if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \ if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \
[ "$TARGET_BINARY_INTERFACE"x = x ] test "$TARGET_BINARY_INTERFACE"x = x
then then
echo m88k-dg-dgux"$UNAME_RELEASE" echo m88k-dg-dgux"$UNAME_RELEASE"
else else
@ -580,7 +579,7 @@ EOF
echo i386-ibm-aix echo i386-ibm-aix
exit ;; exit ;;
ia64:AIX:*:*) ia64:AIX:*:*)
if [ -x /usr/bin/oslevel ] ; then if test -x /usr/bin/oslevel ; then
IBM_REV=`/usr/bin/oslevel` IBM_REV=`/usr/bin/oslevel`
else else
IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" IBM_REV="$UNAME_VERSION.$UNAME_RELEASE"
@ -620,7 +619,7 @@ EOF
else else
IBM_ARCH=powerpc IBM_ARCH=powerpc
fi fi
if [ -x /usr/bin/lslpp ] ; then if test -x /usr/bin/lslpp ; then
IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc |
awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
else else
@ -655,7 +654,7 @@ EOF
9000/31?) HP_ARCH=m68000 ;; 9000/31?) HP_ARCH=m68000 ;;
9000/[34]??) HP_ARCH=m68k ;; 9000/[34]??) HP_ARCH=m68k ;;
9000/[678][0-9][0-9]) 9000/[678][0-9][0-9])
if [ -x /usr/bin/getconf ]; then if test -x /usr/bin/getconf; then
sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
case "$sc_cpu_version" in case "$sc_cpu_version" in
@ -669,7 +668,7 @@ EOF
esac ;; esac ;;
esac esac
fi fi
if [ "$HP_ARCH" = "" ]; then if test "$HP_ARCH" = ""; then
set_cc_for_build set_cc_for_build
sed 's/^ //' << EOF > "$dummy.c" sed 's/^ //' << EOF > "$dummy.c"
@ -708,7 +707,7 @@ EOF
test -z "$HP_ARCH" && HP_ARCH=hppa test -z "$HP_ARCH" && HP_ARCH=hppa
fi ;; fi ;;
esac esac
if [ "$HP_ARCH" = hppa2.0w ] if test "$HP_ARCH" = hppa2.0w
then then
set_cc_for_build set_cc_for_build
@ -782,7 +781,7 @@ EOF
echo hppa1.0-hp-osf echo hppa1.0-hp-osf
exit ;; exit ;;
i*86:OSF1:*:*) i*86:OSF1:*:*)
if [ -x /usr/sbin/sysversion ] ; then if test -x /usr/sbin/sysversion ; then
echo "$UNAME_MACHINE"-unknown-osf1mk echo "$UNAME_MACHINE"-unknown-osf1mk
else else
echo "$UNAME_MACHINE"-unknown-osf1 echo "$UNAME_MACHINE"-unknown-osf1
@ -1095,7 +1094,17 @@ EOF
echo "$UNAME_MACHINE"-dec-linux-"$LIBC" echo "$UNAME_MACHINE"-dec-linux-"$LIBC"
exit ;; exit ;;
x86_64:Linux:*:*) x86_64:Linux:*:*)
echo "$UNAME_MACHINE"-pc-linux-"$LIBC" set_cc_for_build
LIBCABI=$LIBC
if test "$CC_FOR_BUILD" != no_compiler_found; then
if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \
(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_X32 >/dev/null
then
LIBCABI="$LIBC"x32
fi
fi
echo "$UNAME_MACHINE"-pc-linux-"$LIBCABI"
exit ;; exit ;;
xtensa*:Linux:*:*) xtensa*:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
@ -1284,7 +1293,7 @@ EOF
echo mips-sony-newsos6 echo mips-sony-newsos6
exit ;; exit ;;
R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
if [ -d /usr/nec ]; then if test -d /usr/nec; then
echo mips-nec-sysv"$UNAME_RELEASE" echo mips-nec-sysv"$UNAME_RELEASE"
else else
echo mips-unknown-sysv"$UNAME_RELEASE" echo mips-unknown-sysv"$UNAME_RELEASE"
@ -1332,6 +1341,9 @@ EOF
*:Rhapsody:*:*) *:Rhapsody:*:*)
echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE"
exit ;; exit ;;
arm64:Darwin:*:*)
echo aarch64-apple-darwin"$UNAME_RELEASE"
exit ;;
*:Darwin:*:*) *:Darwin:*:*)
UNAME_PROCESSOR=`uname -p` UNAME_PROCESSOR=`uname -p`
case $UNAME_PROCESSOR in case $UNAME_PROCESSOR in
@ -1346,7 +1358,7 @@ EOF
else else
set_cc_for_build set_cc_for_build
fi fi
if [ "$CC_FOR_BUILD" != no_compiler_found ]; then if test "$CC_FOR_BUILD" != no_compiler_found; then
if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null grep IS_64BIT_ARCH >/dev/null
@ -1629,6 +1641,12 @@ copies of config.guess and config.sub with the latest versions from:
https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
and and
https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
EOF
year=`echo $timestamp | sed 's,-.*,,'`
# shellcheck disable=SC2003
if test "`expr "\`date +%Y\`" - "$year"`" -lt 3 ; then
cat >&2 <<EOF
If $0 has already been updated, send the following data and any If $0 has already been updated, send the following data and any
information you think might be pertinent to config-patches@gnu.org to information you think might be pertinent to config-patches@gnu.org to
@ -1656,6 +1674,7 @@ UNAME_RELEASE = "$UNAME_RELEASE"
UNAME_SYSTEM = "$UNAME_SYSTEM" UNAME_SYSTEM = "$UNAME_SYSTEM"
UNAME_VERSION = "$UNAME_VERSION" UNAME_VERSION = "$UNAME_VERSION"
EOF EOF
fi
exit 1 exit 1

600
gcc/gmp/configfsf.sub Normal file → Executable file

File diff suppressed because it is too large Load Diff

61
gcc/gmp/configure vendored
View File

@ -1,7 +1,7 @@
#! /bin/sh #! /bin/sh
# From configure.ac Revision. # From configure.ac Revision.
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for GNU MP 6.2.0. # Generated by GNU Autoconf 2.69 for GNU MP 6.2.1.
# #
# Report bugs to <gmp-bugs@gmplib.org, see https://gmplib.org/manual/Reporting-Bugs.html>. # Report bugs to <gmp-bugs@gmplib.org, see https://gmplib.org/manual/Reporting-Bugs.html>.
# #
@ -623,8 +623,8 @@ MAKEFLAGS=
# Identity of this package. # Identity of this package.
PACKAGE_NAME='GNU MP' PACKAGE_NAME='GNU MP'
PACKAGE_TARNAME='gmp' PACKAGE_TARNAME='gmp'
PACKAGE_VERSION='6.2.0' PACKAGE_VERSION='6.2.1'
PACKAGE_STRING='GNU MP 6.2.0' PACKAGE_STRING='GNU MP 6.2.1'
PACKAGE_BUGREPORT='gmp-bugs@gmplib.org, see https://gmplib.org/manual/Reporting-Bugs.html' PACKAGE_BUGREPORT='gmp-bugs@gmplib.org, see https://gmplib.org/manual/Reporting-Bugs.html'
PACKAGE_URL='http://www.gnu.org/software/gmp/' PACKAGE_URL='http://www.gnu.org/software/gmp/'
@ -1414,7 +1414,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures GNU MP 6.2.0 to adapt to many kinds of systems. \`configure' configures GNU MP 6.2.1 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1484,7 +1484,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of GNU MP 6.2.0:";; short | recursive ) echo "Configuration of GNU MP 6.2.1:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
@ -1624,7 +1624,7 @@ fi
test -n "$ac_init_help" && exit $ac_status test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
GNU MP configure 6.2.0 GNU MP configure 6.2.1
generated by GNU Autoconf 2.69 generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc. Copyright (C) 2012 Free Software Foundation, Inc.
@ -2630,7 +2630,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by GNU MP $as_me 6.2.0, which was It was created by GNU MP $as_me 6.2.1, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@ $ $0 $@
@ -3607,7 +3607,7 @@ fi
# Define the identity of the package. # Define the identity of the package.
PACKAGE='gmp' PACKAGE='gmp'
VERSION='6.2.0' VERSION='6.2.1'
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
@ -4360,7 +4360,7 @@ echo "include_mpn(\`alpha/default.m4')" >> $gmp_tmpconfigm4i
gcc_cflags_neon="-mfpu=neon" gcc_cflags_neon="-mfpu=neon"
gcc_cflags_tune="-mtune=cortex-a15 -mtune=cortex-a9" gcc_cflags_tune="-mtune=cortex-a15 -mtune=cortex-a9"
;; ;;
armcortexa53 | armcortexa53neon) armcortexa53 | armcortexa53neon | armcortexa55 | armcortexa55neon)
abilist="64 32" abilist="64 32"
path="arm/neon arm/v7a/cora9 arm/v6t2 arm/v6 arm/v5 arm" path="arm/neon arm/v7a/cora9 arm/v6t2 arm/v6 arm/v5 arm"
path_64="arm64/cora53 arm64" path_64="arm64/cora53 arm64"
@ -5562,7 +5562,7 @@ echo "include_mpn(\`vax/elf.m4')" >> $gmp_tmpconfigm4i
x86_have_mulx=yes x86_have_mulx=yes
path_64="x86_64/zen x86_64" path_64="x86_64/zen x86_64"
;; ;;
zen2 | zen2noavx) zen2 | zen2noavx | zen3 | zen3noavx)
gcc_cflags_cpu="-mtune=znver2 -mtune=znver1 -mtune=amdfam10 -mtune=k8" gcc_cflags_cpu="-mtune=znver2 -mtune=znver1 -mtune=amdfam10 -mtune=k8"
gcc_cflags_arch="-march=znver2 -march=znver1 -march=amdfam10 -march=k8" gcc_cflags_arch="-march=znver2 -march=znver1 -march=amdfam10 -march=k8"
path="x86/k7/mmx x86/k7 x86/mmx x86" path="x86/k7/mmx x86/k7 x86/mmx x86"
@ -5686,7 +5686,7 @@ echo "define(<GMP_AVX_NOT_REALLY_AVAILABLE>,1)" >> $gmp_tmpconfigm4
# Sun cc. # Sun cc.
cc_64_cflags="-xO3 -m64" cc_64_cflags="-xO3 -m64"
;; ;;
*-*-mingw* | *-*-cygwin) *-*-mingw* | *-*-msys | *-*-cygwin)
limb_64=longlong limb_64=longlong
CALLING_CONVENTIONS_OBJS_64="" CALLING_CONVENTIONS_OBJS_64=""
@ -5715,7 +5715,7 @@ esac
# x86s, but allow any CPU here so as to catch "none" too. # x86s, but allow any CPU here so as to catch "none" too.
# #
case $host in case $host in
*-*-mingw*) *-*-mingw* | *-*-msys)
gcc_cflags_optlist="$gcc_cflags_optlist nocygwin" gcc_cflags_optlist="$gcc_cflags_optlist nocygwin"
gcc_cflags_nocygwin="-mno-cygwin" gcc_cflags_nocygwin="-mno-cygwin"
;; ;;
@ -7288,11 +7288,12 @@ case $host in
fat_path="x86 x86/fat x86/i486 fat_path="x86 x86/fat x86/i486
x86/k6 x86/k6/mmx x86/k6/k62mmx x86/k6 x86/k6/mmx x86/k6/k62mmx
x86/k7 x86/k7/mmx x86/k7 x86/k7/mmx
x86/k8 x86/k10 x86/bt1 x86/k8 x86/k10 x86/bt1 x86/bd1
x86/pentium x86/pentium/mmx x86/pentium x86/pentium/mmx
x86/p6 x86/p6/mmx x86/p6/p3mmx x86/p6/sse2 x86/p6 x86/p6/mmx x86/p6/p3mmx x86/p6/sse2
x86/pentium4 x86/pentium4/mmx x86/pentium4/sse2 x86/pentium4 x86/pentium4/mmx x86/pentium4/sse2
x86/core2 x86/coreinhm x86/coreisbr x86/core2 x86/coreinhm x86/coreisbr
x86/goldmont x86/silvermont
x86/atom x86/atom/mmx x86/atom/sse2 x86/nano" x86/atom x86/atom/mmx x86/atom/sse2 x86/nano"
fi fi
@ -12103,7 +12104,7 @@ test -z "$OBJDUMP" && OBJDUMP=objdump
LIBGMP_DLL=0 LIBGMP_DLL=0
case $host in case $host in
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) *-*-cygwin* | *-*-mingw* | *-*-msys | *-*-pw32* | *-*-os2*)
# By default, build only static. # By default, build only static.
if test -z "$enable_shared"; then if test -z "$enable_shared"; then
enable_shared=no enable_shared=no
@ -26216,6 +26217,18 @@ echo "define(<ALIGN_LOGARITHMIC>,<$gmp_cv_asm_align_log>)" >> $gmp_tmpconfigm4
echo "include_mpn(\`arm/arm-defs.m4')" >> $gmp_tmpconfigm4i echo "include_mpn(\`arm/arm-defs.m4')" >> $gmp_tmpconfigm4i
;; ;;
64)
case $host in
*-*-darwin*)
echo "include_mpn(\`arm64/darwin.m4')" >> $gmp_tmpconfigm4i
;;
*)
echo "include_mpn(\`arm64/arm64-defs.m4')" >> $gmp_tmpconfigm4i
;;
esac
;;
esac esac
;; ;;
hppa*-*-*) hppa*-*-*)
@ -26899,13 +26912,6 @@ $as_echo "$as_me: WARNING: +----------------------------------------------------
esac esac
fi fi
case $ABI in
32)
echo "include_mpn(\`x86/x86-defs.m4')" >> $gmp_tmpconfigm4i
$as_echo "#define HAVE_HOST_CPU_FAMILY_x86 1" >>confdefs.h
@ -26948,6 +26954,13 @@ fi
$as_echo "$gmp_cv_asm_x86_coff_type" >&6; } $as_echo "$gmp_cv_asm_x86_coff_type" >&6; }
echo "define(<HAVE_COFF_TYPE>, <$gmp_cv_asm_x86_coff_type>)" >> $gmp_tmpconfigm4 echo "define(<HAVE_COFF_TYPE>, <$gmp_cv_asm_x86_coff_type>)" >> $gmp_tmpconfigm4
case $ABI in
32)
echo "include_mpn(\`x86/x86-defs.m4')" >> $gmp_tmpconfigm4i
$as_echo "#define HAVE_HOST_CPU_FAMILY_x86 1" >>confdefs.h
@ -27165,7 +27178,7 @@ echo "include_mpn(\`x86_64/x86_64-defs.m4')" >> $gmp_tmpconfigm4i
echo "include_mpn(\`x86_64/darwin.m4')" >> $gmp_tmpconfigm4i echo "include_mpn(\`x86_64/darwin.m4')" >> $gmp_tmpconfigm4i
;; ;;
*-*-mingw* | *-*-cygwin) *-*-mingw* | *-*-msys | *-*-cygwin)
echo "include_mpn(\`x86_64/dos64.m4')" >> $gmp_tmpconfigm4i echo "include_mpn(\`x86_64/dos64.m4')" >> $gmp_tmpconfigm4i
;; ;;
@ -28509,7 +28522,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their # report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. # values after options handling.
ac_log=" ac_log="
This file was extended by GNU MP $as_me 6.2.0, which was This file was extended by GNU MP $as_me 6.2.1, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
@ -28581,7 +28594,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\ ac_cs_version="\\
GNU MP config.status 6.2.0 GNU MP config.status 6.2.1
configured by $0, generated by GNU Autoconf 2.69, configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\" with options \\"\$ac_cs_config\\"

View File

@ -722,7 +722,7 @@ case $host in
gcc_cflags_neon="-mfpu=neon" gcc_cflags_neon="-mfpu=neon"
gcc_cflags_tune="-mtune=cortex-a15 -mtune=cortex-a9" gcc_cflags_tune="-mtune=cortex-a15 -mtune=cortex-a9"
;; ;;
armcortexa53 | armcortexa53neon) armcortexa53 | armcortexa53neon | armcortexa55 | armcortexa55neon)
abilist="64 32" abilist="64 32"
path="arm/neon arm/v7a/cora9 arm/v6t2 arm/v6 arm/v5 arm" path="arm/neon arm/v7a/cora9 arm/v6t2 arm/v6 arm/v5 arm"
path_64="arm64/cora53 arm64" path_64="arm64/cora53 arm64"
@ -1889,7 +1889,7 @@ case $host in
x86_have_mulx=yes x86_have_mulx=yes
path_64="x86_64/zen x86_64" path_64="x86_64/zen x86_64"
;; ;;
zen2 | zen2noavx) zen2 | zen2noavx | zen3 | zen3noavx)
gcc_cflags_cpu="-mtune=znver2 -mtune=znver1 -mtune=amdfam10 -mtune=k8" gcc_cflags_cpu="-mtune=znver2 -mtune=znver1 -mtune=amdfam10 -mtune=k8"
gcc_cflags_arch="-march=znver2 -march=znver1 -march=amdfam10 -march=k8" gcc_cflags_arch="-march=znver2 -march=znver1 -march=amdfam10 -march=k8"
path="x86/k7/mmx x86/k7 x86/mmx x86" path="x86/k7/mmx x86/k7 x86/mmx x86"
@ -2011,7 +2011,7 @@ case $host in
# Sun cc. # Sun cc.
cc_64_cflags="-xO3 -m64" cc_64_cflags="-xO3 -m64"
;; ;;
*-*-mingw* | *-*-cygwin) *-*-mingw* | *-*-msys | *-*-cygwin)
limb_64=longlong limb_64=longlong
CALLING_CONVENTIONS_OBJS_64="" CALLING_CONVENTIONS_OBJS_64=""
AC_DEFINE(HOST_DOS64,1,[Define to 1 for Windos/64]) AC_DEFINE(HOST_DOS64,1,[Define to 1 for Windos/64])
@ -2037,7 +2037,7 @@ esac
# x86s, but allow any CPU here so as to catch "none" too. # x86s, but allow any CPU here so as to catch "none" too.
# #
case $host in case $host in
*-*-mingw*) *-*-mingw* | *-*-msys)
gcc_cflags_optlist="$gcc_cflags_optlist nocygwin" gcc_cflags_optlist="$gcc_cflags_optlist nocygwin"
gcc_cflags_nocygwin="-mno-cygwin" gcc_cflags_nocygwin="-mno-cygwin"
;; ;;
@ -2291,11 +2291,12 @@ case $host in
fat_path="x86 x86/fat x86/i486 fat_path="x86 x86/fat x86/i486
x86/k6 x86/k6/mmx x86/k6/k62mmx x86/k6 x86/k6/mmx x86/k6/k62mmx
x86/k7 x86/k7/mmx x86/k7 x86/k7/mmx
x86/k8 x86/k10 x86/bt1 x86/k8 x86/k10 x86/bt1 x86/bd1
x86/pentium x86/pentium/mmx x86/pentium x86/pentium/mmx
x86/p6 x86/p6/mmx x86/p6/p3mmx x86/p6/sse2 x86/p6 x86/p6/mmx x86/p6/p3mmx x86/p6/sse2
x86/pentium4 x86/pentium4/mmx x86/pentium4/sse2 x86/pentium4 x86/pentium4/mmx x86/pentium4/sse2
x86/core2 x86/coreinhm x86/coreisbr x86/core2 x86/coreinhm x86/coreisbr
x86/goldmont x86/silvermont
x86/atom x86/atom/mmx x86/atom/sse2 x86/nano" x86/atom x86/atom/mmx x86/atom/sse2 x86/nano"
fi fi
@ -2664,7 +2665,7 @@ AC_LIBTOOL_WIN32_DLL
AC_SUBST(LIBGMP_DLL,0) AC_SUBST(LIBGMP_DLL,0)
case $host in case $host in
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) *-*-cygwin* | *-*-mingw* | *-*-msys | *-*-pw32* | *-*-os2*)
# By default, build only static. # By default, build only static.
if test -z "$enable_shared"; then if test -z "$enable_shared"; then
enable_shared=no enable_shared=no
@ -3699,6 +3700,14 @@ if test "$gmp_asm_syntax_testing" != no; then
case $ABI in case $ABI in
32) 32)
GMP_INCLUDE_MPN(arm/arm-defs.m4) ;; GMP_INCLUDE_MPN(arm/arm-defs.m4) ;;
64)
case $host in
*-*-darwin*)
GMP_INCLUDE_MPN(arm64/darwin.m4) ;;
*)
GMP_INCLUDE_MPN(arm64/arm64-defs.m4) ;;
esac
;;
esac esac
;; ;;
hppa*-*-*) hppa*-*-*)
@ -3774,11 +3783,11 @@ yes
if test "$x86_have_mulx" = yes; then if test "$x86_have_mulx" = yes; then
GMP_ASM_X86_MULX GMP_ASM_X86_MULX
fi fi
GMP_ASM_COFF_TYPE
case $ABI in case $ABI in
32) 32)
GMP_INCLUDE_MPN(x86/x86-defs.m4) GMP_INCLUDE_MPN(x86/x86-defs.m4)
AC_DEFINE(HAVE_HOST_CPU_FAMILY_x86) AC_DEFINE(HAVE_HOST_CPU_FAMILY_x86)
GMP_ASM_COFF_TYPE
GMP_ASM_X86_GOT_UNDERSCORE GMP_ASM_X86_GOT_UNDERSCORE
GMP_ASM_X86_SHLDL_CL GMP_ASM_X86_SHLDL_CL
case $enable_profiling in case $enable_profiling in
@ -3795,7 +3804,7 @@ yes
case $host in case $host in
*-*-darwin*) *-*-darwin*)
GMP_INCLUDE_MPN(x86_64/darwin.m4) ;; GMP_INCLUDE_MPN(x86_64/darwin.m4) ;;
*-*-mingw* | *-*-cygwin) *-*-mingw* | *-*-msys | *-*-cygwin)
GMP_INCLUDE_MPN(x86_64/dos64.m4) ;; GMP_INCLUDE_MPN(x86_64/dos64.m4) ;;
*-openbsd*) *-openbsd*)
GMP_DEFINE_RAW(["define(<OPENBSD>,1)"]) ;; GMP_DEFINE_RAW(["define(<OPENBSD>,1)"]) ;;

File diff suppressed because it is too large Load Diff

View File

@ -1,40 +1,143 @@
#define EOS 257 /* A Bison parser, made by GNU Bison 3.6.4. */
#define BAD 258
#define HELP 259 /* Bison interface for Yacc-like parsers in C
#define HEX 260
#define DECIMAL 261 Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation,
#define QUIT 262 Inc.
#define ABS 263
#define BIN 264 This program is free software: you can redistribute it and/or modify
#define FIB 265 it under the terms of the GNU General Public License as published by
#define GCD 266 the Free Software Foundation, either version 3 of the License, or
#define KRON 267 (at your option) any later version.
#define LCM 268
#define LUCNUM 269 This program is distributed in the hope that it will be useful,
#define NEXTPRIME 270 but WITHOUT ANY WARRANTY; without even the implied warranty of
#define POWM 271 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#define ROOT 272 GNU General Public License for more details.
#define SQRT 273
#define NUMBER 274 You should have received a copy of the GNU General Public License
#define VARIABLE 275 along with this program. If not, see <http://www.gnu.org/licenses/>. */
#define LOR 276
#define LAND 277 /* As a special exception, you may create a larger work that contains
#define EQ 278 part or all of the Bison parser skeleton and distribute that work
#define NE 279 under terms of your choice, so long as that work isn't itself a
#define LE 280 parser generator using the skeleton or a modified version thereof
#define GE 281 as a parser skeleton. Alternatively, if you modify or redistribute
#define LSHIFT 282 the parser skeleton itself, you may (at your option) remove this
#define RSHIFT 283 special exception, which will cause the skeleton and the resulting
#define UMINUS 284 Bison output files to be licensed under the GNU General Public
#ifdef YYSTYPE License without this special exception.
#undef YYSTYPE_IS_DECLARED
#define YYSTYPE_IS_DECLARED 1 This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
especially those whose name start with YY_ or yy_. They are
private implementation details that can be changed or removed. */
#ifndef YY_YY_CALC_H_INCLUDED
# define YY_YY_CALC_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif #endif
#ifndef YYSTYPE_IS_DECLARED #if YYDEBUG
#define YYSTYPE_IS_DECLARED 1 extern int yydebug;
typedef union { #endif
/* Token kinds. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype
{
YYEMPTY = -2,
YYEOF = 0, /* "end of file" */
YYerror = 256, /* error */
YYUNDEF = 257, /* "invalid token" */
EOS = 258, /* EOS */
BAD = 259, /* BAD */
HELP = 260, /* HELP */
HEX = 261, /* HEX */
DECIMAL = 262, /* DECIMAL */
QUIT = 263, /* QUIT */
ABS = 264, /* ABS */
BIN = 265, /* BIN */
FIB = 266, /* FIB */
GCD = 267, /* GCD */
KRON = 268, /* KRON */
LCM = 269, /* LCM */
LUCNUM = 270, /* LUCNUM */
NEXTPRIME = 271, /* NEXTPRIME */
POWM = 272, /* POWM */
ROOT = 273, /* ROOT */
SQRT = 274, /* SQRT */
NUMBER = 275, /* NUMBER */
VARIABLE = 276, /* VARIABLE */
LOR = 277, /* LOR */
LAND = 278, /* LAND */
EQ = 279, /* EQ */
NE = 280, /* NE */
LE = 281, /* LE */
GE = 282, /* GE */
LSHIFT = 283, /* LSHIFT */
RSHIFT = 284, /* RSHIFT */
UMINUS = 285 /* UMINUS */
};
typedef enum yytokentype yytoken_kind_t;
#endif
/* Token kinds. */
#define YYEOF 0
#define YYerror 256
#define YYUNDEF 257
#define EOS 258
#define BAD 259
#define HELP 260
#define HEX 261
#define DECIMAL 262
#define QUIT 263
#define ABS 264
#define BIN 265
#define FIB 266
#define GCD 267
#define KRON 268
#define LCM 269
#define LUCNUM 270
#define NEXTPRIME 271
#define POWM 272
#define ROOT 273
#define SQRT 274
#define NUMBER 275
#define VARIABLE 276
#define LOR 277
#define LAND 278
#define EQ 279
#define NE 280
#define LE 281
#define GE 282
#define LSHIFT 283
#define RSHIFT 284
#define UMINUS 285
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
union YYSTYPE
{
#line 142 "../../../gmp/demos/calc/calc.y"
char *str; char *str;
int var; int var;
} YYSTYPE;
#endif /* !YYSTYPE_IS_DECLARED */ #line 131 "calc.h"
};
typedef union YYSTYPE YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
#endif
extern YYSTYPE yylval; extern YYSTYPE yylval;
int yyparse (void);
#endif /* !YY_YY_CALC_H_INCLUDED */

179
gcc/gmp/doc/gmp.info Normal file
View File

@ -0,0 +1,179 @@
This is gmp.info, produced by makeinfo version 6.7 from gmp.texi.
This manual describes how to install and use the GNU multiple precision
arithmetic library, version 6.2.1.
Copyright 1991, 1993-2016, 2018-2020 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with the Front-Cover Texts being "A GNU Manual", and
with the Back-Cover Texts being "You have freedom to copy and modify
this GNU Manual, like GNU software". A copy of the license is included
in *note GNU Free Documentation License::.
INFO-DIR-SECTION GNU libraries
START-INFO-DIR-ENTRY
* gmp: (gmp). GNU Multiple Precision Arithmetic Library.
END-INFO-DIR-ENTRY

Indirect:
gmp.info-1: 863
gmp.info-2: 303737

Tag Table:
(Indirect)
Node: Top863
Node: Copying2941
Node: Introduction to GMP5288
Node: Installing GMP8004
Node: Build Options8736
Node: ABI and ISA24445
Node: Notes for Package Builds34286
Node: Notes for Particular Systems37373
Node: Known Build Problems45124
Node: Performance optimization48656
Node: GMP Basics49785
Node: Headers and Libraries50433
Node: Nomenclature and Types51838
Node: Function Classes53834
Node: Variable Conventions55369
Node: Parameter Conventions57609
Node: Memory Management59416
Node: Reentrancy60544
Node: Useful Macros and Constants62412
Node: Compatibility with older versions63403
Node: Demonstration Programs64313
Node: Efficiency66172
Node: Debugging73778
Node: Profiling80553
Node: Autoconf84544
Node: Emacs86325
Node: Reporting Bugs86931
Node: Integer Functions89557
Node: Initializing Integers90333
Node: Assigning Integers92709
Node: Simultaneous Integer Init & Assign94320
Node: Converting Integers95967
Node: Integer Arithmetic98907
Node: Integer Division100643
Node: Integer Exponentiation107402
Node: Integer Roots108899
Node: Number Theoretic Functions110616
Node: Integer Comparisons118111
Node: Integer Logic and Bit Fiddling119549
Node: I/O of Integers122189
Node: Integer Random Numbers125180
Node: Integer Import and Export127803
Node: Miscellaneous Integer Functions131819
Node: Integer Special Functions133733
Node: Rational Number Functions137906
Node: Initializing Rationals139099
Node: Rational Conversions141572
Node: Rational Arithmetic143594
Node: Comparing Rationals145006
Node: Applying Integer Functions146477
Node: I/O of Rationals147996
Node: Floating-point Functions150355
Node: Initializing Floats153400
Node: Assigning Floats157492
Node: Simultaneous Float Init & Assign160080
Node: Converting Floats161630
Node: Float Arithmetic164895
Node: Float Comparison167048
Node: I/O of Floats168619
Node: Miscellaneous Float Functions171308
Node: Low-level Functions173310
Node: Random Number Functions207558
Node: Random State Initialization208626
Node: Random State Seeding211491
Node: Random State Miscellaneous212896
Node: Formatted Output213538
Node: Formatted Output Strings213783
Node: Formatted Output Functions219178
Node: C++ Formatted Output223242
Node: Formatted Input225942
Node: Formatted Input Strings226178
Node: Formatted Input Functions230838
Node: C++ Formatted Input233807
Node: C++ Class Interface235710
Node: C++ Interface General236661
Node: C++ Interface Integers239730
Node: C++ Interface Rationals243963
Node: C++ Interface Floats247987
Node: C++ Interface Random Numbers254004
Node: C++ Interface Limitations256404
Node: Custom Allocation259979
Node: Language Bindings264198
Node: Algorithms267511
Node: Multiplication Algorithms268211
Node: Basecase Multiplication269300
Node: Karatsuba Multiplication271208
Node: Toom 3-Way Multiplication274832
Node: Toom 4-Way Multiplication281251
Node: Higher degree Toom'n'half282630
Node: FFT Multiplication283922
Node: Other Multiplication289258
Node: Unbalanced Multiplication291732
Node: Division Algorithms292520
Node: Single Limb Division292899
Node: Basecase Division295787
Node: Divide and Conquer Division296990
Node: Block-Wise Barrett Division299058
Node: Exact Division299710
Node: Exact Remainder303737
Node: Small Quotient Division305987
Node: Greatest Common Divisor Algorithms307585
Node: Binary GCD307882
Node: Lehmer's Algorithm310732
Node: Subquadratic GCD312962
Node: Extended GCD315431
Node: Jacobi Symbol316749
Node: Powering Algorithms318658
Node: Normal Powering Algorithm318921
Node: Modular Powering Algorithm319449
Node: Root Extraction Algorithms320231
Node: Square Root Algorithm320546
Node: Nth Root Algorithm322687
Node: Perfect Square Algorithm323472
Node: Perfect Power Algorithm325559
Node: Radix Conversion Algorithms326180
Node: Binary to Radix326556
Node: Radix to Binary330177
Node: Other Algorithms332265
Node: Prime Testing Algorithm332617
Node: Factorial Algorithm333801
Node: Binomial Coefficients Algorithm336201
Node: Fibonacci Numbers Algorithm337095
Node: Lucas Numbers Algorithm339569
Node: Random Number Algorithms340290
Node: Assembly Coding342410
Node: Assembly Code Organisation343370
Node: Assembly Basics344337
Node: Assembly Carry Propagation345487
Node: Assembly Cache Handling347317
Node: Assembly Functional Units349478
Node: Assembly Floating Point351091
Node: Assembly SIMD Instructions354870
Node: Assembly Software Pipelining355852
Node: Assembly Loop Unrolling356915
Node: Assembly Writing Guide359130
Node: Internals361895
Node: Integer Internals362407
Node: Rational Internals364871
Node: Float Internals366109
Node: Raw Output Internals373509
Node: C++ Interface Internals374703
Node: Contributors378024
Node: References384255
Node: GNU Free Documentation License390174
Node: Concept Index415316
Node: Function Index463130

End Tag Table

Local Variables:
coding: iso-8859-1
End:

View File

@ -1,9 +1,9 @@
This is gmp.info, produced by makeinfo version 6.6 from gmp.texi. This is gmp.info, produced by makeinfo version 6.7 from gmp.texi.
This manual describes how to install and use the GNU multiple precision This manual describes how to install and use the GNU multiple precision
arithmetic library, version 6.2.0. arithmetic library, version 6.2.1.
Copyright 1991, 1993-2016, 2018 Free Software Foundation, Inc. Copyright 1991, 1993-2016, 2018-2020 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or under the terms of the GNU Free Documentation License, Version 1.3 or
@ -24,9 +24,9 @@ GNU MP
****** ******
This manual describes how to install and use the GNU multiple precision This manual describes how to install and use the GNU multiple precision
arithmetic library, version 6.2.0. arithmetic library, version 6.2.1.
Copyright 1991, 1993-2016, 2018 Free Software Foundation, Inc. Copyright 1991, 1993-2016, 2018-2020 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or under the terms of the GNU Free Documentation License, Version 1.3 or
@ -230,7 +230,7 @@ Build Directory
directory. For example directory. For example
cd /my/build/dir cd /my/build/dir
/my/sources/gmp-6.2.0/configure /my/sources/gmp-6.2.1/configure
Not all 'make' programs have the necessary features ('VPATH') to Not all 'make' programs have the necessary features ('VPATH') to
support this. In particular, SunOS and Slowaris 'make' have bugs support this. In particular, SunOS and Slowaris 'make' have bugs
@ -1503,7 +1503,7 @@ File: gmp.info, Node: Useful Macros and Constants, Next: Compatibility with ol
-- Global Constant: const char * const gmp_version -- Global Constant: const char * const gmp_version
The GMP version number, as a null-terminated string, in the form The GMP version number, as a null-terminated string, in the form
"i.j.k". This release is "6.2.0". Note that the format "i.j" was "i.j.k". This release is "6.2.1". Note that the format "i.j" was
used, before version 4.3.0, when k was zero. used, before version 4.3.0, when k was zero.
-- Macro: __GMP_CC -- Macro: __GMP_CC
@ -1723,8 +1723,8 @@ Rational Arithmetic
Number Sequences Number Sequences
Functions like 'mpz_fac_ui', 'mpz_fib_ui' and 'mpz_bin_uiui' are Functions like 'mpz_fac_ui', 'mpz_fib_ui' and 'mpz_bin_uiui' are
designed for calculating isolated values. If a range of values is designed for calculating isolated values. If a range of values is
wanted it's probably best to call to get a starting point and wanted it's probably best to get a starting point and iterate from
iterate from there. there.
Text Input/Output Text Input/Output
Hexadecimal or octal are suggested for input or output in text Hexadecimal or octal are suggested for input or output in text
@ -1805,7 +1805,7 @@ Source File Paths
to the source directory. to the source directory.
cd /my/build/dir cd /my/build/dir
/my/source/dir/gmp-6.2.0/configure /my/source/dir/gmp-6.2.1/configure
This works via 'VPATH', and might require GNU 'make'. Alternately This works via 'VPATH', and might require GNU 'make'. Alternately
it might be possible to change the '.c.lo' rules appropriately. it might be possible to change the '.c.lo' rules appropriately.

View File

@ -1,9 +1,9 @@
This is gmp.info, produced by makeinfo version 6.6 from gmp.texi. This is gmp.info, produced by makeinfo version 6.7 from gmp.texi.
This manual describes how to install and use the GNU multiple precision This manual describes how to install and use the GNU multiple precision
arithmetic library, version 6.2.0. arithmetic library, version 6.2.1.
Copyright 1991, 1993-2016, 2018 Free Software Foundation, Inc. Copyright 1991, 1993-2016, 2018-2020 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or under the terms of the GNU Free Documentation License, Version 1.3 or

View File

@ -14,7 +14,7 @@
This manual describes how to install and use the GNU multiple precision This manual describes how to install and use the GNU multiple precision
arithmetic library, version @value{VERSION}. arithmetic library, version @value{VERSION}.
Copyright 1991, 1993-2016, 2018 Free Software Foundation, Inc. Copyright 1991, 1993-2016, 2018-2020 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document under Permission is granted to copy, distribute and/or modify this document under
the terms of the GNU Free Documentation License, Version 1.3 or any later the terms of the GNU Free Documentation License, Version 1.3 or any later
@ -2538,7 +2538,7 @@ mpz_submul (mpq_numref(q), mpq_denref(q), z);
@cindex Number sequences @cindex Number sequences
Functions like @code{mpz_fac_ui}, @code{mpz_fib_ui} and @code{mpz_bin_uiui} Functions like @code{mpz_fac_ui}, @code{mpz_fib_ui} and @code{mpz_bin_uiui}
are designed for calculating isolated values. If a range of values is wanted are designed for calculating isolated values. If a range of values is wanted
it's probably best to call to get a starting point and iterate from there. it's probably best to get a starting point and iterate from there.
@item Text Input/Output @item Text Input/Output
@cindex Text input/output @cindex Text input/output

View File

@ -1,4 +1,4 @@
@set UPDATED 17 January 2020 @set UPDATED 14 November 2020
@set UPDATED-MONTH January 2020 @set UPDATED-MONTH November 2020
@set EDITION 6.2.0 @set EDITION 6.2.1
@set VERSION 6.2.0 @set VERSION 6.2.1

View File

@ -1,4 +1,4 @@
@set UPDATED 17 January 2020 @set UPDATED 14 November 2020
@set UPDATED-MONTH January 2020 @set UPDATED-MONTH November 2020
@set EDITION 6.2.0 @set EDITION 6.2.1
@set VERSION 6.2.0 @set VERSION 6.2.1

View File

@ -2329,7 +2329,7 @@ enum
/* Major version number is the value of __GNU_MP__ too, above. */ /* Major version number is the value of __GNU_MP__ too, above. */
#define __GNU_MP_VERSION 6 #define __GNU_MP_VERSION 6
#define __GNU_MP_VERSION_MINOR 2 #define __GNU_MP_VERSION_MINOR 2
#define __GNU_MP_VERSION_PATCHLEVEL 0 #define __GNU_MP_VERSION_PATCHLEVEL 1
#define __GNU_MP_RELEASE (__GNU_MP_VERSION * 10000 + __GNU_MP_VERSION_MINOR * 100 + __GNU_MP_VERSION_PATCHLEVEL) #define __GNU_MP_RELEASE (__GNU_MP_VERSION * 10000 + __GNU_MP_VERSION_MINOR * 100 + __GNU_MP_VERSION_PATCHLEVEL)
#define __GMP_H__ #define __GMP_H__

View File

@ -289,13 +289,13 @@ typedef struct {mp_limb_t inv21, inv32, inv53;} gmp_pi2_t;
#endif #endif
#if ! HAVE_MEMSET #if ! HAVE_MEMSET
#define memset(p, c, n) \ #define memset(p, c, n) \
do { \ do { \
ASSERT ((n) >= 0); \ unsigned char *__memset__p = (unsigned char *) (p); \
char *__memset__p = (p); \ int __i; \
int __i; \ ASSERT ((n) >= 0); \
for (__i = 0; __i < (n); __i++) \ for (__i = 0; __i < (n); __i++) \
__memset__p[__i] = (c); \ __memset__p[__i] = (c); \
} while (0) } while (0)
#endif #endif

View File

@ -436,7 +436,7 @@ long __MPN(count_leading_zeros) (UDItype);
&& W_TYPE_SIZE == 32 && W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \ #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
do { \ do { \
if (__builtin_constant_p (bl) && -(USItype)(bl) < 0x100) \ if (__builtin_constant_p (bl) && -(USItype)(bl) < (USItype)(bl)) \
__asm__ ("subs\t%1, %4, %5\n\tadc\t%0, %2, %3" \ __asm__ ("subs\t%1, %4, %5\n\tadc\t%0, %2, %3" \
: "=r" (sh), "=&r" (sl) \ : "=r" (sh), "=&r" (sl) \
: "r" (ah), "rI" (bh), \ : "r" (ah), "rI" (bh), \
@ -447,8 +447,8 @@ long __MPN(count_leading_zeros) (UDItype);
: "r" (ah), "rI" (bh), "%r" (al), "rI" (bl) __CLOBBER_CC); \ : "r" (ah), "rI" (bh), "%r" (al), "rI" (bl) __CLOBBER_CC); \
} while (0) } while (0)
/* FIXME: Extend the immediate range for the low word by using both ADDS and /* FIXME: Extend the immediate range for the low word by using both ADDS and
SUBS, since they set carry in the same way. Note: We need separate SUBS, since they set carry in the same way. We need separate definitions
definitions for thumb and non-thumb to to th absense of RSC under thumb. */ for thumb and non-thumb since thumb lacks RSC. */
#if defined (__thumb__) #if defined (__thumb__)
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
do { \ do { \
@ -504,7 +504,7 @@ long __MPN(count_leading_zeros) (UDItype);
__asm__ ("subs\t%1, %4, %5\n\tsbc\t%0, %2, %3" \ __asm__ ("subs\t%1, %4, %5\n\tsbc\t%0, %2, %3" \
: "=r" (sh), "=&r" (sl) \ : "=r" (sh), "=&r" (sl) \
: "r" (ah), "rI" (bh), "r" (al), "rI" (bl) __CLOBBER_CC); \ : "r" (ah), "rI" (bh), "r" (al), "rI" (bl) __CLOBBER_CC); \
else /* only bh might be a constant */ \ else \
__asm__ ("subs\t%1, %4, %5\n\tsbc\t%0, %2, %3" \ __asm__ ("subs\t%1, %4, %5\n\tsbc\t%0, %2, %3" \
: "=r" (sh), "=&r" (sl) \ : "=r" (sh), "=&r" (sl) \
: "r" (ah), "rI" (bh), "r" (al), "rI" (bl) __CLOBBER_CC); \ : "r" (ah), "rI" (bh), "r" (al), "rI" (bl) __CLOBBER_CC); \
@ -560,11 +560,9 @@ extern UWtype __MPN(udiv_qrnnd) (UWtype *, UWtype, UWtype, UWtype);
#endif /* __arm__ */ #endif /* __arm__ */
#if defined (__aarch64__) && W_TYPE_SIZE == 64 #if defined (__aarch64__) && W_TYPE_SIZE == 64
/* FIXME: Extend the immediate range for the low word by using both
ADDS and SUBS, since they set carry in the same way. */
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \ #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
do { \ do { \
if (__builtin_constant_p (bl) && -(UDItype)(bl) < 0x1000) \ if (__builtin_constant_p (bl) && ~(UDItype)(bl) <= (UDItype)(bl)) \
__asm__ ("subs\t%1, %x4, %5\n\tadc\t%0, %x2, %x3" \ __asm__ ("subs\t%1, %x4, %5\n\tadc\t%0, %x2, %x3" \
: "=r" (sh), "=&r" (sl) \ : "=r" (sh), "=&r" (sl) \
: "rZ" ((UDItype)(ah)), "rZ" ((UDItype)(bh)), \ : "rZ" ((UDItype)(ah)), "rZ" ((UDItype)(bh)), \
@ -577,7 +575,7 @@ extern UWtype __MPN(udiv_qrnnd) (UWtype *, UWtype, UWtype, UWtype);
} while (0) } while (0)
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
do { \ do { \
if (__builtin_constant_p (bl) && -(UDItype)(bl) < 0x1000) \ if (__builtin_constant_p (bl) && ~(UDItype)(bl) <= (UDItype)(bl)) \
__asm__ ("adds\t%1, %x4, %5\n\tsbc\t%0, %x2, %x3" \ __asm__ ("adds\t%1, %x4, %5\n\tsbc\t%0, %x2, %x3" \
: "=r,r" (sh), "=&r,&r" (sl) \ : "=r,r" (sh), "=&r,&r" (sl) \
: "rZ,rZ" ((UDItype)(ah)), "rZ,rZ" ((UDItype)(bh)), \ : "rZ,rZ" ((UDItype)(ah)), "rZ,rZ" ((UDItype)(bh)), \
@ -1056,7 +1054,7 @@ extern UWtype __MPN(udiv_qrnnd) (UWtype *, UWtype, UWtype, UWtype);
&& (HAVE_HOST_CPU_haswell || HAVE_HOST_CPU_broadwell \ && (HAVE_HOST_CPU_haswell || HAVE_HOST_CPU_broadwell \
|| HAVE_HOST_CPU_skylake || HAVE_HOST_CPU_bd4 || HAVE_HOST_CPU_zen) || HAVE_HOST_CPU_skylake || HAVE_HOST_CPU_bd4 || HAVE_HOST_CPU_zen)
#define umul_ppmm(w1, w0, u, v) \ #define umul_ppmm(w1, w0, u, v) \
__asm__ ("mulx\t%3, %0, %1" \ __asm__ ("mulx\t%3, %q0, %q1" \
: "=r" (w0), "=r" (w1) \ : "=r" (w0), "=r" (w1) \
: "%d" ((UDItype)(u)), "rm" ((UDItype)(v))) : "%d" ((UDItype)(u)), "rm" ((UDItype)(v)))
#else #else
@ -1494,36 +1492,37 @@ extern UWtype __MPN(udiv_qrnnd) (UWtype *, UWtype, UWtype, UWtype);
This might seem strange, but gcc folds away the dead code late. */ This might seem strange, but gcc folds away the dead code late. */
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
do { \ do { \
if (__builtin_constant_p (bl) && bl > -0x8000 && bl <= 0x8000) { \ if (__builtin_constant_p (bl) \
&& (bl) > -0x8000 && (bl) <= 0x8000 && (bl) != 0) { \
if (__builtin_constant_p (ah) && (ah) == 0) \ if (__builtin_constant_p (ah) && (ah) == 0) \
__asm__ ("addic %1,%3,%4\n\tsubfze %0,%2" \ __asm__ ("addic %1,%3,%4\n\tsubfze %0,%2" \
: "=r" (sh), "=&r" (sl) \ : "=r" (sh), "=&r" (sl) \
: "r" ((UDItype)(bh)), \ : "r" ((UDItype)(bh)), \
"rI" ((UDItype)(al)), "*rI" (-((UDItype)(bl))) \ "r" ((UDItype)(al)), "*rI" (-((UDItype)(bl))) \
__CLOBBER_CC); \ __CLOBBER_CC); \
else if (__builtin_constant_p (ah) && (ah) == ~(UDItype) 0) \ else if (__builtin_constant_p (ah) && (ah) == ~(UDItype) 0) \
__asm__ ("addic %1,%3,%4\n\tsubfme %0,%2" \ __asm__ ("addic %1,%3,%4\n\tsubfme %0,%2" \
: "=r" (sh), "=&r" (sl) \ : "=r" (sh), "=&r" (sl) \
: "r" ((UDItype)(bh)), \ : "r" ((UDItype)(bh)), \
"rI" ((UDItype)(al)), "*rI" (-((UDItype)(bl))) \ "r" ((UDItype)(al)), "*rI" (-((UDItype)(bl))) \
__CLOBBER_CC); \ __CLOBBER_CC); \
else if (__builtin_constant_p (bh) && (bh) == 0) \ else if (__builtin_constant_p (bh) && (bh) == 0) \
__asm__ ("addic %1,%3,%4\n\taddme %0,%2" \ __asm__ ("addic %1,%3,%4\n\taddme %0,%2" \
: "=r" (sh), "=&r" (sl) \ : "=r" (sh), "=&r" (sl) \
: "r" ((UDItype)(ah)), \ : "r" ((UDItype)(ah)), \
"rI" ((UDItype)(al)), "*rI" (-((UDItype)(bl))) \ "r" ((UDItype)(al)), "*rI" (-((UDItype)(bl))) \
__CLOBBER_CC); \ __CLOBBER_CC); \
else if (__builtin_constant_p (bh) && (bh) == ~(UDItype) 0) \ else if (__builtin_constant_p (bh) && (bh) == ~(UDItype) 0) \
__asm__ ("addic %1,%3,%4\n\taddze %0,%2" \ __asm__ ("addic %1,%3,%4\n\taddze %0,%2" \
: "=r" (sh), "=&r" (sl) \ : "=r" (sh), "=&r" (sl) \
: "r" ((UDItype)(ah)), \ : "r" ((UDItype)(ah)), \
"rI" ((UDItype)(al)), "*rI" (-((UDItype)(bl))) \ "r" ((UDItype)(al)), "*rI" (-((UDItype)(bl))) \
__CLOBBER_CC); \ __CLOBBER_CC); \
else \ else \
__asm__ ("addic %1,%4,%5\n\tsubfe %0,%3,%2" \ __asm__ ("addic %1,%4,%5\n\tsubfe %0,%3,%2" \
: "=r" (sh), "=&r" (sl) \ : "=r" (sh), "=&r" (sl) \
: "r" ((UDItype)(ah)), "r" ((UDItype)(bh)), \ : "r" ((UDItype)(ah)), "r" ((UDItype)(bh)), \
"rI" ((UDItype)(al)), "*rI" (-((UDItype)(bl))) \ "r" ((UDItype)(al)), "*rI" (-((UDItype)(bl))) \
__CLOBBER_CC); \ __CLOBBER_CC); \
} else { \ } else { \
if (__builtin_constant_p (ah) && (ah) == 0) \ if (__builtin_constant_p (ah) && (ah) == 0) \
@ -2056,8 +2055,10 @@ extern __longlong_h_C UWtype mpn_udiv_qrnnd_r (UWtype, UWtype, UWtype, UWtype *)
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \ #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
do { \ do { \
UWtype __x; \ UWtype __x; \
__x = (al) + (bl); \ UWtype __al = (al); \
(sh) = (ah) + (bh) + (__x < (al)); \ UWtype __bl = (bl); \
__x = __al + __bl; \
(sh) = (ah) + (bh) + (__x < __al); \
(sl) = __x; \ (sl) = __x; \
} while (0) } while (0)
#endif #endif
@ -2066,8 +2067,10 @@ extern __longlong_h_C UWtype mpn_udiv_qrnnd_r (UWtype, UWtype, UWtype, UWtype *)
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
do { \ do { \
UWtype __x; \ UWtype __x; \
__x = (al) - (bl); \ UWtype __al = (al); \
(sh) = (ah) - (bh) - ((al) < (bl)); \ UWtype __bl = (bl); \
__x = __al - __bl; \
(sh) = (ah) - (bh) - (__al < __bl); \
(sl) = __x; \ (sl) = __x; \
} while (0) } while (0)
#endif #endif

673
gcc/gmp/mini-gmp/ChangeLog Normal file
View File

@ -0,0 +1,673 @@
2020-11-10 Marco Bodrato <bodrato@mail.dm.unipi.it>
* tests/run-tests: Update WINEPATH, instead of overwriting it.
2020-10-25 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-mpq.c (mpq_canonical_sign): Use the correct type for size.
2020-10-18 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-mpq.c (mpq_out_str): Return 0 when base is out of range.
* mini-gmp.c (mpz_out_str): Likewise. (spotted by Paul Eggert)
* tests/t-str.c: Test out-of-range bases for mpz_out_str.
* tests/t-mpq_str.c: Likewise, for mpq_out_str.
2020-10-06 Niels Möller <nisse@lysator.liu.se>
* tests/run-tests: Better support for make check on wine or cygwin.
2020-09-10 Marco Bodrato <bodrato@mail.dm.unipi.it>
* tests/t-mpq_double.c (mpq_get_d_exact_p): Cleanup.
* mini-gmp.h: Update FILE tests from gmp-h (tx Vincent Lefèvre).
2020-05-21 Torbjörn Granlund <tg@gmplib.org>
* tests/t-mpq_muldiv_2exp.c (testmain): Cast printf args to right type.
* tests/t-double.c: Provide default M_PI definition.
2020-05-19 Torbjörn Granlund <tg@gmplib.org>
* tests/hex-random.h (enum hex_random_op): Remove final ",".
2019-12-04 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp/mini-gmp.c (mpn_invert_3by2): Remove shortcuts.
2019-11-19 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp/mini-gmp.c (mpn_invert_3by2): Shortcut for short limbs.
2019-11-09 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp/mini-gmp.c (gmp_clz, gmp_popcount_limb, mpz_export):
Avoid undefined behaviour with small limb sizes.
2019-09-30 Niels Möller <nisse@lysator.liu.se>
* tests/t-gcd.c (gcdext_valid_p): Stricter checks for gcdext
corner cases.
2018-12-21 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp/mini-gmp.c: Support for micro-gmp.
2018-11-07 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp/mini-gmp.c: Silence a couple of warnings.
2018-10-30 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.c (mpz_probab_prime_p): BPSW test for primality.
* tests/hex-random.c (hex_random_lucm_op): New function.
* tests/hex-random.h: Declare it.
* tests/mini-random.c (mini_random_lucm_op): New function.
* tests/mini-random.h: Declare it.
* mini-gmp/tests/t-lucm.c: New test
* mini-gmp/tests/Makefile (CHECK_PROGRAMS): Add t-lucm.
2018-09-07 Niels Möller <nisse@lysator.liu.se>
* tests/t-div.c (testmain): Add missing const declarations.
2018-05-20 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.c (mpz_get_d): Convert a fixed number of
bits (GMP_DBL_MANT_BITS) to avoid rounding.
* mini-mpq.c (mpq_mul): Use mpq_nan_init.
* tests/t-double.c (test_matissa): Tests converted bits.
2018-04-26 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-mpq.c: New file, mini-implementation of mpq_t.
* mini-mpq.h: New file, definitions for mpq_t.
* tests/t-mpq_addsub: New tests for mpq_add and sub.
* tests/t-mpq_muldiv: New tests for mpq_mul and div.
* tests/t-mpq_muldiv_2exp: New tests for mpq_*_2exp.
2018-03-11 Niels Möller <nisse@lysator.liu.se>
* mini-gmp.c (mpn_div_qr_2_preinv): Drop separate rp argument.
Clobber input np, and store remainder in np[0] and np[1]. This is
all the current caller needs, and it eliminates one allocation in
the common case of un-normalized d.
(mpn_div_qr_2): Delete #if:ed out function.
(mpn_div_qr_preinv): Update the only call site for
mpn_div_qr_2_preinv.
2018-02-10 Niels Möller <nisse@lysator.liu.se>
* mini-gmp.c (mpn_div_qr_1_preinv): When qp is non-NULL, reuse
area for shifted input, to avoid an allocation.
2018-01-15 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.c (gmp_popcount_limb): Micro-optimisations.
* tests/t-comb.c (checkWilson): Check also mpz_2fac_ui.
2017-12-30 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.c (mpz_mfac_ui, mpz_2fac_ui): New functions.
* mini-gmp.h: Declare them.
* mini-gmp.c (mpz_fac_ui): Use mpz_mfac_ui.
2017-07-23 Niels Möller <nisse@lysator.liu.se>
* mini-gmp.c (GMP_MPN_OVERLAP_P): New macro, copy of
MPN_OVERLAP_P, from gmp-impl.h.
(mpn_mul): Assert that output area doesn't overlap with the input.
2017-02-03 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.c (mpz_sizeinbase, mpz_get_str, mpz_set_str): Support
bases up to 62.
* tests/t-str.c: Update tests accordingly.
2016-11-27 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.c (mpz_get_si): fewer branches, safer forumla for negatives.
* tests/t-signed.c: Removed a typo
2016-11-24 Niels Möller <nisse@lysator.liu.se>
* tests/hex-random.c (mkseed): Produce a 48-bit mpz_t value,
regardless of word size.
(hex_random_init): Use gmp_randseed instead of gmp_randseed_ui,
and support seeds exceeding an unsigned long.
* tests/hex-random.c (mkseed): New function, using /dev/urandom
for random seed when available.
(hex_random_init): Use it.
2016-11-23 Niels Möller <nisse@lysator.liu.se>
* mini-gmp.c (GMP_CMP): New macro.
(mpz_sgn, mpz_cmp_si, mpz_cmp_ui, mpz_cmpabs_ui): Use it.
2016-11-22 Niels Möller <nisse@lysator.liu.se>
* tests/t-invert.c (test_3by2, test_2by1): New functions,
extracted from testmain.
(testmain): Add test with inputs which triggered the
mpn_invert_3by2 bug (see 2016-11-16 entry).
2016-11-21 Marco Bodrato <bodrato@mail.dm.unipi.it>
* tests/t-signed.c: compare different signs, and after overflow.
2016-11-20 Niels Möller <nisse@lysator.liu.se>
* tests/t-signed.c: Reorganize testcase, to avoid undefined
behaviour with signed overflow.
2016-11-19 Niels Möller <nisse@lysator.liu.se>
* tests/run-tests: Set up LD_LIBRARY_PATH and DYLD_LIBRARY_PATH
for tests only, based on TEST_LIBRARY_PATH.
* tests/mini-random.h: Use name "../mini-gmp.h" for include, so we
don't need any -I options to the compiler.
* tests/Makefile: Pass CFLAGS to the linker, as
recommended by the GNU coding standard.
(CPPFLAGS): New variable, with empty default value.
(CFLAGS): Remove the -I flag involving MINI_GMP_DIR, to leave free
for overriding on make command line.
(EXTRA_CFLAGS): Deleted variable, no longer needed.
2016-11-18 Torbjörn Granlund <tg@gmplib.org>
* tests/Makefile: Pass EXTRA_CFLAGS to linker as a intermediate fix.
2016-11-17 Marco Bodrato <bodrato@mail.dm.unipi.it>
* tests/t-str.c: free a pointer to avoid memory leaks.
2016-11-16 Niels Möller <nisse@lysator.liu.se>
* mini-gmp.c (mpn_invert_3by2): Fix arithmetic overflow
bug, and improve documentation of the algorithm.
2016-11-15 Niels Möller <nisse@lysator.liu.se>
* tests/t-limbs.c (testmain): Skip tests with zero product.
* tests/hex-random.c (hex_random_init): Added fflush call.
2016-11-15 Torbjörn Granlund <tg@gmplib.org>
* tests/Makefile (TESTS): New variable, allowing separation of
compilation and running of tests.
* tests/run-tests: Allow empty tests list.
2016-11-14 Marco Bodrato <bodrato@mail.dm.unipi.it>
* tests/t-str.c: Some more test cases.
* tests/t-pprime_p.c: Use shorter operands, with different sizes.
2016-11-01 Torbjörn Granlund <tg@gmplib.org>
* tests/hex-random.c: Reinstate gmp.h inclusion.
2016-08-22 Niels Möller <nisse@lysator.liu.se>
* mini-gmp.c (mpn_set_str_other): Always return size >= 1, with
unnormalized result in the case the input digits are all zero.
Fixes crash on a large number of leading zeros, reported by Axel
Miller.
(mpz_set_str): Normalize as needed, after above change. Return
failure for inputs string with no digits, i.e., empty except for
optional sign, base prefix and white space.
2016-01-01 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.c: Silence warnings due to (un)signed types.
* tests/testutils.c: Likewise.
* tests/t-logops.c: Likewise.
* tests/t-cmp_d.c: Likewise.
* tests/t-reuse.c: Likewise.
* tests/t-cong.c: Likewise.
2015-11-13 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.c: Lazy allocation for mpz_t.
(mpz_rootrem): Exploit lazy allocation to avoid init2.
2015-11-06 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.c (mpn_com, mpn_neg): New functions.
* mini-gmp.h: Declare them.
* mini-gmp.c (mpz_div_r_2exp): Use mpn_neg.
2015-10-29 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.c: Removed a typo (spotted by Paul Zimmermann).
2015-05-30 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.h: Declare mpn_zero_p.
* mini-gmp.c: Define mpn_zero_p as a function, not a macro.
2014-08-27 Niels Möller <nisse@lysator.liu.se>
* mini-gmp.c (mpz_abs_sub_bit): Do full normalization,
needed if mpz_clrbit clears the most significant one bit.
2014-07-28 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.c: Remove some useless variables.
2014-05-20 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.c: +1 in the init2 argument before setbit.
2014-05-15 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.c: Micro-optimisations.
2014-03-12 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.c (mpz_probab_prime_p): Micro-optimisation.
2014-03-06 Niels Möller <nisse@lysator.liu.se>
* mini-gmp.c (gmp_millerrabin): New internal function.
(mpz_probab_prime_p): New function.
* mini-gmp.h (mpz_probab_prime_p): Declare it.
* tests/t-pprime_p.c: New test program.
* tests/Makefile (CHECK_PROGRAMS): Added t-pprime_p.
2014-03-03 Niels Möller <nisse@lysator.liu.se>
* mini-gmp.c (mpz_congruent_p): New function.
* mini-gmp.h: Declare it.
* tests/t-cong.c: New file, based on tests/mpz/t-cong.c.
* tests/Makefile (CHECK_PROGRAMS): Added t-cong.
* tests/testutils.c (dump): New function. Deleted static
functions in other files.
(mpz_set_str_or_abort): Moved function here, from...
* tests/t-cmp_d.c: ... old location.
* tests/t-reuse.c (dump3): Renamed, from ...
(dump): ...old name.
2014-02-21 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.c (mpn_sqrtrem): New function.
* mini-gmp.h: Declare it.
* tests/t-sqrt.c: Test it.
2014-02-15 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.c (mpz_div_qr): init + set = init_set .
2014-02-10 Marco Bodrato <bodrato@mail.dm.unipi.it>
* tests/t-limbs.c: New test for mpz_limbs_*.
* tests/Makefile (CHECK_PROGRAMS): Add it.
2014-02-08 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.c (mpz_realloc2, mpz_limbs_read, mpz_limbs_modify
mpz_limbs_write, mpz_limbs_finish, mpz_roinit_n): New functions.
(mpn_perfect_square_p): New function.
* mini-gmp.h: Declare them.
* tests/t-mul.c: Use roinit and limbs_read to test mpn.
* tests/t-sqrt.c: Test also mpn_perfect_square_p.
2014-02-03 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.c (mpn_rootrem): Allow NULL argument.
* mini-gmp.c (mpn_zero): New function.
(mpz_perfect_square_p): New function.
* mini-gmp.h: Declare them.
* tests/t-sqrt.c: Test mpz_perfect_square_p.
* tests/t-root.c: Test also 1-th root, allow perfect powers.
2014-01-23 Marco Bodrato <bodrato@mail.dm.unipi.it>
* tests/t-aorsmul.c: New file, test for mpz_{add,sub}mul{,_ui}
* tests/Makefile: Add t-aorsmul.
2014-01-19 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.c (mpn_popcount): New function.
(mpz_popcount): Use it.
(mpz_addmul_ui, mpz_addmul, mpz_submul_ui, mpz_submul): Added.
* mini-gmp.h: Declare them.
2014-01-16 Niels Möller <nisse@lysator.liu.se>
* mini-gmp.c (mp_bits_per_limb): New const value.
* mini-gmp.h: Declare it.
2013-03-13 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.c: Write loops in a cleaner way.
2013-02-27 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.c (mpz_div_q_2exp): Adjust only if needed.
(mpn_common_scan): New service function to unify scan loops.
(mpz_scan0, mpz_scan1): Simplify by using mpn_common_scan.
(mpz_make_odd): Simplify, assume in-place operation on positive.
(mpn_scan0, mpn_scan1): New functions.
* mini-gmp.h (mpn_scan0, mpn_scan1): New declarations.
* tests/t-scan.c: Test also mpn_scan0 and mpn_scan1.
2013-02-25 Niels Möller <nisse@lysator.liu.se>
* tests/t-double.c (testmain): Declare double variables as
volatile, to drop extended precision.
* tests/testutils.c (testfree): New function. Use it everywhere
where test programs deallocate storage allocated via the mini-gmp
allocation functions, including uses of mpz_get_str for various
test failure messages.
2013-02-19 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.c: Move asserts to work-around a compiler bug.
(mpz_export): Reorder branches.
(mpz_mul_ui): Avoid temporary allocation (mpn_mul_1 can work in-place).
* tests/t-reuse.c: Fix typo causing the same negation condition to
be applied to all operands. (See 2013-02-03, Torbjorn)
2013-02-17 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.c (mpz_mul): Read sizes just once.
(mpn_set_str_other): Remove a redundant variable.
(mpz_abs_add): Use SWAP once, to order sizes.
(mpz_mul_ui): Micro-optimisation.
(mpz_rootrem): Use _init2 before _setbit.
(mpz_set_str): Optimise-out a variable.
(mpz_import): Normalise only if needed.
(mpn_div_qr_1): Speed-up the d=1 case, delaying a branch.
2013-02-12 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.c (fac_ui, bin_uiui): Use shorter and faster code.
* mini-gmp.c: Reduce branches.
2013-01-23 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.c (mpz_cmpabs_d, mpz_cmp_d): Simplify.
(mpz_set_str): Behaviour more adherent to the real GMP.
* tests/t-str.c: Cast size_t to unsigned long, for printf.
* tests/t-import.c: Likewise.
* tests/t-comb.c: Remove an unused var.
* tests/t-div.c: Remove unused args passed to fprintf.
* tests/t-double.c: Use float immediates with float vars.
2013-01-22 Niels Möller <nisse@lysator.liu.se>
* mini-gmp.c (mpz_cmp_d): Simplified, just sort out signs, then
call mpz_cmpabs_d.
* tests/testutils.h: Include stdio.h and stdlib.h.
(numberof): New define.
* tests/t-cmp_d.c: New file, copied from tests/mpz/t-cmp_d.c with
minor changes.
* tests/Makefile (CHECK_PROGRAMS): Added t-cmp_d,
* mini-gmp.c (mpz_cmpabs_d): New function.
* mini-gmp.h: Declare it.
2013-01-21 Niels Möller <nisse@lysator.liu.se>
* tests/t-str.c (testmain): Test mpz_out_str, using
the tmpfile function for i/o.
2013-01-20 Marco Bodrato <bodrato@mail.dm.unipi.it>
* tests/testutils.c (testhalves): New function, test default
memory functions.
* tests/testutils.h (testhalves): Declare it
* tests/t-logops.c: Use testhalves.
* mini-gmp.c (mpz_init_set_str): New function.
* mini-gmp.h (mpz_init_set_str): Declare it.
* tests/t-str.c: Test mpz_init_set_str.
2013-01-19 Marco Bodrato <bodrato@mail.dm.unipi.it>
* tests/t-double.c (testmain): Get the current free
function using mp_get_memory_functions.
* tests/t-str.c (testmain): Likewise.
* tests/testutils.h (tu_free): Remove declaration.
* tests/testutils.c (block_check, tu_free): Mark static.
2013-01-18 Niels Möller <nisse@lysator.liu.se>
* tests/t-str.c (test_small): New function, exercising
parsing of whitespace and base prefixes.
(testmain): Call it.
* tests/t-gcd.c (gcdext_valid_p): Fixed memory leak.
* tests/t-double.c (testmain): Call tu_free rather than
free, for storage allocated by mpz_get_str.
* tests/t-str.c (testmain): Likewise.
* tests/testutils.c (block_init, block_check): New functions.
(tu_alloc, tu_realloc, tu_free): New functions.
(main): Use mp_set_memory_functions.
* tests/testutils.h (tu_free): Declare.
* tests/testutils.h: New file, declarations for test programs.
* tests/testutils.c (main): New file, with shared main
function for all the test programs. Also includes mini-gmp.c.
Calls testmain after initialization. All other test programs
updated to define testmain rather than main.
2013-01-18 Marco Bodrato <bodrato@mail.dm.unipi.it>
* tests/t-signed.c: Slightly larger coverage.
* tests/t-double.c: Test also mpz_init_set_d.
2013-01-18 Torbjorn Granlund <tege@gmplib.org>
* tests/t-div.c: Test mpz_divisible_p and mpz_divisible_ui_p.
* tests/t-div.c: Test also mpz_mod, mpz_mod_ui. Compare
mpz_divisible_p just to ceil, to save time.
* mini-gmp.c: Prefix some names with GMP_.
2013-01-16 Marco Bodrato <bodrato@mail.dm.unipi.it>
* tests/t-double.c: Test mpz_cmp_d.
* mini-gmp.c (mpz_cmp_d): Correct multiword comparison.
* mini-gmp.c (mpz_set_str): Handle the empty string.
* tests/t-str.c: Test base <= 0.
2013-01-15 Niels Möller <nisse@lysator.liu.se>
* tests/t-str.c (main): Use x->_mp_d rather than x[0]._mp_d.
* tests/t-invert.c (main): Likewise.
* tests/t-mul.c (main): Test mpn_mul_n and mpn_sqr.
* tests/hex-random.h (enum hex_random_op): New value OP_SQR.
* tests/mini-random.c (mini_random_op3): Renamed, from...
(mini_random_op): ... old name. Updated callers.
(mini_random_op2): New function.
* tests/hex-random.c (hex_random_op3): Renamed, from...
(hex_random_op): ... old name. Updated callers.
(hex_random_op2): New function.
2013-01-15 Marco Bodrato <bodrato@mail.dm.unipi.it>
* tests/t-logops.c: Improve popcount/hamdist testing.
* tests/t-signed.c: Test more cases.
2013-01-14 Niels Möller <nisse@lysator.liu.se>
* tests/t-str.c (main): Added tests for mpn_get_str and
mpn_set_str.
2013-01-11 Marco Bodrato <bodrato@mail.dm.unipi.it>
* tests/t-comb.c: New test program, testing both
mpz_fac_ui and mpz_bin_uiui.
* tests/Makefile (CHECK_PROGRAMS): Added t-comb.
* mini-gmp.c (mpz_mul_si): Simplify.
(mpz_mul_ui, mpz_mul, mpz_div_qr): Replace init+REALLOC with init2.
* mini-gmp.c (NEG_CAST): New macro.
(mpz_mul_si, mpz_set_si, mpz_cmp_si): Use NEG_CAST.
* mini-gmp.c (mpz_set_si, mpz_cmp_si): Simplify by using
the _ui variant.
* tests/t-root.c: Use mpz_ui_pow_ui, when base fits an ui.
* tests/t-mul.c: Test also mpz_mul_si.
* tests/t-sub.c: Test also mpz_ui_sub.
* mini-gmp.c (mpz_fits_slong_p): Correct range.
* tests/t-signed.c: New test program, for get/set/cmp_si.
* tests/Makefile (CHECK_PROGRAMS): Added t-signed.
* mini-gmp.c (mpz_hamdist): Handle different sizes.
* tests/t-logops.c: Test also popcount and hamdist.
2013-01-10 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.c (mpz_export, mpz_import): Less restrictive ASSERTs.
* tests/t-import.c: Test also size=0 or count=0.
2013-01-10 Torbjorn Granlund <tege@gmplib.org>
* tests/t-import.c (main): Don't drop off function end.
2013-01-09 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.c (mpz_export): Support op=0 countp=NULL.
2013-01-08 Niels Möller <nisse@lysator.liu.se>
* tests/t-import.c: New test program, testing both
mpz_import and mpz_export.
* tests/Makefile (CHECK_PROGRAMS): Added t-import.
* tests/mini-random.c (mini_rrandomb_export): New function.
* tests/mini-random.h: Declare it.
* tests/hex-random.c (hex_rrandomb_export): New function.
* tests/hex-random.h: Declare it.
* mini-gmp.c (mpz_export): Compute accurate word count up
front, to avoid generating any high zero words.
2013-01-07 Marco Bodrato <bodrato@mail.dm.unipi.it>
* README: Document base limitation for conversions.
* mini-gmp.c (mpz_set_str): Remove goto.
(mpz_import, mpz_export): Correctly use order/endianness.
2013-01-04 Marco Bodrato <bodrato@mail.dm.unipi.it>
From shuax:
* mini-gmp.c (mpz_import): Reset limb after storing it.
2012-11-22 Niels Möller <nisse@lysator.liu.se>
* tests/run-tests: Copied latest version from GNU Nettle.
Minor fix to the use of $EMULATOR, and proper copyright notice.
2012-06-24 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.c (mpz_div_r_2exp, mpz_div_q_2exp): Improve
adjustment condition.
2012-06-08 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.c (mpz_realloc): remove a branch.
2012-05-25 Marco Bodrato <bodrato@mail.dm.unipi.it>
* tests/t-div.c: Test all _qr, _q, _r variants.
* tests/t-lcm.c: Test the _ui variant.
* mini-gmp.c (mpz_mod, mpz_mod_ui): New functions.
* mini-gmp.h (mpz_mod, mpz_mod_ui): Prototypes.
2012-05-09 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.c: merge mpz_rootrem and mpz_sqrtrem.
2012-04-13 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.h (mpz_fac_ui, mpz_bin_uiui): New definitions.
* mini-gmp.c (mpz_fac_ui, mpz_bin_uiui): Trivial implementation.
2012-04-11 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.h (mpz_root, mpz_rootrem): define (correctly).
* mini-gmp.c (mpz_rootrem): Extended code from _root.
(mpz_root): Use mpz_rootrem.
(mpz_mul_ui): Correctly handle negative operands.
* tests/Makefile (CHECK_PROGRAMS): add t-root.
* tests/t-root.c: New file.
* tests/t-reuse.c: Enable root{,rem} tests.
2012-04-10 Marco Bodrato <bodrato@mail.dm.unipi.it>
* mini-gmp.c (mpz_root): New, support negative operands.
* mini-gmp.h (mpz_root): define.
(mpz_out_str): Test also __STDIO_LOADED (for VMS).
* mpz/2fac_ui.c: Cosmetic change.
* tests/t-reuse.c: New test case, based on tests/mpz/reuse.c.
* mini-gmp.c (mpz_cdiv_r_ui): New function.
(mpz_fdiv_r_ui): New function.
(mpz_tdiv_r_ui): New function.
(mpz_powm_ui): New function.
(mpz_pow_ui): New function.
(mpz_ui_pow_ui): Use mpz_pow_ui.
(mpz_gcdext): Fixed input/output overlap, for the case of one
input being zero.
(mpz_sqrtrem): Fix for the case r NULL, U zero.
2012-02-28 Niels Möller <nisse@lysator.liu.se>
* tests/Makefile (srcdir, MINI_GMP_DIR): New make variables. These
can be overridden when using a separate build directory.
(EXTRA_CFLAGS): Renamed, was OPTFLAGS.
* mini-gmp.c (mpz_abs_add): Don't cache limb pointers
over MPZ_REALLOC, since that breaks in-place operation. Bug
spotted by Torbjörn.
(mpz_and, mpz_ior, mpz_xor): Likewise.
(mpz_cmp): Fixed comparison of negative numbers.
2012-02-26 Niels Möller <nisse@lysator.liu.se>
* mini-gmp: New subdirectory. For use by GMP bootstrap, and as a
fallback for applications needing bignums but not high
performance.

View File

@ -32,7 +32,7 @@ see https://www.gnu.org/licenses/. */
/* NOTE: All functions in this file which are not declared in /* NOTE: All functions in this file which are not declared in
mini-gmp.h are internal, and are not intended to be compatible mini-gmp.h are internal, and are not intended to be compatible
neither with GMP nor with future versions of mini-gmp. */ with GMP or with future versions of mini-gmp. */
/* Much of the material copied from GMP files, including: gmp-impl.h, /* Much of the material copied from GMP files, including: gmp-impl.h,
longlong.h, mpn/generic/add_n.c, mpn/generic/addmul_1.c, longlong.h, mpn/generic/add_n.c, mpn/generic/addmul_1.c,
@ -790,7 +790,7 @@ mpn_invert_3by2 (mp_limb_t u1, mp_limb_t u0)
qh' = floor( (b^3 - 1) / u) - b = floor ((b^3 - b u - 1) / u qh' = floor( (b^3 - 1) / u) - b = floor ((b^3 - b u - 1) / u
= floor( (b (~u) + b-1) / u), = floor( (b (~u) + b-1) / u),
and the remainder and the remainder
r = b (~u) + b-1 - qh (b uh + ul) r = b (~u) + b-1 - qh (b uh + ul)
@ -3418,7 +3418,7 @@ gmp_lucas_mod (mpz_t V, mpz_t Qk, long Q,
gmp_lucas_step_k_2k (V, Qk, n); gmp_lucas_step_k_2k (V, Qk, n);
/* A step k->k+1 is performed if the bit in $n$ is 1 */ /* A step k->k+1 is performed if the bit in $n$ is 1 */
/* mpz_tstbit(n,bs) or the the bit is 0 in $n$ but */ /* mpz_tstbit(n,bs) or the bit is 0 in $n$ but */
/* should be 1 in $n+1$ (bs == b0) */ /* should be 1 in $n+1$ (bs == b0) */
if (b0 == bs || mpz_tstbit (n, bs)) if (b0 == bs || mpz_tstbit (n, bs))
{ {
@ -4381,6 +4381,8 @@ mpz_out_str (FILE *stream, int base, const mpz_t x)
size_t len; size_t len;
str = mpz_get_str (NULL, base, x); str = mpz_get_str (NULL, base, x);
if (!str)
return 0;
len = strlen (str); len = strlen (str);
len = fwrite (str, 1, len, stream); len = fwrite (str, 1, len, stream);
gmp_free (str); gmp_free (str);
@ -4488,7 +4490,7 @@ mpz_export (void *r, size_t *countp, int order, size_t size, int endian,
ptrdiff_t word_step; ptrdiff_t word_step;
/* The current (partial) limb. */ /* The current (partial) limb. */
mp_limb_t limb; mp_limb_t limb;
/* The number of bytes left to to in this limb. */ /* The number of bytes left to do in this limb. */
size_t bytes; size_t bytes;
/* The index where the limb was read. */ /* The index where the limb was read. */
mp_size_t i; mp_size_t i;

View File

@ -1,6 +1,6 @@
/* mini-gmp, a minimalistic implementation of a GNU GMP subset. /* mini-gmp, a minimalistic implementation of a GNU GMP subset.
Copyright 2011-2015, 2017, 2019 Free Software Foundation, Inc. Copyright 2011-2015, 2017, 2019-2020 Free Software Foundation, Inc.
This file is part of the GNU MP Library. This file is part of the GNU MP Library.
@ -291,7 +291,8 @@ int mpz_init_set_str (mpz_t, const char *, int);
|| defined (_MSL_STDIO_H) /* Metrowerks */ \ || defined (_MSL_STDIO_H) /* Metrowerks */ \
|| defined (_STDIO_H_INCLUDED) /* QNX4 */ \ || defined (_STDIO_H_INCLUDED) /* QNX4 */ \
|| defined (_ISO_STDIO_ISO_H) /* Sun C++ */ \ || defined (_ISO_STDIO_ISO_H) /* Sun C++ */ \
|| defined (__STDIO_LOADED) /* VMS */ || defined (__STDIO_LOADED) /* VMS */ \
|| defined (__DEFINED_FILE) /* musl */
size_t mpz_out_str (FILE *, int, const mpz_t); size_t mpz_out_str (FILE *, int, const mpz_t);
#endif #endif

View File

@ -5,7 +5,7 @@
Acknowledgment: special thanks to Bradley Lucier for his comments Acknowledgment: special thanks to Bradley Lucier for his comments
to the preliminary version of this code. to the preliminary version of this code.
Copyright 2018, 2019 Free Software Foundation, Inc. Copyright 2018-2020 Free Software Foundation, Inc.
This file is part of the GNU MP Library. This file is part of the GNU MP Library.
@ -107,10 +107,10 @@ mpq_clear (mpq_t x)
static void static void
mpq_canonical_sign (mpq_t r) mpq_canonical_sign (mpq_t r)
{ {
int cmp = mpq_denref (r)->_mp_size; mp_size_t ds = mpq_denref (r)->_mp_size;
if (cmp <= 0) if (ds <= 0)
{ {
if (cmp == 0) if (ds == 0)
gmp_die("mpq: Fraction with zero denominator."); gmp_die("mpq: Fraction with zero denominator.");
mpz_neg (mpq_denref (r), mpq_denref (r)); mpz_neg (mpq_denref (r), mpq_denref (r));
mpz_neg (mpq_numref (r), mpq_numref (r)); mpz_neg (mpq_numref (r), mpq_numref (r));
@ -515,6 +515,8 @@ mpq_out_str (FILE *stream, int base, const mpq_t x)
void (*gmp_free_func) (void *, size_t); void (*gmp_free_func) (void *, size_t);
str = mpq_get_str (NULL, base, x); str = mpq_get_str (NULL, base, x);
if (!str)
return 0;
len = strlen (str); len = strlen (str);
len = fwrite (str, 1, len, stream); len = fwrite (str, 1, len, stream);
mp_get_memory_functions (NULL, NULL, &gmp_free_func); mp_get_memory_functions (NULL, NULL, &gmp_free_func);

View File

@ -26,7 +26,7 @@ enum hex_random_op
OP_TDIV_Q_2, OP_TDIV_R_2, OP_TDIV_Q_2, OP_TDIV_R_2,
OP_GCD, OP_LCM, OP_POWM, OP_AND, OP_IOR, OP_XOR, OP_GCD, OP_LCM, OP_POWM, OP_AND, OP_IOR, OP_XOR,
OP_SETBIT, OP_CLRBIT, OP_COMBIT, OP_SETBIT, OP_CLRBIT, OP_COMBIT,
OP_SCAN0, OP_SCAN1, OP_SCAN0, OP_SCAN1
}; };
void hex_random_init (void); void hex_random_init (void);

View File

@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
# Copyright (C) 2000-2002, 2004, 2005, 2011, 2012, 2016 Niels Möller # Copyright (C) 2000-2002, 2004, 2005, 2011, 2012, 2016, 2020 Niels Möller
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -28,6 +28,22 @@ fi
export srcdir export srcdir
if [ -n "$TEST_SHLIB_DIR" ] ; then
# Prepend to LD_LIBRARY_PATH, if it is alredy set.
LD_LIBRARY_PATH="${TEST_SHLIB_DIR}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
# For MACOS
DYLD_LIBRARY_PATH="$TEST_SHLIB_DIR"
# For Windows
PATH="${TEST_SHLIB_DIR}:${PATH}"
# For Wine
WINEPATH="${TEST_SHLIB_DIR}${WINEPATH:+;$WINEPATH}"
export LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH
export PATH
export WINEPATH
fi
# When used in make rules, we sometimes get the filenames VPATH # When used in make rules, we sometimes get the filenames VPATH
# expanded, but usually not. # expanded, but usually not.
find_program () { find_program () {
@ -38,6 +54,8 @@ find_program () {
*) *)
if [ -x "$1" ] ; then if [ -x "$1" ] ; then
echo "./$1" echo "./$1"
elif [ -x "$1.exe" ] ; then
echo "./$1.exe"
else else
echo "$srcdir/$1" echo "$srcdir/$1"
fi fi
@ -54,20 +72,10 @@ env_program () {
fi fi
} }
TEST_LD_LIBRARY_PATH="$LD_LIBRARY_PATH"
TEST_DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH"
if [ "$TEST_LIBRARY_PATH" ] ; then
TEST_LD_LIBRARY_PATH="$TEST_LIBRARY_PATH:$TEST_LD_LIBRARY_PATH"
TEST_DYLD_LIBRARY_PATH="$TEST_LIBRARY_PATH:$TEST_DYLD_LIBRARY_PATH"
fi
test_program () { test_program () {
testname=`basename "$1" .exe` testname=`basename "$1" .exe`
testname=`basename "$testname" -test` testname=`basename "$testname" -test`
if [ -z "$EMULATOR" ] || head -1 "$1" | grep '^#!' > /dev/null; then if [ -z "$EMULATOR" ] || head -1 "$1" | grep '^#!' > /dev/null; then
LD_LIBRARY_PATH="$TEST_LD_LIBRARY_PATH" \
DYLD_LIBRARY_PATH="$TEST_DYLD_LIBRARY_PATH" \
"$1" $testflags "$1" $testflags
else else
$EMULATOR "$1" $testflags $EMULATOR "$1" $testflags

View File

@ -1,6 +1,6 @@
/* /*
Copyright 2012, 2013, 2018 Free Software Foundation, Inc. Copyright 2012, 2013, 2018, 2020 Free Software Foundation, Inc.
This file is part of the GNU MP Library test suite. This file is part of the GNU MP Library test suite.
@ -118,6 +118,10 @@ test_matissa (void)
mpz_clear (y); mpz_clear (y);
} }
#ifndef M_PI
#define M_PI 3.141592653589793238462643383279502884
#endif
static const struct static const struct
{ {
double d; double d;

View File

@ -58,13 +58,7 @@ mpz_get_d_exact_p (const mpz_t z)
int int
mpq_get_d_exact_p (const mpq_t q) mpq_get_d_exact_p (const mpq_t q)
{ {
/* return mpq_mantissasizeinbits (q) <= DBL_MANT_DIG; */ return mpq_mantissasizeinbits (q) <= DBL_MANT_DIG;
return
(mpz_sizeinbase (mpq_denref (q), 2) -
mpz_scan1 (mpq_denref (q), 0) == 1) &&
(mpz_sizeinbase (mpq_numref (q), 2) -
mpz_scan1 (mpq_numref (q), 0) <= DBL_MANT_DIG);
/* mpz_sizeinbase (zero, 2) - mpz_scan1 (zero, 0) == 2 */
} }
#define HAVE_EXACT_P 1 #define HAVE_EXACT_P 1
#endif #endif
@ -128,6 +122,9 @@ check_random (void)
d = ldexp ((double) m, e); d = ldexp ((double) m, e);
mpq_set_d (y, d); mpq_set_d (y, d);
if (i == 0)
mpq_neg (z, y);
mpq_add (y, y, z); mpq_add (y, y, z);
mpq_set_d (z, mpq_get_d (y)); mpq_set_d (z, mpq_get_d (y));
f = mpq_get_d (z); f = mpq_get_d (z);

View File

@ -100,7 +100,7 @@ testmain (int argc, char **argv)
|| mpz_sizeinbase (t, 2) - 1 != e || mpz_cmp_ui (mpq_denref (aq), 1) != 0) || mpz_sizeinbase (t, 2) - 1 != e || mpz_cmp_ui (mpq_denref (aq), 1) != 0)
{ {
fprintf (stderr, "mpq_div_2exp failed: %lu\n", e); fprintf (stderr, "mpq_div_2exp failed: %lu\n", e);
fprintf (stderr, "%li %li %lu %zu\n", e2, t2, mpz_scan1 (t, 0), mpz_sizeinbase (t, 2)); fprintf (stderr, "%li %li %lu %lu\n", e2, t2, mpz_scan1 (t, 0), (unsigned long) mpz_sizeinbase (t, 2));
dump ("na", a); dump ("na", a);
dump ("da", b); dump ("da", b);
dump ("nr", mpq_numref (rq)); dump ("nr", mpq_numref (rq));

View File

@ -1,6 +1,6 @@
/* /*
Copyright 2012-2014, 2016, 2018 Free Software Foundation, Inc. Copyright 2012-2014, 2016, 2018, 2020 Free Software Foundation, Inc.
This file is part of the GNU MP Library test suite. This file is part of the GNU MP Library test suite.
@ -160,6 +160,18 @@ testmain (int argc, char **argv)
fprintf (stderr, fprintf (stderr,
"Failed to create temporary file. Skipping mpq_out_str tests.\n"); "Failed to create temporary file. Skipping mpq_out_str tests.\n");
if (mpq_out_str (tmp, 63, a) != 0)
{
printf ("mpq_out_str did not return 0 (error) with base > 62\n");
abort ();
}
if (mpq_out_str (tmp, -37, a) != 0)
{
printf ("mpq_out_str did not return 0 (error) with base < -37\n");
abort ();
}
for (i = 0; i < COUNT/60; i++) for (i = 0; i < COUNT/60; i++)
{ {
int base; int base;

View File

@ -1,6 +1,6 @@
/* /*
Copyright 2012-2014, 2016 Free Software Foundation, Inc. Copyright 2012-2014, 2016, 2020 Free Software Foundation, Inc.
This file is part of the GNU MP Library test suite. This file is part of the GNU MP Library test suite.
@ -156,6 +156,18 @@ testmain (int argc, char **argv)
fprintf (stderr, fprintf (stderr,
"Failed to create temporary file. Skipping mpz_out_str tests.\n"); "Failed to create temporary file. Skipping mpz_out_str tests.\n");
if (mpz_out_str (tmp, 63, a) != 0)
{
printf ("mpz_out_str did not return 0 (error) with base > 62\n");
abort ();
}
if (mpz_out_str (tmp, -37, a) != 0)
{
printf ("mpz_out_str did not return 0 (error) with base < -37\n");
abort ();
}
for (i = 0; i < COUNT; i++) for (i = 0; i < COUNT; i++)
{ {
int base; int base;

View File

@ -0,0 +1,53 @@
divert(-1)
dnl m4 macros for ARM64 ELF assembler.
dnl Copyright 2020 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
dnl Standard commenting is with @, the default m4 # is for constants and we
dnl don't want to disable macro expansions in or after them.
changecom
dnl LEA_HI(reg,gmp_symbol), LEA_LO(reg,gmp_symbol)
dnl
dnl Load the address of gmp_symbol into a register. We split this into two
dnl parts to allow separation for manual insn scheduling.
ifdef(`PIC',`dnl
define(`LEA_HI', `adrp $1, :got:$2')dnl
define(`LEA_LO', `ldr $1, [$1, #:got_lo12:$2]')dnl
',`dnl
define(`LEA_HI', `adrp $1, $2')dnl
define(`LEA_LO', `add $1, $1, :lo12:$2')dnl
')dnl
divert`'dnl

View File

@ -61,15 +61,9 @@ PROLOGUE(mpn_bdiv_q_1)
clz cnt, x6 clz cnt, x6
lsr d, d, cnt lsr d, d, cnt
ifdef(`PIC',` LEA_HI( x7, binvert_limb_table)
adrp x7, :got:__gmp_binvert_limb_table
ubfx x6, d, 1, 7 ubfx x6, d, 1, 7
ldr x7, [x7, #:got_lo12:__gmp_binvert_limb_table] LEA_LO( x7, binvert_limb_table)
',`
adrp x7, __gmp_binvert_limb_table
ubfx x6, d, 1, 7
add x7, x7, :lo12:__gmp_binvert_limb_table
')
ldrb w6, [x7, x6] ldrb w6, [x7, x6]
ubfiz x7, x6, 1, 8 ubfiz x7, x6, 1, 8
umull x6, w6, w6 umull x6, w6, w6
@ -81,7 +75,7 @@ ifdef(`PIC',`
mul x6, x6, x6 mul x6, x6, x6
msub di, x6, d, x7 msub di, x6, d, x7
b mpn_pi1_bdiv_q_1 b GSYM_PREFIX`'mpn_pi1_bdiv_q_1
EPILOGUE() EPILOGUE()
PROLOGUE(mpn_pi1_bdiv_q_1) PROLOGUE(mpn_pi1_bdiv_q_1)

View File

@ -0,0 +1,50 @@
divert(-1)
dnl m4 macros for ARM64 Darwin assembler.
dnl Copyright 2020 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
dnl Standard commenting is with @, the default m4 # is for constants and we
dnl don't want to disable macro expansions in or after them.
changecom
dnl LEA_HI(reg,gmp_symbol), LEA_LO(reg,gmp_symbol)
dnl
dnl Load the address of gmp_symbol into a register. We split this into two
dnl parts to allow separation for manual insn scheduling. TODO: Darwin allows
dnl for relaxing these two insns into an adr and a nop, but that requires the
dnl .loh pseudo for connecting them.
define(`LEA_HI',`adrp $1, $2@GOTPAGE')dnl
define(`LEA_LO',`ldr $1, [$1, $2@GOTPAGEOFF]')dnl
divert`'dnl

View File

@ -41,9 +41,9 @@ C Compiler generated, mildly edited. Could surely be further optimised.
ASM_START() ASM_START()
PROLOGUE(mpn_invert_limb) PROLOGUE(mpn_invert_limb)
lsr x2, x0, #54 lsr x2, x0, #54
adrp x1, approx_tab LEA_HI( x1, approx_tab)
and x2, x2, #0x1fe and x2, x2, #0x1fe
add x1, x1, :lo12:approx_tab LEA_LO( x1, approx_tab)
ldrh w3, [x1,x2] ldrh w3, [x1,x2]
lsr x4, x0, #24 lsr x4, x0, #24
add x4, x4, #1 add x4, x4, #1

View File

@ -3,19 +3,30 @@ dnl ARM64 mpn_lshift.
dnl Copyright 2013, 2014, 2017 Free Software Foundation, Inc. dnl Copyright 2013, 2014, 2017 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library. dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU Lesser General Public License as published dnl it under the terms of either:
dnl by the Free Software Foundation; either version 3 of the License, or (at dnl
dnl your option) any later version. dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl License for more details. dnl for more details.
dnl
dnl You should have received a copy of the GNU Lesser General Public License dnl You should have received copies of the GNU General Public License and the
dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4') include(`../config.m4')

View File

@ -3,19 +3,30 @@ dnl ARM64 mpn_lshiftc.
dnl Copyright 2013, 2014, 2017 Free Software Foundation, Inc. dnl Copyright 2013, 2014, 2017 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library. dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU Lesser General Public License as published dnl it under the terms of either:
dnl by the Free Software Foundation; either version 3 of the License, or (at dnl
dnl your option) any later version. dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl License for more details. dnl for more details.
dnl
dnl You should have received a copy of the GNU Lesser General Public License dnl You should have received copies of the GNU General Public License and the
dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4') include(`../config.m4')

View File

@ -3,19 +3,30 @@ dnl ARM64 mpn_rshift.
dnl Copyright 2013, 2014, 2017 Free Software Foundation, Inc. dnl Copyright 2013, 2014, 2017 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library. dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU Lesser General Public License as published dnl it under the terms of either:
dnl by the Free Software Foundation; either version 3 of the License, or (at dnl
dnl your option) any later version. dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl License for more details. dnl for more details.
dnl
dnl You should have received a copy of the GNU Lesser General Public License dnl You should have received copies of the GNU General Public License and the
dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4') include(`../config.m4')

View File

@ -70,6 +70,8 @@ mpn_compute_powtab_mul (powers_t *powtab, mp_ptr powtab_mem, mp_size_t un,
mp_limb_t cy; mp_limb_t cy;
long start_idx; long start_idx;
int c; int c;
mp_size_t shift;
long pi;
mp_limb_t big_base = mp_bases[base].big_base; mp_limb_t big_base = mp_bases[base].big_base;
int chars_per_limb = mp_bases[base].chars_per_limb; int chars_per_limb = mp_bases[base].chars_per_limb;
@ -97,7 +99,7 @@ mpn_compute_powtab_mul (powers_t *powtab, mp_ptr powtab_mem, mp_size_t un,
c = t[0] == 0; c = t[0] == 0;
t += c; t += c;
n -= c; n -= c;
mp_size_t shift = c; shift = c;
SET_powers_t (pt[0], t, n, digits_in_base, base, shift); SET_powers_t (pt[0], t, n, digits_in_base, base, shift);
p = t; p = t;
@ -139,7 +141,7 @@ mpn_compute_powtab_mul (powers_t *powtab, mp_ptr powtab_mem, mp_size_t un,
start_idx = n_pows - 3; start_idx = n_pows - 3;
} }
for (long pi = start_idx; pi >= 0; pi--) for (pi = start_idx; pi >= 0; pi--)
{ {
t = powtab_mem_ptr; t = powtab_mem_ptr;
powtab_mem_ptr += 2 * n + 2; powtab_mem_ptr += 2 * n + 2;
@ -214,6 +216,10 @@ mpn_compute_powtab_div (powers_t *powtab, mp_ptr powtab_mem, mp_size_t un,
powers_t *pt = powtab; powers_t *pt = powtab;
mp_size_t n = 1;
mp_size_t shift = 0;
long pi;
p = powtab_mem_ptr; p = powtab_mem_ptr;
powtab_mem_ptr += 1; powtab_mem_ptr += 1;
p[0] = big_base; p[0] = big_base;
@ -221,9 +227,7 @@ mpn_compute_powtab_div (powers_t *powtab, mp_ptr powtab_mem, mp_size_t un,
SET_powers_t (pt[0], p, 1, digits_in_base, base, 0); SET_powers_t (pt[0], p, 1, digits_in_base, base, 0);
pt++; pt++;
mp_size_t n = 1; for (pi = n_pows - 1; pi >= 0; pi--)
mp_size_t shift = 0;
for (long pi = n_pows - 1; pi >= 0; pi--)
{ {
t = powtab_mem_ptr; t = powtab_mem_ptr;
powtab_mem_ptr += 2 * n; powtab_mem_ptr += 2 * n;
@ -271,7 +275,7 @@ mpn_compute_powtab_div (powers_t *powtab, mp_ptr powtab_mem, mp_size_t un,
/* Strip any remaining low zero limbs. */ /* Strip any remaining low zero limbs. */
pt -= n_pows + 1; pt -= n_pows + 1;
for (long pi = n_pows; pi >= 0; pi--) for (pi = n_pows; pi >= 0; pi--)
{ {
mp_ptr t = pt[pi].p; mp_ptr t = pt[pi].p;
mp_size_t shift = pt[pi].shift; mp_size_t shift = pt[pi].shift;
@ -293,7 +297,8 @@ powtab_decide (size_t *exptab, size_t un, int base)
{ {
int chars_per_limb = mp_bases[base].chars_per_limb; int chars_per_limb = mp_bases[base].chars_per_limb;
long n_pows = 0; long n_pows = 0;
for (size_t pn = (un + 1) >> 1; pn != 1; pn = (pn + 1) >> 1) size_t pn;
for (pn = (un + 1) >> 1; pn != 1; pn = (pn + 1) >> 1)
{ {
exptab[n_pows] = pn * chars_per_limb; exptab[n_pows] = pn * chars_per_limb;
n_pows++; n_pows++;
@ -301,11 +306,13 @@ powtab_decide (size_t *exptab, size_t un, int base)
exptab[n_pows] = chars_per_limb; exptab[n_pows] = chars_per_limb;
#if HAVE_mpn_compute_powtab_mul && HAVE_mpn_compute_powtab_div #if HAVE_mpn_compute_powtab_mul && HAVE_mpn_compute_powtab_div
{
size_t pn = un - 1; size_t pn = un - 1;
size_t xn = (un + 1) >> 1; size_t xn = (un + 1) >> 1;
unsigned mcost = 1; unsigned mcost = 1;
unsigned dcost = 1; unsigned dcost = 1;
for (long i = n_pows - 2; i >= 0; i--) long i;
for (i = n_pows - 2; i >= 0; i--)
{ {
size_t pow = (pn >> (i + 1)) + 1; size_t pow = (pn >> (i + 1)) + 1;
@ -332,6 +339,7 @@ powtab_decide (size_t *exptab, size_t un, int base)
return n_pows; return n_pows;
else else
return -n_pows; return -n_pows;
}
#elif HAVE_mpn_compute_powtab_mul #elif HAVE_mpn_compute_powtab_mul
return n_pows; return n_pows;
#elif HAVE_mpn_compute_powtab_div #elif HAVE_mpn_compute_powtab_div

View File

@ -37,13 +37,14 @@ see https://www.gnu.org/licenses/. */
#include "gmp-impl.h" #include "gmp-impl.h"
#if 0 /* unused, so leave out for now */
static mp_size_t static mp_size_t
mpn_dcpi1_bdiv_q_n_itch (mp_size_t n) mpn_dcpi1_bdiv_q_n_itch (mp_size_t n)
{ {
/* NOTE: Depends on mullo_n and mpn_dcpi1_bdiv_qr_n interface */ /* NOTE: Depends on mullo_n and mpn_dcpi1_bdiv_qr_n interface */
return n; return n;
} }
#endif
/* Computes Q = - N / D mod B^n, destroys N. /* Computes Q = - N / D mod B^n, destroys N.

View File

@ -56,13 +56,13 @@ mpn_gcd_22 (mp_limb_t u1, mp_limb_t u0, mp_limb_t v1, mp_limb_t v0)
if (UNLIKELY (t0 == 0)) if (UNLIKELY (t0 == 0))
{ {
int c;
if (t1 == 0) if (t1 == 0)
{ {
g.d1 = (u1 << 1) | (u0 >> (GMP_LIMB_BITS - 1)); g.d1 = (u1 << 1) | (u0 >> (GMP_LIMB_BITS - 1));
g.d0 = (u0 << 1) | 1; g.d0 = (u0 << 1) | 1;
return g; return g;
} }
int c;
count_trailing_zeros (c, t1); count_trailing_zeros (c, t1);
/* v1 = min (u1, v1) */ /* v1 = min (u1, v1) */

View File

@ -226,7 +226,7 @@ mpn_get_d (mp_srcptr up, mp_size_t size, mp_size_t sign, long exp)
x <<= GMP_NAIL_BITS; x <<= GMP_NAIL_BITS;
mhi |= x >> nbits >> 11; mhi |= x >> nbits >> 11;
mlo = x << GMP_LIMB_BITS - nbits - 11; mlo = x << (GMP_LIMB_BITS - nbits - 11);
nbits = nbits + 11 - GMP_NAIL_BITS; nbits = nbits + 11 - GMP_NAIL_BITS;
} }
else else

View File

@ -369,6 +369,8 @@ mpn_get_str (unsigned char *str, int base, mp_ptr up, mp_size_t un)
int pi; int pi;
size_t out_len; size_t out_len;
mp_ptr tmp; mp_ptr tmp;
size_t ndig;
mp_size_t xn;
TMP_DECL; TMP_DECL;
/* Special case zero, as the code below doesn't handle it. */ /* Special case zero, as the code below doesn't handle it. */
@ -435,8 +437,6 @@ mpn_get_str (unsigned char *str, int base, mp_ptr up, mp_size_t un)
powtab_mem = TMP_BALLOC_LIMBS (mpn_str_powtab_alloc (un)); powtab_mem = TMP_BALLOC_LIMBS (mpn_str_powtab_alloc (un));
/* Compute a table of powers, were the largest power is >= sqrt(U). */ /* Compute a table of powers, were the largest power is >= sqrt(U). */
size_t ndig;
mp_size_t xn;
DIGITS_IN_BASE_PER_LIMB (ndig, un, base); DIGITS_IN_BASE_PER_LIMB (ndig, un, base);
xn = 1 + ndig / mp_bases[base].chars_per_limb; /* FIXME: scalar integer division */ xn = 1 + ndig / mp_bases[base].chars_per_limb; /* FIXME: scalar integer division */

View File

@ -256,7 +256,15 @@ static const unsigned char tab[2048] = {
#error No table for provided NBITS #error No table for provided NBITS
#endif #endif
static const unsigned char *tabp = tab - (1 << (NBITS - 1) << NBITS); /* Doing tabp with a #define makes compiler warnings about pointing outside an
object go away. We used to define this as a variable. It is not clear if
e.g. (vector[100] - 10) + 10 is well- defined as per the C standard;
(vector[100] + 10) - 10 surely is and there is no sequence point so the
expressions should be equivalent. To make this safe, we might want to
define tabp as a macro with the index as an argument. Depending on the
platform, relocs might allow for assembly-time or linker-time resolution to
take place. */
#define tabp (tab - (1 << (NBITS - 1) << NBITS))
static inline mp_double_limb_t static inline mp_double_limb_t
div1 (mp_limb_t n0, mp_limb_t d0) div1 (mp_limb_t n0, mp_limb_t d0)
@ -314,14 +322,12 @@ div1 (mp_limb_t n0, mp_limb_t d0)
static const unsigned char tab[16] = { static const unsigned char tab[16] = {
63, 59, 55, 52, 50, 47, 45, 43, 41, 39, 38, 36, 35, 34, 33, 32 63, 59, 55, 52, 50, 47, 45, 43, 41, 39, 38, 36, 35, 34, 33, 32
}; };
static const unsigned char *tabp = tab - (1 << (NBITS - 1));
#elif NBITS == 6 #elif NBITS == 6
/* This needs full division about 0.93% of the time. */ /* This needs full division about 0.93% of the time. */
static const unsigned char tab[32] = { static const unsigned char tab[32] = {
127,123,119,116,112,109,106,104,101, 98, 96, 94, 92, 90, 88, 86, 127,123,119,116,112,109,106,104,101, 98, 96, 94, 92, 90, 88, 86,
84, 82, 80, 79, 77, 76, 74, 73, 72, 70, 69, 68, 67, 66, 65, 64 84, 82, 80, 79, 77, 76, 74, 73, 72, 70, 69, 68, 67, 66, 65, 64
}; };
static const unsigned char *tabp = tab - (1 << (NBITS - 1));
#elif NBITS == 7 #elif NBITS == 7
/* This needs full division about 0.49% of the time. */ /* This needs full division about 0.49% of the time. */
static const unsigned char tab[64] = { static const unsigned char tab[64] = {
@ -330,7 +336,6 @@ static const unsigned char tab[64] = {
169,167,166,164,162,161,159,158,156,155,153,152,150,149,147,146, 169,167,166,164,162,161,159,158,156,155,153,152,150,149,147,146,
145,143,142,141,140,139,137,136,135,134,133,132,131,130,129,128 145,143,142,141,140,139,137,136,135,134,133,132,131,130,129,128
}; };
static const unsigned char *tabp = tab - (1 << (NBITS - 1));
#elif NBITS == 8 #elif NBITS == 8
/* This needs full division about 0.26% of the time. */ /* This needs full division about 0.26% of the time. */
static const unsigned short tab[128] = { static const unsigned short tab[128] = {
@ -343,11 +348,20 @@ static const unsigned short tab[128] = {
291,290,288,287,286,285,283,282,281,280,279,277,276,275,274,273, 291,290,288,287,286,285,283,282,281,280,279,277,276,275,274,273,
272,270,269,268,267,266,265,264,263,262,261,260,259,258,257,256 272,270,269,268,267,266,265,264,263,262,261,260,259,258,257,256
}; };
static const unsigned short *tabp = tab - (1 << (NBITS - 1));
#else #else
#error No table for provided NBITS #error No table for provided NBITS
#endif #endif
/* Doing tabp with a #define makes compiler warnings about pointing outside an
object go away. We used to define this as a variable. It is not clear if
e.g. (vector[100] - 10) + 10 is well- defined as per the C standard;
(vector[100] + 10) - 10 surely is and there is no sequence point so the
expressions should be equivalent. To make this safe, we might want to
define tabp as a macro with the index as an argument. Depending on the
platform, relocs might allow for assembly-time or linker-time resolution to
take place. */
#define tabp (tab - (1 << (NBITS - 1)))
static inline mp_double_limb_t static inline mp_double_limb_t
div1 (mp_limb_t n0, mp_limb_t d0) div1 (mp_limb_t n0, mp_limb_t d0)
{ {

View File

@ -256,7 +256,7 @@ mpn_mod_1_1p_cps (mp_limb_t cps[4], mp_limb_t b)
cps[2] = B1modb >> cnt; cps[2] = B1modb >> cnt;
} }
B2modb = - b * bi; B2modb = - b * bi;
ASSERT (B2modb <= b); // NB: equality iff b = B/2 ASSERT (B2modb <= b); /* NB: equality iff b = B/2 */
cps[3] = B2modb; cps[3] = B2modb;
} }

View File

@ -6,7 +6,7 @@
SAFE TO REACH THEM THROUGH DOCUMENTED INTERFACES. IN FACT, IT IS ALMOST SAFE TO REACH THEM THROUGH DOCUMENTED INTERFACES. IN FACT, IT IS ALMOST
GUARANTEED THAT THEY WILL CHANGE OR DISAPPEAR IN A FUTURE GNU MP RELEASE. GUARANTEED THAT THEY WILL CHANGE OR DISAPPEAR IN A FUTURE GNU MP RELEASE.
Copyright 1998-2010, 2012, 2013, 2018 Free Software Foundation, Inc. Copyright 1998-2010, 2012, 2013, 2018, 2020 Free Software Foundation, Inc.
This file is part of the GNU MP Library. This file is part of the GNU MP Library.
@ -553,9 +553,12 @@ mpn_fft_mul_modF_K (mp_ptr *ap, mp_ptr *bp, mp_size_t n, mp_size_t K)
cc += mpn_add_n (tpn, tpn, a, n) + a[n]; cc += mpn_add_n (tpn, tpn, a, n) + a[n];
if (cc != 0) if (cc != 0)
{ {
/* FIXME: use MPN_INCR_U here, since carry is not expected. */
cc = mpn_add_1 (tp, tp, n2, cc); cc = mpn_add_1 (tp, tp, n2, cc);
ASSERT (cc == 0); /* If mpn_add_1 give a carry (cc != 0),
the result (tp) is at most GMP_NUMB_MAX - 1,
so the following addition can't overflow.
*/
tp[0] += cc;
} }
a[n] = mpn_sub_n (a, tp, tpn, n) && mpn_add_1 (a, a, n, CNST_LIMB(1)); a[n] = mpn_sub_n (a, tp, tpn, n) && mpn_add_1 (a, a, n, CNST_LIMB(1));
} }

View File

@ -109,6 +109,8 @@ mpn_set_str (mp_ptr rp, const unsigned char *str, size_t str_len, int base)
mp_ptr powtab_mem, tp; mp_ptr powtab_mem, tp;
powers_t powtab[GMP_LIMB_BITS]; powers_t powtab[GMP_LIMB_BITS];
int chars_per_limb; int chars_per_limb;
powers_t *pt;
size_t n_pows;
mp_size_t size; mp_size_t size;
mp_size_t un; mp_size_t un;
TMP_DECL; TMP_DECL;
@ -122,8 +124,8 @@ mpn_set_str (mp_ptr rp, const unsigned char *str, size_t str_len, int base)
/* Allocate one large block for the powers of big_base. */ /* Allocate one large block for the powers of big_base. */
powtab_mem = TMP_BALLOC_LIMBS (mpn_str_powtab_alloc (un)); powtab_mem = TMP_BALLOC_LIMBS (mpn_str_powtab_alloc (un));
size_t n_pows = mpn_compute_powtab (powtab, powtab_mem, un, base); n_pows = mpn_compute_powtab (powtab, powtab_mem, un, base);
powers_t *pt = powtab + n_pows; pt = powtab + n_pows;
tp = TMP_BALLOC_LIMBS (mpn_dc_set_str_itch (un)); tp = TMP_BALLOC_LIMBS (mpn_dc_set_str_itch (un));
size = mpn_dc_set_str (rp, str, str_len, pt, tp); size = mpn_dc_set_str (rp, str, str_len, pt, tp);

View File

@ -37,6 +37,9 @@ see https://www.gnu.org/licenses/. */
#include <stdio.h> #include <stdio.h>
#include "gmp-impl.h" #include "gmp-impl.h"
#if HAVE_NATIVE_mpn_rsblsh1_n || HAVE_NATIVE_mpn_sublsh1_n
#else
/* Stores |{ap,n}-{bp,n}| in {rp,n}, /* Stores |{ap,n}-{bp,n}| in {rp,n},
returns the sign of {ap,n}-{bp,n}. */ returns the sign of {ap,n}-{bp,n}. */
static int static int
@ -65,6 +68,7 @@ abs_sub_n (mp_ptr rp, mp_srcptr ap, mp_srcptr bp, mp_size_t n)
} }
return 0; return 0;
} }
#endif
/* Computes at most count terms of the sequence needed by the /* Computes at most count terms of the sequence needed by the
Lucas-Lehmer-Riesel test, indexing backward: Lucas-Lehmer-Riesel test, indexing backward:

View File

@ -6,7 +6,7 @@
SAFE TO REACH IT THROUGH DOCUMENTED INTERFACES. IN FACT, IT IS ALMOST SAFE TO REACH IT THROUGH DOCUMENTED INTERFACES. IN FACT, IT IS ALMOST
GUARANTEED THAT IT WILL CHANGE OR DISAPPEAR IN A FUTURE GNU MP RELEASE. GUARANTEED THAT IT WILL CHANGE OR DISAPPEAR IN A FUTURE GNU MP RELEASE.
Copyright 2009, 2010, 2012, 2015 Free Software Foundation, Inc. Copyright 2009, 2010, 2012, 2015, 2020 Free Software Foundation, Inc.
This file is part of the GNU MP Library. This file is part of the GNU MP Library.
@ -38,6 +38,34 @@ see https://www.gnu.org/licenses/. */
#include "gmp-impl.h" #include "gmp-impl.h"
#if GMP_NUMB_BITS < 21
#error Not implemented: Both sublsh_n(,,,20) should be corrected.
#endif
#if GMP_NUMB_BITS < 16
#error Not implemented: divexact_by42525 needs splitting.
#endif
#if GMP_NUMB_BITS < 12
#error Not implemented: Hard to adapt...
#endif
/* FIXME: tuneup should decide the best variant */
#ifndef AORSMUL_FASTER_AORS_AORSLSH
#define AORSMUL_FASTER_AORS_AORSLSH 1
#endif
#ifndef AORSMUL_FASTER_AORS_2AORSLSH
#define AORSMUL_FASTER_AORS_2AORSLSH 1
#endif
#ifndef AORSMUL_FASTER_2AORSLSH
#define AORSMUL_FASTER_2AORSLSH 1
#endif
#ifndef AORSMUL_FASTER_3AORSLSH
#define AORSMUL_FASTER_3AORSLSH 1
#endif
#if HAVE_NATIVE_mpn_sublsh_n #if HAVE_NATIVE_mpn_sublsh_n
#define DO_mpn_sublsh_n(dst,src,n,s,ws) mpn_sublsh_n(dst,dst,src,n,s) #define DO_mpn_sublsh_n(dst,src,n,s,ws) mpn_sublsh_n(dst,dst,src,n,s)
#else #else
@ -57,6 +85,7 @@ DO_mpn_sublsh_n(mp_ptr dst, mp_srcptr src, mp_size_t n, unsigned int s, mp_ptr w
#if HAVE_NATIVE_mpn_addlsh_n #if HAVE_NATIVE_mpn_addlsh_n
#define DO_mpn_addlsh_n(dst,src,n,s,ws) mpn_addlsh_n(dst,dst,src,n,s) #define DO_mpn_addlsh_n(dst,src,n,s,ws) mpn_addlsh_n(dst,dst,src,n,s)
#else #else
#if !defined (AORSMUL_FASTER_2AORSLSH) && !defined (AORSMUL_FASTER_AORS_2AORSLSH)
static mp_limb_t static mp_limb_t
DO_mpn_addlsh_n(mp_ptr dst, mp_srcptr src, mp_size_t n, unsigned int s, mp_ptr ws) DO_mpn_addlsh_n(mp_ptr dst, mp_srcptr src, mp_size_t n, unsigned int s, mp_ptr ws)
{ {
@ -69,6 +98,7 @@ DO_mpn_addlsh_n(mp_ptr dst, mp_srcptr src, mp_size_t n, unsigned int s, mp_ptr w
#endif #endif
} }
#endif #endif
#endif
#if HAVE_NATIVE_mpn_subrsh #if HAVE_NATIVE_mpn_subrsh
#define DO_mpn_subrsh(dst,nd,src,ns,s,ws) mpn_subrsh(dst,nd,src,ns,s) #define DO_mpn_subrsh(dst,nd,src,ns,s,ws) mpn_subrsh(dst,nd,src,ns,s)
@ -84,32 +114,6 @@ do { \
#endif #endif
#if GMP_NUMB_BITS < 21
#error Not implemented: Both sublsh_n(,,,20) should be corrected.
#endif
#if GMP_NUMB_BITS < 16
#error Not implemented: divexact_by42525 needs splitting.
#endif
#if GMP_NUMB_BITS < 12
#error Not implemented: Hard to adapt...
#endif
/* FIXME: tuneup should decide the best variant */
#ifndef AORSMUL_FASTER_AORS_AORSLSH
#define AORSMUL_FASTER_AORS_AORSLSH 1
#endif
#ifndef AORSMUL_FASTER_AORS_2AORSLSH
#define AORSMUL_FASTER_AORS_2AORSLSH 1
#endif
#ifndef AORSMUL_FASTER_2AORSLSH
#define AORSMUL_FASTER_2AORSLSH 1
#endif
#ifndef AORSMUL_FASTER_3AORSLSH
#define AORSMUL_FASTER_3AORSLSH 1
#endif
#define BINVERT_9 \ #define BINVERT_9 \
((((GMP_NUMB_MAX / 9) << (6 - GMP_NUMB_BITS % 6)) * 8 & GMP_NUMB_MAX) | 0x39) ((((GMP_NUMB_MAX / 9) << (6 - GMP_NUMB_BITS % 6)) * 8 & GMP_NUMB_MAX) | 0x39)

View File

@ -6,7 +6,7 @@
SAFE TO REACH IT THROUGH DOCUMENTED INTERFACES. IN FACT, IT IS ALMOST SAFE TO REACH IT THROUGH DOCUMENTED INTERFACES. IN FACT, IT IS ALMOST
GUARANTEED THAT IT WILL CHANGE OR DISAPPEAR IN A FUTURE GNU MP RELEASE. GUARANTEED THAT IT WILL CHANGE OR DISAPPEAR IN A FUTURE GNU MP RELEASE.
Copyright 2009, 2010, 2012, 2015 Free Software Foundation, Inc. Copyright 2009, 2010, 2012, 2015, 2020 Free Software Foundation, Inc.
This file is part of the GNU MP Library. This file is part of the GNU MP Library.
@ -37,6 +37,7 @@ see https://www.gnu.org/licenses/. */
#include "gmp-impl.h" #include "gmp-impl.h"
#if GMP_NUMB_BITS < 29 #if GMP_NUMB_BITS < 29
#error Not implemented: Both sublsh_n(,,,28) should be corrected; r2 and r5 need one more LIMB. #error Not implemented: Both sublsh_n(,,,28) should be corrected; r2 and r5 need one more LIMB.
#endif #endif
@ -46,6 +47,21 @@ see https://www.gnu.org/licenses/. */
#endif #endif
/* FIXME: tuneup should decide the best variant */
#ifndef AORSMUL_FASTER_AORS_AORSLSH
#define AORSMUL_FASTER_AORS_AORSLSH 1
#endif
#ifndef AORSMUL_FASTER_AORS_2AORSLSH
#define AORSMUL_FASTER_AORS_2AORSLSH 1
#endif
#ifndef AORSMUL_FASTER_2AORSLSH
#define AORSMUL_FASTER_2AORSLSH 1
#endif
#ifndef AORSMUL_FASTER_3AORSLSH
#define AORSMUL_FASTER_3AORSLSH 1
#endif
#if HAVE_NATIVE_mpn_sublsh_n #if HAVE_NATIVE_mpn_sublsh_n
#define DO_mpn_sublsh_n(dst,src,n,s,ws) mpn_sublsh_n(dst,dst,src,n,s) #define DO_mpn_sublsh_n(dst,src,n,s,ws) mpn_sublsh_n(dst,dst,src,n,s)
#else #else
@ -65,6 +81,7 @@ DO_mpn_sublsh_n(mp_ptr dst, mp_srcptr src, mp_size_t n, unsigned int s, mp_ptr w
#if HAVE_NATIVE_mpn_addlsh_n #if HAVE_NATIVE_mpn_addlsh_n
#define DO_mpn_addlsh_n(dst,src,n,s,ws) mpn_addlsh_n(dst,dst,src,n,s) #define DO_mpn_addlsh_n(dst,src,n,s,ws) mpn_addlsh_n(dst,dst,src,n,s)
#else #else
#if !defined (AORSMUL_FASTER_2AORSLSH) && !defined (AORSMUL_FASTER_AORS_2AORSLSH)
static mp_limb_t static mp_limb_t
DO_mpn_addlsh_n(mp_ptr dst, mp_srcptr src, mp_size_t n, unsigned int s, mp_ptr ws) DO_mpn_addlsh_n(mp_ptr dst, mp_srcptr src, mp_size_t n, unsigned int s, mp_ptr ws)
{ {
@ -77,6 +94,7 @@ DO_mpn_addlsh_n(mp_ptr dst, mp_srcptr src, mp_size_t n, unsigned int s, mp_ptr w
#endif #endif
} }
#endif #endif
#endif
#if HAVE_NATIVE_mpn_subrsh #if HAVE_NATIVE_mpn_subrsh
#define DO_mpn_subrsh(dst,nd,src,ns,s,ws) mpn_subrsh(dst,nd,src,ns,s) #define DO_mpn_subrsh(dst,nd,src,ns,s,ws) mpn_subrsh(dst,nd,src,ns,s)
@ -92,20 +110,6 @@ do { \
#endif #endif
/* FIXME: tuneup should decide the best variant */
#ifndef AORSMUL_FASTER_AORS_AORSLSH
#define AORSMUL_FASTER_AORS_AORSLSH 1
#endif
#ifndef AORSMUL_FASTER_AORS_2AORSLSH
#define AORSMUL_FASTER_AORS_2AORSLSH 1
#endif
#ifndef AORSMUL_FASTER_2AORSLSH
#define AORSMUL_FASTER_2AORSLSH 1
#endif
#ifndef AORSMUL_FASTER_3AORSLSH
#define AORSMUL_FASTER_3AORSLSH 1
#endif
#if GMP_NUMB_BITS < 43 #if GMP_NUMB_BITS < 43
#define BIT_CORRECTION 1 #define BIT_CORRECTION 1
#define CORRECTION_BITS GMP_NUMB_BITS #define CORRECTION_BITS GMP_NUMB_BITS

View File

@ -5,19 +5,30 @@ dnl Contributed to the GNU project by Torbjörn Granlund.
dnl Copyright 2018 Free Software Foundation, Inc. dnl Copyright 2018 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library. dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU Lesser General Public License as published dnl it under the terms of either:
dnl by the Free Software Foundation; either version 3 of the License, or (at dnl
dnl your option) any later version. dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl License for more details. dnl for more details.
dnl
dnl You should have received a copy of the GNU Lesser General Public License dnl You should have received copies of the GNU General Public License and the
dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4') include(`../config.m4')

View File

@ -5,19 +5,30 @@ dnl Contributed to the GNU project by Torbjörn Granlund.
dnl Copyright 2018 Free Software Foundation, Inc. dnl Copyright 2018 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library. dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU Lesser General Public License as published dnl it under the terms of either:
dnl by the Free Software Foundation; either version 3 of the License, or (at dnl
dnl your option) any later version. dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl License for more details. dnl for more details.
dnl
dnl You should have received a copy of the GNU Lesser General Public License dnl You should have received copies of the GNU General Public License and the
dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4') include(`../config.m4')

View File

@ -105,6 +105,7 @@ static struct {
{ "steamroller","AuthenticAMD", MAKE_FMS (21, 0x30) }, { "steamroller","AuthenticAMD", MAKE_FMS (21, 0x30) },
{ "excavator", "AuthenticAMD", MAKE_FMS (21, 0x60) }, { "excavator", "AuthenticAMD", MAKE_FMS (21, 0x60) },
{ "jaguar", "AuthenticAMD", MAKE_FMS (22, 1) }, { "jaguar", "AuthenticAMD", MAKE_FMS (22, 1) },
{ "zen", "AuthenticAMD", MAKE_FMS (23, 1) },
{ "viac3", "CentaurHauls", MAKE_FMS (6, 0) }, { "viac3", "CentaurHauls", MAKE_FMS (6, 0) },
{ "viac32", "CentaurHauls", MAKE_FMS (6, 9) }, { "viac32", "CentaurHauls", MAKE_FMS (6, 9) },
@ -335,6 +336,28 @@ __gmpn_cpuvec_init (void)
CPUVEC_SETUP_atom_sse2; CPUVEC_SETUP_atom_sse2;
break; break;
case 0x37: /* Silvermont */
case 0x4a: /* Silvermont */
case 0x4c: /* Airmont */
case 0x4d: /* Silvermont/Avoton */
case 0x5a: /* Silvermont */
TRACE (printf (" silvermont\n"));
CPUVEC_SETUP_atom;
CPUVEC_SETUP_atom_mmx;
CPUVEC_SETUP_atom_sse2;
CPUVEC_SETUP_silvermont;
break;
case 0x5c: /* Goldmont */
case 0x5f: /* Goldmont */
case 0x7a: /* Goldmont Plus */
TRACE (printf (" goldmont\n"));
CPUVEC_SETUP_atom;
CPUVEC_SETUP_atom_mmx;
CPUVEC_SETUP_atom_sse2;
CPUVEC_SETUP_goldmont;
break;
case 0x1a: /* NHM Gainestown */ case 0x1a: /* NHM Gainestown */
case 0x1b: case 0x1b:
case 0x1e: /* NHM Lynnfield/Jasper */ case 0x1e: /* NHM Lynnfield/Jasper */
@ -362,6 +385,7 @@ __gmpn_cpuvec_init (void)
case 0x2a: /* SBR */ case 0x2a: /* SBR */
case 0x2d: /* SBR-EP */ case 0x2d: /* SBR-EP */
case 0x3a: /* IBR */ case 0x3a: /* IBR */
case 0x3e: /* IBR Ivytown */
case 0x3c: /* Haswell client */ case 0x3c: /* Haswell client */
case 0x3f: /* Haswell server */ case 0x3f: /* Haswell server */
case 0x45: /* Haswell ULT */ case 0x45: /* Haswell ULT */
@ -428,8 +452,6 @@ __gmpn_cpuvec_init (void)
case 0x0f: /* k8 */ case 0x0f: /* k8 */
case 0x11: /* "fam 11h", mix of k8 and k10 */ case 0x11: /* "fam 11h", mix of k8 and k10 */
case 0x13: /* unknown, conservatively assume k8 */ case 0x13: /* unknown, conservatively assume k8 */
case 0x16: /* unknown, conservatively assume k8 */
case 0x17: /* unknown, conservatively assume k8 */
TRACE (printf (" k8\n")); TRACE (printf (" k8\n"));
CPUVEC_SETUP_k7; CPUVEC_SETUP_k7;
CPUVEC_SETUP_k7_mmx; CPUVEC_SETUP_k7_mmx;
@ -444,6 +466,7 @@ __gmpn_cpuvec_init (void)
break; break;
case 0x14: /* bobcat */ case 0x14: /* bobcat */
case 0x16: /* jaguar */
TRACE (printf (" bobcat\n")); TRACE (printf (" bobcat\n"));
CPUVEC_SETUP_k7; CPUVEC_SETUP_k7;
CPUVEC_SETUP_k7_mmx; CPUVEC_SETUP_k7_mmx;
@ -454,6 +477,14 @@ __gmpn_cpuvec_init (void)
TRACE (printf (" bulldozer\n")); TRACE (printf (" bulldozer\n"));
CPUVEC_SETUP_k7; CPUVEC_SETUP_k7;
CPUVEC_SETUP_k7_mmx; CPUVEC_SETUP_k7_mmx;
CPUVEC_SETUP_bd1;
break;
case 0x17: /* zen */
case 0x19: /* zen3 */
TRACE (printf (" zen\n"));
CPUVEC_SETUP_k7;
CPUVEC_SETUP_k7_mmx;
break; break;
} }
} }

View File

@ -35,7 +35,7 @@ C cycles/bit
C AMD K8,K9 12.3 C AMD K8,K9 12.3
C AMD K10 8.0 C AMD K10 8.0
C AMD bd1 10.0 C AMD bd1 10.0
C AMD bd2 7.2 C AMD bd2 7.2
C AMD bd3 ? C AMD bd3 ?
C AMD bd4 6.7 C AMD bd4 6.7
C AMD bt1 13.6 C AMD bt1 13.6

View File

@ -433,13 +433,14 @@ __gmpn_cpuvec_init (void)
CPUVEC_SETUP_bt2; CPUVEC_SETUP_bt2;
break; break;
case 0x15: /* bulldozer, piledriver, steamroller, excavator */ case 0x15: /* bulldozer, piledriver, steamroller, excavator */
CPUVEC_SETUP_k8; CPUVEC_SETUP_k8;
CPUVEC_SETUP_k10; CPUVEC_SETUP_k10;
CPUVEC_SETUP_bd1; CPUVEC_SETUP_bd1;
break; break;
case 0x17: /* zen */ case 0x17: /* zen */
case 0x19: /* zen3 */
CPUVEC_SETUP_zen; CPUVEC_SETUP_zen;
break; break;
} }

View File

@ -38,6 +38,7 @@ see https://www.gnu.org/licenses/. */
/* 3600-4000 MHz Intel Xeon E3-1270v5 Skylake */ /* 3600-4000 MHz Intel Xeon E3-1270v5 Skylake */
/* FFT tuning limit = 465,990,371 */ /* FFT tuning limit = 465,990,371 */
/* Generated by tuneup.c, 2019-10-18, gcc 8.3 */ /* Generated by tuneup.c, 2019-10-18, gcc 8.3 */
/* FFT_TABLEs merged with a new run, 2020-09-25, fft_max_size 1000000000 */
#define MOD_1_NORM_THRESHOLD 0 /* always */ #define MOD_1_NORM_THRESHOLD 0 /* always */
#define MOD_1_UNNORM_THRESHOLD 0 /* always */ #define MOD_1_UNNORM_THRESHOLD 0 /* always */
@ -135,10 +136,13 @@ see https://www.gnu.org/licenses/. */
{ 3071,15}, { 6911,16}, { 3583,15}, { 7679,14}, \ { 3071,15}, { 6911,16}, { 3583,15}, { 7679,14}, \
{ 15359,15}, { 7935,17}, { 2047,16}, { 4095,15}, \ { 15359,15}, { 7935,17}, { 2047,16}, { 4095,15}, \
{ 8703,16}, { 4607,15}, { 9983,14}, { 19967,16}, \ { 8703,16}, { 4607,15}, { 9983,14}, { 19967,16}, \
{ 5631,15}, { 11775,17}, { 3071,16}, { 65536,17}, \ { 5631,15}, { 11775,17}, { 3071,16}, \
{ 131072,18}, { 262144,19}, { 524288,20}, {1048576,21}, \ { 7679,15}, { 15359,18}, { 2047,17}, { 4095,16}, \
{2097152,22}, {4194304,23}, {8388608,24} } { 9727,15}, { 19967,17}, { 5119,16}, { 11775,15}, \
#define MUL_FFT_TABLE3_SIZE 227 { 24063,17}, { 6143,16}, { 12799,17}, { 7167,16}, \
{ 65536,17}, { 131072,18}, { 262144,19}, { 524288,20}, \
{1048576,21}, {2097152,22}, {4194304,23}, {8388608,24} }
#define MUL_FFT_TABLE3_SIZE 239
#define MUL_FFT_THRESHOLD 6272 #define MUL_FFT_THRESHOLD 6272
#define SQR_FFT_MODF_THRESHOLD 400 /* k = 5 */ #define SQR_FFT_MODF_THRESHOLD 400 /* k = 5 */
@ -192,10 +196,13 @@ see https://www.gnu.org/licenses/. */
{ 6911,16}, { 3583,15}, { 7679,14}, { 15359,17}, \ { 6911,16}, { 3583,15}, { 7679,14}, { 15359,17}, \
{ 2047,16}, { 4095,15}, { 8191,16}, { 4607,15}, \ { 2047,16}, { 4095,15}, { 8191,16}, { 4607,15}, \
{ 9983,14}, { 19967,16}, { 5631,15}, { 11775,17}, \ { 9983,14}, { 19967,16}, { 5631,15}, { 11775,17}, \
{ 3071,16}, { 65536,17}, { 131072,18}, { 262144,19}, \ { 3071,16}, { 7679,15}, { 15359,18}, { 2047,17}, \
{ 4095,16}, { 9727,15}, { 19967,17}, { 5119,16}, \
{ 11775,15}, { 23551,17}, { 6143,16}, { 12799,17}, \
{ 7167,16}, { 65536,17}, { 131072,18}, { 262144,19}, \
{ 524288,20}, {1048576,21}, {2097152,22}, {4194304,23}, \ { 524288,20}, {1048576,21}, {2097152,22}, {4194304,23}, \
{8388608,24} } {8388608,24} }
#define SQR_FFT_TABLE3_SIZE 205 #define SQR_FFT_TABLE3_SIZE 217
#define SQR_FFT_THRESHOLD 4224 #define SQR_FFT_THRESHOLD 4224
#define MULLO_BASECASE_THRESHOLD 0 /* always */ #define MULLO_BASECASE_THRESHOLD 0 /* always */

View File

@ -93,10 +93,28 @@ define(`PROLOGUE_cpu',
m4_assert_numargs(1) m4_assert_numargs(1)
` GLOBL $1 ` GLOBL $1
TYPE($1,`function') TYPE($1,`function')
COFF_TYPE($1)
$1: $1:
') ')
dnl Usage: COFF_TYPE(GSYM_PREFIX`'foo)
dnl
dnl Emit COFF style ".def ... .endef" type information for a function, when
dnl supported. The argument should include any GSYM_PREFIX.
dnl
dnl See autoconf macro GMP_ASM_COFF_TYPE for HAVE_COFF_TYPE.
define(COFF_TYPE,
m4_assert_numargs(1)
m4_assert_defined(`HAVE_COFF_TYPE')
`ifelse(HAVE_COFF_TYPE,yes,
`.def $1
.scl 2
.type 32
.endef')')
dnl Usage: ASSERT([cond][,instructions]) dnl Usage: ASSERT([cond][,instructions])
dnl dnl
dnl If WANT_ASSERT is 1, output the given instructions and expect the given dnl If WANT_ASSERT is 1, output the given instructions and expect the given

View File

@ -38,6 +38,7 @@ see https://www.gnu.org/licenses/. */
/* 3600-4400 MHz Matisse */ /* 3600-4400 MHz Matisse */
/* FFT tuning limit = 703,392,483 */ /* FFT tuning limit = 703,392,483 */
/* Generated by tuneup.c, 2019-10-19, gcc 8.3 */ /* Generated by tuneup.c, 2019-10-19, gcc 8.3 */
/* FFT_TABLEs merged with a new run, 2020-09-24, fft_max_size 2000000000 */
#define MOD_1_NORM_THRESHOLD 0 /* always */ #define MOD_1_NORM_THRESHOLD 0 /* always */
#define MOD_1_UNNORM_THRESHOLD 0 /* always */ #define MOD_1_UNNORM_THRESHOLD 0 /* always */
@ -147,10 +148,14 @@ see https://www.gnu.org/licenses/. */
{ 4095,15}, { 8959,16}, { 4607,15}, { 9983,14}, \ { 4095,15}, { 8959,16}, { 4607,15}, { 9983,14}, \
{ 19967,16}, { 5631,15}, { 11775,17}, { 3071,16}, \ { 19967,16}, { 5631,15}, { 11775,17}, { 3071,16}, \
{ 7679,15}, { 15871,18}, { 2047,17}, { 4095,16}, \ { 7679,15}, { 15871,18}, { 2047,17}, { 4095,16}, \
{ 9727,15}, { 19967,17}, { 5119,16}, { 65536,17}, \ { 9727,15}, { 19967,17}, \
{ 5119,16}, { 11775,15}, { 24063,17}, { 6143,16}, \
{ 12799,17}, { 7167,16}, { 15871,15}, { 31743,18}, \
{ 4095,17}, { 8191,16}, { 16895,17}, { 9215,16}, \
{ 19967,17}, { 11263,16}, { 24063,18}, { 6143,17}, \
{ 131072,18}, { 262144,19}, { 524288,20}, {1048576,21}, \ { 131072,18}, { 262144,19}, { 524288,20}, {1048576,21}, \
{2097152,22}, {4194304,23}, {8388608,24} } {2097152,22}, {4194304,23}, {8388608,24} }
#define MUL_FFT_TABLE3_SIZE 275 #define MUL_FFT_TABLE3_SIZE 289
#define MUL_FFT_THRESHOLD 4736 #define MUL_FFT_THRESHOLD 4736
#define SQR_FFT_MODF_THRESHOLD 396 /* k = 5 */ #define SQR_FFT_MODF_THRESHOLD 396 /* k = 5 */
@ -223,10 +228,14 @@ see https://www.gnu.org/licenses/. */
{ 9983,14}, { 19967,16}, { 5119,15}, { 10239,16}, \ { 9983,14}, { 19967,16}, { 5119,15}, { 10239,16}, \
{ 5631,15}, { 11775,17}, { 3071,16}, { 7679,15}, \ { 5631,15}, { 11775,17}, { 3071,16}, { 7679,15}, \
{ 15359,18}, { 2047,17}, { 4095,16}, { 9727,15}, \ { 15359,18}, { 2047,17}, { 4095,16}, { 9727,15}, \
{ 19967,17}, { 5119,16}, { 65536,17}, { 131072,18}, \ { 19967,17}, \
{ 262144,19}, { 524288,20}, {1048576,21}, {2097152,22}, \ { 5119,16}, { 11775,15}, { 23551,17}, { 6143,16}, \
{4194304,23}, {8388608,24} } { 12799,17}, { 7167,16}, { 15871,15}, { 31743,18}, \
#define SQR_FFT_TABLE3_SIZE 282 { 4095,17}, { 8191,16}, { 16895,17}, { 9215,16}, \
{ 19967,17}, { 11263,16}, { 24063,18}, { 6143,17}, \
{ 131072,18}, { 262144,19}, { 524288,20}, {1048576,21}, \
{2097152,22}, {4194304,23}, {8388608,24} }
#define SQR_FFT_TABLE3_SIZE 296
#define SQR_FFT_THRESHOLD 3264 #define SQR_FFT_THRESHOLD 3264
#define MULLO_BASECASE_THRESHOLD 0 /* always */ #define MULLO_BASECASE_THRESHOLD 0 /* always */

View File

@ -70,8 +70,9 @@ mpq_cmp_numden (mpq_srcptr op1, mpz_srcptr num_op2, mpz_srcptr den_op2)
{ {
int cmp; int cmp;
/* Cannot use num1_sign - num2_size, may overflow an "int" */
if (num1_sign != num2_size) if (num1_sign != num2_size)
return num1_sign - num2_size; return (num1_sign > num2_size) ? 1 : -1;
cmp = mpn_cmp (PTR(NUM(op1)), PTR(num_op2), num1_size); cmp = mpn_cmp (PTR(NUM(op1)), PTR(num_op2), num1_size);
return (num1_sign > 0 ? cmp : -cmp); return (num1_sign > 0 ? cmp : -cmp);

View File

@ -1,8 +1,8 @@
/* mpz_cmp(u,v) -- Compare U, V. Return positive, zero, or negative /* mpz_cmp(u,v) -- Compare U, V. Return positive, zero, or negative
based on if U > V, U == V, or U < V. based on if U > V, U == V, or U < V.
Copyright 1991, 1993, 1994, 1996, 2001, 2002, 2011 Free Software Foundation, Copyright 1991, 1993, 1994, 1996, 2001, 2002, 2011, 2020 Free Software
Inc. Foundation, Inc.
This file is part of the GNU MP Library. This file is part of the GNU MP Library.
@ -35,15 +35,15 @@ see https://www.gnu.org/licenses/. */
int int
mpz_cmp (mpz_srcptr u, mpz_srcptr v) __GMP_NOTHROW mpz_cmp (mpz_srcptr u, mpz_srcptr v) __GMP_NOTHROW
{ {
mp_size_t usize, vsize, dsize, asize; mp_size_t usize, vsize, asize;
mp_srcptr up, vp; mp_srcptr up, vp;
int cmp; int cmp;
usize = SIZ(u); usize = SIZ(u);
vsize = SIZ(v); vsize = SIZ(v);
dsize = usize - vsize; /* Cannot use usize - vsize, may overflow an "int" */
if (dsize != 0) if (usize != vsize)
return dsize; return (usize > vsize) ? 1 : -1;
asize = ABS (usize); asize = ABS (usize);
up = PTR(u); up = PTR(u);

View File

@ -8,7 +8,7 @@
With the current implementation, the first 24 MR-tests are substituted by a With the current implementation, the first 24 MR-tests are substituted by a
Baillie-PSW probable prime test. Baillie-PSW probable prime test.
This implementation the Baillie-PSW test was checked up to 19*2^46, This implementation the Baillie-PSW test was checked up to 31*2^46,
for smaller values no MR-test is performed, regardless of reps, and for smaller values no MR-test is performed, regardless of reps, and
2 ("surely prime") is returned if the number was not proved composite. 2 ("surely prime") is returned if the number was not proved composite.
@ -101,11 +101,11 @@ mpz_millerrabin (mpz_srcptr n, int reps)
|| SIZ (n) - 64 / GMP_NUMB_BITS == (PTR (n) [64 / GMP_NUMB_BITS] < CNST_LIMB(1) << 64 % GMP_NUMB_BITS) || SIZ (n) - 64 / GMP_NUMB_BITS == (PTR (n) [64 / GMP_NUMB_BITS] < CNST_LIMB(1) << 64 % GMP_NUMB_BITS)
#endif #endif
#else #else
/* Consider numbers up to 19*2^46 that pass the BPSW test as primes. /* Consider numbers up to 31*2^46 that pass the BPSW test as primes.
This implementation was tested up to 19*2^46 = 2^50+2^47+2^46 */ This implementation was tested up to 31*2^46 */
/* 2^4 < 19 = 0b10011 < 2^5 */ /* 2^4 < 31 = 0b11111 < 2^5 */
#define GMP_BPSW_LIMB_CONST CNST_LIMB(19) #define GMP_BPSW_LIMB_CONST CNST_LIMB(31)
#define GMP_BPSW_BITS_CONST (LOG2C(19) - 1) #define GMP_BPSW_BITS_CONST (LOG2C(31) - 1)
#define GMP_BPSW_BITS_LIMIT (46 + GMP_BPSW_BITS_CONST) #define GMP_BPSW_BITS_LIMIT (46 + GMP_BPSW_BITS_CONST)
#define GMP_BPSW_LIMBS_LIMIT (GMP_BPSW_BITS_LIMIT / GMP_NUMB_BITS) #define GMP_BPSW_LIMBS_LIMIT (GMP_BPSW_BITS_LIMIT / GMP_NUMB_BITS)

View File

@ -104,13 +104,15 @@ mpz_mul (mpz_ptr w, mpz_srcptr u, mpz_srcptr v)
if (ALLOC (w) < wsize) if (ALLOC (w) < wsize)
{ {
if (ALLOC (w) != 0) if (ALLOC (w) != 0)
if (wp == up || wp == vp) {
{ if (wp == up || wp == vp)
free_me = wp; {
free_me_size = ALLOC (w); free_me = wp;
} free_me_size = ALLOC (w);
else }
(*__gmp_free_func) (wp, (size_t) ALLOC (w) * GMP_LIMB_BYTES); else
(*__gmp_free_func) (wp, (size_t) ALLOC (w) * GMP_LIMB_BYTES);
}
ALLOC (w) = wsize; ALLOC (w) = wsize;
wp = __GMP_ALLOCATE_FUNC_LIMBS (wsize); wp = __GMP_ALLOCATE_FUNC_LIMBS (wsize);

View File

@ -4,7 +4,7 @@
CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN
FUTURE GNU MP RELEASES. FUTURE GNU MP RELEASES.
Copyright 2001, 2002, 2005, 2012, 2015 Free Software Foundation, Inc. Copyright 2001, 2002, 2005, 2012, 2015, 2020 Free Software Foundation, Inc.
This file is part of the GNU MP Library. This file is part of the GNU MP Library.
@ -32,6 +32,8 @@ You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not, GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */ see https://www.gnu.org/licenses/. */
#include <stdlib.h>
#include <stdio.h>
#include "gmp-impl.h" #include "gmp-impl.h"
#include "longlong.h" #include "longlong.h"
@ -170,6 +172,7 @@ mpz_n_pow_ui (mpz_ptr r, mp_srcptr bp, mp_size_t bsize, unsigned long int e)
#else #else
mp_limb_t b_twolimbs[2]; mp_limb_t b_twolimbs[2];
#endif #endif
mp_limb_t ovfl;
TMP_DECL; TMP_DECL;
TRACE (printf ("mpz_n_pow_ui rp=0x%lX bp=0x%lX bsize=%ld e=%lu (0x%lX)\n", TRACE (printf ("mpz_n_pow_ui rp=0x%lX bp=0x%lX bsize=%ld e=%lu (0x%lX)\n",
@ -213,7 +216,14 @@ mpz_n_pow_ui (mpz_ptr r, mp_srcptr bp, mp_size_t bsize, unsigned long int e)
/* Strip low zero bits from b. */ /* Strip low zero bits from b. */
count_trailing_zeros (btwos, blimb); count_trailing_zeros (btwos, blimb);
blimb >>= btwos; blimb >>= btwos;
rtwos_bits = e * btwos;
umul_ppmm (ovfl, rtwos_bits, e, btwos);
if (ovfl)
{
fprintf (stderr, "gmp: overflow in mpz type\n");
abort ();
}
rtwos_limbs += rtwos_bits / GMP_NUMB_BITS; rtwos_limbs += rtwos_bits / GMP_NUMB_BITS;
rtwos_bits %= GMP_NUMB_BITS; rtwos_bits %= GMP_NUMB_BITS;
TRACE (printf ("trailing zero btwos=%d rtwos_limbs=%ld rtwos_bits=%lu\n", TRACE (printf ("trailing zero btwos=%d rtwos_limbs=%ld rtwos_bits=%lu\n",
@ -368,7 +378,15 @@ mpz_n_pow_ui (mpz_ptr r, mp_srcptr bp, mp_size_t bsize, unsigned long int e)
ASSERT (blimb != 0); ASSERT (blimb != 0);
count_leading_zeros (cnt, blimb); count_leading_zeros (cnt, blimb);
ralloc = (bsize*GMP_NUMB_BITS - cnt + GMP_NAIL_BITS) * e / GMP_NUMB_BITS + 5;
umul_ppmm (ovfl, ralloc, (bsize*GMP_NUMB_BITS - cnt + GMP_NAIL_BITS), e);
if (ovfl)
{
fprintf (stderr, "gmp: overflow in mpz type\n");
abort ();
}
ralloc = ralloc / GMP_NUMB_BITS + 5;
TRACE (printf ("ralloc %ld, from bsize=%ld blimb=0x%lX cnt=%d\n", TRACE (printf ("ralloc %ld, from bsize=%ld blimb=0x%lX cnt=%d\n",
ralloc, bsize, blimb, cnt)); ralloc, bsize, blimb, cnt));
rp = MPZ_NEWALLOC (r, ralloc + rtwos_limbs); rp = MPZ_NEWALLOC (r, ralloc + rtwos_limbs);

View File

@ -171,7 +171,7 @@ check_mpz (void)
mpz_class b; mpz_class b;
b = a; b = a;
ASSERT_ALWAYS (0); /* should not be reached */ ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) { } catch (invalid_argument&) {
} }
} }
@ -182,7 +182,7 @@ check_mpz (void)
mpz_class b; mpz_class b;
b = a; b = a;
ASSERT_ALWAYS (0); /* should not be reached */ ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) { } catch (invalid_argument&) {
} }
} }
@ -357,7 +357,7 @@ check_mpq (void)
mpq_class b; mpq_class b;
b = a; b = a;
ASSERT_ALWAYS (0); /* should not be reached */ ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) { } catch (invalid_argument&) {
} }
} }
@ -368,7 +368,7 @@ check_mpq (void)
mpq_class b; mpq_class b;
b = a; b = a;
ASSERT_ALWAYS (0); /* should not be reached */ ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) { } catch (invalid_argument&) {
} }
} }
@ -543,7 +543,7 @@ check_mpf (void)
mpf_class b; mpf_class b;
b = a; b = a;
ASSERT_ALWAYS (0); /* should not be reached */ ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) { } catch (invalid_argument&) {
} }
} }
@ -554,7 +554,7 @@ check_mpf (void)
mpf_class b; mpf_class b;
b = a; b = a;
ASSERT_ALWAYS (0); /* should not be reached */ ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) { } catch (invalid_argument&) {
} }
} }

View File

@ -154,7 +154,7 @@ check_mpz (void)
const char *a = "ABC"; const char *a = "ABC";
mpz_class b(a); mpz_class b(a);
ASSERT_ALWAYS (0); /* should not be reached */ ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) { } catch (invalid_argument&) {
} }
} }
@ -165,7 +165,7 @@ check_mpz (void)
int base = 16; int base = 16;
mpz_class b(a, base); mpz_class b(a, base);
ASSERT_ALWAYS (0); /* should not be reached */ ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) { } catch (invalid_argument&) {
} }
} }
@ -175,7 +175,7 @@ check_mpz (void)
string a("abc"); string a("abc");
mpz_class b(a); mpz_class b(a);
ASSERT_ALWAYS (0); /* should not be reached */ ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) { } catch (invalid_argument&) {
} }
} }
@ -186,7 +186,7 @@ check_mpz (void)
int base = 8; int base = 8;
mpz_class b(a, base); mpz_class b(a, base);
ASSERT_ALWAYS (0); /* should not be reached */ ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) { } catch (invalid_argument&) {
} }
} }
@ -341,7 +341,7 @@ check_mpq (void)
const char *a = "abc"; const char *a = "abc";
mpq_class b(a); mpq_class b(a);
ASSERT_ALWAYS (0); /* should not be reached */ ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) { } catch (invalid_argument&) {
} }
} }
@ -352,7 +352,7 @@ check_mpq (void)
int base = 16; int base = 16;
mpq_class b (a, base); mpq_class b (a, base);
ASSERT_ALWAYS (0); /* should not be reached */ ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) { } catch (invalid_argument&) {
} }
} }
@ -362,7 +362,7 @@ check_mpq (void)
string a("abc"); string a("abc");
mpq_class b(a); mpq_class b(a);
ASSERT_ALWAYS (0); /* should not be reached */ ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) { } catch (invalid_argument&) {
} }
} }
@ -373,7 +373,7 @@ check_mpq (void)
int base = 8; int base = 8;
mpq_class b (a, base); mpq_class b (a, base);
ASSERT_ALWAYS (0); /* should not be reached */ ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) { } catch (invalid_argument&) {
} }
} }
@ -635,7 +635,7 @@ check_mpf (void)
const char *a = "abc"; const char *a = "abc";
mpf_class b(a); mpf_class b(a);
ASSERT_ALWAYS (0); /* should not be reached */ ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) { } catch (invalid_argument&) {
} }
} }
@ -646,7 +646,7 @@ check_mpf (void)
int prec = 256; int prec = 256;
mpf_class b(a, prec); ASSERT_ALWAYS(b == 1234567890L); mpf_class b(a, prec); ASSERT_ALWAYS(b == 1234567890L);
ASSERT_ALWAYS (0); /* should not be reached */ ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) { } catch (invalid_argument&) {
} }
} }
{ {
@ -655,7 +655,7 @@ check_mpf (void)
int prec = 64, base = 8; int prec = 64, base = 8;
mpf_class b(a, prec, base); ASSERT_ALWAYS(b == 262143L); mpf_class b(a, prec, base); ASSERT_ALWAYS(b == 262143L);
ASSERT_ALWAYS (0); /* should not be reached */ ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) { } catch (invalid_argument&) {
} }
} }
@ -665,7 +665,7 @@ check_mpf (void)
string a("abc"); string a("abc");
mpf_class b(a); ASSERT_ALWAYS(b == 1234567890L); mpf_class b(a); ASSERT_ALWAYS(b == 1234567890L);
ASSERT_ALWAYS (0); /* should not be reached */ ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) { } catch (invalid_argument&) {
} }
} }
@ -676,7 +676,7 @@ check_mpf (void)
int prec = 128; int prec = 128;
mpf_class b(a, prec); ASSERT_ALWAYS(b == 1234567890L); mpf_class b(a, prec); ASSERT_ALWAYS(b == 1234567890L);
ASSERT_ALWAYS (0); /* should not be reached */ ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) { } catch (invalid_argument&) {
} }
} }
{ {
@ -685,7 +685,7 @@ check_mpf (void)
int prec = 256, base = 16; int prec = 256, base = 16;
mpf_class b(a, prec, base); ASSERT_ALWAYS(b == 65535u); mpf_class b(a, prec, base); ASSERT_ALWAYS(b == 65535u);
ASSERT_ALWAYS (0); /* should not be reached */ ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) { } catch (invalid_argument&) {
} }
} }

View File

@ -34,5 +34,5 @@ main ()
{ {
throw_expr(); throw_expr();
} }
catch (invalid_argument) { } catch (invalid_argument&) { }
} }

View File

@ -89,22 +89,22 @@ void checkz (){
ASSERT_ALWAYS(mpz_class::factorial(3.f)==6); ASSERT_ALWAYS(mpz_class::factorial(3.f)==6);
mpz_class ret; mpz_class ret;
try { ret=factorial(-mpz_class(3)); ASSERT_ALWAYS(0); } try { ret=factorial(-mpz_class(3)); ASSERT_ALWAYS(0); }
catch (std::domain_error) {} catch (std::domain_error&) {}
try { ret=mpz_class::factorial(-2); ASSERT_ALWAYS(0); } try { ret=mpz_class::factorial(-2); ASSERT_ALWAYS(0); }
catch (std::domain_error) {} catch (std::domain_error&) {}
try { ret=factorial(mpz_class(1)<<300); ASSERT_ALWAYS(0); } try { ret=factorial(mpz_class(1)<<300); ASSERT_ALWAYS(0); }
catch (std::bad_alloc) {} catch (std::bad_alloc&) {}
ASSERT_ALWAYS(mpz_class::primorial(mpz_class(3))==6); ASSERT_ALWAYS(mpz_class::primorial(mpz_class(3))==6);
ASSERT_ALWAYS(mpz_class::primorial(mpz_class(2)*2)==6); ASSERT_ALWAYS(mpz_class::primorial(mpz_class(2)*2)==6);
ASSERT_ALWAYS(mpz_class::primorial(3)==6); ASSERT_ALWAYS(mpz_class::primorial(3)==6);
ASSERT_ALWAYS(mpz_class::primorial(3ul)==6); ASSERT_ALWAYS(mpz_class::primorial(3ul)==6);
ASSERT_ALWAYS(mpz_class::primorial(3.f)==6); ASSERT_ALWAYS(mpz_class::primorial(3.f)==6);
try { ret=primorial(-mpz_class(3)); ASSERT_ALWAYS(0); } try { ret=primorial(-mpz_class(3)); ASSERT_ALWAYS(0); }
catch (std::domain_error) {} catch (std::domain_error&) {}
try { ret=mpz_class::primorial(-5); ASSERT_ALWAYS(0); } try { ret=mpz_class::primorial(-5); ASSERT_ALWAYS(0); }
catch (std::domain_error) {} catch (std::domain_error&) {}
try { ret=primorial(mpz_class(1)<<300); ASSERT_ALWAYS(0); } try { ret=primorial(mpz_class(1)<<300); ASSERT_ALWAYS(0); }
catch (std::bad_alloc) {} catch (std::bad_alloc&) {}
ASSERT_ALWAYS(mpz_class::fibonacci(mpz_class(6))==8); ASSERT_ALWAYS(mpz_class::fibonacci(mpz_class(6))==8);
ASSERT_ALWAYS(mpz_class::fibonacci(mpz_class(2)*2)==3); ASSERT_ALWAYS(mpz_class::fibonacci(mpz_class(2)*2)==3);
ASSERT_ALWAYS(mpz_class::fibonacci(3)==2); ASSERT_ALWAYS(mpz_class::fibonacci(3)==2);
@ -113,7 +113,7 @@ void checkz (){
ASSERT_ALWAYS(fibonacci(-mpz_class(6))==-8); ASSERT_ALWAYS(fibonacci(-mpz_class(6))==-8);
ASSERT_ALWAYS(mpz_class::fibonacci(-3)==2); ASSERT_ALWAYS(mpz_class::fibonacci(-3)==2);
try { ret=fibonacci(mpz_class(1)<<300); ASSERT_ALWAYS(0); } try { ret=fibonacci(mpz_class(1)<<300); ASSERT_ALWAYS(0); }
catch (std::bad_alloc) {} catch (std::bad_alloc&) {}
} }
int int

View File

@ -49,7 +49,7 @@ check_randinit (void)
unsigned long m2exp = ULONG_MAX; unsigned long m2exp = ULONG_MAX;
gmp_randclass r(gmp_randinit_lc_2exp_size, m2exp); gmp_randclass r(gmp_randinit_lc_2exp_size, m2exp);
ASSERT_ALWAYS (0); /* should not be reached */ ASSERT_ALWAYS (0); /* should not be reached */
} catch (length_error) { } catch (length_error&) {
} }
} }

View File

@ -22,10 +22,10 @@ AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/tests
AM_LDFLAGS = -no-install AM_LDFLAGS = -no-install
LDADD = $(top_builddir)/tests/libtests.la $(top_builddir)/libgmp.la LDADD = $(top_builddir)/tests/libtests.la $(top_builddir)/libgmp.la
# add_n_sub_n add_n_sub_n_2 not yet built since mpn_add_n_sub_n doesn't yet exist
#
EXTRA_PROGRAMS = \ EXTRA_PROGRAMS = \
aors_n anymul_1 copy divmod_1 divrem shift logops_n sqrtrem_1_2 primes tst-addsub try addmul_N mul_N cnd_aors_n sqrtrem_1_2 primes try test-add_ssaaaa test-sub_ddmmss
EXTRA_DIST = gen-test-longlong_h.c
allprogs: $(EXTRA_PROGRAMS) allprogs: $(EXTRA_PROGRAMS)
@ -33,3 +33,15 @@ CLEANFILES = $(EXTRA_PROGRAMS)
$(top_builddir)/tests/libtests.la: $(top_builddir)/tests/libtests.la:
cd $(top_builddir)/tests; $(MAKE) $(AM_MAKEFLAGS) libtests.la cd $(top_builddir)/tests; $(MAKE) $(AM_MAKEFLAGS) libtests.la
test-add_ssaaaa.c: gen-test-longlong_h$(EXEEXT_FOR_BUILD)
./gen-test-longlong_h add >test-add_ssaaaa.c || (rm -f test-add_ssaaaa.c; exit 1)
CLEANFILES += test-add_ssaaaa.c
test-sub_ddmmss.c: gen-test-longlong_h$(EXEEXT_FOR_BUILD)
./gen-test-longlong_h sub >test-sub_ddmmss.c || (rm -f test-sub_ddmmss.c; exit 1)
CLEANFILES += test-sub_ddmmss.c
gen-test-longlong_h$(EXEEXT_FOR_BUILD): gen-test-longlong_h.c
$(CC_FOR_BUILD) `test -f 'gen-test-longlong_h.c' || echo '$(srcdir)/'`gen-test-longlong_h.c -o gen-test-longlong_h$(EXEEXT_FOR_BUILD)
CLEANFILES += gen-test-longlong_h$(EXEEXT_FOR_BUILD)

View File

@ -104,11 +104,8 @@ PRE_UNINSTALL = :
POST_UNINSTALL = : POST_UNINSTALL = :
build_triplet = @build@ build_triplet = @build@
host_triplet = @host@ host_triplet = @host@
EXTRA_PROGRAMS = aors_n$(EXEEXT) anymul_1$(EXEEXT) copy$(EXEEXT) \ EXTRA_PROGRAMS = sqrtrem_1_2$(EXEEXT) primes$(EXEEXT) try$(EXEEXT) \
divmod_1$(EXEEXT) divrem$(EXEEXT) shift$(EXEEXT) \ test-add_ssaaaa$(EXEEXT) test-sub_ddmmss$(EXEEXT)
logops_n$(EXEEXT) sqrtrem_1_2$(EXEEXT) primes$(EXEEXT) \
tst-addsub$(EXEEXT) try$(EXEEXT) addmul_N$(EXEEXT) \
mul_N$(EXEEXT) cnd_aors_n$(EXEEXT)
subdir = tests/devel subdir = tests/devel
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
@ -120,80 +117,35 @@ mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES = CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES = CONFIG_CLEAN_VPATH_FILES =
addmul_N_SOURCES = addmul_N.c
addmul_N_OBJECTS = addmul_N.$(OBJEXT)
addmul_N_LDADD = $(LDADD)
addmul_N_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 =
anymul_1_SOURCES = anymul_1.c
anymul_1_OBJECTS = anymul_1.$(OBJEXT)
anymul_1_LDADD = $(LDADD)
anymul_1_DEPENDENCIES = $(top_builddir)/tests/libtests.la \
$(top_builddir)/libgmp.la
aors_n_SOURCES = aors_n.c
aors_n_OBJECTS = aors_n.$(OBJEXT)
aors_n_LDADD = $(LDADD)
aors_n_DEPENDENCIES = $(top_builddir)/tests/libtests.la \
$(top_builddir)/libgmp.la
cnd_aors_n_SOURCES = cnd_aors_n.c
cnd_aors_n_OBJECTS = cnd_aors_n.$(OBJEXT)
cnd_aors_n_LDADD = $(LDADD)
cnd_aors_n_DEPENDENCIES = $(top_builddir)/tests/libtests.la \
$(top_builddir)/libgmp.la
copy_SOURCES = copy.c
copy_OBJECTS = copy.$(OBJEXT)
copy_LDADD = $(LDADD)
copy_DEPENDENCIES = $(top_builddir)/tests/libtests.la \
$(top_builddir)/libgmp.la
divmod_1_SOURCES = divmod_1.c
divmod_1_OBJECTS = divmod_1.$(OBJEXT)
divmod_1_LDADD = $(LDADD)
divmod_1_DEPENDENCIES = $(top_builddir)/tests/libtests.la \
$(top_builddir)/libgmp.la
divrem_SOURCES = divrem.c
divrem_OBJECTS = divrem.$(OBJEXT)
divrem_LDADD = $(LDADD)
divrem_DEPENDENCIES = $(top_builddir)/tests/libtests.la \
$(top_builddir)/libgmp.la
logops_n_SOURCES = logops_n.c
logops_n_OBJECTS = logops_n.$(OBJEXT)
logops_n_LDADD = $(LDADD)
logops_n_DEPENDENCIES = $(top_builddir)/tests/libtests.la \
$(top_builddir)/libgmp.la
mul_N_SOURCES = mul_N.c
mul_N_OBJECTS = mul_N.$(OBJEXT)
mul_N_LDADD = $(LDADD)
mul_N_DEPENDENCIES = $(top_builddir)/tests/libtests.la \
$(top_builddir)/libgmp.la
primes_SOURCES = primes.c primes_SOURCES = primes.c
primes_OBJECTS = primes.$(OBJEXT) primes_OBJECTS = primes.$(OBJEXT)
primes_LDADD = $(LDADD) primes_LDADD = $(LDADD)
primes_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ primes_DEPENDENCIES = $(top_builddir)/tests/libtests.la \
$(top_builddir)/libgmp.la $(top_builddir)/libgmp.la
shift_SOURCES = shift.c AM_V_lt = $(am__v_lt_@AM_V@)
shift_OBJECTS = shift.$(OBJEXT) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
shift_LDADD = $(LDADD) am__v_lt_0 = --silent
shift_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ am__v_lt_1 =
$(top_builddir)/libgmp.la
sqrtrem_1_2_SOURCES = sqrtrem_1_2.c sqrtrem_1_2_SOURCES = sqrtrem_1_2.c
sqrtrem_1_2_OBJECTS = sqrtrem_1_2.$(OBJEXT) sqrtrem_1_2_OBJECTS = sqrtrem_1_2.$(OBJEXT)
sqrtrem_1_2_LDADD = $(LDADD) sqrtrem_1_2_LDADD = $(LDADD)
sqrtrem_1_2_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ sqrtrem_1_2_DEPENDENCIES = $(top_builddir)/tests/libtests.la \
$(top_builddir)/libgmp.la $(top_builddir)/libgmp.la
test_add_ssaaaa_SOURCES = test-add_ssaaaa.c
test_add_ssaaaa_OBJECTS = test-add_ssaaaa.$(OBJEXT)
test_add_ssaaaa_LDADD = $(LDADD)
test_add_ssaaaa_DEPENDENCIES = $(top_builddir)/tests/libtests.la \
$(top_builddir)/libgmp.la
test_sub_ddmmss_SOURCES = test-sub_ddmmss.c
test_sub_ddmmss_OBJECTS = test-sub_ddmmss.$(OBJEXT)
test_sub_ddmmss_LDADD = $(LDADD)
test_sub_ddmmss_DEPENDENCIES = $(top_builddir)/tests/libtests.la \
$(top_builddir)/libgmp.la
try_SOURCES = try.c try_SOURCES = try.c
try_OBJECTS = try.$(OBJEXT) try_OBJECTS = try.$(OBJEXT)
try_LDADD = $(LDADD) try_LDADD = $(LDADD)
try_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ try_DEPENDENCIES = $(top_builddir)/tests/libtests.la \
$(top_builddir)/libgmp.la $(top_builddir)/libgmp.la
tst_addsub_SOURCES = tst-addsub.c
tst_addsub_OBJECTS = tst-addsub.$(OBJEXT)
tst_addsub_LDADD = $(LDADD)
tst_addsub_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_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false am__v_P_0 = false
@ -227,12 +179,10 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 = am__v_CCLD_1 =
SOURCES = addmul_N.c anymul_1.c aors_n.c cnd_aors_n.c copy.c \ SOURCES = primes.c sqrtrem_1_2.c test-add_ssaaaa.c test-sub_ddmmss.c \
divmod_1.c divrem.c logops_n.c mul_N.c primes.c shift.c \ try.c
sqrtrem_1_2.c try.c tst-addsub.c DIST_SOURCES = primes.c sqrtrem_1_2.c test-add_ssaaaa.c \
DIST_SOURCES = addmul_N.c anymul_1.c aors_n.c cnd_aors_n.c copy.c \ test-sub_ddmmss.c try.c
divmod_1.c divrem.c logops_n.c mul_N.c primes.c shift.c \
sqrtrem_1_2.c try.c tst-addsub.c
am__can_run_installinfo = \ am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \ case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \ n|no|NO) false;; \
@ -423,7 +373,9 @@ top_srcdir = @top_srcdir@
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/tests AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/tests
AM_LDFLAGS = -no-install AM_LDFLAGS = -no-install
LDADD = $(top_builddir)/tests/libtests.la $(top_builddir)/libgmp.la LDADD = $(top_builddir)/tests/libtests.la $(top_builddir)/libgmp.la
CLEANFILES = $(EXTRA_PROGRAMS) EXTRA_DIST = gen-test-longlong_h.c
CLEANFILES = $(EXTRA_PROGRAMS) test-add_ssaaaa.c test-sub_ddmmss.c \
gen-test-longlong_h$(EXEEXT_FOR_BUILD)
all: all-am all: all-am
.SUFFIXES: .SUFFIXES:
@ -458,62 +410,26 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps): $(am__aclocal_m4_deps):
addmul_N$(EXEEXT): $(addmul_N_OBJECTS) $(addmul_N_DEPENDENCIES) $(EXTRA_addmul_N_DEPENDENCIES)
@rm -f addmul_N$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(addmul_N_OBJECTS) $(addmul_N_LDADD) $(LIBS)
anymul_1$(EXEEXT): $(anymul_1_OBJECTS) $(anymul_1_DEPENDENCIES) $(EXTRA_anymul_1_DEPENDENCIES)
@rm -f anymul_1$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(anymul_1_OBJECTS) $(anymul_1_LDADD) $(LIBS)
aors_n$(EXEEXT): $(aors_n_OBJECTS) $(aors_n_DEPENDENCIES) $(EXTRA_aors_n_DEPENDENCIES)
@rm -f aors_n$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(aors_n_OBJECTS) $(aors_n_LDADD) $(LIBS)
cnd_aors_n$(EXEEXT): $(cnd_aors_n_OBJECTS) $(cnd_aors_n_DEPENDENCIES) $(EXTRA_cnd_aors_n_DEPENDENCIES)
@rm -f cnd_aors_n$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(cnd_aors_n_OBJECTS) $(cnd_aors_n_LDADD) $(LIBS)
copy$(EXEEXT): $(copy_OBJECTS) $(copy_DEPENDENCIES) $(EXTRA_copy_DEPENDENCIES)
@rm -f copy$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(copy_OBJECTS) $(copy_LDADD) $(LIBS)
divmod_1$(EXEEXT): $(divmod_1_OBJECTS) $(divmod_1_DEPENDENCIES) $(EXTRA_divmod_1_DEPENDENCIES)
@rm -f divmod_1$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(divmod_1_OBJECTS) $(divmod_1_LDADD) $(LIBS)
divrem$(EXEEXT): $(divrem_OBJECTS) $(divrem_DEPENDENCIES) $(EXTRA_divrem_DEPENDENCIES)
@rm -f divrem$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(divrem_OBJECTS) $(divrem_LDADD) $(LIBS)
logops_n$(EXEEXT): $(logops_n_OBJECTS) $(logops_n_DEPENDENCIES) $(EXTRA_logops_n_DEPENDENCIES)
@rm -f logops_n$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(logops_n_OBJECTS) $(logops_n_LDADD) $(LIBS)
mul_N$(EXEEXT): $(mul_N_OBJECTS) $(mul_N_DEPENDENCIES) $(EXTRA_mul_N_DEPENDENCIES)
@rm -f mul_N$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(mul_N_OBJECTS) $(mul_N_LDADD) $(LIBS)
primes$(EXEEXT): $(primes_OBJECTS) $(primes_DEPENDENCIES) $(EXTRA_primes_DEPENDENCIES) primes$(EXEEXT): $(primes_OBJECTS) $(primes_DEPENDENCIES) $(EXTRA_primes_DEPENDENCIES)
@rm -f primes$(EXEEXT) @rm -f primes$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(primes_OBJECTS) $(primes_LDADD) $(LIBS) $(AM_V_CCLD)$(LINK) $(primes_OBJECTS) $(primes_LDADD) $(LIBS)
shift$(EXEEXT): $(shift_OBJECTS) $(shift_DEPENDENCIES) $(EXTRA_shift_DEPENDENCIES)
@rm -f shift$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(shift_OBJECTS) $(shift_LDADD) $(LIBS)
sqrtrem_1_2$(EXEEXT): $(sqrtrem_1_2_OBJECTS) $(sqrtrem_1_2_DEPENDENCIES) $(EXTRA_sqrtrem_1_2_DEPENDENCIES) sqrtrem_1_2$(EXEEXT): $(sqrtrem_1_2_OBJECTS) $(sqrtrem_1_2_DEPENDENCIES) $(EXTRA_sqrtrem_1_2_DEPENDENCIES)
@rm -f sqrtrem_1_2$(EXEEXT) @rm -f sqrtrem_1_2$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(sqrtrem_1_2_OBJECTS) $(sqrtrem_1_2_LDADD) $(LIBS) $(AM_V_CCLD)$(LINK) $(sqrtrem_1_2_OBJECTS) $(sqrtrem_1_2_LDADD) $(LIBS)
test-add_ssaaaa$(EXEEXT): $(test_add_ssaaaa_OBJECTS) $(test_add_ssaaaa_DEPENDENCIES) $(EXTRA_test_add_ssaaaa_DEPENDENCIES)
@rm -f test-add_ssaaaa$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(test_add_ssaaaa_OBJECTS) $(test_add_ssaaaa_LDADD) $(LIBS)
test-sub_ddmmss$(EXEEXT): $(test_sub_ddmmss_OBJECTS) $(test_sub_ddmmss_DEPENDENCIES) $(EXTRA_test_sub_ddmmss_DEPENDENCIES)
@rm -f test-sub_ddmmss$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(test_sub_ddmmss_OBJECTS) $(test_sub_ddmmss_LDADD) $(LIBS)
try$(EXEEXT): $(try_OBJECTS) $(try_DEPENDENCIES) $(EXTRA_try_DEPENDENCIES) try$(EXEEXT): $(try_OBJECTS) $(try_DEPENDENCIES) $(EXTRA_try_DEPENDENCIES)
@rm -f try$(EXEEXT) @rm -f try$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(try_OBJECTS) $(try_LDADD) $(LIBS) $(AM_V_CCLD)$(LINK) $(try_OBJECTS) $(try_LDADD) $(LIBS)
tst-addsub$(EXEEXT): $(tst_addsub_OBJECTS) $(tst_addsub_DEPENDENCIES) $(EXTRA_tst_addsub_DEPENDENCIES)
@rm -f tst-addsub$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(tst_addsub_OBJECTS) $(tst_addsub_LDADD) $(LIBS)
mostlyclean-compile: mostlyclean-compile:
-rm -f *.$(OBJEXT) -rm -f *.$(OBJEXT)
@ -743,6 +659,15 @@ allprogs: $(EXTRA_PROGRAMS)
$(top_builddir)/tests/libtests.la: $(top_builddir)/tests/libtests.la:
cd $(top_builddir)/tests; $(MAKE) $(AM_MAKEFLAGS) libtests.la cd $(top_builddir)/tests; $(MAKE) $(AM_MAKEFLAGS) libtests.la
test-add_ssaaaa.c: gen-test-longlong_h$(EXEEXT_FOR_BUILD)
./gen-test-longlong_h add >test-add_ssaaaa.c || (rm -f test-add_ssaaaa.c; exit 1)
test-sub_ddmmss.c: gen-test-longlong_h$(EXEEXT_FOR_BUILD)
./gen-test-longlong_h sub >test-sub_ddmmss.c || (rm -f test-sub_ddmmss.c; exit 1)
gen-test-longlong_h$(EXEEXT_FOR_BUILD): gen-test-longlong_h.c
$(CC_FOR_BUILD) `test -f 'gen-test-longlong_h.c' || echo '$(srcdir)/'`gen-test-longlong_h.c -o gen-test-longlong_h$(EXEEXT_FOR_BUILD)
# Tell versions [3.59,3.63) of GNU make to not export all variables. # 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. # Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT: .NOEXPORT:

View File

@ -1,272 +0,0 @@
/*
Copyright 1996-2002, 2004, 2007 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 <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "gmp-impl.h"
#include "longlong.h"
#if defined (USG) || defined (__SVR4) || defined (_UNICOS) || defined (__hpux)
#include <time.h>
int
cputime ()
{
if (CLOCKS_PER_SEC < 100000)
return clock () * 1000 / CLOCKS_PER_SEC;
return clock () / (CLOCKS_PER_SEC / 1000);
}
#else
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
int
cputime ()
{
struct rusage rus;
getrusage (0, &rus);
return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000;
}
#endif
#ifndef NOCHECK
static void print_posneg (mp_limb_t);
#endif
#ifdef PRINT
static void mpn_print (mp_ptr, mp_size_t);
#endif
#define LXW ((int) (2 * sizeof (mp_limb_t)))
#define M * 1000000
#ifndef CLOCK
#error "Don't know CLOCK of your machine"
#endif
#ifndef OPS
#define OPS (CLOCK/5)
#endif
#ifndef SIZE
#define SIZE 496
#endif
#ifndef TIMES
#define TIMES OPS/(SIZE+1)
#endif
#if N == 2
#define mpn_addmul_N mpn_addmul_2
#elif N == 3
#define mpn_addmul_N mpn_addmul_3
#elif N == 4
#define mpn_addmul_N mpn_addmul_4
#elif N == 5
#define mpn_addmul_N mpn_addmul_5
#elif N == 6
#define mpn_addmul_N mpn_addmul_6
#elif N == 7
#define mpn_addmul_N mpn_addmul_7
#elif N == 8
#define mpn_addmul_N mpn_addmul_8
#endif
mp_limb_t
refmpn_addmul_N (mp_ptr rp, mp_srcptr up, mp_size_t n, mp_srcptr vp)
{
int i;
for (i = 1; i < N; i++)
{
rp[n] = mpn_addmul_1 (rp, up, n, *vp);
rp++;
vp++;
}
return mpn_addmul_1 (rp, up, n, *vp);
}
int
main (int argc, char **argv)
{
mp_limb_t up[SIZE];
mp_limb_t ref[SIZE + N - 1];
mp_limb_t mem[SIZE + N + 1];
mp_ptr rp = mem + 1;
mp_limb_t vp[N];
mp_limb_t cy_ref, cy_try;
int i;
#if TIMES != 1
long t0, t;
double cyc;
#endif
unsigned test;
mp_size_t size;
unsigned ntests;
ntests = ~(unsigned) 0;
if (argc == 2)
ntests = strtol (argv[1], 0, 0);
for (test = 1; test <= ntests; test++)
{
#if TIMES == 1 && ! defined (PRINT)
if (test % (CLOCK / SIZE / 1000) == 0)
{
printf ("\r%u", test);
fflush (stdout);
}
#endif
#ifdef RANDOM
size = random () % (SIZE - N + 1) + N;
#else
size = SIZE;
#endif
rp[size + N - 1] = 0x12345678;
rp[-1] = 0x87654321;
mpn_random (vp, N);
#if TIMES != 1 /* run timing tests unless asked not to */
mpn_random (up, size);
mpn_random (rp, size + N - 1);
MPN_COPY (ref, rp, size + N - 1);
t0 = cputime();
for (i = 0; i < TIMES; i++)
mpn_addmul_N (ref, up, size, vp);
t = cputime() - t0;
cyc = ((double) t * CLOCK) / (TIMES * size * 1000.0) / N;
printf ("mpn_addmul_%d: %5ldms (%.3f cycles/limb) [%.2f Gb/s]\n",
N, t, cyc, CLOCK/cyc*GMP_LIMB_BITS*GMP_LIMB_BITS/1e9);
#endif
#ifdef PLAIN_RANDOM
#define MPN_RANDOM mpn_random
#else
#define MPN_RANDOM mpn_random2
#endif
#ifdef ZEROu
MPN_ZERO (up, size);
#else
MPN_RANDOM (up, size);
#endif
MPN_RANDOM (vp, N);
#ifdef ZERO
MPN_ZERO (rp, size + N - 1);
#else
MPN_RANDOM (rp, size + N - 1);
#endif
#if defined (PRINT) || defined (PRINTV)
printf ("vp=");
mpn_print (vp, N);
#endif
#ifdef PRINT
printf ("%*s ", 3 + N * LXW, "");
mpn_print (rp, size);
printf ("%*s ", 3 + N * LXW, "");
mpn_print (up, size);
#endif
MPN_COPY (ref, rp, size + N - 1);
cy_ref = refmpn_addmul_N (ref, up, size, vp);
cy_try = mpn_addmul_N (rp, up, size, vp);
#ifdef PRINT
printf ("%*lX ", LXW, cy_ref);
mpn_print (ref, size + N - 1);
printf ("%*lX ", LXW, cy_try);
mpn_print (rp, size + N - 1);
#endif
#ifndef NOCHECK
if (cy_ref != cy_try || mpn_cmp (ref, rp, size + N - 1) != 0
|| rp[size + N - 1] != 0x12345678 || rp[-1] != 0x87654321)
{
printf ("\n ref%*s try%*s diff\n", LXW - 3, "", 2 * LXW - 6, "");
for (i = 0; i < size + N - 1; i++)
{
printf ("%6d: ", i);
printf ("%0*llX ", LXW, (unsigned long long) ref[i]);
printf ("%0*llX ", LXW, (unsigned long long) rp[i]);
print_posneg (rp[i] - ref[i]);
printf ("\n");
}
printf ("retval: ");
printf ("%0*llX ", LXW, (unsigned long long) cy_ref);
printf ("%0*llX ", LXW, (unsigned long long) cy_try);
print_posneg (cy_try - cy_ref);
printf ("\n");
if (rp[-1] != 0x87654321)
printf ("clobbered at low end\n");
if (rp[size + N - 1] != 0x12345678)
printf ("clobbered at high end\n");
printf ("TEST NUMBER %u\n", test);
abort();
}
#endif
}
exit (0);
}
#ifndef NOCHECK
static void
print_posneg (mp_limb_t d)
{
char buf[LXW + 2];
if (d == 0)
printf (" %*X", LXW, 0);
else if (-d < d)
{
sprintf (buf, "%llX", (unsigned long long) -d);
printf ("%*s-%s", LXW - (int) strlen (buf), "", buf);
}
else
{
sprintf (buf, "%llX", (unsigned long long) d);
printf ("%*s+%s", LXW - (int) strlen (buf), "", buf);
}
}
#endif
#ifdef PRINT
static void
mpn_print (mp_ptr p, mp_size_t size)
{
mp_size_t i;
for (i = size - 1; i >= 0; i--)
{
#ifdef _LONG_LONG_LIMB
printf ("%0*lX%0*lX", (int) (sizeof(mp_limb_t)),
(unsigned long) (p[i] >> (GMP_LIMB_BITS/2)),
(int) (sizeof(mp_limb_t)), (unsigned long) (p[i]));
#else
printf ("%0*lX", LXW, p[i]);
#endif
#ifdef SPACE
if (i != 0)
printf (" ");
#endif
}
puts ("");
}
#endif

View File

@ -1,255 +0,0 @@
/*
Copyright 1996-2002, 2004, 2006-2008 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 <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "gmp-impl.h"
#include "longlong.h"
#include "tests/tests.h"
#ifdef OPERATION_mul_1
#define func __gmpn_mul_1
#define reffunc refmpn_mul_1
#define funcname "mpn_mul_1"
#endif
#ifdef OPERATION_addmul_1
#define func __gmpn_addmul_1
#define reffunc refmpn_addmul_1
#define funcname "mpn_addmul_1"
#endif
#ifdef OPERATION_submul_1
#define func __gmpn_submul_1
#define reffunc refmpn_submul_1
#define funcname "mpn_submul_1"
#endif
#if defined (USG) || defined (__SVR4) || defined (_UNICOS) || defined (__hpux)
#include <time.h>
int
cputime ()
{
if (CLOCKS_PER_SEC < 100000)
return clock () * 1000 / CLOCKS_PER_SEC;
return clock () / (CLOCKS_PER_SEC / 1000);
}
#else
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
int
cputime ()
{
struct rusage rus;
getrusage (0, &rus);
return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000;
}
#endif
static void print_posneg (mp_limb_t);
static void mpn_print (mp_ptr, mp_size_t);
#define LXW ((int) (2 * sizeof (mp_limb_t)))
#define M * 1000000
#ifndef CLOCK
#error "Don't know CLOCK of your machine"
#endif
#ifndef OPS
#define OPS (CLOCK/5)
#endif
#ifndef SIZE
#define SIZE 496
#endif
#ifndef TIMES
#define TIMES OPS/(SIZE+1)
#endif
int
main (int argc, char **argv)
{
mp_ptr s1, ref, rp;
mp_limb_t cy_ref, cy_try;
int i;
long t0, t;
unsigned int test;
mp_limb_t xlimb;
mp_size_t size;
double cyc;
unsigned int ntests;
s1 = malloc (SIZE * sizeof (mp_limb_t));
ref = malloc (SIZE * sizeof (mp_limb_t));
rp = malloc ((SIZE + 2) * sizeof (mp_limb_t));
rp++;
ntests = ~(unsigned) 0;
if (argc == 2)
ntests = strtol (argv[1], 0, 0);
for (test = 1; test <= ntests; test++)
{
#if TIMES == 1 && ! defined (PRINT)
if (test % (1 + 0x80000 / (SIZE + 20)) == 0)
{
printf ("\r%u", test);
fflush (stdout);
}
#endif
#ifdef PLAIN_RANDOM
#define MPN_RANDOM mpn_random
#else
#define MPN_RANDOM mpn_random2
#endif
#ifdef RANDOM
size = random () % SIZE + 1;
#else
size = SIZE;
#endif
rp[-1] = 0x87654321;
rp[size] = 0x12345678;
#ifdef FIXED_XLIMB
xlimb = FIXED_XLIMB;
#else
MPN_RANDOM (&xlimb, 1);
#endif
#if TIMES != 1
mpn_random (s1, size);
mpn_random (rp, size);
MPN_COPY (ref, rp, size);
t0 = cputime();
for (i = 0; i < TIMES; i++)
func (ref, s1, size, xlimb);
t = cputime() - t0;
cyc = ((double) t * CLOCK) / (TIMES * size * 1000.0);
printf (funcname ": %5ldms (%.3f cycles/limb) [%.2f Gb/s]\n",
t, cyc,
CLOCK/cyc*GMP_LIMB_BITS*GMP_LIMB_BITS/1e9);
#endif
#ifndef NOCHECK
MPN_RANDOM (s1, size);
#ifdef ZERO
memset (rp, 0, size * sizeof *rp);
#else
MPN_RANDOM (rp, size);
#endif
#if defined (PRINT) || defined (XPRINT)
printf ("xlimb=");
mpn_print (&xlimb, 1);
#endif
#ifdef PRINT
#ifndef OPERATION_mul_1
printf ("%*s ", (int) (2 * sizeof(mp_limb_t)), "");
mpn_print (rp, size);
#endif
printf ("%*s ", (int) (2 * sizeof(mp_limb_t)), "");
mpn_print (s1, size);
#endif
MPN_COPY (ref, rp, size);
cy_ref = reffunc (ref, s1, size, xlimb);
cy_try = func (rp, s1, size, xlimb);
#ifdef PRINT
mpn_print (&cy_ref, 1);
mpn_print (ref, size);
mpn_print (&cy_try, 1);
mpn_print (rp, size);
#endif
if (cy_ref != cy_try || mpn_cmp (ref, rp, size) != 0
|| rp[-1] != 0x87654321 || rp[size] != 0x12345678)
{
printf ("\n ref%*s try%*s diff\n", LXW - 3, "", 2 * LXW - 6, "");
for (i = 0; i < size; i++)
{
printf ("%6d: ", i);
printf ("%0*llX ", LXW, (unsigned long long) ref[i]);
printf ("%0*llX ", LXW, (unsigned long long) rp[i]);
print_posneg (rp[i] - ref[i]);
printf ("\n");
}
printf ("retval: ");
printf ("%0*llX ", LXW, (unsigned long long) cy_ref);
printf ("%0*llX ", LXW, (unsigned long long) cy_try);
print_posneg (cy_try - cy_ref);
printf ("\n");
if (rp[-1] != 0x87654321)
printf ("clobbered at low end\n");
if (rp[size] != 0x12345678)
printf ("clobbered at high end\n");
printf ("TEST NUMBER %u\n", test);
abort();
}
#endif
}
exit (0);
}
static void
print_posneg (mp_limb_t d)
{
char buf[LXW + 2];
if (d == 0)
printf (" %*X", LXW, 0);
else if (-d < d)
{
sprintf (buf, "%llX", (unsigned long long) -d);
printf ("%*s-%s", LXW - (int) strlen (buf), "", buf);
}
else
{
sprintf (buf, "%llX", (unsigned long long) d);
printf ("%*s+%s", LXW - (int) strlen (buf), "", buf);
}
}
static void
mpn_print (mp_ptr p, mp_size_t size)
{
mp_size_t i;
for (i = size - 1; i >= 0; i--)
{
#ifdef _LONG_LONG_LIMB
printf ("%0*lX%0*lX", (int) (sizeof(mp_limb_t)),
(unsigned long) (p[i] >> (GMP_LIMB_BITS/2)),
(int) (sizeof(mp_limb_t)), (unsigned long) (p[i]));
#else
printf ("%0*lX", (int) (2 * sizeof(mp_limb_t)), p[i]);
#endif
#ifdef SPACE
if (i != 0)
printf (" ");
#endif
}
puts ("");
}

View File

@ -1,262 +0,0 @@
/*
Copyright 1996-2004, 2009, 2011 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 <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "gmp-impl.h"
#include "tests.h"
#ifdef OPERATION_add_n
#define func __gmpn_add_n
#define reffunc refmpn_add_n
#define funcname "mpn_add_n"
#endif
#ifdef OPERATION_sub_n
#define func __gmpn_sub_n
#define reffunc refmpn_sub_n
#define funcname "mpn_sub_n"
#endif
#ifdef OPERATION_addlsh1_n
#define func __gmpn_addlsh1_n
#define reffunc refmpn_addlsh1_n
#define funcname "mpn_addlsh1_n"
#endif
#ifdef OPERATION_sublsh1_n
#define func __gmpn_sublsh1_n
#define reffunc refmpn_sublsh1_n
#define funcname "mpn_sublsh1_n"
#endif
#ifdef OPERATION_rsh1add_n
#define func __gmpn_rsh1add_n
#define reffunc refmpn_rsh1add_n
#define funcname "mpn_rsh1add_n"
#endif
#ifdef OPERATION_rsh1sub_n
#define func __gmpn_rsh1sub_n
#define reffunc refmpn_rsh1sub_n
#define funcname "mpn_rsh1sub_n"
#endif
#if defined (USG) || defined (__SVR4) || defined (_UNICOS) || defined (__hpux)
#include <time.h>
int
cputime ()
{
if (CLOCKS_PER_SEC < 100000)
return clock () * 1000 / CLOCKS_PER_SEC;
return clock () / (CLOCKS_PER_SEC / 1000);
}
#else
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
int
cputime ()
{
struct rusage rus;
getrusage (0, &rus);
return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000;
}
#endif
static void print_posneg (mp_limb_t);
static void mpn_print (mp_ptr, mp_size_t);
#define LXW ((int) (2 * sizeof (mp_limb_t)))
#define M * 1000000
#ifndef CLOCK
#error "Don't know CLOCK of your machine"
#endif
#ifndef OPS
#define OPS (CLOCK/5)
#endif
#ifndef SIZE
#define SIZE 328
#endif
#ifndef TIMES
#define TIMES OPS/(SIZE+1)
#endif
int
main (int argc, char **argv)
{
mp_ptr s1, s2, dx, dy;
mp_limb_t cyx, cyy;
int i;
#if TIMES != 1
long t0, t;
#endif
unsigned int test;
mp_size_t size;
unsigned int ntests;
s1 = malloc (SIZE * sizeof (mp_limb_t));
s2 = malloc (SIZE * sizeof (mp_limb_t));
dx = malloc ((SIZE + 2) * sizeof (mp_limb_t));
dy = malloc ((SIZE + 2) * sizeof (mp_limb_t));
ntests = ~(unsigned) 0;
if (argc == 2)
ntests = strtol (argv[1], 0, 0);
for (test = 1; test <= ntests; test++)
{
#if TIMES == 1 && ! defined (PRINT)
if (test % (SIZE > 100000 ? 1 : 100000 / SIZE) == 0)
{
printf ("\r%u", test);
fflush (stdout);
}
#endif
#ifdef RANDOM
size = random () % SIZE + 1;
#else
size = SIZE;
#endif
dx[0] = 0x87654321;
dy[0] = 0x87654321;
dx[size+1] = 0x12345678;
dy[size+1] = 0x12345678;
#if TIMES != 1
mpn_random (s1, size);
mpn_random (s2, size);
t0 = cputime();
for (i = 0; i < TIMES; i++)
func (dx+1, s1, s2, size);
t = cputime() - t0;
printf (funcname ": %5ldms (%.3f cycles/limb)\n",
t, ((double) t * CLOCK) / (TIMES * size * 1000.0));
#endif
#ifndef NOCHECK
mpn_random2 (s1, size);
mpn_random2 (s2, size);
#ifdef PRINT
mpn_print (s1, size);
mpn_print (s2, size);
#endif
/* Put garbage in the destination. */
for (i = 0; i < size; i++)
{
dx[i+1] = 0xdead;
dy[i+1] = 0xbeef;
}
cyx = reffunc (dx+1, s1, s2, size);
cyy = func (dy+1, s1, s2, size);
#ifdef PRINT
mpn_print (&cyx, 1);
mpn_print (dx+1, size);
mpn_print (&cyy, 1);
mpn_print (dy+1, size);
#endif
if (cyx != cyy || mpn_cmp (dx, dy, size+2) != 0
|| dx[0] != 0x87654321 || dx[size+1] != 0x12345678)
{
mp_size_t s, e;
for (s = 0;; s++)
if ((unsigned long long) (dx+1)[s] != (unsigned long long) (dy+1)[s])
break;
for (e = size - 1;; e--)
if ((unsigned long long) (dx+1)[e] != (unsigned long long) (dy+1)[e])
break;
#ifndef PRINT
for (i = s; i <= e; i++)
{
printf ("%6d: ", i);
printf ("%0*llX ", LXW, (unsigned long long) (dx+1)[i]);
printf ("%0*llX ", LXW, (unsigned long long) (dy+1)[i]);
print_posneg ((dy+1)[i] - (dx+1)[i]);
printf ("\n");
}
printf ("%6s: ", "retval");
printf ("%0*llX ", LXW, (unsigned long long) cyx);
printf ("%0*llX ", LXW, (unsigned long long) cyy);
print_posneg (cyx - cyy);
#endif
printf ("\n");
if (dy[0] != 0x87654321)
printf ("clobbered at low end\n");
if (dy[size+1] != 0x12345678)
printf ("clobbered at high end\n");
printf ("TEST NUMBER %u\n", test);
abort();
}
#endif
}
exit (0);
}
static void
print_posneg (mp_limb_t d)
{
char buf[LXW + 2];
if (d == 0)
printf (" %*X", LXW, 0);
else if (-d < d)
{
sprintf (buf, "%llX", (unsigned long long) -d);
printf ("%*s-%s", LXW - (int) strlen (buf), "", buf);
}
else
{
sprintf (buf, "%llX", (unsigned long long) d);
printf ("%*s+%s", LXW - (int) strlen (buf), "", buf);
}
}
static void
mpn_print (mp_ptr p, mp_size_t size)
{
mp_size_t i;
for (i = size - 1; i >= 0; i--)
{
#ifdef _LONG_LONG_LIMB
printf ("%0*lX%0*lX", (int) (sizeof(mp_limb_t)),
(unsigned long) (p[i] >> (GMP_LIMB_BITS/2)),
(int) (sizeof(mp_limb_t)), (unsigned long) (p[i]));
#else
printf ("%0*lX", (int) (2 * sizeof(mp_limb_t)), p[i]);
#endif
#ifdef SPACE
if (i != 0)
printf (" ");
#endif
}
puts ("");
}

View File

@ -1,257 +0,0 @@
/*
Copyright 1996-2004, 2009, 2011 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 <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "gmp-impl.h"
#include "tests/tests.h"
#ifdef OPERATION_cnd_add_n
#define func __gmpn_cnd_add_n
#define reffunc refmpn_cnd_add_n
#define funcname "mpn_cnd_add_n"
#endif
#ifdef OPERATION_cnd_sub_n
#define func __gmpn_cnd_sub_n
#define reffunc refmpn_cnd_sub_n
#define funcname "mpn_cnd_sub_n"
#endif
#if defined (USG) || defined (__SVR4) || defined (_UNICOS) || defined (__hpux)
#include <time.h>
int
cputime ()
{
if (CLOCKS_PER_SEC < 100000)
return clock () * 1000 / CLOCKS_PER_SEC;
return clock () / (CLOCKS_PER_SEC / 1000);
}
#else
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
int
cputime ()
{
struct rusage rus;
getrusage (0, &rus);
return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000;
}
#endif
static void print_posneg (mp_limb_t);
static void mpn_print (mp_ptr, mp_size_t);
#define LXW ((int) (2 * sizeof (mp_limb_t)))
#define M * 1000000
#ifndef CLOCK
#error "Don't know CLOCK of your machine"
#endif
#ifndef OPS
#define OPS (CLOCK/5)
#endif
#ifndef SIZE
#define SIZE 328
#endif
#ifndef TIMES
#define TIMES OPS/(SIZE+1)
#endif
int
main (int argc, char **argv)
{
mp_ptr s1, s2, dx, dy;
mp_limb_t cyx, cyy;
int i;
#if TIMES != 1
long t0, t;
#endif
unsigned int test;
mp_size_t size;
unsigned int ntests;
s1 = malloc ((SIZE + 2) * sizeof (mp_limb_t));
s2 = malloc ((SIZE + 2) * sizeof (mp_limb_t));
dx = malloc ((SIZE + 2) * sizeof (mp_limb_t));
dy = malloc ((SIZE + 2) * sizeof (mp_limb_t));
s1 += 1;
s2 += 1;
ntests = ~(unsigned) 0;
if (argc == 2)
ntests = strtol (argv[1], 0, 0);
for (test = 1; test <= ntests; test++)
{
#if TIMES == 1 && ! defined (PRINT)
if (test % (SIZE > 100000 ? 1 : 100000 / SIZE) == 0)
{
printf ("\r%u", test);
fflush (stdout);
}
#endif
#ifdef PLAIN_RANDOM
#define MPN_RANDOM mpn_random
#else
#define MPN_RANDOM mpn_random2
#endif
#ifdef RANDOM
size = random () % SIZE + 1;
#else
size = SIZE;
#endif
dx[0] = 0x87654321;
dy[0] = 0x87654321;
dx[size+1] = 0x12345678;
dy[size+1] = 0x12345678;
#if TIMES != 1
mpn_random (s1 - 1, size + 2);
mpn_random (s2 - 1, size + 2);
t0 = cputime();
for (i = 0; i < TIMES; i++)
func (i & 1, dx+1, s1, s2, size);
t = cputime() - t0;
printf (funcname ": %5ldms (%.3f cycles/limb)\n",
t, ((double) t * CLOCK) / (TIMES * size * 1000.0));
#endif
#ifndef NOCHECK
#ifndef ZEROup
MPN_RANDOM (s1 - 1, size + 2);
#else
MPN_ZERO (s1, size);
#endif
#ifndef ZEROvp
MPN_RANDOM (s2 - 1, size + 2);
#else
MPN_ZERO (s2, size);
#endif
#ifdef PRINT
mpn_print (s1, size);
mpn_print (s2, size);
#endif
/* Put garbage in the destination. */
for (i = 0; i < size; i++)
{
dx[i+1] = 0xdead;
dy[i+1] = 0xbeef;
}
int cond = random() & 1;
cyx = reffunc (cond, dx+1, s1, s2, size);
cyy = func (cond, dy+1, s1, s2, size);
#ifdef PRINT
mpn_print (&cyx, 1);
mpn_print (dx+1, size);
mpn_print (&cyy, 1);
mpn_print (dy+1, size);
#endif
if (cyx != cyy || mpn_cmp (dx, dy, size+2) != 0
|| dx[0] != 0x87654321 || dx[size+1] != 0x12345678)
{
mp_size_t s, e;
for (s = 0;; s++)
if ((unsigned long long) (dx+1)[s] != (unsigned long long) (dy+1)[s])
break;
for (e = size - 1;; e--)
if ((unsigned long long) (dx+1)[e] != (unsigned long long) (dy+1)[e])
break;
#ifndef PRINT
for (i = s; i <= e; i++)
{
printf ("%6d: ", i);
printf ("%0*llX ", LXW, (unsigned long long) (dx+1)[i]);
printf ("%0*llX ", LXW, (unsigned long long) (dy+1)[i]);
print_posneg ((dy+1)[i] - (dx+1)[i]);
printf ("\n");
}
printf ("%6s: ", "retval");
printf ("%0*llX ", LXW, (unsigned long long) cyx);
printf ("%0*llX ", LXW, (unsigned long long) cyy);
print_posneg (cyx - cyy);
#endif
printf ("\n");
if (dy[0] != 0x87654321)
printf ("clobbered at low end\n");
if (dy[size+1] != 0x12345678)
printf ("clobbered at high end\n");
printf ("TEST NUMBER %u\n", test);
abort();
}
#endif
}
exit (0);
}
static void
print_posneg (mp_limb_t d)
{
char buf[LXW + 2];
if (d == 0)
printf (" %*X", LXW, 0);
else if (-d < d)
{
sprintf (buf, "%llX", (unsigned long long) -d);
printf ("%*s-%s", LXW - (int) strlen (buf), "", buf);
}
else
{
sprintf (buf, "%llX", (unsigned long long) d);
printf ("%*s+%s", LXW - (int) strlen (buf), "", buf);
}
}
static void
mpn_print (mp_ptr p, mp_size_t size)
{
mp_size_t i;
for (i = size - 1; i >= 0; i--)
{
#ifdef _LONG_LONG_LIMB
printf ("%0*lX%0*lX", (int) (sizeof(mp_limb_t)),
(unsigned long) (p[i] >> (GMP_LIMB_BITS/2)),
(int) (sizeof(mp_limb_t)), (unsigned long) (p[i]));
#else
printf ("%0*lX", (int) (2 * sizeof(mp_limb_t)), p[i]);
#endif
#ifdef SPACE
if (i != 0)
printf (" ");
#endif
}
puts ("");
}

View File

@ -1,225 +0,0 @@
/*
Copyright 1999-2001, 2004, 2009, 2011 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 <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "gmp-impl.h"
#include "tests.h"
#ifdef OPERATION_copyi
#define func MPN_COPY_INCR
#define reffunc refmpn_copyi
#define funcname "MPN_COPY_INCR"
#endif
#ifdef OPERATION_copyd
#define func MPN_COPY_DECR
#define reffunc refmpn_copyd
#define funcname "MPN_COPY_DECR"
#endif
#if defined (USG) || defined (__SVR4) || defined (_UNICOS) || defined (__hpux)
#include <time.h>
int
cputime ()
{
if (CLOCKS_PER_SEC < 100000)
return clock () * 1000 / CLOCKS_PER_SEC;
return clock () / (CLOCKS_PER_SEC / 1000);
}
#else
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
int
cputime ()
{
struct rusage rus;
getrusage (0, &rus);
return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000;
}
#endif
static void print_posneg (mp_limb_t);
static void mpn_print (mp_ptr, mp_size_t);
#define LXW ((int) (2 * sizeof (mp_limb_t)))
#define M * 1000000
#ifndef CLOCK
#error "Don't know CLOCK of your machine"
#endif
#ifndef OPS
#define OPS (CLOCK/5)
#endif
#ifndef SIZE
#define SIZE 496
#endif
#ifndef TIMES
#define TIMES OPS/(SIZE+1)
#endif
int
main (int argc, char **argv)
{
mp_ptr s1, dx, dy;
int i;
long t0, t;
unsigned int test;
mp_size_t size;
unsigned int ntests;
s1 = malloc (SIZE * sizeof (mp_limb_t));
dx = malloc ((SIZE + 2) * sizeof (mp_limb_t));
dy = malloc ((SIZE + 2) * sizeof (mp_limb_t));
ntests = ~(unsigned) 0;
if (argc == 2)
ntests = strtol (argv[1], 0, 0);
for (test = 1; test <= ntests; test++)
{
#if TIMES == 1 && ! defined (PRINT)
if (test % (SIZE > 100000 ? 1 : 100000 / SIZE) == 0)
{
printf ("\r%u", test);
fflush (stdout);
}
#endif
#ifdef RANDOM
size = random () % SIZE + 1;
#else
size = SIZE;
#endif
dx[0] = 0x87654321;
dy[0] = 0x87654321;
dx[size+1] = 0x12345678;
dy[size+1] = 0x12345678;
#if TIMES != 1
mpn_random (s1, size);
t0 = cputime();
for (i = 0; i < TIMES; i++)
func (dx+1, s1, size);
t = cputime() - t0;
printf (funcname ": %5ldms (%.3f cycles/limb)\n",
t, ((double) t * CLOCK) / (TIMES * size * 1000.0));
#endif
#ifndef NOCHECK
mpn_random2 (s1, size);
#ifdef PRINT
mpn_print (s1, size);
#endif
/* Put garbage in the destination. */
for (i = 0; i < size; i++)
{
dx[i+1] = 0xdead;
dy[i+1] = 0xbeef;
}
reffunc (dx+1, s1, size);
func (dy+1, s1, size);
#ifdef PRINT
mpn_print (dx+1, size);
mpn_print (dy+1, size);
#endif
if (mpn_cmp (dx, dy, size+2) != 0
|| dx[0] != 0x87654321 || dx[size+1] != 0x12345678)
{
mp_size_t s, e;
for (s = 0;; s++)
if ((unsigned long long) (dx+1)[s] != (unsigned long long) (dy+1)[s])
break;
for (e = size - 1;; e--)
if ((unsigned long long) (dx+1)[e] != (unsigned long long) (dy+1)[e])
break;
#ifndef PRINT
for (i = s; i <= e; i++)
{
printf ("%6d: ", i);
printf ("%0*llX ", LXW, (unsigned long long) (dx+1)[i]);
printf ("%0*llX ", LXW, (unsigned long long) (dy+1)[i]);
print_posneg ((dy+1)[i] - (dx+1)[i]);
printf ("\n");
}
#endif
printf ("\n");
if (dy[0] != 0x87654321)
printf ("clobbered at low end\n");
if (dy[size+1] != 0x12345678)
printf ("clobbered at high end\n");
printf ("TEST NUMBER %u\n", test);
abort();
}
#endif
}
exit (0);
}
static void
print_posneg (mp_limb_t d)
{
char buf[LXW + 2];
if (d == 0)
printf (" %*X", LXW, 0);
else if (-d < d)
{
sprintf (buf, "%llX", (unsigned long long) -d);
printf ("%*s-%s", LXW - (int) strlen (buf), "", buf);
}
else
{
sprintf (buf, "%llX", (unsigned long long) d);
printf ("%*s+%s", LXW - (int) strlen (buf), "", buf);
}
}
static void
mpn_print (mp_ptr p, mp_size_t size)
{
mp_size_t i;
for (i = size - 1; i >= 0; i--)
{
#ifdef _LONG_LONG_LIMB
printf ("%0*lX%0*lX", (int) (sizeof(mp_limb_t)),
(unsigned long) (p[i] >> (GMP_LIMB_BITS/2)),
(int) (sizeof(mp_limb_t)), (unsigned long) (p[i]));
#else
printf ("%0*lX", (int) (2 * sizeof(mp_limb_t)), p[i]);
#endif
#ifdef SPACE
if (i != 0)
printf (" ");
#endif
}
puts ("");
}

View File

@ -1,199 +0,0 @@
/*
Copyright 1996, 1998, 2000, 2001, 2007 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 (USG) || defined (__SVR4) || defined (_UNICOS) || defined (__hpux)
#include <time.h>
int
cputime ()
{
if (CLOCKS_PER_SEC < 100000)
return clock () * 1000 / CLOCKS_PER_SEC;
return clock () / (CLOCKS_PER_SEC / 1000);
}
#else
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
int
cputime ()
{
struct rusage rus;
getrusage (0, &rus);
return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000;
}
#endif
static void mpn_print (mp_ptr, mp_size_t);
#define M * 1000000
#ifndef CLOCK
#error "Don't know CLOCK of your machine"
#endif
#ifndef OPS
#define OPS 20000000
#endif
#ifndef SIZE
#define SIZE 1000
#endif
#ifndef TIMES
#define TIMES OPS/SIZE
#endif
#ifndef FSIZE
#define FSIZE SIZE
#endif
int
main ()
{
mp_limb_t np[SIZE];
mp_limb_t dx[SIZE + FSIZE + 2];
mp_limb_t dy[SIZE + FSIZE + 2];
mp_limb_t dlimb;
mp_size_t nn, fn;
mp_limb_t retx, rety;
int test;
#if TIMES != 1
int i;
long t0, t;
double cyc;
#endif
for (test = 0; ; test++)
{
#if TIMES == 1 && ! defined (PRINT)
if (test % (SIZE > 100000 ? 1 : 100000 / SIZE) == 0)
{
printf ("\r%u", test);
fflush (stdout);
}
#endif
#ifdef RANDOM
nn = random () % (SIZE + 1);
fn = random () % (FSIZE + 1);
#else
nn = SIZE;
fn = FSIZE;
#endif
dx[0] = 0x87654321;
dx[nn + fn + 1] = 0x12345678;
dy[0] = 0x87654321;
dy[nn + fn + 1] = 0x12345678;
mpn_random2 (np, nn);
#ifdef FIXED_DLIMB
dlimb = FIXED_DLIMB;
#else
do
{
mpn_random2 (&dlimb, 1);
#ifdef FORCE_NORM
dlimb |= GMP_NUMB_HIGHBIT;
#endif
#ifdef FORCE_UNNORM
dlimb &= GMP_NUMB_MAX >> 1;
#endif
}
while (dlimb == 0);
#endif
#if defined (PRINT) || defined (XPRINT)
printf ("N=");
mpn_print (np, nn);
printf ("D=");
mpn_print (&dlimb, 1);
printf ("nn=%ld\n", (long) nn);
#endif
#if TIMES != 1
t0 = cputime();
for (i = 0; i < TIMES; i++)
mpn_divrem_1 (dx + 1, 0L, np, nn, dlimb);
t = cputime() - t0;
cyc = ((double) t * CLOCK) / (TIMES * nn * 1000.0);
printf ("mpn_divrem_1 int: %5ldms (%.3f cycles/limb) [%.2f Gb/s]\n",
t, cyc,
CLOCK/cyc*GMP_LIMB_BITS*GMP_LIMB_BITS/1e9);
t0 = cputime();
for (i = 0; i < TIMES; i++)
mpn_divrem_1 (dx + 1, fn, np, 0, dlimb);
t = cputime() - t0;
cyc = ((double) t * CLOCK) / (TIMES * fn * 1000.0);
printf ("mpn_divrem_1 frac: %5ldms (%.3f cycles/limb) [%.2f Gb/s]\n",
t, cyc,
CLOCK/cyc*GMP_LIMB_BITS*GMP_LIMB_BITS/1e9);
#endif
retx = refmpn_divrem_1 (dx + 1, fn, np, nn, dlimb);
rety = mpn_divrem_1 (dy + 1, fn, np, nn, dlimb);
#ifndef NOCHECK
if (retx != rety || mpn_cmp (dx, dy, fn + nn + 2) != 0)
{
printf ("ERROR in test %d, nn=%ld, fn=%ld\n", test, nn, fn);
mpn_print (np, nn);
mpn_print (&dlimb, 1);
printf ("rq: ");
mpn_print (dx + 1, nn + fn);
printf ("rr: %*lX\n", (int) (2 * sizeof(mp_limb_t)), retx);
printf (" q: ");
mpn_print (dy + 1, nn + fn);
printf (" r: %*lX\n", (int) (2 * sizeof(mp_limb_t)), rety);
if (dy[0] != 0x87654321)
printf ("clobbered at low end %*lX\n", (int) (2 * sizeof(mp_limb_t)), dy[0]);
if (dy[nn + fn + 1] != 0x12345678)
printf ("clobbered at high end\n");
abort ();
}
#endif
}
}
static void
mpn_print (mp_ptr p, mp_size_t size)
{
mp_size_t i;
for (i = size - 1; i >= 0; i--)
{
#ifdef _LONG_LONG_LIMB
printf ("%0*lX%0*lX", (int) (sizeof(mp_limb_t)),
(unsigned long) (p[i] >> (GMP_LIMB_BITS/2)),
(int) (sizeof(mp_limb_t)), (unsigned long) (p[i]));
#else
printf ("%0*lX", (int) (2 * sizeof(mp_limb_t)), p[i]);
#endif
#ifdef SPACE
if (i != 0)
printf (" ");
#endif
}
puts ("");
}

View File

@ -1,118 +0,0 @@
/*
Copyright 1996-1998, 2000, 2001, 2007, 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"
#if defined (USG) || defined (__SVR4) || defined (_UNICOS) || defined (__hpux)
#include <time.h>
int
cputime ()
{
if (CLOCKS_PER_SEC < 100000)
return clock () * 1000 / CLOCKS_PER_SEC;
return clock () / (CLOCKS_PER_SEC / 1000);
}
#else
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
int
cputime ()
{
struct rusage rus;
getrusage (0, &rus);
return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000;
}
#endif
#define M * 1000000
#ifndef CLOCK
#error "Don't know CLOCK of your machine"
#endif
#ifndef OPS
#define OPS 20000000
#endif
#ifndef SIZE
#define SIZE 100
#endif
#ifndef TIMES
#define TIMES OPS/(SIZE+1)
#endif
int
main ()
{
mp_limb_t nptr[2 * SIZE];
mp_limb_t dptr[2 * SIZE];
mp_limb_t qptr[2 * SIZE];
mp_limb_t pptr[2 * SIZE + 1];
mp_limb_t rptr[2 * SIZE];
mp_size_t nsize, dsize, qsize, rsize, psize;
int test;
mp_limb_t qlimb;
for (test = 0; ; test++)
{
printf ("%d\n", test);
#ifdef RANDOM
nsize = random () % (2 * SIZE) + 1;
dsize = random () % nsize + 1;
#else
nsize = 2 * SIZE;
dsize = SIZE;
#endif
mpn_random2 (nptr, nsize);
mpn_random2 (dptr, dsize);
dptr[dsize - 1] |= (mp_limb_t) 1 << (GMP_LIMB_BITS - 1);
MPN_COPY (rptr, nptr, nsize);
qlimb = mpn_divrem (qptr, (mp_size_t) 0, rptr, nsize, dptr, dsize);
rsize = dsize;
qsize = nsize - dsize;
qptr[qsize] = qlimb;
qsize += qlimb;
if (qsize == 0 || qsize > 2 * SIZE)
{
continue; /* bogus */
}
else
{
mp_limb_t cy;
if (qsize > dsize)
mpn_mul (pptr, qptr, qsize, dptr, dsize);
else
mpn_mul (pptr, dptr, dsize, qptr, qsize);
psize = qsize + dsize;
psize -= pptr[psize - 1] == 0;
cy = mpn_add (pptr, pptr, psize, rptr, rsize);
pptr[psize] = cy;
psize += cy;
}
if (nsize != psize || mpn_cmp (nptr, pptr, nsize) != 0)
abort ();
}
}

View File

@ -0,0 +1,140 @@
/*
Copyright 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 <stdlib.h>
#include <string.h>
#include <stdio.h>
typedef unsigned long mp_limb_t; /* neat */
void
one (const char *op, size_t ind, mp_limb_t m0, mp_limb_t s0)
{
printf ("static void f%zu(mp_limb_t*r1p,mp_limb_t*r0p){", ind);
printf ("mp_limb_t r1,r0;");
printf ("%s(r1,r0,0,%ld,0,%ld);", op, (long) m0, (long) s0);
printf ("*r1p=r1;*r0p=r0;");
printf ("}\n");
}
mp_limb_t ops[1000];
enum what_t {ADD, SUB};
int
main (int argc, char **argv)
{
size_t n_operands = 0;
size_t n_functions = 0;
const char *op;
enum what_t what;
if (argc == 2 && strcmp (argv[1], "add") == 0)
{
op = "add_ssaaaa";
what = ADD;
}
else if (argc == 2 && strcmp (argv[1], "sub") == 0)
{
op = "sub_ddmmss";
what = SUB;
}
else
{
fprintf (stderr, "what do yuo want me to do?\n");
exit (1);
}
for (int i = 0; i < 16; i++)
{
ops[n_operands++] = 1 << i;
ops[n_operands++] = -(1 << i);
ops[n_operands++] = (1 << i) - 1;
ops[n_operands++] = -(1 << i) - 1;
}
printf ("#include <stdlib.h>\n");
printf ("#include <stdio.h>\n");
printf ("#include \"gmp-impl.h\"\n");
printf ("#include \"longlong.h\"\n");
/* Print out ops[] definition. */
printf ("static const int ops[%zu] = {\n", n_operands);
for (int i = 0; i < n_operands; i++)
{
printf ("%ld,", (long) ops[i]);
if ((i + 1) % 4 == 0)
puts ("");
}
printf ("};\n");
/* Generate functions and print them. */
for (int i = 0; i < n_operands; i++)
{
for (int j = 0; j < n_operands; j++)
{
one (op, n_functions++, ops[i], ops[j]);
}
}
/* Print out function pointer table. */
printf ("typedef void (*func_t) (mp_limb_t*, mp_limb_t*);\n");
printf ("static const func_t funcs[%zu] = {\n", n_functions);
for (size_t i = 0; i < n_functions; i++)
{
printf ("f%zu,", i);
if ((i + 1) % 16 == 0)
puts ("");
}
printf ("};\n");
/* Print out table of reference results. */
printf ("static const int ref[%zu][2] = {\n", n_functions);
for (int i = 0; i < n_operands; i++)
{
for (int j = 0; j < n_operands; j++)
{
if (what == ADD)
printf ("{%6ld,%2ld},", (long) ( ops[i] + ops[j]), (long) ((mp_limb_t) ((ops[i] + ops[j]) < ops[i])));
else /* SUB */
printf ("{%6ld,%2ld},", (long) ( ops[i] - ops[j]), (long) (-(mp_limb_t) (ops[i] < ops[j])));
if ((i * n_operands + j) % 8 == 0)
puts ("");
}
}
printf ("};\n");
printf ("int main ()\n{\n");
printf (" mp_limb_t r1, r0;\n");
printf (" int err = 0;\n");
printf (" size_t ind = 0;\n");
printf (" for (size_t i = 0; i < %zu; i++)\n", n_functions);
printf (" {\n");
printf (" int ii = i / %zu, jj = i %% %zu;\n", n_operands, n_operands);
printf (" funcs[i](&r1, &r0);\n");
printf (" if (r0 != (mp_limb_signed_t) ref[ind][0] || r1 != (mp_limb_signed_t) ref[ind][1]) {\n");
printf (" printf (\"error for f%%zu(%%d,%%d): want (%%d,%%d) got (%%d,%%d)\\n\", i, (int) ops[ii], (int) ops[jj], ref[ind][1], ref[ind][0], (int) r1, (int) r0);\n");
printf (" err++;\n");
printf (" }\n");
printf (" ind++;\n");
printf (" }\n");
printf (" return err != 0;\n");
printf ("}\n");
return 0;
}

View File

@ -1,229 +0,0 @@
/*
Copyright 1996-2004, 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 <stdlib.h>
#include <stdio.h>
#include "gmp-impl.h"
#include "tests.h"
#ifdef OPERATION_and_n
#define func __gmpn_and_n
#define reffunc refmpn_and_n
#define funcname "mpn_and_n"
#endif
#ifdef OPERATION_andn_n
#define func __gmpn_andn_n
#define reffunc refmpn_andn_n
#define funcname "mpn_andn_n"
#endif
#ifdef OPERATION_nand_n
#define func __gmpn_nand_n
#define reffunc refmpn_nand_n
#define funcname "mpn_nand_n"
#endif
#ifdef OPERATION_ior_n
#define func __gmpn_ior_n
#define reffunc refmpn_ior_n
#define funcname "mpn_ior_n"
#endif
#ifdef OPERATION_iorn_n
#define func __gmpn_iorn_n
#define reffunc refmpn_iorn_n
#define funcname "mpn_iorn_n"
#endif
#ifdef OPERATION_nior_n
#define func __gmpn_nior_n
#define reffunc refmpn_nior_n
#define funcname "mpn_nior_n"
#endif
#ifdef OPERATION_xor_n
#define func __gmpn_xor_n
#define reffunc refmpn_xor_n
#define funcname "mpn_xor_n"
#endif
#ifdef OPERATION_xnor_n
#define func __gmpn_xnor_n
#define reffunc refmpn_xnor_n
#define funcname "mpn_xnor_n"
#endif
#if defined (USG) || defined (__SVR4) || defined (_UNICOS) || defined (__hpux)
#include <time.h>
int
cputime ()
{
if (CLOCKS_PER_SEC < 100000)
return clock () * 1000 / CLOCKS_PER_SEC;
return clock () / (CLOCKS_PER_SEC / 1000);
}
#else
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
int
cputime ()
{
struct rusage rus;
getrusage (0, &rus);
return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000;
}
#endif
static void mpn_print (mp_ptr, mp_size_t);
#define M * 1000000
#ifndef CLOCK
#error "Don't know CLOCK of your machine"
#endif
#ifndef OPS
#define OPS (CLOCK/5)
#endif
#ifndef SIZE
#define SIZE 328
#endif
#ifndef TIMES
#define TIMES OPS/(SIZE+1)
#endif
int
main (int argc, char **argv)
{
mp_ptr s1, s2, dx, dy;
int i;
long t0, t;
unsigned int test;
mp_size_t size;
unsigned int ntests;
s1 = malloc (SIZE * sizeof (mp_limb_t));
s2 = malloc (SIZE * sizeof (mp_limb_t));
dx = malloc ((SIZE + 2) * sizeof (mp_limb_t));
dy = malloc ((SIZE + 2) * sizeof (mp_limb_t));
ntests = ~(unsigned) 0;
if (argc == 2)
ntests = strtol (argv[1], 0, 0);
for (test = 1; test <= ntests; test++)
{
#if TIMES == 1 && ! defined (PRINT)
if (test % (SIZE > 100000 ? 1 : 100000 / SIZE) == 0)
{
printf ("\r%d", test);
fflush (stdout);
}
#endif
#ifdef RANDOM
size = random () % SIZE + 1;
#else
size = SIZE;
#endif
dx[0] = 0x87654321;
dy[0] = 0x87654321;
dx[size+1] = 0x12345678;
dy[size+1] = 0x12345678;
#if TIMES != 1
mpn_random (s1, size);
mpn_random (s2, size);
t0 = cputime();
for (i = 0; i < TIMES; i++)
func (dx+1, s1, s2, size);
t = cputime() - t0;
printf (funcname ": %5ldms (%.3f cycles/limb)\n",
t, ((double) t * CLOCK) / (TIMES * size * 1000.0));
#endif
#ifndef NOCHECK
mpn_random2 (s1, size);
mpn_random2 (s2, size);
#ifdef PRINT
mpn_print (s1, size);
mpn_print (s2, size);
#endif
/* Put garbage in the destination. */
for (i = 0; i < size; i++)
{
dx[i+1] = 0xdead;
dy[i+1] = 0xbeef;
}
reffunc (dx+1, s1, s2, size);
func (dy+1, s1, s2, size);
#ifdef PRINT
mpn_print (dx+1, size);
mpn_print (dy+1, size);
#endif
if (mpn_cmp (dx, dy, size+2) != 0
|| dx[0] != 0x87654321 || dx[size+1] != 0x12345678)
{
#ifndef PRINT
mpn_print (dx+1, size);
mpn_print (dy+1, size);
#endif
printf ("\n");
if (dy[0] != 0x87654321)
printf ("clobbered at low end\n");
if (dy[size+1] != 0x12345678)
printf ("clobbered at high end\n");
printf ("TEST NUMBER %u\n", test);
abort();
}
#endif
}
exit (0);
}
static void
mpn_print (mp_ptr p, mp_size_t size)
{
mp_size_t i;
for (i = size - 1; i >= 0; i--)
{
#ifdef _LONG_LONG_LIMB
printf ("%0*lX%0*lX", (int) (sizeof(mp_limb_t)),
(unsigned long) (p[i] >> (GMP_LIMB_BITS/2)),
(int) (sizeof(mp_limb_t)), (unsigned long) (p[i]));
#else
printf ("%0*lX", (int) (2 * sizeof(mp_limb_t)), p[i]);
#endif
#ifdef SPACE
if (i != 0)
printf (" ");
#endif
}
puts ("");
}

View File

@ -1,270 +0,0 @@
/*
Copyright 1996-2002, 2004, 2007 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 <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "gmp-impl.h"
#include "longlong.h"
#if defined (USG) || defined (__SVR4) || defined (_UNICOS) || defined (__hpux)
#include <time.h>
int
cputime ()
{
if (CLOCKS_PER_SEC < 100000)
return clock () * 1000 / CLOCKS_PER_SEC;
return clock () / (CLOCKS_PER_SEC / 1000);
}
#else
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
int
cputime ()
{
struct rusage rus;
getrusage (0, &rus);
return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000;
}
#endif
#ifndef NOCHECK
static void print_posneg (mp_limb_t);
#endif
#ifdef PRINT
static void mpn_print (mp_ptr, mp_size_t);
#endif
#define LXW ((int) (2 * sizeof (mp_limb_t)))
#define M * 1000000
#ifndef CLOCK
#error "Don't know CLOCK of your machine"
#endif
#ifndef OPS
#define OPS (CLOCK/5)
#endif
#ifndef SIZE
#define SIZE 496
#endif
#ifndef TIMES
#define TIMES OPS/(SIZE+1)
#endif
#if N == 2
#define mpn_mul_N mpn_mul_2
#elif N == 3
#define mpn_mul_N mpn_mul_3
#elif N == 4
#define mpn_mul_N mpn_mul_4
#elif N == 5
#define mpn_mul_N mpn_mul_5
#elif N == 6
#define mpn_mul_N mpn_mul_6
#elif N == 7
#define mpn_mul_N mpn_mul_7
#elif N == 8
#define mpn_mul_N mpn_mul_8
#endif
mp_limb_t
refmpn_mul_N (mp_ptr rp, mp_srcptr up, mp_size_t n, mp_srcptr vp)
{
int i;
rp[n] = mpn_mul_1 (rp, up, n, *vp);
rp++;
vp++;
for (i = 2; i < N; i++)
{
rp[n] = mpn_addmul_1 (rp, up, n, *vp);
rp++;
vp++;
}
return mpn_addmul_1 (rp, up, n, *vp);
}
int
main (int argc, char **argv)
{
mp_limb_t up[SIZE];
mp_limb_t ref[SIZE + N - 1];
mp_limb_t mem[SIZE + N + 1];
mp_ptr rp = mem + 1;
mp_limb_t vp[N];
mp_limb_t cy_ref, cy_try;
int i;
#if TIMES != 1
long t0, t;
double cyc;
#endif
unsigned test;
mp_size_t size;
unsigned ntests;
ntests = ~(unsigned) 0;
if (argc == 2)
ntests = strtol (argv[1], 0, 0);
for (test = 1; test <= ntests; test++)
{
#if TIMES == 1 && ! defined (PRINT)
if (test % (CLOCK / SIZE / 1000) == 0)
{
printf ("\r%u", test);
fflush (stdout);
}
#endif
#ifdef RANDOM
size = random () % (SIZE - N + 1) + N;
#else
size = SIZE;
#endif
rp[size + N - 1] = 0x12345678;
rp[-1] = 0x87654321;
mpn_random (vp, N);
#if TIMES != 1 /* run timing tests unless asked not to */
mpn_random (up, size);
MPN_COPY (ref, rp, size + N - 1);
t0 = cputime();
for (i = 0; i < TIMES; i++)
mpn_mul_N (ref, up, size, vp);
t = cputime() - t0;
cyc = ((double) t * CLOCK) / (TIMES * size * 1000.0) / N;
printf ("mpn_mul_%d: %5ldms (%.3f cycles/limb) [%.2f Gb/s]\n",
N, t, cyc, CLOCK/cyc*GMP_LIMB_BITS*GMP_LIMB_BITS/1e9);
#endif
#ifdef PLAIN_RANDOM
#define MPN_RANDOM mpn_random
#else
#define MPN_RANDOM mpn_random2
#endif
#ifdef ZEROu
MPN_ZERO (up, size);
#else
MPN_RANDOM (up, size);
#endif
MPN_RANDOM (vp, N);
/* vp[0] = vp[1] = vp[2] = vp[3] = vp[4] = vp[5] = 0; */
MPN_RANDOM (rp, size + N - 1);
#if defined (PRINT) || defined (PRINTV)
printf ("vp=");
mpn_print (vp, N);
#endif
#ifdef PRINT
printf ("%*s ", 3 + N * LXW, "");
mpn_print (up, size);
#endif
MPN_COPY (ref, rp, size + N - 1);
cy_ref = refmpn_mul_N (ref, up, size, vp);
cy_try = mpn_mul_N (rp, up, size, vp);
#ifdef PRINT
printf ("%*lX ", LXW, cy_ref);
mpn_print (ref, size + N - 1);
printf ("%*lX ", LXW, cy_try);
mpn_print (rp, size + N - 1);
#endif
#ifndef NOCHECK
if (cy_ref != cy_try || mpn_cmp (ref, rp, size + N - 1) != 0
// if (cy_ref != cy_try || mpn_cmp (ref + 5, rp + 5, size + N - 1 - 6) != 0
|| rp[size + N - 1] != 0x12345678 || rp[-1] != 0x87654321)
{
printf ("\n ref%*s try%*s diff\n", LXW - 3, "", 2 * LXW - 6, "");
for (i = 0; i < size + N - 1; i++)
{
printf ("%6d: ", i);
printf ("%0*llX ", LXW, (unsigned long long) ref[i]);
printf ("%0*llX ", LXW, (unsigned long long) rp[i]);
print_posneg (rp[i] - ref[i]);
printf ("\n");
}
printf ("retval: ");
printf ("%0*llX ", LXW, (unsigned long long) cy_ref);
printf ("%0*llX ", LXW, (unsigned long long) cy_try);
print_posneg (cy_try - cy_ref);
printf ("\n");
if (rp[-1] != 0x87654321)
printf ("clobbered at low end\n");
if (rp[size + N - 1] != 0x12345678)
printf ("clobbered at high end\n");
printf ("TEST NUMBER %u\n", test);
abort();
}
#endif
}
exit (0);
}
#ifndef NOCHECK
static void
print_posneg (mp_limb_t d)
{
char buf[LXW + 2];
if (d == 0)
printf (" %*X", LXW, 0);
else if (-d < d)
{
sprintf (buf, "%llX", (unsigned long long) -d);
printf ("%*s-%s", LXW - (int) strlen (buf), "", buf);
}
else
{
sprintf (buf, "%llX", (unsigned long long) d);
printf ("%*s+%s", LXW - (int) strlen (buf), "", buf);
}
}
#endif
#ifdef PRINT
static void
mpn_print (mp_ptr p, mp_size_t size)
{
mp_size_t i;
for (i = size - 1; i >= 0; i--)
{
#ifdef _LONG_LONG_LIMB
printf ("%0*lX%0*lX", (int) (sizeof(mp_limb_t)),
(unsigned long) (p[i] >> (GMP_LIMB_BITS/2)),
(int) (sizeof(mp_limb_t)), (unsigned long) (p[i]));
#else
printf ("%0*lX", LXW, p[i]);
#endif
#ifdef SPACE
if (i != 0)
printf (" ");
#endif
}
puts ("");
}
#endif

View File

@ -1,244 +0,0 @@
/*
Copyright 1996, 1998-2001, 2004, 2007, 2009, 2011 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 <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "gmp-impl.h"
#include "tests.h"
#ifdef OPERATION_lshift
#define func __gmpn_lshift
#define reffunc refmpn_lshift
#define funcname "mpn_lshift"
#endif
#ifdef OPERATION_rshift
#define func __gmpn_rshift
#define reffunc refmpn_rshift
#define funcname "mpn_rshift"
#endif
#if defined (USG) || defined (__SVR4) || defined (_UNICOS) || defined (__hpux)
#include <time.h>
int
cputime ()
{
if (CLOCKS_PER_SEC < 100000)
return clock () * 1000 / CLOCKS_PER_SEC;
return clock () / (CLOCKS_PER_SEC / 1000);
}
#else
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
int
cputime ()
{
struct rusage rus;
getrusage (0, &rus);
return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000;
}
#endif
static void print_posneg (mp_limb_t);
static void mpn_print (mp_ptr, mp_size_t);
#define LXW ((int) (2 * sizeof (mp_limb_t)))
#define M * 1000000
#ifndef CLOCK
#error "Don't know CLOCK of your machine"
#endif
#ifndef OPS
#define OPS (CLOCK/5)
#endif
#ifndef SIZE
#define SIZE 496
#endif
#ifndef TIMES
#define TIMES OPS/(SIZE+1)
#endif
#ifndef CNT
int CNT = 4;
#endif
int
main (int argc, char **argv)
{
mp_ptr s1, dx, dy;
mp_limb_t cyx, cyy;
int i;
long t0, t;
unsigned int test;
int cnt = CNT;
mp_size_t size;
unsigned int ntests;
s1 = malloc (SIZE * sizeof (mp_limb_t));
dx = malloc ((SIZE + 2) * sizeof (mp_limb_t));
dy = malloc ((SIZE + 2) * sizeof (mp_limb_t));
ntests = ~(unsigned) 0;
if (argc == 2)
ntests = strtol (argv[1], 0, 0);
for (test = 1; test <= ntests; test++)
{
#if TIMES == 1 && ! defined (PRINT)
if (test % (SIZE > 100000 ? 1 : 100000 / SIZE) == 0)
{
printf ("\r%u", test);
fflush (stdout);
}
#endif
#if TIMES == 1
cnt = random () % (GMP_NUMB_BITS - 1) + 1;
#endif
#ifdef RANDOM
size = random () % SIZE + 1;
#else
size = SIZE;
#endif
dx[0] = 0x87654321;
dy[0] = 0x87654321;
dx[size+1] = 0x12345678;
dy[size+1] = 0x12345678;
#if TIMES != 1
mpn_random (s1, size);
t0 = cputime();
for (i = 0; i < TIMES; i++)
func (dx+1, s1, size, cnt);
t = cputime() - t0;
printf (funcname ": %5ldms (%.3f cycles/limb)\n",
t, ((double) t * CLOCK) / (TIMES * size * 1000.0));
#endif
#ifndef NOCHECK
mpn_random (s1, size);
#ifdef PRINT
printf ("cnt=%-*d ", (int) (2 * sizeof(mp_limb_t)) - 4, cnt);
mpn_print (s1, size);
#endif
/* Put garbage in the destination. */
for (i = 0; i < size; i++)
{
dx[i+1] = 0xdead;
dy[i+1] = 0xbeef;
}
cyx = reffunc (dx+1, s1, size, cnt);
cyy = func (dy+1, s1, size, cnt);
#ifdef PRINT
mpn_print (&cyx, 1);
mpn_print (dx+1, size);
mpn_print (&cyy, 1);
mpn_print (dy+1, size);
#endif
if (cyx != cyy || mpn_cmp (dx, dy, size+2) != 0
|| dx[0] != 0x87654321 || dx[size+1] != 0x12345678)
{
mp_size_t s, e;
for (s = 0;; s++)
if ((unsigned long long) (dx+1)[s] != (unsigned long long) (dy+1)[s])
break;
for (e = size - 1;; e--)
if ((unsigned long long) (dx+1)[e] != (unsigned long long) (dy+1)[e])
break;
#ifndef PRINT
printf ("cnt=%-*d\n", (int) (2 * sizeof(mp_limb_t)) - 4, cnt);
for (i = s; i <= e; i++)
{
printf ("%6d: ", i);
printf ("%0*llX ", LXW, (unsigned long long) (dx+1)[i]);
printf ("%0*llX ", LXW, (unsigned long long) (dy+1)[i]);
print_posneg ((dy+1)[i] - (dx+1)[i]);
printf ("\n");
}
printf ("%6s: ", "retval");
printf ("%0*llX ", LXW, (unsigned long long) cyx);
printf ("%0*llX ", LXW, (unsigned long long) cyy);
print_posneg (cyx - cyy);
#endif
printf ("\n");
if (dy[0] != 0x87654321)
printf ("clobbered at low end\n");
if (dy[size+1] != 0x12345678)
printf ("clobbered at high end\n");
printf ("TEST NUMBER %u\n", test);
abort();
}
#endif
}
exit (0);
}
static void
print_posneg (mp_limb_t d)
{
char buf[LXW + 2];
if (d == 0)
printf (" %*X", LXW, 0);
else if (-d < d)
{
sprintf (buf, "%llX", (unsigned long long) -d);
printf ("%*s-%s", LXW - (int) strlen (buf), "", buf);
}
else
{
sprintf (buf, "%llX", (unsigned long long) d);
printf ("%*s+%s", LXW - (int) strlen (buf), "", buf);
}
}
static void
mpn_print (mp_ptr p, mp_size_t size)
{
mp_size_t i;
for (i = size - 1; i >= 0; i--)
{
#ifdef _LONG_LONG_LIMB
printf ("%0*lX%0*lX", (int) (sizeof(mp_limb_t)),
(unsigned long) (p[i] >> (GMP_LIMB_BITS/2)),
(int) (sizeof(mp_limb_t)), (unsigned long) (p[i]));
#else
printf ("%0*lX", (int) (2 * sizeof(mp_limb_t)), p[i]);
#endif
#ifdef SPACE
if (i != 0)
printf (" ");
#endif
}
puts ("");
}

View File

@ -1,97 +0,0 @@
/* 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"
#define ADD 1
#define SUB 2
#ifndef METHOD
#define METHOD ADD
#endif
#if METHOD == ADD
#define REFCALL refmpn_add_n
#define TESTCALL mpn_add_n
#endif
#if METHOD == SUB
#define REFCALL refmpn_sub_n
#define TESTCALL mpn_sub_n
#endif
#define SIZE 100
int
main (int argc, char **argv)
{
mp_size_t alloc_size, max_size, size, i, cumul_size;
mp_ptr s1, s2, dx, dy;
int s1_align, s2_align, d_align;
long pass, n_passes;
mp_limb_t cx, cy;
max_size = SIZE;
n_passes = 1000000;
argc--; argv++;
if (argc)
{
max_size = atol (*argv);
argc--; argv++;
}
alloc_size = max_size + 32;
s1 = malloc (alloc_size * GMP_LIMB_BYTES);
s2 = malloc (alloc_size * GMP_LIMB_BYTES);
dx = malloc (alloc_size * GMP_LIMB_BYTES);
dy = malloc (alloc_size * GMP_LIMB_BYTES);
cumul_size = 0;
for (pass = 0; pass < n_passes; pass++)
{
size = random () % max_size + 1;
cumul_size += size;
if (cumul_size >= 1000000)
{
cumul_size -= 1000000;
printf ("\r%ld", pass); fflush (stdout);
}
s1_align = random () % 32;
s2_align = random () % 32;
d_align = random () % 32;
mpn_random2 (s1 + s1_align, size);
mpn_random2 (s2 + s2_align, size);
for (i = 0; i < alloc_size; i++)
dx[i] = dy[i] = i + 0x9876500;
cx = TESTCALL (dx + d_align, s1 + s1_align, s2 + s2_align, size);
cy = REFCALL (dy + d_align, s1 + s1_align, s2 + s2_align, size);
if (cx != cy || mpn_cmp (dx, dy, alloc_size) != 0)
abort ();
}
printf ("%ld passes OK\n", n_passes);
exit (0);
}

View File

@ -49,10 +49,17 @@ void
tests_start (void) tests_start (void)
{ {
char version[10]; char version[10];
snprintf (version, 10, "%u.%u.%u", #if __STDC_VERSION__ >= 199901L
snprintf (version, sizeof version, "%u.%u.%u",
__GNU_MP_VERSION, __GNU_MP_VERSION,
__GNU_MP_VERSION_MINOR, __GNU_MP_VERSION_MINOR,
__GNU_MP_VERSION_PATCHLEVEL); __GNU_MP_VERSION_PATCHLEVEL);
#else
sprintf (version, "%u.%u.%u",
__GNU_MP_VERSION,
__GNU_MP_VERSION_MINOR,
__GNU_MP_VERSION_PATCHLEVEL);
#endif
if (strcmp (gmp_version, version) != 0) if (strcmp (gmp_version, version) != 0)
{ {

View File

@ -1,6 +1,6 @@
/* Test locale support, or attempt to do so. /* Test locale support, or attempt to do so.
Copyright 2001, 2002, 2011, 2014 Free Software Foundation, Inc. Copyright 2001, 2002, 2011, 2014, 2020 Free Software Foundation, Inc.
This file is part of the GNU MP Library test suite. This file is part of the GNU MP Library test suite.
@ -57,7 +57,7 @@ localeconv (void)
#endif #endif
/* Replace the libc nl_langinfo with one we can manipulate. */ /* Replace the libc nl_langinfo with one we can manipulate. */
#if HAVE_NL_LANGINFO #if HAVE_NL_LANGINFO && ! defined __TERMUX__
char * char *
nl_langinfo (nl_item n) nl_langinfo (nl_item n)
#if defined __cplusplus && defined __GLIBC__ #if defined __cplusplus && defined __GLIBC__

View File

@ -1,6 +1,6 @@
/* Test mpf_get_str and mpf_set_str. /* Test mpf_get_str and mpf_set_str.
Copyright 1996, 2000, 2001, 2008, 2019 Free Software Foundation, Inc. Copyright 1996, 2000, 2001, 2008, 2019, 2020 Free Software Foundation, Inc.
This file is part of the GNU MP Library test suite. This file is part of the GNU MP Library test suite.
@ -138,7 +138,7 @@ main (int argc, char **argv)
if (mpf_cmp (x, y) != 0) if (mpf_cmp (x, y) != 0)
abort (); abort ();
mpf_set_str (y, "0", 10); mpf_set_str (y, " 0", 10);
mpf_set_str (x, "00000000000000000000000000000000000000000000000000000", 10); mpf_set_str (x, "00000000000000000000000000000000000000000000000000000", 10);
MPF_CHECK_FORMAT (x); MPF_CHECK_FORMAT (x);
if (mpf_cmp (x, y) != 0) if (mpf_cmp (x, y) != 0)
@ -160,7 +160,6 @@ main (int argc, char **argv)
if (mpf_cmp (x, y) != 0) if (mpf_cmp (x, y) != 0)
abort (); abort ();
mpf_set_str (y, "0", 16);
mpf_set_str (x, "00000000000000000000000000000000000000000000000000000", 16); mpf_set_str (x, "00000000000000000000000000000000000000000000000000000", 16);
MPF_CHECK_FORMAT (x); MPF_CHECK_FORMAT (x);
if (mpf_cmp (x, y) != 0) if (mpf_cmp (x, y) != 0)
@ -179,6 +178,26 @@ main (int argc, char **argv)
abort (); abort ();
mpf_set_str (x, "0.000000000000000000000000000000000000000000000000000", 16); mpf_set_str (x, "0.000000000000000000000000000000000000000000000000000", 16);
MPF_CHECK_FORMAT (x); 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) if (mpf_cmp (x, y) != 0)
abort (); abort ();

View File

@ -1,6 +1,6 @@
/* Test mpf_get_d_2exp. /* Test mpf_get_d_2exp.
Copyright 2002, 2003, 2017 Free Software Foundation, Inc. Copyright 2002, 2003, 2017, 2020 Free Software Foundation, Inc.
This file is part of the GNU MP Library test suite. This file is part of the GNU MP Library test suite.
@ -39,6 +39,16 @@ check_data (void)
mpf_init2 (f, 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++) for (exp = -513; exp <= 513; exp++)
{ {
size_t i; size_t i;

View File

@ -1,6 +1,6 @@
/* Test mpf_trunc, mpf_ceil, mpf_floor. /* Test mpf_trunc, mpf_ceil, mpf_floor.
Copyright 2001, 2002 Free Software Foundation, Inc. Copyright 2001, 2002, 2020 Free Software Foundation, Inc.
This file is part of the GNU MP Library test suite. This file is part of the GNU MP Library test suite.
@ -78,7 +78,7 @@ check_one (mpf_srcptr src, mpf_srcptr trunc, mpf_srcptr ceil, mpf_srcptr floor)
/* Can't do these unconditionally in case truncation by mpf_set strips /* Can't do these unconditionally in case truncation by mpf_set strips
some low non-zero limbs which would have rounded the result. */ some low non-zero limbs which would have rounded the result. */
if (ABSIZ(src) <= PREC(trunc)+1) if (mpf_size (src) <= PREC(trunc)+1)
{ {
CHECK_INPLACE ("mpf_ceil", mpf_ceil, ceil); CHECK_INPLACE ("mpf_ceil", mpf_ceil, ceil);
CHECK_INPLACE ("mpf_floor", mpf_floor, floor); CHECK_INPLACE ("mpf_floor", mpf_floor, floor);

View File

@ -80,4 +80,7 @@ main (int argc, char **argv)
mpz_clear (a); mpz_clear (a);
mpz_clear (b); mpz_clear (b);
tests_end ();
return 0;
} }

View File

@ -81,4 +81,7 @@ main (int argc, char **argv)
mpz_clear (a); mpz_clear (a);
mpz_clear (b); mpz_clear (b);
mpz_clear (ref); mpz_clear (ref);
tests_end ();
return 0;
} }

View File

@ -128,4 +128,7 @@ main (int argc, char **argv)
mpz_clear (a); mpz_clear (a);
mpz_clear (b); mpz_clear (b);
tests_end ();
return 0;
} }

View File

@ -24,7 +24,7 @@ LDADD = $(top_builddir)/tests/libtests.la $(top_builddir)/libgmp.la
check_PROGRAMS = reuse t-addsub t-cmp t-mul t-mul_i t-tdiv t-tdiv_ui t-fdiv \ check_PROGRAMS = reuse t-addsub t-cmp t-mul t-mul_i t-tdiv t-tdiv_ui t-fdiv \
t-fdiv_ui t-cdiv_ui t-gcd t-gcd_ui t-lcm t-invert dive dive_ui t-sqrtrem \ t-fdiv_ui t-cdiv_ui t-gcd t-gcd_ui t-lcm t-invert dive dive_ui t-sqrtrem \
convert io t-inp_str logic bit t-powm t-powm_ui t-pow t-div_2exp \ convert io t-inp_str logic t-bit t-powm t-powm_ui t-pow t-div_2exp \
t-root t-perfsqr t-perfpow t-jac t-bin t-get_d t-get_d_2exp t-get_si \ t-root t-perfsqr t-perfpow t-jac t-bin t-get_d t-get_d_2exp t-get_si \
t-set_d t-set_si t-lucm \ t-set_d t-set_si t-lucm \
t-fac_ui t-mfac_uiui t-primorial_ui t-fib_ui t-lucnum_ui t-scan t-fits \ t-fac_ui t-mfac_uiui t-primorial_ui t-fib_ui t-lucnum_ui t-scan t-fits \

View File

@ -110,7 +110,7 @@ check_PROGRAMS = reuse$(EXEEXT) t-addsub$(EXEEXT) t-cmp$(EXEEXT) \
t-cdiv_ui$(EXEEXT) t-gcd$(EXEEXT) t-gcd_ui$(EXEEXT) \ t-cdiv_ui$(EXEEXT) t-gcd$(EXEEXT) t-gcd_ui$(EXEEXT) \
t-lcm$(EXEEXT) t-invert$(EXEEXT) dive$(EXEEXT) \ t-lcm$(EXEEXT) t-invert$(EXEEXT) dive$(EXEEXT) \
dive_ui$(EXEEXT) t-sqrtrem$(EXEEXT) convert$(EXEEXT) \ dive_ui$(EXEEXT) t-sqrtrem$(EXEEXT) convert$(EXEEXT) \
io$(EXEEXT) t-inp_str$(EXEEXT) logic$(EXEEXT) bit$(EXEEXT) \ io$(EXEEXT) t-inp_str$(EXEEXT) logic$(EXEEXT) t-bit$(EXEEXT) \
t-powm$(EXEEXT) t-powm_ui$(EXEEXT) t-pow$(EXEEXT) \ t-powm$(EXEEXT) t-powm_ui$(EXEEXT) t-pow$(EXEEXT) \
t-div_2exp$(EXEEXT) t-root$(EXEEXT) t-perfsqr$(EXEEXT) \ t-div_2exp$(EXEEXT) t-root$(EXEEXT) t-perfsqr$(EXEEXT) \
t-perfpow$(EXEEXT) t-jac$(EXEEXT) t-bin$(EXEEXT) \ t-perfpow$(EXEEXT) t-jac$(EXEEXT) t-bin$(EXEEXT) \
@ -136,20 +136,15 @@ mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES = CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES = CONFIG_CLEAN_VPATH_FILES =
bit_SOURCES = bit.c
bit_OBJECTS = bit.$(OBJEXT)
bit_LDADD = $(LDADD)
bit_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 =
convert_SOURCES = convert.c convert_SOURCES = convert.c
convert_OBJECTS = convert.$(OBJEXT) convert_OBJECTS = convert.$(OBJEXT)
convert_LDADD = $(LDADD) convert_LDADD = $(LDADD)
convert_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ convert_DEPENDENCIES = $(top_builddir)/tests/libtests.la \
$(top_builddir)/libgmp.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 =
dive_SOURCES = dive.c dive_SOURCES = dive.c
dive_OBJECTS = dive.$(OBJEXT) dive_OBJECTS = dive.$(OBJEXT)
dive_LDADD = $(LDADD) dive_LDADD = $(LDADD)
@ -190,6 +185,11 @@ t_bin_OBJECTS = t-bin.$(OBJEXT)
t_bin_LDADD = $(LDADD) t_bin_LDADD = $(LDADD)
t_bin_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ t_bin_DEPENDENCIES = $(top_builddir)/tests/libtests.la \
$(top_builddir)/libgmp.la $(top_builddir)/libgmp.la
t_bit_SOURCES = t-bit.c
t_bit_OBJECTS = t-bit.$(OBJEXT)
t_bit_LDADD = $(LDADD)
t_bit_DEPENDENCIES = $(top_builddir)/tests/libtests.la \
$(top_builddir)/libgmp.la
t_cdiv_ui_SOURCES = t-cdiv_ui.c t_cdiv_ui_SOURCES = t-cdiv_ui.c
t_cdiv_ui_OBJECTS = t-cdiv_ui.$(OBJEXT) t_cdiv_ui_OBJECTS = t-cdiv_ui.$(OBJEXT)
t_cdiv_ui_LDADD = $(LDADD) t_cdiv_ui_LDADD = $(LDADD)
@ -493,8 +493,8 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 = am__v_CCLD_1 =
SOURCES = bit.c convert.c dive.c dive_ui.c io.c logic.c reuse.c \ SOURCES = convert.c dive.c dive_ui.c io.c logic.c reuse.c t-addsub.c \
t-addsub.c t-aorsmul.c t-bin.c t-cdiv_ui.c t-cmp.c t-cmp_d.c \ t-aorsmul.c t-bin.c t-bit.c t-cdiv_ui.c t-cmp.c t-cmp_d.c \
t-cmp_si.c t-cong.c t-cong_2exp.c t-div_2exp.c t-divis.c \ t-cmp_si.c t-cong.c t-cong_2exp.c t-div_2exp.c t-divis.c \
t-divis_2exp.c t-export.c t-fac_ui.c t-fdiv.c t-fdiv_ui.c \ t-divis_2exp.c t-export.c t-fac_ui.c t-fdiv.c t-fdiv_ui.c \
t-fib_ui.c t-fits.c t-gcd.c t-gcd_ui.c t-get_d.c \ t-fib_ui.c t-fits.c t-gcd.c t-gcd_ui.c t-get_d.c \
@ -505,11 +505,11 @@ SOURCES = bit.c convert.c dive.c dive_ui.c io.c logic.c reuse.c \
t-powm.c t-powm_ui.c t-pprime_p.c t-primorial_ui.c t-remove.c \ t-powm.c t-powm_ui.c t-pprime_p.c t-primorial_ui.c t-remove.c \
t-root.c t-scan.c t-set_d.c t-set_f.c t-set_si.c t-set_str.c \ t-root.c t-scan.c t-set_d.c t-set_f.c t-set_si.c t-set_str.c \
t-sizeinbase.c t-sqrtrem.c t-tdiv.c t-tdiv_ui.c t-sizeinbase.c t-sqrtrem.c t-tdiv.c t-tdiv_ui.c
DIST_SOURCES = bit.c convert.c dive.c dive_ui.c io.c logic.c reuse.c \ DIST_SOURCES = convert.c dive.c dive_ui.c io.c logic.c reuse.c \
t-addsub.c t-aorsmul.c t-bin.c t-cdiv_ui.c t-cmp.c t-cmp_d.c \ t-addsub.c t-aorsmul.c t-bin.c t-bit.c t-cdiv_ui.c t-cmp.c \
t-cmp_si.c t-cong.c t-cong_2exp.c t-div_2exp.c t-divis.c \ t-cmp_d.c t-cmp_si.c t-cong.c t-cong_2exp.c t-div_2exp.c \
t-divis_2exp.c t-export.c t-fac_ui.c t-fdiv.c t-fdiv_ui.c \ t-divis.c t-divis_2exp.c t-export.c t-fac_ui.c t-fdiv.c \
t-fib_ui.c t-fits.c t-gcd.c t-gcd_ui.c t-get_d.c \ t-fdiv_ui.c t-fib_ui.c t-fits.c t-gcd.c t-gcd_ui.c t-get_d.c \
t-get_d_2exp.c t-get_si.c t-hamdist.c t-import.c t-inp_str.c \ t-get_d_2exp.c t-get_si.c t-hamdist.c t-import.c t-inp_str.c \
t-invert.c t-io_raw.c t-jac.c t-lcm.c t-limbs.c t-lucm.c \ t-invert.c t-io_raw.c t-jac.c t-lcm.c t-limbs.c t-lucm.c \
t-lucnum_ui.c t-mfac_uiui.c t-mul.c t-mul_i.c t-nextprime.c \ t-lucnum_ui.c t-mfac_uiui.c t-mul.c t-mul_i.c t-nextprime.c \
@ -960,10 +960,6 @@ clean-checkPROGRAMS:
echo " rm -f" $$list; \ echo " rm -f" $$list; \
rm -f $$list rm -f $$list
bit$(EXEEXT): $(bit_OBJECTS) $(bit_DEPENDENCIES) $(EXTRA_bit_DEPENDENCIES)
@rm -f bit$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(bit_OBJECTS) $(bit_LDADD) $(LIBS)
convert$(EXEEXT): $(convert_OBJECTS) $(convert_DEPENDENCIES) $(EXTRA_convert_DEPENDENCIES) convert$(EXEEXT): $(convert_OBJECTS) $(convert_DEPENDENCIES) $(EXTRA_convert_DEPENDENCIES)
@rm -f convert$(EXEEXT) @rm -f convert$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(convert_OBJECTS) $(convert_LDADD) $(LIBS) $(AM_V_CCLD)$(LINK) $(convert_OBJECTS) $(convert_LDADD) $(LIBS)
@ -1000,6 +996,10 @@ t-bin$(EXEEXT): $(t_bin_OBJECTS) $(t_bin_DEPENDENCIES) $(EXTRA_t_bin_DEPENDENCIE
@rm -f t-bin$(EXEEXT) @rm -f t-bin$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(t_bin_OBJECTS) $(t_bin_LDADD) $(LIBS) $(AM_V_CCLD)$(LINK) $(t_bin_OBJECTS) $(t_bin_LDADD) $(LIBS)
t-bit$(EXEEXT): $(t_bit_OBJECTS) $(t_bit_DEPENDENCIES) $(EXTRA_t_bit_DEPENDENCIES)
@rm -f t-bit$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(t_bit_OBJECTS) $(t_bit_LDADD) $(LIBS)
t-cdiv_ui$(EXEEXT): $(t_cdiv_ui_OBJECTS) $(t_cdiv_ui_DEPENDENCIES) $(EXTRA_t_cdiv_ui_DEPENDENCIES) t-cdiv_ui$(EXEEXT): $(t_cdiv_ui_OBJECTS) $(t_cdiv_ui_DEPENDENCIES) $(EXTRA_t_cdiv_ui_DEPENDENCIES)
@rm -f t-cdiv_ui$(EXEEXT) @rm -f t-cdiv_ui$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(t_cdiv_ui_OBJECTS) $(t_cdiv_ui_LDADD) $(LIBS) $(AM_V_CCLD)$(LINK) $(t_cdiv_ui_OBJECTS) $(t_cdiv_ui_LDADD) $(LIBS)
@ -1577,9 +1577,9 @@ logic.log: logic$(EXEEXT)
--log-file $$b.log --trs-file $$b.trs \ --log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT) "$$tst" $(AM_TESTS_FD_REDIRECT)
bit.log: bit$(EXEEXT) t-bit.log: t-bit$(EXEEXT)
@p='bit$(EXEEXT)'; \ @p='t-bit$(EXEEXT)'; \
b='bit'; \ b='t-bit'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \ --log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \

View File

@ -1,7 +1,7 @@
/* Test conversion using mpz_get_str and mpz_set_str. /* Test conversion using mpz_get_str and mpz_set_str.
Copyright 1993, 1994, 1996, 1999-2002, 2006, 2007 Free Software Foundation, Copyright 1993, 1994, 1996, 1999-2002, 2006, 2007, 2020 Free Software
Inc. Foundation, Inc.
This file is part of the GNU MP Library test suite. This file is part of the GNU MP Library test suite.
@ -21,12 +21,14 @@ the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> /* for strlen */ #include <string.h> /* for strlen */
#include <ctype.h> /* for tolower */
#include "gmp-impl.h" #include "gmp-impl.h"
#include "tests.h" #include "tests.h"
void debug_mp (mpz_t, int); void debug_mp (mpz_t, int);
static int str_casecmp (const char *, const char *);
void void
string_urandomb (char *bp, size_t len, int base, gmp_randstate_ptr rands) string_urandomb (char *bp, size_t len, int base, gmp_randstate_ptr rands)
@ -140,7 +142,7 @@ main (int argc, char **argv)
for (bp = buf; bp[0] == '0' && bp[1] != '\0'; bp++) for (bp = buf; bp[0] == '0' && bp[1] != '\0'; bp++)
; ;
if (strcasecmp (str, bp) != 0) if (str_casecmp (str, bp) != 0)
{ {
fprintf (stderr, "ERROR, str and buf different in test %d\n", i); fprintf (stderr, "ERROR, str and buf different in test %d\n", i);
fprintf (stderr, "str = %s\n", str); fprintf (stderr, "str = %s\n", str);
@ -162,6 +164,21 @@ main (int argc, char **argv)
exit (0); exit (0);
} }
/* This is similar to POSIX strcasecmp except that we don't do the comparison
with unsigned char. We avoid strcasecmp for C standard conformance. */
static int
str_casecmp (const char *s1, const char *s2)
{
size_t i;
for (i = 0;; i++)
{
int c1 = s1[i];
int c2 = s2[i];
if (c1 == 0 || tolower (c1) != tolower (c2))
return c1 - c2;
}
}
void void
debug_mp (mpz_t x, int base) debug_mp (mpz_t x, int base)
{ {

View File

@ -1,6 +1,7 @@
/* Test conversion and I/O using mpz_out_str and mpz_inp_str. /* Test conversion and I/O using mpz_out_str and mpz_inp_str.
Copyright 1993, 1994, 1996, 2000, 2001, 2012 Free Software Foundation, Inc. Copyright 1993, 1994, 1996, 2000, 2001, 2012, 2020 Free Software
Foundation, Inc.
This file is part of the GNU MP Library test suite. This file is part of the GNU MP Library test suite.
@ -63,6 +64,18 @@ main (int argc, char **argv)
fp = fopen (FILENAME, "w+"); fp = fopen (FILENAME, "w+");
if (mpz_out_str (fp, 63, op1) != 0)
{
printf ("mpz_out_str did not return 0 (error) with base > 62\n");
abort ();
}
if (mpz_out_str (fp, -37, op1) != 0)
{
printf ("mpz_out_str did not return 0 (error) with base < -37\n");
abort ();
}
for (i = 0; i < reps; i++) for (i = 0; i < reps; i++)
{ {
mpz_urandomb (bs, rands, 32); mpz_urandomb (bs, rands, 32);

View File

@ -6,8 +6,8 @@
mpz_mul_si mpz_mul_si
mpz_addmul_ui (should this really allow a+=a*c?) mpz_addmul_ui (should this really allow a+=a*c?)
Copyright 1996, 1999-2002, 2009, 2012, 2013, 2016 Free Software Foundation, Copyright 1996, 1999-2002, 2009, 2012, 2013, 2016, 2020 Free Software
Inc. Foundation, Inc.
This file is part of the GNU MP Library test suite. This file is part of the GNU MP Library test suite.
@ -174,26 +174,33 @@ struct {
} while (0) } while (0)
void
realloc_if_reducing (mpz_ptr r)
{
if (ABSIZ(r) < ALLOC(r))
_mpz_realloc (r, ABSIZ(r));
}
#define INVOKE_RRS(desc,r1,r2,i1) \ #define INVOKE_RRS(desc,r1,r2,i1) \
do { \ do { \
if (pass & 1) _mpz_realloc (r1, ABSIZ(r1)); \ if (pass & 1) realloc_if_reducing (r1); \
if (pass & 2) _mpz_realloc (r2, ABSIZ(r2)); \ if (pass & 2) realloc_if_reducing (r2); \
(desc).fptr (r1, r2, i1); \ (desc).fptr (r1, r2, i1); \
} while (0) } while (0)
#define INVOKE_RS(desc,r1,i1) \ #define INVOKE_RS(desc,r1,i1) \
do { \ do { \
if (pass & 1) _mpz_realloc (r1, ABSIZ(r1)); \ if (pass & 1) realloc_if_reducing (r1); \
(desc).fptr (r1, i1); \ (desc).fptr (r1, i1); \
} while (0) } while (0)
#define INVOKE_RRSS(desc,r1,r2,i1,i2) \ #define INVOKE_RRSS(desc,r1,r2,i1,i2) \
do { \ do { \
if (pass & 1) _mpz_realloc (r1, ABSIZ(r1)); \ if (pass & 1) realloc_if_reducing (r1); \
if (pass & 2) _mpz_realloc (r2, ABSIZ(r2)); \ if (pass & 2) realloc_if_reducing (r2); \
(desc).fptr (r1, r2, i1, i2); \ (desc).fptr (r1, r2, i1, i2); \
} while (0) } while (0)
#define INVOKE_RSS(desc,r1,i1,i2) \ #define INVOKE_RSS(desc,r1,i1,i2) \
do { \ do { \
if (pass & 1) _mpz_realloc (r1, ABSIZ(r1)); \ if (pass & 1) realloc_if_reducing (r1); \
(desc).fptr (r1, i1, i2); \ (desc).fptr (r1, i1, i2); \
} while (0) } while (0)
@ -204,7 +211,6 @@ main (int argc, char **argv)
unsigned int pass, reps = 400; unsigned int pass, reps = 400;
mpz_t in1, in2, in3; mpz_t in1, in2, in3;
unsigned long int in2i; unsigned long int in2i;
mp_size_t size;
mpz_t res1, res2, res3; mpz_t res1, res2, res3;
mpz_t ref1, ref2, ref3; mpz_t ref1, ref2, ref3;
mpz_t t; mpz_t t;
@ -238,7 +244,7 @@ main (int argc, char **argv)
for (pass = 1; pass <= reps; pass++) for (pass = 1; pass <= reps; pass++)
{ {
#ifndef VERBOSE #ifndef VERBOSE
if (isatty (fileno (stdout))) if (isatty (STDOUT_FILENO))
{ {
printf ("\r%d/%d passes", pass, reps); printf ("\r%d/%d passes", pass, reps);
fflush (stdout); fflush (stdout);
@ -737,7 +743,7 @@ main (int argc, char **argv)
} }
} }
if (isatty (fileno (stdout))) if (isatty (STDOUT_FILENO))
printf ("\r%20s", ""); printf ("\r%20s", "");
mpz_clear (bs); mpz_clear (bs);
@ -752,7 +758,7 @@ main (int argc, char **argv)
mpz_clear (res3); mpz_clear (res3);
mpz_clear (t); mpz_clear (t);
if (isatty (fileno (stdout))) if (isatty (STDOUT_FILENO))
printf ("\r"); printf ("\r");
tests_end (); tests_end ();
@ -763,16 +769,16 @@ void
dump (const char *name, mpz_t in1, mpz_t in2, mpz_t in3) dump (const char *name, mpz_t in1, mpz_t in2, mpz_t in3)
{ {
printf ("failure in %s (", name); printf ("failure in %s (", name);
0 && mpz_out_str (stdout, -16, in1); mpz_out_str (stdout, -16, in1);
if (in2 != NULL) if (in2 != NULL)
{ {
printf (" "); printf (" ");
0 && mpz_out_str (stdout, -16, in2); mpz_out_str (stdout, -16, in2);
} }
if (in3 != NULL) if (in3 != NULL)
{ {
printf (" "); printf (" ");
0 && mpz_out_str (stdout, -16, in3); mpz_out_str (stdout, -16, in3);
} }
printf (")\n"); printf (")\n");
} }

View File

@ -1,6 +1,6 @@
/* Test mpz_get_d. /* Test mpz_get_d.
Copyright 2002, 2012 Free Software Foundation, Inc. Copyright 2002, 2012, 2020 Free Software Foundation, Inc.
This file is part of the GNU MP Library test suite. This file is part of the GNU MP Library test suite.
@ -38,6 +38,13 @@ check_onebit (void)
mpz_init (z); mpz_init (z);
got = mpz_get_d (z);
if (got != 0)
{
printf ("mpz_get_d wrong on zero\n");
abort();
}
mpz_set_ui (z, 1L); mpz_set_ui (z, 1L);
want = 1.0; want = 1.0;

View File

@ -77,7 +77,10 @@ main (int argc, char **argv)
extra_fft = getenv ("GMP_CHECK_FFT"); extra_fft = getenv ("GMP_CHECK_FFT");
fft_max_2exp = 0; fft_max_2exp = 0;
if (extra_fft != NULL) if (extra_fft != NULL)
fft_max_2exp = atoi (extra_fft); {
fft_max_2exp = atoi (extra_fft);
printf ("GMP_CHECK_FFT=%d (include this in bug reports)\n", fft_max_2exp);
}
if (fft_max_2exp <= 1) /* compat with old use of GMP_CHECK_FFT */ if (fft_max_2exp <= 1) /* compat with old use of GMP_CHECK_FFT */
fft_max_2exp = 22; /* default limit, good for any machine */ fft_max_2exp = 22; /* default limit, good for any machine */

View File

@ -2004,10 +2004,10 @@ refmpn_gcd_11 (mp_limb_t x, mp_limb_t y)
mp_double_limb_t mp_double_limb_t
refmpn_gcd_22 (mp_limb_t x1, mp_limb_t x0, mp_limb_t y1, mp_limb_t y0) refmpn_gcd_22 (mp_limb_t x1, mp_limb_t x0, mp_limb_t y1, mp_limb_t y0)
{ {
ASSERT ((x0 & 1) != 0);
ASSERT ((y0 & 1) != 0);
mp_double_limb_t g; mp_double_limb_t g;
mp_limb_t cy; mp_limb_t cy;
ASSERT ((x0 & 1) != 0);
ASSERT ((y0 & 1) != 0);
do do
{ {

Some files were not shown because too many files have changed in this diff Show More