#include <linux/bitops.h> #include <asm/types.h> /** * hweightN - returns the hamming weight of a N-bit word * @x: the word to weigh * * The Hamming Weight of a number is the total number of bits set in it. */
unsigned int __sw_hweight32(unsigned int w) { #ifdef CONFIG_ARCH_HAS_FAST_MULTIPLIER w -= (w >> 1) & 0x55555555; w = (w & 0x33333333) + ((w >> 2) & 0x33333333); w = (w + (w >> 4)) & 0x0f0f0f0f; return (w * 0x01010101) >> 24; #else unsigned int res = w - ((w >> 1) & 0x55555555); res = (res & 0x33333333) + ((res >> 2) & 0x33333333); res = (res + (res >> 4)) & 0x0F0F0F0F; res = res + (res >> 8); return (res + (res >> 16)) & 0x000000FF; #endif }Contributors
Person | Tokens | Prop | Commits | CommitProp | |
arnaldo carvalho de melo | arnaldo carvalho de melo | 139 | 100.00% | 1 | 100.00% |
Total | 139 | 100.00% | 1 | 100.00% |
Person | Tokens | Prop | Commits | CommitProp | |
arnaldo carvalho de melo | arnaldo carvalho de melo | 71 | 100.00% | 1 | 100.00% |
Total | 71 | 100.00% | 1 | 100.00% |
Person | Tokens | Prop | Commits | CommitProp | |
arnaldo carvalho de melo | arnaldo carvalho de melo | 57 | 100.00% | 1 | 100.00% |
Total | 57 | 100.00% | 1 | 100.00% |
Person | Tokens | Prop | Commits | CommitProp | |
arnaldo carvalho de melo | arnaldo carvalho de melo | 182 | 100.00% | 1 | 100.00% |
Total | 182 | 100.00% | 1 | 100.00% |
Person | Tokens | Prop | Commits | CommitProp | |
arnaldo carvalho de melo | arnaldo carvalho de melo | 456 | 100.00% | 1 | 100.00% |
Total | 456 | 100.00% | 1 | 100.00% |