diff options
| author | Thomas Gleixner <tglx@kernel.org> | 2026-05-18 12:01:07 +0300 |
|---|---|---|
| committer | Thomas Gleixner <tglx@kernel.org> | 2026-05-18 12:01:07 +0300 |
| commit | 09d6818d3bdc1ea6e49a425040528cbdbc97bc0a (patch) | |
| tree | 989f9d94c592294e4ae5421c9cbcbad99eee996c /include/uapi/linux/const.h | |
| parent | 1655f6895a896eb632ca8a019259bc5d358a9712 (diff) | |
| parent | 5200f5f493f79f14bbdc349e402a40dfb32f23c8 (diff) | |
| download | linux-09d6818d3bdc1ea6e49a425040528cbdbc97bc0a.tar.xz | |
Merge branch 'linus' into timers/clocksource
... to bring it up to date for new changes.
Diffstat (limited to 'include/uapi/linux/const.h')
| -rw-r--r-- | include/uapi/linux/const.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/uapi/linux/const.h b/include/uapi/linux/const.h index b8f629ef135f..565f309b9df8 100644 --- a/include/uapi/linux/const.h +++ b/include/uapi/linux/const.h @@ -50,4 +50,22 @@ #define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) +/* + * Divide positive or negative dividend by positive or negative divisor + * and round to closest integer. Result is undefined for negative + * divisors if the dividend variable type is unsigned and for negative + * dividends if the divisor variable type is unsigned. + */ +#define __KERNEL_DIV_ROUND_CLOSEST(x, divisor) \ +({ \ + __typeof__(x) __x = x; \ + __typeof__(divisor) __d = divisor; \ + \ + (((__typeof__(x))-1) > 0 || \ + ((__typeof__(divisor))-1) > 0 || \ + (((__x) > 0) == ((__d) > 0))) ? \ + (((__x) + ((__d) / 2)) / (__d)) : \ + (((__x) - ((__d) / 2)) / (__d)); \ +}) + #endif /* _UAPI_LINUX_CONST_H */ |
