Update 'foo.h'

This commit is contained in:
2021-11-10 10:26:44 +01:00
parent efc1117154
commit 1f26a4fcbb

18
foo.h
View File

@@ -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) \
for (tmp = ul, pos = ffs64(tmp); pos; tmp &= (tmp - 1), pos = ffs64(tmp))
#endif /* BITS_H */