aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2023-05-31 21:19:24 +0200
committerlaforge <laforge@osmocom.org>2023-06-03 12:46:26 +0000
commit2549c1e696cc4991a7b5f15f2f81b909b9da6c1b (patch)
tree4c08abf859cb255f2c1bcb94b9c08d80711d751d
parentba8918aae8342497e6e219239f3ed29dc8290349 (diff)
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
-rw-r--r--src/pcu_utils.h3
-rw-r--r--tests/types/TypesTest.cpp4
-rw-r--r--tests/types/TypesTest.ok2
3 files changed, 6 insertions, 3 deletions
diff --git a/src/pcu_utils.h b/src/pcu_utils.h
index 0be37e94..540f7049 100644
--- a/src/pcu_utils.h
+++ b/src/pcu_utils.h
@@ -72,6 +72,9 @@ inline unsigned int pcu_bitcount(unsigned long long x)
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 c6a2fbf5..06284975 100644
--- a/tests/types/TypesTest.cpp
+++ b/tests/types/TypesTest.cpp
@@ -937,10 +937,10 @@ static void test_lsb()
{
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 27afc711..b99e17e7 100644
--- a/tests/types/TypesTest.ok
+++ b/tests/types/TypesTest.ok
@@ -18,7 +18,7 @@ show_rbb: IIRRIIIR
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