summaryrefslogtreecommitdiff
path: root/tools/include/uapi/linux/const.h
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-07-27 08:40:53 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-07-27 08:40:53 +0200
commit5d5fd841c34649f1b09220fe58e59dffd61c447d (patch)
tree195fd42377575ba4b25775564248630a2eb69ce5 /tools/include/uapi/linux/const.h
parentcae6572efdd0948a7b676b3c5a7cebf9483bc781 (diff)
parentf5098b6bae761e346ebcd9da7f95622c04733cff (diff)
downloadlinux-next-5d5fd841c34649f1b09220fe58e59dffd61c447d.tar.gz
linux-next-5d5fd841c34649f1b09220fe58e59dffd61c447d.zip
Merge 7.2-rc5 into usb-next
We need the USB fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'tools/include/uapi/linux/const.h')
-rw-r--r--tools/include/uapi/linux/const.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/include/uapi/linux/const.h b/tools/include/uapi/linux/const.h
index b8f629ef135f..565f309b9df8 100644
--- a/tools/include/uapi/linux/const.h
+++ b/tools/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 */