diff --git a/src/arch/alpha/include/bitops.h b/src/arch/alpha/include/bitops.h new file mode 100644 index 0000000000..9b6c58ba43 --- /dev/null +++ b/src/arch/alpha/include/bitops.h @@ -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 */