diff options
Diffstat (limited to 'coreutils/nproc.c')
-rw-r--r-- | coreutils/nproc.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/coreutils/nproc.c b/coreutils/nproc.c index a0d818c59..df63bf57a 100644 --- a/coreutils/nproc.c +++ b/coreutils/nproc.c | |||
@@ -56,13 +56,10 @@ int nproc_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
56 | unsigned long *mask = get_malloc_cpu_affinity(0, &sz); | 56 | unsigned long *mask = get_malloc_cpu_affinity(0, &sz); |
57 | sz /= sizeof(long); | 57 | sz /= sizeof(long); |
58 | for (i = 0; i < sz; i++) { | 58 | for (i = 0; i < sz; i++) { |
59 | unsigned long m = mask[i]; | 59 | if (mask[i] != 0) /* most mask[i] are usually 0 */ |
60 | while (m) { | 60 | count += bb_popcnt_long(mask[i]); |
61 | if (m & 1) | ||
62 | count++; | ||
63 | m >>= 1; | ||
64 | } | ||
65 | } | 61 | } |
62 | IF_FEATURE_CLEAN_UP(free(mask);) | ||
66 | } | 63 | } |
67 | 64 | ||
68 | IF_LONG_OPTS(count -= ignore;) | 65 | IF_LONG_OPTS(count -= ignore;) |