2 * Sherlock Library -- Linked Lists
4 * (c) 1997--1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
7 #ifndef _SHERLOCK_LISTS_H
8 #define _SHERLOCK_LISTS_H
11 struct node *next, *prev;
14 typedef struct list { /* In fact two overlayed nodes */
15 struct node *head, *null, *tail;
19 #define HEAD(list) ((void *)((list).head))
20 #define TAIL(list) ((void *)((list).tail))
21 #define WALK_LIST(n,list) for(n=HEAD(list);(NODE (n))->next; \
22 n=(void *)((NODE (n))->next))
23 #define DO_FOR_ALL(n,list) WALK_LIST(n,list)
24 #define WALK_LIST_DELSAFE(n,nxt,list) \
25 for(n=HEAD(list); nxt=(void *)((NODE (n))->next); n=(void *) nxt)
26 #define WALK_LIST_BACKWARDS(n,list) for(n=TAIL(list);(NODE (n))->prev; \
27 n=(void *)((NODE (n))->prev))
28 #define WALK_LIST_BACKWARDS_DELSAFE(n,prv,list) \
29 for(n=TAIL(list); prv=(void *)((NODE (n))->prev); n=(void *) prv)
31 #define EMPTY_LIST(list) (!(list).head->next)
33 void add_tail(list *, node *);
34 void add_head(list *, node *);
35 void rem_node(node *);
36 void add_tail_list(list *, list *);
37 void init_list(list *);
38 void insert_node(node *, node *);
40 #if !defined(_SHERLOCK_LISTS_C) && defined(__GNUC__)
41 #define LIST_INLINE extern inline
42 #include "lib/lists.c"