* libguile/srfi-14.i.c: Update from Unicode 14.0.0.
* libguile/unidata_to_charset.pl (compute): Write arrays as static const
data, to avoid polluting the namespace and to avoid adding these to the
GC root set.
* libguile/srfi-14.c (SCM_CODEPOINT_F_IMMUTABLE): New flag.
(scm_charset_is_immutable): New internal predicate.
(SCM_VALIDATE_MUTABLE_CHARSET): New internal validator.
(cs_full_ranges, cs_full_ranges_len): Re-express as separate ranges and
len, because the ranges pointer in scm_t_char_set is mutable.
(scm_char_set_unfold_x, scm_list_to_char_set_x)
(scm_string_to_char_set_x, scm_char_set_filter_x)
(scm_i_ucs_range_to_char_set, scm_char_set_adjoin_x)
(scm_char_set_delete_x, scm_char_set_complement_x)
(scm_char_set_unfold_x, scm_char_set_intersection_x)
(scm_char_set_difference_x, scm_char_set_xor_x): Require mutable
charsets.
(define_charset): Add immutable flag.
(scm_init_srfi_14): Adapt initial charset definitions.
* libguile/numbers.c (log_of_shifted_double, scm_log10): Avoid complex
extension when the argument is a real nan.
* test-suite/tests/numbers.test: Tests for nans of either sign.
* libguile/numbers.c (scm_abs): As stated. When x is a nan with the sign bit
set, this changes the behavior of (magnitude x) back to what it was in 3.0.7,
to clear that bit.
* libguile/integers.c (scm_integer_abs_z): Just call
scm_integer_negate_z if negation is needed.
(scm_integer_sub_zz): Use mpz_sub instead of cloning bignum.
Calling out to Scheme was a performance regression.
* libguile/integers.h:
* libguile/integers.c (scm_integer_expt_ii, scm_integer_expt_zi): New
internal functions.
* libguile/numbers.c (scm_integer_expt): Go back to C. But, include
fast cases for inums and doubles.
* module/ice-9/boot-9.scm: Revert addition of integer-expt.
* libguile/deprecated.c (make_bignum): Move here from numbers.c, to
support scm_i_long2big etc.
(scm_i_big2dbl):
(scm_i_long2big):
(scm_i_ulong2big):
(scm_i_clonebig):
(scm_i_normbig): Deprecate.
(scm_install_gmp_memory_functions): Deprecate, happily! SCM bignums now
have digits allocated inline with the bignum itself, so they are
completely transparent to the GC already. The price is that if GMP ever
allocates digits via the MPZ API, those digits then have to be copied
back into managed memory. But we avoid having to install finalizers and
we avoid having to muck with GMP's allocator.
* libguile/numbers.c (scm_from_mpz): Use scm_integer_from_mpz.
(scm_init_numbers): Never muck with GMP's allocators.
* doc/ref/guile-invoke.texi (Environment Variables): Remove note about
GUILE_INSTALL_GMP_MEMORY_FUNCTIONS.
* meta/build-env.in: No need to set GUILE_INSTALL_GMP_MEMORY_FUNCTIONS.
* libguile/integers.c (scm_integer_to_double_z): Doubles that can't be
exactly represented as integers should round.
(bignum_frexp_z): New helper.
(scm_integer_from_mpz, scm_integer_from_double): New internal functions.
* libguile/numbers.h:
* libguile/numbers.c (scm_i_bigcmp, scm_i_dbl2big, scm_i_dbl2num):
Remove unused internal functions.
(scm_inexact_to_exact): Rework to avoid scm_i_dbl2big.
(scm_bigequal): Move here, from eq.c.
(scm_integer_to_double_z): Use the new helper.
(scm_i_big2dbl): Use scm_integer_to_double_z.
* libguile/numbers.c: We require IEEE infinities and NaN so there is no
case in which ALLOW_DIVIDE_BY_ZERO would not be defined.
(scm_divide, scm_tan, scm_tanh, scm_log, scm_log10): Always throw on
overflow for divide by exact zero, never throw for divide by inexact
zero.
* libguile/numbers.c (scm_product): Remove need for s_product defines.
Call out to product, as appropriate.
(product): New helper.
* libguile/integers.h:
* libguile/integers.c (scm_integer_mul_ii):
(scm_integer_mul_zi):
(scm_integer_mul_zz): New internal functions.
* libguile/numbers.c (scm_sum): Remove need for s_sum defines.
(negate, difference): New helpers.
(scm_difference): Call out to difference or negate, as appropriate.
* libguile/integers.h:
* libguile/integers.c (scm_integer_negate_i):
(scm_integer_negate_z):
(scm_integer_sub_ii):
(scm_integer_sub_iz):
(scm_integer_sub_zi):
(scm_integer_sub_zz): New internal functions.
* libguile/integers.h:
* libguile/integers.c (scm_integer_to_double_z):
(scm_integer_add_ii, scm_integer_add_zi, scm_integer_add_zz): New
internal functions.
* libguile/numbers.c (sum): New helper for scm_sum. Clean up to avoid
repetition. The dispatch is less optimal but the code is shorter and
more maintainable; in any case if speed is important, the compiler needs
to be involved.
(scm_sum): Adapt.