From: Richard Henderson <richard.henderson@linaro.org>
To: "Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>,
qemu-devel@nongnu.org,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Pierrick Bouvier" <pierrick.bouvier@linaro.org>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
qemu-arm@nongnu.org, qemu-s390x@nongnu.org,
qemu-riscv@nongnu.org, qemu-ppc@nongnu.org,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Philippe Mathieu-Daudé" <philmd@mailo.com>,
"Zhao Liu" <zhao1.liu@intel.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Eric Blake" <eblake@redhat.com>
Subject: Re: [PATCH v3 02/15] cpus: Add const-qualified CPU environment accessors
Date: Fri, 21 Aug 2026 10:07:27 -0700 [thread overview]
Message-ID: <bde71c0c-ba94-4bd6-9ef9-e868fbd8562e@linaro.org> (raw)
In-Reply-To: <22188776-edeb-44e6-b79d-0b877292221d@oss.qualcomm.com>
On 8/21/26 08:51, Philippe Mathieu-Daudé wrote:
> No, this now fails distinctly on Ubuntu 24.04:
>
> In file included from ../accel/tcg/tcg-runtime.c:26:
> ../accel/tcg/tcg-runtime.c: In function ‘helper_exit_atomic’:
> /home/runner/work/qemu/qemu/include/exec/cpu-common.h:100:31: error: expected expression
> before ‘typeof’
> 100 | #define env_cpu(env) _Generic(typeof(*env), \
> | ^~~~~~
> ../accel/tcg/tcg-runtime.c:135:26: note: in expansion of macro ‘env_cpu’
> 135 | cpu_loop_exit_atomic(env_cpu(env), GETPC());
> | ^~~~~~~
Yeah, this of course fails because _Generic wants an expression and typeof() is a type not
an expression.
However, in this case less is more -- just don't dereference env:
#define env_cpu(env) _Generic(env, \
CPUArchState *: \
(CPUState *)((void *)(env) - sizeof(CPUState)), \
const CPUArchState *: \
(const CPUState *)((const void *)(env) - sizeof(CPUState)))
etc. It's only top-level qualifiers that are stripped (so const int -> const), but
qualified pointers aren't top level (so const int * and int * do not match).
r~
next prev parent reply other threads:[~2026-08-21 17:08 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-21 10:49 [PATCH v3 00/15] cpus: Constify @cpu in SysemuCPUOps::has_work() handler Philippe Mathieu-Daudé
2026-08-21 10:49 ` [PATCH v3 01/15] linux-user: Uncast void pointer argument as Object in target_cpu_free() Philippe Mathieu-Daudé
2026-08-21 10:49 ` [PATCH v3 02/15] cpus: Add const-qualified CPU environment accessors Philippe Mathieu-Daudé
2026-08-21 11:33 ` Philippe Mathieu-Daudé
2026-08-21 15:51 ` Philippe Mathieu-Daudé
2026-08-21 17:07 ` Richard Henderson [this message]
2026-08-24 9:32 ` Philippe Mathieu-Daudé
2026-08-21 16:44 ` Richard Henderson
2026-08-21 10:49 ` [PATCH v3 03/15] linux-user: Replace env_cpu_const() by generic env_cpu() equivalent Philippe Mathieu-Daudé
2026-08-21 10:49 ` [PATCH v3 04/15] system/cpus: Constify various CPUState arguments Philippe Mathieu-Daudé
2026-08-21 16:41 ` Richard Henderson
2026-08-21 10:49 ` [PATCH v3 05/15] target/avr: Constify CPUAVRState for some cpu_*() getters Philippe Mathieu-Daudé
2026-08-21 10:49 ` [PATCH v3 06/15] target/hexagon: Constify CPUHexagonState in hexagon_thread_is_enabled() Philippe Mathieu-Daudé
2026-08-21 10:49 ` [PATCH v3 07/15] target/i386: Constify CPU*State for cpu_*_interrupt() getters Philippe Mathieu-Daudé
2026-08-21 10:49 ` [PATCH v3 08/15] target/loongarch: Constify CPULoongArchState for various cpu_*() getters Philippe Mathieu-Daudé
2026-08-21 10:49 ` [PATCH v3 09/15] target/mips: Constify CPUMIPSState " Philippe Mathieu-Daudé
2026-08-21 10:49 ` [PATCH v3 10/15] target/s390x: Constify S390CPU for cpu_has_*() getters Philippe Mathieu-Daudé
2026-08-21 10:49 ` [PATCH v3 11/15] target/riscv: Constify @iprio argument in riscv_cpu_pending_to_irq() Philippe Mathieu-Daudé
2026-08-21 10:49 ` [PATCH v3 12/15] target/riscv: Constify CPURISCVState for various cpu_*() getters Philippe Mathieu-Daudé
2026-08-21 10:49 ` [PATCH v3 13/15] target/sparc: Constify CPUSPARCState " Philippe Mathieu-Daudé
2026-08-21 10:49 ` [PATCH v3 14/15] target/tricore: Document architectural interrupts as not implemented Philippe Mathieu-Daudé
2026-08-21 10:49 ` [PATCH v3 15/15] cpus: Constify @cpu in SysemuCPUOps::has_work() handler Philippe Mathieu-Daudé
2026-08-21 16:42 ` Richard Henderson
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=bde71c0c-ba94-4bd6-9ef9-e868fbd8562e@linaro.org \
--to=richard.henderson@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=eblake@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=philmd@mailo.com \
--cc=philmd@oss.qualcomm.com \
--cc=pierrick.bouvier@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=zhao1.liu@intel.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 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.