From 58bbe2161cf6b3873aeb4ed1f2aa283059464643 Mon Sep 17 00:00:00 2001 From: "Eric W. Biederman" Date: Thu, 18 Jul 2002 22:26:45 +0000 Subject: [PATCH] Add alpha version of bitops.h --- src/arch/alpha/include/bitops.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/arch/alpha/include/bitops.h 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 */