Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 24165
b: refs/heads/master
c: 09020ad
h: refs/heads/master
i:
  24163: 9f7dbdc
v: v3
  • Loading branch information
Akinobu Mita authored and Linus Torvalds committed Mar 26, 2006
1 parent 4a6b295 commit f6e6d27
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6d29ea23da033f46ac4ab359d46650a7f7474611
refs/heads/master: 09020adb61416c4307de35941a9725a5e33d9beb
41 changes: 41 additions & 0 deletions trunk/include/asm-generic/bitops/ffs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#ifndef _ASM_GENERIC_BITOPS_FFS_H_
#define _ASM_GENERIC_BITOPS_FFS_H_

/**
* ffs - find first bit set
* @x: the word to search
*
* This is defined the same way as
* the libc and compiler builtin ffs routines, therefore
* differs in spirit from the above ffz (man ffs).
*/
static inline int ffs(int x)
{
int r = 1;

if (!x)
return 0;
if (!(x & 0xffff)) {
x >>= 16;
r += 16;
}
if (!(x & 0xff)) {
x >>= 8;
r += 8;
}
if (!(x & 0xf)) {
x >>= 4;
r += 4;
}
if (!(x & 3)) {
x >>= 2;
r += 2;
}
if (!(x & 1)) {
x >>= 1;
r += 1;
}
return r;
}

#endif /* _ASM_GENERIC_BITOPS_FFS_H_ */

0 comments on commit f6e6d27

Please sign in to comment.