All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Maxim Skokov" <skokovmaksimevg@gmail.com>, <bpf@vger.kernel.org>
Cc: <daniel@iogearbox.net>, <andrii@kernel.org>, <eddyz87@gmail.com>,
	<yonghong.song@linux.dev>
Subject: Re: [PATCH bpf-next] bpf: Cast helper IDs to the helper type in bpf_helper_defs.h
Date: Wed, 21 Oct 2026 00:42:44 +0000	[thread overview]
Message-ID: <DMA3L9A79PD7.DRTZ2IXQUVA7@gmail.com> (raw)
In-Reply-To: <20261020101229.111074-1-skokovmaksimevg@gmail.com>

On Tue, Oct 20, 2026 at 03:12 AM Maxim Skokov <skokovmaksimevg@gmail.com> wrote:
> Converting void * to a function pointer is a GNU extension in C (gcc
> -pedantic: "ISO C forbids initialization between function pointer and
> 'void *'") and an error in C++, so BPF programs written in C++ can't
> include bpf_helpers.h.

What C++ programs you have in mind?
Since today there is one as a selftest.
C++ is far from being supported.

... and including the header doesn't get them far. bpf_for() and bpf_repeat()
in bpf_helpers.h initialize 'struct bpf_iter_num *___p' with (void *)0,
which is an error in C++. The bpf_iter_num_*() externs there have no
extern "C", so the kfunc names get mangled. vmlinux.h doesn't compile
as C++ at all: struct page has a field named private and struct device
has one named class.

> Tested: the generated header compiles with clang for the bpf target as
> C, gnu++20 and c++17, and with gcc as C; with gcc -pedantic the 211
> function pointer warnings are gone. All 1082 selftests BPF programs
> build to byte-identical objects with the old and the new header.

Those are all C programs.

It feels to me that you're scratching the surface.
We have to see full roadmap to decide whether we should even bother
making these steps.

pw-bot: cr

  reply	other threads:[~2026-10-21  0:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20 10:12 [PATCH bpf-next] bpf: Cast helper IDs to the helper type in bpf_helper_defs.h Maxim Skokov
2026-10-21  0:42 ` Alexei Starovoitov [this message]
2026-10-21  1:34   ` Kumar Kartikeya Dwivedi
2026-10-21  5:17   ` Maxim Skokov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DMA3L9A79PD7.DRTZ2IXQUVA7@gmail.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=skokovmaksimevg@gmail.com \
    --cc=yonghong.song@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.