mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 10:11:27 +01:00
xen-tools/libs.h currently contains a shared BUILD_BUG_ON() implementation and is used by some tools. Extend this to include ARRAY_SIZE and clean up all the opencoding. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Jan Beulich <jbeulich@suse.com>
17 lines
387 B
C
17 lines
387 B
C
#ifndef __XEN_TOOLS_LIBS__
|
|
#define __XEN_TOOLS_LIBS__
|
|
|
|
#ifndef BUILD_BUG_ON
|
|
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
|
|
#define BUILD_BUG_ON(p) ({ _Static_assert(!(p), "!(" #p ")"); })
|
|
#else
|
|
#define BUILD_BUG_ON(p) ((void)sizeof(char[1 - 2 * !!(p)]))
|
|
#endif
|
|
#endif
|
|
|
|
#ifndef ARRAY_SIZE
|
|
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*a))
|
|
#endif
|
|
|
|
#endif /* __XEN_TOOLS_LIBS__ */
|