diff --git a/gcc/gmp/.gdbinit b/gcc/gmp/.gdbinit new file mode 100644 index 0000000000..2a17063ff3 --- /dev/null +++ b/gcc/gmp/.gdbinit @@ -0,0 +1,42 @@ +# Copyright 1999 Free Software Foundation, Inc. +# +# This file is part of the GNU MP Library. +# +# The GNU MP Library is free software; you can redistribute it and/or modify +# it under the terms of either: +# +# * the GNU Lesser General Public License as published by the Free +# Software Foundation; either version 3 of the License, or (at your +# option) any later version. +# +# or +# +# * the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any +# later version. +# +# or both in parallel, as here. +# +# The GNU MP Library is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received copies of the GNU General Public License and the +# GNU Lesser General Public License along with the GNU MP Library. If not, +# see https://www.gnu.org/licenses/. + + +define pz +set __gmpz_dump ($) +end + +define pq +set __gmpz_dump ($->_mp_num) +echo / +set __gmpz_dump ($->_mp_den) +end + +define pf +set __gmpf_dump ($) +end diff --git a/gcc/gmp/ChangeLog b/gcc/gmp/ChangeLog index 0689b88161..a06dea1a6c 100644 --- a/gcc/gmp/ChangeLog +++ b/gcc/gmp/ChangeLog @@ -1,3 +1,204 @@ +2020-11-13 Marco Bodrato + + * 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 + + * 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 + + * 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 + + * 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 + + * configfsf.guess: Updated to version 2020-10-22, from gnulib. + +2020-10-17 Marco Bodrato + + * 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 + + * configure.ac: Recognise zen3. + * config.guess: Recognise zen3. + +2020-10-14 Marco Bodrato + + * 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 + + * Makefile.am: Better support for make check-mini-gmp on wine or cygwin. + +2020-09-22 Torbjörn Granlund + + * tests/mpz/t-mul.c: Print GMP_CHECK_FFT. + + * longlong.h (x86 umul_ppmm): Fix typo. + +2020-09-21 Torbjörn Granlund + + * mpz/n_pow_ui.c: Detect and report overflow. + +2020-07-04 Torbjörn Granlund + + * 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 + + * 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 + + * 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 + + * configure.ac: Recognise armcortexa55. + +2020-05-25 Torbjörn Granlund + + * 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 + + * 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 + + * 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 + + * 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 + + * 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 + + * 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 + + * tests/mpz/reuse.c (realloc_if_reducing): New function. + (INVOKE_RRS, etc): Use realloc_if_reducing. + 2020-01-17 Torbjörn Granlund * Version 6.2.0 released. diff --git a/gcc/gmp/Makefile.am b/gcc/gmp/Makefile.am index 0b9eb85a10..1c24694e7b 100644 --- a/gcc/gmp/Makefile.am +++ b/gcc/gmp/Makefile.am @@ -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" \ diff --git a/gcc/gmp/Makefile.in b/gcc/gmp/Makefile.in index ca12871692..d85f1153e4 100644 --- a/gcc/gmp/Makefile.in +++ b/gcc/gmp/Makefile.in @@ -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" \ diff --git a/gcc/gmp/NEWS b/gcc/gmp/NEWS index d83556ab3a..6fc3ae425b 100644 --- a/gcc/gmp/NEWS +++ b/gcc/gmp/NEWS @@ -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 diff --git a/gcc/gmp/config.guess b/gcc/gmp/config.guess index 663148895f..2d2680315e 100755 --- a/gcc/gmp/config.guess +++ b/gcc/gmp/config.guess @@ -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. */ diff --git a/gcc/gmp/configfsf.guess b/gcc/gmp/configfsf.guess old mode 100644 new mode 100755 index 45001cfecd..12dd5b4245 --- a/gcc/gmp/configfsf.guess +++ b/gcc/gmp/configfsf.guess @@ -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 + #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 <&2 - exit 1 + # No normalization, but not necessarily accepted, that comes below. ;; esac + else # Here we handle the default operating systems that come with various machines. @@ -1528,6 +1497,7 @@ else # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. +kernel= case $cpu-$vendor in score-*) os=elf @@ -1539,7 +1509,8 @@ case $cpu-$vendor in os=riscix1.2 ;; arm*-rebel) - os=linux + kernel=linux + os=gnu ;; arm*-semi) os=aout @@ -1705,84 +1676,173 @@ case $cpu-$vendor in os=none ;; esac + fi +# Now, validate our (potentially fixed-up) OS. +case $os in + # Sometimes we do "kernel-abi", so those need to count as OSes. + musl* | newlib* | uclibc*) + ;; + # Likewise for "kernel-libc" + eabi | eabihf | gnueabi | gnueabihf) + ;; + # Now accept the basic system types. + # The portable systems comes first. + # Each alternative MUST end in a * to match a version number. + gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \ + | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \ + | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \ + | sym* | plan9* | psp* | sim* | xray* | os68k* | v88r* \ + | hiux* | abug | nacl* | netware* | windows* \ + | os9* | macos* | osx* | ios* \ + | mpw* | magic* | mmixware* | mon960* | lnews* \ + | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \ + | aos* | aros* | cloudabi* | sortix* | twizzler* \ + | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \ + | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \ + | mirbsd* | netbsd* | dicos* | openedition* | ose* \ + | bitrig* | openbsd* | solidbsd* | libertybsd* | os108* \ + | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \ + | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \ + | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \ + | udi* | lites* | ieee* | go32* | aux* | hcos* \ + | chorusrdb* | cegcc* | glidix* \ + | cygwin* | msys* | pe* | moss* | proelf* | rtems* \ + | midipix* | mingw32* | mingw64* | mint* \ + | uxpv* | beos* | mpeix* | udk* | moxiebox* \ + | interix* | uwin* | mks* | rhapsody* | darwin* \ + | openstep* | oskit* | conix* | pw32* | nonstopux* \ + | storm-chaos* | tops10* | tenex* | tops20* | its* \ + | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \ + | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \ + | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ + | skyos* | haiku* | rdos* | toppers* | drops* | es* \ + | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ + | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ + | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx*) + ;; + # This one is extra strict with allowed versions + sco3.2v2 | sco3.2v[4-9]* | sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + ;; + none) + ;; + *) + echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2 + exit 1 + ;; +esac + +# As a final step for OS-related things, validate the OS-kernel combination +# (given a valid OS), if there is a kernel. +case $kernel-$os in + linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* | linux-musl* | linux-uclibc* ) + ;; + uclinux-uclibc* ) + ;; + -dietlibc* | -newlib* | -musl* | -uclibc* ) + # These are just libc implementations, not actual OSes, and thus + # require a kernel. + echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2 + exit 1 + ;; + kfreebsd*-gnu* | kopensolaris*-gnu*) + ;; + nto-qnx*) + ;; + os2-emx) + ;; + *-eabi* | *-gnueabi*) + ;; + -*) + # Blank kernel with real OS is always fine. + ;; + *-*) + echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2 + exit 1 + ;; +esac + # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. case $vendor in unknown) - case $os in - riscix*) + case $cpu-$os in + *-riscix*) vendor=acorn ;; - sunos*) + *-sunos*) vendor=sun ;; - cnk*|-aix*) + *-cnk* | *-aix*) vendor=ibm ;; - beos*) + *-beos*) vendor=be ;; - hpux*) + *-hpux*) vendor=hp ;; - mpeix*) + *-mpeix*) vendor=hp ;; - hiux*) + *-hiux*) vendor=hitachi ;; - unos*) + *-unos*) vendor=crds ;; - dgux*) + *-dgux*) vendor=dg ;; - luna*) + *-luna*) vendor=omron ;; - genix*) + *-genix*) vendor=ns ;; - clix*) + *-clix*) vendor=intergraph ;; - mvs* | opened*) + *-mvs* | *-opened*) vendor=ibm ;; - os400*) + *-os400*) vendor=ibm ;; - ptx*) + s390-* | s390x-*) + vendor=ibm + ;; + *-ptx*) vendor=sequent ;; - tpf*) + *-tpf*) vendor=ibm ;; - vxsim* | vxworks* | windiss*) + *-vxsim* | *-vxworks* | *-windiss*) vendor=wrs ;; - aux*) + *-aux*) vendor=apple ;; - hms*) + *-hms*) vendor=hitachi ;; - mpw* | macos*) + *-mpw* | *-macos*) vendor=apple ;; - *mint | mint[0-9]* | *MiNT | MiNT[0-9]*) + *-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*) vendor=atari ;; - vos*) + *-vos*) vendor=stratus ;; esac ;; esac -echo "$cpu-$vendor-$os" +echo "$cpu-$vendor-${kernel:+$kernel-}$os" exit # Local variables: diff --git a/gcc/gmp/configure b/gcc/gmp/configure index 23b90778ec..c27d6a846c 100755 --- a/gcc/gmp/configure +++ b/gcc/gmp/configure @@ -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 . # @@ -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(,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(,<$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(, <$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\\" diff --git a/gcc/gmp/configure.ac b/gcc/gmp/configure.ac index 024cacb6b8..cafdb3c716 100644 --- a/gcc/gmp/configure.ac +++ b/gcc/gmp/configure.ac @@ -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(,1)"]) ;; diff --git a/gcc/gmp/demos/calc/calc.c b/gcc/gmp/demos/calc/calc.c index cc653a21d7..8b472ac87d 100644 --- a/gcc/gmp/demos/calc/calc.c +++ b/gcc/gmp/demos/calc/calc.c @@ -1,23 +1,74 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ +/* A Bison parser, made by GNU Bison 3.6.4. */ -#define YYBYACC 1 -#define YYMAJOR 1 -#define YYMINOR 9 -#define YYPATCH 20170201 +/* Bison implementation for Yacc-like parsers in C -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 -#define YYPREFIX "yy" + 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 . */ + +/* 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. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* 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. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "3.6.4" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ #define YYPURE 0 -#line 2 "../../../gmp/demos/calc/calc.y" +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + + + + +/* First part of user prologue. */ +#line 1 "../../../gmp/demos/calc/calc.y" + /* A simple integer desk calculator using yacc and gmp. Copyright 2000-2002 Free Software Foundation, Inc. @@ -156,502 +207,1764 @@ mpz_t variable[26]; YYERROR; \ } -#ifdef YYSTYPE -#undef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 + +#line 212 "calc.c" + +# ifndef YY_CAST +# ifdef __cplusplus +# define YY_CAST(Type, Val) static_cast (Val) +# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast (Val) +# else +# define YY_CAST(Type, Val) ((Type) (Val)) +# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val)) +# endif +# endif +# ifndef YY_NULLPTR +# if defined __cplusplus +# if 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif +# else +# define YY_NULLPTR ((void*)0) +# endif +# endif + +/* Use api.header.include to #include this header + instead of duplicating it here. */ +#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 +#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" -typedef union { + char *str; int var; -} YYSTYPE; -#endif /* !YYSTYPE_IS_DECLARED */ -#line 172 "calc.c" -/* compatibility with bison */ -#ifdef YYPARSE_PARAM -/* compatibility with FreeBSD */ -# ifdef YYPARSE_PARAM_TYPE -# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) -# else -# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) +#line 329 "calc.c" + +}; +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 */ +/* Symbol kind. */ +enum yysymbol_kind_t +{ + YYSYMBOL_YYEMPTY = -2, + YYSYMBOL_YYEOF = 0, /* "end of file" */ + YYSYMBOL_YYerror = 1, /* error */ + YYSYMBOL_YYUNDEF = 2, /* "invalid token" */ + YYSYMBOL_EOS = 3, /* EOS */ + YYSYMBOL_BAD = 4, /* BAD */ + YYSYMBOL_HELP = 5, /* HELP */ + YYSYMBOL_HEX = 6, /* HEX */ + YYSYMBOL_DECIMAL = 7, /* DECIMAL */ + YYSYMBOL_QUIT = 8, /* QUIT */ + YYSYMBOL_ABS = 9, /* ABS */ + YYSYMBOL_BIN = 10, /* BIN */ + YYSYMBOL_FIB = 11, /* FIB */ + YYSYMBOL_GCD = 12, /* GCD */ + YYSYMBOL_KRON = 13, /* KRON */ + YYSYMBOL_LCM = 14, /* LCM */ + YYSYMBOL_LUCNUM = 15, /* LUCNUM */ + YYSYMBOL_NEXTPRIME = 16, /* NEXTPRIME */ + YYSYMBOL_POWM = 17, /* POWM */ + YYSYMBOL_ROOT = 18, /* ROOT */ + YYSYMBOL_SQRT = 19, /* SQRT */ + YYSYMBOL_NUMBER = 20, /* NUMBER */ + YYSYMBOL_VARIABLE = 21, /* VARIABLE */ + YYSYMBOL_LOR = 22, /* LOR */ + YYSYMBOL_LAND = 23, /* LAND */ + YYSYMBOL_24_ = 24, /* '<' */ + YYSYMBOL_25_ = 25, /* '>' */ + YYSYMBOL_EQ = 26, /* EQ */ + YYSYMBOL_NE = 27, /* NE */ + YYSYMBOL_LE = 28, /* LE */ + YYSYMBOL_GE = 29, /* GE */ + YYSYMBOL_LSHIFT = 30, /* LSHIFT */ + YYSYMBOL_RSHIFT = 31, /* RSHIFT */ + YYSYMBOL_32_ = 32, /* '+' */ + YYSYMBOL_33_ = 33, /* '-' */ + YYSYMBOL_34_ = 34, /* '*' */ + YYSYMBOL_35_ = 35, /* '/' */ + YYSYMBOL_36_ = 36, /* '%' */ + YYSYMBOL_UMINUS = 37, /* UMINUS */ + YYSYMBOL_38_ = 38, /* '^' */ + YYSYMBOL_39_ = 39, /* '!' */ + YYSYMBOL_40_ = 40, /* '=' */ + YYSYMBOL_41_ = 41, /* '(' */ + YYSYMBOL_42_ = 42, /* ')' */ + YYSYMBOL_43_ = 43, /* ',' */ + YYSYMBOL_YYACCEPT = 44, /* $accept */ + YYSYMBOL_top = 45, /* top */ + YYSYMBOL_statements = 46, /* statements */ + YYSYMBOL_statement = 47, /* statement */ + YYSYMBOL_e = 48, /* e */ + YYSYMBOL_gcdlist = 49, /* gcdlist */ + YYSYMBOL_lcmlist = 50 /* lcmlist */ +}; +typedef enum yysymbol_kind_t yysymbol_kind_t; + + + + +#ifdef short +# undef short +#endif + +/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure + and (if available) are included + so that the code can choose integer types of a good width. */ + +#ifndef __PTRDIFF_MAX__ +# include /* INFRINGES ON USER NAME SPACE */ +# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_STDINT_H # endif +#endif + +/* Narrow types that promote to a signed type and that can represent a + signed or unsigned integer of at least N bits. In tables they can + save space and decrease cache pressure. Promoting to a signed type + helps avoid bugs in integer arithmetic. */ + +#ifdef __INT_LEAST8_MAX__ +typedef __INT_LEAST8_TYPE__ yytype_int8; +#elif defined YY_STDINT_H +typedef int_least8_t yytype_int8; #else -# define YYPARSE_DECL() yyparse(void) +typedef signed char yytype_int8; #endif -/* Parameters sent to lex. */ -#ifdef YYLEX_PARAM -# define YYLEX_DECL() yylex(void *YYLEX_PARAM) -# define YYLEX yylex(YYLEX_PARAM) +#ifdef __INT_LEAST16_MAX__ +typedef __INT_LEAST16_TYPE__ yytype_int16; +#elif defined YY_STDINT_H +typedef int_least16_t yytype_int16; #else -# define YYLEX_DECL() yylex(void) -# define YYLEX yylex() +typedef short yytype_int16; #endif -/* Parameters sent to yyerror. */ -#ifndef YYERROR_DECL -#define YYERROR_DECL() yyerror(const char *s) -#endif -#ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(msg) +#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__ +typedef __UINT_LEAST8_TYPE__ yytype_uint8; +#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \ + && UINT_LEAST8_MAX <= INT_MAX) +typedef uint_least8_t yytype_uint8; +#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX +typedef unsigned char yytype_uint8; +#else +typedef short yytype_uint8; #endif -extern int YYPARSE_DECL(); - -#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 -#define YYERRCODE 256 -typedef int YYINT; -static const YYINT yylhs[] = { -1, - 0, 0, 2, 2, 2, 1, 1, 1, 1, 1, - 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 4, 4, 5, 5, -}; -static const YYINT yylen[] = { 2, - 1, 2, 2, 3, 2, 0, 1, 3, 1, 1, - 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 2, 2, 3, 3, 3, 3, 3, 3, 3, - 3, 4, 6, 4, 4, 6, 4, 4, 4, 8, - 6, 4, 1, 1, 1, 3, 1, 3, -}; -static const YYINT yydefred[] = { 0, - 0, 9, 10, 11, 12, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 44, 0, 0, 0, - 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 43, 0, 0, - 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 22, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 13, 4, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 32, 0, 34, 35, 0, 0, 37, 0, 38, - 39, 0, 0, 42, 0, 0, 0, 0, 0, 0, - 33, 36, 0, 41, 0, 40, -}; -static const YYINT yydgoto[] = { 21, - 22, 23, 24, 64, 67, -}; -static const YYINT yysindex[] = { 742, - -257, 0, 0, 0, 0, -22, -20, -17, -5, 5, - 18, 20, 22, 25, 28, 29, 0, -54, 808, 808, - 0, -244, 786, 667, 0, 808, 808, 808, 808, 808, - 808, 808, 808, 808, 808, 808, 808, 0, -27, 203, - 0, -217, 808, 808, 808, 808, 808, 808, 808, 808, - 808, 808, 808, 808, 808, 808, 808, 808, 0, 454, - 465, 487, 667, -33, 498, 667, -16, 520, 531, 542, - 564, 586, 667, 0, 0, 678, 929, -28, -28, -28, - -28, -28, -28, -21, -21, -6, -6, -27, -27, -27, - -27, 0, 808, 0, 0, 808, 808, 0, 808, 0, - 0, 808, 808, 0, 597, 667, 608, 667, 619, 645, - 0, 0, 808, 0, 656, 0, -}; -static const YYINT yyrindex[] = { 2, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, - 0, 50, 2, 3, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, - 0, 71, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -12, 0, 0, -11, 0, 0, 0, 0, - 0, 0, 4, 0, 0, 193, 64, 166, 178, 182, - 187, 189, 191, 139, 151, 112, 124, 37, 49, 76, - 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, -2, 0, 15, 0, 0, - 0, 0, 0, 0, 0, 0, -}; -static const YYINT yygindex[] = { 0, - 52, 0, 1065, 0, 0, -}; -#define YYTABLESIZE 1212 -static const YYINT yytable[] = { 25, - 43, 6, 7, 8, 59, 59, 37, 95, 57, 23, - 96, 59, 41, 55, 53, 57, 54, 26, 56, 27, - 55, 53, 28, 54, 98, 56, 59, 99, 45, 47, - 57, 45, 47, 43, 29, 55, 16, 43, 46, 75, - 56, 46, 43, 43, 30, 43, 23, 43, 17, 1, - 23, 23, 23, 23, 23, 48, 23, 31, 48, 32, - 43, 33, 43, 30, 34, 58, 58, 35, 36, 23, - 2, 23, 58, 16, 42, 18, 0, 16, 16, 16, - 16, 16, 0, 16, 19, 17, 0, 58, 0, 17, - 17, 17, 17, 17, 43, 17, 16, 0, 16, 0, - 0, 0, 0, 0, 30, 0, 0, 30, 17, 0, - 17, 14, 18, 0, 0, 0, 18, 18, 18, 18, - 18, 19, 18, 15, 0, 19, 19, 19, 19, 19, - 0, 19, 0, 0, 0, 18, 0, 18, 20, 0, - 0, 0, 0, 0, 19, 0, 19, 0, 0, 0, - 21, 0, 14, 0, 14, 14, 14, 0, 0, 0, - 0, 0, 0, 0, 15, 24, 15, 15, 15, 0, - 0, 14, 0, 14, 0, 0, 0, 29, 0, 20, - 0, 26, 20, 15, 0, 15, 27, 0, 25, 0, - 28, 21, 31, 0, 21, 0, 0, 0, 20, 0, - 20, 0, 0, 0, 0, 0, 24, 0, 0, 24, - 21, 0, 21, 0, 0, 0, 0, 0, 29, 0, - 0, 29, 26, 0, 0, 26, 0, 27, 0, 25, - 27, 28, 25, 31, 28, 59, 31, 0, 0, 57, - 0, 0, 0, 74, 55, 53, 0, 54, 0, 56, - 0, 0, 0, 51, 52, 0, 0, 43, 6, 7, - 8, 0, 45, 0, 46, 0, 23, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 43, 43, 43, 43, - 43, 43, 43, 43, 0, 23, 23, 23, 23, 23, - 23, 23, 23, 16, 0, 0, 58, 0, 0, 0, - 0, 0, 0, 0, 0, 17, 0, 0, 0, 0, - 0, 0, 16, 16, 16, 16, 16, 16, 16, 16, - 30, 0, 0, 0, 17, 17, 17, 17, 17, 17, - 17, 17, 18, 0, 0, 0, 0, 0, 0, 30, - 30, 19, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 18, 18, 18, 18, 18, 18, 18, 18, 0, - 19, 19, 19, 19, 19, 19, 19, 19, 14, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 15, 0, 0, 0, 0, 0, 0, 14, 14, 14, - 14, 14, 14, 14, 14, 20, 0, 0, 0, 15, - 15, 15, 15, 15, 15, 15, 15, 21, 0, 0, - 0, 0, 0, 0, 20, 20, 20, 20, 20, 20, - 20, 20, 24, 0, 0, 0, 21, 21, 21, 21, - 21, 21, 21, 21, 29, 0, 0, 0, 26, 0, - 0, 24, 24, 27, 0, 25, 0, 28, 0, 31, - 0, 0, 0, 29, 29, 0, 0, 26, 26, 0, - 0, 0, 27, 27, 25, 25, 28, 28, 31, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 43, 44, - 47, 48, 49, 50, 51, 52, 59, 0, 0, 0, - 57, 0, 0, 0, 92, 55, 53, 59, 54, 0, - 56, 57, 0, 0, 0, 0, 55, 53, 93, 54, - 0, 56, 0, 45, 0, 46, 0, 0, 0, 59, - 0, 0, 0, 57, 45, 0, 46, 94, 55, 53, - 59, 54, 0, 56, 57, 0, 0, 0, 0, 55, - 53, 97, 54, 0, 56, 0, 45, 58, 46, 0, - 0, 0, 59, 0, 0, 0, 57, 45, 58, 46, - 100, 55, 53, 59, 54, 0, 56, 57, 0, 0, - 0, 101, 55, 53, 59, 54, 0, 56, 57, 45, - 58, 46, 0, 55, 53, 102, 54, 0, 56, 0, - 45, 58, 46, 0, 0, 0, 59, 0, 0, 0, - 57, 45, 0, 46, 0, 55, 53, 103, 54, 0, - 56, 0, 0, 58, 0, 0, 0, 0, 59, 0, - 0, 0, 57, 45, 58, 46, 104, 55, 53, 59, - 54, 0, 56, 57, 0, 58, 0, 111, 55, 53, - 59, 54, 0, 56, 57, 45, 0, 46, 112, 55, - 53, 59, 54, 0, 56, 57, 45, 58, 46, 0, - 55, 53, 113, 54, 0, 56, 0, 45, 0, 46, - 0, 0, 0, 0, 0, 0, 0, 59, 45, 58, - 46, 57, 0, 0, 0, 114, 55, 53, 59, 54, - 58, 56, 57, 0, 0, 0, 116, 55, 53, 59, - 54, 58, 56, 57, 45, 0, 46, 0, 55, 53, - 59, 54, 58, 56, 57, 45, 0, 46, 0, 55, - 53, 0, 54, 0, 56, 0, 45, 0, 46, 43, - 44, 47, 48, 49, 50, 51, 52, 45, 58, 46, - 43, 44, 47, 48, 49, 50, 51, 52, 0, 58, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 58, 0, 43, 44, 47, 48, 49, 50, 51, 52, - 0, 58, 0, 43, 44, 47, 48, 49, 50, 51, - 52, 20, 0, 0, 0, 0, 19, 0, 0, 0, - 0, 0, 0, 0, 0, 43, 44, 47, 48, 49, - 50, 51, 52, 0, 0, 0, 43, 44, 47, 48, - 49, 50, 51, 52, 0, 0, 0, 43, 44, 47, - 48, 49, 50, 51, 52, 20, 0, 0, 0, 0, - 19, 0, 0, 0, 0, 0, 0, 0, 0, 43, - 44, 47, 48, 49, 50, 51, 52, 20, 0, 0, - 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, - 0, 43, 44, 47, 48, 49, 50, 51, 52, 0, - 0, 0, 43, 44, 47, 48, 49, 50, 51, 52, - 0, 0, 0, 43, 44, 47, 48, 49, 50, 51, - 52, 0, 0, 0, 43, 44, 47, 48, 49, 50, - 51, 52, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 43, 44, 47, 48, 49, 50, 51, 52, 0, 0, - 0, 43, 44, 47, 48, 49, 50, 51, 52, 0, - 0, 0, 43, 44, 47, 48, 49, 50, 51, 52, - 0, 0, 0, 0, 44, 47, 48, 49, 50, 51, - 52, 59, 0, 0, 0, 57, 0, 0, 0, 0, - 55, 53, 0, 54, 0, 56, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 45, 0, - 46, 0, 0, 0, 0, 0, 0, 1, 0, 0, - 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 17, 18, 0, 0, 0, - 0, 0, 58, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 2, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, - 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 38, 39, 40, 0, 0, 0, 0, 0, - 60, 61, 62, 63, 65, 66, 68, 69, 70, 71, - 72, 73, 0, 0, 0, 0, 0, 76, 77, 78, - 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, - 89, 90, 91, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 105, 0, 0, - 106, 107, 0, 108, 0, 0, 109, 110, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 115, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 47, 48, 49, 50, - 51, 52, -}; -static const YYINT yycheck[] = { 257, - 0, 0, 0, 0, 33, 33, 61, 41, 37, 0, - 44, 33, 257, 42, 43, 37, 45, 40, 47, 40, - 42, 43, 40, 45, 41, 47, 33, 44, 41, 41, - 37, 44, 44, 33, 40, 42, 0, 37, 41, 257, - 47, 44, 42, 43, 40, 45, 37, 47, 0, 0, - 41, 42, 43, 44, 45, 41, 47, 40, 44, 40, - 60, 40, 62, 0, 40, 94, 94, 40, 40, 60, - 0, 62, 94, 37, 23, 0, -1, 41, 42, 43, - 44, 45, -1, 47, 0, 37, -1, 94, -1, 41, - 42, 43, 44, 45, 94, 47, 60, -1, 62, -1, - -1, -1, -1, -1, 41, -1, -1, 44, 60, -1, - 62, 0, 37, -1, -1, -1, 41, 42, 43, 44, - 45, 37, 47, 0, -1, 41, 42, 43, 44, 45, - -1, 47, -1, -1, -1, 60, -1, 62, 0, -1, - -1, -1, -1, -1, 60, -1, 62, -1, -1, -1, - 0, -1, 41, -1, 43, 44, 45, -1, -1, -1, - -1, -1, -1, -1, 41, 0, 43, 44, 45, -1, - -1, 60, -1, 62, -1, -1, -1, 0, -1, 41, - -1, 0, 44, 60, -1, 62, 0, -1, 0, -1, - 0, 41, 0, -1, 44, -1, -1, -1, 60, -1, - 62, -1, -1, -1, -1, -1, 41, -1, -1, 44, - 60, -1, 62, -1, -1, -1, -1, -1, 41, -1, - -1, 44, 41, -1, -1, 44, -1, 41, -1, 41, - 44, 41, 44, 41, 44, 33, 44, -1, -1, 37, - -1, -1, -1, 41, 42, 43, -1, 45, -1, 47, - -1, -1, -1, 282, 283, -1, -1, 257, 257, 257, - 257, -1, 60, -1, 62, -1, 257, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 276, 277, 278, 279, - 280, 281, 282, 283, -1, 276, 277, 278, 279, 280, - 281, 282, 283, 257, -1, -1, 94, -1, -1, -1, - -1, -1, -1, -1, -1, 257, -1, -1, -1, -1, - -1, -1, 276, 277, 278, 279, 280, 281, 282, 283, - 257, -1, -1, -1, 276, 277, 278, 279, 280, 281, - 282, 283, 257, -1, -1, -1, -1, -1, -1, 276, - 277, 257, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 276, 277, 278, 279, 280, 281, 282, 283, -1, - 276, 277, 278, 279, 280, 281, 282, 283, 257, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 257, -1, -1, -1, -1, -1, -1, 276, 277, 278, - 279, 280, 281, 282, 283, 257, -1, -1, -1, 276, - 277, 278, 279, 280, 281, 282, 283, 257, -1, -1, - -1, -1, -1, -1, 276, 277, 278, 279, 280, 281, - 282, 283, 257, -1, -1, -1, 276, 277, 278, 279, - 280, 281, 282, 283, 257, -1, -1, -1, 257, -1, - -1, 276, 277, 257, -1, 257, -1, 257, -1, 257, - -1, -1, -1, 276, 277, -1, -1, 276, 277, -1, - -1, -1, 276, 277, 276, 277, 276, 277, 276, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 276, 277, - 278, 279, 280, 281, 282, 283, 33, -1, -1, -1, - 37, -1, -1, -1, 41, 42, 43, 33, 45, -1, - 47, 37, -1, -1, -1, -1, 42, 43, 44, 45, - -1, 47, -1, 60, -1, 62, -1, -1, -1, 33, - -1, -1, -1, 37, 60, -1, 62, 41, 42, 43, - 33, 45, -1, 47, 37, -1, -1, -1, -1, 42, - 43, 44, 45, -1, 47, -1, 60, 94, 62, -1, - -1, -1, 33, -1, -1, -1, 37, 60, 94, 62, - 41, 42, 43, 33, 45, -1, 47, 37, -1, -1, - -1, 41, 42, 43, 33, 45, -1, 47, 37, 60, - 94, 62, -1, 42, 43, 44, 45, -1, 47, -1, - 60, 94, 62, -1, -1, -1, 33, -1, -1, -1, - 37, 60, -1, 62, -1, 42, 43, 44, 45, -1, - 47, -1, -1, 94, -1, -1, -1, -1, 33, -1, - -1, -1, 37, 60, 94, 62, 41, 42, 43, 33, - 45, -1, 47, 37, -1, 94, -1, 41, 42, 43, - 33, 45, -1, 47, 37, 60, -1, 62, 41, 42, - 43, 33, 45, -1, 47, 37, 60, 94, 62, -1, - 42, 43, 44, 45, -1, 47, -1, 60, -1, 62, - -1, -1, -1, -1, -1, -1, -1, 33, 60, 94, - 62, 37, -1, -1, -1, 41, 42, 43, 33, 45, - 94, 47, 37, -1, -1, -1, 41, 42, 43, 33, - 45, 94, 47, 37, 60, -1, 62, -1, 42, 43, - 33, 45, 94, 47, 37, 60, -1, 62, -1, 42, - 43, -1, 45, -1, 47, -1, 60, -1, 62, 276, - 277, 278, 279, 280, 281, 282, 283, 60, 94, 62, - 276, 277, 278, 279, 280, 281, 282, 283, -1, 94, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 94, -1, 276, 277, 278, 279, 280, 281, 282, 283, - -1, 94, -1, 276, 277, 278, 279, 280, 281, 282, - 283, 40, -1, -1, -1, -1, 45, -1, -1, -1, - -1, -1, -1, -1, -1, 276, 277, 278, 279, 280, - 281, 282, 283, -1, -1, -1, 276, 277, 278, 279, - 280, 281, 282, 283, -1, -1, -1, 276, 277, 278, - 279, 280, 281, 282, 283, 40, -1, -1, -1, -1, - 45, -1, -1, -1, -1, -1, -1, -1, -1, 276, - 277, 278, 279, 280, 281, 282, 283, 40, -1, -1, - -1, -1, 45, -1, -1, -1, -1, -1, -1, -1, - -1, 276, 277, 278, 279, 280, 281, 282, 283, -1, - -1, -1, 276, 277, 278, 279, 280, 281, 282, 283, - -1, -1, -1, 276, 277, 278, 279, 280, 281, 282, - 283, -1, -1, -1, 276, 277, 278, 279, 280, 281, - 282, 283, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 276, 277, 278, 279, 280, 281, 282, 283, -1, -1, - -1, 276, 277, 278, 279, 280, 281, 282, 283, -1, - -1, -1, 276, 277, 278, 279, 280, 281, 282, 283, - -1, -1, -1, -1, 277, 278, 279, 280, 281, 282, - 283, 33, -1, -1, -1, 37, -1, -1, -1, -1, - 42, 43, -1, 45, -1, 47, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 60, -1, - 62, -1, -1, -1, -1, -1, -1, 256, -1, -1, - 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, - 269, 270, 271, 272, 273, 274, 275, -1, -1, -1, - -1, -1, 94, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, - 273, 274, 275, 19, 20, -1, -1, -1, -1, -1, - 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - 36, 37, -1, -1, -1, -1, -1, 43, 44, 45, - 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 93, -1, -1, - 96, 97, -1, 99, -1, -1, 102, 103, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 113, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 278, 279, 280, 281, - 282, 283, -}; -#define YYFINAL 21 -#ifndef YYDEBUG -#define YYDEBUG 0 +#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__ +typedef __UINT_LEAST16_TYPE__ yytype_uint16; +#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \ + && UINT_LEAST16_MAX <= INT_MAX) +typedef uint_least16_t yytype_uint16; +#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX +typedef unsigned short yytype_uint16; +#else +typedef int yytype_uint16; #endif -#define YYMAXTOKEN 284 -#define YYUNDFTOKEN 292 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) + +#ifndef YYPTRDIFF_T +# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__ +# define YYPTRDIFF_T __PTRDIFF_TYPE__ +# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__ +# elif defined PTRDIFF_MAX +# ifndef ptrdiff_t +# include /* INFRINGES ON USER NAME SPACE */ +# endif +# define YYPTRDIFF_T ptrdiff_t +# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX +# else +# define YYPTRDIFF_T long +# define YYPTRDIFF_MAXIMUM LONG_MAX +# endif +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned +# endif +#endif + +#define YYSIZE_MAXIMUM \ + YY_CAST (YYPTRDIFF_T, \ + (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \ + ? YYPTRDIFF_MAXIMUM \ + : YY_CAST (YYSIZE_T, -1))) + +#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X)) + + +/* Stored state numbers (used for stacks). */ +typedef yytype_int8 yy_state_t; + +/* State numbers in computations. */ +typedef int yy_state_fast_t; + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(Msgid) dgettext ("bison-runtime", Msgid) +# endif +# endif +# ifndef YY_ +# define YY_(Msgid) Msgid +# endif +#endif + + +#ifndef YY_ATTRIBUTE_PURE +# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__) +# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__)) +# else +# define YY_ATTRIBUTE_PURE +# endif +#endif + +#ifndef YY_ATTRIBUTE_UNUSED +# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__) +# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) +# else +# define YY_ATTRIBUTE_UNUSED +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(E) ((void) (E)) +#else +# define YYUSE(E) /* empty */ +#endif + +#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +/* Suppress an incorrect diagnostic about yylval being uninitialized. */ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \ + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ + _Pragma ("GCC diagnostic pop") +#else +# define YY_INITIAL_VALUE(Value) Value +#endif +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#endif +#ifndef YY_INITIAL_VALUE +# define YY_INITIAL_VALUE(Value) /* Nothing. */ +#endif + +#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__ +# define YY_IGNORE_USELESS_CAST_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"") +# define YY_IGNORE_USELESS_CAST_END \ + _Pragma ("GCC diagnostic pop") +#endif +#ifndef YY_IGNORE_USELESS_CAST_BEGIN +# define YY_IGNORE_USELESS_CAST_BEGIN +# define YY_IGNORE_USELESS_CAST_END +#endif + + +#define YY_ASSERT(E) ((void) (0 && (E))) + +#if !defined yyoverflow + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS +# include /* INFRINGES ON USER NAME SPACE */ + /* Use EXIT_SUCCESS as a witness for stdlib.h. */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's 'empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined EXIT_SUCCESS \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined EXIT_SUCCESS +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined EXIT_SUCCESS +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* !defined yyoverflow */ + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yy_state_t yyss_alloc; + YYSTYPE yyvs_alloc; +}; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +# define YYCOPY_NEEDED 1 + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYPTRDIFF_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / YYSIZEOF (*yyptr); \ + } \ + while (0) + +#endif + +#if defined YYCOPY_NEEDED && YYCOPY_NEEDED +/* Copy COUNT objects from SRC to DST. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(Dst, Src, Count) \ + __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src))) +# else +# define YYCOPY(Dst, Src, Count) \ + do \ + { \ + YYPTRDIFF_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (Dst)[yyi] = (Src)[yyi]; \ + } \ + while (0) +# endif +# endif +#endif /* !YYCOPY_NEEDED */ + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 41 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 552 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 44 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 7 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 49 +/* YYNSTATES -- Number of states. */ +#define YYNSTATES 118 + +#define YYMAXUTOK 285 + + +/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, with out-of-bounds checking. */ +#define YYTRANSLATE(YYX) \ + (0 <= (YYX) && (YYX) <= YYMAXUTOK \ + ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \ + : YYSYMBOL_YYUNDEF) + +/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM + as returned by yylex. */ +static const yytype_int8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 39, 2, 2, 2, 36, 2, 2, + 41, 42, 34, 32, 43, 33, 2, 35, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 24, 40, 25, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 38, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 26, + 27, 28, 29, 30, 31, 37 +}; + #if YYDEBUG -static const char *const yyname[] = { - -"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -"'!'",0,0,0,"'%'",0,0,"'('","')'","'*'","'+'","','","'-'",0,"'/'",0,0,0,0,0,0,0, -0,0,0,0,0,"'<'","'='","'>'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,"'^'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,"EOS","BAD","HELP","HEX","DECIMAL","QUIT","ABS","BIN","FIB", -"GCD","KRON","LCM","LUCNUM","NEXTPRIME","POWM","ROOT","SQRT","NUMBER", -"VARIABLE","LOR","LAND","EQ","NE","LE","GE","LSHIFT","RSHIFT","UMINUS",0,0,0,0, -0,0,0,"illegal-symbol", -}; -static const char *const yyrule[] = { -"$accept : top", -"top : statement", -"top : statements statement", -"statements : statement EOS", -"statements : statements statement EOS", -"statements : error EOS", -"statement :", -"statement : e", -"statement : VARIABLE '=' e", -"statement : HELP", -"statement : HEX", -"statement : DECIMAL", -"statement : QUIT", -"e : '(' e ')'", -"e : e '+' e", -"e : e '-' e", -"e : e '*' e", -"e : e '/' e", -"e : e '%' e", -"e : e '^' e", -"e : e LSHIFT e", -"e : e RSHIFT e", -"e : e '!'", -"e : '-' e", -"e : e '<' e", -"e : e LE e", -"e : e EQ e", -"e : e NE e", -"e : e GE e", -"e : e '>' e", -"e : e LAND e", -"e : e LOR e", -"e : ABS '(' e ')'", -"e : BIN '(' e ',' e ')'", -"e : FIB '(' e ')'", -"e : GCD '(' gcdlist ')'", -"e : KRON '(' e ',' e ')'", -"e : LCM '(' lcmlist ')'", -"e : LUCNUM '(' e ')'", -"e : NEXTPRIME '(' e ')'", -"e : POWM '(' e ',' e ',' e ')'", -"e : ROOT '(' e ',' e ')'", -"e : SQRT '(' e ')'", -"e : VARIABLE", -"e : NUMBER", -"gcdlist : e", -"gcdlist : gcdlist ',' e", -"lcmlist : e", -"lcmlist : lcmlist ',' e", - + /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ +static const yytype_int16 yyrline[] = +{ + 0, 167, 167, 168, 171, 172, 173, 175, 177, 182, + 188, 189, 190, 191, 197, 198, 199, 200, 201, 202, + 203, 205, 207, 209, 211, 213, 214, 215, 216, 217, + 218, 220, 221, 223, 224, 226, 228, 229, 231, 232, + 234, 235, 236, 238, 240, 246, 257, 258, 261, 262 }; #endif -int yydebug; -int yynerrs; +/** Accessing symbol of state STATE. */ +#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State]) -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; +#if YYDEBUG || 0 +/* The user-facing name of the symbol whose (internal) number is + YYSYMBOL. No bounds checking. */ +static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED; -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "\"end of file\"", "error", "\"invalid token\"", "EOS", "BAD", "HELP", + "HEX", "DECIMAL", "QUIT", "ABS", "BIN", "FIB", "GCD", "KRON", "LCM", + "LUCNUM", "NEXTPRIME", "POWM", "ROOT", "SQRT", "NUMBER", "VARIABLE", + "LOR", "LAND", "'<'", "'>'", "EQ", "NE", "LE", "GE", "LSHIFT", "RSHIFT", + "'+'", "'-'", "'*'", "'/'", "'%'", "UMINUS", "'^'", "'!'", "'='", "'('", + "')'", "','", "$accept", "top", "statements", "statement", "e", + "gcdlist", "lcmlist", YY_NULLPTR +}; + +static const char * +yysymbol_name (yysymbol_kind_t yysymbol) +{ + return yytname[yysymbol]; +} #endif -#define YYINITSTACKSIZE 200 +#ifdef YYPRINT +/* YYTOKNUM[NUM] -- (External) token number corresponding to the + (internal) symbol number NUM (which must be that of a token). */ +static const yytype_int16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 60, 62, 279, 280, 281, 282, + 283, 284, 43, 45, 42, 47, 37, 285, 94, 33, + 61, 40, 41, 44 +}; +#endif + +#define YYPACT_NINF (-39) + +#define yypact_value_is_default(Yyn) \ + ((Yyn) == YYPACT_NINF) + +#define YYTABLE_NINF (-8) + +#define yytable_value_is_error(Yyn) \ + ((Yyn) == YYTABLE_NINF) + + /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +static const yytype_int16 yypact[] = +{ + 41, 3, -39, -39, -39, -39, 2, 4, 27, 32, + 35, 36, 39, 42, 45, 46, 47, -39, -18, 124, + 124, 89, 91, 87, 464, -39, 124, 124, 124, 124, + 124, 124, 124, 124, 124, 124, 124, 124, -39, -36, + 254, -39, 88, -39, 124, 124, 124, 124, 124, 124, + 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, + -39, 275, 144, 296, 464, -38, 166, 464, 29, 317, + 338, 188, 210, 359, 464, -39, -39, 481, 497, 513, + 513, 513, 513, 513, 513, 31, 31, -15, -15, -36, + -36, -36, -36, -39, 124, -39, -39, 124, 124, -39, + 124, -39, -39, 124, 124, -39, 380, 464, 401, 464, + 232, 422, -39, -39, 124, -39, 443, -39 +}; + + /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE does not specify something else to do. Zero + means the default is an error. */ +static const yytype_int8 yydefact[] = +{ + 0, 0, 10, 11, 12, 13, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 45, 44, 0, + 0, 0, 7, 2, 8, 6, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 44, 24, + 0, 1, 3, 4, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 23, 0, 0, 0, 46, 0, 0, 48, 0, 0, + 0, 0, 0, 0, 9, 14, 5, 32, 31, 25, + 30, 27, 28, 26, 29, 21, 22, 15, 16, 17, + 18, 19, 20, 33, 0, 35, 36, 0, 0, 38, + 0, 39, 40, 0, 0, 43, 0, 47, 0, 49, + 0, 0, 34, 37, 0, 42, 0, 41 +}; + + /* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -39, -39, -39, 70, -19, -39, -39 +}; + + /* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 21, 22, 23, 24, 65, 68 +}; + + /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule whose + number is the opposite. If YYTABLE_NINF, syntax error. */ +static const yytype_int8 yytable[] = +{ + 39, 40, 59, 60, 96, 97, 25, 61, 62, 63, + 64, 66, 67, 69, 70, 71, 72, 73, 74, 56, + 57, 58, 37, 59, 60, 77, 78, 79, 80, 81, + 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, + 92, -7, 1, 26, -7, 27, 2, 3, 4, 5, + 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 54, 55, 56, 57, 58, 28, 59, + 60, 99, 100, 29, 19, 106, 30, 31, 107, 108, + 32, 109, 20, 33, 110, 111, 34, 35, 36, 41, + 43, 76, 42, 0, 0, 116, 2, 3, 4, 5, + 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, + 0, 0, 20, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 38, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, + 0, 0, 0, 0, 0, 20, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 0, 59, 60, 0, 0, 0, 94, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 0, 59, 60, 0, 0, 0, 98, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 0, 59, 60, 0, 0, + 0, 103, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 0, 59, 60, + 0, 0, 0, 104, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 0, + 59, 60, 0, 0, 0, 114, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 0, 59, 60, 0, 0, 75, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 0, 59, 60, 0, 0, 93, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 0, 59, 60, 0, 0, 95, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 0, 59, 60, 0, 0, 101, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 0, 59, 60, 0, 0, + 102, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 0, 59, 60, 0, + 0, 105, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 0, 59, 60, + 0, 0, 112, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 0, 59, + 60, 0, 0, 113, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 0, + 59, 60, 0, 0, 115, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 0, 59, 60, 0, 0, 117, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 0, 59, 60, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 0, 59, + 60, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 0, 59, 60, -8, -8, -8, + -8, -8, -8, 52, 53, 54, 55, 56, 57, 58, + 0, 59, 60 +}; + +static const yytype_int8 yycheck[] = +{ + 19, 20, 38, 39, 42, 43, 3, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 34, + 35, 36, 40, 38, 39, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 0, 1, 41, 3, 41, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 32, 33, 34, 35, 36, 41, 38, + 39, 42, 43, 41, 33, 94, 41, 41, 97, 98, + 41, 100, 41, 41, 103, 104, 41, 41, 41, 0, + 3, 3, 22, -1, -1, 114, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, + 19, 20, 21, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 33, -1, -1, -1, -1, -1, + -1, -1, 41, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 33, -1, -1, + -1, -1, -1, -1, -1, 41, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + 36, -1, 38, 39, -1, -1, -1, 43, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, -1, 38, 39, -1, -1, -1, 43, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, -1, 38, 39, -1, -1, + -1, 43, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, -1, 38, 39, + -1, -1, -1, 43, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, -1, + 38, 39, -1, -1, -1, 43, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + 36, -1, 38, 39, -1, -1, 42, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, -1, 38, 39, -1, -1, 42, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, -1, 38, 39, -1, -1, 42, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, -1, 38, 39, -1, -1, 42, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, -1, 38, 39, -1, -1, + 42, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, -1, 38, 39, -1, + -1, 42, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, -1, 38, 39, + -1, -1, 42, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, -1, 38, + 39, -1, -1, 42, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, -1, + 38, 39, -1, -1, 42, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, + -1, 38, 39, -1, -1, 42, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + 36, -1, 38, 39, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, -1, 38, + 39, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, -1, 38, 39, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, + -1, 38, 39 +}; + + /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_int8 yystos[] = +{ + 0, 1, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 33, + 41, 45, 46, 47, 48, 3, 41, 41, 41, 41, + 41, 41, 41, 41, 41, 41, 41, 40, 21, 48, + 48, 0, 47, 3, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 38, + 39, 48, 48, 48, 48, 49, 48, 48, 50, 48, + 48, 48, 48, 48, 48, 42, 3, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 42, 43, 42, 42, 43, 43, 42, + 43, 42, 42, 43, 43, 42, 48, 48, 48, 48, + 48, 48, 42, 42, 43, 42, 48, 42 +}; + + /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_int8 yyr1[] = +{ + 0, 44, 45, 45, 46, 46, 46, 47, 47, 47, + 47, 47, 47, 47, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 49, 49, 50, 50 +}; + + /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ +static const yytype_int8 yyr2[] = +{ + 0, 2, 1, 2, 2, 3, 2, 0, 1, 3, + 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 2, 3, 3, 3, 3, 3, + 3, 3, 3, 4, 6, 4, 4, 6, 4, 4, + 4, 8, 6, 4, 1, 1, 1, 3, 1, 3 +}; + + +enum { YYENOMEM = -2 }; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ + do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ + while (0) + +/* Backward compatibility with an undocumented macro. + Use YYerror or YYUNDEF. */ +#define YYERRCODE YYUNDEF + + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + +/* This macro is provided for backward compatibility. */ +# ifndef YY_LOCATION_PRINT +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif + + +# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Kind, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + + +/*-----------------------------------. +| Print this symbol's value on YYO. | +`-----------------------------------*/ + +static void +yy_symbol_value_print (FILE *yyo, + yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep) +{ + FILE *yyoutput = yyo; + YYUSE (yyoutput); + if (!yyvaluep) + return; +# ifdef YYPRINT + if (yykind < YYNTOKENS) + YYPRINT (yyo, yytoknum[yykind], *yyvaluep); +# endif + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + YYUSE (yykind); + YY_IGNORE_MAYBE_UNINITIALIZED_END +} + + +/*---------------------------. +| Print this symbol on YYO. | +`---------------------------*/ + +static void +yy_symbol_print (FILE *yyo, + yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep) +{ + YYFPRINTF (yyo, "%s %s (", + yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind)); + + yy_symbol_value_print (yyo, yykind, yyvaluep); + YYFPRINTF (yyo, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +static void +yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop) +{ + YYFPRINTF (stderr, "Stack now"); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +static void +yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, + int yyrule) +{ + int yylno = yyrline[yyrule]; + int yynrhs = yyr2[yyrule]; + int yyi; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, + YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]), + &yyvsp[(yyi + 1) - (yynrhs)]); + YYFPRINTF (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyssp, yyvsp, Rule); \ +} while (0) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) ((void) 0) +# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + + + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +static void +yydestruct (const char *yymsg, + yysymbol_kind_t yykind, YYSTYPE *yyvaluep) +{ + YYUSE (yyvaluep); + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp); + + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + YYUSE (yykind); + YY_IGNORE_MAYBE_UNINITIALIZED_END +} + + +/* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; +/* Number of syntax errors so far. */ +int yynerrs; + + + + +/*----------. +| yyparse. | +`----------*/ + +int +yyparse (void) +{ + yy_state_fast_t yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + 'yyss': related to states. + 'yyvs': related to semantic values. + + Refer to the stacks through separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* Their size. */ + YYPTRDIFF_T yystacksize; + + /* The state stack. */ + yy_state_t yyssa[YYINITDEPTH]; + yy_state_t *yyss; + yy_state_t *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + int yyn; + /* The return value of yyparse. */ + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + yynerrs = 0; + yystate = 0; + yyerrstatus = 0; + + yystacksize = YYINITDEPTH; + yyssp = yyss = yyssa; + yyvsp = yyvs = yyvsa; + + + YYDPRINTF ((stderr, "Starting parse\n")); + + yychar = YYEMPTY; /* Cause a token to be read. */ + goto yysetstate; + + +/*------------------------------------------------------------. +| yynewstate -- push a new state, which is found in yystate. | +`------------------------------------------------------------*/ +yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + +/*--------------------------------------------------------------------. +| yysetstate -- set current state (the top of the stack) to yystate. | +`--------------------------------------------------------------------*/ +yysetstate: + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + YY_ASSERT (0 <= yystate && yystate < YYNSTATES); + YY_IGNORE_USELESS_CAST_BEGIN + *yyssp = YY_CAST (yy_state_t, yystate); + YY_IGNORE_USELESS_CAST_END + YY_STACK_PRINT (yyss, yyssp); + + if (yyss + yystacksize - 1 <= yyssp) +#if !defined yyoverflow && !defined YYSTACK_RELOCATE + goto yyexhaustedlab; +#else + { + /* Get the current used size of the three stacks, in elements. */ + YYPTRDIFF_T yysize = yyssp - yyss + 1; + +# if defined yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + yy_state_t *yyss1 = yyss; + YYSTYPE *yyvs1 = yyvs; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * YYSIZEOF (*yyssp), + &yyvs1, yysize * YYSIZEOF (*yyvsp), + &yystacksize); + yyss = yyss1; + yyvs = yyvs1; + } +# else /* defined YYSTACK_RELOCATE */ + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yy_state_t *yyss1 = yyss; + union yyalloc *yyptr = + YY_CAST (union yyalloc *, + YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize)))); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + YY_IGNORE_USELESS_CAST_BEGIN + YYDPRINTF ((stderr, "Stack size increased to %ld\n", + YY_CAST (long, yystacksize))); + YY_IGNORE_USELESS_CAST_END + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } +#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ + + if (yystate == YYFINAL) + YYACCEPT; + + goto yybackup; + + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + /* Do appropriate processing given the current state. Read a + lookahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to lookahead token. */ + yyn = yypact[yystate]; + if (yypact_value_is_default (yyn)) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token\n")); + yychar = yylex (); + } + + if (yychar <= YYEOF) + { + yychar = YYEOF; + yytoken = YYSYMBOL_YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else if (yychar == YYerror) + { + /* The scanner already issued an error message, process directly + to error recovery. But do not keep the error token as + lookahead, it is too special and may lead us to an endless + loop in error recovery. */ + yychar = YYUNDEF; + yytoken = YYSYMBOL_YYerror; + goto yyerrlab1; + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yytable_value_is_error (yyn)) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the lookahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + yystate = yyn; + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END + + /* Discard the shifted token. */ + yychar = YYEMPTY; + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + '$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 6: +#line 173 "../../../gmp/demos/calc/calc.y" + { sp = stack[0]; yyerrok; } +#line 1516 "calc.c" + break; + + case 8: +#line 177 "../../../gmp/demos/calc/calc.y" + { + mpz_out_str (stdout, obase, sp); putchar ('\n'); + sp--; + CHECK_EMPTY (); + } +#line 1526 "calc.c" + break; + + case 9: +#line 182 "../../../gmp/demos/calc/calc.y" + { + CHECK_VARIABLE ((yyvsp[-2].var)); + mpz_swap (variable[(yyvsp[-2].var)], sp); + sp--; + CHECK_EMPTY (); + } +#line 1537 "calc.c" + break; + + case 10: +#line 188 "../../../gmp/demos/calc/calc.y" + { calc_help (); } +#line 1543 "calc.c" + break; + + case 11: +#line 189 "../../../gmp/demos/calc/calc.y" + { ibase = 16; obase = -16; } +#line 1549 "calc.c" + break; + + case 12: +#line 190 "../../../gmp/demos/calc/calc.y" + { ibase = 0; obase = 10; } +#line 1555 "calc.c" + break; + + case 13: +#line 191 "../../../gmp/demos/calc/calc.y" + { exit (0); } +#line 1561 "calc.c" + break; + + case 15: +#line 198 "../../../gmp/demos/calc/calc.y" + { sp--; mpz_add (sp, sp, sp+1); } +#line 1567 "calc.c" + break; + + case 16: +#line 199 "../../../gmp/demos/calc/calc.y" + { sp--; mpz_sub (sp, sp, sp+1); } +#line 1573 "calc.c" + break; + + case 17: +#line 200 "../../../gmp/demos/calc/calc.y" + { sp--; mpz_mul (sp, sp, sp+1); } +#line 1579 "calc.c" + break; + + case 18: +#line 201 "../../../gmp/demos/calc/calc.y" + { sp--; mpz_fdiv_q (sp, sp, sp+1); } +#line 1585 "calc.c" + break; + + case 19: +#line 202 "../../../gmp/demos/calc/calc.y" + { sp--; mpz_fdiv_r (sp, sp, sp+1); } +#line 1591 "calc.c" + break; + + case 20: +#line 203 "../../../gmp/demos/calc/calc.y" + { CHECK_UI ("Exponent", sp); + sp--; mpz_pow_ui (sp, sp, mpz_get_ui (sp+1)); } +#line 1598 "calc.c" + break; + + case 21: +#line 205 "../../../gmp/demos/calc/calc.y" + { CHECK_UI ("Shift count", sp); + sp--; mpz_mul_2exp (sp, sp, mpz_get_ui (sp+1)); } +#line 1605 "calc.c" + break; + + case 22: +#line 207 "../../../gmp/demos/calc/calc.y" + { CHECK_UI ("Shift count", sp); + sp--; mpz_fdiv_q_2exp (sp, sp, mpz_get_ui (sp+1)); } +#line 1612 "calc.c" + break; + + case 23: +#line 209 "../../../gmp/demos/calc/calc.y" + { CHECK_UI ("Factorial", sp); + mpz_fac_ui (sp, mpz_get_ui (sp)); } +#line 1619 "calc.c" + break; + + case 24: +#line 211 "../../../gmp/demos/calc/calc.y" + { mpz_neg (sp, sp); } +#line 1625 "calc.c" + break; + + case 25: +#line 213 "../../../gmp/demos/calc/calc.y" + { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) < 0); } +#line 1631 "calc.c" + break; + + case 26: +#line 214 "../../../gmp/demos/calc/calc.y" + { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) <= 0); } +#line 1637 "calc.c" + break; + + case 27: +#line 215 "../../../gmp/demos/calc/calc.y" + { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) == 0); } +#line 1643 "calc.c" + break; + + case 28: +#line 216 "../../../gmp/demos/calc/calc.y" + { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) != 0); } +#line 1649 "calc.c" + break; + + case 29: +#line 217 "../../../gmp/demos/calc/calc.y" + { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) >= 0); } +#line 1655 "calc.c" + break; + + case 30: +#line 218 "../../../gmp/demos/calc/calc.y" + { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) > 0); } +#line 1661 "calc.c" + break; + + case 31: +#line 220 "../../../gmp/demos/calc/calc.y" + { sp--; mpz_set_ui (sp, mpz_sgn (sp) && mpz_sgn (sp+1)); } +#line 1667 "calc.c" + break; + + case 32: +#line 221 "../../../gmp/demos/calc/calc.y" + { sp--; mpz_set_ui (sp, mpz_sgn (sp) || mpz_sgn (sp+1)); } +#line 1673 "calc.c" + break; + + case 33: +#line 223 "../../../gmp/demos/calc/calc.y" + { mpz_abs (sp, sp); } +#line 1679 "calc.c" + break; + + case 34: +#line 224 "../../../gmp/demos/calc/calc.y" + { sp--; CHECK_UI ("Binomial base", sp+1); + mpz_bin_ui (sp, sp, mpz_get_ui (sp+1)); } +#line 1686 "calc.c" + break; + + case 35: +#line 226 "../../../gmp/demos/calc/calc.y" + { CHECK_UI ("Fibonacci", sp); + mpz_fib_ui (sp, mpz_get_ui (sp)); } +#line 1693 "calc.c" + break; + + case 37: +#line 229 "../../../gmp/demos/calc/calc.y" + { sp--; mpz_set_si (sp, + mpz_kronecker (sp, sp+1)); } +#line 1700 "calc.c" + break; + + case 39: +#line 232 "../../../gmp/demos/calc/calc.y" + { CHECK_UI ("Lucas number", sp); + mpz_lucnum_ui (sp, mpz_get_ui (sp)); } +#line 1707 "calc.c" + break; + + case 40: +#line 234 "../../../gmp/demos/calc/calc.y" + { mpz_nextprime (sp, sp); } +#line 1713 "calc.c" + break; + + case 41: +#line 235 "../../../gmp/demos/calc/calc.y" + { sp -= 2; mpz_powm (sp, sp, sp+1, sp+2); } +#line 1719 "calc.c" + break; + + case 42: +#line 236 "../../../gmp/demos/calc/calc.y" + { sp--; CHECK_UI ("Nth-root", sp+1); + mpz_root (sp, sp, mpz_get_ui (sp+1)); } +#line 1726 "calc.c" + break; + + case 43: +#line 238 "../../../gmp/demos/calc/calc.y" + { mpz_sqrt (sp, sp); } +#line 1732 "calc.c" + break; + + case 44: +#line 240 "../../../gmp/demos/calc/calc.y" + { + sp++; + CHECK_OVERFLOW (); + CHECK_VARIABLE ((yyvsp[0].var)); + mpz_set (sp, variable[(yyvsp[0].var)]); + } +#line 1743 "calc.c" + break; + + case 45: +#line 246 "../../../gmp/demos/calc/calc.y" + { + sp++; + CHECK_OVERFLOW (); + if (mpz_set_str (sp, (yyvsp[0].str), ibase) != 0) + { + fprintf (stderr, "Invalid number: %s\n", (yyvsp[0].str)); + YYERROR; + } + } +#line 1757 "calc.c" + break; + + case 47: +#line 258 "../../../gmp/demos/calc/calc.y" + { sp--; mpz_gcd (sp, sp, sp+1); } +#line 1763 "calc.c" + break; + + case 49: +#line 262 "../../../gmp/demos/calc/calc.y" + { sp--; mpz_lcm (sp, sp, sp+1); } +#line 1769 "calc.c" + break; + + +#line 1773 "calc.c" + + default: break; + } + /* User semantic actions sometimes alter yychar, and that requires + that yytoken be updated with the new translation. We take the + approach of translating immediately before every use of yytoken. + One alternative is translating here after every semantic action, + but that translation would be missed if the semantic action invokes + YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or + if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an + incorrect destructor might then be invoked immediately. In the + case of YYERROR or YYBACKUP, subsequent parser actions might lead + to an incorrect destructor call or verbose syntax error message + before the lookahead is translated. */ + YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + + *++yyvsp = yyval; + + /* Now 'shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + { + const int yylhs = yyr1[yyn] - YYNTOKENS; + const int yyi = yypgoto[yylhs] + *yyssp; + yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp + ? yytable[yyi] + : yydefgoto[yylhs]); + } + + goto yynewstate; + + +/*--------------------------------------. +| yyerrlab -- here on detecting error. | +`--------------------------------------*/ +yyerrlab: + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar); + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; + yyerror (YY_("syntax error")); + } + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + /* Pacify compilers when the user code never invokes YYERROR and the + label yyerrorlab therefore never appears in user code. */ + if (0) + YYERROR; + + /* Do not reclaim the symbols of the rule whose action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + /* Pop stack until we find a state that shifts the error token. */ + for (;;) + { + yyn = yypact[yystate]; + if (!yypact_value_is_default (yyn)) + { + yyn += YYSYMBOL_YYerror; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + YY_ACCESSING_SYMBOL (yystate), yyvsp); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + + +#if !defined yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + + +/*-----------------------------------------------------. +| yyreturn -- parsing is finished, return the result. | +`-----------------------------------------------------*/ +yyreturn: + if (yychar != YYEMPTY) + { + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = YYTRANSLATE (yychar); + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + } + /* Do not reclaim the symbols of the rule whose action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + YY_ACCESSING_SYMBOL (+*yyssp), yyvsp); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif + + return yyresult; +} + +#line 264 "../../../gmp/demos/calc/calc.y" -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 265 "../../../gmp/demos/calc/calc.y" yyerror (char *s) { @@ -706,443 +2019,3 @@ main (int argc, char *argv[]) return yyparse (); } -#line 710 "calc.c" - -#if YYDEBUG -#include /* needed for printf */ -#endif - -#include /* needed for malloc, etc */ -#include /* needed for memset */ - -/* allocate initial stack or double stack size, up to YYMAXDEPTH */ -static int yygrowstack(YYSTACKDATA *data) -{ - int i; - unsigned newsize; - YYINT *newss; - YYSTYPE *newvs; - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate; -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } -#endif - - yym = 0; - yyn = 0; - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 5: -#line 173 "../../../gmp/demos/calc/calc.y" - { sp = stack[0]; yyerrok; } -break; -case 7: -#line 177 "../../../gmp/demos/calc/calc.y" - { - mpz_out_str (stdout, obase, sp); putchar ('\n'); - sp--; - CHECK_EMPTY (); - } -break; -case 8: -#line 182 "../../../gmp/demos/calc/calc.y" - { - CHECK_VARIABLE (yystack.l_mark[-2].var); - mpz_swap (variable[yystack.l_mark[-2].var], sp); - sp--; - CHECK_EMPTY (); - } -break; -case 9: -#line 188 "../../../gmp/demos/calc/calc.y" - { calc_help (); } -break; -case 10: -#line 189 "../../../gmp/demos/calc/calc.y" - { ibase = 16; obase = -16; } -break; -case 11: -#line 190 "../../../gmp/demos/calc/calc.y" - { ibase = 0; obase = 10; } -break; -case 12: -#line 191 "../../../gmp/demos/calc/calc.y" - { exit (0); } -break; -case 14: -#line 198 "../../../gmp/demos/calc/calc.y" - { sp--; mpz_add (sp, sp, sp+1); } -break; -case 15: -#line 199 "../../../gmp/demos/calc/calc.y" - { sp--; mpz_sub (sp, sp, sp+1); } -break; -case 16: -#line 200 "../../../gmp/demos/calc/calc.y" - { sp--; mpz_mul (sp, sp, sp+1); } -break; -case 17: -#line 201 "../../../gmp/demos/calc/calc.y" - { sp--; mpz_fdiv_q (sp, sp, sp+1); } -break; -case 18: -#line 202 "../../../gmp/demos/calc/calc.y" - { sp--; mpz_fdiv_r (sp, sp, sp+1); } -break; -case 19: -#line 203 "../../../gmp/demos/calc/calc.y" - { CHECK_UI ("Exponent", sp); - sp--; mpz_pow_ui (sp, sp, mpz_get_ui (sp+1)); } -break; -case 20: -#line 205 "../../../gmp/demos/calc/calc.y" - { CHECK_UI ("Shift count", sp); - sp--; mpz_mul_2exp (sp, sp, mpz_get_ui (sp+1)); } -break; -case 21: -#line 207 "../../../gmp/demos/calc/calc.y" - { CHECK_UI ("Shift count", sp); - sp--; mpz_fdiv_q_2exp (sp, sp, mpz_get_ui (sp+1)); } -break; -case 22: -#line 209 "../../../gmp/demos/calc/calc.y" - { CHECK_UI ("Factorial", sp); - mpz_fac_ui (sp, mpz_get_ui (sp)); } -break; -case 23: -#line 211 "../../../gmp/demos/calc/calc.y" - { mpz_neg (sp, sp); } -break; -case 24: -#line 213 "../../../gmp/demos/calc/calc.y" - { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) < 0); } -break; -case 25: -#line 214 "../../../gmp/demos/calc/calc.y" - { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) <= 0); } -break; -case 26: -#line 215 "../../../gmp/demos/calc/calc.y" - { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) == 0); } -break; -case 27: -#line 216 "../../../gmp/demos/calc/calc.y" - { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) != 0); } -break; -case 28: -#line 217 "../../../gmp/demos/calc/calc.y" - { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) >= 0); } -break; -case 29: -#line 218 "../../../gmp/demos/calc/calc.y" - { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) > 0); } -break; -case 30: -#line 220 "../../../gmp/demos/calc/calc.y" - { sp--; mpz_set_ui (sp, mpz_sgn (sp) && mpz_sgn (sp+1)); } -break; -case 31: -#line 221 "../../../gmp/demos/calc/calc.y" - { sp--; mpz_set_ui (sp, mpz_sgn (sp) || mpz_sgn (sp+1)); } -break; -case 32: -#line 223 "../../../gmp/demos/calc/calc.y" - { mpz_abs (sp, sp); } -break; -case 33: -#line 224 "../../../gmp/demos/calc/calc.y" - { sp--; CHECK_UI ("Binomial base", sp+1); - mpz_bin_ui (sp, sp, mpz_get_ui (sp+1)); } -break; -case 34: -#line 226 "../../../gmp/demos/calc/calc.y" - { CHECK_UI ("Fibonacci", sp); - mpz_fib_ui (sp, mpz_get_ui (sp)); } -break; -case 36: -#line 229 "../../../gmp/demos/calc/calc.y" - { sp--; mpz_set_si (sp, - mpz_kronecker (sp, sp+1)); } -break; -case 38: -#line 232 "../../../gmp/demos/calc/calc.y" - { CHECK_UI ("Lucas number", sp); - mpz_lucnum_ui (sp, mpz_get_ui (sp)); } -break; -case 39: -#line 234 "../../../gmp/demos/calc/calc.y" - { mpz_nextprime (sp, sp); } -break; -case 40: -#line 235 "../../../gmp/demos/calc/calc.y" - { sp -= 2; mpz_powm (sp, sp, sp+1, sp+2); } -break; -case 41: -#line 236 "../../../gmp/demos/calc/calc.y" - { sp--; CHECK_UI ("Nth-root", sp+1); - mpz_root (sp, sp, mpz_get_ui (sp+1)); } -break; -case 42: -#line 238 "../../../gmp/demos/calc/calc.y" - { mpz_sqrt (sp, sp); } -break; -case 43: -#line 240 "../../../gmp/demos/calc/calc.y" - { - sp++; - CHECK_OVERFLOW (); - CHECK_VARIABLE (yystack.l_mark[0].var); - mpz_set (sp, variable[yystack.l_mark[0].var]); - } -break; -case 44: -#line 246 "../../../gmp/demos/calc/calc.y" - { - sp++; - CHECK_OVERFLOW (); - if (mpz_set_str (sp, yystack.l_mark[0].str, ibase) != 0) - { - fprintf (stderr, "Invalid number: %s\n", yystack.l_mark[0].str); - YYERROR; - } - } -break; -case 46: -#line 258 "../../../gmp/demos/calc/calc.y" - { sp--; mpz_gcd (sp, sp, sp+1); } -break; -case 48: -#line 262 "../../../gmp/demos/calc/calc.y" - { sp--; mpz_lcm (sp, sp, sp+1); } -break; -#line 1092 "calc.c" - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/gcc/gmp/demos/calc/calc.h b/gcc/gmp/demos/calc/calc.h index 8c48e2a260..36136d1751 100644 --- a/gcc/gmp/demos/calc/calc.h +++ b/gcc/gmp/demos/calc/calc.h @@ -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 . */ + +/* 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 */ diff --git a/gcc/gmp/doc/gmp.info b/gcc/gmp/doc/gmp.info new file mode 100644 index 0000000000..449c156ba6 --- /dev/null +++ b/gcc/gmp/doc/gmp.info @@ -0,0 +1,179 @@ +This is gmp.info, produced by makeinfo version 6.7 from gmp.texi. + +This manual describes how to install and use the GNU multiple precision +arithmetic library, version 6.2.1. + + Copyright 1991, 1993-2016, 2018-2020 Free Software Foundation, Inc. + + Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.3 or +any later version published by the Free Software Foundation; with no +Invariant Sections, with the Front-Cover Texts being "A GNU Manual", and +with the Back-Cover Texts being "You have freedom to copy and modify +this GNU Manual, like GNU software". A copy of the license is included +in *note GNU Free Documentation License::. +INFO-DIR-SECTION GNU libraries +START-INFO-DIR-ENTRY +* gmp: (gmp). GNU Multiple Precision Arithmetic Library. +END-INFO-DIR-ENTRY + + +Indirect: +gmp.info-1: 863 +gmp.info-2: 303737 + +Tag Table: +(Indirect) +Node: Top863 +Node: Copying2941 +Node: Introduction to GMP5288 +Node: Installing GMP8004 +Node: Build Options8736 +Node: ABI and ISA24445 +Node: Notes for Package Builds34286 +Node: Notes for Particular Systems37373 +Node: Known Build Problems45124 +Node: Performance optimization48656 +Node: GMP Basics49785 +Node: Headers and Libraries50433 +Node: Nomenclature and Types51838 +Node: Function Classes53834 +Node: Variable Conventions55369 +Node: Parameter Conventions57609 +Node: Memory Management59416 +Node: Reentrancy60544 +Node: Useful Macros and Constants62412 +Node: Compatibility with older versions63403 +Node: Demonstration Programs64313 +Node: Efficiency66172 +Node: Debugging73778 +Node: Profiling80553 +Node: Autoconf84544 +Node: Emacs86325 +Node: Reporting Bugs86931 +Node: Integer Functions89557 +Node: Initializing Integers90333 +Node: Assigning Integers92709 +Node: Simultaneous Integer Init & Assign94320 +Node: Converting Integers95967 +Node: Integer Arithmetic98907 +Node: Integer Division100643 +Node: Integer Exponentiation107402 +Node: Integer Roots108899 +Node: Number Theoretic Functions110616 +Node: Integer Comparisons118111 +Node: Integer Logic and Bit Fiddling119549 +Node: I/O of Integers122189 +Node: Integer Random Numbers125180 +Node: Integer Import and Export127803 +Node: Miscellaneous Integer Functions131819 +Node: Integer Special Functions133733 +Node: Rational Number Functions137906 +Node: Initializing Rationals139099 +Node: Rational Conversions141572 +Node: Rational Arithmetic143594 +Node: Comparing Rationals145006 +Node: Applying Integer Functions146477 +Node: I/O of Rationals147996 +Node: Floating-point Functions150355 +Node: Initializing Floats153400 +Node: Assigning Floats157492 +Node: Simultaneous Float Init & Assign160080 +Node: Converting Floats161630 +Node: Float Arithmetic164895 +Node: Float Comparison167048 +Node: I/O of Floats168619 +Node: Miscellaneous Float Functions171308 +Node: Low-level Functions173310 +Node: Random Number Functions207558 +Node: Random State Initialization208626 +Node: Random State Seeding211491 +Node: Random State Miscellaneous212896 +Node: Formatted Output213538 +Node: Formatted Output Strings213783 +Node: Formatted Output Functions219178 +Node: C++ Formatted Output223242 +Node: Formatted Input225942 +Node: Formatted Input Strings226178 +Node: Formatted Input Functions230838 +Node: C++ Formatted Input233807 +Node: C++ Class Interface235710 +Node: C++ Interface General236661 +Node: C++ Interface Integers239730 +Node: C++ Interface Rationals243963 +Node: C++ Interface Floats247987 +Node: C++ Interface Random Numbers254004 +Node: C++ Interface Limitations256404 +Node: Custom Allocation259979 +Node: Language Bindings264198 +Node: Algorithms267511 +Node: Multiplication Algorithms268211 +Node: Basecase Multiplication269300 +Node: Karatsuba Multiplication271208 +Node: Toom 3-Way Multiplication274832 +Node: Toom 4-Way Multiplication281251 +Node: Higher degree Toom'n'half282630 +Node: FFT Multiplication283922 +Node: Other Multiplication289258 +Node: Unbalanced Multiplication291732 +Node: Division Algorithms292520 +Node: Single Limb Division292899 +Node: Basecase Division295787 +Node: Divide and Conquer Division296990 +Node: Block-Wise Barrett Division299058 +Node: Exact Division299710 +Node: Exact Remainder303737 +Node: Small Quotient Division305987 +Node: Greatest Common Divisor Algorithms307585 +Node: Binary GCD307882 +Node: Lehmer's Algorithm310732 +Node: Subquadratic GCD312962 +Node: Extended GCD315431 +Node: Jacobi Symbol316749 +Node: Powering Algorithms318658 +Node: Normal Powering Algorithm318921 +Node: Modular Powering Algorithm319449 +Node: Root Extraction Algorithms320231 +Node: Square Root Algorithm320546 +Node: Nth Root Algorithm322687 +Node: Perfect Square Algorithm323472 +Node: Perfect Power Algorithm325559 +Node: Radix Conversion Algorithms326180 +Node: Binary to Radix326556 +Node: Radix to Binary330177 +Node: Other Algorithms332265 +Node: Prime Testing Algorithm332617 +Node: Factorial Algorithm333801 +Node: Binomial Coefficients Algorithm336201 +Node: Fibonacci Numbers Algorithm337095 +Node: Lucas Numbers Algorithm339569 +Node: Random Number Algorithms340290 +Node: Assembly Coding342410 +Node: Assembly Code Organisation343370 +Node: Assembly Basics344337 +Node: Assembly Carry Propagation345487 +Node: Assembly Cache Handling347317 +Node: Assembly Functional Units349478 +Node: Assembly Floating Point351091 +Node: Assembly SIMD Instructions354870 +Node: Assembly Software Pipelining355852 +Node: Assembly Loop Unrolling356915 +Node: Assembly Writing Guide359130 +Node: Internals361895 +Node: Integer Internals362407 +Node: Rational Internals364871 +Node: Float Internals366109 +Node: Raw Output Internals373509 +Node: C++ Interface Internals374703 +Node: Contributors378024 +Node: References384255 +Node: GNU Free Documentation License390174 +Node: Concept Index415316 +Node: Function Index463130 + +End Tag Table + + +Local Variables: +coding: iso-8859-1 +End: diff --git a/gcc/gmp/doc/gmp.info-1 b/gcc/gmp/doc/gmp.info-1 index 5440fff5d1..0616dbb62a 100644 --- a/gcc/gmp/doc/gmp.info-1 +++ b/gcc/gmp/doc/gmp.info-1 @@ -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. diff --git a/gcc/gmp/doc/gmp.info-2 b/gcc/gmp/doc/gmp.info-2 index de53785273..8931949530 100644 --- a/gcc/gmp/doc/gmp.info-2 +++ b/gcc/gmp/doc/gmp.info-2 @@ -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 diff --git a/gcc/gmp/doc/gmp.texi b/gcc/gmp/doc/gmp.texi index a69d0e9b0e..6bca5da75c 100644 --- a/gcc/gmp/doc/gmp.texi +++ b/gcc/gmp/doc/gmp.texi @@ -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 diff --git a/gcc/gmp/doc/stamp-vti b/gcc/gmp/doc/stamp-vti index e62c3dbf4c..e5cfa1ecb5 100644 --- a/gcc/gmp/doc/stamp-vti +++ b/gcc/gmp/doc/stamp-vti @@ -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 diff --git a/gcc/gmp/doc/version.texi b/gcc/gmp/doc/version.texi index e62c3dbf4c..e5cfa1ecb5 100644 --- a/gcc/gmp/doc/version.texi +++ b/gcc/gmp/doc/version.texi @@ -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 diff --git a/gcc/gmp/gmp-h.in b/gcc/gmp/gmp-h.in index d8ce7fdb6d..3d449d427b 100644 --- a/gcc/gmp/gmp-h.in +++ b/gcc/gmp/gmp-h.in @@ -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__ diff --git a/gcc/gmp/gmp-impl.h b/gcc/gmp/gmp-impl.h index 8192dac217..2e5906906a 100644 --- a/gcc/gmp/gmp-impl.h +++ b/gcc/gmp/gmp-impl.h @@ -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 diff --git a/gcc/gmp/longlong.h b/gcc/gmp/longlong.h index bc3fc81cb0..edbaf568e9 100644 --- a/gcc/gmp/longlong.h +++ b/gcc/gmp/longlong.h @@ -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 diff --git a/gcc/gmp/mini-gmp/ChangeLog b/gcc/gmp/mini-gmp/ChangeLog new file mode 100644 index 0000000000..449241f148 --- /dev/null +++ b/gcc/gmp/mini-gmp/ChangeLog @@ -0,0 +1,673 @@ +2020-11-10 Marco Bodrato + + * tests/run-tests: Update WINEPATH, instead of overwriting it. + +2020-10-25 Marco Bodrato + + * mini-mpq.c (mpq_canonical_sign): Use the correct type for size. + +2020-10-18 Marco Bodrato + + * 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 + + * tests/run-tests: Better support for make check on wine or cygwin. + +2020-09-10 Marco Bodrato + + * 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 + + * 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 + + * tests/hex-random.h (enum hex_random_op): Remove final ",". + +2019-12-04 Marco Bodrato + + * mini-gmp/mini-gmp.c (mpn_invert_3by2): Remove shortcuts. + +2019-11-19 Marco Bodrato + + * mini-gmp/mini-gmp.c (mpn_invert_3by2): Shortcut for short limbs. + +2019-11-09 Marco Bodrato + + * 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 + + * tests/t-gcd.c (gcdext_valid_p): Stricter checks for gcdext + corner cases. + +2018-12-21 Marco Bodrato + + * mini-gmp/mini-gmp.c: Support for micro-gmp. + +2018-11-07 Marco Bodrato + + * mini-gmp/mini-gmp.c: Silence a couple of warnings. + +2018-10-30 Marco Bodrato + + * 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 + + * tests/t-div.c (testmain): Add missing const declarations. + +2018-05-20 Marco Bodrato + + * 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 + + * 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 + + * 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 + + * 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 + + * mini-gmp.c (gmp_popcount_limb): Micro-optimisations. + * tests/t-comb.c (checkWilson): Check also mpz_2fac_ui. + +2017-12-30 Marco Bodrato + + * 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 + + * 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 + + * 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 + + * 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 + + * 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 + + * 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 + + * 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 + + * tests/t-signed.c: compare different signs, and after overflow. + +2016-11-20 Niels Möller + + * tests/t-signed.c: Reorganize testcase, to avoid undefined + behaviour with signed overflow. + +2016-11-19 Niels Möller + + * 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 + + * tests/Makefile: Pass EXTRA_CFLAGS to linker as a intermediate fix. + +2016-11-17 Marco Bodrato + + * tests/t-str.c: free a pointer to avoid memory leaks. + +2016-11-16 Niels Möller + + * mini-gmp.c (mpn_invert_3by2): Fix arithmetic overflow + bug, and improve documentation of the algorithm. + +2016-11-15 Niels Möller + + * 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 + + * 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 + + * 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 + + * tests/hex-random.c: Reinstate gmp.h inclusion. + +2016-08-22 Niels Möller + + * 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 + + * 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 + + * mini-gmp.c: Lazy allocation for mpz_t. + (mpz_rootrem): Exploit lazy allocation to avoid init2. + +2015-11-06 Marco Bodrato + + * 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 + + * mini-gmp.c: Removed a typo (spotted by Paul Zimmermann). + +2015-05-30 Marco Bodrato + + * 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 + + * 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 + + * mini-gmp.c: Remove some useless variables. + +2014-05-20 Marco Bodrato + + * mini-gmp.c: +1 in the init2 argument before setbit. + +2014-05-15 Marco Bodrato + + * mini-gmp.c: Micro-optimisations. + +2014-03-12 Marco Bodrato + + * mini-gmp.c (mpz_probab_prime_p): Micro-optimisation. + +2014-03-06 Niels Möller + + * 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 + + * 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 + + * mini-gmp.c (mpn_sqrtrem): New function. + * mini-gmp.h: Declare it. + * tests/t-sqrt.c: Test it. + +2014-02-15 Marco Bodrato + + * mini-gmp.c (mpz_div_qr): init + set = init_set . + +2014-02-10 Marco Bodrato + + * tests/t-limbs.c: New test for mpz_limbs_*. + * tests/Makefile (CHECK_PROGRAMS): Add it. + +2014-02-08 Marco Bodrato + + * 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 + + * 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 + + * tests/t-aorsmul.c: New file, test for mpz_{add,sub}mul{,_ui} + * tests/Makefile: Add t-aorsmul. + +2014-01-19 Marco Bodrato + + * 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 + + * mini-gmp.c (mp_bits_per_limb): New const value. + * mini-gmp.h: Declare it. + +2013-03-13 Marco Bodrato + + * mini-gmp.c: Write loops in a cleaner way. + +2013-02-27 Marco Bodrato + + * 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 + + * 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 + + * 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 + + * 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 + + * mini-gmp.c (fac_ui, bin_uiui): Use shorter and faster code. + + * mini-gmp.c: Reduce branches. + +2013-01-23 Marco Bodrato + + * 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 + + * 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 + + * tests/t-str.c (testmain): Test mpz_out_str, using + the tmpfile function for i/o. + +2013-01-20 Marco Bodrato + + * 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 + + * 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 + + * 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 + + * tests/t-signed.c: Slightly larger coverage. + * tests/t-double.c: Test also mpz_init_set_d. + +2013-01-18 Torbjorn Granlund + + * 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 + + * 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 + + * 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 + + * tests/t-logops.c: Improve popcount/hamdist testing. + * tests/t-signed.c: Test more cases. + +2013-01-14 Niels Möller + + * tests/t-str.c (main): Added tests for mpn_get_str and + mpn_set_str. + +2013-01-11 Marco Bodrato + + * 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 + + * 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 + + * tests/t-import.c (main): Don't drop off function end. + +2013-01-09 Marco Bodrato + + * mini-gmp.c (mpz_export): Support op=0 countp=NULL. + +2013-01-08 Niels Möller + + * 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 + + * 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 + + From shuax: + * mini-gmp.c (mpz_import): Reset limb after storing it. + +2012-11-22 Niels Möller + + * 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 + + * mini-gmp.c (mpz_div_r_2exp, mpz_div_q_2exp): Improve + adjustment condition. + +2012-06-08 Marco Bodrato + + * mini-gmp.c (mpz_realloc): remove a branch. + +2012-05-25 Marco Bodrato + + * 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 + + * mini-gmp.c: merge mpz_rootrem and mpz_sqrtrem. + +2012-04-13 Marco Bodrato + + * 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 + + * 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 + + * 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 + + * 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 + + * mini-gmp: New subdirectory. For use by GMP bootstrap, and as a + fallback for applications needing bignums but not high + performance. diff --git a/gcc/gmp/mini-gmp/mini-gmp.c b/gcc/gmp/mini-gmp/mini-gmp.c index 78cd103447..48ce1072ba 100644 --- a/gcc/gmp/mini-gmp/mini-gmp.c +++ b/gcc/gmp/mini-gmp/mini-gmp.c @@ -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; diff --git a/gcc/gmp/mini-gmp/mini-gmp.h b/gcc/gmp/mini-gmp/mini-gmp.h index 7cce3f7a32..d575f7d132 100644 --- a/gcc/gmp/mini-gmp/mini-gmp.h +++ b/gcc/gmp/mini-gmp/mini-gmp.h @@ -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 diff --git a/gcc/gmp/mini-gmp/mini-mpq.c b/gcc/gmp/mini-gmp/mini-mpq.c index fd9b439907..6fed03dc6d 100644 --- a/gcc/gmp/mini-gmp/mini-mpq.c +++ b/gcc/gmp/mini-gmp/mini-mpq.c @@ -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); diff --git a/gcc/gmp/mini-gmp/tests/hex-random.h b/gcc/gmp/mini-gmp/tests/hex-random.h index da443472e5..20670979e4 100644 --- a/gcc/gmp/mini-gmp/tests/hex-random.h +++ b/gcc/gmp/mini-gmp/tests/hex-random.h @@ -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); diff --git a/gcc/gmp/mini-gmp/tests/run-tests b/gcc/gmp/mini-gmp/tests/run-tests index 5d452d6b12..3ebc4ae474 100755 --- a/gcc/gmp/mini-gmp/tests/run-tests +++ b/gcc/gmp/mini-gmp/tests/run-tests @@ -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 diff --git a/gcc/gmp/mini-gmp/tests/t-double.c b/gcc/gmp/mini-gmp/tests/t-double.c index 9a1aa8f112..0a11fadd6f 100644 --- a/gcc/gmp/mini-gmp/tests/t-double.c +++ b/gcc/gmp/mini-gmp/tests/t-double.c @@ -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; diff --git a/gcc/gmp/mini-gmp/tests/t-mpq_double.c b/gcc/gmp/mini-gmp/tests/t-mpq_double.c index 1bd6c92f53..3cfba60840 100644 --- a/gcc/gmp/mini-gmp/tests/t-mpq_double.c +++ b/gcc/gmp/mini-gmp/tests/t-mpq_double.c @@ -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); diff --git a/gcc/gmp/mini-gmp/tests/t-mpq_muldiv_2exp.c b/gcc/gmp/mini-gmp/tests/t-mpq_muldiv_2exp.c index 46b2c0c2fb..df5cf5cdce 100644 --- a/gcc/gmp/mini-gmp/tests/t-mpq_muldiv_2exp.c +++ b/gcc/gmp/mini-gmp/tests/t-mpq_muldiv_2exp.c @@ -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)); diff --git a/gcc/gmp/mini-gmp/tests/t-mpq_str.c b/gcc/gmp/mini-gmp/tests/t-mpq_str.c index 7c69153a7a..1794a58ee9 100644 --- a/gcc/gmp/mini-gmp/tests/t-mpq_str.c +++ b/gcc/gmp/mini-gmp/tests/t-mpq_str.c @@ -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; diff --git a/gcc/gmp/mini-gmp/tests/t-str.c b/gcc/gmp/mini-gmp/tests/t-str.c index 1e78676eed..0394e7977b 100644 --- a/gcc/gmp/mini-gmp/tests/t-str.c +++ b/gcc/gmp/mini-gmp/tests/t-str.c @@ -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; diff --git a/gcc/gmp/mpn/arm64/arm64-defs.m4 b/gcc/gmp/mpn/arm64/arm64-defs.m4 new file mode 100644 index 0000000000..46149f7bfd --- /dev/null +++ b/gcc/gmp/mpn/arm64/arm64-defs.m4 @@ -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 diff --git a/gcc/gmp/mpn/arm64/bdiv_q_1.asm b/gcc/gmp/mpn/arm64/bdiv_q_1.asm index 2e189b884b..7fffc9369c 100644 --- a/gcc/gmp/mpn/arm64/bdiv_q_1.asm +++ b/gcc/gmp/mpn/arm64/bdiv_q_1.asm @@ -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) diff --git a/gcc/gmp/mpn/arm64/darwin.m4 b/gcc/gmp/mpn/arm64/darwin.m4 new file mode 100644 index 0000000000..36e72fe45e --- /dev/null +++ b/gcc/gmp/mpn/arm64/darwin.m4 @@ -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 diff --git a/gcc/gmp/mpn/arm64/invert_limb.asm b/gcc/gmp/mpn/arm64/invert_limb.asm index a94b0e9611..6a99bf0028 100644 --- a/gcc/gmp/mpn/arm64/invert_limb.asm +++ b/gcc/gmp/mpn/arm64/invert_limb.asm @@ -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 diff --git a/gcc/gmp/mpn/arm64/lshift.asm b/gcc/gmp/mpn/arm64/lshift.asm index 472b7ec00e..eaafaa442a 100644 --- a/gcc/gmp/mpn/arm64/lshift.asm +++ b/gcc/gmp/mpn/arm64/lshift.asm @@ -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') diff --git a/gcc/gmp/mpn/arm64/lshiftc.asm b/gcc/gmp/mpn/arm64/lshiftc.asm index dd4c4ce335..7c93a3d775 100644 --- a/gcc/gmp/mpn/arm64/lshiftc.asm +++ b/gcc/gmp/mpn/arm64/lshiftc.asm @@ -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') diff --git a/gcc/gmp/mpn/arm64/rshift.asm b/gcc/gmp/mpn/arm64/rshift.asm index 78ae9602b3..acee714b27 100644 --- a/gcc/gmp/mpn/arm64/rshift.asm +++ b/gcc/gmp/mpn/arm64/rshift.asm @@ -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') diff --git a/gcc/gmp/mpn/generic/compute_powtab.c b/gcc/gmp/mpn/generic/compute_powtab.c index f4fbc64790..41d3a2d3b1 100644 --- a/gcc/gmp/mpn/generic/compute_powtab.c +++ b/gcc/gmp/mpn/generic/compute_powtab.c @@ -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 diff --git a/gcc/gmp/mpn/generic/dcpi1_bdiv_q.c b/gcc/gmp/mpn/generic/dcpi1_bdiv_q.c index 1a4bd2a9e5..eb1c42721b 100644 --- a/gcc/gmp/mpn/generic/dcpi1_bdiv_q.c +++ b/gcc/gmp/mpn/generic/dcpi1_bdiv_q.c @@ -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. diff --git a/gcc/gmp/mpn/generic/gcd_22.c b/gcc/gmp/mpn/generic/gcd_22.c index d97f096827..05a4338a4c 100644 --- a/gcc/gmp/mpn/generic/gcd_22.c +++ b/gcc/gmp/mpn/generic/gcd_22.c @@ -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) */ diff --git a/gcc/gmp/mpn/generic/get_d.c b/gcc/gmp/mpn/generic/get_d.c index 9784f21544..8bef128108 100644 --- a/gcc/gmp/mpn/generic/get_d.c +++ b/gcc/gmp/mpn/generic/get_d.c @@ -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 diff --git a/gcc/gmp/mpn/generic/get_str.c b/gcc/gmp/mpn/generic/get_str.c index 19cc581aec..d4d3a132c2 100644 --- a/gcc/gmp/mpn/generic/get_str.c +++ b/gcc/gmp/mpn/generic/get_str.c @@ -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 */ diff --git a/gcc/gmp/mpn/generic/hgcd2.c b/gcc/gmp/mpn/generic/hgcd2.c index 3fa40122e4..19214700d2 100644 --- a/gcc/gmp/mpn/generic/hgcd2.c +++ b/gcc/gmp/mpn/generic/hgcd2.c @@ -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) { diff --git a/gcc/gmp/mpn/generic/mod_1_1.c b/gcc/gmp/mpn/generic/mod_1_1.c index f6342d6816..1fada117fb 100644 --- a/gcc/gmp/mpn/generic/mod_1_1.c +++ b/gcc/gmp/mpn/generic/mod_1_1.c @@ -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; } diff --git a/gcc/gmp/mpn/generic/mul_fft.c b/gcc/gmp/mpn/generic/mul_fft.c index df8ee63a5f..a896ff19fe 100644 --- a/gcc/gmp/mpn/generic/mul_fft.c +++ b/gcc/gmp/mpn/generic/mul_fft.c @@ -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)); } diff --git a/gcc/gmp/mpn/generic/set_str.c b/gcc/gmp/mpn/generic/set_str.c index 2bd584c0b3..33fc29cbcb 100644 --- a/gcc/gmp/mpn/generic/set_str.c +++ b/gcc/gmp/mpn/generic/set_str.c @@ -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); diff --git a/gcc/gmp/mpn/generic/strongfibo.c b/gcc/gmp/mpn/generic/strongfibo.c index ffd038a2b7..210647b31d 100644 --- a/gcc/gmp/mpn/generic/strongfibo.c +++ b/gcc/gmp/mpn/generic/strongfibo.c @@ -37,6 +37,9 @@ see https://www.gnu.org/licenses/. */ #include #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: diff --git a/gcc/gmp/mpn/generic/toom_interpolate_12pts.c b/gcc/gmp/mpn/generic/toom_interpolate_12pts.c index 347e3410da..627346613a 100644 --- a/gcc/gmp/mpn/generic/toom_interpolate_12pts.c +++ b/gcc/gmp/mpn/generic/toom_interpolate_12pts.c @@ -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) diff --git a/gcc/gmp/mpn/generic/toom_interpolate_16pts.c b/gcc/gmp/mpn/generic/toom_interpolate_16pts.c index 5d76bba8c2..c1457be643 100644 --- a/gcc/gmp/mpn/generic/toom_interpolate_16pts.c +++ b/gcc/gmp/mpn/generic/toom_interpolate_16pts.c @@ -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 diff --git a/gcc/gmp/mpn/powerpc64/mode64/p9/addmul_2.asm b/gcc/gmp/mpn/powerpc64/mode64/p9/addmul_2.asm index 1dd59ea5b6..846a894bb2 100644 --- a/gcc/gmp/mpn/powerpc64/mode64/p9/addmul_2.asm +++ b/gcc/gmp/mpn/powerpc64/mode64/p9/addmul_2.asm @@ -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') diff --git a/gcc/gmp/mpn/powerpc64/mode64/p9/mul_2.asm b/gcc/gmp/mpn/powerpc64/mode64/p9/mul_2.asm index 632b6cbc9a..01b50a38dd 100644 --- a/gcc/gmp/mpn/powerpc64/mode64/p9/mul_2.asm +++ b/gcc/gmp/mpn/powerpc64/mode64/p9/mul_2.asm @@ -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') diff --git a/gcc/gmp/mpn/x86/fat/fat.c b/gcc/gmp/mpn/x86/fat/fat.c index 18be05a395..4c8cf3c23b 100644 --- a/gcc/gmp/mpn/x86/fat/fat.c +++ b/gcc/gmp/mpn/x86/fat/fat.c @@ -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; } } diff --git a/gcc/gmp/mpn/x86_64/bd2/gcd_22.asm b/gcc/gmp/mpn/x86_64/bd2/gcd_22.asm index a4f30eadda..070cb3e265 100644 --- a/gcc/gmp/mpn/x86_64/bd2/gcd_22.asm +++ b/gcc/gmp/mpn/x86_64/bd2/gcd_22.asm @@ -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 diff --git a/gcc/gmp/mpn/x86_64/fat/fat.c b/gcc/gmp/mpn/x86_64/fat/fat.c index b7446a395f..cc35afa46d 100644 --- a/gcc/gmp/mpn/x86_64/fat/fat.c +++ b/gcc/gmp/mpn/x86_64/fat/fat.c @@ -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; } diff --git a/gcc/gmp/mpn/x86_64/skylake/gmp-mparam.h b/gcc/gmp/mpn/x86_64/skylake/gmp-mparam.h index a899ea167e..e8018117bd 100644 --- a/gcc/gmp/mpn/x86_64/skylake/gmp-mparam.h +++ b/gcc/gmp/mpn/x86_64/skylake/gmp-mparam.h @@ -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 */ diff --git a/gcc/gmp/mpn/x86_64/x86_64-defs.m4 b/gcc/gmp/mpn/x86_64/x86_64-defs.m4 index 64e3729801..4e08f2a06c 100644 --- a/gcc/gmp/mpn/x86_64/x86_64-defs.m4 +++ b/gcc/gmp/mpn/x86_64/x86_64-defs.m4 @@ -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 diff --git a/gcc/gmp/mpn/x86_64/zen2/gmp-mparam.h b/gcc/gmp/mpn/x86_64/zen2/gmp-mparam.h index 3748c5f580..0d8eb80e1f 100644 --- a/gcc/gmp/mpn/x86_64/zen2/gmp-mparam.h +++ b/gcc/gmp/mpn/x86_64/zen2/gmp-mparam.h @@ -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 */ diff --git a/gcc/gmp/mpq/cmp.c b/gcc/gmp/mpq/cmp.c index d3eefe20f8..495e77e017 100644 --- a/gcc/gmp/mpq/cmp.c +++ b/gcc/gmp/mpq/cmp.c @@ -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); diff --git a/gcc/gmp/mpz/cmp.c b/gcc/gmp/mpz/cmp.c index a97b0043a3..ba4c023e92 100644 --- a/gcc/gmp/mpz/cmp.c +++ b/gcc/gmp/mpz/cmp.c @@ -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); diff --git a/gcc/gmp/mpz/millerrabin.c b/gcc/gmp/mpz/millerrabin.c index 1f5d482605..ee4eb1ae89 100644 --- a/gcc/gmp/mpz/millerrabin.c +++ b/gcc/gmp/mpz/millerrabin.c @@ -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) diff --git a/gcc/gmp/mpz/mul.c b/gcc/gmp/mpz/mul.c index d72c93e177..a70df9ffa0 100644 --- a/gcc/gmp/mpz/mul.c +++ b/gcc/gmp/mpz/mul.c @@ -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); diff --git a/gcc/gmp/mpz/n_pow_ui.c b/gcc/gmp/mpz/n_pow_ui.c index cf293f5405..69fdd12925 100644 --- a/gcc/gmp/mpz/n_pow_ui.c +++ b/gcc/gmp/mpz/n_pow_ui.c @@ -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 +#include #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); diff --git a/gcc/gmp/tests/cxx/t-assign.cc b/gcc/gmp/tests/cxx/t-assign.cc index bd2e41a0ec..a11b0d98f5 100644 --- a/gcc/gmp/tests/cxx/t-assign.cc +++ b/gcc/gmp/tests/cxx/t-assign.cc @@ -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&) { } } diff --git a/gcc/gmp/tests/cxx/t-constr.cc b/gcc/gmp/tests/cxx/t-constr.cc index 0b2ac97950..500878e45b 100644 --- a/gcc/gmp/tests/cxx/t-constr.cc +++ b/gcc/gmp/tests/cxx/t-constr.cc @@ -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&) { } } diff --git a/gcc/gmp/tests/cxx/t-do-exceptions-work-at-all-with-this-compiler.cc b/gcc/gmp/tests/cxx/t-do-exceptions-work-at-all-with-this-compiler.cc index 341a818b75..014eb75229 100644 --- a/gcc/gmp/tests/cxx/t-do-exceptions-work-at-all-with-this-compiler.cc +++ b/gcc/gmp/tests/cxx/t-do-exceptions-work-at-all-with-this-compiler.cc @@ -34,5 +34,5 @@ main () { throw_expr(); } - catch (invalid_argument) { } + catch (invalid_argument&) { } } diff --git a/gcc/gmp/tests/cxx/t-ops2z.cc b/gcc/gmp/tests/cxx/t-ops2z.cc index 6d0e4ad0fd..78694b772d 100644 --- a/gcc/gmp/tests/cxx/t-ops2z.cc +++ b/gcc/gmp/tests/cxx/t-ops2z.cc @@ -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 diff --git a/gcc/gmp/tests/cxx/t-rand.cc b/gcc/gmp/tests/cxx/t-rand.cc index 1f011eba7f..d336d084d7 100644 --- a/gcc/gmp/tests/cxx/t-rand.cc +++ b/gcc/gmp/tests/cxx/t-rand.cc @@ -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&) { } } diff --git a/gcc/gmp/tests/devel/Makefile.am b/gcc/gmp/tests/devel/Makefile.am index 6b384f0dc7..6c939a57a5 100644 --- a/gcc/gmp/tests/devel/Makefile.am +++ b/gcc/gmp/tests/devel/Makefile.am @@ -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) diff --git a/gcc/gmp/tests/devel/Makefile.in b/gcc/gmp/tests/devel/Makefile.in index 796371dffa..b299954e41 100644 --- a/gcc/gmp/tests/devel/Makefile.in +++ b/gcc/gmp/tests/devel/Makefile.in @@ -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: diff --git a/gcc/gmp/tests/devel/addmul_N.c b/gcc/gmp/tests/devel/addmul_N.c deleted file mode 100644 index 410e291bc8..0000000000 --- a/gcc/gmp/tests/devel/addmul_N.c +++ /dev/null @@ -1,272 +0,0 @@ -/* -Copyright 1996-2002, 2004, 2007 Free Software Foundation, Inc. - -This file is part of the GNU MP Library test suite. - -The GNU MP Library test suite is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 3 of the License, -or (at your option) any later version. - -The GNU MP Library test suite is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -Public License for more details. - -You should have received a copy of the GNU General Public License along with -the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ - -#include -#include -#include -#include "gmp-impl.h" -#include "longlong.h" - -#if defined (USG) || defined (__SVR4) || defined (_UNICOS) || defined (__hpux) -#include - -int -cputime () -{ - if (CLOCKS_PER_SEC < 100000) - return clock () * 1000 / CLOCKS_PER_SEC; - return clock () / (CLOCKS_PER_SEC / 1000); -} -#else -#include -#include -#include - -int -cputime () -{ - struct rusage rus; - - getrusage (0, &rus); - return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000; -} -#endif - -#ifndef NOCHECK -static void print_posneg (mp_limb_t); -#endif -#ifdef PRINT -static void mpn_print (mp_ptr, mp_size_t); -#endif - -#define LXW ((int) (2 * sizeof (mp_limb_t))) -#define M * 1000000 - -#ifndef CLOCK -#error "Don't know CLOCK of your machine" -#endif - -#ifndef OPS -#define OPS (CLOCK/5) -#endif -#ifndef SIZE -#define SIZE 496 -#endif -#ifndef TIMES -#define TIMES OPS/(SIZE+1) -#endif - -#if N == 2 -#define mpn_addmul_N mpn_addmul_2 -#elif N == 3 -#define mpn_addmul_N mpn_addmul_3 -#elif N == 4 -#define mpn_addmul_N mpn_addmul_4 -#elif N == 5 -#define mpn_addmul_N mpn_addmul_5 -#elif N == 6 -#define mpn_addmul_N mpn_addmul_6 -#elif N == 7 -#define mpn_addmul_N mpn_addmul_7 -#elif N == 8 -#define mpn_addmul_N mpn_addmul_8 -#endif - -mp_limb_t -refmpn_addmul_N (mp_ptr rp, mp_srcptr up, mp_size_t n, mp_srcptr vp) -{ - int i; - for (i = 1; i < N; i++) - { - rp[n] = mpn_addmul_1 (rp, up, n, *vp); - rp++; - vp++; - } - return mpn_addmul_1 (rp, up, n, *vp); -} - -int -main (int argc, char **argv) -{ - mp_limb_t up[SIZE]; - mp_limb_t ref[SIZE + N - 1]; - mp_limb_t mem[SIZE + N + 1]; - mp_ptr rp = mem + 1; - mp_limb_t vp[N]; - mp_limb_t cy_ref, cy_try; - int i; -#if TIMES != 1 - long t0, t; - double cyc; -#endif - unsigned test; - mp_size_t size; - unsigned ntests; - - ntests = ~(unsigned) 0; - if (argc == 2) - ntests = strtol (argv[1], 0, 0); - - for (test = 1; test <= ntests; test++) - { -#if TIMES == 1 && ! defined (PRINT) - if (test % (CLOCK / SIZE / 1000) == 0) - { - printf ("\r%u", test); - fflush (stdout); - } -#endif - -#ifdef RANDOM - size = random () % (SIZE - N + 1) + N; -#else - size = SIZE; -#endif - - rp[size + N - 1] = 0x12345678; - rp[-1] = 0x87654321; - - mpn_random (vp, N); - -#if TIMES != 1 /* run timing tests unless asked not to */ - mpn_random (up, size); - mpn_random (rp, size + N - 1); - - MPN_COPY (ref, rp, size + N - 1); - t0 = cputime(); - for (i = 0; i < TIMES; i++) - mpn_addmul_N (ref, up, size, vp); - t = cputime() - t0; - cyc = ((double) t * CLOCK) / (TIMES * size * 1000.0) / N; - printf ("mpn_addmul_%d: %5ldms (%.3f cycles/limb) [%.2f Gb/s]\n", - N, t, cyc, CLOCK/cyc*GMP_LIMB_BITS*GMP_LIMB_BITS/1e9); -#endif - -#ifdef PLAIN_RANDOM -#define MPN_RANDOM mpn_random -#else -#define MPN_RANDOM mpn_random2 -#endif - -#ifdef ZEROu - MPN_ZERO (up, size); -#else - MPN_RANDOM (up, size); -#endif - MPN_RANDOM (vp, N); -#ifdef ZERO - MPN_ZERO (rp, size + N - 1); -#else - MPN_RANDOM (rp, size + N - 1); -#endif - -#if defined (PRINT) || defined (PRINTV) - printf ("vp="); - mpn_print (vp, N); -#endif -#ifdef PRINT - printf ("%*s ", 3 + N * LXW, ""); - mpn_print (rp, size); - printf ("%*s ", 3 + N * LXW, ""); - mpn_print (up, size); -#endif - - MPN_COPY (ref, rp, size + N - 1); - cy_ref = refmpn_addmul_N (ref, up, size, vp); - cy_try = mpn_addmul_N (rp, up, size, vp); - -#ifdef PRINT - printf ("%*lX ", LXW, cy_ref); - mpn_print (ref, size + N - 1); - printf ("%*lX ", LXW, cy_try); - mpn_print (rp, size + N - 1); -#endif - -#ifndef NOCHECK - if (cy_ref != cy_try || mpn_cmp (ref, rp, size + N - 1) != 0 - || rp[size + N - 1] != 0x12345678 || rp[-1] != 0x87654321) - { - printf ("\n ref%*s try%*s diff\n", LXW - 3, "", 2 * LXW - 6, ""); - for (i = 0; i < size + N - 1; i++) - { - printf ("%6d: ", i); - printf ("%0*llX ", LXW, (unsigned long long) ref[i]); - printf ("%0*llX ", LXW, (unsigned long long) rp[i]); - print_posneg (rp[i] - ref[i]); - printf ("\n"); - } - printf ("retval: "); - printf ("%0*llX ", LXW, (unsigned long long) cy_ref); - printf ("%0*llX ", LXW, (unsigned long long) cy_try); - print_posneg (cy_try - cy_ref); - printf ("\n"); - if (rp[-1] != 0x87654321) - printf ("clobbered at low end\n"); - if (rp[size + N - 1] != 0x12345678) - printf ("clobbered at high end\n"); - printf ("TEST NUMBER %u\n", test); - abort(); - } -#endif - } - exit (0); -} - -#ifndef NOCHECK -static void -print_posneg (mp_limb_t d) -{ - char buf[LXW + 2]; - if (d == 0) - printf (" %*X", LXW, 0); - else if (-d < d) - { - sprintf (buf, "%llX", (unsigned long long) -d); - printf ("%*s-%s", LXW - (int) strlen (buf), "", buf); - } - else - { - sprintf (buf, "%llX", (unsigned long long) d); - printf ("%*s+%s", LXW - (int) strlen (buf), "", buf); - } -} -#endif - -#ifdef PRINT -static void -mpn_print (mp_ptr p, mp_size_t size) -{ - mp_size_t i; - - for (i = size - 1; i >= 0; i--) - { -#ifdef _LONG_LONG_LIMB - printf ("%0*lX%0*lX", (int) (sizeof(mp_limb_t)), - (unsigned long) (p[i] >> (GMP_LIMB_BITS/2)), - (int) (sizeof(mp_limb_t)), (unsigned long) (p[i])); -#else - printf ("%0*lX", LXW, p[i]); -#endif -#ifdef SPACE - if (i != 0) - printf (" "); -#endif - } - puts (""); -} -#endif diff --git a/gcc/gmp/tests/devel/anymul_1.c b/gcc/gmp/tests/devel/anymul_1.c deleted file mode 100644 index 84f2781e58..0000000000 --- a/gcc/gmp/tests/devel/anymul_1.c +++ /dev/null @@ -1,255 +0,0 @@ -/* -Copyright 1996-2002, 2004, 2006-2008 Free Software Foundation, Inc. - -This file is part of the GNU MP Library test suite. - -The GNU MP Library test suite is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 3 of the License, -or (at your option) any later version. - -The GNU MP Library test suite is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -Public License for more details. - -You should have received a copy of the GNU General Public License along with -the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ - -#include -#include -#include -#include "gmp-impl.h" -#include "longlong.h" -#include "tests/tests.h" - -#ifdef OPERATION_mul_1 -#define func __gmpn_mul_1 -#define reffunc refmpn_mul_1 -#define funcname "mpn_mul_1" -#endif - -#ifdef OPERATION_addmul_1 -#define func __gmpn_addmul_1 -#define reffunc refmpn_addmul_1 -#define funcname "mpn_addmul_1" -#endif - -#ifdef OPERATION_submul_1 -#define func __gmpn_submul_1 -#define reffunc refmpn_submul_1 -#define funcname "mpn_submul_1" -#endif - -#if defined (USG) || defined (__SVR4) || defined (_UNICOS) || defined (__hpux) -#include - -int -cputime () -{ - if (CLOCKS_PER_SEC < 100000) - return clock () * 1000 / CLOCKS_PER_SEC; - return clock () / (CLOCKS_PER_SEC / 1000); -} -#else -#include -#include -#include - -int -cputime () -{ - struct rusage rus; - - getrusage (0, &rus); - return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000; -} -#endif - -static void print_posneg (mp_limb_t); -static void mpn_print (mp_ptr, mp_size_t); - -#define LXW ((int) (2 * sizeof (mp_limb_t))) -#define M * 1000000 - -#ifndef CLOCK -#error "Don't know CLOCK of your machine" -#endif - -#ifndef OPS -#define OPS (CLOCK/5) -#endif -#ifndef SIZE -#define SIZE 496 -#endif -#ifndef TIMES -#define TIMES OPS/(SIZE+1) -#endif - -int -main (int argc, char **argv) -{ - mp_ptr s1, ref, rp; - mp_limb_t cy_ref, cy_try; - int i; - long t0, t; - unsigned int test; - mp_limb_t xlimb; - mp_size_t size; - double cyc; - unsigned int ntests; - - s1 = malloc (SIZE * sizeof (mp_limb_t)); - ref = malloc (SIZE * sizeof (mp_limb_t)); - rp = malloc ((SIZE + 2) * sizeof (mp_limb_t)); - rp++; - - ntests = ~(unsigned) 0; - if (argc == 2) - ntests = strtol (argv[1], 0, 0); - - for (test = 1; test <= ntests; test++) - { -#if TIMES == 1 && ! defined (PRINT) - if (test % (1 + 0x80000 / (SIZE + 20)) == 0) - { - printf ("\r%u", test); - fflush (stdout); - } -#endif - -#ifdef PLAIN_RANDOM -#define MPN_RANDOM mpn_random -#else -#define MPN_RANDOM mpn_random2 -#endif - -#ifdef RANDOM - size = random () % SIZE + 1; -#else - size = SIZE; -#endif - - rp[-1] = 0x87654321; - rp[size] = 0x12345678; - -#ifdef FIXED_XLIMB - xlimb = FIXED_XLIMB; -#else - MPN_RANDOM (&xlimb, 1); -#endif - -#if TIMES != 1 - mpn_random (s1, size); - mpn_random (rp, size); - - MPN_COPY (ref, rp, size); - t0 = cputime(); - for (i = 0; i < TIMES; i++) - func (ref, s1, size, xlimb); - t = cputime() - t0; - cyc = ((double) t * CLOCK) / (TIMES * size * 1000.0); - printf (funcname ": %5ldms (%.3f cycles/limb) [%.2f Gb/s]\n", - t, cyc, - CLOCK/cyc*GMP_LIMB_BITS*GMP_LIMB_BITS/1e9); -#endif - -#ifndef NOCHECK - MPN_RANDOM (s1, size); -#ifdef ZERO - memset (rp, 0, size * sizeof *rp); -#else - MPN_RANDOM (rp, size); -#endif -#if defined (PRINT) || defined (XPRINT) - printf ("xlimb="); - mpn_print (&xlimb, 1); -#endif -#ifdef PRINT -#ifndef OPERATION_mul_1 - printf ("%*s ", (int) (2 * sizeof(mp_limb_t)), ""); - mpn_print (rp, size); -#endif - printf ("%*s ", (int) (2 * sizeof(mp_limb_t)), ""); - mpn_print (s1, size); -#endif - - MPN_COPY (ref, rp, size); - cy_ref = reffunc (ref, s1, size, xlimb); - cy_try = func (rp, s1, size, xlimb); - -#ifdef PRINT - mpn_print (&cy_ref, 1); - mpn_print (ref, size); - mpn_print (&cy_try, 1); - mpn_print (rp, size); -#endif - - if (cy_ref != cy_try || mpn_cmp (ref, rp, size) != 0 - || rp[-1] != 0x87654321 || rp[size] != 0x12345678) - { - printf ("\n ref%*s try%*s diff\n", LXW - 3, "", 2 * LXW - 6, ""); - for (i = 0; i < size; i++) - { - printf ("%6d: ", i); - printf ("%0*llX ", LXW, (unsigned long long) ref[i]); - printf ("%0*llX ", LXW, (unsigned long long) rp[i]); - print_posneg (rp[i] - ref[i]); - printf ("\n"); - } - printf ("retval: "); - printf ("%0*llX ", LXW, (unsigned long long) cy_ref); - printf ("%0*llX ", LXW, (unsigned long long) cy_try); - print_posneg (cy_try - cy_ref); - printf ("\n"); - if (rp[-1] != 0x87654321) - printf ("clobbered at low end\n"); - if (rp[size] != 0x12345678) - printf ("clobbered at high end\n"); - printf ("TEST NUMBER %u\n", test); - abort(); - } -#endif - } - exit (0); -} - -static void -print_posneg (mp_limb_t d) -{ - char buf[LXW + 2]; - if (d == 0) - printf (" %*X", LXW, 0); - else if (-d < d) - { - sprintf (buf, "%llX", (unsigned long long) -d); - printf ("%*s-%s", LXW - (int) strlen (buf), "", buf); - } - else - { - sprintf (buf, "%llX", (unsigned long long) d); - printf ("%*s+%s", LXW - (int) strlen (buf), "", buf); - } -} - -static void -mpn_print (mp_ptr p, mp_size_t size) -{ - mp_size_t i; - - for (i = size - 1; i >= 0; i--) - { -#ifdef _LONG_LONG_LIMB - printf ("%0*lX%0*lX", (int) (sizeof(mp_limb_t)), - (unsigned long) (p[i] >> (GMP_LIMB_BITS/2)), - (int) (sizeof(mp_limb_t)), (unsigned long) (p[i])); -#else - printf ("%0*lX", (int) (2 * sizeof(mp_limb_t)), p[i]); -#endif -#ifdef SPACE - if (i != 0) - printf (" "); -#endif - } - puts (""); -} diff --git a/gcc/gmp/tests/devel/aors_n.c b/gcc/gmp/tests/devel/aors_n.c deleted file mode 100644 index d15cb58a89..0000000000 --- a/gcc/gmp/tests/devel/aors_n.c +++ /dev/null @@ -1,262 +0,0 @@ -/* -Copyright 1996-2004, 2009, 2011 Free Software Foundation, Inc. - -This file is part of the GNU MP Library test suite. - -The GNU MP Library test suite is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 3 of the License, -or (at your option) any later version. - -The GNU MP Library test suite is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -Public License for more details. - -You should have received a copy of the GNU General Public License along with -the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ - -#include -#include -#include -#include "gmp-impl.h" -#include "tests.h" - -#ifdef OPERATION_add_n -#define func __gmpn_add_n -#define reffunc refmpn_add_n -#define funcname "mpn_add_n" -#endif - -#ifdef OPERATION_sub_n -#define func __gmpn_sub_n -#define reffunc refmpn_sub_n -#define funcname "mpn_sub_n" -#endif - -#ifdef OPERATION_addlsh1_n -#define func __gmpn_addlsh1_n -#define reffunc refmpn_addlsh1_n -#define funcname "mpn_addlsh1_n" -#endif - -#ifdef OPERATION_sublsh1_n -#define func __gmpn_sublsh1_n -#define reffunc refmpn_sublsh1_n -#define funcname "mpn_sublsh1_n" -#endif - -#ifdef OPERATION_rsh1add_n -#define func __gmpn_rsh1add_n -#define reffunc refmpn_rsh1add_n -#define funcname "mpn_rsh1add_n" -#endif - -#ifdef OPERATION_rsh1sub_n -#define func __gmpn_rsh1sub_n -#define reffunc refmpn_rsh1sub_n -#define funcname "mpn_rsh1sub_n" -#endif - -#if defined (USG) || defined (__SVR4) || defined (_UNICOS) || defined (__hpux) -#include - -int -cputime () -{ - if (CLOCKS_PER_SEC < 100000) - return clock () * 1000 / CLOCKS_PER_SEC; - return clock () / (CLOCKS_PER_SEC / 1000); -} -#else -#include -#include -#include - -int -cputime () -{ - struct rusage rus; - - getrusage (0, &rus); - return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000; -} -#endif - -static void print_posneg (mp_limb_t); -static void mpn_print (mp_ptr, mp_size_t); - -#define LXW ((int) (2 * sizeof (mp_limb_t))) -#define M * 1000000 - -#ifndef CLOCK -#error "Don't know CLOCK of your machine" -#endif - -#ifndef OPS -#define OPS (CLOCK/5) -#endif -#ifndef SIZE -#define SIZE 328 -#endif -#ifndef TIMES -#define TIMES OPS/(SIZE+1) -#endif - -int -main (int argc, char **argv) -{ - mp_ptr s1, s2, dx, dy; - mp_limb_t cyx, cyy; - int i; -#if TIMES != 1 - long t0, t; -#endif - unsigned int test; - mp_size_t size; - unsigned int ntests; - - s1 = malloc (SIZE * sizeof (mp_limb_t)); - s2 = malloc (SIZE * sizeof (mp_limb_t)); - dx = malloc ((SIZE + 2) * sizeof (mp_limb_t)); - dy = malloc ((SIZE + 2) * sizeof (mp_limb_t)); - - ntests = ~(unsigned) 0; - if (argc == 2) - ntests = strtol (argv[1], 0, 0); - - for (test = 1; test <= ntests; test++) - { -#if TIMES == 1 && ! defined (PRINT) - if (test % (SIZE > 100000 ? 1 : 100000 / SIZE) == 0) - { - printf ("\r%u", test); - fflush (stdout); - } -#endif - -#ifdef RANDOM - size = random () % SIZE + 1; -#else - size = SIZE; -#endif - - dx[0] = 0x87654321; - dy[0] = 0x87654321; - dx[size+1] = 0x12345678; - dy[size+1] = 0x12345678; - -#if TIMES != 1 - mpn_random (s1, size); - mpn_random (s2, size); - - t0 = cputime(); - for (i = 0; i < TIMES; i++) - func (dx+1, s1, s2, size); - t = cputime() - t0; - printf (funcname ": %5ldms (%.3f cycles/limb)\n", - t, ((double) t * CLOCK) / (TIMES * size * 1000.0)); -#endif - -#ifndef NOCHECK - mpn_random2 (s1, size); - mpn_random2 (s2, size); - -#ifdef PRINT - mpn_print (s1, size); - mpn_print (s2, size); -#endif - - /* Put garbage in the destination. */ - for (i = 0; i < size; i++) - { - dx[i+1] = 0xdead; - dy[i+1] = 0xbeef; - } - - cyx = reffunc (dx+1, s1, s2, size); - cyy = func (dy+1, s1, s2, size); - -#ifdef PRINT - mpn_print (&cyx, 1); - mpn_print (dx+1, size); - mpn_print (&cyy, 1); - mpn_print (dy+1, size); -#endif - - if (cyx != cyy || mpn_cmp (dx, dy, size+2) != 0 - || dx[0] != 0x87654321 || dx[size+1] != 0x12345678) - { - mp_size_t s, e; - for (s = 0;; s++) - if ((unsigned long long) (dx+1)[s] != (unsigned long long) (dy+1)[s]) - break; - for (e = size - 1;; e--) - if ((unsigned long long) (dx+1)[e] != (unsigned long long) (dy+1)[e]) - break; -#ifndef PRINT - for (i = s; i <= e; i++) - { - printf ("%6d: ", i); - printf ("%0*llX ", LXW, (unsigned long long) (dx+1)[i]); - printf ("%0*llX ", LXW, (unsigned long long) (dy+1)[i]); - print_posneg ((dy+1)[i] - (dx+1)[i]); - printf ("\n"); - } - printf ("%6s: ", "retval"); - printf ("%0*llX ", LXW, (unsigned long long) cyx); - printf ("%0*llX ", LXW, (unsigned long long) cyy); - print_posneg (cyx - cyy); -#endif - printf ("\n"); - if (dy[0] != 0x87654321) - printf ("clobbered at low end\n"); - if (dy[size+1] != 0x12345678) - printf ("clobbered at high end\n"); - printf ("TEST NUMBER %u\n", test); - abort(); - } -#endif - } - exit (0); -} - -static void -print_posneg (mp_limb_t d) -{ - char buf[LXW + 2]; - if (d == 0) - printf (" %*X", LXW, 0); - else if (-d < d) - { - sprintf (buf, "%llX", (unsigned long long) -d); - printf ("%*s-%s", LXW - (int) strlen (buf), "", buf); - } - else - { - sprintf (buf, "%llX", (unsigned long long) d); - printf ("%*s+%s", LXW - (int) strlen (buf), "", buf); - } -} - -static void -mpn_print (mp_ptr p, mp_size_t size) -{ - mp_size_t i; - - for (i = size - 1; i >= 0; i--) - { -#ifdef _LONG_LONG_LIMB - printf ("%0*lX%0*lX", (int) (sizeof(mp_limb_t)), - (unsigned long) (p[i] >> (GMP_LIMB_BITS/2)), - (int) (sizeof(mp_limb_t)), (unsigned long) (p[i])); -#else - printf ("%0*lX", (int) (2 * sizeof(mp_limb_t)), p[i]); -#endif -#ifdef SPACE - if (i != 0) - printf (" "); -#endif - } - puts (""); -} diff --git a/gcc/gmp/tests/devel/cnd_aors_n.c b/gcc/gmp/tests/devel/cnd_aors_n.c deleted file mode 100644 index 00d6db11c1..0000000000 --- a/gcc/gmp/tests/devel/cnd_aors_n.c +++ /dev/null @@ -1,257 +0,0 @@ -/* -Copyright 1996-2004, 2009, 2011 Free Software Foundation, Inc. - -This file is part of the GNU MP Library test suite. - -The GNU MP Library test suite is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 3 of the License, -or (at your option) any later version. - -The GNU MP Library test suite is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -Public License for more details. - -You should have received a copy of the GNU General Public License along with -the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ - -#include -#include -#include -#include "gmp-impl.h" -#include "tests/tests.h" - -#ifdef OPERATION_cnd_add_n -#define func __gmpn_cnd_add_n -#define reffunc refmpn_cnd_add_n -#define funcname "mpn_cnd_add_n" -#endif - -#ifdef OPERATION_cnd_sub_n -#define func __gmpn_cnd_sub_n -#define reffunc refmpn_cnd_sub_n -#define funcname "mpn_cnd_sub_n" -#endif - -#if defined (USG) || defined (__SVR4) || defined (_UNICOS) || defined (__hpux) -#include - -int -cputime () -{ - if (CLOCKS_PER_SEC < 100000) - return clock () * 1000 / CLOCKS_PER_SEC; - return clock () / (CLOCKS_PER_SEC / 1000); -} -#else -#include -#include -#include - -int -cputime () -{ - struct rusage rus; - - getrusage (0, &rus); - return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000; -} -#endif - -static void print_posneg (mp_limb_t); -static void mpn_print (mp_ptr, mp_size_t); - -#define LXW ((int) (2 * sizeof (mp_limb_t))) -#define M * 1000000 - -#ifndef CLOCK -#error "Don't know CLOCK of your machine" -#endif - -#ifndef OPS -#define OPS (CLOCK/5) -#endif -#ifndef SIZE -#define SIZE 328 -#endif -#ifndef TIMES -#define TIMES OPS/(SIZE+1) -#endif - -int -main (int argc, char **argv) -{ - mp_ptr s1, s2, dx, dy; - mp_limb_t cyx, cyy; - int i; -#if TIMES != 1 - long t0, t; -#endif - unsigned int test; - mp_size_t size; - unsigned int ntests; - - s1 = malloc ((SIZE + 2) * sizeof (mp_limb_t)); - s2 = malloc ((SIZE + 2) * sizeof (mp_limb_t)); - dx = malloc ((SIZE + 2) * sizeof (mp_limb_t)); - dy = malloc ((SIZE + 2) * sizeof (mp_limb_t)); - - s1 += 1; - s2 += 1; - - ntests = ~(unsigned) 0; - if (argc == 2) - ntests = strtol (argv[1], 0, 0); - - for (test = 1; test <= ntests; test++) - { -#if TIMES == 1 && ! defined (PRINT) - if (test % (SIZE > 100000 ? 1 : 100000 / SIZE) == 0) - { - printf ("\r%u", test); - fflush (stdout); - } -#endif - -#ifdef PLAIN_RANDOM -#define MPN_RANDOM mpn_random -#else -#define MPN_RANDOM mpn_random2 -#endif - -#ifdef RANDOM - size = random () % SIZE + 1; -#else - size = SIZE; -#endif - - dx[0] = 0x87654321; - dy[0] = 0x87654321; - dx[size+1] = 0x12345678; - dy[size+1] = 0x12345678; - -#if TIMES != 1 - mpn_random (s1 - 1, size + 2); - mpn_random (s2 - 1, size + 2); - - t0 = cputime(); - for (i = 0; i < TIMES; i++) - func (i & 1, dx+1, s1, s2, size); - t = cputime() - t0; - printf (funcname ": %5ldms (%.3f cycles/limb)\n", - t, ((double) t * CLOCK) / (TIMES * size * 1000.0)); -#endif - -#ifndef NOCHECK -#ifndef ZEROup - MPN_RANDOM (s1 - 1, size + 2); -#else - MPN_ZERO (s1, size); -#endif -#ifndef ZEROvp - MPN_RANDOM (s2 - 1, size + 2); -#else - MPN_ZERO (s2, size); -#endif - -#ifdef PRINT - mpn_print (s1, size); - mpn_print (s2, size); -#endif - - /* Put garbage in the destination. */ - for (i = 0; i < size; i++) - { - dx[i+1] = 0xdead; - dy[i+1] = 0xbeef; - } - - int cond = random() & 1; - - cyx = reffunc (cond, dx+1, s1, s2, size); - cyy = func (cond, dy+1, s1, s2, size); - -#ifdef PRINT - mpn_print (&cyx, 1); - mpn_print (dx+1, size); - mpn_print (&cyy, 1); - mpn_print (dy+1, size); -#endif - - if (cyx != cyy || mpn_cmp (dx, dy, size+2) != 0 - || dx[0] != 0x87654321 || dx[size+1] != 0x12345678) - { - mp_size_t s, e; - for (s = 0;; s++) - if ((unsigned long long) (dx+1)[s] != (unsigned long long) (dy+1)[s]) - break; - for (e = size - 1;; e--) - if ((unsigned long long) (dx+1)[e] != (unsigned long long) (dy+1)[e]) - break; -#ifndef PRINT - for (i = s; i <= e; i++) - { - printf ("%6d: ", i); - printf ("%0*llX ", LXW, (unsigned long long) (dx+1)[i]); - printf ("%0*llX ", LXW, (unsigned long long) (dy+1)[i]); - print_posneg ((dy+1)[i] - (dx+1)[i]); - printf ("\n"); - } - printf ("%6s: ", "retval"); - printf ("%0*llX ", LXW, (unsigned long long) cyx); - printf ("%0*llX ", LXW, (unsigned long long) cyy); - print_posneg (cyx - cyy); -#endif - printf ("\n"); - if (dy[0] != 0x87654321) - printf ("clobbered at low end\n"); - if (dy[size+1] != 0x12345678) - printf ("clobbered at high end\n"); - printf ("TEST NUMBER %u\n", test); - abort(); - } -#endif - } - exit (0); -} - -static void -print_posneg (mp_limb_t d) -{ - char buf[LXW + 2]; - if (d == 0) - printf (" %*X", LXW, 0); - else if (-d < d) - { - sprintf (buf, "%llX", (unsigned long long) -d); - printf ("%*s-%s", LXW - (int) strlen (buf), "", buf); - } - else - { - sprintf (buf, "%llX", (unsigned long long) d); - printf ("%*s+%s", LXW - (int) strlen (buf), "", buf); - } -} - -static void -mpn_print (mp_ptr p, mp_size_t size) -{ - mp_size_t i; - - for (i = size - 1; i >= 0; i--) - { -#ifdef _LONG_LONG_LIMB - printf ("%0*lX%0*lX", (int) (sizeof(mp_limb_t)), - (unsigned long) (p[i] >> (GMP_LIMB_BITS/2)), - (int) (sizeof(mp_limb_t)), (unsigned long) (p[i])); -#else - printf ("%0*lX", (int) (2 * sizeof(mp_limb_t)), p[i]); -#endif -#ifdef SPACE - if (i != 0) - printf (" "); -#endif - } - puts (""); -} diff --git a/gcc/gmp/tests/devel/copy.c b/gcc/gmp/tests/devel/copy.c deleted file mode 100644 index 65dbd9b60f..0000000000 --- a/gcc/gmp/tests/devel/copy.c +++ /dev/null @@ -1,225 +0,0 @@ -/* -Copyright 1999-2001, 2004, 2009, 2011 Free Software Foundation, Inc. - -This file is part of the GNU MP Library test suite. - -The GNU MP Library test suite is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 3 of the License, -or (at your option) any later version. - -The GNU MP Library test suite is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -Public License for more details. - -You should have received a copy of the GNU General Public License along with -the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ - -#include -#include -#include -#include "gmp-impl.h" -#include "tests.h" - -#ifdef OPERATION_copyi -#define func MPN_COPY_INCR -#define reffunc refmpn_copyi -#define funcname "MPN_COPY_INCR" -#endif - -#ifdef OPERATION_copyd -#define func MPN_COPY_DECR -#define reffunc refmpn_copyd -#define funcname "MPN_COPY_DECR" -#endif - -#if defined (USG) || defined (__SVR4) || defined (_UNICOS) || defined (__hpux) -#include - -int -cputime () -{ - if (CLOCKS_PER_SEC < 100000) - return clock () * 1000 / CLOCKS_PER_SEC; - return clock () / (CLOCKS_PER_SEC / 1000); -} -#else -#include -#include -#include - -int -cputime () -{ - struct rusage rus; - - getrusage (0, &rus); - return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000; -} -#endif - -static void print_posneg (mp_limb_t); -static void mpn_print (mp_ptr, mp_size_t); - -#define LXW ((int) (2 * sizeof (mp_limb_t))) -#define M * 1000000 - -#ifndef CLOCK -#error "Don't know CLOCK of your machine" -#endif - -#ifndef OPS -#define OPS (CLOCK/5) -#endif -#ifndef SIZE -#define SIZE 496 -#endif -#ifndef TIMES -#define TIMES OPS/(SIZE+1) -#endif - -int -main (int argc, char **argv) -{ - mp_ptr s1, dx, dy; - int i; - long t0, t; - unsigned int test; - mp_size_t size; - unsigned int ntests; - - s1 = malloc (SIZE * sizeof (mp_limb_t)); - dx = malloc ((SIZE + 2) * sizeof (mp_limb_t)); - dy = malloc ((SIZE + 2) * sizeof (mp_limb_t)); - - ntests = ~(unsigned) 0; - if (argc == 2) - ntests = strtol (argv[1], 0, 0); - - for (test = 1; test <= ntests; test++) - { -#if TIMES == 1 && ! defined (PRINT) - if (test % (SIZE > 100000 ? 1 : 100000 / SIZE) == 0) - { - printf ("\r%u", test); - fflush (stdout); - } -#endif - -#ifdef RANDOM - size = random () % SIZE + 1; -#else - size = SIZE; -#endif - - dx[0] = 0x87654321; - dy[0] = 0x87654321; - dx[size+1] = 0x12345678; - dy[size+1] = 0x12345678; - -#if TIMES != 1 - mpn_random (s1, size); - - t0 = cputime(); - for (i = 0; i < TIMES; i++) - func (dx+1, s1, size); - t = cputime() - t0; - printf (funcname ": %5ldms (%.3f cycles/limb)\n", - t, ((double) t * CLOCK) / (TIMES * size * 1000.0)); -#endif - -#ifndef NOCHECK - mpn_random2 (s1, size); - -#ifdef PRINT - mpn_print (s1, size); -#endif - - /* Put garbage in the destination. */ - for (i = 0; i < size; i++) - { - dx[i+1] = 0xdead; - dy[i+1] = 0xbeef; - } - - reffunc (dx+1, s1, size); - func (dy+1, s1, size); - -#ifdef PRINT - mpn_print (dx+1, size); - mpn_print (dy+1, size); -#endif - - if (mpn_cmp (dx, dy, size+2) != 0 - || dx[0] != 0x87654321 || dx[size+1] != 0x12345678) - { - mp_size_t s, e; - for (s = 0;; s++) - if ((unsigned long long) (dx+1)[s] != (unsigned long long) (dy+1)[s]) - break; - for (e = size - 1;; e--) - if ((unsigned long long) (dx+1)[e] != (unsigned long long) (dy+1)[e]) - break; -#ifndef PRINT - for (i = s; i <= e; i++) - { - printf ("%6d: ", i); - printf ("%0*llX ", LXW, (unsigned long long) (dx+1)[i]); - printf ("%0*llX ", LXW, (unsigned long long) (dy+1)[i]); - print_posneg ((dy+1)[i] - (dx+1)[i]); - printf ("\n"); - } -#endif - printf ("\n"); - if (dy[0] != 0x87654321) - printf ("clobbered at low end\n"); - if (dy[size+1] != 0x12345678) - printf ("clobbered at high end\n"); - printf ("TEST NUMBER %u\n", test); - abort(); - } -#endif - } - exit (0); -} - -static void -print_posneg (mp_limb_t d) -{ - char buf[LXW + 2]; - if (d == 0) - printf (" %*X", LXW, 0); - else if (-d < d) - { - sprintf (buf, "%llX", (unsigned long long) -d); - printf ("%*s-%s", LXW - (int) strlen (buf), "", buf); - } - else - { - sprintf (buf, "%llX", (unsigned long long) d); - printf ("%*s+%s", LXW - (int) strlen (buf), "", buf); - } -} - -static void -mpn_print (mp_ptr p, mp_size_t size) -{ - mp_size_t i; - - for (i = size - 1; i >= 0; i--) - { -#ifdef _LONG_LONG_LIMB - printf ("%0*lX%0*lX", (int) (sizeof(mp_limb_t)), - (unsigned long) (p[i] >> (GMP_LIMB_BITS/2)), - (int) (sizeof(mp_limb_t)), (unsigned long) (p[i])); -#else - printf ("%0*lX", (int) (2 * sizeof(mp_limb_t)), p[i]); -#endif -#ifdef SPACE - if (i != 0) - printf (" "); -#endif - } - puts (""); -} diff --git a/gcc/gmp/tests/devel/divmod_1.c b/gcc/gmp/tests/devel/divmod_1.c deleted file mode 100644 index 2757375dd0..0000000000 --- a/gcc/gmp/tests/devel/divmod_1.c +++ /dev/null @@ -1,199 +0,0 @@ -/* -Copyright 1996, 1998, 2000, 2001, 2007 Free Software Foundation, Inc. - -This file is part of the GNU MP Library test suite. - -The GNU MP Library test suite is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 3 of the License, -or (at your option) any later version. - -The GNU MP Library test suite is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -Public License for more details. - -You should have received a copy of the GNU General Public License along with -the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ - -#include -#include -#include "gmp-impl.h" -#include "tests.h" - -#if defined (USG) || defined (__SVR4) || defined (_UNICOS) || defined (__hpux) -#include - -int -cputime () -{ - if (CLOCKS_PER_SEC < 100000) - return clock () * 1000 / CLOCKS_PER_SEC; - return clock () / (CLOCKS_PER_SEC / 1000); -} -#else -#include -#include -#include - -int -cputime () -{ - struct rusage rus; - - getrusage (0, &rus); - return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000; -} -#endif - -static void mpn_print (mp_ptr, mp_size_t); - -#define M * 1000000 - -#ifndef CLOCK -#error "Don't know CLOCK of your machine" -#endif - -#ifndef OPS -#define OPS 20000000 -#endif -#ifndef SIZE -#define SIZE 1000 -#endif -#ifndef TIMES -#define TIMES OPS/SIZE -#endif - -#ifndef FSIZE -#define FSIZE SIZE -#endif - -int -main () -{ - mp_limb_t np[SIZE]; - mp_limb_t dx[SIZE + FSIZE + 2]; - mp_limb_t dy[SIZE + FSIZE + 2]; - mp_limb_t dlimb; - mp_size_t nn, fn; - mp_limb_t retx, rety; - int test; -#if TIMES != 1 - int i; - long t0, t; - double cyc; -#endif - - for (test = 0; ; test++) - { -#if TIMES == 1 && ! defined (PRINT) - if (test % (SIZE > 100000 ? 1 : 100000 / SIZE) == 0) - { - printf ("\r%u", test); - fflush (stdout); - } -#endif - -#ifdef RANDOM - nn = random () % (SIZE + 1); - fn = random () % (FSIZE + 1); -#else - nn = SIZE; - fn = FSIZE; -#endif - - dx[0] = 0x87654321; - dx[nn + fn + 1] = 0x12345678; - dy[0] = 0x87654321; - dy[nn + fn + 1] = 0x12345678; - mpn_random2 (np, nn); - -#ifdef FIXED_DLIMB - dlimb = FIXED_DLIMB; -#else - do - { - mpn_random2 (&dlimb, 1); -#ifdef FORCE_NORM - dlimb |= GMP_NUMB_HIGHBIT; -#endif -#ifdef FORCE_UNNORM - dlimb &= GMP_NUMB_MAX >> 1; -#endif - } - while (dlimb == 0); -#endif - -#if defined (PRINT) || defined (XPRINT) - printf ("N="); - mpn_print (np, nn); - printf ("D="); - mpn_print (&dlimb, 1); - printf ("nn=%ld\n", (long) nn); -#endif - -#if TIMES != 1 - t0 = cputime(); - for (i = 0; i < TIMES; i++) - mpn_divrem_1 (dx + 1, 0L, np, nn, dlimb); - t = cputime() - t0; - cyc = ((double) t * CLOCK) / (TIMES * nn * 1000.0); - printf ("mpn_divrem_1 int: %5ldms (%.3f cycles/limb) [%.2f Gb/s]\n", - t, cyc, - CLOCK/cyc*GMP_LIMB_BITS*GMP_LIMB_BITS/1e9); - t0 = cputime(); - for (i = 0; i < TIMES; i++) - mpn_divrem_1 (dx + 1, fn, np, 0, dlimb); - t = cputime() - t0; - cyc = ((double) t * CLOCK) / (TIMES * fn * 1000.0); - printf ("mpn_divrem_1 frac: %5ldms (%.3f cycles/limb) [%.2f Gb/s]\n", - t, cyc, - CLOCK/cyc*GMP_LIMB_BITS*GMP_LIMB_BITS/1e9); -#endif - - retx = refmpn_divrem_1 (dx + 1, fn, np, nn, dlimb); - rety = mpn_divrem_1 (dy + 1, fn, np, nn, dlimb); - -#ifndef NOCHECK - if (retx != rety || mpn_cmp (dx, dy, fn + nn + 2) != 0) - { - printf ("ERROR in test %d, nn=%ld, fn=%ld\n", test, nn, fn); - mpn_print (np, nn); - mpn_print (&dlimb, 1); - printf ("rq: "); - mpn_print (dx + 1, nn + fn); - printf ("rr: %*lX\n", (int) (2 * sizeof(mp_limb_t)), retx); - printf (" q: "); - mpn_print (dy + 1, nn + fn); - printf (" r: %*lX\n", (int) (2 * sizeof(mp_limb_t)), rety); - if (dy[0] != 0x87654321) - printf ("clobbered at low end %*lX\n", (int) (2 * sizeof(mp_limb_t)), dy[0]); - if (dy[nn + fn + 1] != 0x12345678) - printf ("clobbered at high end\n"); - abort (); - } -#endif - } -} - -static void -mpn_print (mp_ptr p, mp_size_t size) -{ - mp_size_t i; - - for (i = size - 1; i >= 0; i--) - { -#ifdef _LONG_LONG_LIMB - printf ("%0*lX%0*lX", (int) (sizeof(mp_limb_t)), - (unsigned long) (p[i] >> (GMP_LIMB_BITS/2)), - (int) (sizeof(mp_limb_t)), (unsigned long) (p[i])); -#else - printf ("%0*lX", (int) (2 * sizeof(mp_limb_t)), p[i]); -#endif -#ifdef SPACE - if (i != 0) - printf (" "); -#endif - } - puts (""); -} diff --git a/gcc/gmp/tests/devel/divrem.c b/gcc/gmp/tests/devel/divrem.c deleted file mode 100644 index e6c38c669c..0000000000 --- a/gcc/gmp/tests/devel/divrem.c +++ /dev/null @@ -1,118 +0,0 @@ -/* -Copyright 1996-1998, 2000, 2001, 2007, 2009 Free Software Foundation, Inc. - -This file is part of the GNU MP Library test suite. - -The GNU MP Library test suite is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 3 of the License, -or (at your option) any later version. - -The GNU MP Library test suite is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -Public License for more details. - -You should have received a copy of the GNU General Public License along with -the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ - -#include -#include -#include "gmp-impl.h" - -#if defined (USG) || defined (__SVR4) || defined (_UNICOS) || defined (__hpux) -#include - -int -cputime () -{ - if (CLOCKS_PER_SEC < 100000) - return clock () * 1000 / CLOCKS_PER_SEC; - return clock () / (CLOCKS_PER_SEC / 1000); -} -#else -#include -#include -#include - -int -cputime () -{ - struct rusage rus; - - getrusage (0, &rus); - return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000; -} -#endif - -#define M * 1000000 - -#ifndef CLOCK -#error "Don't know CLOCK of your machine" -#endif - -#ifndef OPS -#define OPS 20000000 -#endif -#ifndef SIZE -#define SIZE 100 -#endif -#ifndef TIMES -#define TIMES OPS/(SIZE+1) -#endif - -int -main () -{ - mp_limb_t nptr[2 * SIZE]; - mp_limb_t dptr[2 * SIZE]; - mp_limb_t qptr[2 * SIZE]; - mp_limb_t pptr[2 * SIZE + 1]; - mp_limb_t rptr[2 * SIZE]; - mp_size_t nsize, dsize, qsize, rsize, psize; - int test; - mp_limb_t qlimb; - - for (test = 0; ; test++) - { - printf ("%d\n", test); -#ifdef RANDOM - nsize = random () % (2 * SIZE) + 1; - dsize = random () % nsize + 1; -#else - nsize = 2 * SIZE; - dsize = SIZE; -#endif - - mpn_random2 (nptr, nsize); - mpn_random2 (dptr, dsize); - dptr[dsize - 1] |= (mp_limb_t) 1 << (GMP_LIMB_BITS - 1); - - MPN_COPY (rptr, nptr, nsize); - qlimb = mpn_divrem (qptr, (mp_size_t) 0, rptr, nsize, dptr, dsize); - rsize = dsize; - qsize = nsize - dsize; - qptr[qsize] = qlimb; - qsize += qlimb; - if (qsize == 0 || qsize > 2 * SIZE) - { - continue; /* bogus */ - } - else - { - mp_limb_t cy; - if (qsize > dsize) - mpn_mul (pptr, qptr, qsize, dptr, dsize); - else - mpn_mul (pptr, dptr, dsize, qptr, qsize); - psize = qsize + dsize; - psize -= pptr[psize - 1] == 0; - cy = mpn_add (pptr, pptr, psize, rptr, rsize); - pptr[psize] = cy; - psize += cy; - } - - if (nsize != psize || mpn_cmp (nptr, pptr, nsize) != 0) - abort (); - } -} diff --git a/gcc/gmp/tests/devel/gen-test-longlong_h.c b/gcc/gmp/tests/devel/gen-test-longlong_h.c new file mode 100644 index 0000000000..939c3f23bd --- /dev/null +++ b/gcc/gmp/tests/devel/gen-test-longlong_h.c @@ -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 +#include +#include + +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 \n"); + printf ("#include \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; +} diff --git a/gcc/gmp/tests/devel/logops_n.c b/gcc/gmp/tests/devel/logops_n.c deleted file mode 100644 index 349c6372a7..0000000000 --- a/gcc/gmp/tests/devel/logops_n.c +++ /dev/null @@ -1,229 +0,0 @@ -/* -Copyright 1996-2004, 2009 Free Software Foundation, Inc. - -This file is part of the GNU MP Library test suite. - -The GNU MP Library test suite is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 3 of the License, -or (at your option) any later version. - -The GNU MP Library test suite is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -Public License for more details. - -You should have received a copy of the GNU General Public License along with -the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ - -#include -#include -#include "gmp-impl.h" -#include "tests.h" - -#ifdef OPERATION_and_n -#define func __gmpn_and_n -#define reffunc refmpn_and_n -#define funcname "mpn_and_n" -#endif - -#ifdef OPERATION_andn_n -#define func __gmpn_andn_n -#define reffunc refmpn_andn_n -#define funcname "mpn_andn_n" -#endif - -#ifdef OPERATION_nand_n -#define func __gmpn_nand_n -#define reffunc refmpn_nand_n -#define funcname "mpn_nand_n" -#endif - -#ifdef OPERATION_ior_n -#define func __gmpn_ior_n -#define reffunc refmpn_ior_n -#define funcname "mpn_ior_n" -#endif - -#ifdef OPERATION_iorn_n -#define func __gmpn_iorn_n -#define reffunc refmpn_iorn_n -#define funcname "mpn_iorn_n" -#endif - -#ifdef OPERATION_nior_n -#define func __gmpn_nior_n -#define reffunc refmpn_nior_n -#define funcname "mpn_nior_n" -#endif - -#ifdef OPERATION_xor_n -#define func __gmpn_xor_n -#define reffunc refmpn_xor_n -#define funcname "mpn_xor_n" -#endif - -#ifdef OPERATION_xnor_n -#define func __gmpn_xnor_n -#define reffunc refmpn_xnor_n -#define funcname "mpn_xnor_n" -#endif - -#if defined (USG) || defined (__SVR4) || defined (_UNICOS) || defined (__hpux) -#include - -int -cputime () -{ - if (CLOCKS_PER_SEC < 100000) - return clock () * 1000 / CLOCKS_PER_SEC; - return clock () / (CLOCKS_PER_SEC / 1000); -} -#else -#include -#include -#include - -int -cputime () -{ - struct rusage rus; - - getrusage (0, &rus); - return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000; -} -#endif - -static void mpn_print (mp_ptr, mp_size_t); - -#define M * 1000000 - -#ifndef CLOCK -#error "Don't know CLOCK of your machine" -#endif - -#ifndef OPS -#define OPS (CLOCK/5) -#endif -#ifndef SIZE -#define SIZE 328 -#endif -#ifndef TIMES -#define TIMES OPS/(SIZE+1) -#endif - -int -main (int argc, char **argv) -{ - mp_ptr s1, s2, dx, dy; - int i; - long t0, t; - unsigned int test; - mp_size_t size; - unsigned int ntests; - - s1 = malloc (SIZE * sizeof (mp_limb_t)); - s2 = malloc (SIZE * sizeof (mp_limb_t)); - dx = malloc ((SIZE + 2) * sizeof (mp_limb_t)); - dy = malloc ((SIZE + 2) * sizeof (mp_limb_t)); - - ntests = ~(unsigned) 0; - if (argc == 2) - ntests = strtol (argv[1], 0, 0); - - for (test = 1; test <= ntests; test++) - { -#if TIMES == 1 && ! defined (PRINT) - if (test % (SIZE > 100000 ? 1 : 100000 / SIZE) == 0) - { - printf ("\r%d", test); - fflush (stdout); - } -#endif - -#ifdef RANDOM - size = random () % SIZE + 1; -#else - size = SIZE; -#endif - - dx[0] = 0x87654321; - dy[0] = 0x87654321; - dx[size+1] = 0x12345678; - dy[size+1] = 0x12345678; - -#if TIMES != 1 - mpn_random (s1, size); - mpn_random (s2, size); - - t0 = cputime(); - for (i = 0; i < TIMES; i++) - func (dx+1, s1, s2, size); - t = cputime() - t0; - printf (funcname ": %5ldms (%.3f cycles/limb)\n", - t, ((double) t * CLOCK) / (TIMES * size * 1000.0)); -#endif - -#ifndef NOCHECK - mpn_random2 (s1, size); - mpn_random2 (s2, size); - -#ifdef PRINT - mpn_print (s1, size); - mpn_print (s2, size); -#endif - - /* Put garbage in the destination. */ - for (i = 0; i < size; i++) - { - dx[i+1] = 0xdead; - dy[i+1] = 0xbeef; - } - - reffunc (dx+1, s1, s2, size); - func (dy+1, s1, s2, size); -#ifdef PRINT - mpn_print (dx+1, size); - mpn_print (dy+1, size); -#endif - if (mpn_cmp (dx, dy, size+2) != 0 - || dx[0] != 0x87654321 || dx[size+1] != 0x12345678) - { -#ifndef PRINT - mpn_print (dx+1, size); - mpn_print (dy+1, size); -#endif - printf ("\n"); - if (dy[0] != 0x87654321) - printf ("clobbered at low end\n"); - if (dy[size+1] != 0x12345678) - printf ("clobbered at high end\n"); - printf ("TEST NUMBER %u\n", test); - abort(); - } -#endif - } - exit (0); -} - -static void -mpn_print (mp_ptr p, mp_size_t size) -{ - mp_size_t i; - - for (i = size - 1; i >= 0; i--) - { -#ifdef _LONG_LONG_LIMB - printf ("%0*lX%0*lX", (int) (sizeof(mp_limb_t)), - (unsigned long) (p[i] >> (GMP_LIMB_BITS/2)), - (int) (sizeof(mp_limb_t)), (unsigned long) (p[i])); -#else - printf ("%0*lX", (int) (2 * sizeof(mp_limb_t)), p[i]); -#endif -#ifdef SPACE - if (i != 0) - printf (" "); -#endif - } - puts (""); -} diff --git a/gcc/gmp/tests/devel/mul_N.c b/gcc/gmp/tests/devel/mul_N.c deleted file mode 100644 index c9de5ecc68..0000000000 --- a/gcc/gmp/tests/devel/mul_N.c +++ /dev/null @@ -1,270 +0,0 @@ -/* -Copyright 1996-2002, 2004, 2007 Free Software Foundation, Inc. - -This file is part of the GNU MP Library test suite. - -The GNU MP Library test suite is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 3 of the License, -or (at your option) any later version. - -The GNU MP Library test suite is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -Public License for more details. - -You should have received a copy of the GNU General Public License along with -the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ - -#include -#include -#include -#include "gmp-impl.h" -#include "longlong.h" - -#if defined (USG) || defined (__SVR4) || defined (_UNICOS) || defined (__hpux) -#include - -int -cputime () -{ - if (CLOCKS_PER_SEC < 100000) - return clock () * 1000 / CLOCKS_PER_SEC; - return clock () / (CLOCKS_PER_SEC / 1000); -} -#else -#include -#include -#include - -int -cputime () -{ - struct rusage rus; - - getrusage (0, &rus); - return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000; -} -#endif - -#ifndef NOCHECK -static void print_posneg (mp_limb_t); -#endif -#ifdef PRINT -static void mpn_print (mp_ptr, mp_size_t); -#endif - -#define LXW ((int) (2 * sizeof (mp_limb_t))) -#define M * 1000000 - -#ifndef CLOCK -#error "Don't know CLOCK of your machine" -#endif - -#ifndef OPS -#define OPS (CLOCK/5) -#endif -#ifndef SIZE -#define SIZE 496 -#endif -#ifndef TIMES -#define TIMES OPS/(SIZE+1) -#endif - -#if N == 2 -#define mpn_mul_N mpn_mul_2 -#elif N == 3 -#define mpn_mul_N mpn_mul_3 -#elif N == 4 -#define mpn_mul_N mpn_mul_4 -#elif N == 5 -#define mpn_mul_N mpn_mul_5 -#elif N == 6 -#define mpn_mul_N mpn_mul_6 -#elif N == 7 -#define mpn_mul_N mpn_mul_7 -#elif N == 8 -#define mpn_mul_N mpn_mul_8 -#endif - -mp_limb_t -refmpn_mul_N (mp_ptr rp, mp_srcptr up, mp_size_t n, mp_srcptr vp) -{ - int i; - rp[n] = mpn_mul_1 (rp, up, n, *vp); - rp++; - vp++; - for (i = 2; i < N; i++) - { - rp[n] = mpn_addmul_1 (rp, up, n, *vp); - rp++; - vp++; - } - return mpn_addmul_1 (rp, up, n, *vp); -} - -int -main (int argc, char **argv) -{ - mp_limb_t up[SIZE]; - mp_limb_t ref[SIZE + N - 1]; - mp_limb_t mem[SIZE + N + 1]; - mp_ptr rp = mem + 1; - mp_limb_t vp[N]; - mp_limb_t cy_ref, cy_try; - int i; -#if TIMES != 1 - long t0, t; - double cyc; -#endif - unsigned test; - mp_size_t size; - unsigned ntests; - - ntests = ~(unsigned) 0; - if (argc == 2) - ntests = strtol (argv[1], 0, 0); - - for (test = 1; test <= ntests; test++) - { -#if TIMES == 1 && ! defined (PRINT) - if (test % (CLOCK / SIZE / 1000) == 0) - { - printf ("\r%u", test); - fflush (stdout); - } -#endif - -#ifdef RANDOM - size = random () % (SIZE - N + 1) + N; -#else - size = SIZE; -#endif - - rp[size + N - 1] = 0x12345678; - rp[-1] = 0x87654321; - - mpn_random (vp, N); - -#if TIMES != 1 /* run timing tests unless asked not to */ - mpn_random (up, size); - - MPN_COPY (ref, rp, size + N - 1); - t0 = cputime(); - for (i = 0; i < TIMES; i++) - mpn_mul_N (ref, up, size, vp); - t = cputime() - t0; - cyc = ((double) t * CLOCK) / (TIMES * size * 1000.0) / N; - printf ("mpn_mul_%d: %5ldms (%.3f cycles/limb) [%.2f Gb/s]\n", - N, t, cyc, CLOCK/cyc*GMP_LIMB_BITS*GMP_LIMB_BITS/1e9); -#endif - -#ifdef PLAIN_RANDOM -#define MPN_RANDOM mpn_random -#else -#define MPN_RANDOM mpn_random2 -#endif - -#ifdef ZEROu - MPN_ZERO (up, size); -#else - MPN_RANDOM (up, size); -#endif - MPN_RANDOM (vp, N); - /* vp[0] = vp[1] = vp[2] = vp[3] = vp[4] = vp[5] = 0; */ - MPN_RANDOM (rp, size + N - 1); - -#if defined (PRINT) || defined (PRINTV) - printf ("vp="); - mpn_print (vp, N); -#endif -#ifdef PRINT - printf ("%*s ", 3 + N * LXW, ""); - mpn_print (up, size); -#endif - - MPN_COPY (ref, rp, size + N - 1); - cy_ref = refmpn_mul_N (ref, up, size, vp); - cy_try = mpn_mul_N (rp, up, size, vp); - -#ifdef PRINT - printf ("%*lX ", LXW, cy_ref); - mpn_print (ref, size + N - 1); - printf ("%*lX ", LXW, cy_try); - mpn_print (rp, size + N - 1); -#endif - -#ifndef NOCHECK - if (cy_ref != cy_try || mpn_cmp (ref, rp, size + N - 1) != 0 -// if (cy_ref != cy_try || mpn_cmp (ref + 5, rp + 5, size + N - 1 - 6) != 0 - || rp[size + N - 1] != 0x12345678 || rp[-1] != 0x87654321) - { - printf ("\n ref%*s try%*s diff\n", LXW - 3, "", 2 * LXW - 6, ""); - for (i = 0; i < size + N - 1; i++) - { - printf ("%6d: ", i); - printf ("%0*llX ", LXW, (unsigned long long) ref[i]); - printf ("%0*llX ", LXW, (unsigned long long) rp[i]); - print_posneg (rp[i] - ref[i]); - printf ("\n"); - } - printf ("retval: "); - printf ("%0*llX ", LXW, (unsigned long long) cy_ref); - printf ("%0*llX ", LXW, (unsigned long long) cy_try); - print_posneg (cy_try - cy_ref); - printf ("\n"); - if (rp[-1] != 0x87654321) - printf ("clobbered at low end\n"); - if (rp[size + N - 1] != 0x12345678) - printf ("clobbered at high end\n"); - printf ("TEST NUMBER %u\n", test); - abort(); - } -#endif - } - exit (0); -} - -#ifndef NOCHECK -static void -print_posneg (mp_limb_t d) -{ - char buf[LXW + 2]; - if (d == 0) - printf (" %*X", LXW, 0); - else if (-d < d) - { - sprintf (buf, "%llX", (unsigned long long) -d); - printf ("%*s-%s", LXW - (int) strlen (buf), "", buf); - } - else - { - sprintf (buf, "%llX", (unsigned long long) d); - printf ("%*s+%s", LXW - (int) strlen (buf), "", buf); - } -} -#endif - -#ifdef PRINT -static void -mpn_print (mp_ptr p, mp_size_t size) -{ - mp_size_t i; - - for (i = size - 1; i >= 0; i--) - { -#ifdef _LONG_LONG_LIMB - printf ("%0*lX%0*lX", (int) (sizeof(mp_limb_t)), - (unsigned long) (p[i] >> (GMP_LIMB_BITS/2)), - (int) (sizeof(mp_limb_t)), (unsigned long) (p[i])); -#else - printf ("%0*lX", LXW, p[i]); -#endif -#ifdef SPACE - if (i != 0) - printf (" "); -#endif - } - puts (""); -} -#endif diff --git a/gcc/gmp/tests/devel/shift.c b/gcc/gmp/tests/devel/shift.c deleted file mode 100644 index ad5125b49c..0000000000 --- a/gcc/gmp/tests/devel/shift.c +++ /dev/null @@ -1,244 +0,0 @@ -/* -Copyright 1996, 1998-2001, 2004, 2007, 2009, 2011 Free Software Foundation, -Inc. - -This file is part of the GNU MP Library test suite. - -The GNU MP Library test suite is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 3 of the License, -or (at your option) any later version. - -The GNU MP Library test suite is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -Public License for more details. - -You should have received a copy of the GNU General Public License along with -the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ - -#include -#include -#include -#include "gmp-impl.h" -#include "tests.h" - -#ifdef OPERATION_lshift -#define func __gmpn_lshift -#define reffunc refmpn_lshift -#define funcname "mpn_lshift" -#endif - -#ifdef OPERATION_rshift -#define func __gmpn_rshift -#define reffunc refmpn_rshift -#define funcname "mpn_rshift" -#endif - -#if defined (USG) || defined (__SVR4) || defined (_UNICOS) || defined (__hpux) -#include - -int -cputime () -{ - if (CLOCKS_PER_SEC < 100000) - return clock () * 1000 / CLOCKS_PER_SEC; - return clock () / (CLOCKS_PER_SEC / 1000); -} -#else -#include -#include -#include - -int -cputime () -{ - struct rusage rus; - - getrusage (0, &rus); - return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000; -} -#endif - -static void print_posneg (mp_limb_t); -static void mpn_print (mp_ptr, mp_size_t); - -#define LXW ((int) (2 * sizeof (mp_limb_t))) -#define M * 1000000 - -#ifndef CLOCK -#error "Don't know CLOCK of your machine" -#endif - -#ifndef OPS -#define OPS (CLOCK/5) -#endif -#ifndef SIZE -#define SIZE 496 -#endif -#ifndef TIMES -#define TIMES OPS/(SIZE+1) -#endif - -#ifndef CNT -int CNT = 4; -#endif - -int -main (int argc, char **argv) -{ - mp_ptr s1, dx, dy; - mp_limb_t cyx, cyy; - int i; - long t0, t; - unsigned int test; - int cnt = CNT; - mp_size_t size; - unsigned int ntests; - - s1 = malloc (SIZE * sizeof (mp_limb_t)); - dx = malloc ((SIZE + 2) * sizeof (mp_limb_t)); - dy = malloc ((SIZE + 2) * sizeof (mp_limb_t)); - - ntests = ~(unsigned) 0; - if (argc == 2) - ntests = strtol (argv[1], 0, 0); - - for (test = 1; test <= ntests; test++) - { -#if TIMES == 1 && ! defined (PRINT) - if (test % (SIZE > 100000 ? 1 : 100000 / SIZE) == 0) - { - printf ("\r%u", test); - fflush (stdout); - } -#endif - -#if TIMES == 1 - cnt = random () % (GMP_NUMB_BITS - 1) + 1; -#endif - -#ifdef RANDOM - size = random () % SIZE + 1; -#else - size = SIZE; -#endif - - dx[0] = 0x87654321; - dy[0] = 0x87654321; - dx[size+1] = 0x12345678; - dy[size+1] = 0x12345678; - -#if TIMES != 1 - mpn_random (s1, size); - - t0 = cputime(); - for (i = 0; i < TIMES; i++) - func (dx+1, s1, size, cnt); - t = cputime() - t0; - printf (funcname ": %5ldms (%.3f cycles/limb)\n", - t, ((double) t * CLOCK) / (TIMES * size * 1000.0)); -#endif - -#ifndef NOCHECK - mpn_random (s1, size); - -#ifdef PRINT - printf ("cnt=%-*d ", (int) (2 * sizeof(mp_limb_t)) - 4, cnt); - mpn_print (s1, size); -#endif - - /* Put garbage in the destination. */ - for (i = 0; i < size; i++) - { - dx[i+1] = 0xdead; - dy[i+1] = 0xbeef; - } - - cyx = reffunc (dx+1, s1, size, cnt); - cyy = func (dy+1, s1, size, cnt); - -#ifdef PRINT - mpn_print (&cyx, 1); - mpn_print (dx+1, size); - mpn_print (&cyy, 1); - mpn_print (dy+1, size); -#endif - - if (cyx != cyy || mpn_cmp (dx, dy, size+2) != 0 - || dx[0] != 0x87654321 || dx[size+1] != 0x12345678) - { - mp_size_t s, e; - for (s = 0;; s++) - if ((unsigned long long) (dx+1)[s] != (unsigned long long) (dy+1)[s]) - break; - for (e = size - 1;; e--) - if ((unsigned long long) (dx+1)[e] != (unsigned long long) (dy+1)[e]) - break; -#ifndef PRINT - printf ("cnt=%-*d\n", (int) (2 * sizeof(mp_limb_t)) - 4, cnt); - for (i = s; i <= e; i++) - { - printf ("%6d: ", i); - printf ("%0*llX ", LXW, (unsigned long long) (dx+1)[i]); - printf ("%0*llX ", LXW, (unsigned long long) (dy+1)[i]); - print_posneg ((dy+1)[i] - (dx+1)[i]); - printf ("\n"); - } - printf ("%6s: ", "retval"); - printf ("%0*llX ", LXW, (unsigned long long) cyx); - printf ("%0*llX ", LXW, (unsigned long long) cyy); - print_posneg (cyx - cyy); -#endif - printf ("\n"); - if (dy[0] != 0x87654321) - printf ("clobbered at low end\n"); - if (dy[size+1] != 0x12345678) - printf ("clobbered at high end\n"); - printf ("TEST NUMBER %u\n", test); - abort(); - } -#endif - } - exit (0); -} - -static void -print_posneg (mp_limb_t d) -{ - char buf[LXW + 2]; - if (d == 0) - printf (" %*X", LXW, 0); - else if (-d < d) - { - sprintf (buf, "%llX", (unsigned long long) -d); - printf ("%*s-%s", LXW - (int) strlen (buf), "", buf); - } - else - { - sprintf (buf, "%llX", (unsigned long long) d); - printf ("%*s+%s", LXW - (int) strlen (buf), "", buf); - } -} - -static void -mpn_print (mp_ptr p, mp_size_t size) -{ - mp_size_t i; - - for (i = size - 1; i >= 0; i--) - { -#ifdef _LONG_LONG_LIMB - printf ("%0*lX%0*lX", (int) (sizeof(mp_limb_t)), - (unsigned long) (p[i] >> (GMP_LIMB_BITS/2)), - (int) (sizeof(mp_limb_t)), (unsigned long) (p[i])); -#else - printf ("%0*lX", (int) (2 * sizeof(mp_limb_t)), p[i]); -#endif -#ifdef SPACE - if (i != 0) - printf (" "); -#endif - } - puts (""); -} diff --git a/gcc/gmp/tests/devel/tst-addsub.c b/gcc/gmp/tests/devel/tst-addsub.c deleted file mode 100644 index 4aa827a60f..0000000000 --- a/gcc/gmp/tests/devel/tst-addsub.c +++ /dev/null @@ -1,97 +0,0 @@ -/* Copyright 1996, 2001 Free Software Foundation, Inc. - -This file is part of the GNU MP Library test suite. - -The GNU MP Library test suite is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 3 of the License, -or (at your option) any later version. - -The GNU MP Library test suite is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -Public License for more details. - -You should have received a copy of the GNU General Public License along with -the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ - -#include -#include -#include "gmp-impl.h" -#include "tests.h" - -#define ADD 1 -#define SUB 2 - -#ifndef METHOD -#define METHOD ADD -#endif - -#if METHOD == ADD -#define REFCALL refmpn_add_n -#define TESTCALL mpn_add_n -#endif - -#if METHOD == SUB -#define REFCALL refmpn_sub_n -#define TESTCALL mpn_sub_n -#endif - -#define SIZE 100 - -int -main (int argc, char **argv) -{ - mp_size_t alloc_size, max_size, size, i, cumul_size; - mp_ptr s1, s2, dx, dy; - int s1_align, s2_align, d_align; - long pass, n_passes; - mp_limb_t cx, cy; - - max_size = SIZE; - n_passes = 1000000; - - argc--; argv++; - if (argc) - { - max_size = atol (*argv); - argc--; argv++; - } - - alloc_size = max_size + 32; - s1 = malloc (alloc_size * GMP_LIMB_BYTES); - s2 = malloc (alloc_size * GMP_LIMB_BYTES); - dx = malloc (alloc_size * GMP_LIMB_BYTES); - dy = malloc (alloc_size * GMP_LIMB_BYTES); - - cumul_size = 0; - for (pass = 0; pass < n_passes; pass++) - { - size = random () % max_size + 1; - - cumul_size += size; - if (cumul_size >= 1000000) - { - cumul_size -= 1000000; - printf ("\r%ld", pass); fflush (stdout); - } - s1_align = random () % 32; - s2_align = random () % 32; - d_align = random () % 32; - - mpn_random2 (s1 + s1_align, size); - mpn_random2 (s2 + s2_align, size); - - for (i = 0; i < alloc_size; i++) - dx[i] = dy[i] = i + 0x9876500; - - cx = TESTCALL (dx + d_align, s1 + s1_align, s2 + s2_align, size); - cy = REFCALL (dy + d_align, s1 + s1_align, s2 + s2_align, size); - - if (cx != cy || mpn_cmp (dx, dy, alloc_size) != 0) - abort (); - } - - printf ("%ld passes OK\n", n_passes); - exit (0); -} diff --git a/gcc/gmp/tests/misc.c b/gcc/gmp/tests/misc.c index 6c40d78b82..3c81090841 100644 --- a/gcc/gmp/tests/misc.c +++ b/gcc/gmp/tests/misc.c @@ -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) { diff --git a/gcc/gmp/tests/misc/t-locale.c b/gcc/gmp/tests/misc/t-locale.c index a789309fef..c5b0b3c04c 100644 --- a/gcc/gmp/tests/misc/t-locale.c +++ b/gcc/gmp/tests/misc/t-locale.c @@ -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__ diff --git a/gcc/gmp/tests/mpf/t-conv.c b/gcc/gmp/tests/mpf/t-conv.c index a64e86fdd7..2f992af998 100644 --- a/gcc/gmp/tests/mpf/t-conv.c +++ b/gcc/gmp/tests/mpf/t-conv.c @@ -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 (); diff --git a/gcc/gmp/tests/mpf/t-get_d_2exp.c b/gcc/gmp/tests/mpf/t-get_d_2exp.c index 6868bf3d29..b716cf891b 100644 --- a/gcc/gmp/tests/mpf/t-get_d_2exp.c +++ b/gcc/gmp/tests/mpf/t-get_d_2exp.c @@ -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; diff --git a/gcc/gmp/tests/mpf/t-trunc.c b/gcc/gmp/tests/mpf/t-trunc.c index 31fc2bd3f2..6543a1ee90 100644 --- a/gcc/gmp/tests/mpf/t-trunc.c +++ b/gcc/gmp/tests/mpf/t-trunc.c @@ -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); diff --git a/gcc/gmp/tests/mpn/t-gcd_11.c b/gcc/gmp/tests/mpn/t-gcd_11.c index 14226b0282..2b4de2f5fb 100644 --- a/gcc/gmp/tests/mpn/t-gcd_11.c +++ b/gcc/gmp/tests/mpn/t-gcd_11.c @@ -80,4 +80,7 @@ main (int argc, char **argv) mpz_clear (a); mpz_clear (b); + + tests_end (); + return 0; } diff --git a/gcc/gmp/tests/mpn/t-gcd_22.c b/gcc/gmp/tests/mpn/t-gcd_22.c index baed35af4f..314bf18b26 100644 --- a/gcc/gmp/tests/mpn/t-gcd_22.c +++ b/gcc/gmp/tests/mpn/t-gcd_22.c @@ -81,4 +81,7 @@ main (int argc, char **argv) mpz_clear (a); mpz_clear (b); mpz_clear (ref); + + tests_end (); + return 0; } diff --git a/gcc/gmp/tests/mpn/t-gcdext_1.c b/gcc/gmp/tests/mpn/t-gcdext_1.c index 99143ae7b8..1e73a11b25 100644 --- a/gcc/gmp/tests/mpn/t-gcdext_1.c +++ b/gcc/gmp/tests/mpn/t-gcdext_1.c @@ -128,4 +128,7 @@ main (int argc, char **argv) mpz_clear (a); mpz_clear (b); + + tests_end (); + return 0; } diff --git a/gcc/gmp/tests/mpz/Makefile.am b/gcc/gmp/tests/mpz/Makefile.am index 6a56edac6f..5b5eb6ddc7 100644 --- a/gcc/gmp/tests/mpz/Makefile.am +++ b/gcc/gmp/tests/mpz/Makefile.am @@ -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 \ diff --git a/gcc/gmp/tests/mpz/Makefile.in b/gcc/gmp/tests/mpz/Makefile.in index 6f42c51d78..1071296886 100644 --- a/gcc/gmp/tests/mpz/Makefile.in +++ b/gcc/gmp/tests/mpz/Makefile.in @@ -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) \ diff --git a/gcc/gmp/tests/mpz/convert.c b/gcc/gmp/tests/mpz/convert.c index fdb3874b3b..c449c669e8 100644 --- a/gcc/gmp/tests/mpz/convert.c +++ b/gcc/gmp/tests/mpz/convert.c @@ -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 #include #include /* for strlen */ +#include /* 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) { diff --git a/gcc/gmp/tests/mpz/io.c b/gcc/gmp/tests/mpz/io.c index 892f61d619..3522e9ddbf 100644 --- a/gcc/gmp/tests/mpz/io.c +++ b/gcc/gmp/tests/mpz/io.c @@ -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); diff --git a/gcc/gmp/tests/mpz/reuse.c b/gcc/gmp/tests/mpz/reuse.c index f057a9672a..a8f2201892 100644 --- a/gcc/gmp/tests/mpz/reuse.c +++ b/gcc/gmp/tests/mpz/reuse.c @@ -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"); } diff --git a/gcc/gmp/tests/mpz/bit.c b/gcc/gmp/tests/mpz/t-bit.c similarity index 100% rename from gcc/gmp/tests/mpz/bit.c rename to gcc/gmp/tests/mpz/t-bit.c diff --git a/gcc/gmp/tests/mpz/t-get_d.c b/gcc/gmp/tests/mpz/t-get_d.c index 46e5eafb75..f4c839ffcf 100644 --- a/gcc/gmp/tests/mpz/t-get_d.c +++ b/gcc/gmp/tests/mpz/t-get_d.c @@ -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; diff --git a/gcc/gmp/tests/mpz/t-mul.c b/gcc/gmp/tests/mpz/t-mul.c index 66e021eaca..0dc22e9d3a 100644 --- a/gcc/gmp/tests/mpz/t-mul.c +++ b/gcc/gmp/tests/mpz/t-mul.c @@ -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 */ diff --git a/gcc/gmp/tests/refmpn.c b/gcc/gmp/tests/refmpn.c index 42bb411229..0c8cea5512 100644 --- a/gcc/gmp/tests/refmpn.c +++ b/gcc/gmp/tests/refmpn.c @@ -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 { diff --git a/gcc/gmp/tests/spinner.c b/gcc/gmp/tests/spinner.c index 04e5b99946..13448d0828 100644 --- a/gcc/gmp/tests/spinner.c +++ b/gcc/gmp/tests/spinner.c @@ -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 (); diff --git a/gcc/gmp/tune/speed.c b/gcc/gmp/tune/speed.c index 1708e4ca19..cddf8d947d 100644 --- a/gcc/gmp/tune/speed.c +++ b/gcc/gmp/tune/speed.c @@ -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 diff --git a/gcc/gmp/tune/speed.h b/gcc/gmp/tune/speed.h index f23bacb1ef..6dc72f8fb5 100644 --- a/gcc/gmp/tune/speed.h +++ b/gcc/gmp/tune/speed.h @@ -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) \ diff --git a/gcc/gmp/tune/time.c b/gcc/gmp/tune/time.c index 9060c3d050..dc27038f01 100644 --- a/gcc/gmp/tune/time.c +++ b/gcc/gmp/tune/time.c @@ -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 @@ -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", diff --git a/gcc/gmp/tune/tune-gcd-p.c b/gcc/gmp/tune/tune-gcd-p.c index 3b5a4a8a36..0a08657185 100644 --- a/gcc/gmp/tune/tune-gcd-p.c +++ b/gcc/gmp/tune/tune-gcd-p.c @@ -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; diff --git a/gcc/gmp/tune/tuneup.c b/gcc/gmp/tune/tuneup.c index 86ba5edf67..fe1bf1a913 100644 --- a/gcc/gmp/tune/tuneup.c +++ b/gcc/gmp/tune/tuneup.c @@ -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 ();