scripts/gendwarfksyms/types.c
Source file repositories/reference/linux-study-clean/scripts/gendwarfksyms/types.c
File Facts
- System
- Linux kernel
- Corpus path
scripts/gendwarfksyms/types.c- Extension
.c- Size
- 13055 bytes
- Lines
- 590
- 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
inttypes.hstdio.hstdlib.hstring.hzlib.hgendwarfksyms.h
Detected Declarations
struct type_list_entrystruct type_expansionstruct versionfunction type_list_freefunction list_for_each_entry_safefunction type_list_appendfunction type_list_writefunction list_for_each_entryfunction type_expansion_initfunction type_expansion_freefunction type_expansion_appendfunction __type_map_getfunction hash_for_each_possiblefunction type_map_getfunction cmp_expansion_namefunction type_map_writefunction type_map_freefunction hash_for_each_safefunction version_initfunction version_freefunction version_addfunction is_type_prefixfunction get_type_prefixfunction __calculate_versionfunction calculate_versionfunction __type_expandfunction list_for_each_entryfunction type_expandfunction type_parsefunction expand_typefunction expand_symbolfunction generate_symtypes_and_versions
Annotated Snippet
struct type_list_entry {
const char *str;
void *owned;
struct list_head list;
};
static void type_list_free(struct list_head *list)
{
struct type_list_entry *entry;
struct type_list_entry *tmp;
list_for_each_entry_safe(entry, tmp, list, list) {
if (entry->owned)
free(entry->owned);
free(entry);
}
INIT_LIST_HEAD(list);
}
static int type_list_append(struct list_head *list, const char *s, void *owned)
{
struct type_list_entry *entry;
if (!s)
return 0;
entry = xmalloc(sizeof(*entry));
entry->str = s;
entry->owned = owned;
list_add_tail(&entry->list, list);
return strlen(entry->str);
}
static void type_list_write(struct list_head *list, FILE *file)
{
struct type_list_entry *entry;
list_for_each_entry(entry, list, list) {
if (entry->str)
checkp(fputs(entry->str, file));
}
}
/*
* An expanded type string in symtypes format.
*/
struct type_expansion {
char *name;
size_t len;
struct list_head expanded;
struct hlist_node hash;
};
static void type_expansion_init(struct type_expansion *type)
{
type->name = NULL;
type->len = 0;
INIT_LIST_HEAD(&type->expanded);
}
static inline void type_expansion_free(struct type_expansion *type)
{
free(type->name);
type->name = NULL;
type->len = 0;
type_list_free(&type->expanded);
}
static void type_expansion_append(struct type_expansion *type, const char *s,
void *owned)
{
type->len += type_list_append(&type->expanded, s, owned);
}
/*
* type_map -- the longest expansions for each type.
*
* const char *name -> struct type_expansion *
*/
#define TYPE_HASH_BITS 12
static HASHTABLE_DEFINE(type_map, 1 << TYPE_HASH_BITS);
static int __type_map_get(const char *name, struct type_expansion **res)
{
struct type_expansion *e;
hash_for_each_possible(type_map, e, hash, hash_str(name)) {
if (!strcmp(name, e->name)) {
Annotation
- Immediate include surface: `inttypes.h`, `stdio.h`, `stdlib.h`, `string.h`, `zlib.h`, `gendwarfksyms.h`.
- Detected declarations: `struct type_list_entry`, `struct type_expansion`, `struct version`, `function type_list_free`, `function list_for_each_entry_safe`, `function type_list_append`, `function type_list_write`, `function list_for_each_entry`, `function type_expansion_init`, `function type_expansion_free`.
- 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.