-
-/* ===========================================================================
- * Reverse the first len bits of a code using bit manipulation
- */
-Z_INTERNAL uint16_t PREFIX(bi_reverse)(unsigned code, int len) {
- /* code: the value to invert */
- /* len: its bit length */
- Assert(len >= 1 && len <= 15, "code length must be 1-15");
-#define bitrev8(b) \
- (uint8_t)((((uint8_t)(b) * 0x80200802ULL) & 0x0884422110ULL) * 0x0101010101ULL >> 32)
- return (bitrev8(code >> 8) | (uint16_t)bitrev8(code) << 8) >> (16 - len);
-}