scripts/basic/fixdep.c
Source file repositories/reference/linux-study-clean/scripts/basic/fixdep.c
File Facts
- System
- Linux kernel
- Corpus path
scripts/basic/fixdep.c- Extension
.c- Size
- 10854 bytes
- Lines
- 441
- 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
sys/types.hsys/stat.hunistd.hfcntl.hstring.hstdbool.hstdlib.hstdio.hctype.hxalloc.h
Detected Declarations
struct itemfunction usagefunction strhashfunction add_to_hashtablefunction in_hashtablefunction use_configfunction str_ends_withfunction parse_config_filefunction is_ignored_filefunction is_no_parse_filefunction parse_dep_filefunction mainfunction ferror
Annotated Snippet
struct item {
struct item *next;
unsigned int len;
unsigned int hash;
char name[];
};
#define HASHSZ 256
static struct item *config_hashtab[HASHSZ], *file_hashtab[HASHSZ];
static unsigned int strhash(const char *str, unsigned int sz)
{
/* fnv32 hash */
unsigned int i, hash = 2166136261U;
for (i = 0; i < sz; i++)
hash = (hash ^ str[i]) * 0x01000193;
return hash;
}
/*
* Add a new value to the configuration string.
*/
static void add_to_hashtable(const char *name, int len, unsigned int hash,
struct item *hashtab[])
{
struct item *aux;
aux = xmalloc(sizeof(*aux) + len);
memcpy(aux->name, name, len);
aux->len = len;
aux->hash = hash;
aux->next = hashtab[hash % HASHSZ];
hashtab[hash % HASHSZ] = aux;
}
/*
* Lookup a string in the hash table. If found, just return true.
* If not, add it to the hashtable and return false.
*/
static bool in_hashtable(const char *name, int len, struct item *hashtab[])
{
struct item *aux;
unsigned int hash = strhash(name, len);
for (aux = hashtab[hash % HASHSZ]; aux; aux = aux->next) {
if (aux->hash == hash && aux->len == len &&
memcmp(aux->name, name, len) == 0)
return true;
}
add_to_hashtable(name, len, hash, hashtab);
return false;
}
/*
* Record the use of a CONFIG_* word.
*/
static void use_config(const char *m, int slen)
{
if (in_hashtable(m, slen, config_hashtab))
return;
/* Print out a dependency path from a symbol name. */
printf(" $(wildcard include/config/%.*s) \\\n", slen, m);
}
/* test if s ends in sub */
static int str_ends_with(const char *s, int slen, const char *sub)
{
int sublen = strlen(sub);
if (sublen > slen)
return 0;
return !memcmp(s + slen - sublen, sub, sublen);
}
static void parse_config_file(const char *p)
{
const char *q, *r;
const char *start = p;
while ((p = strstr(p, "CONFIG_"))) {
if (p > start && (isalnum(p[-1]) || p[-1] == '_')) {
p += 7;
continue;
}
p += 7;
Annotation
- Immediate include surface: `sys/types.h`, `sys/stat.h`, `unistd.h`, `fcntl.h`, `string.h`, `stdbool.h`, `stdlib.h`, `stdio.h`.
- Detected declarations: `struct item`, `function usage`, `function strhash`, `function add_to_hashtable`, `function in_hashtable`, `function use_config`, `function str_ends_with`, `function parse_config_file`, `function is_ignored_file`, `function is_no_parse_file`.
- 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.