aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduard Zingerman <[email protected]>2022-11-11 00:32:40 +0200
committerAndrii Nakryiko <[email protected]>2022-11-11 10:24:23 -0800
commit42597aa372f5d2f26f209c5db36b1cd098b27147 (patch)
treea67b4cb3203b34b4b125e15079324dcc6ac80e98
parentc7028aa2fb03597e85ad2ac1ad0ac319ace00418 (diff)
libbpf: Hashmap.h update to fix build issues using LLVM14
A fix for the LLVM compilation error while building bpftool. Replaces the expression: _Static_assert((p) == NULL || ...) by expression: _Static_assert((__builtin_constant_p((p)) ? (p) == NULL : 0) || ...) When "p" is not a constant the former is not considered to be a constant expression by LLVM 14. The error was introduced in the following patch-set: [1]. The error was reported here: [2]. [1] https://lore.kernel.org/bpf/[email protected]/ [2] https://lore.kernel.org/all/[email protected]/ Reported-by: kernel test robot <[email protected]> Fixes: c302378bc157 ("libbpf: Hashmap interface update to allow both long and void* keys/values") Signed-off-by: Eduard Zingerman <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Acked-by: Stanislav Fomichev <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
-rw-r--r--tools/lib/bpf/hashmap.h3
-rw-r--r--tools/perf/util/hashmap.h3
2 files changed, 4 insertions, 2 deletions
diff --git a/tools/lib/bpf/hashmap.h b/tools/lib/bpf/hashmap.h
index 3fe647477bad..0a5bf1937a7c 100644
--- a/tools/lib/bpf/hashmap.h
+++ b/tools/lib/bpf/hashmap.h
@@ -123,7 +123,8 @@ enum hashmap_insert_strategy {
};
#define hashmap_cast_ptr(p) ({ \
- _Static_assert((p) == NULL || sizeof(*(p)) == sizeof(long), \
+ _Static_assert((__builtin_constant_p((p)) ? (p) == NULL : 0) || \
+ sizeof(*(p)) == sizeof(long), \
#p " pointee should be a long-sized integer or a pointer"); \
(long *)(p); \
})
diff --git a/tools/perf/util/hashmap.h b/tools/perf/util/hashmap.h
index 3fe647477bad..0a5bf1937a7c 100644
--- a/tools/perf/util/hashmap.h
+++ b/tools/perf/util/hashmap.h
@@ -123,7 +123,8 @@ enum hashmap_insert_strategy {
};
#define hashmap_cast_ptr(p) ({ \
- _Static_assert((p) == NULL || sizeof(*(p)) == sizeof(long), \
+ _Static_assert((__builtin_constant_p((p)) ? (p) == NULL : 0) || \
+ sizeof(*(p)) == sizeof(long), \
#p " pointee should be a long-sized integer or a pointer"); \
(long *)(p); \
})