MCPcopy Create free account
hub / github.com/F-Stack/f-stack / rev

Function rev

app/redis-6.2.6/src/dict.c:793–801  ·  view source on GitHub ↗

Function to reverse bits. Algorithm from: * http://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel */

Source from the content-addressed store, hash-verified

791/* Function to reverse bits. Algorithm from:
792 * http://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel */
793static unsigned long rev(unsigned long v) {
794 unsigned long s = CHAR_BIT * sizeof(v); // bit size; must be power of 2
795 unsigned long mask = ~0UL;
796 while ((s >>= 1) > 0) {
797 mask ^= (mask << s);
798 v = ((v >> s) & mask) | ((v << s) & ~mask);
799 }
800 return v;
801}
802
803/* dictScan() is used to iterate over the elements of a dictionary.
804 *

Callers 1

dictScanFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected