mirror of
https://github.com/torvalds/linux.git
synced 2025-11-01 00:58:39 +02:00
Introduce the ktime_get() associated function to the ClockSource trait, allowing each clock source to specify how it retrieves the current time. This enables Instant::now() to be implemented generically using the type-level ClockSource abstraction. This change enhances the type safety and extensibility of timekeeping by statically associating time retrieval mechanisms with their respective clock types. It also reduces the reliance on hardcoded clock logic within Instant. Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com> Link: https://lore.kernel.org/r/20250610093258.3435874-4-fujita.tomonori@gmail.com Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
29 lines
477 B
C
29 lines
477 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#include <linux/ktime.h>
|
|
#include <linux/timekeeping.h>
|
|
|
|
ktime_t rust_helper_ktime_get_real(void)
|
|
{
|
|
return ktime_get_real();
|
|
}
|
|
|
|
ktime_t rust_helper_ktime_get_boottime(void)
|
|
{
|
|
return ktime_get_boottime();
|
|
}
|
|
|
|
ktime_t rust_helper_ktime_get_clocktai(void)
|
|
{
|
|
return ktime_get_clocktai();
|
|
}
|
|
|
|
s64 rust_helper_ktime_to_us(const ktime_t kt)
|
|
{
|
|
return ktime_to_us(kt);
|
|
}
|
|
|
|
s64 rust_helper_ktime_to_ms(const ktime_t kt)
|
|
{
|
|
return ktime_to_ms(kt);
|
|
}
|