summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2024-05-31 12:01:43 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2024-05-31 16:03:23 +0200
commit2075553a1b0eb843d4ee73a039b3e30bed9274e0 (patch)
tree904f192fa9d7c920c9dde6a7bc26b208c3b03312 /include
parent5a68a246e750359819d63bcff5ef97dd9c7788fc (diff)
libbb: add bit counting function, use where appropriate
Although "naive" counting function is not too slow and is smaller, using it on e.g. each of 1024 words of CPU mask feels wrong. function old new delta bb_popcnt_32 - 52 +52 get_prefix 323 321 -2 nproc_main 206 199 -7 d4_run_script 739 731 -8 ipcalc_main 533 507 -26 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 0/4 up/down: 52/-43) Total: 9 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'include')
-rw-r--r--include/libbb.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/include/libbb.h b/include/libbb.h
index 67d29f843..6914b5882 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -397,6 +397,13 @@ extern int *BB_GLOBAL_CONST bb_errno;
uint64_t bb_bswap_64(uint64_t x) FAST_FUNC;
#endif
+unsigned FAST_FUNC bb_popcnt_32(uint32_t m);
+#if ULONG_MAX > 0xffffffff
+unsigned FAST_FUNC bb_popcnt_long(unsigned_long m);
+#else
+#define bb_popcnt_long(m) bb_popcnt_32(m)
+#endif
+
unsigned long FAST_FUNC isqrt(unsigned long long N);
unsigned long long monotonic_ns(void) FAST_FUNC;