Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 182414
b: refs/heads/master
c: 9f41699
h: refs/heads/master
v: v3
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Jan 29, 2010
1 parent 5ca0abc commit 4783caf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8433be1184e4f22c37d4b8ed36cde529a47882f4
refs/heads/master: 9f41699ed067fa695faff8e2e9981b2550abec62
18 changes: 16 additions & 2 deletions trunk/include/linux/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
static __inline__ int get_bitmask_order(unsigned int count)
{
int order;

order = fls(count);
return order; /* We could be slightly more clever with -1 here... */
}

static __inline__ int get_count_order(unsigned int count)
{
int order;

order = fls(count) - 1;
if (count & (count - 1))
order++;
Expand All @@ -45,6 +45,20 @@ static inline unsigned long hweight_long(unsigned long w)
return sizeof(w) == 4 ? hweight32(w) : hweight64(w);
}

#define HWEIGHT8(w) \
( (!!((w) & (1ULL << 0))) + \
(!!((w) & (1ULL << 1))) + \
(!!((w) & (1ULL << 2))) + \
(!!((w) & (1ULL << 3))) + \
(!!((w) & (1ULL << 4))) + \
(!!((w) & (1ULL << 5))) + \
(!!((w) & (1ULL << 6))) + \
(!!((w) & (1ULL << 7))) )

#define HWEIGHT16(w) (HWEIGHT8(w) + HWEIGHT8(w >> 8))
#define HWEIGHT32(w) (HWEIGHT16(w) + HWEIGHT16(w >> 16))
#define HWEIGHT64(w) (HWEIGHT32(w) + HWEIGHT32(w >> 32))

/**
* rol32 - rotate a 32-bit value left
* @word: value to rotate
Expand Down

0 comments on commit 4783caf

Please sign in to comment.