| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This significantly speeds up loads that create lots of bignums, like
(language cps slot-allocation) for files with many top-level
definitions. Compiling such a file is typically 2.5 times faster.
See <https://lists.gnu.org/archive/html/guile-devel/2020-02/msg00023.html>.
* libguile/numbers.c (custom_gmp_malloc): Use
'scm_gc_malloc_pointerless' instead of 'scm_malloc'.
(custom_gmp_realloc): Use 'scm_gc_realloc'.
(custom_gmp_free): Remove call to 'free'.
(make_bignum): Use 'scm_gc_malloc' instead of 'scm_gc_malloc_pointerless'.
Call 'scm_i_set_finalizer' only when SCM_INSTALL_GMP_MEMORY_FUNCTIONS is
false.
|
|
|
|
|
|
|
| |
* libguile/numbers.c (scm_exact_integer_sqrt, scm_sqrt)
(exact_integer_is_perfect_square, exact_integer_floor_square_root):
Where it is trivial to do so, use GMP's low-level mpn functions to
avoid heap allocation.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fixes <https://bugs.gnu.org/21901>.
Reported by Zefram <zefram@fysh.org>.
* libguile/numbers.c: Add another top-level 'verify' to ensure that
LONG_MIN is not a fixnum.
(scm_ash, scm_round_ash): Ensure that when the shift count is LONG_MIN,
it is not handled via the normal code path, to avoid signed overflow
when the shift count is negated.
* test-suite/tests/numbers.test: Add tests.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is a followup to commit 011aec7e240ef987931548d90c53e6692c85d01c.
When rounding, right shifting a negative integer by a huge shift count
results in 0, not -1.
* libguile/numbers.c: Add top-level 'verify' to ensure that the
assumptions in 'scm_ash' and 'scm_round_ash' are valid.
(scm_round_ash): In the case that handles huge right shifts, require
that the shift count _exceeds_ the integer length, and return 0 instead
of -1.
* test-suite/tests/numbers.test: Adjust tests accordingly.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fixes <https://bugs.gnu.org/32644>.
Reported by Stefan Israelsson Tampe <stefan.itampe@gmail.com>.
The need for this arose because the type inferrer for 'ursh' sometimes
passes (- 1 (expt 2 64)) as the second argument to 'ash'.
* libguile/numbers.c (scm_ash, scm_round_ash): Gracefully handle several
cases where the shift count does not fit in a C 'long'.
* test-suite/tests/numbers.test: Add tests.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This assumption does not hold on systems that use the LLP64 data model.
Partially fixes <https://debbugs.gnu.org/22406>.
Reported by Peter TB Brett <peter@peter-b.co.uk>.
* libguile/numbers.h (scm_t_inum): Move here from numbers.c, and change
to be equivalent to 'long' (formerly 'scm_t_signed_bits').
(SCM_MOST_POSITIVE_FIXNUM, SCM_MOST_NEGATIVE_FIXNUM): Define based on
SCM_I_FIXNUM_BIT instead of SCM_T_SIGNED_BITS_MAX.
(SCM_I_INUM): Adjust definitions to return a 'scm_t_inum', and avoiding
the assumption that SCM_UNPACK returns a 'long'.
* libguile/numbers.c (scm_t_inum): Move definition to numbers.h.
Verify that 'scm_t_inum' fits within a SCM value.
(scm_i_inum2big): Remove preprocessor code that forced a compile error
unless sizeof (long) == sizeof (void *).
|
|
|
|
|
|
|
|
| |
Reported by Miroslav Lichvar <mlichvar@redhat.com>
in <https://lists.gnu.org/archive/html/guile-devel/2016-02/msg00045.html>
* libguile/conv-integer.i.c: Avoid signed overflow.
* libguile/numbers.c (scm_is_signed_integer): Avoid signed overflow.
|
|
|
|
|
|
|
| |
* libguile/numbers.c (scm_product): Only reduce (* x -1) to (- x) when X
is a bignum. Fixes weirdness when X is not a number and instead
multiplication should dispatch to GOOPS. Thanks to Alejandro Sanchez
for the report.
|
|
|
|
|
| |
* libguile/numbers.c (log_of_fraction): Use labs instead of abs on
longs. Thanks to Matt Wette for the tip.
|
|
|
|
|
|
| |
* configure.ac: Check for __sincos.
* libguile/numbers.c (scm_c_make_polar): Fall back to __sincos if
possible. Fixes zero signedness of make-polar on macOS.
|
|
|
|
|
| |
* libguile/numbers.c (scm_number_to_string): Use scm_from_latin1_string
where appropriate. Avoids mucking about with iconv.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* libguile/root.h:
* libguile/root.c: Remove these files.
* libguile/deprecated.h:
* libguile/deprecated.c (scm_internal_cwdr, scm_call_with_dynamic_root)
(scm_dynamic_root, scm_apply_with_dynamic_root): Deprecate.
Remove all root.h usage, which was vestigial.
* module/ice-9/serialize.scm: Use (current-thread) instead
of (dynamic-root).
|
|
|
|
|
|
|
|
| |
Fixes a regression introduced in commit
ad79736c68a803a59814fbfc0cb4b092c2b4cddf.
* libguile/numbers.c (scm_atan): Fix the complex case.
* test-suite/tests/numbers.test ("atan"): Add test.
|
|
|
|
|
|
|
|
|
|
| |
Although popular compilers allow it as long as the expression is of type
void, it violates C99 and some compilers choke on it.
* libguile/numbers.c (scm_euclidean_divide, scm_floor_divide)
(scm_ceiling_divide, scm_truncate_divide, scm_centered_divide)
(scm_round_divide): Don't use the return statement with an expression
from functions with return type void.
|
|
|
|
|
|
|
| |
* libguile/ports.h (scm_lfwrite_unlocked): Remove.
* libguile/ports.c (scm_lfwrite): Rename from scm_lfwrite_unlocked.
* libguile/numbers.c:
* libguile/print.c: Adapt to call scm_lfwrite.
|
|\
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Conflicts:
GUILE-VERSION
NEWS
guile-readline/ice-9/readline.scm
libguile/async.c
libguile/backtrace.c
libguile/deprecated.h
libguile/gc-malloc.c
libguile/gdbint.c
libguile/init.c
libguile/ioext.c
libguile/mallocs.c
libguile/print.c
libguile/rw.c
libguile/scmsigs.c
libguile/script.c
libguile/simpos.c
libguile/snarf.h
libguile/strports.c
libguile/threads.c
libguile/vm-i-scheme.c
libguile/vm-i-system.c
module/srfi/srfi-18.scm
test-suite/Makefile.am
test-suite/standalone/test-num2integral.c
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* libguile/numbers.c (scm_logbit_p): If the requested bit is the sign
bit (or above), check the sign portably. Otherwise, ensure that we're
testing the bit in a two's complement representation.
(left_shift_exact_integer): Avoid left-shifting negative integers.
* libguile/vm-i-scheme.c (ash): Avoid left-shifting negative integers.
|
|\|
| |
| |
| |
| |
| | |
Conflicts:
module/system/vm/traps.scm
test-suite/tests/peval.test
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* libguile/numbers.c (scm_exact_integer_p, scm_is_exact_integer):
New procedures.
(scm_integer_p): Improve docstring.
* libguile/numbers.h (scm_exact_integer_p, scm_is_exact_integer):
New prototypes.
* doc/ref/api-data.texi (Integers): Add docs.
* test-suite/tests/numbers.test ("exact-integer?"): Add tests.
|
|\| |
|
| |
| |
| |
| |
| |
| |
| |
| | |
* libguile/numbers.c (left_shift_exact_integer): Fix edge case where
N is -1 and count is SCM_I_FIXNUM_BIT-1 to return the most negative
fixnum. Previously this result was returned as a bignum.
* test-suite/tests/numbers.test (ash): Add tests.
|
| |
| |
| |
| | |
This reverts commit 8df68898b9f6ba15171244f1f3549688f13d605f.
|
|\|
| |
| |
| |
| |
| |
| | |
Conflicts:
libguile/deprecated.h
libguile/programs.c
libguile/programs.h
|
| |
| |
| |
| |
| |
| |
| | |
* libguile/numbers.c (scm_ash): Fix (ash -1 SCM_I_FIXNUM_BIT-1) to
return a fixnum instead of a bignum.
* test-suite/tests/numbers.test (ash): Add tests.
|
| |
| |
| |
| | |
* libguile/numbers.c (char_decimal_value): A wee micro-optimization.
|
|\| |
|
| |
| |
| |
| |
| |
| |
| | |
* libguile/numbers.c (mem2ureal, left_shift_exact_integer,
floor_right_shift_exact_integer, round_right_shift_exact_integer):
Use 'assert' instead of 'scm_syserror' to indicate a case that should
never happen.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* libguile/numbers.c (scm_numerator, scm_denominator): Handle signed
zeroes and infinities in accordance with the corresponding R6RS flonum
procedures.
* module/rnrs/arithmetic/flonums.scm (flnumerator, fldenominator):
Remove special handling of infinities.
* test-suite/tests/numbers.test (numerator, denominator): Add tests.
Convert existing tests to use 'pass-if-equal'.
* test-suite/tests/r6rs-arithmetic-flonums.test (flnumerator): Fix
broken test of (flnumerator -0.0).
|
| |
| |
| |
| |
| | |
* libguile/numbers.c (scm_gcd): Use 'scm_wta_dispatch_2' not
'SCM_WTA_DISPATCH_2'.
|
|\|
| |
| |
| |
| |
| | |
Conflicts:
libguile/numbers.c
libguile/vm-i-scheme.c
|
| |
| |
| |
| |
| |
| |
| | |
* libguile/numbers.c (DOUBLE_IS_FINITE, DOUBLE_IS_POSITIVE_INFINITY,
DOUBLE_IS_NEGATIVE_INFINITY): Remove.
(scm_odd_p, scm_even_p, scm_finite_p, icmplx2str, scm_rational_p,
scm_inexact_to_exact): Use 'isfinite' instead of 'DOUBLE_IS_FINITE'.
|
| |
| |
| |
| |
| |
| |
| | |
* libguile/numbers.c (double_is_non_negative_zero): Remove.
(idbl2str, scm_max, scm_min, scm_angle, log_of_shifted_double,
scm_log10): Use 'copysign' to check signs of zeroes,
instead of 'double_is_non_negative_zero'.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* libguile/numbers.c (scm_i_from_double): New static function.
(scm_from_double): Just call 'scm_i_from_double'.
(scm_inf, scm_nan, scm_abs, scm_i_inexact_floor_quotient,
scm_i_inexact_floor_remainder, scm_i_inexact_floor_divide,
scm_i_inexact_ceiling_quotient, scm_i_inexact_ceiling_remainder,
scm_i_inexact_ceiling_divide, scm_i_inexact_truncate_quotient,
scm_i_inexact_truncate_remainder, scm_i_inexact_truncate_divide,
scm_i_inexact_centered_quotient, scm_i_inexact_centered_remainder,
scm_i_inexact_centered_divide, scm_i_inexact_round_quotient,
scm_i_inexact_round_remainder, scm_i_inexact_round_divide,
scm_max, scm_min, scm_sum, scm_difference, scm_product,
scm_divide, scm_truncate_number, scm_round_number, scm_floor,
scm_ceiling, scm_expt, scm_sin, scm_cos, scm_tan, scm_sinh,
scm_cosh, scm_tanh, scm_asin, scm_acos, scm_atan, scm_sys_asinh,
scm_sys_acosh, scm_sys_atanh, scm_real_part, scm_imag_part,
scm_magnitude, scm_angle, scm_exact_to_inexact, log_of_shifted_double,
log_of_fraction, scm_log10, scm_exp, scm_sqrt, scm_init_numbers):
Use 'scm_i_from_double' instead of 'scm_from_double'.
|
| |
| |
| |
| | |
* libguile/numbers.c (scm_rationalize): Fix formatting.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Fixes <http://bugs.gnu.org/14905>.
Reported by Göran Weinholt <goran@weinholt.se>.
* libguile/numbers.c (scm_rationalize): Rewrite. Previously an
incorrect algorithm was used which failed in many cases.
* test-suite/tests/numbers.test (rationalize): Add tests.
|
|\|
| |
| |
| |
| | |
Conflicts:
libguile/numbers.c
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Fixes <http://bugs.gnu.org/14870>.
Reported by Göran Weinholt <goran@weinholt.se>.
* libguile/numbers.c (scm_gcd, scm_lcm): Support inexact integers.
* test-suite/tests/numbers.test (gcd, lcm): Add tests.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Fixes <http://bugs.gnu.org/14865>.
Reported by Göran Weinholt <goran@weinholt.se>.
* libguile/numbers.c (scm_min, scm_max): NaNs beat infinities, as per
the R6RS errata.
* test-suite/tests/numbers.test (min, max): Update tests.
|
|\|
| |
| |
| |
| |
| | |
Conflicts:
libguile/keywords.c
libguile/vm.c
|
| |
| |
| |
| |
| |
| | |
* libguile/numbers.c (scm_less_p): Avoid converting inums to doubles.
* test-suite/tests/numbers.test (<): Add tests.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* libguile/numbers.c (scm_num_eq_p): Fix bug comparing fractions to
infinities (reported by Göran Weinholt <goran@weinholt.se>). Fix
erroneous comment describing the logic behind inum/flonum comparison.
Use similar logic for inum/complex comparison to avoid rounding
errors. Make minor indentation fixes and simplifications.
* test-suite/tests/numbers.test (=): Add tests.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* libguile/numbers.c (INUM_LOSSLESSLY_CONVERTIBLE_TO_DOUBLE):
New macro.
(scm_i_divide2double): Use INUM_LOSSLESSLY_CONVERTIBLE_TO_DOUBLE to
determine if our fast path is safe. Previously, negative arguments
were not checked properly.
* test-suite/tests/numbers.test (exact->inexact): Add tests.
|
|\| |
|
| |
| |
| |
| |
| |
| |
| | |
* libguile/numbers.c (VARARG_MPZ_ITERATOR)[!HAVE_DECL_MPZ_INITS]: New
macro.
(mpz_inits, mpz_clears)[!HAVE_DECL_MPZ_INITS]: New functions.
* configure.ac: Check for the declaration of `mpz_inits'.
|
|\|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Conflicts:
configure.ac
libguile/deprecated.c
libguile/deprecated.h
libguile/filesys.h
libguile/fluids.c
libguile/fports.c
libguile/gc.c
libguile/guile.c
libguile/numbers.c
libguile/objcodes.c
libguile/r6rs-ports.c
libguile/smob.c
libguile/socket.c
libguile/threads.h
module/language/scheme/decompile-tree-il.scm
module/language/tree-il/peval.scm
test-suite/tests/syncase.test
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* libguile/numbers.c (exact_integer_is_perfect_square,
exact_integer_floor_square_root): New static functions.
(scm_sqrt): Use SCM_LIKELY. Add 'scm_t_inum' variable in inum case to
reduce the number of uses of SCM_I_INUM. Rename 'mpz_t' variable.
Remove unneeded sign check. Handle bignums too large to fit in a
double. Handle fractions too large or too small to fit in a
normalized double.
* test-suite/tests/numbers.test ("sqrt"): Add tests.
|
| |
| |
| |
| |
| | |
* libguile/numbers.c (scm_exact_integer_sqrt): Use GMP for inum
case. It is faster than what we had before.
|