Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-d85dpvay1hoqscpezlntyd8x@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+8
+3
tools/include/linux/compiler-gcc.h
··· 16 16 #if GCC_VERSION >= 40300 17 17 # define __compiletime_error(message) __attribute__((error(message))) 18 18 #endif /* GCC_VERSION >= 40300 */ 19 + 20 + /* &a[0] degrades to a pointer: a different type from an array */ 21 + #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
+5
tools/include/linux/compiler.h
··· 17 17 # define __always_inline inline __attribute__((always_inline)) 18 18 #endif 19 19 20 + /* Are two types/vars the same type (ignoring qualifiers)? */ 21 + #ifndef __same_type 22 + # define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) 23 + #endif 24 + 20 25 #ifdef __ANDROID__ 21 26 /* 22 27 * FIXME: Big hammer to get rid of tons of: