[PATCH] libosmocore[master]: linuxlist.h: add llist_len()

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Tue Jan 10 23:40:00 UTC 2017


Review at  https://gerrit.osmocom.org/1563

linuxlist.h: add llist_len()

After subchan_demux.c in libosmo-abis, osmo-bts/common/vty.c and openbsc's
gtphub_test.c, more places would like to count the llist items (mostly unit
tests). Instead of proliferating numerous local implementations, add here.

Before merging this, make sure the name llist_head() is not redefined, see:
libosmo-abis Change-Id I99c627cf2a2f0dca1ec5d2ad36e3c3f7f0d8d191
openbsc Change-Id I9a7e438de4539c382de54b7337fd18e4bf19d007

Change-Id: Ic49adc7a346f5722bf624d7d3b4a735e4220ae15
---
M include/osmocom/core/linuxlist.h
1 file changed, 9 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/63/1563/1

diff --git a/include/osmocom/core/linuxlist.h b/include/osmocom/core/linuxlist.h
index 1c83395..69d9752 100644
--- a/include/osmocom/core/linuxlist.h
+++ b/include/osmocom/core/linuxlist.h
@@ -351,6 +351,15 @@
 	for ((pos) = (pos)->next, prefetch((pos)->next); (pos) != (head); \
         	(pos) = (pos)->next, ({ smp_read_barrier_depends(); 0;}), prefetch((pos)->next))
 
+static inline int llist_len(struct llist_head *head)
+{
+	struct llist_head *entry;
+	int i = 0;
+	llist_for_each(entry, head)
+		i++;
+	return i;
+}
+
 /*!
  *  }@
  */

-- 
To view, visit https://gerrit.osmocom.org/1563
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic49adc7a346f5722bf624d7d3b4a735e4220ae15
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>


More information about the gerrit-log mailing list