Home | History | Annotate | Download | only in kconfig

Lines Matching refs:sym

38 void sym_add_default(struct symbol *sym, const char *def)
40 struct property *prop = prop_alloc(P_DEFAULT, sym);
47 struct symbol *sym;
58 sym = sym_lookup("ARCH", 0);
59 sym->type = S_STRING;
60 sym->flags |= SYMBOL_AUTO;
63 sym_add_default(sym, p);
65 sym = sym_lookup("KERNELVERSION", 0);
66 sym->type = S_STRING;
67 sym->flags |= SYMBOL_AUTO;
70 sym_add_default(sym, p);
72 sym = sym_lookup("UNAME_RELEASE", 0);
73 sym->type = S_STRING;
74 sym->flags |= SYMBOL_AUTO;
75 sym_add_default(sym, uts.release);
78 enum symbol_type sym_get_type(struct symbol *sym)
80 enum symbol_type type = sym->type;
83 if (sym_is_choice_value(sym) && sym->visible == yes)
112 struct property *sym_get_choice_prop(struct symbol *sym)
116 for_all_choices(sym, prop)
121 struct property *sym_get_default_prop(struct symbol *sym)
125 for_all_defaults(sym, prop) {
133 struct property *sym_get_range_prop(struct symbol *sym)
137 for_all_properties(sym, prop, P_RANGE) {
145 static int sym_get_range_val(struct symbol *sym, int base)
147 sym_calc_value(sym);
148 switch (sym->type) {
158 return strtol(sym->curr.val, NULL, base);
161 static void sym_validate_range(struct symbol *sym)
167 switch (sym->type) {
177 prop = sym_get_range_prop(sym);
180 val = strtol(sym->curr.val, NULL, base);
181 val2 = sym_get_range_val(prop->expr->left.sym, base);
183 val2 = sym_get_range_val(prop->expr->right.sym, base);
187 if (sym->type == S_INT)
191 sym->curr.val = strdup(str);
194 static void sym_calc_visibility(struct symbol *sym)
201 for_all_prompts(sym, prop) {
205 if (tri == mod && (sym->type != S_TRISTATE || modules_val == no))
207 if (sym->visible != tri) {
208 sym->visible = tri;
209 sym_set_changed(sym);
211 if (sym_is_choice_value(sym))
214 if (sym->rev_dep.expr)
215 tri = expr_calc_value(sym->rev_dep.expr);
216 if (tri == mod && sym_get_type(sym) == S_BOOLEAN)
218 if (sym->rev_dep.tri != tri) {
219 sym->rev_dep.tri = tri;
220 sym_set_changed(sym);
224 static struct symbol *sym_calc_choice(struct symbol *sym)
231 def_sym = sym->def[S_DEF_USER].val;
239 for_all_defaults(sym, prop) {
250 prop = sym_get_choice_prop(sym);
252 def_sym = e->right.sym;
259 sym->curr.tri = no;
263 void sym_calc_value(struct symbol *sym)
269 if (!sym)
272 if (sym->flags & SYMBOL_VALID)
274 sym->flags |= SYMBOL_VALID;
276 oldval = sym->curr;
278 switch (sym->type) {
289 sym->curr.val = sym->name;
290 sym->curr.tri = no;
293 if (!sym_is_choice_value(sym))
294 sym->flags &= ~SYMBOL_WRITE;
296 sym_calc_visibility(sym);
299 sym->curr = newval;
301 switch (sym_get_type(sym)) {
304 if (sym_is_choice_value(sym) && sym->visible == yes) {
305 prop = sym_get_choice_prop(sym);
306 newval.tri = (prop_get_symbol(prop)->curr.val == sym) ? yes : no;
307 } else if (E_OR(sym->visible, sym->rev_dep.tri) != no) {
308 sym->flags |= SYMBOL_WRITE;
309 if (sym_has_value(sym))
310 newval.tri = sym->def[S_DEF_USER].tri;
311 else if (!sym_is_choice(sym)) {
312 prop = sym_get_default_prop(sym);
316 newval.tri = E_OR(E_AND(newval.tri, sym->visible), sym->rev_dep.tri);
317 } else if (!sym_is_choice(sym)) {
318 prop = sym_get_default_prop(sym);
320 sym->flags |= SYMBOL_WRITE;
324 if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN)
330 if (sym->visible != no) {
331 sym->flags |= SYMBOL_WRITE;
332 if (sym_has_value(sym)) {
333 newval.val = sym->def[S_DEF_USER].val;
337 prop = sym_get_default_prop(sym);
341 sym->flags |= SYMBOL_WRITE;
351 sym->curr = newval;
352 if (sym_is_choice(sym) && newval.tri == yes)
353 sym->curr.val = sym_calc_choice(sym);
354 sym_validate_range(sym);
356 if (memcmp(&oldval, &sym->curr, sizeof(oldval))) {
357 sym_set_changed(sym);
358 if (modules_sym == sym) {
364 if (sym_is_choice(sym)) {
365 int flags = sym->flags & (SYMBOL_CHANGED | SYMBOL_WRITE);
366 prop = sym_get_choice_prop(sym);
368 e->right.sym->flags |= flags;
370 sym_set_changed(e->right.sym);
377 struct symbol *sym;
380 for_all_symbols(i, sym)
381 sym->flags &= ~SYMBOL_VALID;
387 void sym_set_changed(struct symbol *sym)
391 sym->flags |= SYMBOL_CHANGED;
392 for (prop = sym->prop; prop; prop = prop->next) {
400 struct symbol *sym;
403 for_all_symbols(i, sym)
404 sym_set_changed(sym);
407 bool sym_tristate_within_range(struct symbol *sym, tristate val)
409 int type = sym_get_type(sym);
411 if (sym->visible == no)
419 if (sym->visible <= sym->rev_dep.tri)
421 if (sym_is_choice_value(sym) && sym->visible == yes)
423 return val >= sym->rev_dep.tri && val <= sym->visible;
426 bool sym_set_tristate_value(struct symbol *sym, tristate val)
428 tristate oldval = sym_get_tristate_value(sym);
430 if (oldval != val && !sym_tristate_within_range(sym, val))
433 if (!(sym->flags & SYMBOL_DEF_USER)) {
434 sym->flags |= SYMBOL_DEF_USER;
435 sym_set_changed(sym);
441 if (sym_is_choice_value(sym) && val == yes) {
442 struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym));
446 cs->def[S_DEF_USER].val = sym;
450 if (e->right.sym->visible != no)
451 e->right.sym->flags |= SYMBOL_DEF_USER;
455 sym->def[S_DEF_USER].tri = val;
462 tristate sym_toggle_tristate_value(struct symbol *sym)
466 oldval = newval = sym_get_tristate_value(sym);
479 if (sym_set_tristate_value(sym, newval))
485 bool sym_string_valid(struct symbol *sym, const char *str)
489 switch (sym->type) {
528 bool sym_string_within_range(struct symbol *sym, const char *str)
533 switch (sym->type) {
535 return sym_string_valid(sym, str);
537 if (!sym_string_valid(sym, str))
539 prop = sym_get_range_prop(sym);
543 return val >= sym_get_range_val(prop->expr->left.sym, 10) &&
544 val <= sym_get_range_val(prop->expr->right.sym, 10);
546 if (!sym_string_valid(sym, str))
548 prop = sym_get_range_prop(sym);
552 return val >= sym_get_range_val(prop->expr->left.sym, 16) &&
553 val <= sym_get_range_val(prop->expr->right.sym, 16);
558 return sym_tristate_within_range(sym, yes);
560 return sym_tristate_within_range(sym, mod);
562 return sym_tristate_within_range(sym, no);
570 bool sym_set_string_value(struct symbol *sym, const char *newval)
576 switch (sym->type) {
581 return sym_set_tristate_value(sym, yes);
583 return sym_set_tristate_value(sym, mod);
585 return sym_set_tristate_value(sym, no);
592 if (!sym_string_within_range(sym, newval))
595 if (!(sym->flags & SYMBOL_DEF_USER)) {
596 sym->flags |= SYMBOL_DEF_USER;
597 sym_set_changed(sym);
600 oldval = sym->def[S_DEF_USER].val;
602 if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) {
604 sym->def[S_DEF_USER].val = val = malloc(size);
608 sym->def[S_DEF_USER].val = val = malloc(size);
619 const char *sym_get_string_value(struct symbol *sym)
623 switch (sym->type) {
626 val = sym_get_tristate_value(sym);
639 return (const char *)sym->curr.val;
642 bool sym_is_changable(struct symbol *sym)
644 return sym->visible > sym->rev_dep.tri;
723 struct symbol *sym, **sym_arr = NULL;
734 for_all_symbols(i, sym) {
735 if (sym->flags & SYMBOL_CONST || !sym->name)
737 if (regexec(&re, sym->name, 0, NULL, 0))
748 sym_arr[cnt++] = sym;
758 struct symbol *sym_check_deps(struct symbol *sym);
762 struct symbol *sym;
769 sym = sym_check_expr_deps(e->left.expr);
770 if (sym)
771 return sym;
777 sym = sym_check_deps(e->left.sym);
778 if (sym)
779 return sym;
780 return sym_check_deps(e->right.sym);
782 return sym_check_deps(e->left.sym);
790 struct symbol *sym_check_deps(struct symbol *sym)
795 if (sym->flags & SYMBOL_CHECK) {
796 printf("Warning! Found recursive dependency: %s", sym->name);
797 return sym;
799 if (sym->flags & SYMBOL_CHECKED)
802 sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
803 sym2 = sym_check_expr_deps(sym->rev_dep.expr);
807 for (prop = sym->prop; prop; prop = prop->next) {
813 if (prop->type != P_DEFAULT || sym_is_choice(sym))
821 printf(" %s", sym->name);
822 if (sym2 == sym) {
827 sym->flags &= ~SYMBOL_CHECK;
831 struct property *prop_alloc(enum prop_type type, struct symbol *sym)
839 prop->sym = sym;
844 if (sym) {
845 for (propp = &sym->prop; *propp; propp = &(*propp)->next)
857 return prop->expr->left.sym;