Rename BUILD_BUG_ON_ZERO macro
In order to avoid name clash on distributions which decide to include kernel headers instead of UAPI ones. For example, on SLES 11SP4: gcc -DHAVE_CONFIG_H -I./linux/x86_64 -I./linux -I. -Wall -O2 -c net.c In file included from /usr/include/linux/sysctl.h:25:0, from /usr/include/linux/netfilter.h:6, from /usr/include/linux/netfilter_arp.h:8, from /usr/include/linux/netfilter_arp/arp_tables.h:14, from net.c:60: net.c: In function 'print_packet_mreq': gcc_compat.h:59:27: error: negative width in bit-field '<anonymous>' # define MUST_BE_ARRAY(a) BUILD_BUG_ON_ZERO(!SAME_TYPE((a), &(a)[0])) ^ defs.h:76:53: note: in expansion of macro 'MUST_BE_ARRAY' #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]) + MUST_BE_ARRAY(a)) ^ net.c:747:22: note: in expansion of macro 'ARRAY_SIZE' if (mreq.mr_alen > ARRAY_SIZE(mreq.mr_address)) ^ due to the fact BUILD_BUG_ON_ZERO is already defined in <linux/kernel.h>. * gcc_compat.h (BUILD_BUG_ON_ZERO): Rename to FAIL_BUILD_ON_ZERO. (MUST_BE_ARRAY): Update usage.
This commit is contained in:
@ -54,9 +54,9 @@
|
||||
|
||||
#if GNUC_PREREQ(3, 0)
|
||||
# define SAME_TYPE(x, y) __builtin_types_compatible_p(typeof(x), typeof(y))
|
||||
# define BUILD_BUG_ON_ZERO(expr) (sizeof(int[-1 + 2 * !!(expr)]) * 0)
|
||||
# define FAIL_BUILD_ON_ZERO(expr) (sizeof(int[-1 + 2 * !!(expr)]) * 0)
|
||||
/* &(a)[0] is a pointer and not an array, shouldn't be treated as the same */
|
||||
# define MUST_BE_ARRAY(a) BUILD_BUG_ON_ZERO(!SAME_TYPE((a), &(a)[0]))
|
||||
# define MUST_BE_ARRAY(a) FAIL_BUILD_ON_ZERO(!SAME_TYPE((a), &(a)[0]))
|
||||
#else
|
||||
# define SAME_TYPE(x, y) 0
|
||||
# define MUST_BE_ARRAY(a) 0
|
||||
|
Reference in New Issue
Block a user