X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Finclude%2Fpalacios%2Fvmm_list.h;h=f1e878f5a616104e61fee4deb5c99ffe60dd08f3;hb=58ea47f1e53d66fae94afb18a314bdfd8862948e;hp=da7a0b2340bbb4059632b9371fe3484d5522c8a7;hpb=df58bd3c484a52b1e166dc28e7b9b6fd94e5a023;p=palacios.git diff --git a/palacios/include/palacios/vmm_list.h b/palacios/include/palacios/vmm_list.h index da7a0b2..f1e878f 100644 --- a/palacios/include/palacios/vmm_list.h +++ b/palacios/include/palacios/vmm_list.h @@ -1,6 +1,13 @@ +/* Stolen From Linux list implementation */ +/* 2008, Modifications by Jack Lange */ + + #ifndef _VMM_LIST_H #define _VMM_LIST_H + +#ifdef __V3VEE__ + #include #undef offsetof @@ -12,7 +19,7 @@ (type *)( (char *)__mptr - offsetof(type,member) );}) -static inline void prefetch(const void *x) {;} +static inline void prefetch(const void *x) {const void * foo; foo = x;} /* * These are non-NULL pointers that will result in page faults @@ -226,6 +233,53 @@ static inline void list_splice_init(struct list_head *list, container_of(ptr, type, member) /** + * list_entry - get the struct for the tail entry + * @ptr: the list_head head pointer. + * @type: the type of the struct this is embedded in. + * @member: the name of the list_struct within the struct. + */ +#define list_tail_entry(head, type, member) ({ \ + type * tail = NULL; \ + if ((head)->prev != (head)) { \ + tail = list_entry((head)->prev, type, member); \ + } \ + tail; \ +}) + +/** + * list_first_entry - get the struct for the first entry + * @ptr: the list_head head pointer. + * @type: the type of the struct this is embedded in. + * @member: the name of the list_struct within the struct. + */ +#define list_first_entry(head, type, member) \ +({ \ + type * first = NULL; \ + if ((head)->next != (head)) { \ + first = list_entry((head)->next, type, member); \ + } \ + first; \ + }) + + + +/** + * list_next_entry -- get the struct for the next entry in a list + * @ptr: current list entry + * @type: type of the struct this is embedded in + * @member: name of the list struct within the struct + */ +#define list_next_entry(node, type, member) \ + ({ \ + type * next = NULL; \ + if ((node)->next != (node)) { \ + next = list_entry((node)->next, type, member); \ + } \ + next; \ + }) + + +/** * list_for_each - iterate over a list * @pos: the &struct list_head to use as a loop counter. * @head: the head for your list. @@ -525,4 +579,7 @@ static inline void hlist_add_after(struct hlist_node *n, pos = n) + +#endif // ! __V3VEE__ + #endif