tools/perf/arch/riscv/util/header.c
Source file repositories/reference/linux-study-clean/tools/perf/arch/riscv/util/header.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/arch/riscv/util/header.c- Extension
.c- Size
- 1921 bytes
- Lines
- 105
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- 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
stdio.hstdlib.hapi/fs/fs.herrno.h../../util/debug.h../../util/header.h
Detected Declarations
function get_cpuidfunction get_cpuidfunction get_cpuid_str
Annotated Snippet
if (!strncmp(line, CPUINFO_MVEN, strlen(CPUINFO_MVEN))) {
mvendorid = _get_field(line);
if (!mvendorid)
goto free;
} else if (!strncmp(line, CPUINFO_MARCH, strlen(CPUINFO_MARCH))) {
marchid = _get_field(line);
if (!marchid)
goto free;
} else if (!strncmp(line, CPUINFO_MIMP, strlen(CPUINFO_MIMP))) {
mimpid = _get_field(line);
if (!mimpid)
goto free;
break;
}
}
if (!mvendorid || !marchid || !mimpid)
goto free;
if (asprintf(&cpuid, "%s-%s-%s", mvendorid, marchid, mimpid) < 0)
cpuid = NULL;
free:
fclose(cpuinfo);
free(mvendorid);
free(marchid);
free(mimpid);
return cpuid;
}
int get_cpuid(char *buffer, size_t sz, struct perf_cpu cpu __maybe_unused)
{
char *cpuid = _get_cpuid();
int ret = 0;
if (sz < strlen(cpuid)) {
ret = -EINVAL;
goto free;
}
scnprintf(buffer, sz, "%s", cpuid);
free:
free(cpuid);
return ret;
}
char *
get_cpuid_str(struct perf_cpu cpu __maybe_unused)
{
return _get_cpuid();
}
Annotation
- Immediate include surface: `stdio.h`, `stdlib.h`, `api/fs/fs.h`, `errno.h`, `../../util/debug.h`, `../../util/header.h`.
- Detected declarations: `function get_cpuid`, `function get_cpuid`, `function get_cpuid_str`.
- Atlas domain: Support Tooling And Documentation / tools.
- 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.