summaryrefslogtreecommitdiff
path: root/tools/include
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2026-06-25 13:02:03 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2026-07-21 21:00:09 -0300
commit4a97144794920cb17e4a1c56c243edc757f42df9 (patch)
treebcea13935a18c7fca6b2601bd905cbc0d5e9e651 /tools/include
parent88b8c6ae2ccb3ef9dbb04c8e13a4d1a98c42e922 (diff)
tools headers UAPI: Sync linux/const.h with the kernel sources
To pick up the changes in: de9e2b3d88af3641 ("uapi: Provide DIV_ROUND_CLOSEST()") That just rebuilds perf, silencing this build warning. This addresses this perf build warning: Warning: Kernel ABI header differences: diff -u tools/include/uapi/linux/const.h include/uapi/linux/const.h Please see tools/include/uapi/README for further details. Cc: Cristian Ciocaltea <cristian.ciocaltea@collabora.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/include')
-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 */