aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scripts/kconfig/expr.h5
-rw-r--r--scripts/kconfig/list.h91
-rw-r--r--scripts/kconfig/lkc_proto.h4
-rw-r--r--scripts/kconfig/mconf.c6
-rw-r--r--scripts/kconfig/menu.c14
5 files changed, 106 insertions, 14 deletions
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index bd2e09895553..cdd48600e02a 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -12,7 +12,7 @@ extern "C" {
12 12
13#include <assert.h> 13#include <assert.h>
14#include <stdio.h> 14#include <stdio.h>
15#include <sys/queue.h> 15#include "list.h"
16#ifndef __cplusplus 16#ifndef __cplusplus
17#include <stdbool.h> 17#include <stdbool.h>
18#endif 18#endif
@@ -175,12 +175,11 @@ struct menu {
175#define MENU_ROOT 0x0002 175#define MENU_ROOT 0x0002
176 176
177struct jump_key { 177struct jump_key {
178 CIRCLEQ_ENTRY(jump_key) entries; 178 struct list_head entries;
179 size_t offset; 179 size_t offset;
180 struct menu *target; 180 struct menu *target;
181 int index; 181 int index;
182}; 182};
183CIRCLEQ_HEAD(jk_head, jump_key);
184 183
185#define JUMP_NB 9 184#define JUMP_NB 9
186 185
diff --git a/scripts/kconfig/list.h b/scripts/kconfig/list.h
new file mode 100644
index 000000000000..0ae730be5f49
--- /dev/null
+++ b/scripts/kconfig/list.h
@@ -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
23struct 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 */
57static 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 */
68static 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 */
86static 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
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h
index 1d1c08537f1e..ef1a7381f956 100644
--- a/scripts/kconfig/lkc_proto.h
+++ b/scripts/kconfig/lkc_proto.h
@@ -21,9 +21,9 @@ P(menu_get_root_menu,struct menu *,(struct menu *menu));
21P(menu_get_parent_menu,struct menu *,(struct menu *menu)); 21P(menu_get_parent_menu,struct menu *,(struct menu *menu));
22P(menu_has_help,bool,(struct menu *menu)); 22P(menu_has_help,bool,(struct menu *menu));
23P(menu_get_help,const char *,(struct menu *menu)); 23P(menu_get_help,const char *,(struct menu *menu));
24P(get_symbol_str, void, (struct gstr *r, struct symbol *sym, struct jk_head 24P(get_symbol_str, void, (struct gstr *r, struct symbol *sym, struct list_head
25 *head)); 25 *head));
26P(get_relations_str, struct gstr, (struct symbol **sym_arr, struct jk_head 26P(get_relations_str, struct gstr, (struct symbol **sym_arr, struct list_head
27 *head)); 27 *head));
28P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help)); 28P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help));
29 29
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index 48f67448af7b..53975cf87608 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -312,7 +312,7 @@ static void set_config_filename(const char *config_filename)
312 312
313 313
314struct search_data { 314struct search_data {
315 struct jk_head *head; 315 struct list_head *head;
316 struct menu **targets; 316 struct menu **targets;
317 int *keys; 317 int *keys;
318}; 318};
@@ -323,7 +323,7 @@ static void update_text(char *buf, size_t start, size_t end, void *_data)
323 struct jump_key *pos; 323 struct jump_key *pos;
324 int k = 0; 324 int k = 0;
325 325
326 CIRCLEQ_FOREACH(pos, data->head, entries) { 326 list_for_each_entry(pos, data->head, entries) {
327 if (pos->offset >= start && pos->offset < end) { 327 if (pos->offset >= start && pos->offset < end) {
328 char header[4]; 328 char header[4];
329 329
@@ -375,7 +375,7 @@ again:
375 375
376 sym_arr = sym_re_search(dialog_input); 376 sym_arr = sym_re_search(dialog_input);
377 do { 377 do {
378 struct jk_head head = CIRCLEQ_HEAD_INITIALIZER(head); 378 LIST_HEAD(head);
379 struct menu *targets[JUMP_NB]; 379 struct menu *targets[JUMP_NB];
380 int keys[JUMP_NB + 1], i; 380 int keys[JUMP_NB + 1], i;
381 struct search_data data = { 381 struct search_data data = {
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index a3cade659f89..e98a05c8e508 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -508,7 +508,7 @@ const char *menu_get_help(struct menu *menu)
508} 508}
509 509
510static void get_prompt_str(struct gstr *r, struct property *prop, 510static void get_prompt_str(struct gstr *r, struct property *prop,
511 struct jk_head *head) 511 struct list_head *head)
512{ 512{
513 int i, j; 513 int i, j;
514 struct menu *submenu[8], *menu, *location = NULL; 514 struct menu *submenu[8], *menu, *location = NULL;
@@ -544,12 +544,13 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
544 } else 544 } else
545 jump->target = location; 545 jump->target = location;
546 546
547 if (CIRCLEQ_EMPTY(head)) 547 if (list_empty(head))
548 jump->index = 0; 548 jump->index = 0;
549 else 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 if (i > 0) { 556 if (i > 0) {
@@ -573,7 +574,8 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
573/* 574/*
574 * head is optional and may be NULL 575 * head is optional and may be NULL
575 */ 576 */
576void get_symbol_str(struct gstr *r, struct symbol *sym, struct jk_head *head) 577void get_symbol_str(struct gstr *r, struct symbol *sym,
578 struct list_head *head)
577{ 579{
578 bool hit; 580 bool hit;
579 struct property *prop; 581 struct property *prop;
@@ -612,7 +614,7 @@ void get_symbol_str(struct gstr *r, struct symbol *sym, struct jk_head *head)
612 str_append(r, "\n\n"); 614 str_append(r, "\n\n");
613} 615}
614 616
615struct gstr get_relations_str(struct symbol **sym_arr, struct jk_head *head) 617struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head)
616{ 618{
617 struct symbol *sym; 619 struct symbol *sym;
618 struct gstr res = str_new(); 620 struct gstr res = str_new();