Attention is currently required from: Hoernchen, pespin.

pespin has uploaded this change for review.

View Change

pcu_utils.h: Replace software based bitcount impl with gcc builtin

The cast for different types it's not really needed, simply use the
unsigned long long version to make sure we don't drop 1s, in any case
__builtin_popcountll() will be quicker than what we used to have.

Change-Id: I80ae72d34d53564fc3da1601ee48c8b2ffe79735
---
M src/pcu_utils.h
1 file changed, 15 insertions(+), 9 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/18/33118/1
diff --git a/src/pcu_utils.h b/src/pcu_utils.h
index 1c698ca..2dd86ac 100644
--- a/src/pcu_utils.h
+++ b/src/pcu_utils.h
@@ -67,17 +67,10 @@
return fn % GSM_MAX_FN;
}

-#ifdef __cplusplus
-template <typename T>
-inline unsigned int pcu_bitcount(T x)
+inline unsigned int pcu_bitcount(unsigned long long x)
{
- unsigned int count = 0;
- for (count = 0; x; count += 1)
- x &= x - 1;
-
- return count;
+ return __builtin_popcountll(x);
}
-#endif

static inline uint8_t pcu_lsb(uint8_t x)
{

To view, visit change 33118. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: I80ae72d34d53564fc3da1601ee48c8b2ffe79735
Gerrit-Change-Number: 33118
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin@sysmocom.de>
Gerrit-Reviewer: Hoernchen <ewild@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Attention: Hoernchen <ewild@sysmocom.de>
Gerrit-Attention: pespin <pespin@sysmocom.de>
Gerrit-MessageType: newchange