Set tchain earliest/latest on any removal
[akaros.git] / kern / include / sys / queue.h
index c14f014..8524177 100644 (file)
@@ -30,8 +30,7 @@
  * $FreeBSD$
  */
 
-#ifndef ROS_KERN_SYS_QUEUE_H
-#define ROS_KERN_SYS_QUEUE_H
+#pragma once
 
 #include <ros/common.h>    /* for __offsetof */
 
@@ -421,6 +420,11 @@ struct {                                                           \
 
 #define        BSD_LIST_NEXT(elm, field)       ((elm)->field.le_next)
 
+#define        BSD_LIST_PREV(elm, head, type, field)                   \
+       ((elm)->field.le_prev == &BSD_LIST_FIRST((head)) ? NULL :       \
+           container_of((elm)->field.le_prev,                  \
+           struct type, field.le_next))
+
 #define        BSD_LIST_REMOVE(elm, field) do {                                        \
        QMD_SAVELINK(oldnext, (elm)->field.le_next);                    \
        QMD_SAVELINK(oldprev, (elm)->field.le_prev);                    \
@@ -629,5 +633,3 @@ struct {                                                            \
        else                                                            \
                (head2)->tqh_last = &(head2)->tqh_first;                \
 } while (0)
-
-#endif /* ROS_KERN_SYS_QUEUE_H */