[PATCH 1/4] bitvec: add bitvec_find_first_bit_pos() from gsm/rxlev_stat.c

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

pablo at gnumonks.org pablo at gnumonks.org
Mon Mar 28 17:24:19 UTC 2011


From: Pablo Neira Ayuso <pablo at gnumonks.org>

This patch adds bitvec_find_bit_pos() to bitvec.c where it really
belongs to. Before this patch used to be part of gsm/rxlev_stat.c
---
 include/osmocom/core/bitvec.h |    2 ++
 src/bitvec.c                  |   14 ++++++++++++++
 src/gsm/rxlev_stat.c          |   12 ------------
 3 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/include/osmocom/core/bitvec.h b/include/osmocom/core/bitvec.h
index 42977fb..bbe1641 100644
--- a/include/osmocom/core/bitvec.h
+++ b/include/osmocom/core/bitvec.h
@@ -68,6 +68,8 @@ int bitvec_set_uint(struct bitvec *bv, unsigned int in, int count);
 /* get multiple bits (based on numeric value) from current pos */
 int bitvec_get_uint(struct bitvec *bv, int num_bits);
 
+/* find the first bit set in bit vector */
+int bitvec_find_bit_pos(const struct bitvec *bv, unsigned int n, enum bit_value val);
 
 /* Pad the bit vector up to a certain bit position */
 int bitvec_spare_padding(struct bitvec *bv, unsigned int up_to_bit);
diff --git a/src/bitvec.c b/src/bitvec.c
index 4984af2..4fd3834 100644
--- a/src/bitvec.c
+++ b/src/bitvec.c
@@ -217,3 +217,17 @@ int bitvec_spare_padding(struct bitvec *bv, unsigned int up_to_bit)
 
 	return 0;
 }
+
+/* find first bit set in bit vector */
+int bitvec_find_bit_pos(const struct bitvec *bv, unsigned int n,
+			enum bit_value val)
+{
+	unsigned int i;
+
+	for (i = n; i < bv->data_len*8; i++) {
+		if (bitvec_get_bit_pos(bv, i) == val)
+			return i;
+	}
+
+	return -1;
+}
diff --git a/src/gsm/rxlev_stat.c b/src/gsm/rxlev_stat.c
index 626aaff..d226861 100644
--- a/src/gsm/rxlev_stat.c
+++ b/src/gsm/rxlev_stat.c
@@ -30,18 +30,6 @@
 #include <osmocom/core/bitvec.h>
 #include <osmocom/gsm/rxlev_stat.h>
 
-int bitvec_find_bit_pos(const struct bitvec *bv, unsigned int n, enum bit_value val)
-{
-	unsigned int i;
-
-	for (i = n; i < bv->data_len*8; i++) {
-		if (bitvec_get_bit_pos(bv, i) == val)
-			return i;
-	}
-
-	return -1;
-}
-
 void rxlev_stat_input(struct rxlev_stats *st, uint16_t arfcn, uint8_t rxlev)
 {
 	struct bitvec bv;
-- 
1.7.2.3





More information about the OpenBSC mailing list