diff options
| author | FUJITA Tomonori <[email protected]> | 2025-05-02 00:45:24 +0000 |
|---|---|---|
| committer | Andreas Hindborg <[email protected]> | 2025-06-16 13:01:15 +0000 |
| commit | 1b7bbd5975279a1cf8d907fbc719f350031194c2 (patch) | |
| tree | 4fe36e4de48b157f91cf7f559b4aeab20e79abd5 /rust/helpers/helpers.c | |
| parent | Linux 6.16-rc2 (diff) | |
| download | kernel-1b7bbd5975279a1cf8d907fbc719f350031194c2.tar.gz kernel-1b7bbd5975279a1cf8d907fbc719f350031194c2.zip | |
rust: time: Avoid 64-bit integer division on 32-bit architectures
Avoid 64-bit integer division that 32-bit architectures don't
implement generally. This uses ktime_to_us() and ktime_to_ms()
instead.
The time abstraction needs i64 / u32 division so C's div_s64() can be
used but ktime_to_us() and ktime_to_ms() provide a simpler solution
for this time abstraction problem on 32-bit architectures.
32-bit ARM is the only 32-bit architecture currently supported by
Rust. Using the cfg attribute, only 32-bit architectures will call
ktime_to_us() and ktime_to_ms(), while the other 64-bit architectures
will continue to use the current code as-is to avoid the overhead.
One downside of calling the C's functions is that the as_micros/millis
methods can no longer be const fn. We stick with the simpler approach
unless there's a compelling need for a const fn.
Suggested-by: Arnd Bergmann <[email protected]>
Suggested-by: Boqun Feng <[email protected]>
Signed-off-by: FUJITA Tomonori <[email protected]>
Reviewed-by: Andreas Hindborg <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Andreas Hindborg <[email protected]>
Diffstat (limited to 'rust/helpers/helpers.c')
| -rw-r--r-- | rust/helpers/helpers.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/rust/helpers/helpers.c b/rust/helpers/helpers.c index 16fa9bca5949..1a05bb0dd420 100644 --- a/rust/helpers/helpers.c +++ b/rust/helpers/helpers.c @@ -40,6 +40,7 @@ #include "spinlock.c" #include "sync.c" #include "task.c" +#include "time.c" #include "uaccess.c" #include "vmalloc.c" #include "wait.c" |
