diff options
Diffstat (limited to 'libglusterfs/src')
-rw-r--r-- | libglusterfs/src/list.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libglusterfs/src/list.h b/libglusterfs/src/list.h index a860275a91e..875594136a2 100644 --- a/libglusterfs/src/list.h +++ b/libglusterfs/src/list.h @@ -256,4 +256,18 @@ static inline void list_replace_init(struct list_head *old, &pos->member != (head); \ pos = n, n = list_entry(n->member.prev, typeof(*n), member)) +/* + * This list implementation has some advantages, but one disadvantage: you + * can't use NULL to check whether you're at the head or tail. Thus, the + * address of the head has to be an argument for these macros. + */ + +#define list_next(ptr, head, type, member) \ + (((ptr)->member.next == head) ? NULL \ + : list_entry((ptr)->member.next, type, member)) + +#define list_prev(ptr, head, type, member) \ + (((ptr)->member.prev == head) ? NULL \ + : list_entry((ptr)->member.prev, type, member)) + #endif /* _LLIST_H */ |