...so it can be used by pahole.c too. Signed-off-by: Alan Maguire <alan.maguire@xxxxxxxxxx> Acked-by: Jiri Olsa <jolsa@xxxxxxxxxx> Acked-by: Andrii Nakryiko <andrii@xxxxxxxxxx> --- dwarves.c | 16 ---------------- dwarves.h | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/dwarves.c b/dwarves.c index 218367b..9f97eda 100644 --- a/dwarves.c +++ b/dwarves.c @@ -2094,22 +2094,6 @@ int cus__load_file(struct cus *cus, struct conf_load *conf, _min1 < _min2 ? _min1 : _min2; }) #endif -/* Force a compilation error if condition is true, but also produce a - result (of value 0 and type size_t), so the expression can be used - e.g. in a structure initializer (or where-ever else comma expressions - aren't permitted). */ -#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) - -/* Are two types/vars the same type (ignoring qualifiers)? */ -#ifndef __same_type -# define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) -#endif - -/* &a[0] degrades to a pointer: a different type from an array */ -#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) - -#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) - #ifndef DW_LANG_C89 #define DW_LANG_C89 0x0001 #endif diff --git a/dwarves.h b/dwarves.h index db68161..857b37c 100644 --- a/dwarves.h +++ b/dwarves.h @@ -19,6 +19,22 @@ #include "list.h" #include "rbtree.h" +/* Force a compilation error if condition is true, but also produce a + result (of value 0 and type size_t), so the expression can be used + e.g. in a structure initializer (or where-ever else comma expressions + aren't permitted). */ +#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) + +/* Are two types/vars the same type (ignoring qualifiers)? */ +#ifndef __same_type +# define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) +#endif + +/* &a[0] degrades to a pointer: a different type from an array */ +#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) + +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) + struct cu; enum load_steal_kind { -- 2.31.1