-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Catalin Marinas
committed
Sep 14, 2012
1 parent
dea4950
commit e62119b
Showing
5 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: 0753f70f07fbbd23a48d61ffea37028bd0bd6c7d | ||
refs/heads/master: 048fa2df92c325cb4425dccd66c8922c8342b507 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef _ASM_GENERIC_BITOPS_BUILTIN___FFS_H_ | ||
#define _ASM_GENERIC_BITOPS_BUILTIN___FFS_H_ | ||
|
||
/** | ||
* __ffs - find first bit in word. | ||
* @word: The word to search | ||
* | ||
* Undefined if no bit exists, so code should check against 0 first. | ||
*/ | ||
static __always_inline unsigned long __ffs(unsigned long word) | ||
{ | ||
return __builtin_ctzl(word); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef _ASM_GENERIC_BITOPS_BUILTIN___FLS_H_ | ||
#define _ASM_GENERIC_BITOPS_BUILTIN___FLS_H_ | ||
|
||
/** | ||
* __fls - find last (most-significant) set bit in a long word | ||
* @word: the word to search | ||
* | ||
* Undefined if no set bit exists, so code should check against 0 first. | ||
*/ | ||
static __always_inline unsigned long __fls(unsigned long word) | ||
{ | ||
return (sizeof(word) * 8) - 1 - __builtin_clzl(word); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef _ASM_GENERIC_BITOPS_BUILTIN_FFS_H_ | ||
#define _ASM_GENERIC_BITOPS_BUILTIN_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 __always_inline int ffs(int x) | ||
{ | ||
return __builtin_ffs(x); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef _ASM_GENERIC_BITOPS_BUILTIN_FLS_H_ | ||
#define _ASM_GENERIC_BITOPS_BUILTIN_FLS_H_ | ||
|
||
/** | ||
* fls - find last (most-significant) bit set | ||
* @x: the word to search | ||
* | ||
* This is defined the same way as ffs. | ||
* Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. | ||
*/ | ||
static __always_inline int fls(int x) | ||
{ | ||
return x ? sizeof(x) * 8 - __builtin_clz(x) : 0; | ||
} | ||
|
||
#endif |