scripts/kconfig/preprocess.c
Source file repositories/reference/linux-study-clean/scripts/kconfig/preprocess.c
File Facts
- System
- Linux kernel
- Corpus path
scripts/kconfig/preprocess.c- Extension
.c- Size
- 11324 bytes
- Lines
- 582
- 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.hstdarg.hstdbool.hstdio.hstdlib.hstring.harray_size.hlist.hxalloc.hinternal.hlkc.hpreprocess.h
Detected Declarations
struct envstruct functionstruct variablefunction __attribute__function env_addfunction env_delfunction list_for_each_entryfunction env_write_depfunction list_for_each_entry_safefunction list_for_each_entryfunction variable_addfunction variable_delfunction variable_all_delfunction expansionfunction is_end_of_strfunction is_end_of_token
Annotated Snippet
struct env {
char *name;
char *value;
struct list_head node;
};
static void env_add(const char *name, const char *value)
{
struct env *e;
e = xmalloc(sizeof(*e));
e->name = xstrdup(name);
e->value = xstrdup(value);
list_add_tail(&e->node, &env_list);
}
static void env_del(struct env *e)
{
list_del(&e->node);
free(e->name);
free(e->value);
free(e);
}
/* The returned pointer must be freed when done */
static char *env_expand(const char *name)
{
struct env *e;
const char *value;
if (!*name)
return NULL;
list_for_each_entry(e, &env_list, node) {
if (!strcmp(name, e->name))
return xstrdup(e->value);
}
value = getenv(name);
if (!value)
return NULL;
/*
* We need to remember all referenced environment variables.
* They will be written out to include/config/auto.conf.cmd
*/
env_add(name, value);
return xstrdup(value);
}
void env_write_dep(struct gstr *s)
{
struct env *e, *tmp;
list_for_each_entry_safe(e, tmp, &env_list, node) {
str_printf(s,
"\n"
"ifneq \"$(%s)\" \"%s\"\n"
"$(autoconfig): FORCE\n"
"endif\n",
e->name, e->value);
env_del(e);
}
}
/*
* Built-in functions
*/
struct function {
const char *name;
unsigned int min_args;
unsigned int max_args;
char *(*func)(int argc, char *argv[]);
};
static char *do_error_if(int argc, char *argv[])
{
if (!strcmp(argv[0], "y"))
pperror("%s", argv[1]);
return xstrdup("");
}
static char *do_filename(int argc, char *argv[])
{
return xstrdup(cur_filename);
}
Annotation
- Immediate include surface: `ctype.h`, `stdarg.h`, `stdbool.h`, `stdio.h`, `stdlib.h`, `string.h`, `array_size.h`, `list.h`.
- Detected declarations: `struct env`, `struct function`, `struct variable`, `function __attribute__`, `function env_add`, `function env_del`, `function list_for_each_entry`, `function env_write_dep`, `function list_for_each_entry_safe`, `function list_for_each_entry`.
- 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.