From: Eugene Syromyatnikov Date: Sun, 13 Nov 2016 10:45:59 +0000 (+0300) Subject: Rename BUILD_BUG_ON_ZERO macro X-Git-Tag: v4.15~137 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e061d67dffff7a9ea882560e7dc2bde910e353d7;p=strace 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 '' # 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 . * gcc_compat.h (BUILD_BUG_ON_ZERO): Rename to FAIL_BUILD_ON_ZERO. (MUST_BE_ARRAY): Update usage. --- diff --git a/gcc_compat.h b/gcc_compat.h index eb5242f7..fe3f9048 100644 --- a/gcc_compat.h +++ b/gcc_compat.h @@ -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