Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Nov 2023 16:37:51 GMT
From:      "Bjoern A. Zeeb" <bz@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: d7ae58192a9a - stable/13 - LinuxKPI: list.h add list_count_nodes()
Message-ID:  <202311291637.3ATGbpZ6044328@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=d7ae58192a9a966929220bc8c6b5280bf73e8437

commit d7ae58192a9a966929220bc8c6b5280bf73e8437
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2023-06-26 08:45:17 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2023-11-29 16:36:03 +0000

    LinuxKPI: list.h add list_count_nodes()
    
    Implement list_count_nodes() using a simple loop.  This is needed by
    an updated wireless driver.
    
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit 1b18fb7faa75cc6dfa2e253190b41e63a997ca9d)
---
 sys/compat/linuxkpi/common/include/linux/list.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/sys/compat/linuxkpi/common/include/linux/list.h b/sys/compat/linuxkpi/common/include/linux/list.h
index 30437bb54888..a27abedc55b0 100644
--- a/sys/compat/linuxkpi/common/include/linux/list.h
+++ b/sys/compat/linuxkpi/common/include/linux/list.h
@@ -464,6 +464,20 @@ static inline int list_is_last(const struct list_head *list,
 	return list->next == head;
 }
 
+static inline size_t
+list_count_nodes(const struct list_head *list)
+{
+	const struct list_head *lh;
+	size_t count;
+
+	count = 0;
+	list_for_each(lh, list) {
+		count++;
+	}
+
+	return (count);
+}
+
 #define	hlist_entry(ptr, type, field)	container_of(ptr, type, field)
 
 #define	hlist_for_each(p, head)						\



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202311291637.3ATGbpZ6044328>