scripts/gendwarfksyms/cache.c
Source file repositories/reference/linux-study-clean/scripts/gendwarfksyms/cache.c
File Facts
- System
- Linux kernel
- Corpus path
scripts/gendwarfksyms/cache.c- Extension
.c- Size
- 855 bytes
- Lines
- 52
- 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
gendwarfksyms.h
Detected Declarations
struct cache_itemfunction cache_setfunction cache_getfunction hash_for_each_possiblefunction cache_initfunction cache_freefunction hash_for_each_safe
Annotated Snippet
struct cache_item {
unsigned long key;
int value;
struct hlist_node hash;
};
void cache_set(struct cache *cache, unsigned long key, int value)
{
struct cache_item *ci;
ci = xmalloc(sizeof(*ci));
ci->key = key;
ci->value = value;
hash_add(cache->cache, &ci->hash, hash_32(key));
}
int cache_get(struct cache *cache, unsigned long key)
{
struct cache_item *ci;
hash_for_each_possible(cache->cache, ci, hash, hash_32(key)) {
if (ci->key == key)
return ci->value;
}
return -1;
}
void cache_init(struct cache *cache)
{
hash_init(cache->cache);
}
void cache_free(struct cache *cache)
{
struct hlist_node *tmp;
struct cache_item *ci;
hash_for_each_safe(cache->cache, ci, tmp, hash) {
free(ci);
}
hash_init(cache->cache);
}
Annotation
- Immediate include surface: `gendwarfksyms.h`.
- Detected declarations: `struct cache_item`, `function cache_set`, `function cache_get`, `function hash_for_each_possible`, `function cache_init`, `function cache_free`, `function hash_for_each_safe`.
- 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.