ia64/xen-unstable

annotate tools/blktap2/include/list.h @ 19835:edfdeb150f27

Fix buildsystem to detect udev > version 124

udev removed the udevinfo symlink from versions higher than 123 and
xen's build-system could not detect if udev is in place and has the
required version.

Signed-off-by: Marc-A. Dahlhaus <mad@wol.de>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jun 25 13:02:37 2009 +0100 (2009-06-25)
parents b7f73a7f3078
children
rev   line source
keir@19647 1 /*
keir@19647 2 * list.h
keir@19647 3 *
keir@19647 4 * This is a subset of linux's list.h intended to be used in user-space.
keir@19817 5 * XXX The namespace conflicts with NetBSD's <sys/queue.h>
keir@19647 6 *
keir@19647 7 */
keir@19647 8
keir@19647 9 #ifndef __LIST_H__
keir@19647 10 #define __LIST_H__
keir@19647 11
keir@19647 12 #define LIST_POISON1 ((void *) 0x00100100)
keir@19647 13 #define LIST_POISON2 ((void *) 0x00200200)
keir@19647 14
keir@19647 15 struct list_head {
keir@19647 16 struct list_head *next, *prev;
keir@19647 17 };
keir@19647 18
keir@19817 19 /* XXX workaround for conflicts. The list API should use its own
keir@19817 20 * namespace prefix, i.e. BLK_
keir@19817 21 */
keir@19817 22 #ifdef LIST_HEAD_INIT
keir@19817 23 #undef LIST_HEAD_INIT
keir@19817 24 #endif
keir@19817 25 #ifndef LIST_HEAD
keir@19817 26 #undef LIST_HEAD
keir@19817 27 #endif
keir@19817 28
keir@19647 29 #define LIST_HEAD_INIT(name) { &(name), &(name) }
keir@19647 30
keir@19647 31 #define LIST_HEAD(name) \
keir@19647 32 struct list_head name = LIST_HEAD_INIT(name)
keir@19647 33
keir@19647 34 static inline void INIT_LIST_HEAD(struct list_head *list)
keir@19647 35 {
keir@19647 36 list->next = list;
keir@19647 37 list->prev = list;
keir@19647 38 }
keir@19647 39
keir@19647 40 static inline void __list_add(struct list_head *new,
keir@19647 41 struct list_head *prev,
keir@19647 42 struct list_head *next)
keir@19647 43 {
keir@19647 44 next->prev = new;
keir@19647 45 new->next = next;
keir@19647 46 new->prev = prev;
keir@19647 47 prev->next = new;
keir@19647 48 }
keir@19647 49
keir@19647 50 static inline void list_add(struct list_head *new, struct list_head *head)
keir@19647 51 {
keir@19647 52 __list_add(new, head, head->next);
keir@19647 53 }
keir@19647 54
keir@19647 55 static inline void list_add_tail(struct list_head *new, struct list_head *head)
keir@19647 56 {
keir@19647 57 __list_add(new, head->prev, head);
keir@19647 58 }
keir@19647 59
keir@19647 60 static inline void __list_del(struct list_head * prev, struct list_head * next)
keir@19647 61 {
keir@19647 62 next->prev = prev;
keir@19647 63 prev->next = next;
keir@19647 64 }
keir@19647 65
keir@19647 66 static inline void list_del(struct list_head *entry)
keir@19647 67 {
keir@19647 68 __list_del(entry->prev, entry->next);
keir@19647 69 entry->next = LIST_POISON1;
keir@19647 70 entry->prev = LIST_POISON2;
keir@19647 71 }
keir@19647 72
keir@19647 73 static inline void list_del_init(struct list_head *entry)
keir@19647 74 {
keir@19647 75 __list_del(entry->prev, entry->next);
keir@19647 76 INIT_LIST_HEAD(entry);
keir@19647 77 }
keir@19647 78
keir@19647 79 static inline int list_empty(const struct list_head *head)
keir@19647 80 {
keir@19647 81 return head->next == head;
keir@19647 82 }
keir@19647 83
keir@19647 84 static inline int list_is_last(const struct list_head *list,
keir@19647 85 const struct list_head *head)
keir@19647 86 {
keir@19647 87 return list->next == head;
keir@19647 88 }
keir@19647 89
keir@19647 90 #define list_entry(ptr, type, member) \
keir@19647 91 ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
keir@19647 92
keir@19647 93 #define list_for_each_entry(pos, head, member) \
keir@19647 94 for (pos = list_entry((head)->next, typeof(*pos), member); \
keir@19647 95 &pos->member != (head); \
keir@19647 96 pos = list_entry(pos->member.next, typeof(*pos), member))
keir@19647 97
keir@19647 98 #define list_for_each_entry_safe(pos, n, head, member) \
keir@19647 99 for (pos = list_entry((head)->next, typeof(*pos), member), \
keir@19647 100 n = list_entry(pos->member.next, typeof(*pos), member); \
keir@19647 101 &pos->member != (head); \
keir@19647 102 pos = n, n = list_entry(n->member.next, typeof(*n), member))
keir@19647 103
keir@19647 104 #endif /* __LIST_H__ */