Update 'foo.h'
This commit is contained in:
18
foo.h
18
foo.h
@@ -1,19 +1,3 @@
|
|||||||
/** bit_for_each64 - iterate over an u64 bits
|
/**/
|
||||||
* @pos: an int used as current bit
|
|
||||||
* @tmp: a temp u64 used as temporary storage
|
|
||||||
* @ul: the u64 to loop over
|
|
||||||
*
|
|
||||||
* Usage:
|
|
||||||
* u64 u=139, _t; // u=b10001011
|
|
||||||
* int cur;
|
|
||||||
* bit_for_each64(cur, _t, u) {
|
|
||||||
* printf("%d\n", cur);
|
|
||||||
* }
|
|
||||||
* This will display the position of each bit in u: 1, 2, 4, 8
|
|
||||||
*
|
|
||||||
* I should probably re-think the implementation...
|
|
||||||
*/
|
|
||||||
#define bit_for_each64(pos, tmp, ul) \
|
#define bit_for_each64(pos, tmp, ul) \
|
||||||
for (tmp = ul, pos = ffs64(tmp); pos; tmp &= (tmp - 1), pos = ffs64(tmp))
|
for (tmp = ul, pos = ffs64(tmp); pos; tmp &= (tmp - 1), pos = ffs64(tmp))
|
||||||
|
|
||||||
#endif /* BITS_H */
|
|
||||||
|
Reference in New Issue
Block a user