mirror of
https://github.com/freebsd/freebsd-src
synced 2024-07-23 11:16:33 +00:00
contrib/bc: upgrade to version 6.6.0
This update removes printing of a leading zero in scientific or engineering output modes (which are an extended feature of this implementation). (cherry-picked from commit 8b83ef067441f6d3a4a55e92d1738724954a057c) MFC after: 2 weeks
This commit is contained in:
parent
5804b7ab37
commit
76238846ad
|
@ -59,7 +59,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
The files `src/rand.c` and `include/rand.h` are under the following copyrights
|
The files `src/rand.c` and `include/rand.h` are under the following copyrights
|
||||||
and license:
|
and license:
|
||||||
|
|
||||||
Copyright (c) 2014-2017 Melissa O'Neill and PCG Project contributors
|
Copyright (c) 2014-2017 Melissa O'Neill and PCG Project contributors<br>
|
||||||
Copyright (c) 2018-2023 Gavin D. Howard <gavin@gavinhoward.com>
|
Copyright (c) 2018-2023 Gavin D. Howard <gavin@gavinhoward.com>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
|
|
@ -205,7 +205,7 @@ DC_DEFS = $(DC_DEFS1) $(DC_DEFS2) $(DC_DEFS3) $(DC_DEFS4) $(DC_DEFS5)
|
||||||
CPPFLAGS1 = -D$(BC_ENABLED_NAME)=$(BC_ENABLED) -D$(DC_ENABLED_NAME)=$(DC_ENABLED)
|
CPPFLAGS1 = -D$(BC_ENABLED_NAME)=$(BC_ENABLED) -D$(DC_ENABLED_NAME)=$(DC_ENABLED)
|
||||||
CPPFLAGS2 = $(CPPFLAGS1) -I$(INCDIR)/ -DBUILD_TYPE=$(BC_BUILD_TYPE) %%LONG_BIT_DEFINE%%
|
CPPFLAGS2 = $(CPPFLAGS1) -I$(INCDIR)/ -DBUILD_TYPE=$(BC_BUILD_TYPE) %%LONG_BIT_DEFINE%%
|
||||||
CPPFLAGS3 = $(CPPFLAGS2) -DEXECPREFIX=$(EXEC_PREFIX) -DMAINEXEC=$(MAIN_EXEC)
|
CPPFLAGS3 = $(CPPFLAGS2) -DEXECPREFIX=$(EXEC_PREFIX) -DMAINEXEC=$(MAIN_EXEC)
|
||||||
CPPFLAGS4 = $(CPPFLAGS3) %%BSD%%
|
CPPFLAGS4 = $(CPPFLAGS3) %%BSD%% %%APPLE%%
|
||||||
CPPFLAGS5 = $(CPPFLAGS4) -DBC_NUM_KARATSUBA_LEN=$(BC_NUM_KARATSUBA_LEN)
|
CPPFLAGS5 = $(CPPFLAGS4) -DBC_NUM_KARATSUBA_LEN=$(BC_NUM_KARATSUBA_LEN)
|
||||||
CPPFLAGS6 = $(CPPFLAGS5) -DBC_ENABLE_NLS=$(BC_ENABLE_NLS)
|
CPPFLAGS6 = $(CPPFLAGS5) -DBC_ENABLE_NLS=$(BC_ENABLE_NLS)
|
||||||
CPPFLAGS7 = $(CPPFLAGS6) -D$(BC_ENABLE_EXTRA_MATH_NAME)=$(BC_ENABLE_EXTRA_MATH)
|
CPPFLAGS7 = $(CPPFLAGS6) -D$(BC_ENABLE_EXTRA_MATH_NAME)=$(BC_ENABLE_EXTRA_MATH)
|
||||||
|
|
|
@ -1,5 +1,17 @@
|
||||||
# News
|
# News
|
||||||
|
|
||||||
|
## 6.6.0
|
||||||
|
|
||||||
|
This is a production release with two bug fixes and one change.
|
||||||
|
|
||||||
|
The first bug fix is to fix the build on Mac OSX.
|
||||||
|
|
||||||
|
The second bug was to remove printing a leading zero in scientific or
|
||||||
|
engineering output modes.
|
||||||
|
|
||||||
|
The change was that the implementation of `irand()` was improved to call the
|
||||||
|
PRNG less.
|
||||||
|
|
||||||
## 6.5.0
|
## 6.5.0
|
||||||
|
|
||||||
This is a production release that fixes an infinite loop bug in `root()` and
|
This is a production release that fixes an infinite loop bug in `root()` and
|
||||||
|
|
|
@ -422,13 +422,23 @@ Other projects based on this bc are:
|
||||||
|
|
||||||
* [busybox `bc`][8]. The busybox maintainers have made their own changes, so any
|
* [busybox `bc`][8]. The busybox maintainers have made their own changes, so any
|
||||||
bugs in the busybox `bc` should be reported to them.
|
bugs in the busybox `bc` should be reported to them.
|
||||||
|
|
||||||
* [toybox `bc`][9]. The maintainer has also made his own changes, so bugs in the
|
* [toybox `bc`][9]. The maintainer has also made his own changes, so bugs in the
|
||||||
toybox `bc` should be reported there.
|
toybox `bc` should be reported there.
|
||||||
|
|
||||||
* [FreeBSD `bc`][23]. While the `bc` in FreeBSD is kept up-to-date, it is better
|
* [FreeBSD `bc`][23]. While the `bc` in FreeBSD is kept up-to-date, it is better
|
||||||
to [report bugs there][24], as well as [submit patches][25], and the
|
to [report bugs there][24], as well as [submit patches][25], and the
|
||||||
maintainers of the package will contact me if necessary.
|
maintainers of the package will contact me if necessary.
|
||||||
|
* [Mac OSX `bc`][35]. Any bugs in that `bc` should be reported to me, but do
|
||||||
|
expect bugs because the version is old.
|
||||||
|
* [Android Open Source `bc`][32]. Any bugs in that `bc` can be reported here.
|
||||||
|
|
||||||
|
This is a non-comprehensive list of Linux distros that use this `bc` as the
|
||||||
|
system `bc`:
|
||||||
|
|
||||||
|
* [Gentoo][33]; it is a first-class alternative to GNU `bc`, but not exclusive.
|
||||||
|
* [Linux from Scratch][34].
|
||||||
|
|
||||||
|
Other Linux distros package it as a second-class alternative, usually as `bc-gh`
|
||||||
|
or `howard-bc`.
|
||||||
|
|
||||||
## Language
|
## Language
|
||||||
|
|
||||||
|
@ -500,3 +510,7 @@ Folders:
|
||||||
[29]: https://github.com/gavinhoward/bc
|
[29]: https://github.com/gavinhoward/bc
|
||||||
[30]: ./manuals/bc/A.1.md#extended-library
|
[30]: ./manuals/bc/A.1.md#extended-library
|
||||||
[31]: ./manuals/build.md#settings
|
[31]: ./manuals/build.md#settings
|
||||||
|
[32]: https://android.googlesource.com/platform/external/bc/
|
||||||
|
[33]: https://github.com/gentoo/gentoo/blob/master/app-alternatives/bc/bc-0.ebuild#L8
|
||||||
|
[34]: https://www.linuxfromscratch.org/lfs/view/stable/chapter08/bc.html
|
||||||
|
[35]: https://github.com/apple-oss-distributions/bc/tree/main/bc
|
||||||
|
|
|
@ -772,7 +772,7 @@ predefined_build() {
|
||||||
dc_default_digit_clamp=0;;
|
dc_default_digit_clamp=0;;
|
||||||
|
|
||||||
GDH)
|
GDH)
|
||||||
CFLAGS="-flto -Weverything -Wno-padded -Werror -pedantic -std=c11"
|
CFLAGS="-flto -Weverything -Wno-padded -Wno-unsafe-buffer-usage -Werror -pedantic -std=c11"
|
||||||
bc_only=0
|
bc_only=0
|
||||||
dc_only=0
|
dc_only=0
|
||||||
coverage=0
|
coverage=0
|
||||||
|
@ -806,7 +806,7 @@ predefined_build() {
|
||||||
dc_default_digit_clamp=1;;
|
dc_default_digit_clamp=1;;
|
||||||
|
|
||||||
DBG)
|
DBG)
|
||||||
CFLAGS="-Weverything -Wno-padded -Werror -pedantic -std=c11"
|
CFLAGS="-Weverything -Wno-padded -Wno-unsafe-buffer-usage -Werror -pedantic -std=c11"
|
||||||
bc_only=0
|
bc_only=0
|
||||||
dc_only=0
|
dc_only=0
|
||||||
coverage=0
|
coverage=0
|
||||||
|
@ -1653,12 +1653,12 @@ else
|
||||||
# We are also setting the CFLAGS and LDFLAGS here.
|
# We are also setting the CFLAGS and LDFLAGS here.
|
||||||
if [ "$editline" -ne 0 ]; then
|
if [ "$editline" -ne 0 ]; then
|
||||||
LDFLAGS="$LDFLAGS -ledit"
|
LDFLAGS="$LDFLAGS -ledit"
|
||||||
CFLAGS="$CFLAGS -DBC_ENABLE_EDITLINE=1 -DBC_ENABLE_READLINE=0"
|
CPPFLAGS="$CPPFLAGS -DBC_ENABLE_EDITLINE=1 -DBC_ENABLE_READLINE=0"
|
||||||
elif [ "$readline" -ne 0 ]; then
|
elif [ "$readline" -ne 0 ]; then
|
||||||
LDFLAGS="$LDFLAGS -lreadline"
|
LDFLAGS="$LDFLAGS -lreadline"
|
||||||
CFLAGS="$CFLAGS -DBC_ENABLE_EDITLINE=0 -DBC_ENABLE_READLINE=1"
|
CPPFLAGS="$CPPFLAGS -DBC_ENABLE_EDITLINE=0 -DBC_ENABLE_READLINE=1"
|
||||||
else
|
else
|
||||||
CFLAGS="$CFLAGS -DBC_ENABLE_EDITLINE=0 -DBC_ENABLE_READLINE=0"
|
CPPFLAGS="$CPPFLAGS -DBC_ENABLE_EDITLINE=0 -DBC_ENABLE_READLINE=0"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -1682,6 +1682,24 @@ else
|
||||||
CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700"
|
CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Test Mac OSX. This is not in an if statement because regardless of whatever
|
||||||
|
# the user says, we need to know if we are on Mac OSX. If we are, we have to set
|
||||||
|
# _DARWIN_C_SOURCE.
|
||||||
|
printf 'Testing for Mac OSX...\n'
|
||||||
|
|
||||||
|
flags="-DBC_TEST_APPLE -DBC_ENABLE_AFL=0"
|
||||||
|
"$CC" $CPPFLAGS $CFLAGS $flags "-I$scriptdir/include" -E "$scriptdir/src/vm.c" > /dev/null 2>&1
|
||||||
|
|
||||||
|
err="$?"
|
||||||
|
|
||||||
|
if [ "$err" -ne 0 ]; then
|
||||||
|
printf 'On Mac OSX. Using _DARWIN_C_SOURCE.\n\n'
|
||||||
|
apple="-D_DARWIN_C_SOURCE"
|
||||||
|
else
|
||||||
|
printf 'Not on Mac OSX.\n\n'
|
||||||
|
apple=""
|
||||||
|
fi
|
||||||
|
|
||||||
# Test OpenBSD. This is not in an if statement because regardless of whatever
|
# Test OpenBSD. This is not in an if statement because regardless of whatever
|
||||||
# the user says, we need to know if we are on OpenBSD to activate _BSD_SOURCE.
|
# the user says, we need to know if we are on OpenBSD to activate _BSD_SOURCE.
|
||||||
# No, I cannot `#define _BSD_SOURCE` in a header because OpenBSD's patched GCC
|
# No, I cannot `#define _BSD_SOURCE` in a header because OpenBSD's patched GCC
|
||||||
|
@ -1690,7 +1708,6 @@ fi
|
||||||
# we have to set it because we also set _POSIX_C_SOURCE, which OpenBSD headers
|
# we have to set it because we also set _POSIX_C_SOURCE, which OpenBSD headers
|
||||||
# detect, and when they detect it, they turn off _BSD_SOURCE unless it is
|
# detect, and when they detect it, they turn off _BSD_SOURCE unless it is
|
||||||
# specifically requested.
|
# specifically requested.
|
||||||
set +e
|
|
||||||
printf 'Testing for OpenBSD...\n'
|
printf 'Testing for OpenBSD...\n'
|
||||||
|
|
||||||
flags="-DBC_TEST_OPENBSD -DBC_ENABLE_AFL=0"
|
flags="-DBC_TEST_OPENBSD -DBC_ENABLE_AFL=0"
|
||||||
|
@ -1713,6 +1730,8 @@ else
|
||||||
bsd=""
|
bsd=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
if [ "$library" -eq 1 ]; then
|
if [ "$library" -eq 1 ]; then
|
||||||
bc_lib=""
|
bc_lib=""
|
||||||
fi
|
fi
|
||||||
|
@ -2072,6 +2091,7 @@ contents=$(replace "$contents" "CLEAN_PREREQS" "$CLEAN_PREREQS")
|
||||||
contents=$(replace "$contents" "GEN_EMU" "$GEN_EMU")
|
contents=$(replace "$contents" "GEN_EMU" "$GEN_EMU")
|
||||||
|
|
||||||
contents=$(replace "$contents" "BSD" "$bsd")
|
contents=$(replace "$contents" "BSD" "$bsd")
|
||||||
|
contents=$(replace "$contents" "APPLE" "$apple")
|
||||||
|
|
||||||
contents=$(replace "$contents" "BC_DEFAULT_BANNER" "$bc_default_banner")
|
contents=$(replace "$contents" "BC_DEFAULT_BANNER" "$bc_default_banner")
|
||||||
contents=$(replace "$contents" "BC_DEFAULT_SIGINT_RESET" "$bc_default_sigint_reset")
|
contents=$(replace "$contents" "BC_DEFAULT_SIGINT_RESET" "$bc_default_sigint_reset")
|
||||||
|
|
|
@ -71,6 +71,10 @@ typedef BclBigDig BcBigDig;
|
||||||
/// An alias for portability.
|
/// An alias for portability.
|
||||||
#define BC_NUM_BIGDIG_C UINT64_C
|
#define BC_NUM_BIGDIG_C UINT64_C
|
||||||
|
|
||||||
|
/// The max number + 1 that two limbs can hold. This is used for generating
|
||||||
|
/// numbers because the PRNG can generate a number that will fill two limbs.
|
||||||
|
#define BC_BASE_RAND_POW (BC_NUM_BIGDIG_C(1000000000000000000))
|
||||||
|
|
||||||
/// The actual limb type.
|
/// The actual limb type.
|
||||||
typedef int_least32_t BcDig;
|
typedef int_least32_t BcDig;
|
||||||
|
|
||||||
|
@ -88,6 +92,10 @@ typedef int_least32_t BcDig;
|
||||||
/// An alias for portability.
|
/// An alias for portability.
|
||||||
#define BC_NUM_BIGDIG_C UINT32_C
|
#define BC_NUM_BIGDIG_C UINT32_C
|
||||||
|
|
||||||
|
/// The max number + 1 that two limbs can hold. This is used for generating
|
||||||
|
/// numbers because the PRNG can generate a number that will fill two limbs.
|
||||||
|
#define BC_BASE_RAND_POW (UINT64_C(100000000))
|
||||||
|
|
||||||
/// The actual limb type.
|
/// The actual limb type.
|
||||||
typedef int_least16_t BcDig;
|
typedef int_least16_t BcDig;
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,13 @@
|
||||||
#endif // __FreeBSD__
|
#endif // __FreeBSD__
|
||||||
#endif // BC_TEST_FREEBSD
|
#endif // BC_TEST_FREEBSD
|
||||||
|
|
||||||
|
// This is used by configure.sh to test for Mac OSX.
|
||||||
|
#ifdef BC_TEST_APPLE
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#error On Mac OSX without _DARWIN_C_SOURCE
|
||||||
|
#endif // __APPLE__
|
||||||
|
#endif // BC_TEST_APPLE
|
||||||
|
|
||||||
// Windows has deprecated isatty() and the rest of these. Or doesn't have them.
|
// Windows has deprecated isatty() and the rest of these. Or doesn't have them.
|
||||||
// So these are just fixes for Windows.
|
// So these are just fixes for Windows.
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
|
@ -37,6 +37,6 @@
|
||||||
#define BC_VERSION_H
|
#define BC_VERSION_H
|
||||||
|
|
||||||
/// The current version.
|
/// The current version.
|
||||||
#define VERSION 6.5.0
|
#define VERSION 6.6.0
|
||||||
|
|
||||||
#endif // BC_VERSION_H
|
#endif // BC_VERSION_H
|
||||||
|
|
|
@ -3515,8 +3515,9 @@ bc_num_print(BcNum* restrict n, BcBigDig base, bool newline)
|
||||||
// Print the sign.
|
// Print the sign.
|
||||||
if (BC_NUM_NEG(n)) bc_num_putchar('-', true);
|
if (BC_NUM_NEG(n)) bc_num_putchar('-', true);
|
||||||
|
|
||||||
// Print the leading zero if necessary.
|
// Print the leading zero if necessary. We don't print when using
|
||||||
if (BC_Z && BC_NUM_RDX_VAL(n) == n->len)
|
// scientific or engineering modes.
|
||||||
|
if (BC_Z && BC_NUM_RDX_VAL(n) == n->len && base != 0 && base != 1)
|
||||||
{
|
{
|
||||||
bc_num_printHex(0, 1, false, !newline);
|
bc_num_printHex(0, 1, false, !newline);
|
||||||
}
|
}
|
||||||
|
@ -3815,7 +3816,7 @@ void
|
||||||
bc_num_irand(BcNum* restrict a, BcNum* restrict b, BcRNG* restrict rng)
|
bc_num_irand(BcNum* restrict a, BcNum* restrict b, BcRNG* restrict rng)
|
||||||
{
|
{
|
||||||
BcNum atemp;
|
BcNum atemp;
|
||||||
size_t i, len;
|
size_t i;
|
||||||
|
|
||||||
assert(a != b);
|
assert(a != b);
|
||||||
|
|
||||||
|
@ -3835,24 +3836,76 @@ bc_num_irand(BcNum* restrict a, BcNum* restrict b, BcRNG* restrict rng)
|
||||||
assert(atemp.num != NULL);
|
assert(atemp.num != NULL);
|
||||||
assert(atemp.len);
|
assert(atemp.len);
|
||||||
|
|
||||||
len = atemp.len - 1;
|
if (atemp.len > 2)
|
||||||
|
|
||||||
// Just generate a random number for each limb.
|
|
||||||
for (i = 0; i < len; ++i)
|
|
||||||
{
|
{
|
||||||
b->num[i] = (BcDig) bc_rand_bounded(rng, BC_BASE_POW);
|
size_t len;
|
||||||
|
|
||||||
|
len = atemp.len - 2;
|
||||||
|
|
||||||
|
// Just generate a random number for each limb.
|
||||||
|
for (i = 0; i < len; i += 2)
|
||||||
|
{
|
||||||
|
BcRand dig;
|
||||||
|
|
||||||
|
dig = bc_rand_bounded(rng, BC_BASE_RAND_POW);
|
||||||
|
|
||||||
|
b->num[i] = (BcDig) (dig % BC_BASE_POW);
|
||||||
|
b->num[i + 1] = (BcDig) (dig / BC_BASE_POW);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// We need this set.
|
||||||
|
i = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do the last digit explicitly because the bound must be right. But only
|
// This will be true if there's one full limb after the two limb groups.
|
||||||
// do it if the limb does not equal 1. If it does, we have already hit the
|
if (i == atemp.len - 2)
|
||||||
// limit.
|
|
||||||
if (atemp.num[i] != 1)
|
|
||||||
{
|
{
|
||||||
b->num[i] = (BcDig) bc_rand_bounded(rng, (BcRand) atemp.num[i]);
|
// Increment this for easy use.
|
||||||
b->len = atemp.len;
|
i += 1;
|
||||||
|
|
||||||
|
// If the last digit is not one, we need to set a bound for it
|
||||||
|
// explicitly. Since there's still an empty limb, we need to fill that.
|
||||||
|
if (atemp.num[i] != 1)
|
||||||
|
{
|
||||||
|
BcRand dig;
|
||||||
|
BcRand bound;
|
||||||
|
|
||||||
|
// Set the bound to the bound of the last limb times the amount
|
||||||
|
// needed to fill the second-to-last limb as well.
|
||||||
|
bound = ((BcRand) atemp.num[i]) * BC_BASE_POW;
|
||||||
|
|
||||||
|
dig = bc_rand_bounded(rng, bound);
|
||||||
|
|
||||||
|
// Fill the last two.
|
||||||
|
b->num[i - 1] = (BcDig) (dig % BC_BASE_POW);
|
||||||
|
b->num[i] = (BcDig) (dig / BC_BASE_POW);
|
||||||
|
|
||||||
|
// Ensure that the length will be correct. If the last limb is zero,
|
||||||
|
// then the length needs to be one less than the bound.
|
||||||
|
b->len = atemp.len - (b->num[i] == 0);
|
||||||
|
}
|
||||||
|
// Here the last limb *is* one, which means the last limb does *not*
|
||||||
|
// need to be filled. Also, the length needs to be one less because the
|
||||||
|
// last limb is 0.
|
||||||
|
else
|
||||||
|
{
|
||||||
|
b->num[i - 1] = (BcDig) bc_rand_bounded(rng, BC_BASE_POW);
|
||||||
|
b->len = atemp.len - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Here, there is only one limb to fill.
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// See above for how this works.
|
||||||
|
if (atemp.num[i] != 1)
|
||||||
|
{
|
||||||
|
b->num[i] = (BcDig) bc_rand_bounded(rng, (BcRand) atemp.num[i]);
|
||||||
|
b->len = atemp.len - (b->num[i] == 0);
|
||||||
|
}
|
||||||
|
else b->len = atemp.len - 1;
|
||||||
}
|
}
|
||||||
// We want 1 less len in the case where we skip the last limb.
|
|
||||||
else b->len = len;
|
|
||||||
|
|
||||||
bc_num_clean(b);
|
bc_num_clean(b);
|
||||||
|
|
||||||
|
|
|
@ -2703,12 +2703,21 @@ bc_program_globalSetting(BcProgram* p, uchar inst)
|
||||||
assert(inst >= BC_INST_LINE_LENGTH && inst <= BC_INST_LEADING_ZERO);
|
assert(inst >= BC_INST_LINE_LENGTH && inst <= BC_INST_LEADING_ZERO);
|
||||||
#endif // DC_ENABLED
|
#endif // DC_ENABLED
|
||||||
|
|
||||||
if (inst == BC_INST_LINE_LENGTH) val = (BcBigDig) vm->line_len;
|
if (inst == BC_INST_LINE_LENGTH)
|
||||||
|
{
|
||||||
|
val = (BcBigDig) vm->line_len;
|
||||||
|
}
|
||||||
#if BC_ENABLED
|
#if BC_ENABLED
|
||||||
else if (inst == BC_INST_GLOBAL_STACKS) val = (BC_G != 0);
|
else if (inst == BC_INST_GLOBAL_STACKS)
|
||||||
|
{
|
||||||
|
val = (BC_G != 0);
|
||||||
|
}
|
||||||
#endif // BC_ENABLED
|
#endif // BC_ENABLED
|
||||||
#if DC_ENABLED
|
#if DC_ENABLED
|
||||||
else if (inst == BC_INST_EXTENDED_REGISTERS) val = (DC_X != 0);
|
else if (inst == BC_INST_EXTENDED_REGISTERS)
|
||||||
|
{
|
||||||
|
val = (DC_X != 0);
|
||||||
|
}
|
||||||
#endif // DC_ENABLED
|
#endif // DC_ENABLED
|
||||||
else val = (BC_Z != 0);
|
else val = (BC_Z != 0);
|
||||||
|
|
||||||
|
|
|
@ -517,8 +517,11 @@ bc_rand_int(BcRNG* r)
|
||||||
BcRand
|
BcRand
|
||||||
bc_rand_bounded(BcRNG* r, BcRand bound)
|
bc_rand_bounded(BcRNG* r, BcRand bound)
|
||||||
{
|
{
|
||||||
|
BcRand rand;
|
||||||
|
BcRand threshold;
|
||||||
|
|
||||||
// Calculate the threshold below which we have to try again.
|
// Calculate the threshold below which we have to try again.
|
||||||
BcRand rand, threshold = (0 - bound) % bound;
|
threshold = (0 - bound) % bound;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,6 +47,7 @@ misc7
|
||||||
misc8
|
misc8
|
||||||
void
|
void
|
||||||
rand
|
rand
|
||||||
|
rand_limits
|
||||||
recursive_arrays
|
recursive_arrays
|
||||||
divmod
|
divmod
|
||||||
modexp
|
modexp
|
||||||
|
|
284
contrib/bc/tests/bc/rand_limits.txt
Normal file
284
contrib/bc/tests/bc/rand_limits.txt
Normal file
|
@ -0,0 +1,284 @@
|
||||||
|
seed = 12183415694832323910165063565742029266.78201143488173352403523006\
|
||||||
|
17939450703787369504276248076613097826033345478457018711188931947\
|
||||||
|
5643844725709641352295875549316406250
|
||||||
|
|
||||||
|
if (maxrand() >= 2^64 - 1) {
|
||||||
|
|
||||||
|
for (i = 1; i <= 37; ++i)
|
||||||
|
{
|
||||||
|
irand(10^i)
|
||||||
|
}
|
||||||
|
|
||||||
|
1
|
||||||
|
77
|
||||||
|
914
|
||||||
|
8200
|
||||||
|
44887
|
||||||
|
866441
|
||||||
|
2358358
|
||||||
|
13559535
|
||||||
|
416767986
|
||||||
|
9276295152
|
||||||
|
89383616490
|
||||||
|
954770306600
|
||||||
|
8117340260822
|
||||||
|
90441255304792
|
||||||
|
123091484400148
|
||||||
|
673234816385761
|
||||||
|
33144762500773628
|
||||||
|
741775860680476044
|
||||||
|
4715856253932519349
|
||||||
|
44722685516799788803
|
||||||
|
691627564627043533689
|
||||||
|
3601367765145373281202
|
||||||
|
27535154823004408648947
|
||||||
|
51478009115008961612866
|
||||||
|
4031778740698066425486191
|
||||||
|
95653217339584215257144674
|
||||||
|
426302455455598639876532628
|
||||||
|
1216686741117783240797844143
|
||||||
|
17705719185928989853748208134
|
||||||
|
784851648926334033332776172502
|
||||||
|
3120413811981279690501349408357
|
||||||
|
38214388551463331616358091659583
|
||||||
|
720453131307667144268209805308554
|
||||||
|
8939221360785849706894139937864130
|
||||||
|
10262211588802126422696984407808741
|
||||||
|
267283013443362846268603285132432016
|
||||||
|
2034014520976339794036584994364919660
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
5
|
||||||
|
15
|
||||||
|
701
|
||||||
|
8215
|
||||||
|
98794
|
||||||
|
602366
|
||||||
|
2027255
|
||||||
|
74687524
|
||||||
|
830825144
|
||||||
|
6081336208
|
||||||
|
24314055735
|
||||||
|
838559932276
|
||||||
|
6866719060925
|
||||||
|
36806875401211
|
||||||
|
406827598340727
|
||||||
|
5356006452532004
|
||||||
|
38220052834497507
|
||||||
|
337361587138720056
|
||||||
|
1181974760686154481
|
||||||
|
16008532535003488966
|
||||||
|
951908092544652236970
|
||||||
|
90730737551380302703
|
||||||
|
46492092840194767743061
|
||||||
|
188697840939074129889664
|
||||||
|
3963332393372745718515074
|
||||||
|
78044317381361304314479194
|
||||||
|
257814131633376797403093774
|
||||||
|
5383100889234097635148206308
|
||||||
|
39812361752905775691804497289
|
||||||
|
222434065196674291290714932718
|
||||||
|
4942298796724199168854529657788
|
||||||
|
30804146383811856719866376789543
|
||||||
|
817977187096950760817419359822004
|
||||||
|
922359768927341898905002631901715
|
||||||
|
84002847212517205019842390182209654
|
||||||
|
423700247670879534125867432896848815
|
||||||
|
982360002329187383971171836321012954
|
||||||
|
|
||||||
|
for (i = 1; i <= 37; ++i)
|
||||||
|
{
|
||||||
|
irand(10^i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
seed = 12183415694832323910165063565742029266.82951754507405817776622978\
|
||||||
|
09630984098584076072986006731059784797092101840727292180396879039\
|
||||||
|
9608224106486886739730834960937500000
|
||||||
|
|
||||||
|
if (maxrand() >= 2^64 - 1) {
|
||||||
|
|
||||||
|
for (i = 1; i <= 37; ++i)
|
||||||
|
{
|
||||||
|
irand(10^i)
|
||||||
|
}
|
||||||
|
|
||||||
|
9
|
||||||
|
84
|
||||||
|
802
|
||||||
|
9765
|
||||||
|
80115
|
||||||
|
246589
|
||||||
|
4463508
|
||||||
|
85992729
|
||||||
|
977135
|
||||||
|
4189279533
|
||||||
|
68755431294
|
||||||
|
107950335674
|
||||||
|
9675253977558
|
||||||
|
87867459318681
|
||||||
|
801765066192715
|
||||||
|
2162649050595056
|
||||||
|
2892195376814570
|
||||||
|
134060417012729962
|
||||||
|
7176764836888537721
|
||||||
|
5273685153052366176
|
||||||
|
461774434438273613889
|
||||||
|
152344588818260411506
|
||||||
|
11709967193759556155964
|
||||||
|
533206453770793013516792
|
||||||
|
2511508581949736433569969
|
||||||
|
1573162243991468106989339
|
||||||
|
215826582488545888127004159
|
||||||
|
1480805837640270183994742134
|
||||||
|
61049958584446767740466194227
|
||||||
|
145231395106326027295263107581
|
||||||
|
7023255505921253691380349839502
|
||||||
|
48606431941187693512006850149822
|
||||||
|
87214859605659588002413450479944
|
||||||
|
7949773868584392220935704452065706
|
||||||
|
4544031206641768922348422844031232
|
||||||
|
37285268346623956247142903563298469
|
||||||
|
696722030777467416877847444483018982
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
9
|
||||||
|
73
|
||||||
|
468
|
||||||
|
1781
|
||||||
|
79556
|
||||||
|
166610
|
||||||
|
9336284
|
||||||
|
96403025
|
||||||
|
23318279
|
||||||
|
1074901232
|
||||||
|
30659049590
|
||||||
|
125915951725
|
||||||
|
3123436435684
|
||||||
|
52610031172756
|
||||||
|
445020218860038
|
||||||
|
87520306151384
|
||||||
|
47213087211849485
|
||||||
|
154045322058555704
|
||||||
|
9488624282418036451
|
||||||
|
12849313140308039019
|
||||||
|
828063328914872193931
|
||||||
|
2956454855398834052902
|
||||||
|
87417046449320418408586
|
||||||
|
165187095179884370295407
|
||||||
|
3602892678245454556711806
|
||||||
|
88079064510429999588220544
|
||||||
|
376741359503002189591164726
|
||||||
|
56633499559885161310029862
|
||||||
|
11172900796387700171428233596
|
||||||
|
473873806840427957175182603343
|
||||||
|
824290276873152640168308384248
|
||||||
|
36092351141101218267245025967581
|
||||||
|
39973475177812910298579659860850
|
||||||
|
7364670182480566996610562443888661
|
||||||
|
51592684301602944329896812066058114
|
||||||
|
951444349069518195584787848316744461
|
||||||
|
3234933598293500107173129970384252570
|
||||||
|
|
||||||
|
for (i = 1; i <= 37; ++i)
|
||||||
|
{
|
||||||
|
irand(10^i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
seed = 149423560533592712773538909996244073918.2952752612544959208642520\
|
||||||
|
06505634103779572918483064082477106507620297186161725006312917321\
|
||||||
|
53815843275879160501062870025634765625
|
||||||
|
|
||||||
|
if (maxrand() >= 2^64 - 1) {
|
||||||
|
|
||||||
|
for (i = 1; i <= 37; ++i)
|
||||||
|
{
|
||||||
|
irand(10^i)
|
||||||
|
}
|
||||||
|
|
||||||
|
0
|
||||||
|
94
|
||||||
|
825
|
||||||
|
907
|
||||||
|
62512
|
||||||
|
633399
|
||||||
|
3539412
|
||||||
|
65712557
|
||||||
|
329618801
|
||||||
|
9052319971
|
||||||
|
50117657456
|
||||||
|
719515050973
|
||||||
|
396081658001
|
||||||
|
98762199564287
|
||||||
|
537857673363391
|
||||||
|
5701380917944903
|
||||||
|
16144997029797264
|
||||||
|
918603142053856533
|
||||||
|
4437053492025674148
|
||||||
|
76125560050255946142
|
||||||
|
262504846798815931770
|
||||||
|
688599520356200914010
|
||||||
|
77509440962809216890090
|
||||||
|
889672321539369676198789
|
||||||
|
5795540531885308263478299
|
||||||
|
88374255397211092706329509
|
||||||
|
118231692173643319720953958
|
||||||
|
6218036129497143746927154520
|
||||||
|
3236727278542723274070894570
|
||||||
|
72098882691751515204435662053
|
||||||
|
8305331942254135876823981226459
|
||||||
|
33980292322856768815329277766669
|
||||||
|
154632353482145519952015208333866
|
||||||
|
192400848794451940507964192401413
|
||||||
|
69666401739718540927805290639731997
|
||||||
|
545814355378177567662640611917018958
|
||||||
|
4986776343571879972263664198494529846
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
6
|
||||||
|
47
|
||||||
|
709
|
||||||
|
350
|
||||||
|
45155
|
||||||
|
117711
|
||||||
|
6147313
|
||||||
|
26359748
|
||||||
|
56878412
|
||||||
|
930721373
|
||||||
|
47052494689
|
||||||
|
84216331603
|
||||||
|
1874946867051
|
||||||
|
30417072907659
|
||||||
|
157776263741438
|
||||||
|
3325742508233965
|
||||||
|
39500653878059614
|
||||||
|
278676289794009775
|
||||||
|
3342139004245631096
|
||||||
|
63313724143310202591
|
||||||
|
647891168358497623537
|
||||||
|
5925769871143510986759
|
||||||
|
3051401096746445704645
|
||||||
|
761857520743586046415633
|
||||||
|
9077595326394996332524977
|
||||||
|
2159936754163773508122732
|
||||||
|
426809670586105698135317225
|
||||||
|
3294516277260755029991322796
|
||||||
|
14749983115477586453985047494
|
||||||
|
692100641365100970093726483540
|
||||||
|
9502478720578852594268790479747
|
||||||
|
9062487417784678956874793130476
|
||||||
|
352159971921852073191742323073689
|
||||||
|
2270803770328639487517517910897872
|
||||||
|
35166631277333300065883628523569361
|
||||||
|
596441689792333324819903835359197616
|
||||||
|
6933582360405829608479430394981956723
|
||||||
|
|
||||||
|
for (i = 1; i <= 37; ++i)
|
||||||
|
{
|
||||||
|
irand(10^i)
|
||||||
|
}
|
||||||
|
}
|
222
contrib/bc/tests/bc/rand_limits_results.txt
Normal file
222
contrib/bc/tests/bc/rand_limits_results.txt
Normal file
|
@ -0,0 +1,222 @@
|
||||||
|
5
|
||||||
|
15
|
||||||
|
701
|
||||||
|
8215
|
||||||
|
98794
|
||||||
|
602366
|
||||||
|
2027255
|
||||||
|
74687524
|
||||||
|
830825144
|
||||||
|
6081336208
|
||||||
|
24314055735
|
||||||
|
838559932276
|
||||||
|
6866719060925
|
||||||
|
36806875401211
|
||||||
|
406827598340727
|
||||||
|
5356006452532004
|
||||||
|
38220052834497507
|
||||||
|
337361587138720056
|
||||||
|
1181974760686154481
|
||||||
|
16008532535003488966
|
||||||
|
951908092544652236970
|
||||||
|
90730737551380302703
|
||||||
|
46492092840194767743061
|
||||||
|
188697840939074129889664
|
||||||
|
3963332393372745718515074
|
||||||
|
78044317381361304314479194
|
||||||
|
257814131633376797403093774
|
||||||
|
5383100889234097635148206308
|
||||||
|
39812361752905775691804497289
|
||||||
|
222434065196674291290714932718
|
||||||
|
4942298796724199168854529657788
|
||||||
|
30804146383811856719866376789543
|
||||||
|
817977187096950760817419359822004
|
||||||
|
922359768927341898905002631901715
|
||||||
|
84002847212517205019842390182209654
|
||||||
|
423700247670879534125867432896848815
|
||||||
|
982360002329187383971171836321012954
|
||||||
|
1
|
||||||
|
77
|
||||||
|
914
|
||||||
|
8200
|
||||||
|
44887
|
||||||
|
866441
|
||||||
|
2358358
|
||||||
|
13559535
|
||||||
|
416767986
|
||||||
|
9276295152
|
||||||
|
89383616490
|
||||||
|
954770306600
|
||||||
|
8117340260822
|
||||||
|
90441255304792
|
||||||
|
123091484400148
|
||||||
|
673234816385761
|
||||||
|
33144762500773628
|
||||||
|
741775860680476044
|
||||||
|
4715856253932519349
|
||||||
|
44722685516799788803
|
||||||
|
691627564627043533689
|
||||||
|
3601367765145373281202
|
||||||
|
27535154823004408648947
|
||||||
|
51478009115008961612866
|
||||||
|
4031778740698066425486191
|
||||||
|
95653217339584215257144674
|
||||||
|
426302455455598639876532628
|
||||||
|
1216686741117783240797844143
|
||||||
|
17705719185928989853748208134
|
||||||
|
784851648926334033332776172502
|
||||||
|
3120413811981279690501349408357
|
||||||
|
38214388551463331616358091659583
|
||||||
|
720453131307667144268209805308554
|
||||||
|
8939221360785849706894139937864130
|
||||||
|
10262211588802126422696984407808741
|
||||||
|
267283013443362846268603285132432016
|
||||||
|
2034014520976339794036584994364919660
|
||||||
|
9
|
||||||
|
73
|
||||||
|
468
|
||||||
|
1781
|
||||||
|
79556
|
||||||
|
166610
|
||||||
|
9336284
|
||||||
|
96403025
|
||||||
|
23318279
|
||||||
|
1074901232
|
||||||
|
30659049590
|
||||||
|
125915951725
|
||||||
|
3123436435684
|
||||||
|
52610031172756
|
||||||
|
445020218860038
|
||||||
|
87520306151384
|
||||||
|
47213087211849485
|
||||||
|
154045322058555704
|
||||||
|
9488624282418036451
|
||||||
|
12849313140308039019
|
||||||
|
828063328914872193931
|
||||||
|
2956454855398834052902
|
||||||
|
87417046449320418408586
|
||||||
|
165187095179884370295407
|
||||||
|
3602892678245454556711806
|
||||||
|
88079064510429999588220544
|
||||||
|
376741359503002189591164726
|
||||||
|
56633499559885161310029862
|
||||||
|
11172900796387700171428233596
|
||||||
|
473873806840427957175182603343
|
||||||
|
824290276873152640168308384248
|
||||||
|
36092351141101218267245025967581
|
||||||
|
39973475177812910298579659860850
|
||||||
|
7364670182480566996610562443888661
|
||||||
|
51592684301602944329896812066058114
|
||||||
|
951444349069518195584787848316744461
|
||||||
|
3234933598293500107173129970384252570
|
||||||
|
9
|
||||||
|
84
|
||||||
|
802
|
||||||
|
9765
|
||||||
|
80115
|
||||||
|
246589
|
||||||
|
4463508
|
||||||
|
85992729
|
||||||
|
977135
|
||||||
|
4189279533
|
||||||
|
68755431294
|
||||||
|
107950335674
|
||||||
|
9675253977558
|
||||||
|
87867459318681
|
||||||
|
801765066192715
|
||||||
|
2162649050595056
|
||||||
|
2892195376814570
|
||||||
|
134060417012729962
|
||||||
|
7176764836888537721
|
||||||
|
5273685153052366176
|
||||||
|
461774434438273613889
|
||||||
|
152344588818260411506
|
||||||
|
11709967193759556155964
|
||||||
|
533206453770793013516792
|
||||||
|
2511508581949736433569969
|
||||||
|
1573162243991468106989339
|
||||||
|
215826582488545888127004159
|
||||||
|
1480805837640270183994742134
|
||||||
|
61049958584446767740466194227
|
||||||
|
145231395106326027295263107581
|
||||||
|
7023255505921253691380349839502
|
||||||
|
48606431941187693512006850149822
|
||||||
|
87214859605659588002413450479944
|
||||||
|
7949773868584392220935704452065706
|
||||||
|
4544031206641768922348422844031232
|
||||||
|
37285268346623956247142903563298469
|
||||||
|
696722030777467416877847444483018982
|
||||||
|
6
|
||||||
|
47
|
||||||
|
709
|
||||||
|
350
|
||||||
|
45155
|
||||||
|
117711
|
||||||
|
6147313
|
||||||
|
26359748
|
||||||
|
56878412
|
||||||
|
930721373
|
||||||
|
47052494689
|
||||||
|
84216331603
|
||||||
|
1874946867051
|
||||||
|
30417072907659
|
||||||
|
157776263741438
|
||||||
|
3325742508233965
|
||||||
|
39500653878059614
|
||||||
|
278676289794009775
|
||||||
|
3342139004245631096
|
||||||
|
63313724143310202591
|
||||||
|
647891168358497623537
|
||||||
|
5925769871143510986759
|
||||||
|
3051401096746445704645
|
||||||
|
761857520743586046415633
|
||||||
|
9077595326394996332524977
|
||||||
|
2159936754163773508122732
|
||||||
|
426809670586105698135317225
|
||||||
|
3294516277260755029991322796
|
||||||
|
14749983115477586453985047494
|
||||||
|
692100641365100970093726483540
|
||||||
|
9502478720578852594268790479747
|
||||||
|
9062487417784678956874793130476
|
||||||
|
352159971921852073191742323073689
|
||||||
|
2270803770328639487517517910897872
|
||||||
|
35166631277333300065883628523569361
|
||||||
|
596441689792333324819903835359197616
|
||||||
|
6933582360405829608479430394981956723
|
||||||
|
0
|
||||||
|
94
|
||||||
|
825
|
||||||
|
907
|
||||||
|
62512
|
||||||
|
633399
|
||||||
|
3539412
|
||||||
|
65712557
|
||||||
|
329618801
|
||||||
|
9052319971
|
||||||
|
50117657456
|
||||||
|
719515050973
|
||||||
|
396081658001
|
||||||
|
98762199564287
|
||||||
|
537857673363391
|
||||||
|
5701380917944903
|
||||||
|
16144997029797264
|
||||||
|
918603142053856533
|
||||||
|
4437053492025674148
|
||||||
|
76125560050255946142
|
||||||
|
262504846798815931770
|
||||||
|
688599520356200914010
|
||||||
|
77509440962809216890090
|
||||||
|
889672321539369676198789
|
||||||
|
5795540531885308263478299
|
||||||
|
88374255397211092706329509
|
||||||
|
118231692173643319720953958
|
||||||
|
6218036129497143746927154520
|
||||||
|
3236727278542723274070894570
|
||||||
|
72098882691751515204435662053
|
||||||
|
8305331942254135876823981226459
|
||||||
|
33980292322856768815329277766669
|
||||||
|
154632353482145519952015208333866
|
||||||
|
192400848794451940507964192401413
|
||||||
|
69666401739718540927805290639731997
|
||||||
|
545814355378177567662640611917018958
|
||||||
|
4986776343571879972263664198494529846
|
|
@ -3,6 +3,7 @@ lib2
|
||||||
fib
|
fib
|
||||||
places
|
places
|
||||||
rand
|
rand
|
||||||
|
rand_limits
|
||||||
scientific
|
scientific
|
||||||
shift
|
shift
|
||||||
trunc
|
trunc
|
||||||
|
|
|
@ -190,11 +190,17 @@ else
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# This sed, and the script, are to remove an incompatibility with GNU bc,
|
|
||||||
# where GNU bc is wrong. See the development manual
|
|
||||||
# (manuals/development.md#script-tests) for more information.
|
|
||||||
printf 'Generating %s results...' "$f"
|
printf 'Generating %s results...' "$f"
|
||||||
printf '%s\n' "$halt" 2> /dev/null | "$d" "$s" | sed -n -f "$testdir/script.sed" > "$results"
|
|
||||||
|
# This particular test needs to be generated straight.
|
||||||
|
if [ "$d" = "dc" ] && [ "$f" = "stream.dc" ]; then
|
||||||
|
printf '%s\n' "$halt" 2> /dev/null | "$d" "$s" > "$results"
|
||||||
|
else
|
||||||
|
# This sed, and the script, are to remove an incompatibility with GNU
|
||||||
|
# bc, where GNU bc is wrong. See the development manual
|
||||||
|
# (manuals/development.md#script-tests) for more information.
|
||||||
|
printf '%s\n' "$halt" 2> /dev/null | "$d" "$s" | sed -n -f "$testdir/script.sed" > "$results"
|
||||||
|
fi
|
||||||
printf 'done\n'
|
printf 'done\n'
|
||||||
res="$results"
|
res="$results"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue