summaryrefslogtreecommitdiffstats
path: root/list.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:50:40 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:50:40 +0000
commit2a5fcae954f992cf558eb91c83aa4c5a880a6bdc (patch)
tree843baab7b4189d366d3d5479fe272950bf407034 /list.h
parentInitial commit. (diff)
downloadethtool-2a5fcae954f992cf558eb91c83aa4c5a880a6bdc.tar.xz
ethtool-2a5fcae954f992cf558eb91c83aa4c5a880a6bdc.zip
Adding upstream version 1:6.1.upstream/1%6.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'list.h')
-rw-r--r--list.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/list.h b/list.h
new file mode 100644
index 0000000..aa97fdd
--- /dev/null
+++ b/list.h
@@ -0,0 +1,34 @@
+#ifndef ETHTOOL_LIST_H__
+#define ETHTOOL_LIST_H__
+
+#include <unistd.h>
+
+/* Generic list utilities */
+
+struct list_head {
+ struct list_head *next, *prev;
+};
+
+#define LIST_HEAD_INIT(name) { &(name), &(name) }
+
+static inline void list_add(struct list_head *new, struct list_head *head)
+{
+ head->next->prev = new;
+ new->next = head->next;
+ new->prev = head;
+ head->next = new;
+}
+
+static inline void list_del(struct list_head *entry)
+{
+ entry->next->prev = entry->prev;
+ entry->prev->next = entry->next;
+ entry->next = NULL;
+ entry->prev = NULL;
+}
+
+#define list_for_each_safe(pos, n, head) \
+ for (pos = (head)->next, n = pos->next; pos != (head); \
+ pos = n, n = pos->next)
+
+#endif