Add alpha version of bitops.h

This commit is contained in:
Eric W. Biederman 2002-07-18 22:26:45 +00:00
commit 58bbe2161c

View file

@ -0,0 +1,22 @@
#ifndef ALPHA_BITOPS_H
#define ALPHA_BITOPS_H
/**
* log2 - Find the truncated log base 2 of x
*/
static inline unsigned long log2(unsigned long x)
{
unsigned long r = 63;
do {
if (x & (1UL << r)) {
break;
}
r--;
} while(r > 0);
if (x == 0) {
r = -1UL;
}
return r;
}
#endif /* ALPHA_BITOPS_H */