diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2024-05-31 12:01:43 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2024-05-31 16:03:23 +0200 |
commit | 2075553a1b0eb843d4ee73a039b3e30bed9274e0 (patch) | |
tree | 904f192fa9d7c920c9dde6a7bc26b208c3b03312 /include | |
parent | 5a68a246e750359819d63bcff5ef97dd9c7788fc (diff) | |
download | busybox-w32-2075553a1b0eb843d4ee73a039b3e30bed9274e0.tar.gz busybox-w32-2075553a1b0eb843d4ee73a039b3e30bed9274e0.tar.bz2 busybox-w32-2075553a1b0eb843d4ee73a039b3e30bed9274e0.zip |
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.h | 7 |
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; | |||
397 | uint64_t bb_bswap_64(uint64_t x) FAST_FUNC; | 397 | uint64_t bb_bswap_64(uint64_t x) FAST_FUNC; |
398 | #endif | 398 | #endif |
399 | 399 | ||
400 | unsigned FAST_FUNC bb_popcnt_32(uint32_t m); | ||
401 | #if ULONG_MAX > 0xffffffff | ||
402 | unsigned FAST_FUNC bb_popcnt_long(unsigned_long m); | ||
403 | #else | ||
404 | #define bb_popcnt_long(m) bb_popcnt_32(m) | ||
405 | #endif | ||
406 | |||
400 | unsigned long FAST_FUNC isqrt(unsigned long long N); | 407 | unsigned long FAST_FUNC isqrt(unsigned long long N); |
401 | 408 | ||
402 | unsigned long long monotonic_ns(void) FAST_FUNC; | 409 | unsigned long long monotonic_ns(void) FAST_FUNC; |