diff mbox series

[bpf-next,1/2] libbpf: Do not use btf_dump__new macro for c++ objects

Message ID 20211223131736.483956-1-jolsa@kernel.org (mailing list archive)
State Accepted
Delegated to: BPF
Headers show
Series [bpf-next,1/2] libbpf: Do not use btf_dump__new macro for c++ objects | expand

Checks

Context Check Description
bpf/vmtest-bpf-next success VM_Test
bpf/vmtest-bpf-next-PR success PR summary
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 1 maintainers not CCed: kpsingh@kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch warning WARNING: From:/Signed-off-by: email address mismatch: 'From: Jiri Olsa <jolsa@redhat.com>' != 'Signed-off-by: Jiri Olsa <jolsa@kernel.org>'
netdev/kdoc success Errors and warnings before: 12 this patch: 12
netdev/source_inline success Was 0 now: 0

Commit Message

Jiri Olsa Dec. 23, 2021, 1:17 p.m. UTC
As reported in here [0], C++ compilers don't support __builtin_types_compatible_p(),
so at least don't screw up compilation for them and let C++ users
pick btf_dump__new vs btf_dump__new_deprecated explicitly.

[0] https://github.com/libbpf/libbpf/issues/283#issuecomment-986100727
Fixes: 6084f5dc928f ("libbpf: Ensure btf_dump__new() and btf_dump_opts are future-proof")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/lib/bpf/btf.h | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Yonghong Song Dec. 23, 2021, 4:13 p.m. UTC | #1
On 12/23/21 5:17 AM, Jiri Olsa wrote:
> As reported in here [0], C++ compilers don't support __builtin_types_compatible_p(),
> so at least don't screw up compilation for them and let C++ users
> pick btf_dump__new vs btf_dump__new_deprecated explicitly.
> 
> [0] https://github.com/libbpf/libbpf/issues/283#issuecomment-986100727
> Fixes: 6084f5dc928f ("libbpf: Ensure btf_dump__new() and btf_dump_opts are future-proof")
> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>

Acked-by: Yonghong Song <yhs@fb.com>
Andrii Nakryiko Dec. 23, 2021, 6:25 p.m. UTC | #2
On Thu, Dec 23, 2021 at 8:13 AM Yonghong Song <yhs@fb.com> wrote:
>
>
>
> On 12/23/21 5:17 AM, Jiri Olsa wrote:
> > As reported in here [0], C++ compilers don't support __builtin_types_compatible_p(),
> > so at least don't screw up compilation for them and let C++ users
> > pick btf_dump__new vs btf_dump__new_deprecated explicitly.
> >
> > [0] https://github.com/libbpf/libbpf/issues/283#issuecomment-986100727
> > Fixes: 6084f5dc928f ("libbpf: Ensure btf_dump__new() and btf_dump_opts are future-proof")
> > Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
>
> Acked-by: Yonghong Song <yhs@fb.com>


Adjusted commit message a but and applied to bpf-next, thanks.
diff mbox series

Patch

diff --git a/tools/lib/bpf/btf.h b/tools/lib/bpf/btf.h
index 742a2bf71c5e..061839f04525 100644
--- a/tools/lib/bpf/btf.h
+++ b/tools/lib/bpf/btf.h
@@ -313,12 +313,18 @@  LIBBPF_API struct btf_dump *btf_dump__new_deprecated(const struct btf *btf,
  *
  * The rest works just like in case of ___libbpf_override() usage with symbol
  * versioning.
+ *
+ * C++ compilers don't support __builtin_types_compatible_p(), so at least
+ * don't screw up compilation for them and let C++ users pick btf_dump__new
+ * vs btf_dump__new_deprecated explicitly.
  */
+#ifndef __cplusplus
 #define btf_dump__new(a1, a2, a3, a4) __builtin_choose_expr(				\
 	__builtin_types_compatible_p(typeof(a4), btf_dump_printf_fn_t) ||		\
 	__builtin_types_compatible_p(typeof(a4), void(void *, const char *, va_list)),	\
 	btf_dump__new_deprecated((void *)a1, (void *)a2, (void *)a3, (void *)a4),	\
 	btf_dump__new((void *)a1, (void *)a2, (void *)a3, (void *)a4))
+#endif
 
 LIBBPF_API void btf_dump__free(struct btf_dump *d);