Skip to contentSkip to conversation

missing mini-os list_top macro

PATCH New Diego Ongaro 1 participant 1 message Jul 18, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 missing mini-os list_top macro

mini-os is missing list_top in its list.h
---

extras/mini-os/include/list.h +6 -0
diff -r 37289395de03 extras/mini-os/include/list.h
@@ -23,6 +23,12 @@
 #define INIT_LIST_HEAD(ptr) do { \
 	(ptr)->next = (ptr); (ptr)->prev = (ptr); \
 } while (0)
+
+#define list_top(head, type, member)					  \
+({ 									  \
+	struct list_head *_head = (head);				  \
+	list_empty(_head) ? NULL : list_entry(_head->next, type, member); \
+})
 
 /*
  * Insert a new entry between two known consecutive entries.