tools include: Adopt __same_type() and __must_be_array() from the kernel
tip-bot for Arnaldo Carvalho de Melo
merge botCommit-ID: f6441aff8946f7fd6ab730d7eb9eba18a9ebeba4 Gitweb: http://git.kernel.org/tip/f6441aff8946f7fd6ab730d7eb9eba18a9ebeba4 Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Mon, 17 Apr 2017 11:25:00 -0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 19 Apr 2017 13:01:42 -0300
tools include: Adopt __same_type() and __must_be_array() from the kernel
Will be used to adopt the more stringent version of ARRAY_SIZE(), the one in the kernel sources.
Cc Adrian Hunter <[email protected]>
Cc David Ahern <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Wang Nan <[email protected]>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/include/linux/compiler-gcc.h | 3 +++ tools/include/linux/compiler.h | 5 +++++ 2 files changed, 8 insertions(+)
tools/include/linux/compiler-gcc.h +3 -0
@@ -16,3 +16,6 @@#if GCC_VERSION >=40300 # define __compiletime_error (message) __attribute__((error(message)))#endif /* GCC_VERSION >= 40300 */ + +/* &a[0] degrades to a pointer: a different type from an array */ +#define __must_be_array (a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
tools/include/linux/compiler.h +5 -0
@@ -17,6 +17,11 @@# define __always_inline inline __attribute__((always_inline))#endif +/* Are two types/vars the same type (ignoring qualifiers)? */ +#ifndef __same_type +# define __same_type (a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) +#endif +#ifdef __ANDROID__/* * FIXME: Big hammer to get rid of tons of: