Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 15558
b: refs/heads/master
c: 90933fc
h: refs/heads/master
v: v3
  • Loading branch information
Stephen Hemminger authored and David S. Miller committed Jan 3, 2006
1 parent 7f0d9c1 commit cfb6216
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 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: 3821af2fe13700cab6fd67367128fa180e43f8b8
refs/heads/master: 90933fc8ba5cc9034e3c04ee19938a22b0b4fe4e
28 changes: 27 additions & 1 deletion trunk/include/asm-x86_64/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,20 @@ static __inline__ unsigned long __ffs(unsigned long word)
return word;
}

/*
* __fls: find last bit set.
* @word: The word to search
*
* Undefined if no zero exists, so code should check against ~0UL first.
*/
static __inline__ unsigned long __fls(unsigned long word)
{
__asm__("bsrq %1,%0"
:"=r" (word)
:"rm" (word));
return word;
}

#ifdef __KERNEL__

static inline int sched_find_first_bit(const unsigned long *b)
Expand Down Expand Up @@ -369,6 +383,19 @@ static __inline__ int ffs(int x)
return r+1;
}

/**
* fls64 - find last bit set in 64 bit word
* @x: the word to search
*
* This is defined the same way as fls.
*/
static __inline__ int fls64(__u64 x)
{
if (x == 0)
return 0;
return __fls(x) + 1;
}

/**
* hweightN - returns the hamming weight of a N-bit word
* @x: the word to weigh
Expand Down Expand Up @@ -409,7 +436,6 @@ static __inline__ int ffs(int x)

/* find last set bit */
#define fls(x) generic_fls(x)
#define fls64(x) generic_fls64(x)

#endif /* __KERNEL__ */

Expand Down

0 comments on commit cfb6216

Please sign in to comment.