Support to multi-threading and pthread interface (POSIX.1-2008) (#23)
[lunaix-os.git] / lunaix-os / includes / lunaix / ds / llist.h
index a4797c34d3f889ab9c0e970ed693607ee7953fbe..1eec54bc42a16a36245a6278f2d32bcfd70a0ec3 100644 (file)
@@ -12,7 +12,7 @@
 #ifndef __LUNAIX_LLIST_H
 #define __LUNAIX_LLIST_H
 
 #ifndef __LUNAIX_LLIST_H
 #define __LUNAIX_LLIST_H
 
-#include <lunaix/common.h>
+#include <lunaix/types.h>
 
 struct llist_header
 {
 
 struct llist_header
 {
@@ -50,6 +50,12 @@ llist_prepend(struct llist_header* head, struct llist_header* elem)
     __llist_add(elem, head, head->next);
 }
 
     __llist_add(elem, head, head->next);
 }
 
+static inline void
+llist_insert_after(struct llist_header* head, struct llist_header* elem)
+{
+    __llist_add(elem, head, head->next);
+}
+
 static inline void
 llist_delete(struct llist_header* elem)
 {
 static inline void
 llist_delete(struct llist_header* elem)
 {
@@ -81,6 +87,22 @@ llist_empty(struct llist_header* elem)
  */
 #define list_entry(ptr, type, member) container_of(ptr, type, member)
 
  */
 #define list_entry(ptr, type, member) container_of(ptr, type, member)
 
+/**
+ * list_next - get the struct for next entry
+ * @ptr:       the &struct list_head pointer.
+ * @type:      the type of the struct this is embedded in.
+ * @member:    the name of the list_struct within the struct.
+ */
+#define list_next(current, type, member) container_of(current->member.next, type, member)
+
+/**
+ * list_prev - get the struct for prev entry
+ * @ptr:       the &struct list_head pointer.
+ * @type:      the type of the struct this is embedded in.
+ * @member:    the name of the list_struct within the struct.
+ */
+#define list_prev(current, type, member) container_of(current->member.prev, type, member)
+
 /**
  * list_for_each_entry -       iterate over list of given type
  * @pos:       the type * to use as a loop counter.
 /**
  * list_for_each_entry -       iterate over list of given type
  * @pos:       the type * to use as a loop counter.