Message ID | 20240524194829.f11312298857.I2921f495b9feefbfe464ffd71c7350c66be119a8@changeid (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/3] backports: add list_count_nodes() | expand |
diff --git a/backport/backport-include/linux/list.h b/backport/backport-include/linux/list.h new file mode 100644 index 000000000000..8495fd419a95 --- /dev/null +++ b/backport/backport-include/linux/list.h @@ -0,0 +1,19 @@ +#ifndef __BP_LINUX_LIST_H +#define __BP_LINUX_LIST_H +#include_next <linux/list.h> + +#if LINUX_VERSION_IS_LESS(6,3,0) +#define list_count_nodes LINUX_BACKPORT(list_count_nodes) +static inline size_t list_count_nodes(struct list_head *head) +{ + struct list_head *pos; + size_t count = 0; + + list_for_each(pos, head) + count++; + + return count; +} +#endif + +#endif /* __BP_LINUX_LIST_H */