tools/testing/selftests/vDSO/vdso_test_abi.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/vDSO/vdso_test_abi.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/vDSO/vdso_test_abi.c- Extension
.c- Size
- 8029 bytes
- Lines
- 300
- 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
stdint.helf.hstdio.htime.hsys/auxv.hsys/time.hunistd.hsys/syscall.hkselftest.hvdso_config.hvdso_call.hparse_vdso.h
Detected Declarations
struct vdso_timespec64function vdso_test_gettimeofdayfunction vdso_test_clock_gettime64function vdso_test_clock_gettimefunction vdso_test_timefunction vdso_test_clock_getresfunction vdso_test_clock_getres_time64function vdso_test_clock_getres_time64function vdso_test_clockfunction main
Annotated Snippet
struct vdso_timespec64 {
uint64_t tv_sec;
uint64_t tv_nsec;
};
typedef long (*vdso_gettimeofday_t)(struct timeval *tv, struct timezone *tz);
typedef long (*vdso_clock_gettime_t)(clockid_t clk_id, struct timespec *ts);
typedef long (*vdso_clock_gettime64_t)(clockid_t clk_id, struct vdso_timespec64 *ts);
typedef long (*vdso_clock_getres_t)(clockid_t clk_id, struct timespec *ts);
typedef long (*vdso_clock_getres_time64_t)(clockid_t clk_id, struct vdso_timespec64 *ts);
typedef time_t (*vdso_time_t)(time_t *t);
static const char * const vdso_clock_name[] = {
[CLOCK_REALTIME] = "CLOCK_REALTIME",
[CLOCK_MONOTONIC] = "CLOCK_MONOTONIC",
[CLOCK_PROCESS_CPUTIME_ID] = "CLOCK_PROCESS_CPUTIME_ID",
[CLOCK_THREAD_CPUTIME_ID] = "CLOCK_THREAD_CPUTIME_ID",
[CLOCK_MONOTONIC_RAW] = "CLOCK_MONOTONIC_RAW",
[CLOCK_REALTIME_COARSE] = "CLOCK_REALTIME_COARSE",
[CLOCK_MONOTONIC_COARSE] = "CLOCK_MONOTONIC_COARSE",
[CLOCK_BOOTTIME] = "CLOCK_BOOTTIME",
[CLOCK_REALTIME_ALARM] = "CLOCK_REALTIME_ALARM",
[CLOCK_BOOTTIME_ALARM] = "CLOCK_BOOTTIME_ALARM",
[10 /* CLOCK_SGI_CYCLE */] = "CLOCK_SGI_CYCLE",
[CLOCK_TAI] = "CLOCK_TAI",
};
static void vdso_test_gettimeofday(void)
{
/* Find gettimeofday. */
vdso_gettimeofday_t vdso_gettimeofday =
(vdso_gettimeofday_t)vdso_sym(version, name[0]);
if (!vdso_gettimeofday) {
ksft_print_msg("Couldn't find %s\n", name[0]);
ksft_test_result_skip("%s\n", name[0]);
return;
}
struct timeval tv;
long ret = VDSO_CALL(vdso_gettimeofday, 2, &tv, 0);
if (ret == 0) {
ksft_print_msg("The time is %lld.%06lld\n",
(long long)tv.tv_sec, (long long)tv.tv_usec);
ksft_test_result_pass("%s\n", name[0]);
} else {
ksft_test_result_fail("%s\n", name[0]);
}
}
static void vdso_test_clock_gettime64(clockid_t clk_id)
{
/* Find clock_gettime64. */
vdso_clock_gettime64_t vdso_clock_gettime64 =
(vdso_clock_gettime64_t)vdso_sym(version, name[5]);
if (!vdso_clock_gettime64) {
ksft_print_msg("Couldn't find %s\n", name[5]);
ksft_test_result_skip("%s %s\n", name[5],
vdso_clock_name[clk_id]);
return;
}
struct vdso_timespec64 ts;
long ret = VDSO_CALL(vdso_clock_gettime64, 2, clk_id, &ts);
if (ret == 0) {
ksft_print_msg("The time is %lld.%06lld\n",
(long long)ts.tv_sec, (long long)ts.tv_nsec);
ksft_test_result_pass("%s %s\n", name[5],
vdso_clock_name[clk_id]);
} else {
ksft_test_result_fail("%s %s\n", name[5],
vdso_clock_name[clk_id]);
}
}
static void vdso_test_clock_gettime(clockid_t clk_id)
{
/* Find clock_gettime. */
vdso_clock_gettime_t vdso_clock_gettime =
(vdso_clock_gettime_t)vdso_sym(version, name[1]);
if (!vdso_clock_gettime) {
ksft_print_msg("Couldn't find %s\n", name[1]);
ksft_test_result_skip("%s %s\n", name[1],
vdso_clock_name[clk_id]);
return;
}
Annotation
- Immediate include surface: `stdint.h`, `elf.h`, `stdio.h`, `time.h`, `sys/auxv.h`, `sys/time.h`, `unistd.h`, `sys/syscall.h`.
- Detected declarations: `struct vdso_timespec64`, `function vdso_test_gettimeofday`, `function vdso_test_clock_gettime64`, `function vdso_test_clock_gettime`, `function vdso_test_time`, `function vdso_test_clock_getres`, `function vdso_test_clock_getres_time64`, `function vdso_test_clock_getres_time64`, `function vdso_test_clock`, `function main`.
- 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.