1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-09 13:30:26 +02:00

Convert bitvectors to use inline-only word-size units

* libguile/bitvectors.h: Unit of bitvectors is scm_t_bits, not uint32_t.
* libguile/bitvectors.c: Adapt implementation.
(make_bitvector): Malloc pointerless instead, with inline bits.
* libguile/posix.c (scm_setaffinity):
* libguile/bytevectors.c (uniform-array->bytevector): Adapt to unit size
change.
* module/system/vm/assembler.scm (intern-constant, link-data): Adapt to
bitvector representation change.
This commit is contained in:
Andy Wingo 2025-06-03 16:54:19 +02:00
parent 9ff7c0651c
commit d6e59a1d3e
5 changed files with 303 additions and 208 deletions

View file

@ -699,9 +699,15 @@ SCM_DEFINE (scm_uniform_array_to_bytevector, "uniform-array->bytevector",
if (sz >= 8 && ((sz % 8) == 0))
byte_len = len * (sz / 8);
else if (sz < 8)
/* Elements of sub-byte size (bitvectors) are addressed in 32-bit
units. */
byte_len = ((len * sz + 31) / 32) * 4;
{
if (sz != 1)
abort ();
size_t bits_per_word = sizeof (scm_t_bits) * 8;
/* Elements of sub-byte size (bitvectors) are addressed in word-sized
units. */
size_t word_len = (len + bits_per_word - 1) / bits_per_word;
byte_len = word_len * sizeof (scm_t_bits);
}
else
/* an internal guile error, really */
SCM_MISC_ERROR ("uniform elements larger than 8 bits must fill whole bytes", SCM_EOL);