This is a followup to commit 011aec7e24.
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.
Fixes <https://bugs.gnu.org/32938>.
Reported by Josh Datko <jbd@cryptotronix.com>.
* libguile/validate.h (SCM_VALIDATE_LIST_COPYLEN)
(SCM_VALIDATE_NONEMPTYLIST_COPYLEN): Use '!=' instead of '>=' to
validate the result of 'scm_ilength' after it has been stored in
the user variable 'cvar'.
* test-suite/tests/bytevectors.test: Add tests. Use '#:use-module'
instead of ':use-module' in 'define-module' form.
* libguile/boolean.c (scm_nil_p): Improve docstring.
* doc/ref/api-languages.texi (Nil): Add documentation for 'nil?', along
with a description of how Elisp interprets Scheme booleans and
end-of-list.
Fixes <https://bugs.gnu.org/32786>.
'scm_atomic_compare_and_swap_scm' is a thin wrapper around
'atomic_compare_exchange_weak' (where available), and therefore it may
spuriously fail on some platforms, leaving the atomic object unchanged
even when the observed value is equal to the expected value. Since
'scm_atomic_compare_and_swap_scm' returns both a boolean result and the
observed value, the caller is able to detect spurious failures when
using that API.
'atomic-box-compare-and-swap!' presents a simpler API, returning only
the observed value. The documentation advises callers to assume that
the exchange succeeded if the observed value is 'eq?' to the expected
value. It's therefore not possible to report spurious failures with
this API.
'atomic-box-compare-and-swap!' uses 'scm_atomic_compare_and_swap_scm',
and prior to this commit would simply ignore the boolean result and
return the observed value. In case of spurious failures, the caller
would legitimately conclude that the exchange had succeeded.
With this commit, 'atomic-box-compare-and-swap!' now retries in case of
spurious failures.
* libguile/atomic.c (scm_atomic_box_compare_and_swap_x): If
'scm_atomic_compare_and_swap_scm' returns false and the observed value
is equal to 'expected', then try again.
* libguile/intrinsics.c (atomic_compare_and_swap_scm): Ditto.
* acinclude.m4 (GUILE_ENABLE_JIT): For MIPS, PPC, sparc, ia64, hppa,
s390, and alpha: mark JIT as unavailable. Only architectures left are
x86-64, i686, aarch64, and armv7. If JIT is available, enable it by
default; previously only x86-64 and i686 were supported.
* libguile/jit.c (jit_alloc_fn): On targets that need a dynamically
allocated literal pool, we will need to trace that pool, so pass a
pointerful malloc. Fixes JIT on AArch64.