tools/perf/util/syscalltbl.c
Source file repositories/reference/linux-study-clean/tools/perf/util/syscalltbl.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/syscalltbl.c- Extension
.c- Size
- 3070 bytes
- Lines
- 134
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: syscall or user/kernel boundary
- Status
- core 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 participates in a user/kernel boundary; inspect argument validation, copy_from_user/copy_to_user, credentials, and dispatch target.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
syscalltbl.hstdlib.hasm/bitsperlong.hlinux/compiler.hlinux/kernel.hlinux/zalloc.hstring.hstring2.htrace/beauty/generated/syscalltbl.c
Detected Declarations
struct syscall_cmp_keyfunction syscallcmpnamefunction syscalltbl__idfunction syscalltbl__num_idxfunction syscalltbl__id_at_idxfunction syscalltbl__strglobmatch_nextfunction syscalltbl__strglobmatch_first
Annotated Snippet
struct syscall_cmp_key {
const char *name;
const char *const *tbl;
};
static int syscallcmpname(const void *vkey, const void *ventry)
{
const struct syscall_cmp_key *key = vkey;
const uint16_t *entry = ventry;
return strcmp(key->name, key->tbl[*entry]);
}
int syscalltbl__id(int e_machine, const char *name)
{
const struct syscalltbl *table = find_table(e_machine);
struct syscall_cmp_key key;
const uint16_t *id;
if (!table)
return -1;
key.name = name;
key.tbl = table->num_to_name;
id = bsearch(&key, table->sorted_names, table->sorted_names_len,
sizeof(table->sorted_names[0]), syscallcmpname);
return id ? *id : -1;
}
int syscalltbl__num_idx(int e_machine)
{
const struct syscalltbl *table = find_table(e_machine);
if (!table)
return 0;
return table->sorted_names_len;
}
int syscalltbl__id_at_idx(int e_machine, int idx)
{
const struct syscalltbl *table = find_table(e_machine);
if (!table)
return -1;
assert(idx >= 0 && idx < table->sorted_names_len);
return table->sorted_names[idx];
}
int syscalltbl__strglobmatch_next(int e_machine, const char *syscall_glob, int *idx)
{
const struct syscalltbl *table = find_table(e_machine);
for (int i = *idx + 1; table && i < table->sorted_names_len; ++i) {
const char *name = table->num_to_name[table->sorted_names[i]];
if (strglobmatch(name, syscall_glob)) {
*idx = i;
return table->sorted_names[i];
}
}
return -1;
}
int syscalltbl__strglobmatch_first(int e_machine, const char *syscall_glob, int *idx)
{
*idx = -1;
return syscalltbl__strglobmatch_next(e_machine, syscall_glob, idx);
}
Annotation
- Immediate include surface: `syscalltbl.h`, `stdlib.h`, `asm/bitsperlong.h`, `linux/compiler.h`, `linux/kernel.h`, `linux/zalloc.h`, `string.h`, `string2.h`.
- Detected declarations: `struct syscall_cmp_key`, `function syscallcmpname`, `function syscalltbl__id`, `function syscalltbl__num_idx`, `function syscalltbl__id_at_idx`, `function syscalltbl__strglobmatch_next`, `function syscalltbl__strglobmatch_first`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: core 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.