scripts/kconfig/expr.c
Source file repositories/reference/linux-study-clean/scripts/kconfig/expr.c
File Facts
- System
- Linux kernel
- Corpus path
scripts/kconfig/expr.c- Extension
.c- Size
- 29230 bytes
- Lines
- 1181
- Domain
- Support Tooling And Documentation
- Bucket
- scripts
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
ctype.herrno.hstdio.hstdlib.hstring.hhash.hxalloc.hinternal.hlkc.h
Detected Declarations
enum string_value_kindfunction hash_for_each_possiblefunction expr_eliminate_eqfunction __expr_eliminate_eqfunction otherfunction simplificationsfunction expr_eliminate_dupsfunction expr_contains_symbolfunction expr_depends_symbolfunction expr_parse_stringfunction __expr_calc_valuefunction expr_calc_valuefunction expr_invalidate_allfunction expr_compare_typefunction expr_printfunction expr_print_file_helperfunction expr_fprintfunction expr_print_gstr_helperfunction expr_gstr_printfunction expr_print_revdepfunction expr_gstr_print_revdep
Annotated Snippet
if (l->type == E_SYMBOL) {
if (l->left.sym == &symbol_no)
return l;
else if (l->left.sym == &symbol_yes)
return r;
}
if (r->type == E_SYMBOL) {
if (r->left.sym == &symbol_no)
return r;
else if (r->left.sym == &symbol_yes)
return l;
}
break;
case E_OR:
l = expr_eliminate_yn(e->left.expr);
r = expr_eliminate_yn(e->right.expr);
if (l->type == E_SYMBOL) {
if (l->left.sym == &symbol_no)
return r;
else if (l->left.sym == &symbol_yes)
return l;
}
if (r->type == E_SYMBOL) {
if (r->left.sym == &symbol_no)
return l;
else if (r->left.sym == &symbol_yes)
return r;
}
break;
default:
;
}
return e;
}
/*
* e1 || e2 -> ?
*/
static struct expr *expr_join_or(struct expr *e1, struct expr *e2)
{
struct expr *tmp;
struct symbol *sym1, *sym2;
if (expr_eq(e1, e2))
return e1;
if (e1->type != E_EQUAL && e1->type != E_UNEQUAL && e1->type != E_SYMBOL && e1->type != E_NOT)
return NULL;
if (e2->type != E_EQUAL && e2->type != E_UNEQUAL && e2->type != E_SYMBOL && e2->type != E_NOT)
return NULL;
if (e1->type == E_NOT) {
tmp = e1->left.expr;
if (tmp->type != E_EQUAL && tmp->type != E_UNEQUAL && tmp->type != E_SYMBOL)
return NULL;
sym1 = tmp->left.sym;
} else
sym1 = e1->left.sym;
if (e2->type == E_NOT) {
if (e2->left.expr->type != E_SYMBOL)
return NULL;
sym2 = e2->left.expr->left.sym;
} else
sym2 = e2->left.sym;
if (sym1 != sym2)
return NULL;
if (sym1->type != S_BOOLEAN && sym1->type != S_TRISTATE)
return NULL;
if (sym1->type == S_TRISTATE) {
if (e1->type == E_EQUAL && e2->type == E_EQUAL &&
((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_mod) ||
(e1->right.sym == &symbol_mod && e2->right.sym == &symbol_yes))) {
// (a='y') || (a='m') -> (a!='n')
return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_no);
}
if (e1->type == E_EQUAL && e2->type == E_EQUAL &&
((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_no) ||
(e1->right.sym == &symbol_no && e2->right.sym == &symbol_yes))) {
// (a='y') || (a='n') -> (a!='m')
return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_mod);
}
if (e1->type == E_EQUAL && e2->type == E_EQUAL &&
((e1->right.sym == &symbol_mod && e2->right.sym == &symbol_no) ||
(e1->right.sym == &symbol_no && e2->right.sym == &symbol_mod))) {
// (a='m') || (a='n') -> (a!='y')
return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_yes);
}
}
if (sym1->type == S_BOOLEAN) {
// a || !a -> y
if ((e1->type == E_NOT && e1->left.expr->type == E_SYMBOL && e2->type == E_SYMBOL) ||
(e2->type == E_NOT && e2->left.expr->type == E_SYMBOL && e1->type == E_SYMBOL))
Annotation
- Immediate include surface: `ctype.h`, `errno.h`, `stdio.h`, `stdlib.h`, `string.h`, `hash.h`, `xalloc.h`, `internal.h`.
- Detected declarations: `enum string_value_kind`, `function hash_for_each_possible`, `function expr_eliminate_eq`, `function __expr_eliminate_eq`, `function other`, `function simplifications`, `function expr_eliminate_dups`, `function expr_contains_symbol`, `function expr_depends_symbol`, `function expr_parse_string`.
- Atlas domain: Support Tooling And Documentation / scripts.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.