rcx

library of miscellaneous bits of C code
git clone git://git.rr3.xyz/rcx
Log | Files | Refs | README | LICENSE

commit eaa709cff6d7a23ede478704e902dc723b220fa0
parent 68c907170c4d36d5cc9c789692ff0e7c025d435c
Author: Robert Russell <robertrussell.72001@gmail.com>
Date:   Sun, 24 Sep 2023 18:33:23 -0700

Rename r8search -> rzb

rzb = rightmost zero byte

Diffstat:
Minc/bits.h | 16++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/inc/bits.h b/inc/bits.h @@ -164,26 +164,26 @@ r_ctz64(u64 n) { /* See Warren, "Hacker's Delight", 2 ed., sec. 6.1. The basic idea is to map * the rightmost 0x00 byte to 0x80 and all bytes right of the rightmost 0x00 to - * 0x00, and then use ctz. When the argument n has no zero byte, r8search - * returns sizeof n. By first XORing with a suitable value, these functions can - * be used to find arbitrary bytes. Also, by replacing the masks within the - * definition, this method adapts to searching for arbitrary length sequences - * of 0 bits aligned in a particular way. */ + * 0x00, and then use ctz. When the argument n has no zero byte, rzb returns + * sizeof n. By first XORing with a suitable value, these functions can be used + * to find arbitrary bytes. Also, by replacing the masks within the definition, + * this method adapts to searching for arbitrary length sequences of 0 bits + * aligned in a particular way. */ static inline int -r_r8search16(u16 n) { +r_rzb16(u16 n) { n = (n - U16_C(0x0101)) & ~n & U16_C(0x8080); return r_ctz16(n) / 8u; } static inline int -r_r8search32(u32 n) { +r_rzb32(u32 n) { n = (n - U32_C(0x01010101)) & ~n & U32_C(0x80808080); return r_ctz32(n) / 8u; } static inline int -r_r8search64(u64 n) { +r_rzb64(u64 n) { n = (n - U64_C(0x0101010101010101)) & ~n & U64_C(0x8080808080808080); return r_ctz64(n) / 8u; }