static inline unsigned
flsw(machine_word_t v)
{
- STATIC_ASSERT(WORDSIZE == 4 || WORDSIZE == 8);
- if (WORDSIZE == 4)
+ STATIC_ASSERT(WORDBITS == 32 || WORDBITS == 64);
+ if (WORDBITS == 32)
return fls32(v);
else
return fls64(v);
static inline unsigned
ffsw(machine_word_t v)
{
- STATIC_ASSERT(WORDSIZE == 4 || WORDSIZE == 8);
- if (WORDSIZE == 4)
+ STATIC_ASSERT(WORDBITS == 32 || WORDBITS == 64);
+ if (WORDBITS == 32)
return ffs32(v);
else
return ffs64(v);
{
machine_word_t v;
- STATIC_ASSERT(WORDSIZE == 4 || WORDSIZE == 8);
+ STATIC_ASSERT(WORDBITS == 32 || WORDBITS == 64);
v = b;
v |= v << 8;
v |= v << 16;
- v |= v << ((WORDSIZE == 8) ? 32 : 0);
+ v |= v << ((WORDBITS == 64) ? 32 : 0);
return v;
}
* example, if a word is 8 bytes and the match is of length 5, then
* we'll simply copy 8 bytes. This is okay as long as we don't write
* beyond the end of the output buffer, hence the check for (winend -
- * end >= WORDSIZE - 1).
+ * end >= WORDBYTES - 1).
*/
- if (UNALIGNED_ACCESS_IS_FAST &&
- likely(winend - end >= WORDSIZE - 1))
- {
+ if (UNALIGNED_ACCESS_IS_FAST && likely(winend - end >= WORDBYTES - 1)) {
- if (offset >= WORDSIZE) {
+ if (offset >= WORDBYTES) {
/* The source and destination words don't overlap. */
/* To improve branch prediction, one iteration of this
* and we'll need to continue copying. */
copy_word_unaligned(src, dst);
- src += WORDSIZE;
- dst += WORDSIZE;
+ src += WORDBYTES;
+ dst += WORDBYTES;
if (dst < end) {
do {
copy_word_unaligned(src, dst);
- src += WORDSIZE;
- dst += WORDSIZE;
+ src += WORDBYTES;
+ dst += WORDBYTES;
} while (dst < end);
}
return;
machine_word_t v = repeat_byte(*(dst - 1));
do {
store_word_unaligned(v, dst);
- src += WORDSIZE;
- dst += WORDSIZE;
+ src += WORDBYTES;
+ dst += WORDBYTES;
} while (dst < end);
return;
}
/*
* We don't bother with special cases for other 'offset <
- * WORDSIZE', which are usually rarer than 'offset == 1'. Extra
- * checks will just slow things down. Actually, it's possible
- * to handle all the 'offset < WORDSIZE' cases using the same
- * code, but it still becomes more complicated doesn't seem any
- * faster overall; it definitely slows down the more common
- * 'offset == 1' case.
+ * WORDBYTES', which are usually rarer than 'offset == 1'.
+ * Extra checks will just slow things down. Actually, it's
+ * possible to handle all the 'offset < WORDBYTES' cases using
+ * the same code, but it still becomes more complicated doesn't
+ * seem any faster overall; it definitely slows down the more
+ * common 'offset == 1' case.
*/
}
lz_extend(const u8 * const strptr, const u8 * const matchptr,
u32 len, const u32 max_len)
{
- while (UNALIGNED_ACCESS_IS_FAST && len + WORDSIZE <= max_len) {
+ while (UNALIGNED_ACCESS_IS_FAST && len + WORDBYTES <= max_len) {
machine_word_t v = load_word_unaligned(matchptr + len) ^
load_word_unaligned(strptr + len);
if (v != 0) {
if (CPU_IS_LITTLE_ENDIAN)
len += ffsw(v) >> 3;
else
- len += (8 * WORDSIZE - 1 - flsw(v)) >> 3;
+ len += (WORDBITS - 1 - flsw(v)) >> 3;
return len;
}
- len += WORDSIZE;
+ len += WORDBYTES;
}
while (len < max_len && matchptr[len] == strptr[len])
*/
typedef size_t machine_word_t;
-#define WORDSIZE sizeof(machine_word_t)
+#define WORDBYTES sizeof(machine_word_t)
+#define WORDBITS (8 * WORDBYTES)
#endif /* _WIMLIB_TYPES_H */
unsigned decode_table_pos;
#ifdef USE_WORD_FILL
- const unsigned entries_per_word = WORDSIZE / sizeof(decode_table[0]);
+ const unsigned entries_per_word = WORDBYTES / sizeof(decode_table[0]);
#endif
#ifdef USE_SSE2_FILL
aliased_word_t *p;
unsigned n;
- STATIC_ASSERT(WORDSIZE == 4 || WORDSIZE == 8);
+ STATIC_ASSERT(WORDBITS == 32 || WORDBITS == 64);
v = MAKE_DIRECT_ENTRY(sorted_syms[sym_idx], codeword_len);
v |= v << 16;
- v |= v << (WORDSIZE == 8 ? 32 : 0);
+ v |= v << (WORDBITS == 64 ? 32 : 0);
p = (aliased_word_t *)decode_table_ptr;
n = stores_per_loop;
avail = BITBUF_NBITS - is->bitsleft;
if (UNALIGNED_ACCESS_IS_FAST && CPU_IS_LITTLE_ENDIAN &&
- WORDSIZE == 8 && likely(is->next - is->begin >= 8))
+ WORDBYTES == 8 && likely(is->next - is->begin >= 8))
{
is->next -= (avail & ~15) >> 3;
is->bitbuf |= load_u64_unaligned(is->next) << (avail & 15);
/* Can the specified number of bits always be added to 'bitbuf' after any
* pending 16-bit coding units have been flushed? */
-#define CAN_BUFFER(n) ((n) <= (8 * sizeof(machine_word_t)) - 15)
+#define CAN_BUFFER(n) ((n) <= WORDBITS - 15)
/*
* Initialize the output bitstream.
if (litrunlen) { /* Is the literal run nonempty? */
/* Verify optimization is enabled on 64-bit */
- STATIC_ASSERT(sizeof(machine_word_t) < 8 ||
+ STATIC_ASSERT(WORDBITS < 64 ||
CAN_BUFFER(4 * MAIN_CODEWORD_LIMIT));
if (CAN_BUFFER(4 * MAIN_CODEWORD_LIMIT)) {
14 + ALIGNED_CODEWORD_LIMIT)
/* Verify optimization is enabled on 64-bit */
- STATIC_ASSERT(sizeof(machine_word_t) < 8 || CAN_BUFFER(MAX_MATCH_BITS));
+ STATIC_ASSERT(WORDBITS < 64 || CAN_BUFFER(MAX_MATCH_BITS));
/* Output the main symbol for the match. */