aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/bpf_helpers.h
diff options
context:
space:
mode:
authorAndrii Nakryiko <andriin@fb.com>2019-10-03 21:02:11 -0700
committerAlexei Starovoitov <ast@kernel.org>2019-10-05 18:03:12 -0700
commita53ba15d81995868651dd28a85d8045aef3d4e20 (patch)
tree7039bc769c81e37de5dec53fea25e8286e4dfdb9 /tools/testing/selftests/bpf/bpf_helpers.h
parentbpf: Add loop test case with 32 bit reg comparison against 0 (diff)
downloadlinux-dev-a53ba15d81995868651dd28a85d8045aef3d4e20.tar.xz
linux-dev-a53ba15d81995868651dd28a85d8045aef3d4e20.zip
libbpf: Fix BTF-defined map's __type macro handling of arrays
Due to a quirky C syntax of declaring pointers to array or function prototype, existing __type() macro doesn't work with map key/value types that are array or function prototype. One has to create a typedef first and use it to specify key/value type for a BPF map. By using typeof(), pointer to type is now handled uniformly for all kinds of types. Convert one of self-tests as a demonstration. Signed-off-by: Andrii Nakryiko <andriin@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20191004040211.2434033-1-andriin@fb.com
Diffstat (limited to 'tools/testing/selftests/bpf/bpf_helpers.h')
-rw-r--r--tools/testing/selftests/bpf/bpf_helpers.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/testing/selftests/bpf/bpf_helpers.h b/tools/testing/selftests/bpf/bpf_helpers.h
index 54a50699bbfd..9f77cbaac01c 100644
--- a/tools/testing/selftests/bpf/bpf_helpers.h
+++ b/tools/testing/selftests/bpf/bpf_helpers.h
@@ -3,7 +3,7 @@
#define __BPF_HELPERS__
#define __uint(name, val) int (*name)[val]
-#define __type(name, val) val *name
+#define __type(name, val) typeof(val) *name
/* helper macro to print out debug messages */
#define bpf_printk(fmt, ...) \