aboutsummaryrefslogtreecommitdiffstats
path: root/tools/include/linux/compiler-gcc.h
diff options
context:
space:
mode:
authorJakub Kicinski <jakub.kicinski@netronome.com>2018-07-10 14:43:05 -0700
committerDaniel Borkmann <daniel@iogearbox.net>2018-07-11 22:13:34 +0200
commit531b014e7a2fedaeff0b19b2934d830cd4b35dc0 (patch)
tree0de8355e9d533b4f6f90c3b389f58c992e75bb14 /tools/include/linux/compiler-gcc.h
parenttools: libbpf: move library error code into a separate file (diff)
downloadlinux-dev-531b014e7a2fedaeff0b19b2934d830cd4b35dc0.tar.xz
linux-dev-531b014e7a2fedaeff0b19b2934d830cd4b35dc0.zip
tools: bpf: make use of reallocarray
reallocarray() is a safer variant of realloc which checks for multiplication overflow in case of array allocation. Since it's not available in Glibc < 2.26 import kernel's overflow.h and add a static inline implementation when needed. Use feature detection to probe for existence of reallocarray. Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com> Reviewed-by: Jiong Wang <jiong.wang@netronome.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools/include/linux/compiler-gcc.h')
-rw-r--r--tools/include/linux/compiler-gcc.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/tools/include/linux/compiler-gcc.h b/tools/include/linux/compiler-gcc.h
index 70fe61295733..0d35f18006a1 100644
--- a/tools/include/linux/compiler-gcc.h
+++ b/tools/include/linux/compiler-gcc.h
@@ -36,3 +36,7 @@
#endif
#define __printf(a, b) __attribute__((format(printf, a, b)))
#define __scanf(a, b) __attribute__((format(scanf, a, b)))
+
+#if GCC_VERSION >= 50100
+#define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1
+#endif