]> granicus.if.org Git - strace/commitdiff
Rename BUILD_BUG_ON_ZERO macro
authorEugene Syromyatnikov <evgsyr@gmail.com>
Sun, 13 Nov 2016 10:45:59 +0000 (13:45 +0300)
committerDmitry V. Levin <ldv@altlinux.org>
Sun, 13 Nov 2016 11:04:49 +0000 (11:04 +0000)
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.

gcc_compat.h

index eb5242f77e5ee879d7b92e1f1b54004245a9a191..fe3f9048f7d099eaa63814b4c30501945685c217 100644 (file)
@@ -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