mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: James Hilliard <james.hilliard1@gmail.com>, bpf@vger.kernel.org
Cc: "Alexei Starovoitov" <ast@kernel.org>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Martin KaFai Lau" <kafai@fb.com>,
	"Song Liu" <songliubraving@fb.com>, "Yonghong Song" <yhs@fb.com>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"KP Singh" <kpsingh@kernel.org>, "Björn Töpel" <bjorn@kernel.org>,
	"Magnus Karlsson" <magnus.karlsson@intel.com>,
	"Maciej Fijalkowski" <maciej.fijalkowski@intel.com>,
	"Jonathan Lemon" <jonathan.lemon@gmail.com>,
	"open list:BPF (Safe dynamic programs and tools)"
	<netdev@vger.kernel.org>,
	"open list" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 1/1] libbpf: replace typeof with __typeof__
Date: Wed, 8 Jun 2022 14:50:52 +0200	[thread overview]
Message-ID: <b05401b0-308e-03a2-af94-4ecc5322fd1f@iogearbox.net> (raw)
In-Reply-To: <20220608064004.1493239-1-james.hilliard1@gmail.com>

Hi James,

On 6/8/22 8:40 AM, James Hilliard wrote:
> It seems the gcc preprocessor breaks when typeof is used with
> macros.
> 
> Fixes errors like:
> error: expected identifier or '(' before '#pragma'
>    106 | SEC("cgroup/bind6")
>        | ^~~
> 
> error: expected '=', ',', ';', 'asm' or '__attribute__' before '#pragma'
>    114 | char _license[] SEC("license") = "GPL";
>        | ^~~
> 
> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> ---
> Changes v1 -> v2:
>    - replace typeof with __typeof__ instead of changing pragma macros
> ---
>   tools/lib/bpf/bpf_core_read.h   | 16 ++++++++--------
>   tools/lib/bpf/bpf_helpers.h     |  4 ++--
>   tools/lib/bpf/bpf_tracing.h     | 24 ++++++++++++------------
>   tools/lib/bpf/btf.h             |  4 ++--
>   tools/lib/bpf/libbpf_internal.h |  6 +++---
>   tools/lib/bpf/usdt.bpf.h        |  6 +++---
>   tools/lib/bpf/xsk.h             | 12 ++++++------
>   7 files changed, 36 insertions(+), 36 deletions(-)
> 
> diff --git a/tools/lib/bpf/bpf_core_read.h b/tools/lib/bpf/bpf_core_read.h
> index fd48b1ff59ca..d3a88721c9e7 100644
> --- a/tools/lib/bpf/bpf_core_read.h
> +++ b/tools/lib/bpf/bpf_core_read.h
> @@ -111,7 +111,7 @@ enum bpf_enum_value_kind {
>   })
>   
>   #define ___bpf_field_ref1(field)	(field)
> -#define ___bpf_field_ref2(type, field)	(((typeof(type) *)0)->field)
> +#define ___bpf_field_ref2(type, field)	(((__typeof__(type) *)0)->field)
>   #define ___bpf_field_ref(args...)					    \
>   	___bpf_apply(___bpf_field_ref, ___bpf_narg(args))(args)
>   

Can't we just add the below?

#ifndef typeof
# define typeof __typeof__
#endif

Thanks,
Daniel

  reply	other threads:[~2022-06-08 12:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-08  6:40 James Hilliard
2022-06-08 12:50 ` Daniel Borkmann [this message]
2022-06-08 13:04   ` James Hilliard
2022-06-08 15:22     ` Daniel Borkmann
2022-06-09  6:14       ` James Hilliard

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=b05401b0-308e-03a2-af94-4ecc5322fd1f@iogearbox.net \
    --to=daniel@iogearbox.net \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bjorn@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=james.hilliard1@gmail.com \
    --cc=john.fastabend@gmail.com \
    --cc=jonathan.lemon@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maciej.fijalkowski@intel.com \
    --cc=magnus.karlsson@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®