Commit ad52f854 authored by Alejandro Mery's avatar Alejandro Mery
Browse files

sunxi-tools.h: add list_next() and list_remove() helpers

parent f2ff0fc8
...@@ -47,7 +47,7 @@ static inline void list_init(struct list_entry *self) ...@@ -47,7 +47,7 @@ static inline void list_init(struct list_entry *self)
self->prev = self->next = self; self->prev = self->next = self;
} }
/** append a list hook @l1 at the end of the list @l0 */ /** appends a list hook @l1 at the end of the list @l0 */
static inline void list_append(struct list_entry *l0, struct list_entry *l1) static inline void list_append(struct list_entry *l0, struct list_entry *l1)
{ {
l1->next = l0; l1->next = l0;
...@@ -55,12 +55,26 @@ static inline void list_append(struct list_entry *l0, struct list_entry *l1) ...@@ -55,12 +55,26 @@ static inline void list_append(struct list_entry *l0, struct list_entry *l1)
l0->prev = l1; l0->prev = l1;
} }
/** returns list element of a list */ /** removes an entry for the list where it's contained */
static inline void list_remove(struct list_entry *l)
{
struct list_entry *prev = l->prev, *next = l->next;
next->prev = prev;
prev->next = next;
}
/** returns last element of a list */
static inline struct list_entry *list_last(struct list_entry *l) static inline struct list_entry *list_last(struct list_entry *l)
{ {
return (l->prev == l) ? NULL : l->prev; return (l->prev == l) ? NULL : l->prev;
} }
/** returns first element of a list */
static inline struct list_entry *list_next(struct list_entry *l)
{
return (l->next == l) ? NULL : l->next;
}
/** is list empty? */ /** is list empty? */
static inline int list_empty(struct list_entry *l) static inline int list_empty(struct list_entry *l)
{ {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment