pespin has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmo-pcu/+/33125 )
Change subject: Document pcu_lsb() function
......................................................................
Document pcu_lsb() function
While at it, fix a typo in the test output.
This function is nowadays only used in ms_current_pacch_slots(), which
is used only to print the PACCH TS (the first common UL & DL TS).
Change-Id: Id1d0b681f6866618f9f3a8c64d6a6c809ca50ea7
---
M src/pcu_utils.h
M tests/types/TypesTest.cpp
M tests/types/TypesTest.ok
3 files changed, 20 insertions(+), 3 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/25/33125/1
diff --git a/src/pcu_utils.h b/src/pcu_utils.h
index 2dd86ac..1b1bf06 100644
--- a/src/pcu_utils.h
+++ b/src/pcu_utils.h
@@ -72,6 +72,9 @@
return __builtin_popcountll(x);
}
+/* Trim all 1 bits except the Least Significat Bit, which is kept.
+ * equivalent of (1 << ffs(u)) / 2
+ */
static inline uint8_t pcu_lsb(uint8_t x)
{
return x & -x;
diff --git a/tests/types/TypesTest.cpp b/tests/types/TypesTest.cpp
index 871e0d1..0d936de 100644
--- a/tests/types/TypesTest.cpp
+++ b/tests/types/TypesTest.cpp
@@ -937,10 +937,10 @@
{
uint8_t u = 0;
- printf("Testing LBS utility...\n");
+ printf("Testing LSB utility...\n");
do {
- uint8_t x = pcu_lsb(u); /* equivalent of (1 << ffs(u)) / 2 */
+ uint8_t x = pcu_lsb(u);
printf("%2X " OSMO_BIT_SPEC ": {%d} %3d\n",
u, OSMO_BIT_PRINT(u), pcu_bitcount(u), x);
u++;
diff --git a/tests/types/TypesTest.ok b/tests/types/TypesTest.ok
index 27afc71..b99e17e 100644
--- a/tests/types/TypesTest.ok
+++ b/tests/types/TypesTest.ok
@@ -18,7 +18,7 @@
06 3f 10 0d 23 6d 7f 03 18 23 00 46 a0 08 00 17 44 0b 2b 2b 2b 2b 2b
assignment reject: 06 3a 10 7f 06 36 14 7f 06 36 14 7f 06 36 14 7f 06 36 14 c0 2b 2b
assignment reject: 06 3a 10 70 06 36 14 70 06 36 14 70 06 36 14 70 06 36 14 0b 2b 2b
-Testing LBS utility...
+Testing LSB utility...
0 ........: {0} 0
1 .......1: {1} 1
2 ......1.: {1} 2
--
To view, visit
https://gerrit.osmocom.org/c/osmo-pcu/+/33125
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: Id1d0b681f6866618f9f3a8c64d6a6c809ca50ea7
Gerrit-Change-Number: 33125
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-MessageType: newchange