X-Git-Url: http://git.onelab.eu/?p=ipfw.git;a=blobdiff_plain;f=test%2Fmylist.h;fp=test%2Fmylist.h;h=b546fc2ce3fa5ea4df3e993dba3db0cae558ef3b;hp=0000000000000000000000000000000000000000;hb=40445faa1db58b90083115bc315d095e7eb2fe51;hpb=fccf30d4bf6b00b317756a9ff9d2135b361d2599 diff --git a/test/mylist.h b/test/mylist.h new file mode 100644 index 0000000..b546fc2 --- /dev/null +++ b/test/mylist.h @@ -0,0 +1,49 @@ +/* + * $Id: mylist.h 5626 2010-03-04 21:55:22Z luigi $ + * + * linux-like bidirectional lists + */ + +#ifndef _MYLIST_H +#define _MYLIST_H +struct list_head { + struct list_head *prev, *next; +}; + +#define INIT_LIST_HEAD(l) do { (l)->prev = (l)->next = (l); } while (0) +#define list_empty(l) ( (l)->next == l ) +static inline void +__list_add(struct list_head *o, struct list_head *prev, + struct list_head *next) +{ + next->prev = o; + o->next = next; + o->prev = prev; + prev->next = o; +} + +static inline void +list_add_tail(struct list_head *o, struct list_head *head) +{ + __list_add(o, head->prev, head); +} + +#define list_first_entry(pL, ty, member) \ + (ty *)((char *)((pL)->next) - offsetof(ty, member)) + +static inline void +__list_del(struct list_head *prev, struct list_head *next) +{ + next->prev = prev; + prev->next = next; +} + +static inline void +list_del(struct list_head *entry) +{ + ND("called on %p", entry); + __list_del(entry->prev, entry->next); + entry->next = entry->prev = NULL; +} + +#endif /* _MYLIST_H */