From patchwork Thu Dec 23 13:17:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 12698293 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E9AAC433EF for ; Thu, 23 Dec 2021 13:17:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348610AbhLWNRl (ORCPT ); Thu, 23 Dec 2021 08:17:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:53864 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348617AbhLWNRk (ORCPT ); Thu, 23 Dec 2021 08:17:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640265460; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=TVC1GQHPjkWS2kQl8UspAoN8IBhjJpUMo49RPwnmofY=; b=HdpdiMERu4Bneh1gm6D8V1vX5+9fimUUsmCfMY945VdLwqsKq1GSRnJdsDF1rtXRlLYYCg rpDH+6OwmzP2JBK2QP1BnUJwCuoGV2qVmmw4VedxwGi0KSYZwNkJkGh14XJJelY4pgQ9bm T3b3ZyWwEy86eyig3wLBCfkO1j96I34= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-517-Rx00fm_iOMiZI7r9s107mw-1; Thu, 23 Dec 2021 08:17:39 -0500 X-MC-Unique: Rx00fm_iOMiZI7r9s107mw-1 Received: by mail-ed1-f70.google.com with SMTP id ch27-20020a0564021bdb00b003f8389236f8so4424546edb.19 for ; Thu, 23 Dec 2021 05:17:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=TVC1GQHPjkWS2kQl8UspAoN8IBhjJpUMo49RPwnmofY=; b=NZAjfl/6nQ+RL8FsyfgutyW/gyMpebmBdJPEMStw/ycf8xX09QgMzC4PbgjMEjBKKM OicNORdP87EXA3+JOUx+idHaS1JvTfZSrYjJMfYpZKv9Erv0D4F1pOUKP7X0Dobz8W4u 6FUsd8EORf6kw9ZYSQGXYE3EcPv3wcJ8FVCI2SX4b5M845k+TIvGFKyRlKyVkzZBx6IH gsOeM4M1tW74jCeb9qX1jJPSUmYRpK9eLIzUyuA35yBCMvTo+7F6OjifP6JzjSJsJjes Z0fXz5WGrTkbUDkYuxVAD7DG0DOONzV5jE0eNyxLN2Gn049F2peMOXHGChuVYJq29uT0 dRwQ== X-Gm-Message-State: AOAM532YqHi9wycQbxMrlxDJgwiC4I8ZDYGUa6SWIURk+C5K/iJ6B74l 5xjF4Zf5qPr4Gg4eQPyQbHHxR5MmPWXKq8/MJibAPMwlcTZGIONqix5J0ccwwpMLneLzBJ0xe6s RNoZ+HIVvkWHnRnO2 X-Received: by 2002:a05:6402:268a:: with SMTP id w10mr1912140edd.257.1640265458215; Thu, 23 Dec 2021 05:17:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJyCiKIFpTbJoKXgfcKHEZ54xECpeKpBquce8nFLhnQd0JEH5XvYPFm0WKzuaxXXPxp5R5twDA== X-Received: by 2002:a05:6402:268a:: with SMTP id w10mr1912126edd.257.1640265458015; Thu, 23 Dec 2021 05:17:38 -0800 (PST) Received: from krava.redhat.com ([83.240.60.218]) by smtp.gmail.com with ESMTPSA id h10sm1708489ejx.115.2021.12.23.05.17.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 05:17:37 -0800 (PST) From: Jiri Olsa X-Google-Original-From: Jiri Olsa To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh Subject: [PATCH bpf-next 1/2] libbpf: Do not use btf_dump__new macro for c++ objects Date: Thu, 23 Dec 2021 14:17:35 +0100 Message-Id: <20211223131736.483956-1-jolsa@kernel.org> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net 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 Signed-off-by: Jiri Olsa Acked-by: Yonghong Song --- tools/lib/bpf/btf.h | 6 ++++++ 1 file changed, 6 insertions(+) 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); From patchwork Thu Dec 23 13:17:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 12698294 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60E3DC433EF for ; Thu, 23 Dec 2021 13:17:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348619AbhLWNRt (ORCPT ); Thu, 23 Dec 2021 08:17:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39733 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348613AbhLWNRt (ORCPT ); Thu, 23 Dec 2021 08:17:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640265468; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vNaSb3OMoRE9wcAdQ3zOWspvi+wy5zT/zyfsdS3SflI=; b=D/bETRX7Meu+pb3uasCt2Kx7shhwL2CRF3uDiuc8z+gifjBJQZl+zJH/KMJ3hhOuBW4xGj AMB17JaC/kXxQdt2Uv3mr/9g4abwYfE/moGJK5vOJrt2+I7jzA0a2kqrLw7uINmTUUrzIc tXu3wL76WTibKn6JvnlRB8UcOwyhxMY= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-552-y3O-JKGjOb-R8_9WETXIDQ-1; Thu, 23 Dec 2021 08:17:45 -0500 X-MC-Unique: y3O-JKGjOb-R8_9WETXIDQ-1 Received: by mail-ed1-f71.google.com with SMTP id eg23-20020a056402289700b003f80a27ca2bso4475140edb.14 for ; Thu, 23 Dec 2021 05:17:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vNaSb3OMoRE9wcAdQ3zOWspvi+wy5zT/zyfsdS3SflI=; b=bO2xgA4RHtxbM8pNxrUpduuJ0wFwILSFLsz+7z9b4KlE2S/2c8EygHDp/kxC2uancN uVKTeyuN3QurcFzDcSkSyUqOt6ypHZfA8XnKK5udT2XC+AFtL4SLQ246x5wWOkF440T+ vKAj4MdxC7EGDzSiImAnU1UkWEU2Qqhz9WOYsTeuBg0hmh8denw7cyeUWk6UZ/wXa57Y evlIKwdNsoVdDtagamaupO8UmKefqkyihLtyWY5qQMVIwJkeHMqKTaNeQUaPMwpEdjr2 EUnI5gAJ16mS6X7chCUPin26pmwHd8KWpVbDgptkU8ur+9VYss5gaZrvyMU6yYiAqrEI tMhA== X-Gm-Message-State: AOAM5312WKpnfTQYtPrdCNmU3STP52MCaG2EwFe71GCESG/1PHVuTZkQ 9rMd+xEOhfU221Dwx/hqdpIlNkh+1QhJDPTzsX+JIus+XIleby6MwzFbs4bUPkFSz1OfwUedikO bojIpYHWdWs2fjnpG X-Received: by 2002:a17:906:b18c:: with SMTP id w12mr1840151ejy.645.1640265464178; Thu, 23 Dec 2021 05:17:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJwC8968YE5ZR7LaPJnT75CxVmirtTVTSYzqV7G4OHSGq9VKb4UBEdVcbZQ/RxmUk787d2O6lw== X-Received: by 2002:a17:906:b18c:: with SMTP id w12mr1840136ejy.645.1640265464048; Thu, 23 Dec 2021 05:17:44 -0800 (PST) Received: from krava.redhat.com ([83.240.60.218]) by smtp.gmail.com with ESMTPSA id 6sm1743743ejj.164.2021.12.23.05.17.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 05:17:43 -0800 (PST) From: Jiri Olsa X-Google-Original-From: Jiri Olsa To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh Subject: [PATCH bpf-next 2/2] selftests/bpf: Add btf_dump__new to test_cpp Date: Thu, 23 Dec 2021 14:17:36 +0100 Message-Id: <20211223131736.483956-2-jolsa@kernel.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211223131736.483956-1-jolsa@kernel.org> References: <20211223131736.483956-1-jolsa@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Adding btf_dump__new call to test_cpp, so we can test C++ compilation with that. Signed-off-by: Jiri Olsa Acked-by: Yonghong Song --- tools/testing/selftests/bpf/test_cpp.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/test_cpp.cpp b/tools/testing/selftests/bpf/test_cpp.cpp index a8d2e9a87fbf..e00201de2890 100644 --- a/tools/testing/selftests/bpf/test_cpp.cpp +++ b/tools/testing/selftests/bpf/test_cpp.cpp @@ -7,9 +7,15 @@ /* do nothing, just make sure we can link successfully */ +static void dump_printf(void *ctx, const char *fmt, va_list args) +{ +} + int main(int argc, char *argv[]) { + struct btf_dump_opts opts = { }; struct test_core_extern *skel; + struct btf *btf; /* libbpf.h */ libbpf_set_print(NULL); @@ -18,7 +24,8 @@ int main(int argc, char *argv[]) bpf_prog_get_fd_by_id(0); /* btf.h */ - btf__new(NULL, 0); + btf = btf__new(NULL, 0); + btf_dump__new(btf, dump_printf, nullptr, &opts); /* BPF skeleton */ skel = test_core_extern__open_and_load();