Add alpha version of bitops.h
This commit is contained in:
parent
e8dacb6ba8
commit
58bbe2161c
1 changed files with 22 additions and 0 deletions
22
src/arch/alpha/include/bitops.h
Normal file
22
src/arch/alpha/include/bitops.h
Normal 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 */
|
||||
Loading…
Add table
Add a link
Reference in a new issue