Skip to content
Snippets Groups Projects
Commit db1ffc32 authored by Mark Cave-Ayland's avatar Mark Cave-Ayland Committed by Philippe Mathieu-Daudé
Browse files

qemu/bitops.h: add bitrev8 implementation


This will be required for an upcoming checksum calculation.

Signed-off-by: default avatarMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Tested-by: default avatarFinn Thain <fthain@linux-m68k.org>
Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20210625065401.30170-7-mark.cave-ayland@ilande.co.uk>
Signed-off-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
parent c3250c8e
No related branches found
No related tags found
No related merge requests found
......@@ -618,4 +618,26 @@ static inline uint64_t half_unshuffle64(uint64_t x)
return x;
}
/**
* bitrev8:
* @x: 8-bit value to be reversed
*
* Given an input value with bits::
*
* ABCDEFGH
*
* return the value with its bits reversed from left to right::
*
* HGFEDCBA
*
* Returns: the bit-reversed value.
*/
static inline uint8_t bitrev8(uint8_t x)
{
x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa);
x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc);
x = (x >> 4) | (x << 4) ;
return x;
}
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment