Be paranoid about the definition of container_of

Replace any existing definition with a correct version, since there are
broken container_of macros floating around the xorg includes.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2012-02-15 11:58:42 +00:00
parent c0376b7f7b
commit 66cc9c6965
1 changed files with 4 additions and 22 deletions

View File

@ -266,24 +266,6 @@ list_is_empty(struct list *head)
return head->next == head;
}
/**
* Returns a pointer to the container of this list element.
*
* Example:
* struct foo* f;
* f = container_of(&foo->entry, struct foo, entry);
* assert(f == foo);
*
* @param ptr Pointer to the struct list.
* @param type Data type of the list element.
* @param member Member name of the struct list field in the list element.
* @return A pointer to the data struct containing the list head.
*/
#ifndef container_of
#define container_of(ptr, type, member) \
((type *)((char *)(ptr) - (char *) &((type *)0)->member))
#endif
/**
* Alias of container_of
*/
@ -397,14 +379,14 @@ static inline void list_move_tail(struct list *list, struct list *head)
list_add_tail(list, head);
}
#undef container_of
#define container_of(ptr, type, member) \
((type *)((char *)(ptr) - (char *) &((type *)0)->member))
#define list_last_entry(ptr, type, member) \
list_entry((ptr)->prev, type, member)
#endif
#undef container_of
#define container_of(ptr, type, member) \
((type *)((char *)(ptr) - (char *) &((type *)0)->member))
#endif /* _INTEL_LIST_H_ */