diff options
| author | Jean-Sébastien Pédron <dumbbell@FreeBSD.org> | 2026-04-21 00:32:18 +0000 |
|---|---|---|
| committer | Jean-Sébastien Pédron <dumbbell@FreeBSD.org> | 2026-04-22 18:09:56 +0000 |
| commit | 002c08158f9e7eb61c467fe29ff8e24361fb8470 (patch) | |
| tree | 1ececd45708a2d4d3988212d3c09058badc1ae70 | |
| parent | 305ebed50b4e2e2346d211c5a65320fa45c7fbc4 (diff) | |
linuxkpi: Define `DIV_U64_ROUND_UP()`
It is the same as `DIV64_U64_ROUND_UP()` but takes a 32-bit integer as
the divisor.
The amdgpu DRM driver started to use this in Linux 6.12.x.
Reviewed by: bz
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D56576
| -rw-r--r-- | sys/compat/linuxkpi/common/include/linux/math64.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/math64.h b/sys/compat/linuxkpi/common/include/linux/math64.h index 25ca9da1b622..e35aae67fa27 100644 --- a/sys/compat/linuxkpi/common/include/linux/math64.h +++ b/sys/compat/linuxkpi/common/include/linux/math64.h @@ -93,6 +93,12 @@ mul_u32_u32(uint32_t a, uint32_t b) } static inline uint64_t +div_u64_round_up(uint64_t dividend, uint32_t divisor) +{ + return ((dividend + divisor - 1) / divisor); +} + +static inline uint64_t div64_u64_round_up(uint64_t dividend, uint64_t divisor) { return ((dividend + divisor - 1) / divisor); @@ -104,6 +110,9 @@ roundup_u64(uint64_t x1, uint32_t x2) return (div_u64(x1 + x2 - 1, x2) * x2); } +#define DIV_U64_ROUND_UP(...) \ + div_u64_round_up(__VA_ARGS__) + #define DIV64_U64_ROUND_UP(...) \ div64_u64_round_up(__VA_ARGS__) |
