initial import of GMP 6.2.1. from their NEWS:

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.

  FEATURES
  * C90 compliance.
  * Initial support for Darwin on arm64, and improved portability.
  * Support for more processors.
This commit is contained in:
mrg 2021-07-11 21:14:43 +00:00
parent 6f208b789f
commit 6a122452c7
94 changed files with 4818 additions and 1925 deletions

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>
* Version 6.2.0 released.

View File

@ -90,6 +90,7 @@
# 6.1.1 13:1:3 9:1:5 -
# 6.1.2 13:2:3 9:2:5 -
# 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
# 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.
LIBGMP_LT_CURRENT = 14
LIBGMP_LT_REVISION = 0
LIBGMP_LT_REVISION = 1
LIBGMP_LT_AGE = 4
LIBGMPXX_LT_CURRENT = 10
LIBGMPXX_LT_REVISION = 0
LIBGMPXX_LT_REVISION = 1
LIBGMPXX_LT_AGE = 6
@ -412,7 +413,7 @@ EXTRA_DIST += gen-psqr.c
# Distribute mini-gmp. Test sources copied by dist-hook.
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
# Avoid: CVS - cvs directories
@ -436,7 +437,7 @@ check-mini-gmp:
abs_srcdir="`cd $(srcdir) && pwd`" ; \
$(MKDIR_P) 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" \
VPATH="$$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.2 13:2:3 9:2:5 -
# 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
# 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_srcdir = @top_srcdir@
LIBGMP_LT_CURRENT = 14
LIBGMP_LT_REVISION = 0
LIBGMP_LT_REVISION = 1
LIBGMP_LT_AGE = 4
LIBGMPXX_LT_CURRENT = 10
LIBGMPXX_LT_REVISION = 0
LIBGMPXX_LT_REVISION = 1
LIBGMPXX_LT_AGE = 6
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 \
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 \
mini-gmp/mini-gmp.h mini-gmp/mini-mpq.c mini-gmp/mini-mpq.h \
mini-gmp/tests/Makefile mini-gmp/tests/run-tests
mini-gmp/mini-gmp.h mini-gmp/ChangeLog mini-gmp/mini-mpq.c \
mini-gmp/mini-mpq.h mini-gmp/tests/Makefile \
mini-gmp/tests/run-tests
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = gmp.pc $(am__append_1)
@WANT_CXX_TRUE@GMPXX_HEADERS_OPTION = gmpxx.h
@ -1508,7 +1510,7 @@ check-mini-gmp:
abs_srcdir="`cd $(srcdir) && pwd`" ; \
$(MKDIR_P) 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" \
VPATH="$$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
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
BUGS FIXED

View File

@ -992,9 +992,19 @@ main ()
default:
modelstr = "zen2";
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)
{
/* Should recognize Cyrix' processors too. */

View File

@ -2,7 +2,7 @@
# Attempt to guess a canonical system name.
# 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
# under the terms of the GNU General Public License as published by
@ -150,17 +150,15 @@ Linux|GNU|GNU/*)
#elif defined(__dietlibc__)
LIBC=dietlibc
#else
#include <stdarg.h>
#ifdef __DEFINED_va_list
LIBC=musl
#else
LIBC=gnu
#endif
#endif
EOF
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
@ -184,6 +182,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
"/usr/sbin/$sysctl" 2>/dev/null || \
echo unknown)`
case "$UNAME_MACHINE_ARCH" in
aarch64eb) machine=aarch64_be-unknown ;;
armeb) machine=armeb-unknown ;;
arm*) machine=arm-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.
# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
# 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') | \
(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
@ -544,10 +543,10 @@ EOF
AViiON:dgux:*:*)
# DG/UX returns AViiON for all architectures
UNAME_PROCESSOR=`/usr/bin/uname -p`
if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ]
if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110
then
if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \
[ "$TARGET_BINARY_INTERFACE"x = x ]
if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \
test "$TARGET_BINARY_INTERFACE"x = x
then
echo m88k-dg-dgux"$UNAME_RELEASE"
else
@ -580,7 +579,7 @@ EOF
echo i386-ibm-aix
exit ;;
ia64:AIX:*:*)
if [ -x /usr/bin/oslevel ] ; then
if test -x /usr/bin/oslevel ; then
IBM_REV=`/usr/bin/oslevel`
else
IBM_REV="$UNAME_VERSION.$UNAME_RELEASE"
@ -620,7 +619,7 @@ EOF
else
IBM_ARCH=powerpc
fi
if [ -x /usr/bin/lslpp ] ; then
if test -x /usr/bin/lslpp ; then
IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc |
awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
else
@ -655,7 +654,7 @@ EOF
9000/31?) HP_ARCH=m68000 ;;
9000/[34]??) HP_ARCH=m68k ;;
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_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
case "$sc_cpu_version" in
@ -669,7 +668,7 @@ EOF
esac ;;
esac
fi
if [ "$HP_ARCH" = "" ]; then
if test "$HP_ARCH" = ""; then
set_cc_for_build
sed 's/^ //' << EOF > "$dummy.c"
@ -708,7 +707,7 @@ EOF
test -z "$HP_ARCH" && HP_ARCH=hppa
fi ;;
esac
if [ "$HP_ARCH" = hppa2.0w ]
if test "$HP_ARCH" = hppa2.0w
then
set_cc_for_build
@ -782,7 +781,7 @@ EOF
echo hppa1.0-hp-osf
exit ;;
i*86:OSF1:*:*)
if [ -x /usr/sbin/sysversion ] ; then
if test -x /usr/sbin/sysversion ; then
echo "$UNAME_MACHINE"-unknown-osf1mk
else
echo "$UNAME_MACHINE"-unknown-osf1
@ -1095,7 +1094,17 @@ EOF
echo "$UNAME_MACHINE"-dec-linux-"$LIBC"
exit ;;
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 ;;
xtensa*:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
@ -1284,7 +1293,7 @@ EOF
echo mips-sony-newsos6
exit ;;
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"
else
echo mips-unknown-sysv"$UNAME_RELEASE"
@ -1332,6 +1341,9 @@ EOF
*:Rhapsody:*:*)
echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE"
exit ;;
arm64:Darwin:*:*)
echo aarch64-apple-darwin"$UNAME_RELEASE"
exit ;;
*:Darwin:*:*)
UNAME_PROCESSOR=`uname -p`
case $UNAME_PROCESSOR in
@ -1346,7 +1358,7 @@ EOF
else
set_cc_for_build
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') | \
(CCOPTS="" $CC_FOR_BUILD -E - 2>/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
and
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
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_VERSION = "$UNAME_VERSION"
EOF
fi
exit 1

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
#! /bin/sh
# From configure.ac Revision.
# 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>.
#
@ -623,8 +623,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='GNU MP'
PACKAGE_TARNAME='gmp'
PACKAGE_VERSION='6.2.0'
PACKAGE_STRING='GNU MP 6.2.0'
PACKAGE_VERSION='6.2.1'
PACKAGE_STRING='GNU MP 6.2.1'
PACKAGE_BUGREPORT='gmp-bugs@gmplib.org, see https://gmplib.org/manual/Reporting-Bugs.html'
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.
# This message is too long to be a string in the A/UX 3.1 sh.
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]...
@ -1484,7 +1484,7 @@ fi
if test -n "$ac_init_help"; then
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
cat <<\_ACEOF
@ -1624,7 +1624,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
GNU MP configure 6.2.0
GNU MP configure 6.2.1
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@ -2630,7 +2630,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
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
$ $0 $@
@ -3607,7 +3607,7 @@ fi
# Define the identity of the package.
PACKAGE='gmp'
VERSION='6.2.0'
VERSION='6.2.1'
cat >>confdefs.h <<_ACEOF
@ -4360,7 +4360,7 @@ echo "include_mpn(\`alpha/default.m4')" >> $gmp_tmpconfigm4i
gcc_cflags_neon="-mfpu=neon"
gcc_cflags_tune="-mtune=cortex-a15 -mtune=cortex-a9"
;;
armcortexa53 | armcortexa53neon)
armcortexa53 | armcortexa53neon | armcortexa55 | armcortexa55neon)
abilist="64 32"
path="arm/neon arm/v7a/cora9 arm/v6t2 arm/v6 arm/v5 arm"
path_64="arm64/cora53 arm64"
@ -5562,7 +5562,7 @@ echo "include_mpn(\`vax/elf.m4')" >> $gmp_tmpconfigm4i
x86_have_mulx=yes
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_arch="-march=znver2 -march=znver1 -march=amdfam10 -march=k8"
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.
cc_64_cflags="-xO3 -m64"
;;
*-*-mingw* | *-*-cygwin)
*-*-mingw* | *-*-msys | *-*-cygwin)
limb_64=longlong
CALLING_CONVENTIONS_OBJS_64=""
@ -5715,7 +5715,7 @@ esac
# x86s, but allow any CPU here so as to catch "none" too.
#
case $host in
*-*-mingw*)
*-*-mingw* | *-*-msys)
gcc_cflags_optlist="$gcc_cflags_optlist nocygwin"
gcc_cflags_nocygwin="-mno-cygwin"
;;
@ -7288,11 +7288,12 @@ case $host in
fat_path="x86 x86/fat x86/i486
x86/k6 x86/k6/mmx x86/k6/k62mmx
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/p6 x86/p6/mmx x86/p6/p3mmx x86/p6/sse2
x86/pentium4 x86/pentium4/mmx x86/pentium4/sse2
x86/core2 x86/coreinhm x86/coreisbr
x86/goldmont x86/silvermont
x86/atom x86/atom/mmx x86/atom/sse2 x86/nano"
fi
@ -12103,7 +12104,7 @@ test -z "$OBJDUMP" && OBJDUMP=objdump
LIBGMP_DLL=0
case $host in
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
*-*-cygwin* | *-*-mingw* | *-*-msys | *-*-pw32* | *-*-os2*)
# By default, build only static.
if test -z "$enable_shared"; then
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
;;
64)
case $host in
*-*-darwin*)
echo "include_mpn(\`arm64/darwin.m4')" >> $gmp_tmpconfigm4i
;;
*)
echo "include_mpn(\`arm64/arm64-defs.m4')" >> $gmp_tmpconfigm4i
;;
esac
;;
esac
;;
hppa*-*-*)
@ -26899,13 +26912,6 @@ $as_echo "$as_me: WARNING: +----------------------------------------------------
esac
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; }
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
;;
*-*-mingw* | *-*-cygwin)
*-*-mingw* | *-*-msys | *-*-cygwin)
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
# values after options handling.
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
CONFIG_FILES = $CONFIG_FILES
@ -28581,7 +28594,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
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,
with options \\"\$ac_cs_config\\"

View File

@ -35,7 +35,7 @@ see https://www.gnu.org/licenses/.
AC_COPYRIGHT(GMP_COPYRIGHT)
AH_TOP(/*GMP_COPYRIGHT*/)
AC_REVISION($Revision: 1.1.1.3 $)
AC_REVISION($Revision: 1.1.1.4 $)
AC_PREREQ(2.59)
AC_INIT(GNU MP, GMP_VERSION, [gmp-bugs@gmplib.org, see https://gmplib.org/manual/Reporting-Bugs.html], gmp)
AC_CONFIG_SRCDIR(gmp-impl.h)
@ -722,7 +722,7 @@ case $host in
gcc_cflags_neon="-mfpu=neon"
gcc_cflags_tune="-mtune=cortex-a15 -mtune=cortex-a9"
;;
armcortexa53 | armcortexa53neon)
armcortexa53 | armcortexa53neon | armcortexa55 | armcortexa55neon)
abilist="64 32"
path="arm/neon arm/v7a/cora9 arm/v6t2 arm/v6 arm/v5 arm"
path_64="arm64/cora53 arm64"
@ -1889,7 +1889,7 @@ case $host in
x86_have_mulx=yes
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_arch="-march=znver2 -march=znver1 -march=amdfam10 -march=k8"
path="x86/k7/mmx x86/k7 x86/mmx x86"
@ -2011,7 +2011,7 @@ case $host in
# Sun cc.
cc_64_cflags="-xO3 -m64"
;;
*-*-mingw* | *-*-cygwin)
*-*-mingw* | *-*-msys | *-*-cygwin)
limb_64=longlong
CALLING_CONVENTIONS_OBJS_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.
#
case $host in
*-*-mingw*)
*-*-mingw* | *-*-msys)
gcc_cflags_optlist="$gcc_cflags_optlist nocygwin"
gcc_cflags_nocygwin="-mno-cygwin"
;;
@ -2291,11 +2291,12 @@ case $host in
fat_path="x86 x86/fat x86/i486
x86/k6 x86/k6/mmx x86/k6/k62mmx
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/p6 x86/p6/mmx x86/p6/p3mmx x86/p6/sse2
x86/pentium4 x86/pentium4/mmx x86/pentium4/sse2
x86/core2 x86/coreinhm x86/coreisbr
x86/goldmont x86/silvermont
x86/atom x86/atom/mmx x86/atom/sse2 x86/nano"
fi
@ -2664,7 +2665,7 @@ AC_LIBTOOL_WIN32_DLL
AC_SUBST(LIBGMP_DLL,0)
case $host in
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
*-*-cygwin* | *-*-mingw* | *-*-msys | *-*-pw32* | *-*-os2*)
# By default, build only static.
if test -z "$enable_shared"; then
enable_shared=no
@ -3699,6 +3700,14 @@ if test "$gmp_asm_syntax_testing" != no; then
case $ABI in
32)
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
;;
hppa*-*-*)
@ -3774,11 +3783,11 @@ yes
if test "$x86_have_mulx" = yes; then
GMP_ASM_X86_MULX
fi
GMP_ASM_COFF_TYPE
case $ABI in
32)
GMP_INCLUDE_MPN(x86/x86-defs.m4)
AC_DEFINE(HAVE_HOST_CPU_FAMILY_x86)
GMP_ASM_COFF_TYPE
GMP_ASM_X86_GOT_UNDERSCORE
GMP_ASM_X86_SHLDL_CL
case $enable_profiling in
@ -3795,7 +3804,7 @@ yes
case $host in
*-*-darwin*)
GMP_INCLUDE_MPN(x86_64/darwin.m4) ;;
*-*-mingw* | *-*-cygwin)
*-*-mingw* | *-*-msys | *-*-cygwin)
GMP_INCLUDE_MPN(x86_64/dos64.m4) ;;
*-openbsd*)
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
#define BAD 258
#define HELP 259
#define HEX 260
#define DECIMAL 261
#define QUIT 262
#define ABS 263
#define BIN 264
#define FIB 265
#define GCD 266
#define KRON 267
#define LCM 268
#define LUCNUM 269
#define NEXTPRIME 270
#define POWM 271
#define ROOT 272
#define SQRT 273
#define NUMBER 274
#define VARIABLE 275
#define LOR 276
#define LAND 277
#define EQ 278
#define NE 279
#define LE 280
#define GE 281
#define LSHIFT 282
#define RSHIFT 283
#define UMINUS 284
#ifdef YYSTYPE
#undef YYSTYPE_IS_DECLARED
#define YYSTYPE_IS_DECLARED 1
/* A Bison parser, made by GNU Bison 3.6.4. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
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
#ifndef YYSTYPE_IS_DECLARED
#define YYSTYPE_IS_DECLARED 1
typedef union {
#if YYDEBUG
extern int yydebug;
#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;
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;
int yyparse (void);
#endif /* !YY_YY_CALC_H_INCLUDED */

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
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
under the terms of the GNU Free Documentation License, Version 1.3 or
@ -19,157 +19,157 @@ END-INFO-DIR-ENTRY

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

Tag Table:
(Indirect)
Node: Top858
Node: Copying2931
Node: Introduction to GMP5278
Node: Installing GMP7994
Node: Build Options8726
Node: ABI and ISA24435
Node: Notes for Package Builds34276
Node: Notes for Particular Systems37363
Node: Known Build Problems45114
Node: Performance optimization48646
Node: GMP Basics49775
Node: Headers and Libraries50423
Node: Nomenclature and Types51828
Node: Function Classes53824
Node: Variable Conventions55359
Node: Parameter Conventions57599
Node: Memory Management59406
Node: Reentrancy60534
Node: Useful Macros and Constants62402
Node: Compatibility with older versions63393
Node: Demonstration Programs64303
Node: Efficiency66162
Node: Debugging73776
Node: Profiling80551
Node: Autoconf84542
Node: Emacs86323
Node: Reporting Bugs86929
Node: Integer Functions89555
Node: Initializing Integers90331
Node: Assigning Integers92707
Node: Simultaneous Integer Init & Assign94318
Node: Converting Integers95965
Node: Integer Arithmetic98905
Node: Integer Division100641
Node: Integer Exponentiation107400
Node: Integer Roots108897
Node: Number Theoretic Functions110614
Node: Integer Comparisons118109
Node: Integer Logic and Bit Fiddling119547
Node: I/O of Integers122187
Node: Integer Random Numbers125178
Node: Integer Import and Export127801
Node: Miscellaneous Integer Functions131817
Node: Integer Special Functions133731
Node: Rational Number Functions137904
Node: Initializing Rationals139097
Node: Rational Conversions141570
Node: Rational Arithmetic143592
Node: Comparing Rationals145004
Node: Applying Integer Functions146475
Node: I/O of Rationals147994
Node: Floating-point Functions150353
Node: Initializing Floats153398
Node: Assigning Floats157490
Node: Simultaneous Float Init & Assign160078
Node: Converting Floats161628
Node: Float Arithmetic164893
Node: Float Comparison167046
Node: I/O of Floats168617
Node: Miscellaneous Float Functions171306
Node: Low-level Functions173308
Node: Random Number Functions207556
Node: Random State Initialization208624
Node: Random State Seeding211489
Node: Random State Miscellaneous212894
Node: Formatted Output213536
Node: Formatted Output Strings213781
Node: Formatted Output Functions219176
Node: C++ Formatted Output223240
Node: Formatted Input225940
Node: Formatted Input Strings226176
Node: Formatted Input Functions230836
Node: C++ Formatted Input233805
Node: C++ Class Interface235708
Node: C++ Interface General236659
Node: C++ Interface Integers239728
Node: C++ Interface Rationals243961
Node: C++ Interface Floats247985
Node: C++ Interface Random Numbers254002
Node: C++ Interface Limitations256402
Node: Custom Allocation259977
Node: Language Bindings264196
Node: Algorithms267509
Node: Multiplication Algorithms268209
Node: Basecase Multiplication269298
Node: Karatsuba Multiplication271206
Node: Toom 3-Way Multiplication274830
Node: Toom 4-Way Multiplication281249
Node: Higher degree Toom'n'half282628
Node: FFT Multiplication283920
Node: Other Multiplication289256
Node: Unbalanced Multiplication291730
Node: Division Algorithms292518
Node: Single Limb Division292897
Node: Basecase Division295785
Node: Divide and Conquer Division296988
Node: Block-Wise Barrett Division299056
Node: Exact Division299708
Node: Exact Remainder303730
Node: Small Quotient Division305980
Node: Greatest Common Divisor Algorithms307578
Node: Binary GCD307875
Node: Lehmer's Algorithm310725
Node: Subquadratic GCD312955
Node: Extended GCD315424
Node: Jacobi Symbol316742
Node: Powering Algorithms318651
Node: Normal Powering Algorithm318914
Node: Modular Powering Algorithm319442
Node: Root Extraction Algorithms320224
Node: Square Root Algorithm320539
Node: Nth Root Algorithm322680
Node: Perfect Square Algorithm323465
Node: Perfect Power Algorithm325552
Node: Radix Conversion Algorithms326173
Node: Binary to Radix326549
Node: Radix to Binary330170
Node: Other Algorithms332258
Node: Prime Testing Algorithm332610
Node: Factorial Algorithm333794
Node: Binomial Coefficients Algorithm336194
Node: Fibonacci Numbers Algorithm337088
Node: Lucas Numbers Algorithm339562
Node: Random Number Algorithms340283
Node: Assembly Coding342403
Node: Assembly Code Organisation343363
Node: Assembly Basics344330
Node: Assembly Carry Propagation345480
Node: Assembly Cache Handling347310
Node: Assembly Functional Units349471
Node: Assembly Floating Point351084
Node: Assembly SIMD Instructions354863
Node: Assembly Software Pipelining355845
Node: Assembly Loop Unrolling356908
Node: Assembly Writing Guide359123
Node: Internals361888
Node: Integer Internals362400
Node: Rational Internals364864
Node: Float Internals366102
Node: Raw Output Internals373502
Node: C++ Interface Internals374696
Node: Contributors378017
Node: References384248
Node: GNU Free Documentation License390167
Node: Concept Index415309
Node: Function Index463123
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

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
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
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
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
under the terms of the GNU Free Documentation License, Version 1.3 or
@ -230,7 +230,7 @@ Build Directory
directory. For example
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
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
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.
-- Macro: __GMP_CC
@ -1723,8 +1723,8 @@ Rational Arithmetic
Number Sequences
Functions like 'mpz_fac_ui', 'mpz_fib_ui' and 'mpz_bin_uiui' 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.
wanted it's probably best to get a starting point and iterate from
there.
Text Input/Output
Hexadecimal or octal are suggested for input or output in text
@ -1805,7 +1805,7 @@ Source File Paths
to the source directory.
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
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
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
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
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
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
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
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
@cindex Text input/output

View File

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

View File

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

View File

@ -2329,7 +2329,7 @@ enum
/* Major version number is the value of __GNU_MP__ too, above. */
#define __GNU_MP_VERSION 6
#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 __GMP_H__

View File

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

View File

@ -436,7 +436,7 @@ long __MPN(count_leading_zeros) (UDItype);
&& W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
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" \
: "=r" (sh), "=&r" (sl) \
: "r" (ah), "rI" (bh), \
@ -447,8 +447,8 @@ long __MPN(count_leading_zeros) (UDItype);
: "r" (ah), "rI" (bh), "%r" (al), "rI" (bl) __CLOBBER_CC); \
} while (0)
/* 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
definitions for thumb and non-thumb to to th absense of RSC under thumb. */
SUBS, since they set carry in the same way. We need separate definitions
for thumb and non-thumb since thumb lacks RSC. */
#if defined (__thumb__)
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
do { \
@ -504,7 +504,7 @@ long __MPN(count_leading_zeros) (UDItype);
__asm__ ("subs\t%1, %4, %5\n\tsbc\t%0, %2, %3" \
: "=r" (sh), "=&r" (sl) \
: "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" \
: "=r" (sh), "=&r" (sl) \
: "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__ */
#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) \
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" \
: "=r" (sh), "=&r" (sl) \
: "rZ" ((UDItype)(ah)), "rZ" ((UDItype)(bh)), \
@ -577,7 +575,7 @@ extern UWtype __MPN(udiv_qrnnd) (UWtype *, UWtype, UWtype, UWtype);
} while (0)
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
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" \
: "=r,r" (sh), "=&r,&r" (sl) \
: "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_skylake || HAVE_HOST_CPU_bd4 || HAVE_HOST_CPU_zen)
#define umul_ppmm(w1, w0, u, v) \
__asm__ ("mulx\t%3, %0, %1" \
__asm__ ("mulx\t%3, %q0, %q1" \
: "=r" (w0), "=r" (w1) \
: "%d" ((UDItype)(u)), "rm" ((UDItype)(v)))
#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. */
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
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) \
__asm__ ("addic %1,%3,%4\n\tsubfze %0,%2" \
: "=r" (sh), "=&r" (sl) \
: "r" ((UDItype)(bh)), \
"rI" ((UDItype)(al)), "*rI" (-((UDItype)(bl))) \
"r" ((UDItype)(al)), "*rI" (-((UDItype)(bl))) \
__CLOBBER_CC); \
else if (__builtin_constant_p (ah) && (ah) == ~(UDItype) 0) \
__asm__ ("addic %1,%3,%4\n\tsubfme %0,%2" \
: "=r" (sh), "=&r" (sl) \
: "r" ((UDItype)(bh)), \
"rI" ((UDItype)(al)), "*rI" (-((UDItype)(bl))) \
"r" ((UDItype)(al)), "*rI" (-((UDItype)(bl))) \
__CLOBBER_CC); \
else if (__builtin_constant_p (bh) && (bh) == 0) \
__asm__ ("addic %1,%3,%4\n\taddme %0,%2" \
: "=r" (sh), "=&r" (sl) \
: "r" ((UDItype)(ah)), \
"rI" ((UDItype)(al)), "*rI" (-((UDItype)(bl))) \
: "r" ((UDItype)(ah)), \
"r" ((UDItype)(al)), "*rI" (-((UDItype)(bl))) \
__CLOBBER_CC); \
else if (__builtin_constant_p (bh) && (bh) == ~(UDItype) 0) \
__asm__ ("addic %1,%3,%4\n\taddze %0,%2" \
: "=r" (sh), "=&r" (sl) \
: "r" ((UDItype)(ah)), \
"rI" ((UDItype)(al)), "*rI" (-((UDItype)(bl))) \
: "r" ((UDItype)(ah)), \
"r" ((UDItype)(al)), "*rI" (-((UDItype)(bl))) \
__CLOBBER_CC); \
else \
__asm__ ("addic %1,%4,%5\n\tsubfe %0,%3,%2" \
: "=r" (sh), "=&r" (sl) \
: "r" ((UDItype)(ah)), "r" ((UDItype)(bh)), \
"rI" ((UDItype)(al)), "*rI" (-((UDItype)(bl))) \
: "r" ((UDItype)(ah)), "r" ((UDItype)(bh)), \
"r" ((UDItype)(al)), "*rI" (-((UDItype)(bl))) \
__CLOBBER_CC); \
} else { \
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) \
do { \
UWtype __x; \
__x = (al) + (bl); \
(sh) = (ah) + (bh) + (__x < (al)); \
UWtype __al = (al); \
UWtype __bl = (bl); \
__x = __al + __bl; \
(sh) = (ah) + (bh) + (__x < __al); \
(sl) = __x; \
} while (0)
#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) \
do { \
UWtype __x; \
__x = (al) - (bl); \
(sh) = (ah) - (bh) - ((al) < (bl)); \
UWtype __al = (al); \
UWtype __bl = (bl); \
__x = __al - __bl; \
(sh) = (ah) - (bh) - (__al < __bl); \
(sl) = __x; \
} while (0)
#endif

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
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,
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
= floor( (b (~u) + b-1) / u),
and the remainder
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);
/* 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) */
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;
str = mpz_get_str (NULL, base, x);
if (!str)
return 0;
len = strlen (str);
len = fwrite (str, 1, len, stream);
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;
/* The current (partial) 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;
/* The index where the limb was read. */
mp_size_t i;

View File

@ -1,6 +1,6 @@
/* 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.
@ -291,7 +291,8 @@ int mpz_init_set_str (mpz_t, const char *, int);
|| defined (_MSL_STDIO_H) /* Metrowerks */ \
|| defined (_STDIO_H_INCLUDED) /* QNX4 */ \
|| 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);
#endif

View File

@ -5,7 +5,7 @@
Acknowledgment: special thanks to Bradley Lucier for his comments
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.
@ -107,10 +107,10 @@ mpq_clear (mpq_t x)
static void
mpq_canonical_sign (mpq_t r)
{
int cmp = mpq_denref (r)->_mp_size;
if (cmp <= 0)
mp_size_t ds = mpq_denref (r)->_mp_size;
if (ds <= 0)
{
if (cmp == 0)
if (ds == 0)
gmp_die("mpq: Fraction with zero denominator.");
mpz_neg (mpq_denref (r), mpq_denref (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);
str = mpq_get_str (NULL, base, x);
if (!str)
return 0;
len = strlen (str);
len = fwrite (str, 1, len, stream);
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_GCD, OP_LCM, OP_POWM, OP_AND, OP_IOR, OP_XOR,
OP_SETBIT, OP_CLRBIT, OP_COMBIT,
OP_SCAN0, OP_SCAN1,
OP_SCAN0, OP_SCAN1
};
void hex_random_init (void);

View File

@ -1,6 +1,6 @@
#! /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
# it under the terms of the GNU General Public License as published by
@ -28,6 +28,22 @@ fi
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
# expanded, but usually not.
find_program () {
@ -38,6 +54,8 @@ find_program () {
*)
if [ -x "$1" ] ; then
echo "./$1"
elif [ -x "$1.exe" ] ; then
echo "./$1.exe"
else
echo "$srcdir/$1"
fi
@ -54,20 +72,10 @@ env_program () {
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 () {
testname=`basename "$1" .exe`
testname=`basename "$testname" -test`
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
else
$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.
@ -118,6 +118,10 @@ test_matissa (void)
mpz_clear (y);
}
#ifndef M_PI
#define M_PI 3.141592653589793238462643383279502884
#endif
static const struct
{
double d;

View File

@ -58,13 +58,7 @@ mpz_get_d_exact_p (const mpz_t z)
int
mpq_get_d_exact_p (const mpq_t q)
{
/* 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 */
return mpq_mantissasizeinbits (q) <= DBL_MANT_DIG;
}
#define HAVE_EXACT_P 1
#endif
@ -128,6 +122,9 @@ check_random (void)
d = ldexp ((double) m, e);
mpq_set_d (y, d);
if (i == 0)
mpq_neg (z, y);
mpq_add (y, y, z);
mpq_set_d (z, mpq_get_d (y));
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)
{
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 ("da", b);
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.
@ -160,6 +160,18 @@ testmain (int argc, char **argv)
fprintf (stderr,
"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++)
{
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.
@ -156,6 +156,18 @@ testmain (int argc, char **argv)
fprintf (stderr,
"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++)
{
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
lsr d, d, cnt
ifdef(`PIC',`
adrp x7, :got:__gmp_binvert_limb_table
LEA_HI( x7, binvert_limb_table)
ubfx x6, d, 1, 7
ldr x7, [x7, #:got_lo12:__gmp_binvert_limb_table]
',`
adrp x7, __gmp_binvert_limb_table
ubfx x6, d, 1, 7
add x7, x7, :lo12:__gmp_binvert_limb_table
')
LEA_LO( x7, binvert_limb_table)
ldrb w6, [x7, x6]
ubfiz x7, x6, 1, 8
umull x6, w6, w6
@ -81,7 +75,7 @@ ifdef(`PIC',`
mul x6, x6, x6
msub di, x6, d, x7
b mpn_pi1_bdiv_q_1
b GSYM_PREFIX`'mpn_pi1_bdiv_q_1
EPILOGUE()
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()
PROLOGUE(mpn_invert_limb)
lsr x2, x0, #54
adrp x1, approx_tab
LEA_HI( x1, approx_tab)
and x2, x2, #0x1fe
add x1, x1, :lo12:approx_tab
LEA_LO( x1, approx_tab)
ldrh w3, [x1,x2]
lsr x4, x0, #24
add x4, x4, #1

View File

@ -3,19 +3,30 @@ dnl ARM64 mpn_lshift.
dnl Copyright 2013, 2014, 2017 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 the GNU Lesser General Public License as published
dnl by the Free Software Foundation; either version 3 of the License, or (at
dnl your option) any later version.
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 Lesser General Public
dnl License for more details.
dnl You should have received a copy of the GNU Lesser General Public License
dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
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/.
include(`../config.m4')

View File

@ -3,19 +3,30 @@ dnl ARM64 mpn_lshiftc.
dnl Copyright 2013, 2014, 2017 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 the GNU Lesser General Public License as published
dnl by the Free Software Foundation; either version 3 of the License, or (at
dnl your option) any later version.
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 Lesser General Public
dnl License for more details.
dnl You should have received a copy of the GNU Lesser General Public License
dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
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/.
include(`../config.m4')

View File

@ -3,19 +3,30 @@ dnl ARM64 mpn_rshift.
dnl Copyright 2013, 2014, 2017 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 the GNU Lesser General Public License as published
dnl by the Free Software Foundation; either version 3 of the License, or (at
dnl your option) any later version.
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 Lesser General Public
dnl License for more details.
dnl You should have received a copy of the GNU Lesser General Public License
dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
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/.
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;
long start_idx;
int c;
mp_size_t shift;
long pi;
mp_limb_t big_base = mp_bases[base].big_base;
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;
t += c;
n -= c;
mp_size_t shift = c;
shift = c;
SET_powers_t (pt[0], t, n, digits_in_base, base, shift);
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;
}
for (long pi = start_idx; pi >= 0; pi--)
for (pi = start_idx; pi >= 0; pi--)
{
t = powtab_mem_ptr;
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;
mp_size_t n = 1;
mp_size_t shift = 0;
long pi;
p = powtab_mem_ptr;
powtab_mem_ptr += 1;
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);
pt++;
mp_size_t n = 1;
mp_size_t shift = 0;
for (long pi = n_pows - 1; pi >= 0; pi--)
for (pi = n_pows - 1; pi >= 0; pi--)
{
t = powtab_mem_ptr;
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. */
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_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;
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;
n_pows++;
@ -301,11 +306,13 @@ powtab_decide (size_t *exptab, size_t un, int base)
exptab[n_pows] = chars_per_limb;
#if HAVE_mpn_compute_powtab_mul && HAVE_mpn_compute_powtab_div
{
size_t pn = un - 1;
size_t xn = (un + 1) >> 1;
unsigned mcost = 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;
@ -332,6 +339,7 @@ powtab_decide (size_t *exptab, size_t un, int base)
return n_pows;
else
return -n_pows;
}
#elif HAVE_mpn_compute_powtab_mul
return n_pows;
#elif HAVE_mpn_compute_powtab_div

View File

@ -37,13 +37,14 @@ see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#if 0 /* unused, so leave out for now */
static mp_size_t
mpn_dcpi1_bdiv_q_n_itch (mp_size_t n)
{
/* NOTE: Depends on mullo_n and mpn_dcpi1_bdiv_qr_n interface */
return n;
}
#endif
/* 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))
{
int c;
if (t1 == 0)
{
g.d1 = (u1 << 1) | (u0 >> (GMP_LIMB_BITS - 1));
g.d0 = (u0 << 1) | 1;
return g;
}
int c;
count_trailing_zeros (c, t1);
/* 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;
mhi |= x >> nbits >> 11;
mlo = x << GMP_LIMB_BITS - nbits - 11;
mlo = x << (GMP_LIMB_BITS - nbits - 11);
nbits = nbits + 11 - GMP_NAIL_BITS;
}
else

View File

@ -369,6 +369,8 @@ mpn_get_str (unsigned char *str, int base, mp_ptr up, mp_size_t un)
int pi;
size_t out_len;
mp_ptr tmp;
size_t ndig;
mp_size_t xn;
TMP_DECL;
/* 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));
/* 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);
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
#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
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] = {
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
/* This needs full division about 0.93% of the time. */
static const unsigned char tab[32] = {
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
};
static const unsigned char *tabp = tab - (1 << (NBITS - 1));
#elif NBITS == 7
/* This needs full division about 0.49% of the time. */
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,
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
/* This needs full division about 0.26% of the time. */
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,
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
#error No table for provided NBITS
#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
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;
}
B2modb = - b * bi;
ASSERT (B2modb <= b); // NB: equality iff b = B/2
ASSERT (B2modb <= b); /* NB: equality iff b = B/2 */
cps[3] = B2modb;
}

View File

@ -6,7 +6,7 @@
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.
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.
@ -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];
if (cc != 0)
{
/* FIXME: use MPN_INCR_U here, since carry is not expected. */
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));
}

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;
powers_t powtab[GMP_LIMB_BITS];
int chars_per_limb;
powers_t *pt;
size_t n_pows;
mp_size_t size;
mp_size_t un;
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. */
powtab_mem = TMP_BALLOC_LIMBS (mpn_str_powtab_alloc (un));
size_t n_pows = mpn_compute_powtab (powtab, powtab_mem, un, base);
powers_t *pt = powtab + n_pows;
n_pows = mpn_compute_powtab (powtab, powtab_mem, un, base);
pt = powtab + n_pows;
tp = TMP_BALLOC_LIMBS (mpn_dc_set_str_itch (un));
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 "gmp-impl.h"
#if HAVE_NATIVE_mpn_rsblsh1_n || HAVE_NATIVE_mpn_sublsh1_n
#else
/* Stores |{ap,n}-{bp,n}| in {rp,n},
returns the sign of {ap,n}-{bp,n}. */
static int
@ -65,6 +68,7 @@ abs_sub_n (mp_ptr rp, mp_srcptr ap, mp_srcptr bp, mp_size_t n)
}
return 0;
}
#endif
/* Computes at most count terms of the sequence needed by the
Lucas-Lehmer-Riesel test, indexing backward:

View File

@ -6,7 +6,7 @@
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.
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.
@ -38,6 +38,34 @@ see https://www.gnu.org/licenses/. */
#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
#define DO_mpn_sublsh_n(dst,src,n,s,ws) mpn_sublsh_n(dst,dst,src,n,s)
#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
#define DO_mpn_addlsh_n(dst,src,n,s,ws) mpn_addlsh_n(dst,dst,src,n,s)
#else
#if !defined (AORSMUL_FASTER_2AORSLSH) && !defined (AORSMUL_FASTER_AORS_2AORSLSH)
static mp_limb_t
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
#if HAVE_NATIVE_mpn_subrsh
#define DO_mpn_subrsh(dst,nd,src,ns,s,ws) mpn_subrsh(dst,nd,src,ns,s)
@ -84,32 +114,6 @@ do { \
#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 \
((((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
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.
@ -37,6 +37,7 @@ see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#if GMP_NUMB_BITS < 29
#error Not implemented: Both sublsh_n(,,,28) should be corrected; r2 and r5 need one more LIMB.
#endif
@ -46,6 +47,21 @@ see https://www.gnu.org/licenses/. */
#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
#define DO_mpn_sublsh_n(dst,src,n,s,ws) mpn_sublsh_n(dst,dst,src,n,s)
#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
#define DO_mpn_addlsh_n(dst,src,n,s,ws) mpn_addlsh_n(dst,dst,src,n,s)
#else
#if !defined (AORSMUL_FASTER_2AORSLSH) && !defined (AORSMUL_FASTER_AORS_2AORSLSH)
static mp_limb_t
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
#if HAVE_NATIVE_mpn_subrsh
#define DO_mpn_subrsh(dst,nd,src,ns,s,ws) mpn_subrsh(dst,nd,src,ns,s)
@ -92,20 +110,6 @@ do { \
#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
#define BIT_CORRECTION 1
#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 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 the GNU Lesser General Public License as published
dnl by the Free Software Foundation; either version 3 of the License, or (at
dnl your option) any later version.
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 Lesser General Public
dnl License for more details.
dnl You should have received a copy of the GNU Lesser General Public License
dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
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/.
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 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 the GNU Lesser General Public License as published
dnl by the Free Software Foundation; either version 3 of the License, or (at
dnl your option) any later version.
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 Lesser General Public
dnl License for more details.
dnl You should have received a copy of the GNU Lesser General Public License
dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
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/.
include(`../config.m4')

View File

@ -105,6 +105,7 @@ static struct {
{ "steamroller","AuthenticAMD", MAKE_FMS (21, 0x30) },
{ "excavator", "AuthenticAMD", MAKE_FMS (21, 0x60) },
{ "jaguar", "AuthenticAMD", MAKE_FMS (22, 1) },
{ "zen", "AuthenticAMD", MAKE_FMS (23, 1) },
{ "viac3", "CentaurHauls", MAKE_FMS (6, 0) },
{ "viac32", "CentaurHauls", MAKE_FMS (6, 9) },
@ -335,6 +336,28 @@ __gmpn_cpuvec_init (void)
CPUVEC_SETUP_atom_sse2;
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 0x1b:
case 0x1e: /* NHM Lynnfield/Jasper */
@ -362,6 +385,7 @@ __gmpn_cpuvec_init (void)
case 0x2a: /* SBR */
case 0x2d: /* SBR-EP */
case 0x3a: /* IBR */
case 0x3e: /* IBR Ivytown */
case 0x3c: /* Haswell client */
case 0x3f: /* Haswell server */
case 0x45: /* Haswell ULT */
@ -428,8 +452,6 @@ __gmpn_cpuvec_init (void)
case 0x0f: /* k8 */
case 0x11: /* "fam 11h", mix of k8 and k10 */
case 0x13: /* unknown, conservatively assume k8 */
case 0x16: /* unknown, conservatively assume k8 */
case 0x17: /* unknown, conservatively assume k8 */
TRACE (printf (" k8\n"));
CPUVEC_SETUP_k7;
CPUVEC_SETUP_k7_mmx;
@ -444,6 +466,7 @@ __gmpn_cpuvec_init (void)
break;
case 0x14: /* bobcat */
case 0x16: /* jaguar */
TRACE (printf (" bobcat\n"));
CPUVEC_SETUP_k7;
CPUVEC_SETUP_k7_mmx;
@ -454,6 +477,14 @@ __gmpn_cpuvec_init (void)
TRACE (printf (" bulldozer\n"));
CPUVEC_SETUP_k7;
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;
}
}

View File

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

View File

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

View File

@ -38,6 +38,7 @@ see https://www.gnu.org/licenses/. */
/* 3600-4000 MHz Intel Xeon E3-1270v5 Skylake */
/* FFT tuning limit = 465,990,371 */
/* 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_UNNORM_THRESHOLD 0 /* always */
@ -135,10 +136,13 @@ see https://www.gnu.org/licenses/. */
{ 3071,15}, { 6911,16}, { 3583,15}, { 7679,14}, \
{ 15359,15}, { 7935,17}, { 2047,16}, { 4095,15}, \
{ 8703,16}, { 4607,15}, { 9983,14}, { 19967,16}, \
{ 5631,15}, { 11775,17}, { 3071,16}, { 65536,17}, \
{ 131072,18}, { 262144,19}, { 524288,20}, {1048576,21}, \
{2097152,22}, {4194304,23}, {8388608,24} }
#define MUL_FFT_TABLE3_SIZE 227
{ 5631,15}, { 11775,17}, { 3071,16}, \
{ 7679,15}, { 15359,18}, { 2047,17}, { 4095,16}, \
{ 9727,15}, { 19967,17}, { 5119,16}, { 11775,15}, \
{ 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 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}, \
{ 2047,16}, { 4095,15}, { 8191,16}, { 4607,15}, \
{ 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}, \
{8388608,24} }
#define SQR_FFT_TABLE3_SIZE 205
#define SQR_FFT_TABLE3_SIZE 217
#define SQR_FFT_THRESHOLD 4224
#define MULLO_BASECASE_THRESHOLD 0 /* always */

View File

@ -93,10 +93,28 @@ define(`PROLOGUE_cpu',
m4_assert_numargs(1)
` GLOBL $1
TYPE($1,`function')
COFF_TYPE($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
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 */
/* FFT tuning limit = 703,392,483 */
/* 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_UNNORM_THRESHOLD 0 /* always */
@ -147,10 +148,14 @@ see https://www.gnu.org/licenses/. */
{ 4095,15}, { 8959,16}, { 4607,15}, { 9983,14}, \
{ 19967,16}, { 5631,15}, { 11775,17}, { 3071,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}, \
{2097152,22}, {4194304,23}, {8388608,24} }
#define MUL_FFT_TABLE3_SIZE 275
#define MUL_FFT_TABLE3_SIZE 289
#define MUL_FFT_THRESHOLD 4736
#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}, \
{ 5631,15}, { 11775,17}, { 3071,16}, { 7679,15}, \
{ 15359,18}, { 2047,17}, { 4095,16}, { 9727,15}, \
{ 19967,17}, { 5119,16}, { 65536,17}, { 131072,18}, \
{ 262144,19}, { 524288,20}, {1048576,21}, {2097152,22}, \
{4194304,23}, {8388608,24} }
#define SQR_FFT_TABLE3_SIZE 282
{ 19967,17}, \
{ 5119,16}, { 11775,15}, { 23551,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}, \
{2097152,22}, {4194304,23}, {8388608,24} }
#define SQR_FFT_TABLE3_SIZE 296
#define SQR_FFT_THRESHOLD 3264
#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;
/* Cannot use num1_sign - num2_size, may overflow an "int" */
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);
return (num1_sign > 0 ? cmp : -cmp);

View File

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

View File

@ -8,7 +8,7 @@
With the current implementation, the first 24 MR-tests are substituted by a
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
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)
#endif
#else
/* Consider numbers up to 19*2^46 that pass the BPSW test as primes.
This implementation was tested up to 19*2^46 = 2^50+2^47+2^46 */
/* 2^4 < 19 = 0b10011 < 2^5 */
#define GMP_BPSW_LIMB_CONST CNST_LIMB(19)
#define GMP_BPSW_BITS_CONST (LOG2C(19) - 1)
/* Consider numbers up to 31*2^46 that pass the BPSW test as primes.
This implementation was tested up to 31*2^46 */
/* 2^4 < 31 = 0b11111 < 2^5 */
#define GMP_BPSW_LIMB_CONST CNST_LIMB(31)
#define GMP_BPSW_BITS_CONST (LOG2C(31) - 1)
#define GMP_BPSW_BITS_LIMIT (46 + GMP_BPSW_BITS_CONST)
#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) != 0)
if (wp == up || wp == vp)
{
free_me = wp;
free_me_size = ALLOC (w);
}
else
(*__gmp_free_func) (wp, (size_t) ALLOC (w) * GMP_LIMB_BYTES);
{
if (wp == up || wp == vp)
{
free_me = wp;
free_me_size = ALLOC (w);
}
else
(*__gmp_free_func) (wp, (size_t) ALLOC (w) * GMP_LIMB_BYTES);
}
ALLOC (w) = wsize;
wp = __GMP_ALLOCATE_FUNC_LIMBS (wsize);

View File

@ -4,7 +4,7 @@
CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN
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.
@ -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,
see https://www.gnu.org/licenses/. */
#include <stdlib.h>
#include <stdio.h>
#include "gmp-impl.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
mp_limb_t b_twolimbs[2];
#endif
mp_limb_t ovfl;
TMP_DECL;
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. */
count_trailing_zeros (btwos, blimb);
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_bits %= GMP_NUMB_BITS;
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);
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",
ralloc, bsize, blimb, cnt));
rp = MPZ_NEWALLOC (r, ralloc + rtwos_limbs);

View File

@ -171,7 +171,7 @@ check_mpz (void)
mpz_class b;
b = a;
ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) {
} catch (invalid_argument&) {
}
}
@ -182,7 +182,7 @@ check_mpz (void)
mpz_class b;
b = a;
ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) {
} catch (invalid_argument&) {
}
}
@ -357,7 +357,7 @@ check_mpq (void)
mpq_class b;
b = a;
ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) {
} catch (invalid_argument&) {
}
}
@ -368,7 +368,7 @@ check_mpq (void)
mpq_class b;
b = a;
ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) {
} catch (invalid_argument&) {
}
}
@ -543,7 +543,7 @@ check_mpf (void)
mpf_class b;
b = a;
ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) {
} catch (invalid_argument&) {
}
}
@ -554,7 +554,7 @@ check_mpf (void)
mpf_class b;
b = a;
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";
mpz_class b(a);
ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) {
} catch (invalid_argument&) {
}
}
@ -165,7 +165,7 @@ check_mpz (void)
int base = 16;
mpz_class b(a, base);
ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) {
} catch (invalid_argument&) {
}
}
@ -175,7 +175,7 @@ check_mpz (void)
string a("abc");
mpz_class b(a);
ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) {
} catch (invalid_argument&) {
}
}
@ -186,7 +186,7 @@ check_mpz (void)
int base = 8;
mpz_class b(a, base);
ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) {
} catch (invalid_argument&) {
}
}
@ -341,7 +341,7 @@ check_mpq (void)
const char *a = "abc";
mpq_class b(a);
ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) {
} catch (invalid_argument&) {
}
}
@ -352,7 +352,7 @@ check_mpq (void)
int base = 16;
mpq_class b (a, base);
ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) {
} catch (invalid_argument&) {
}
}
@ -362,7 +362,7 @@ check_mpq (void)
string a("abc");
mpq_class b(a);
ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) {
} catch (invalid_argument&) {
}
}
@ -373,7 +373,7 @@ check_mpq (void)
int base = 8;
mpq_class b (a, base);
ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) {
} catch (invalid_argument&) {
}
}
@ -635,7 +635,7 @@ check_mpf (void)
const char *a = "abc";
mpf_class b(a);
ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) {
} catch (invalid_argument&) {
}
}
@ -646,7 +646,7 @@ check_mpf (void)
int prec = 256;
mpf_class b(a, prec); ASSERT_ALWAYS(b == 1234567890L);
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;
mpf_class b(a, prec, base); ASSERT_ALWAYS(b == 262143L);
ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) {
} catch (invalid_argument&) {
}
}
@ -665,7 +665,7 @@ check_mpf (void)
string a("abc");
mpf_class b(a); ASSERT_ALWAYS(b == 1234567890L);
ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) {
} catch (invalid_argument&) {
}
}
@ -676,7 +676,7 @@ check_mpf (void)
int prec = 128;
mpf_class b(a, prec); ASSERT_ALWAYS(b == 1234567890L);
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;
mpf_class b(a, prec, base); ASSERT_ALWAYS(b == 65535u);
ASSERT_ALWAYS (0); /* should not be reached */
} catch (invalid_argument) {
} catch (invalid_argument&) {
}
}

View File

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

View File

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

View File

@ -49,7 +49,7 @@ check_randinit (void)
unsigned long m2exp = ULONG_MAX;
gmp_randclass r(gmp_randinit_lc_2exp_size, m2exp);
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
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 = \
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)
@ -33,3 +33,15 @@ CLEANFILES = $(EXTRA_PROGRAMS)
$(top_builddir)/tests/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 = :
build_triplet = @build@
host_triplet = @host@
EXTRA_PROGRAMS = aors_n$(EXEEXT) anymul_1$(EXEEXT) copy$(EXEEXT) \
divmod_1$(EXEEXT) divrem$(EXEEXT) shift$(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)
EXTRA_PROGRAMS = sqrtrem_1_2$(EXEEXT) primes$(EXEEXT) try$(EXEEXT) \
test-add_ssaaaa$(EXEEXT) test-sub_ddmmss$(EXEEXT)
subdir = tests/devel
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
@ -120,80 +117,35 @@ mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_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_OBJECTS = primes.$(OBJEXT)
primes_LDADD = $(LDADD)
primes_DEPENDENCIES = $(top_builddir)/tests/libtests.la \
$(top_builddir)/libgmp.la
shift_SOURCES = shift.c
shift_OBJECTS = shift.$(OBJEXT)
shift_LDADD = $(LDADD)
shift_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 =
sqrtrem_1_2_SOURCES = sqrtrem_1_2.c
sqrtrem_1_2_OBJECTS = sqrtrem_1_2.$(OBJEXT)
sqrtrem_1_2_LDADD = $(LDADD)
sqrtrem_1_2_DEPENDENCIES = $(top_builddir)/tests/libtests.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_OBJECTS = try.$(OBJEXT)
try_LDADD = $(LDADD)
try_DEPENDENCIES = $(top_builddir)/tests/libtests.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_DEFAULT_V@)
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_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = addmul_N.c anymul_1.c aors_n.c cnd_aors_n.c copy.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
DIST_SOURCES = addmul_N.c anymul_1.c aors_n.c cnd_aors_n.c copy.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
SOURCES = primes.c sqrtrem_1_2.c test-add_ssaaaa.c test-sub_ddmmss.c \
try.c
DIST_SOURCES = primes.c sqrtrem_1_2.c test-add_ssaaaa.c \
test-sub_ddmmss.c try.c
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
@ -423,7 +373,9 @@ top_srcdir = @top_srcdir@
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/tests
AM_LDFLAGS = -no-install
LDADD = $(top_builddir)/tests/libtests.la $(top_builddir)/libgmp.la
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
.SUFFIXES:
@ -458,62 +410,26 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(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)
@rm -f primes$(EXEEXT)
$(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)
@rm -f sqrtrem_1_2$(EXEEXT)
$(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)
@rm -f try$(EXEEXT)
$(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:
-rm -f *.$(OBJEXT)
@ -743,6 +659,15 @@ allprogs: $(EXTRA_PROGRAMS)
$(top_builddir)/tests/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.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

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

@ -49,10 +49,17 @@ void
tests_start (void)
{
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_MINOR,
__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)
{

View File

@ -1,6 +1,6 @@
/* 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.
@ -57,7 +57,7 @@ localeconv (void)
#endif
/* Replace the libc nl_langinfo with one we can manipulate. */
#if HAVE_NL_LANGINFO
#if HAVE_NL_LANGINFO && ! defined __TERMUX__
char *
nl_langinfo (nl_item n)
#if defined __cplusplus && defined __GLIBC__

View File

@ -1,6 +1,6 @@
/* 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.
@ -138,7 +138,7 @@ main (int argc, char **argv)
if (mpf_cmp (x, y) != 0)
abort ();
mpf_set_str (y, "0", 10);
mpf_set_str (y, " 0", 10);
mpf_set_str (x, "00000000000000000000000000000000000000000000000000000", 10);
MPF_CHECK_FORMAT (x);
if (mpf_cmp (x, y) != 0)
@ -160,7 +160,6 @@ main (int argc, char **argv)
if (mpf_cmp (x, y) != 0)
abort ();
mpf_set_str (y, "0", 16);
mpf_set_str (x, "00000000000000000000000000000000000000000000000000000", 16);
MPF_CHECK_FORMAT (x);
if (mpf_cmp (x, y) != 0)
@ -179,6 +178,26 @@ main (int argc, char **argv)
abort ();
mpf_set_str (x, "0.000000000000000000000000000000000000000000000000000", 16);
MPF_CHECK_FORMAT (x);
if (mpf_cmp (x, y) != 0)
abort ();
mpf_set_str (x, "+00000000000000000000000000000000000000000000000000000e-345", 9);
MPF_CHECK_FORMAT (x);
if (mpf_cmp (x, y) != 0)
abort ();
mpf_set_str (x, "-0000000000000000000000000000000000000000000000000000.@AB", 26);
MPF_CHECK_FORMAT (x);
if (mpf_cmp (x, y) != 0)
abort ();
mpf_set_str (x, "000000000000000000000000000000000000000000000000000.0@78", 19);
MPF_CHECK_FORMAT (x);
if (mpf_cmp (x, y) != 0)
abort ();
mpf_set_str (x, "+.0000000000000000000000000000000000000000000000000000e555", 6);
MPF_CHECK_FORMAT (x);
if (mpf_cmp (x, y) != 0)
abort ();
mpf_set_str (x, "-0.000000000000000000000000000000000000000000000000000@-AAAAAAAAAAAAAAAAAAAAAAAA", 17);
MPF_CHECK_FORMAT (x);
if (mpf_cmp (x, y) != 0)
abort ();

View File

@ -1,6 +1,6 @@
/* 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.
@ -39,6 +39,16 @@ check_data (void)
mpf_init2 (f, 3);
got = mpf_get_d_2exp (&got_exp, f);
if (got != 0 || got_exp != 0)
{
printf ("mpf_get_d_2exp wrong on zero\n");
mpf_trace (" f ", f);
d_trace (" got ", got);
printf (" got exp %ld\n", got_exp);
abort();
}
for (exp = -513; exp <= 513; exp++)
{
size_t i;

View File

@ -1,6 +1,6 @@
/* 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.
@ -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
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_floor", mpf_floor, floor);

View File

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

View File

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

View File

@ -128,4 +128,7 @@ main (int argc, char **argv)
mpz_clear (a);
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 \
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-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 \

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-lcm$(EXEEXT) t-invert$(EXEEXT) dive$(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-div_2exp$(EXEEXT) t-root$(EXEEXT) t-perfsqr$(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_CLEAN_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_OBJECTS = convert.$(OBJEXT)
convert_LDADD = $(LDADD)
convert_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 =
dive_SOURCES = dive.c
dive_OBJECTS = dive.$(OBJEXT)
dive_LDADD = $(LDADD)
@ -190,6 +185,11 @@ t_bin_OBJECTS = t-bin.$(OBJEXT)
t_bin_LDADD = $(LDADD)
t_bin_DEPENDENCIES = $(top_builddir)/tests/libtests.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_OBJECTS = t-cdiv_ui.$(OBJEXT)
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_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = bit.c 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 \
SOURCES = convert.c dive.c dive_ui.c io.c logic.c reuse.c t-addsub.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-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 \
@ -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-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
DIST_SOURCES = bit.c 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-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-fib_ui.c t-fits.c t-gcd.c t-gcd_ui.c t-get_d.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-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-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-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-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; \
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)
@rm -f convert$(EXEEXT)
$(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)
$(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)
@rm -f t-cdiv_ui$(EXEEXT)
$(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 \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
bit.log: bit$(EXEEXT)
@p='bit$(EXEEXT)'; \
b='bit'; \
t-bit.log: t-bit$(EXEEXT)
@p='t-bit$(EXEEXT)'; \
b='t-bit'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \

View File

@ -1,7 +1,7 @@
/* Test conversion using mpz_get_str and mpz_set_str.
Copyright 1993, 1994, 1996, 1999-2002, 2006, 2007 Free Software Foundation,
Inc.
Copyright 1993, 1994, 1996, 1999-2002, 2006, 2007, 2020 Free Software
Foundation, Inc.
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 <stdlib.h>
#include <string.h> /* for strlen */
#include <ctype.h> /* for tolower */
#include "gmp-impl.h"
#include "tests.h"
void debug_mp (mpz_t, int);
static int str_casecmp (const char *, const char *);
void
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++)
;
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, "str = %s\n", str);
@ -162,6 +164,21 @@ main (int argc, char **argv)
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
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.
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.
@ -63,6 +64,18 @@ main (int argc, char **argv)
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++)
{
mpz_urandomb (bs, rands, 32);

View File

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

View File

@ -0,0 +1,405 @@
/* Test mpz_setbit, mpz_clrbit, mpz_tstbit.
Copyright 1997, 2000-2003, 2012, 2013 Free Software Foundation, Inc.
This file is part of the GNU MP Library test suite.
The GNU MP Library test suite is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3 of the License,
or (at your option) any later version.
The GNU MP Library test suite is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.
You should have received a copy of the GNU General Public License along with
the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */
#include <stdio.h>
#include <stdlib.h>
#include "gmp-impl.h"
#include "tests.h"
#ifndef SIZE
#define SIZE 4
#endif
void
debug_mp (mpz_srcptr x, int base)
{
mpz_out_str (stdout, base, x); fputc ('\n', stdout);
}
/* exercise the case where mpz_clrbit or mpz_combit ends up extending a
value like -2^(k*GMP_NUMB_BITS-1) when clearing bit k*GMP_NUMB_BITS-1. */
/* And vice-versa. */
void
check_clr_extend (void)
{
mpz_t got, want;
unsigned long i;
int f;
mpz_init (got);
mpz_init (want);
for (i = 1; i < 5; i++)
{
for (f = 0; f <= 1; f++)
{
/* lots of 1 bits in _mp_d */
mpz_set_si (got, 1L);
mpz_mul_2exp (got, got, 10*GMP_NUMB_BITS);
mpz_sub_ui (got, got, 1L);
/* value -2^(n-1) representing ..11100..00 */
mpz_set_si (got, -1L);
mpz_mul_2exp (got, got, i*GMP_NUMB_BITS-1);
/* complement bit n, giving ..11000..00 which is -2^n */
if (f == 0)
mpz_clrbit (got, i*GMP_NUMB_BITS-1);
else
mpz_combit (got, i*GMP_NUMB_BITS-1);
MPZ_CHECK_FORMAT (got);
mpz_set_si (want, -1L);
mpz_mul_2exp (want, want, i*GMP_NUMB_BITS);
if (mpz_cmp (got, want) != 0)
{
if (f == 0)
printf ("mpz_clrbit: ");
else
printf ("mpz_combit: ");
printf ("wrong after extension\n");
mpz_trace ("got ", got);
mpz_trace ("want", want);
abort ();
}
/* complement bit n, going back to ..11100..00 which is -2^(n-1) */
if (f == 0)
mpz_setbit (got, i*GMP_NUMB_BITS-1);
else
mpz_combit (got, i*GMP_NUMB_BITS-1);
MPZ_CHECK_FORMAT (got);
mpz_set_si (want, -1L);
mpz_mul_2exp (want, want, i*GMP_NUMB_BITS - 1);
if (mpz_cmp (got, want) != 0)
{
if (f == 0)
printf ("mpz_setbit: ");
else
printf ("mpz_combit: ");
printf ("wrong after shrinking\n");
mpz_trace ("got ", got);
mpz_trace ("want", want);
abort ();
}
}
}
mpz_clear (got);
mpz_clear (want);
}
void
check_com_negs (void)
{
static const struct {
unsigned long bit;
mp_size_t inp_size;
mp_limb_t inp_n[5];
mp_size_t want_size;
mp_limb_t want_n[5];
} data[] = {
{ GMP_NUMB_BITS, 2, { 1, 1 }, 1, { 1 } },
{ GMP_NUMB_BITS+1, 2, { 1, 1 }, 2, { 1, 3 } },
{ GMP_NUMB_BITS, 2, { 0, 1 }, 2, { 0, 2 } },
{ GMP_NUMB_BITS+1, 2, { 0, 1 }, 2, { 0, 3 } },
};
mpz_t inp, got, want;
int i;
mpz_init (got);
mpz_init (want);
mpz_init (inp);
for (i = 0; i < numberof (data); i++)
{
mpz_set_n (inp, data[i].inp_n, data[i].inp_size);
mpz_neg (inp, inp);
mpz_set_n (want, data[i].want_n, data[i].want_size);
mpz_neg (want, want);
mpz_set (got, inp);
mpz_combit (got, data[i].bit);
if (mpz_cmp (got, want) != 0)
{
printf ("mpz_combit: wrong on neg data[%d]\n", i);
mpz_trace ("inp ", inp);
printf ("bit %lu\n", data[i].bit);
mpz_trace ("got ", got);
mpz_trace ("want", want);
abort ();
}
}
mpz_clear (inp);
mpz_clear (got);
mpz_clear (want);
}
/* See that mpz_tstbit matches a twos complement calculated explicitly, for
various low zeros. */
void
check_tstbit (void)
{
#define MAX_ZEROS 3
#define NUM_LIMBS 3
mp_limb_t pos[1+NUM_LIMBS+MAX_ZEROS];
mp_limb_t neg[1+NUM_LIMBS+MAX_ZEROS];
mpz_t z;
unsigned long i;
int zeros, low1;
int got, want;
mpz_init (z);
for (zeros = 0; zeros <= MAX_ZEROS; zeros++)
{
MPN_ZERO (pos, numberof(pos));
mpn_random2 (pos+zeros, (mp_size_t) NUM_LIMBS);
for (low1 = 0; low1 <= 1; low1++)
{
if (low1)
pos[0] |= 1;
refmpn_neg (neg, pos, (mp_size_t) numberof(neg));
mpz_set_n (z, neg, (mp_size_t) numberof(neg));
mpz_neg (z, z);
for (i = 0; i < numberof(pos)*GMP_NUMB_BITS; i++)
{
got = mpz_tstbit (z, i);
want = refmpn_tstbit (pos, i);
if (got != want)
{
printf ("wrong at bit %lu, with %d zeros\n", i, zeros);
printf ("z neg "); debug_mp (z, -16);
mpz_set_n (z, pos, (mp_size_t) numberof(pos));
printf ("pos "); debug_mp (z, -16);
mpz_set_n (z, neg, (mp_size_t) numberof(neg));
printf ("neg "); debug_mp (z, -16);
exit (1);
}
}
}
}
mpz_clear (z);
}
void
check_single (void)
{
mpz_t x;
int limb, offset, initial;
unsigned long bit;
mpz_init (x);
for (limb = 0; limb < 4; limb++)
{
for (offset = (limb==0 ? 0 : -2); offset <= 2; offset++)
{
for (initial = 1; initial >= -1; initial--)
{
mpz_set_si (x, (long) initial);
bit = (unsigned long) limb*GMP_LIMB_BITS + offset;
mpz_clrbit (x, bit);
MPZ_CHECK_FORMAT (x);
if (mpz_tstbit (x, bit) != 0)
{
printf ("check_single(): expected 0\n");
abort ();
}
mpz_setbit (x, bit);
MPZ_CHECK_FORMAT (x);
if (mpz_tstbit (x, bit) != 1)
{
printf ("check_single(): expected 1\n");
abort ();
}
mpz_clrbit (x, bit);
MPZ_CHECK_FORMAT (x);
if (mpz_tstbit (x, bit) != 0)
{
printf ("check_single(): expected 0\n");
abort ();
}
mpz_combit (x, bit);
MPZ_CHECK_FORMAT (x);
if (mpz_tstbit (x, bit) != 1)
{
printf ("check_single(): expected 1\n");
abort ();
}
mpz_combit (x, bit);
MPZ_CHECK_FORMAT (x);
if (mpz_tstbit (x, bit) != 0)
{
printf ("check_single(): expected 0\n");
abort ();
}
}
}
}
mpz_clear (x);
}
void
check_random (int argc, char *argv[])
{
mpz_t x, s0, s1, s2, s3, m;
mp_size_t xsize;
int i;
int reps = 100000;
int bit0, bit1, bit2, bit3;
unsigned long int bitindex;
const char *s = "";
if (argc == 2)
reps = atoi (argv[1]);
mpz_init (x);
mpz_init (s0);
mpz_init (s1);
mpz_init (s2);
mpz_init (s3);
mpz_init (m);
for (i = 0; i < reps; i++)
{
xsize = urandom () % (2 * SIZE) - SIZE;
mpz_random2 (x, xsize);
bitindex = urandom () % SIZE;
mpz_set (s0, x);
bit0 = mpz_tstbit (x, bitindex);
mpz_setbit (x, bitindex);
MPZ_CHECK_FORMAT (x);
mpz_set (s1, x);
bit1 = mpz_tstbit (x, bitindex);
mpz_clrbit (x, bitindex);
MPZ_CHECK_FORMAT (x);
mpz_set (s2, x);
bit2 = mpz_tstbit (x, bitindex);
mpz_combit (x, bitindex);
MPZ_CHECK_FORMAT (x);
mpz_set (s3, x);
bit3 = mpz_tstbit (x, bitindex);
#define FAIL(str) do { s = str; goto fail; } while (0)
if (bit1 != 1) FAIL ("bit1 != 1");
if (bit2 != 0) FAIL ("bit2 != 0");
if (bit3 != 1) FAIL ("bit3 != 1");
if (bit0 == 0)
{
if (mpz_cmp (s0, s1) == 0 || mpz_cmp (s0, s2) != 0 || mpz_cmp (s0, s3) == 0)
abort ();
}
else
{
if (mpz_cmp (s0, s1) != 0 || mpz_cmp (s0, s2) == 0 || mpz_cmp (s0, s3) != 0)
abort ();
}
if (mpz_cmp (s1, s2) == 0 || mpz_cmp (s1, s3) != 0)
abort ();
if (mpz_cmp (s2, s3) == 0)
abort ();
mpz_combit (x, bitindex);
MPZ_CHECK_FORMAT (x);
if (mpz_cmp (s2, x) != 0)
abort ();
mpz_clrbit (x, bitindex);
MPZ_CHECK_FORMAT (x);
if (mpz_cmp (s2, x) != 0)
abort ();
mpz_ui_pow_ui (m, 2L, bitindex);
MPZ_CHECK_FORMAT (m);
mpz_ior (x, s0, m);
MPZ_CHECK_FORMAT (x);
if (mpz_cmp (x, s3) != 0)
abort ();
mpz_com (m, m);
MPZ_CHECK_FORMAT (m);
mpz_and (x, s0, m);
MPZ_CHECK_FORMAT (x);
if (mpz_cmp (x, s2) != 0)
abort ();
}
mpz_clear (x);
mpz_clear (s0);
mpz_clear (s1);
mpz_clear (s2);
mpz_clear (s3);
mpz_clear (m);
return;
fail:
printf ("%s\n", s);
printf ("bitindex = %lu\n", bitindex);
printf ("x = "); mpz_out_str (stdout, -16, x); printf (" hex\n");
exit (1);
}
int
main (int argc, char *argv[])
{
tests_start ();
mp_trace_base = -16;
check_clr_extend ();
check_com_negs ();
check_tstbit ();
check_random (argc, argv);
check_single ();
tests_end ();
exit (0);
}

View File

@ -1,6 +1,6 @@
/* 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.
@ -38,6 +38,13 @@ check_onebit (void)
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);
want = 1.0;

View File

@ -77,7 +77,10 @@ main (int argc, char **argv)
extra_fft = getenv ("GMP_CHECK_FFT");
fft_max_2exp = 0;
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 */
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
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_limb_t cy;
ASSERT ((x0 & 1) != 0);
ASSERT ((y0 & 1) != 0);
do
{

View File

@ -78,7 +78,7 @@ spinner_signal (int signum)
void
spinner_init (void)
{
spinner_wanted = isatty (fileno (stdout));
spinner_wanted = isatty (STDOUT_FILENO);
if (spinner_wanted == -1)
abort ();

View File

@ -36,9 +36,7 @@ see https://www.gnu.org/licenses/. */
speed_foo() wants an "r" parameter.
The routines don't have help messages or descriptions, but most have
suggestive names. See the source code for full details.
*/
suggestive names. See the source code for full details. */
#include "config.h"
@ -1381,7 +1379,7 @@ main (int argc, char *argv[])
perror ("getrusage");
else
printf ("getrusage(): utime %ld.%06ld data %ld stack %ld maxresident %ld\n",
r.ru_utime.tv_sec, r.ru_utime.tv_usec,
(long) r.ru_utime.tv_sec, (long) r.ru_utime.tv_usec,
r.ru_idrss, r.ru_isrss, r.ru_ixrss);
}
#else

View File

@ -65,6 +65,7 @@ see https://www.gnu.org/licenses/. */
64 itanium-2 L1
128 itanium-2 L2
*/
#undef CACHE_LINE_SIZE
#define CACHE_LINE_SIZE 64 /* bytes */
#define SPEED_TMP_ALLOC_ADJUST_MASK (CACHE_LINE_SIZE/GMP_LIMB_BYTES - 1)
@ -2839,7 +2840,7 @@ int speed_routine_count_zeros_setup (struct speed_params *, mp_ptr, int, int);
}
#define SPEED_ROUTINE_MPN_GCD_1(function) \
SPEED_ROUTINE_MPN_GCD_1_CALL( , function (&px[j-1], 1, py[j-1]))
SPEED_ROUTINE_MPN_GCD_1_CALL(do{}while(0) , function (&px[j-1], 1, py[j-1]))
#define SPEED_ROUTINE_MPN_GCD_11(function) \
SPEED_ROUTINE_MPN_GCD_1_CALL((px[i] |= 1, py[i] |= 1), \
@ -2867,6 +2868,7 @@ int speed_routine_count_zeros_setup (struct speed_params *, mp_ptr, int, int);
unsigned i, j; \
struct hgcd_matrix1 m = {{{0,0},{0,0}}}; \
double t; \
mp_limb_t chain; \
\
speed_operand_src (s, s->xp_block, SPEED_BLOCK_SIZE); \
speed_operand_src (s, s->yp_block, SPEED_BLOCK_SIZE); \
@ -2874,7 +2876,7 @@ int speed_routine_count_zeros_setup (struct speed_params *, mp_ptr, int, int);
\
speed_starttime (); \
i = s->reps; \
mp_limb_t chain = 0; \
chain = 0; \
do \
{ \
for (j = 0; j < SPEED_BLOCK_SIZE; j+= 2) \

View File

@ -151,7 +151,6 @@ see https://www.gnu.org/licenses/. */
speed, on 4xx chips it's either that or an external clock. Measuring
against gettimeofday might be ok. */
#include "config.h"
#include <errno.h>
@ -1472,18 +1471,22 @@ speed_endtime (void)
if (use_cgt)
printf (" clock_gettime %ld.%09ld -> %ld.%09ld\n",
start_cgt.tv_sec, start_cgt.tv_nsec,
end_cgt.tv_sec, end_cgt.tv_nsec);
(long) start_cgt.tv_sec, (long) start_cgt.tv_nsec,
(long) end_cgt.tv_sec, (long) end_cgt.tv_nsec);
if (use_gtod)
printf (" gettimeofday %ld.%06ld -> %ld.%06ld\n",
start_gtod.tv_sec, start_gtod.tv_usec,
end_gtod.tv_sec, end_gtod.tv_usec);
(long) start_gtod.tv_sec,
(long) start_gtod.tv_usec,
(long) end_gtod.tv_sec,
(long) end_gtod.tv_usec);
if (use_grus)
printf (" getrusage %ld.%06ld -> %ld.%06ld\n",
start_grus.ru_utime.tv_sec, start_grus.ru_utime.tv_usec,
end_grus.ru_utime.tv_sec, end_grus.ru_utime.tv_usec);
(long) start_grus.ru_utime.tv_sec,
(long) start_grus.ru_utime.tv_usec,
(long) end_grus.ru_utime.tv_sec,
(long) end_grus.ru_utime.tv_usec);
if (use_times)
printf (" times %ld -> %ld\n",

View File

@ -204,7 +204,8 @@ main(int argc, char **argv)
if (best_time > lehmer_time)
best_p = 0;
printf("%6zu %6zu %5.3g", n, best_p, (double) best_p / n);
printf("%6lu %6lu %5.3g", (unsigned long) n, (unsigned long) best_p,
(double) best_p / n);
if (best_p > 0)
{
double speedup = 100 * (lehmer_time - best_time) / lehmer_time;

View File

@ -523,8 +523,13 @@ print_define_with_speedup (const char *name, mp_size_t value,
mp_size_t runner_up, double speedup)
{
char buf[100];
snprintf (buf, sizeof(buf), "%.2f%% faster than %ld",
#if __STDC_VERSION__ >= 199901L
snprintf (buf, sizeof buf, "%.2f%% faster than %ld",
100.0 * (speedup - 1), runner_up);
#else
sprintf (buf, "%.2f%% faster than %ld",
100.0 * (speedup - 1), runner_up);
#endif
print_define_remark (name, value, buf);
}
@ -1260,7 +1265,7 @@ fft (struct fft_param_t *p)
void
relspeed_div_1_vs_mul_1 (void)
{
const size_t max_opsize = 100;
#define max_opsize 100
mp_size_t n;
long j;
mp_limb_t rp[max_opsize];
@ -2065,7 +2070,7 @@ tune_powm_sec (void)
mp_size_t itch;
mp_bitcnt_t nbits, nbits_next, possible_nbits_cutoff;
const int n_max = 3000 / GMP_NUMB_BITS;
const int n_measurements = 5;
#define n_measurements 5
mp_ptr rp, bp, ep, mp, tp;
double ttab[n_measurements], tk, tkp1;
TMP_DECL;
@ -2746,6 +2751,8 @@ speed_mpn_pre_set_str (struct speed_params *s)
powers_t powtab[GMP_LIMB_BITS];
mp_size_t un;
int chars_per_limb;
size_t n_pows;
powers_t *pt;
TMP_DECL;
SPEED_RESTRICT_COND (s->size >= 1);
@ -2774,8 +2781,8 @@ speed_mpn_pre_set_str (struct speed_params *s)
chars_per_limb = mp_bases[base].chars_per_limb;
un = s->size / chars_per_limb + 1;
powtab_mem = TMP_BALLOC_LIMBS (mpn_str_powtab_alloc (un));
size_t n_pows = mpn_compute_powtab (powtab, powtab_mem, un, base);
powers_t *pt = powtab + n_pows;
n_pows = mpn_compute_powtab (powtab, powtab_mem, un, base);
pt = powtab + n_pows;
tp = TMP_BALLOC_LIMBS (mpn_dc_set_str_itch (un));
speed_starttime ();