libbpf: Fix BTF-defined map's __type macro handling of arrays
authorAndrii Nakryiko <andriin@fb.com>
Fri, 4 Oct 2019 04:02:11 +0000 (21:02 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 1 Feb 2020 09:34:47 +0000 (09:34 +0000)
commitc9ddede0a9fcda03e3c6ac429386f2f392640e72
tree06589fb90aa20b30098c0f51c76265db388943d1
parentd40471b727e8010fc5c9796dea36675e3d567c63
libbpf: Fix BTF-defined map's __type macro handling of arrays

[ Upstream commit a53ba15d81995868651dd28a85d8045aef3d4e20 ]

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
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/testing/selftests/bpf/bpf_helpers.h
tools/testing/selftests/bpf/progs/test_get_stack_rawtp.c