History

Merge branch 'rc-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild

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.

Linus Torvalds committed 14 years ago

Commit 70c80df2 parents 9dce781 bad99555 files · +106 −14Browse files

Showing the changes to scripts (5 of 5 files). Show all

Unified · Split

5 files
  1. scripts/kconfig/expr.h +2 −3
  2. scripts/kconfig/list.h +91 −0
  3. scripts/kconfig/lkc_proto.h +2 −2
  4. scripts/kconfig/mconf.c +3 −3
  5. scripts/kconfig/menu.c +8 −6
scripts/kconfig/expr.h+2−3
@@ -12,7 +12,7 @@ extern "C" { · 11 unmodified lines
1212
1313 #include <assert.h>
1414 #include <stdio.h>
15−#include <sys/queue.h>
15+#include "list.h"
1616 #ifndef __cplusplus
1717 #include <stdbool.h>
1818 #endif
@@ -175,12 +175,11 @@ struct menu { · 156 unmodified lines
175175 #define MENU_ROOT 0x0002
176176
177177 struct jump_key {
178− CIRCLEQ_ENTRY(jump_key) entries;
178+ struct list_head entries;
179179 size_t offset;
180180 struct menu *target;
181181 int index;
182182 };
183−CIRCLEQ_HEAD(jk_head, jump_key);
184183
185184 #define JUMP_NB 9
186185
scripts/kconfig/list.h+91−0
@@ -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
scripts/kconfig/lkc_proto.h+2−2
@@ -21,9 +21,9 @@ P(menu_get_root_menu,struct menu *,(struct menu *menu)); · 20 unmodified lines
2121 P(menu_get_parent_menu,struct menu *,(struct menu *menu));
2222 P(menu_has_help,bool,(struct menu *menu));
2323 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
2525 *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
2727 *head));
2828 P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help));
2929
scripts/kconfig/mconf.c+3−3
@@ -312,7 +312,7 @@ static void set_config_filename(const char *config_filename) · 311 unmodified lines
312312
313313
314314 struct search_data {
315− struct jk_head *head;
315+ struct list_head *head;
316316 struct menu **targets;
317317 int *keys;
318318 };
@@ -323,7 +323,7 @@ static void update_text(char *buf, size_t start, size_t end, void *_data) · 4 unmodified lines
323323 struct jump_key *pos;
324324 int k = 0;
325325
326− CIRCLEQ_FOREACH(pos, data->head, entries) {
326+ list_for_each_entry(pos, data->head, entries) {
327327 if (pos->offset >= start && pos->offset < end) {
328328 char header[4];
329329
@@ -375,7 +375,7 @@ again: · 45 unmodified lines
375375
376376 sym_arr = sym_re_search(dialog_input);
377377 do {
378− struct jk_head head = CIRCLEQ_HEAD_INITIALIZER(head);
378+ LIST_HEAD(head);
379379 struct menu *targets[JUMP_NB];
380380 int keys[JUMP_NB + 1], i;
381381 struct search_data data = {
scripts/kconfig/menu.c+8−6
@@ -508,7 +508,7 @@ const char *menu_get_help(struct menu *menu) · 507 unmodified lines
508508 }
509509
510510 static void get_prompt_str(struct gstr *r, struct property *prop,
511− struct jk_head *head)
511+ struct list_head *head)
512512 {
513513 int i, j;
514514 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
544544 } else
545545 jump->target = location;
546546
547− if (CIRCLEQ_EMPTY(head))
547+ if (list_empty(head))
548548 jump->index = 0;
549549 else
550− jump->index = CIRCLEQ_LAST(head)->index + 1;
550+ jump->index = list_entry(head->prev, struct jump_key,
551+ entries)->index + 1;
551552
552− CIRCLEQ_INSERT_TAIL(head, jump, entries);
553+ list_add_tail(&jump->entries, head);
553554 }
554555
555556 if (i > 0) {
@@ -573,7 +574,8 @@ static void get_prompt_str(struct gstr *r, struct property *prop, · 17 unmodified lines
573574 /*
574575 * head is optional and may be NULL
575576 */
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)
577579 {
578580 bool hit;
579581 struct property *prop;
@@ -612,7 +614,7 @@ void get_symbol_str(struct gstr *r, struct symbol *sym, struct jk_head *head) · 32 unmodified lines
612614 str_append(r, "\n\n");
613615 }
614616
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)
616618 {
617619 struct symbol *sym;
618620 struct gstr res = str_new();