diff options
author | Felix Fietkau <nbd@openwrt.org> | 2013-04-18 12:05:16 +0000 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2013-04-18 12:05:16 +0000 |
commit | 9d5510a500a1804484152adb8951dda3688658bc (patch) | |
tree | 6e4d8725c2956742201d0e14126f7e457b453c66 /scripts/config/list.h | |
parent | 97e7fdf6fdb8a91da52f622b499181171262af19 (diff) | |
download | mtk-20170518-9d5510a500a1804484152adb8951dda3688658bc.zip mtk-20170518-9d5510a500a1804484152adb8951dda3688658bc.tar.gz mtk-20170518-9d5510a500a1804484152adb8951dda3688658bc.tar.bz2 |
build: add new menuconfig code based on linux 3.9
SVN-Revision: 36361
Diffstat (limited to 'scripts/config/list.h')
-rw-r--r-- | scripts/config/list.h | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/scripts/config/list.h b/scripts/config/list.h new file mode 100644 index 0000000..0ae730b --- /dev/null +++ b/scripts/config/list.h @@ -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 |