Properly set bits in large bit arrays

Bit arrays were not properly manipulated by set-bits or clear-bits
if they were larger than 40 bits (one cell + one byte).

Moreover, the bug was likely to cause a bus error on architectures unable
to access unaligned words.
db4
Samuel Tardieu 2008-12-26 20:58:45 +01:00
parent f5dc0884d7
commit 66b410b81f
2 changed files with 3 additions and 1 deletions

View File

@ -76,3 +76,5 @@ IN: bit-arrays.tests
t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t
t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t
} bit-array>integer ] unit-test
[ 49 ] [ 49 <bit-array> dup set-bits [ ] count ] unit-test

View File

@ -25,7 +25,7 @@ TUPLE: bit-array
: (set-bits) ( bit-array n -- )
[ [ length bits>cells ] keep ] dip swap underlying>>
'[ [ _ _ ] dip set-alien-unsigned-4 ] each ; inline
'[ 2 shift [ _ _ ] dip set-alien-unsigned-4 ] each ; inline
PRIVATE>