#define W_MASK(s) ((s)->w_size - 1)
/* Window mask: w_size is always a power of 2, so w_mask = w_size - 1 */
-#ifdef HAVE_BUILTIN_CTZ
-# define W_BITS(s) ((unsigned int)__builtin_ctz((s)->w_size))
-#else
-/* Fallback for w_size which is always a power of 2 between 256 and 32768 */
-static inline unsigned int compute_w_bits(unsigned int w_size) {
- /* Switch ordered by likelihood - most common first (MAX_WBITS=15 -> 32768) */
- switch (w_size) {
- case 32768: return 15; /* MAX_WBITS default */
- case 16384: return 14;
- case 8192: return 13;
- case 4096: return 12;
- case 2048: return 11;
- case 1024: return 10;
- case 512: return 9;
- case 256: return 8;
- }
- Assert(w_size >= 256 && w_size <= 32768, "invalid w_size");
- return 0;
-}
-# define W_BITS(s) compute_w_bits((s)->w_size)
-#endif
+#define W_BITS(s) zng_ctz32((s)->w_size)
/* Window bits: log2(w_size), computed from w_size since w_size is a power of 2 */
#define WIN_INIT STD_MAX_MATCH