#define _ALPHA_BITOPS_H
#include <linux/config.h>
-#include <linux/kernel.h>
#include <asm/compiler.h>
/*
#endif
/* Compute powers of two for the given integer. */
-static inline int floor_log2(unsigned long word)
+static inline long floor_log2(unsigned long word)
{
#if defined(__alpha_cix__) && defined(__alpha_fix__)
return 63 - __kernel_ctlz(word);
#endif
}
-static inline int ceil_log2(unsigned int word)
+static inline long ceil_log2(unsigned long word)
{
long bit = floor_log2(word);
return bit + (word > (1UL << bit));
return __kernel_ctpop(w);
}
-#define hweight32(x) hweight64((x) & 0xfffffffful)
-#define hweight16(x) hweight64((x) & 0xfffful)
-#define hweight8(x) hweight64((x) & 0xfful)
+#define hweight32(x) (unsigned int) hweight64((x) & 0xfffffffful)
+#define hweight16(x) (unsigned int) hweight64((x) & 0xfffful)
+#define hweight8(x) (unsigned int) hweight64((x) & 0xfful)
#else
static inline unsigned long hweight64(unsigned long w)
{
* Find next zero bit in a bitmap reasonably efficiently..
*/
static inline unsigned long
-find_next_zero_bit(void * addr, unsigned long size, unsigned long offset)
+find_next_zero_bit(const void *addr, unsigned long size, unsigned long offset)
{
- unsigned long * p = ((unsigned long *) addr) + (offset >> 6);
+ const unsigned long *p = addr;
unsigned long result = offset & ~63UL;
unsigned long tmp;
+ p += offset >> 6;
if (offset >= size)
return size;
size -= result;
static inline unsigned long
find_next_bit(const void * addr, unsigned long size, unsigned long offset)
{
- const unsigned long * p = ((const unsigned long *) addr) + (offset >> 6);
+ const unsigned long *p = addr;
unsigned long result = offset & ~63UL;
unsigned long tmp;
+ p += offset >> 6;
if (offset >= size)
return size;
size -= result;