]> git.baikalelectronics.ru Git - kernel.git/commit
libbpf bpf_helpers: Use __builtin_offsetof for offsetof
authorIan Rogers <irogers@google.com>
Mon, 20 Jul 2020 06:17:41 +0000 (23:17 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 21 Jul 2020 20:26:25 +0000 (13:26 -0700)
commit0c88f75fbe0e9e3ba9750b5cc4c65052b4f46dc3
treeabe364c7964ce93163f3dcd4dbdb74d8c19e2b28
parent563cceeccba97429209c2b46516dc34eedf80a3d
libbpf bpf_helpers: Use __builtin_offsetof for offsetof

The non-builtin route for offsetof has a dependency on size_t from
stdlib.h/stdint.h that is undeclared and may break targets.
The offsetof macro in bpf_helpers may disable the same macro in other
headers that have a #ifdef offsetof guard. Rather than add additional
dependencies improve the offsetof macro declared here to use the
builtin that is available since llvm 3.7 (the first with a BPF backend).

Signed-off-by: Ian Rogers <irogers@google.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20200720061741.1514673-1-irogers@google.com
tools/lib/bpf/bpf_helpers.h