Pull menuconfig portability fix from Michal Marek: "Here is a fix for v3.7 that makes menuconfig compile again on systems whose C library is lacking CIRCLEQ_* macros. I thought I sent it earlier, but apparently I did not." * 'rc-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild: menuconfig: Replace CIRCLEQ by list_head-style lists.
Unified · Split
| @@ -12,7 +12,7 @@ extern "C" { · 11 unmodified lines | ||
| 12 | 12 | |
| 13 | 13 | #include <assert.h> |
| 14 | 14 | #include <stdio.h> |
| 15 | −#include <sys/queue.h> | |
| 15 | +#include "list.h" | |
| 16 | 16 | #ifndef __cplusplus |
| 17 | 17 | #include <stdbool.h> |
| 18 | 18 | #endif |
| @@ -175,12 +175,11 @@ struct menu { · 156 unmodified lines | ||
| 175 | 175 | #define MENU_ROOT 0x0002 |
| 176 | 176 | |
| 177 | 177 | struct jump_key { |
| 178 | − CIRCLEQ_ENTRY(jump_key) entries; | |
| 178 | + struct list_head entries; | |
| 179 | 179 | size_t offset; |
| 180 | 180 | struct menu *target; |
| 181 | 181 | int index; |
| 182 | 182 | }; |
| 183 | −CIRCLEQ_HEAD(jk_head, jump_key); | |
| 184 | 183 | |
| 185 | 184 | #define JUMP_NB 9 |
| 186 | 185 | |
| @@ -0,0 +1,91 @@ | ||
| 1 | +#ifndef LIST_H | |
| 2 | +#define LIST_H | |
| 3 | + | |
| 4 | +/* | |
| 5 | + * Copied from include/linux/... | |
| 6 | + */ | |
| 7 | + | |
| 8 | +#undef offsetof | |
| 9 | +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * container_of - cast a member of a structure out to the containing structure | |
| 13 | + * @ptr: the pointer to the member. | |
| 14 | + * @type: the type of the container struct this is embedded in. | |
| 15 | + * @member: the name of the member within the struct. | |
| 16 | + * | |
| 17 | + */ | |
| 18 | +#define container_of(ptr, type, member) ({ \ | |
| 19 | + const typeof( ((type *)0)->member ) *__mptr = (ptr); \ | |
| 20 | + (type *)( (char *)__mptr - offsetof(type,member) );}) | |
| 21 | + | |
| 22 | + | |
| 23 | +struct list_head { | |
| 24 | + struct list_head *next, *prev; | |
| 25 | +}; | |
| 26 | + | |
| 27 | + | |
| 28 | +#define LIST_HEAD_INIT(name) { &(name), &(name) } | |
| 29 | + | |
| 30 | +#define LIST_HEAD(name) \ | |
| 31 | + struct list_head name = LIST_HEAD_INIT(name) | |
| 32 | + | |
| 33 | +/** | |
| 34 | + * list_entry - get the struct for this entry | |
| 35 | + * @ptr: the &struct list_head pointer. | |
| 36 | + * @type: the type of the struct this is embedded in. | |
| 37 | + * @member: the name of the list_struct within the struct. | |
| 38 | + */ | |
| 39 | +#define list_entry(ptr, type, member) \ | |
| 40 | + container_of(ptr, type, member) | |
| 41 | + | |
| 42 | +/** | |
| 43 | + * list_for_each_entry - iterate over list of given type | |
| 44 | + * @pos: the type * to use as a loop cursor. | |
| 45 | + * @head: the head for your list. | |
| 46 | + * @member: the name of the list_struct within the struct. | |
| 47 | + */ | |
| 48 | +#define list_for_each_entry(pos, head, member) \ | |
| 49 | + for (pos = list_entry((head)->next, typeof(*pos), member); \ | |
| 50 | + &pos->member != (head); \ | |
| 51 | + pos = list_entry(pos->member.next, typeof(*pos), member)) | |
| 52 | + | |
| 53 | +/** | |
| 54 | + * list_empty - tests whether a list is empty | |
| 55 | + * @head: the list to test. | |
| 56 | + */ | |
| 57 | +static inline int list_empty(const struct list_head *head) | |
| 58 | +{ | |
| 59 | + return head->next == head; | |
| 60 | +} | |
| 61 | + | |
| 62 | +/* | |
| 63 | + * Insert a new entry between two known consecutive entries. | |
| 64 | + * | |
| 65 | + * This is only for internal list manipulation where we know | |
| 66 | + * the prev/next entries already! | |
| 67 | + */ | |
| 68 | +static inline void __list_add(struct list_head *_new, | |
| 69 | + struct list_head *prev, | |
| 70 | + struct list_head *next) | |
| 71 | +{ | |
| 72 | + next->prev = _new; | |
| 73 | + _new->next = next; | |
| 74 | + _new->prev = prev; | |
| 75 | + prev->next = _new; | |
| 76 | +} | |
| 77 | + | |
| 78 | +/** | |
| 79 | + * list_add_tail - add a new entry | |
| 80 | + * @new: new entry to be added | |
| 81 | + * @head: list head to add it before | |
| 82 | + * | |
| 83 | + * Insert a new entry before the specified head. | |
| 84 | + * This is useful for implementing queues. | |
| 85 | + */ | |
| 86 | +static inline void list_add_tail(struct list_head *_new, struct list_head *head) | |
| 87 | +{ | |
| 88 | + __list_add(_new, head->prev, head); | |
| 89 | +} | |
| 90 | + | |
| 91 | +#endif | |
| @@ -21,9 +21,9 @@ P(menu_get_root_menu,struct menu *,(struct menu *menu)); · 20 unmodified lines | ||
| 21 | 21 | P(menu_get_parent_menu,struct menu *,(struct menu *menu)); |
| 22 | 22 | P(menu_has_help,bool,(struct menu *menu)); |
| 23 | 23 | P(menu_get_help,const char *,(struct menu *menu)); |
| 24 | −P(get_symbol_str, void, (struct gstr *r, struct symbol *sym, struct jk_head | |
| 24 | +P(get_symbol_str, void, (struct gstr *r, struct symbol *sym, struct list_head | |
| 25 | 25 | *head)); |
| 26 | −P(get_relations_str, struct gstr, (struct symbol **sym_arr, struct jk_head | |
| 26 | +P(get_relations_str, struct gstr, (struct symbol **sym_arr, struct list_head | |
| 27 | 27 | *head)); |
| 28 | 28 | P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help)); |
| 29 | 29 | |
| @@ -312,7 +312,7 @@ static void set_config_filename(const char *config_filename) · 311 unmodified lines | ||
| 312 | 312 | |
| 313 | 313 | |
| 314 | 314 | struct search_data { |
| 315 | − struct jk_head *head; | |
| 315 | + struct list_head *head; | |
| 316 | 316 | struct menu **targets; |
| 317 | 317 | int *keys; |
| 318 | 318 | }; |
| @@ -323,7 +323,7 @@ static void update_text(char *buf, size_t start, size_t end, void *_data) · 4 unmodified lines | ||
| 323 | 323 | struct jump_key *pos; |
| 324 | 324 | int k = 0; |
| 325 | 325 | |
| 326 | − CIRCLEQ_FOREACH(pos, data->head, entries) { | |
| 326 | + list_for_each_entry(pos, data->head, entries) { | |
| 327 | 327 | if (pos->offset >= start && pos->offset < end) { |
| 328 | 328 | char header[4]; |
| 329 | 329 | |
| @@ -375,7 +375,7 @@ again: · 45 unmodified lines | ||
| 375 | 375 | |
| 376 | 376 | sym_arr = sym_re_search(dialog_input); |
| 377 | 377 | do { |
| 378 | − struct jk_head head = CIRCLEQ_HEAD_INITIALIZER(head); | |
| 378 | + LIST_HEAD(head); | |
| 379 | 379 | struct menu *targets[JUMP_NB]; |
| 380 | 380 | int keys[JUMP_NB + 1], i; |
| 381 | 381 | struct search_data data = { |
| @@ -508,7 +508,7 @@ const char *menu_get_help(struct menu *menu) · 507 unmodified lines | ||
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | static void get_prompt_str(struct gstr *r, struct property *prop, |
| 511 | − struct jk_head *head) | |
| 511 | + struct list_head *head) | |
| 512 | 512 | { |
| 513 | 513 | int i, j; |
| 514 | 514 | struct menu *submenu[8], *menu, *location = NULL; |
| @@ -544,12 +544,13 @@ static void get_prompt_str(struct gstr *r, struct property *prop, · 29 unmodified lines | ||
| 544 | 544 | } else |
| 545 | 545 | jump->target = location; |
| 546 | 546 | |
| 547 | − if (CIRCLEQ_EMPTY(head)) | |
| 547 | + if (list_empty(head)) | |
| 548 | 548 | jump->index = 0; |
| 549 | 549 | else |
| 550 | − jump->index = CIRCLEQ_LAST(head)->index + 1; | |
| 550 | + jump->index = list_entry(head->prev, struct jump_key, | |
| 551 | + entries)->index + 1; | |
| 551 | 552 | |
| 552 | − CIRCLEQ_INSERT_TAIL(head, jump, entries); | |
| 553 | + list_add_tail(&jump->entries, head); | |
| 553 | 554 | } |
| 554 | 555 | |
| 555 | 556 | if (i > 0) { |
| @@ -573,7 +574,8 @@ static void get_prompt_str(struct gstr *r, struct property *prop, · 17 unmodified lines | ||
| 573 | 574 | /* |
| 574 | 575 | * head is optional and may be NULL |
| 575 | 576 | */ |
| 576 | −void get_symbol_str(struct gstr *r, struct symbol *sym, struct jk_head *head) | |
| 577 | +void get_symbol_str(struct gstr *r, struct symbol *sym, | |
| 578 | + struct list_head *head) | |
| 577 | 579 | { |
| 578 | 580 | bool hit; |
| 579 | 581 | struct property *prop; |
| @@ -612,7 +614,7 @@ void get_symbol_str(struct gstr *r, struct symbol *sym, struct jk_head *head) · 32 unmodified lines | ||
| 612 | 614 | str_append(r, "\n\n"); |
| 613 | 615 | } |
| 614 | 616 | |
| 615 | −struct gstr get_relations_str(struct symbol **sym_arr, struct jk_head *head) | |
| 617 | +struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head) | |
| 616 | 618 | { |
| 617 | 619 | struct symbol *sym; |
| 618 | 620 | struct gstr res = str_new(); |