mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-09 03:21:51 +00:00
linux/kernel.h: import DIV_ROUND_CLOSEST_ULL from Linux
Copied from Linux v4.20-rc7. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
This commit is contained in:
parent
ce480791f7
commit
b32aa9ebc5
1 changed files with 12 additions and 0 deletions
|
@ -102,6 +102,18 @@
|
||||||
(((__x) - ((__d) / 2)) / (__d)); \
|
(((__x) - ((__d) / 2)) / (__d)); \
|
||||||
} \
|
} \
|
||||||
)
|
)
|
||||||
|
/*
|
||||||
|
* Same as above but for u64 dividends. divisor must be a 32-bit
|
||||||
|
* number.
|
||||||
|
*/
|
||||||
|
#define DIV_ROUND_CLOSEST_ULL(x, divisor)( \
|
||||||
|
{ \
|
||||||
|
typeof(divisor) __d = divisor; \
|
||||||
|
unsigned long long _tmp = (x) + (__d) / 2; \
|
||||||
|
do_div(_tmp, __d); \
|
||||||
|
_tmp; \
|
||||||
|
} \
|
||||||
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Multiplies an integer by a fraction, while avoiding unnecessary
|
* Multiplies an integer by a fraction, while avoiding unnecessary
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue