2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0.
10 #include <sys/utsname.h>
14 struct symbol symbol_yes = {
17 .flags = SYMBOL_CONST|SYMBOL_VALID,
21 .flags = SYMBOL_CONST|SYMBOL_VALID,
25 .flags = SYMBOL_CONST|SYMBOL_VALID,
29 .flags = SYMBOL_VALID,
32 struct symbol *sym_defconfig_list;
33 struct symbol *modules_sym;
36 enum symbol_type sym_get_type(struct symbol *sym)
38 enum symbol_type type = sym->type;
40 if (type == S_TRISTATE) {
41 if (sym_is_choice_value(sym) && sym->visible == yes)
43 else if (modules_val == no)
49 const char *sym_type_name(enum symbol_type type)
70 struct property *sym_get_choice_prop(struct symbol *sym)
72 struct property *prop;
74 for_all_choices(sym, prop)
79 static struct property *sym_get_default_prop(struct symbol *sym)
81 struct property *prop;
83 for_all_defaults(sym, prop) {
84 prop->visible.tri = expr_calc_value(prop->visible.expr);
85 if (prop->visible.tri != no)
91 static struct property *sym_get_range_prop(struct symbol *sym)
93 struct property *prop;
95 for_all_properties(sym, prop, P_RANGE) {
96 prop->visible.tri = expr_calc_value(prop->visible.expr);
97 if (prop->visible.tri != no)
103 static long long sym_get_range_val(struct symbol *sym, int base)
116 return strtoll(sym->curr.val, NULL, base);
119 static void sym_validate_range(struct symbol *sym)
121 struct property *prop;
136 prop = sym_get_range_prop(sym);
139 val = strtoll(sym->curr.val, NULL, base);
140 val2 = sym_get_range_val(prop->expr->left.sym, base);
142 val2 = sym_get_range_val(prop->expr->right.sym, base);
146 if (sym->type == S_INT)
147 sprintf(str, "%lld", val2);
149 sprintf(str, "0x%llx", val2);
150 sym->curr.val = xstrdup(str);
153 static void sym_set_changed(struct symbol *sym)
155 struct property *prop;
157 sym->flags |= SYMBOL_CHANGED;
158 for (prop = sym->prop; prop; prop = prop->next) {
160 prop->menu->flags |= MENU_CHANGED;
164 static void sym_set_all_changed(void)
169 for_all_symbols(i, sym)
170 sym_set_changed(sym);
173 static void sym_calc_visibility(struct symbol *sym)
175 struct property *prop;
176 struct symbol *choice_sym = NULL;
179 /* any prompt visible? */
182 if (sym_is_choice_value(sym))
183 choice_sym = prop_get_symbol(sym_get_choice_prop(sym));
185 for_all_prompts(sym, prop) {
186 prop->visible.tri = expr_calc_value(prop->visible.expr);
188 * Tristate choice_values with visibility 'mod' are
189 * not visible if the corresponding choice's value is
192 if (choice_sym && sym->type == S_TRISTATE &&
193 prop->visible.tri == mod && choice_sym->curr.tri == yes)
194 prop->visible.tri = no;
196 tri = EXPR_OR(tri, prop->visible.tri);
198 if (tri == mod && (sym->type != S_TRISTATE || modules_val == no))
200 if (sym->visible != tri) {
202 sym_set_changed(sym);
204 if (sym_is_choice_value(sym))
206 /* defaulting to "yes" if no explicit "depends on" are given */
208 if (sym->dir_dep.expr)
209 tri = expr_calc_value(sym->dir_dep.expr);
210 if (tri == mod && sym_get_type(sym) == S_BOOLEAN)
212 if (sym->dir_dep.tri != tri) {
213 sym->dir_dep.tri = tri;
214 sym_set_changed(sym);
217 if (sym->rev_dep.expr)
218 tri = expr_calc_value(sym->rev_dep.expr);
219 if (tri == mod && sym_get_type(sym) == S_BOOLEAN)
221 if (sym->rev_dep.tri != tri) {
222 sym->rev_dep.tri = tri;
223 sym_set_changed(sym);
226 if (sym->implied.expr && sym->dir_dep.tri != no)
227 tri = expr_calc_value(sym->implied.expr);
228 if (tri == mod && sym_get_type(sym) == S_BOOLEAN)
230 if (sym->implied.tri != tri) {
231 sym->implied.tri = tri;
232 sym_set_changed(sym);
237 * Find the default symbol for a choice.
238 * First try the default values for the choice symbol
239 * Next locate the first visible choice value
240 * Return NULL if none was found
242 struct symbol *sym_choice_default(struct symbol *sym)
244 struct symbol *def_sym;
245 struct property *prop;
248 /* any of the defaults visible? */
249 for_all_defaults(sym, prop) {
250 prop->visible.tri = expr_calc_value(prop->visible.expr);
251 if (prop->visible.tri == no)
253 def_sym = prop_get_symbol(prop);
254 if (def_sym->visible != no)
258 /* just get the first visible value */
259 prop = sym_get_choice_prop(sym);
260 expr_list_for_each_sym(prop->expr, e, def_sym)
261 if (def_sym->visible != no)
264 /* failed to locate any defaults */
268 static struct symbol *sym_calc_choice(struct symbol *sym)
270 struct symbol *def_sym;
271 struct property *prop;
275 /* first calculate all choice values' visibilities */
277 prop = sym_get_choice_prop(sym);
278 expr_list_for_each_sym(prop->expr, e, def_sym) {
279 sym_calc_visibility(def_sym);
280 if (def_sym->visible != no)
281 flags &= def_sym->flags;
284 sym->flags &= flags | ~SYMBOL_DEF_USER;
286 /* is the user choice visible? */
287 def_sym = sym->def[S_DEF_USER].val;
288 if (def_sym && def_sym->visible != no)
291 def_sym = sym_choice_default(sym);
294 /* no choice? reset tristate value */
300 static void sym_warn_unmet_dep(struct symbol *sym)
302 struct gstr gs = str_new();
305 "\nWARNING: unmet direct dependencies detected for %s\n",
308 " Depends on [%c]: ",
309 sym->dir_dep.tri == mod ? 'm' : 'n');
310 expr_gstr_print(sym->dir_dep.expr, &gs);
311 str_printf(&gs, "\n");
313 expr_gstr_print_revdep(sym->rev_dep.expr, &gs, yes,
314 " Selected by [y]:\n");
315 expr_gstr_print_revdep(sym->rev_dep.expr, &gs, mod,
316 " Selected by [m]:\n");
318 fputs(str_get(&gs), stderr);
321 void sym_calc_value(struct symbol *sym)
323 struct symbol_value newval, oldval;
324 struct property *prop;
330 if (sym->flags & SYMBOL_VALID)
333 if (sym_is_choice_value(sym) &&
334 sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES) {
335 sym->flags &= ~SYMBOL_NEED_SET_CHOICE_VALUES;
336 prop = sym_get_choice_prop(sym);
337 sym_calc_value(prop_get_symbol(prop));
340 sym->flags |= SYMBOL_VALID;
348 newval = symbol_empty.curr;
352 newval = symbol_no.curr;
355 sym->curr.val = sym->name;
359 sym->flags &= ~SYMBOL_WRITE;
361 sym_calc_visibility(sym);
363 if (sym->visible != no)
364 sym->flags |= SYMBOL_WRITE;
366 /* set default if recursively called */
369 switch (sym_get_type(sym)) {
372 if (sym_is_choice_value(sym) && sym->visible == yes) {
373 prop = sym_get_choice_prop(sym);
374 newval.tri = (prop_get_symbol(prop)->curr.val == sym) ? yes : no;
376 if (sym->visible != no) {
377 /* if the symbol is visible use the user value
378 * if available, otherwise try the default value
380 if (sym_has_value(sym)) {
381 newval.tri = EXPR_AND(sym->def[S_DEF_USER].tri,
386 if (sym->rev_dep.tri != no)
387 sym->flags |= SYMBOL_WRITE;
388 if (!sym_is_choice(sym)) {
389 prop = sym_get_default_prop(sym);
391 newval.tri = EXPR_AND(expr_calc_value(prop->expr),
393 if (newval.tri != no)
394 sym->flags |= SYMBOL_WRITE;
396 if (sym->implied.tri != no) {
397 sym->flags |= SYMBOL_WRITE;
398 newval.tri = EXPR_OR(newval.tri, sym->implied.tri);
402 if (sym->dir_dep.tri < sym->rev_dep.tri)
403 sym_warn_unmet_dep(sym);
404 newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri);
406 if (newval.tri == mod &&
407 (sym_get_type(sym) == S_BOOLEAN || sym->implied.tri == yes))
413 if (sym->visible != no && sym_has_value(sym)) {
414 newval.val = sym->def[S_DEF_USER].val;
417 prop = sym_get_default_prop(sym);
419 struct symbol *ds = prop_get_symbol(prop);
421 sym->flags |= SYMBOL_WRITE;
423 newval.val = ds->curr.val;
432 if (sym_is_choice(sym) && newval.tri == yes)
433 sym->curr.val = sym_calc_choice(sym);
434 sym_validate_range(sym);
436 if (memcmp(&oldval, &sym->curr, sizeof(oldval))) {
437 sym_set_changed(sym);
438 if (modules_sym == sym) {
439 sym_set_all_changed();
440 modules_val = modules_sym->curr.tri;
444 if (sym_is_choice(sym)) {
445 struct symbol *choice_sym;
447 prop = sym_get_choice_prop(sym);
448 expr_list_for_each_sym(prop->expr, e, choice_sym) {
449 if ((sym->flags & SYMBOL_WRITE) &&
450 choice_sym->visible != no)
451 choice_sym->flags |= SYMBOL_WRITE;
452 if (sym->flags & SYMBOL_CHANGED)
453 sym_set_changed(choice_sym);
457 if (sym->flags & SYMBOL_NO_WRITE)
458 sym->flags &= ~SYMBOL_WRITE;
460 if (sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES)
461 set_all_choice_values(sym);
464 void sym_clear_all_valid(void)
469 for_all_symbols(i, sym)
470 sym->flags &= ~SYMBOL_VALID;
471 sym_add_change_count(1);
472 sym_calc_value(modules_sym);
475 bool sym_tristate_within_range(struct symbol *sym, tristate val)
477 int type = sym_get_type(sym);
479 if (sym->visible == no)
482 if (type != S_BOOLEAN && type != S_TRISTATE)
485 if (type == S_BOOLEAN && val == mod)
487 if (sym->visible <= sym->rev_dep.tri)
489 if (sym->implied.tri == yes && val == mod)
491 if (sym_is_choice_value(sym) && sym->visible == yes)
493 return val >= sym->rev_dep.tri && val <= sym->visible;
496 bool sym_set_tristate_value(struct symbol *sym, tristate val)
498 tristate oldval = sym_get_tristate_value(sym);
500 if (oldval != val && !sym_tristate_within_range(sym, val))
503 if (!(sym->flags & SYMBOL_DEF_USER)) {
504 sym->flags |= SYMBOL_DEF_USER;
505 sym_set_changed(sym);
508 * setting a choice value also resets the new flag of the choice
509 * symbol and all other choice values.
511 if (sym_is_choice_value(sym) && val == yes) {
512 struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym));
513 struct property *prop;
516 cs->def[S_DEF_USER].val = sym;
517 cs->flags |= SYMBOL_DEF_USER;
518 prop = sym_get_choice_prop(cs);
519 for (e = prop->expr; e; e = e->left.expr) {
520 if (e->right.sym->visible != no)
521 e->right.sym->flags |= SYMBOL_DEF_USER;
525 sym->def[S_DEF_USER].tri = val;
527 sym_clear_all_valid();
532 tristate sym_toggle_tristate_value(struct symbol *sym)
534 tristate oldval, newval;
536 oldval = newval = sym_get_tristate_value(sym);
549 if (sym_set_tristate_value(sym, newval))
551 } while (oldval != newval);
555 bool sym_string_valid(struct symbol *sym, const char *str)
568 if (ch == '0' && *str != 0)
570 while ((ch = *str++)) {
576 if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X'))
582 } while ((ch = *str++));
598 bool sym_string_within_range(struct symbol *sym, const char *str)
600 struct property *prop;
605 return sym_string_valid(sym, str);
607 if (!sym_string_valid(sym, str))
609 prop = sym_get_range_prop(sym);
612 val = strtoll(str, NULL, 10);
613 return val >= sym_get_range_val(prop->expr->left.sym, 10) &&
614 val <= sym_get_range_val(prop->expr->right.sym, 10);
616 if (!sym_string_valid(sym, str))
618 prop = sym_get_range_prop(sym);
621 val = strtoll(str, NULL, 16);
622 return val >= sym_get_range_val(prop->expr->left.sym, 16) &&
623 val <= sym_get_range_val(prop->expr->right.sym, 16);
628 return sym_tristate_within_range(sym, yes);
630 return sym_tristate_within_range(sym, mod);
632 return sym_tristate_within_range(sym, no);
640 bool sym_set_string_value(struct symbol *sym, const char *newval)
651 return sym_set_tristate_value(sym, yes);
653 return sym_set_tristate_value(sym, mod);
655 return sym_set_tristate_value(sym, no);
662 if (!sym_string_within_range(sym, newval))
665 if (!(sym->flags & SYMBOL_DEF_USER)) {
666 sym->flags |= SYMBOL_DEF_USER;
667 sym_set_changed(sym);
670 oldval = sym->def[S_DEF_USER].val;
671 size = strlen(newval) + 1;
672 if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) {
674 sym->def[S_DEF_USER].val = val = xmalloc(size);
677 } else if (!oldval || strcmp(oldval, newval))
678 sym->def[S_DEF_USER].val = val = xmalloc(size);
683 free((void *)oldval);
684 sym_clear_all_valid();
690 * Find the default value associated to a symbol.
691 * For tristate symbol handle the modules=n case
692 * in which case "m" becomes "y".
693 * If the symbol does not have any default then fallback
694 * to the fixed default values.
696 const char *sym_get_string_default(struct symbol *sym)
698 struct property *prop;
703 sym_calc_visibility(sym);
704 sym_calc_value(modules_sym);
705 val = symbol_no.curr.tri;
706 str = symbol_empty.curr.val;
708 /* If symbol has a default value look it up */
709 prop = sym_get_default_prop(sym);
714 /* The visibility may limit the value from yes => mod */
715 val = EXPR_AND(expr_calc_value(prop->expr), prop->visible.tri);
719 * The following fails to handle the situation
720 * where a default value is further limited by
723 ds = prop_get_symbol(prop);
726 str = (const char *)ds->curr.val;
731 /* Handle select statements */
732 val = EXPR_OR(val, sym->rev_dep.tri);
734 /* transpose mod to yes if modules are not enabled */
736 if (!sym_is_choice_value(sym) && modules_sym->curr.tri == no)
739 /* transpose mod to yes if type is bool */
740 if (sym->type == S_BOOLEAN && val == mod)
743 /* adjust the default value if this symbol is implied by another */
744 if (val < sym->implied.tri)
745 val = sym->implied.tri;
752 case mod: return "m";
753 case yes: return "y";
767 const char *sym_get_string_value(struct symbol *sym)
774 val = sym_get_tristate_value(sym);
779 sym_calc_value(modules_sym);
780 return (modules_sym->curr.tri == no) ? "n" : "m";
788 return (const char *)sym->curr.val;
791 bool sym_is_changable(struct symbol *sym)
793 return sym->visible > sym->rev_dep.tri;
796 static unsigned strhash(const char *s)
799 unsigned hash = 2166136261U;
801 hash = (hash ^ *s) * 0x01000193;
805 struct symbol *sym_lookup(const char *name, int flags)
807 struct symbol *symbol;
812 if (name[0] && !name[1]) {
814 case 'y': return &symbol_yes;
815 case 'm': return &symbol_mod;
816 case 'n': return &symbol_no;
819 hash = strhash(name) % SYMBOL_HASHSIZE;
821 for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) {
823 !strcmp(symbol->name, name) &&
824 (flags ? symbol->flags & flags
825 : !(symbol->flags & (SYMBOL_CONST|SYMBOL_CHOICE))))
828 new_name = xstrdup(name);
834 symbol = xmalloc(sizeof(*symbol));
835 memset(symbol, 0, sizeof(*symbol));
836 symbol->name = new_name;
837 symbol->type = S_UNKNOWN;
838 symbol->flags |= flags;
840 symbol->next = symbol_hash[hash];
841 symbol_hash[hash] = symbol;
846 struct symbol *sym_find(const char *name)
848 struct symbol *symbol = NULL;
854 if (name[0] && !name[1]) {
856 case 'y': return &symbol_yes;
857 case 'm': return &symbol_mod;
858 case 'n': return &symbol_no;
861 hash = strhash(name) % SYMBOL_HASHSIZE;
863 for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) {
865 !strcmp(symbol->name, name) &&
866 !(symbol->flags & SYMBOL_CONST))
873 const char *sym_escape_string_value(const char *in)
880 reslen = strlen(in) + strlen("\"\"") + 1;
884 l = strcspn(p, "\"\\");
894 res = xmalloc(reslen);
901 l = strcspn(p, "\"\\");
909 strncat(res, p++, 1);
921 /* Compare matched symbols as thus:
922 * - first, symbols that match exactly
923 * - then, alphabetical sort
925 static int sym_rel_comp(const void *sym1, const void *sym2)
927 const struct sym_match *s1 = sym1;
928 const struct sym_match *s2 = sym2;
932 * - if matched length on symbol s1 is the length of that symbol,
933 * then this symbol should come first;
934 * - if matched length on symbol s2 is the length of that symbol,
935 * then this symbol should come first.
936 * Note: since the search can be a regexp, both symbols may match
937 * exactly; if this is the case, we can't decide which comes first,
938 * and we fallback to sorting alphabetically.
940 exact1 = (s1->eo - s1->so) == strlen(s1->sym->name);
941 exact2 = (s2->eo - s2->so) == strlen(s2->sym->name);
942 if (exact1 && !exact2)
944 if (!exact1 && exact2)
947 /* As a fallback, sort symbols alphabetically */
948 return strcmp(s1->sym->name, s2->sym->name);
951 struct symbol **sym_re_search(const char *pattern)
953 struct symbol *sym, **sym_arr = NULL;
954 struct sym_match *sym_match_arr = NULL;
961 if (strlen(pattern) == 0)
963 if (regcomp(&re, pattern, REG_EXTENDED|REG_ICASE))
966 for_all_symbols(i, sym) {
967 if (sym->flags & SYMBOL_CONST || !sym->name)
969 if (regexec(&re, sym->name, 1, match, 0))
974 tmp = realloc(sym_match_arr, size * sizeof(struct sym_match));
976 goto sym_re_search_free;
980 /* As regexec returned 0, we know we have a match, so
981 * we can use match[0].rm_[se]o without further checks
983 sym_match_arr[cnt].so = match[0].rm_so;
984 sym_match_arr[cnt].eo = match[0].rm_eo;
985 sym_match_arr[cnt++].sym = sym;
988 qsort(sym_match_arr, cnt, sizeof(struct sym_match), sym_rel_comp);
989 sym_arr = malloc((cnt+1) * sizeof(struct symbol *));
991 goto sym_re_search_free;
992 for (i = 0; i < cnt; i++)
993 sym_arr[i] = sym_match_arr[i].sym;
997 /* sym_match_arr can be NULL if no match, but free(NULL) is OK */
1005 * When we check for recursive dependencies we use a stack to save
1006 * current state so we can print out relevant info to user.
1007 * The entries are located on the call stack so no need to free memory.
1008 * Note insert() remove() must always match to properly clear the stack.
1010 static struct dep_stack {
1011 struct dep_stack *prev, *next;
1013 struct property *prop;
1017 static void dep_stack_insert(struct dep_stack *stack, struct symbol *sym)
1019 memset(stack, 0, sizeof(*stack));
1021 check_top->next = stack;
1022 stack->prev = check_top;
1027 static void dep_stack_remove(void)
1029 check_top = check_top->prev;
1031 check_top->next = NULL;
1035 * Called when we have detected a recursive dependency.
1036 * check_top point to the top of the stact so we use
1037 * the ->prev pointer to locate the bottom of the stack.
1039 static void sym_check_print_recursive(struct symbol *last_sym)
1041 struct dep_stack *stack;
1042 struct symbol *sym, *next_sym;
1043 struct menu *menu = NULL;
1044 struct property *prop;
1045 struct dep_stack cv_stack;
1047 if (sym_is_choice_value(last_sym)) {
1048 dep_stack_insert(&cv_stack, last_sym);
1049 last_sym = prop_get_symbol(sym_get_choice_prop(last_sym));
1052 for (stack = check_top; stack != NULL; stack = stack->prev)
1053 if (stack->sym == last_sym)
1056 fprintf(stderr, "unexpected recursive dependency error\n");
1060 for (; stack; stack = stack->next) {
1062 next_sym = stack->next ? stack->next->sym : last_sym;
1065 prop = stack->sym->prop;
1067 /* for choice values find the menu entry (used below) */
1068 if (sym_is_choice(sym) || sym_is_choice_value(sym)) {
1069 for (prop = sym->prop; prop; prop = prop->next) {
1075 if (stack->sym == last_sym)
1076 fprintf(stderr, "%s:%d:error: recursive dependency detected!\n",
1077 prop->file->name, prop->lineno);
1080 fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n",
1081 prop->file->name, prop->lineno,
1082 sym->name ? sym->name : "<choice>",
1083 prop_get_type_name(prop->type),
1084 next_sym->name ? next_sym->name : "<choice>");
1085 } else if (stack->prop) {
1086 fprintf(stderr, "%s:%d:\tsymbol %s depends on %s\n",
1087 prop->file->name, prop->lineno,
1088 sym->name ? sym->name : "<choice>",
1089 next_sym->name ? next_sym->name : "<choice>");
1090 } else if (sym_is_choice(sym)) {
1091 fprintf(stderr, "%s:%d:\tchoice %s contains symbol %s\n",
1092 menu->file->name, menu->lineno,
1093 sym->name ? sym->name : "<choice>",
1094 next_sym->name ? next_sym->name : "<choice>");
1095 } else if (sym_is_choice_value(sym)) {
1096 fprintf(stderr, "%s:%d:\tsymbol %s is part of choice %s\n",
1097 menu->file->name, menu->lineno,
1098 sym->name ? sym->name : "<choice>",
1099 next_sym->name ? next_sym->name : "<choice>");
1101 fprintf(stderr, "%s:%d:\tsymbol %s is selected or implied by %s\n",
1102 prop->file->name, prop->lineno,
1103 sym->name ? sym->name : "<choice>",
1104 next_sym->name ? next_sym->name : "<choice>");
1109 "For a resolution refer to Documentation/kbuild/kconfig-language.txt\n"
1110 "subsection \"Kconfig recursive dependency limitations\"\n"
1113 if (check_top == &cv_stack)
1117 static struct symbol *sym_check_expr_deps(struct expr *e)
1126 sym = sym_check_expr_deps(e->left.expr);
1129 return sym_check_expr_deps(e->right.expr);
1131 return sym_check_expr_deps(e->left.expr);
1138 sym = sym_check_deps(e->left.sym);
1141 return sym_check_deps(e->right.sym);
1143 return sym_check_deps(e->left.sym);
1147 fprintf(stderr, "Oops! How to check %d?\n", e->type);
1151 /* return NULL when dependencies are OK */
1152 static struct symbol *sym_check_sym_deps(struct symbol *sym)
1154 struct symbol *sym2;
1155 struct property *prop;
1156 struct dep_stack stack;
1158 dep_stack_insert(&stack, sym);
1160 sym2 = sym_check_expr_deps(sym->rev_dep.expr);
1164 sym2 = sym_check_expr_deps(sym->implied.expr);
1168 for (prop = sym->prop; prop; prop = prop->next) {
1169 if (prop->type == P_CHOICE || prop->type == P_SELECT ||
1170 prop->type == P_IMPLY)
1173 sym2 = sym_check_expr_deps(prop->visible.expr);
1176 if (prop->type != P_DEFAULT || sym_is_choice(sym))
1178 stack.expr = prop->expr;
1179 sym2 = sym_check_expr_deps(prop->expr);
1191 static struct symbol *sym_check_choice_deps(struct symbol *choice)
1193 struct symbol *sym, *sym2;
1194 struct property *prop;
1196 struct dep_stack stack;
1198 dep_stack_insert(&stack, choice);
1200 prop = sym_get_choice_prop(choice);
1201 expr_list_for_each_sym(prop->expr, e, sym)
1202 sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
1204 choice->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
1205 sym2 = sym_check_sym_deps(choice);
1206 choice->flags &= ~SYMBOL_CHECK;
1210 expr_list_for_each_sym(prop->expr, e, sym) {
1211 sym2 = sym_check_sym_deps(sym);
1216 expr_list_for_each_sym(prop->expr, e, sym)
1217 sym->flags &= ~SYMBOL_CHECK;
1219 if (sym2 && sym_is_choice_value(sym2) &&
1220 prop_get_symbol(sym_get_choice_prop(sym2)) == choice)
1228 struct symbol *sym_check_deps(struct symbol *sym)
1230 struct symbol *sym2;
1231 struct property *prop;
1233 if (sym->flags & SYMBOL_CHECK) {
1234 sym_check_print_recursive(sym);
1237 if (sym->flags & SYMBOL_CHECKED)
1240 if (sym_is_choice_value(sym)) {
1241 struct dep_stack stack;
1243 /* for choice groups start the check with main choice symbol */
1244 dep_stack_insert(&stack, sym);
1245 prop = sym_get_choice_prop(sym);
1246 sym2 = sym_check_deps(prop_get_symbol(prop));
1248 } else if (sym_is_choice(sym)) {
1249 sym2 = sym_check_choice_deps(sym);
1251 sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
1252 sym2 = sym_check_sym_deps(sym);
1253 sym->flags &= ~SYMBOL_CHECK;
1259 struct property *prop_alloc(enum prop_type type, struct symbol *sym)
1261 struct property *prop;
1262 struct property **propp;
1264 prop = xmalloc(sizeof(*prop));
1265 memset(prop, 0, sizeof(*prop));
1268 prop->file = current_file;
1269 prop->lineno = zconf_lineno();
1271 /* append property to the prop list of symbol */
1273 for (propp = &sym->prop; *propp; propp = &(*propp)->next)
1281 struct symbol *prop_get_symbol(struct property *prop)
1283 if (prop->expr && (prop->expr->type == E_SYMBOL ||
1284 prop->expr->type == E_LIST))
1285 return prop->expr->left.sym;
1289 const char *prop_get_type_name(enum prop_type type)