-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
menuconfig: Replace CIRCLEQ by list_head-style lists.
sys/queue.h and CIRCLEQ in particular have proven to cause portability problems (reported on Debian Sarge, Cygwin and FreeBSD) Reported-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Tested-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Tested-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net> Signed-off-by: Benjamin Poirier <bpoirier@suse.de> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr> Signed-off-by: Michal Marek <mmarek@suse.cz>
- Loading branch information
Benjamin Poirier
authored and
Michal Marek
committed
Oct 25, 2012
1 parent
ddffeb8
commit bad9955
Showing
5 changed files
with
106 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#ifndef LIST_H | ||
#define LIST_H | ||
|
||
/* | ||
* Copied from include/linux/... | ||
*/ | ||
|
||
#undef offsetof | ||
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) | ||
|
||
/** | ||
* container_of - cast a member of a structure out to the containing structure | ||
* @ptr: the pointer to the member. | ||
* @type: the type of the container struct this is embedded in. | ||
* @member: the name of the member within the struct. | ||
* | ||
*/ | ||
#define container_of(ptr, type, member) ({ \ | ||
const typeof( ((type *)0)->member ) *__mptr = (ptr); \ | ||
(type *)( (char *)__mptr - offsetof(type,member) );}) | ||
|
||
|
||
struct list_head { | ||
struct list_head *next, *prev; | ||
}; | ||
|
||
|
||
#define LIST_HEAD_INIT(name) { &(name), &(name) } | ||
|
||
#define LIST_HEAD(name) \ | ||
struct list_head name = LIST_HEAD_INIT(name) | ||
|
||
/** | ||
* list_entry - get the struct for this entry | ||
* @ptr: the &struct list_head pointer. | ||
* @type: the type of the struct this is embedded in. | ||
* @member: the name of the list_struct within the struct. | ||
*/ | ||
#define list_entry(ptr, type, member) \ | ||
container_of(ptr, type, member) | ||
|
||
/** | ||
* list_for_each_entry - iterate over list of given type | ||
* @pos: the type * to use as a loop cursor. | ||
* @head: the head for your list. | ||
* @member: the name of the list_struct within the struct. | ||
*/ | ||
#define list_for_each_entry(pos, head, member) \ | ||
for (pos = list_entry((head)->next, typeof(*pos), member); \ | ||
&pos->member != (head); \ | ||
pos = list_entry(pos->member.next, typeof(*pos), member)) | ||
|
||
/** | ||
* list_empty - tests whether a list is empty | ||
* @head: the list to test. | ||
*/ | ||
static inline int list_empty(const struct list_head *head) | ||
{ | ||
return head->next == head; | ||
} | ||
|
||
/* | ||
* Insert a new entry between two known consecutive entries. | ||
* | ||
* This is only for internal list manipulation where we know | ||
* the prev/next entries already! | ||
*/ | ||
static inline void __list_add(struct list_head *_new, | ||
struct list_head *prev, | ||
struct list_head *next) | ||
{ | ||
next->prev = _new; | ||
_new->next = next; | ||
_new->prev = prev; | ||
prev->next = _new; | ||
} | ||
|
||
/** | ||
* list_add_tail - add a new entry | ||
* @new: new entry to be added | ||
* @head: list head to add it before | ||
* | ||
* Insert a new entry before the specified head. | ||
* This is useful for implementing queues. | ||
*/ | ||
static inline void list_add_tail(struct list_head *_new, struct list_head *head) | ||
{ | ||
__list_add(_new, head->prev, head); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters