qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH-for-10.2 v2] osdep: Undefine FSCALE definition to fix Solaris builds
@ 2025-12-03 12:03 Philippe Mathieu-Daudé
  2025-12-09 19:37 ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 2+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-12-03 12:03 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Eric Blake, Philippe Mathieu-Daudé,
	Richard Henderson

Solaris defines FSCALE in <sys/param.h>:

  301 /*
  302  * Scale factor for scaled integers used to count
  303  * %cpu time and load averages.
  304  */
  305 #define FSHIFT  8               /* bits to right of fixed binary point */
  306 #define FSCALE  (1<<FSHIFT)

When emulating the SVE FSCALE instruction, we defines the same name
in decodetree format in target/arm/tcg/sve.decode:

  1129:FSCALE          01100101 .. 00 1001 100 ... ..... .....    @rdn_pg_rm

This leads to a definition clash:

  In file included from ../target/arm/tcg/translate-sve.c:21:
  ../target/arm/tcg/translate.h:875:17: error: pasting "trans_" and "(" does not give a valid preprocessing token
    875 |     static bool trans_##NAME(DisasContext *s, arg_##NAME *a) \
        |                 ^~~~~~
  ../target/arm/tcg/translate-sve.c:4205:5: note: in expansion of macro 'TRANS_FEAT'
   4205 |     TRANS_FEAT(NAME, FEAT, gen_gvec_fpst_arg_zpzz, name##_zpzz_fns[a->esz], a)
        |     ^~~~~~~~~~
  ../target/arm/tcg/translate-sve.c:4249:1: note: in expansion of macro 'DO_ZPZZ_FP'
   4249 | DO_ZPZZ_FP(FSCALE, aa64_sve, sve_fscalbn)
        | ^~~~~~~~~~
  ../target/arm/tcg/translate-sve.c:4249:12: error: expected declaration specifiers or '...' before numeric constant
   4249 | DO_ZPZZ_FP(FSCALE, aa64_sve, sve_fscalbn)
        |            ^~~~~~
  ../target/arm/tcg/translate.h:875:25: note: in definition of macro 'TRANS_FEAT'
    875 |     static bool trans_##NAME(DisasContext *s, arg_##NAME *a) \
        |                         ^~~~
  ../target/arm/tcg/translate-sve.c:4249:1: note: in expansion of macro 'DO_ZPZZ_FP'
   4249 | DO_ZPZZ_FP(FSCALE, aa64_sve, sve_fscalbn)
        | ^~~~~~~~~~
  ../target/arm/tcg/translate.h:875:47: error: pasting "arg_" and "(" does not give a valid preprocessing token
    875 |     static bool trans_##NAME(DisasContext *s, arg_##NAME *a) \
        |                                               ^~~~
  ../target/arm/tcg/translate-sve.c:4205:5: note: in expansion of macro 'TRANS_FEAT'
   4205 |     TRANS_FEAT(NAME, FEAT, gen_gvec_fpst_arg_zpzz, name##_zpzz_fns[a->esz], a)
        |     ^~~~~~~~~~
  ../target/arm/tcg/translate-sve.c:4249:1: note: in expansion of macro 'DO_ZPZZ_FP'
   4249 | DO_ZPZZ_FP(FSCALE, aa64_sve, sve_fscalbn)
        | ^~~~~~~~~~
  In file included from ../target/arm/tcg/translate-sve.c:100:
  libqemu-aarch64-softmmu.a.p/decode-sve.c.inc:1227:13: warning: 'trans_FSCALE' used but never defined
   1227 | static bool trans_FSCALE(DisasContext *ctx, arg_FSCALE *a);
        |             ^~~~~~~~~~~~
  ../target/arm/tcg/translate-sve.c:4249:30: warning: 'sve_fscalbn_zpzz_fns' defined but not used [-Wunused-const-variable=]
   4249 | DO_ZPZZ_FP(FSCALE, aa64_sve, sve_fscalbn)
        |                              ^~~~~~~~~~~
  ../target/arm/tcg/translate-sve.c:4201:42: note: in definition of macro 'DO_ZPZZ_FP'
   4201 |     static gen_helper_gvec_4_ptr * const name##_zpzz_fns[4] = { \
        |                                          ^~~~

As a kludge, undefine it globally in <qemu/osdep.h>.

Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/qemu/osdep.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index cf8d7cf7e61..3cb45a14678 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -141,6 +141,12 @@ QEMU_EXTERN_C int daemon(int, int);
 #undef ELF_DATA
 #undef ELF_ARCH
 
+/*
+ * Avoid conflict with Solaris FSCALE definition from <sys/param.h> header,
+ * but we might as well do this unconditionally.
+ */
+#undef FSCALE
+
 #ifdef CONFIG_IOVEC
 #include <sys/uio.h>
 #endif
-- 
2.51.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH-for-10.2 v2] osdep: Undefine FSCALE definition to fix Solaris builds
  2025-12-03 12:03 [PATCH-for-10.2 v2] osdep: Undefine FSCALE definition to fix Solaris builds Philippe Mathieu-Daudé
@ 2025-12-09 19:37 ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 2+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-12-09 19:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Eric Blake, Richard Henderson

On 3/12/25 13:03, Philippe Mathieu-Daudé wrote:
> Solaris defines FSCALE in <sys/param.h>:
> 
>    301 /*
>    302  * Scale factor for scaled integers used to count
>    303  * %cpu time and load averages.
>    304  */
>    305 #define FSHIFT  8               /* bits to right of fixed binary point */
>    306 #define FSCALE  (1<<FSHIFT)
> 
> When emulating the SVE FSCALE instruction, we defines the same name
> in decodetree format in target/arm/tcg/sve.decode:
> 
>    1129:FSCALE          01100101 .. 00 1001 100 ... ..... .....    @rdn_pg_rm
> 
> This leads to a definition clash:
> 
>    In file included from ../target/arm/tcg/translate-sve.c:21:
>    ../target/arm/tcg/translate.h:875:17: error: pasting "trans_" and "(" does not give a valid preprocessing token
>      875 |     static bool trans_##NAME(DisasContext *s, arg_##NAME *a) \
>          |                 ^~~~~~
>    ../target/arm/tcg/translate-sve.c:4205:5: note: in expansion of macro 'TRANS_FEAT'
>     4205 |     TRANS_FEAT(NAME, FEAT, gen_gvec_fpst_arg_zpzz, name##_zpzz_fns[a->esz], a)
>          |     ^~~~~~~~~~
>    ../target/arm/tcg/translate-sve.c:4249:1: note: in expansion of macro 'DO_ZPZZ_FP'
>     4249 | DO_ZPZZ_FP(FSCALE, aa64_sve, sve_fscalbn)
>          | ^~~~~~~~~~
>    ../target/arm/tcg/translate-sve.c:4249:12: error: expected declaration specifiers or '...' before numeric constant
>     4249 | DO_ZPZZ_FP(FSCALE, aa64_sve, sve_fscalbn)
>          |            ^~~~~~
>    ../target/arm/tcg/translate.h:875:25: note: in definition of macro 'TRANS_FEAT'
>      875 |     static bool trans_##NAME(DisasContext *s, arg_##NAME *a) \
>          |                         ^~~~
>    ../target/arm/tcg/translate-sve.c:4249:1: note: in expansion of macro 'DO_ZPZZ_FP'
>     4249 | DO_ZPZZ_FP(FSCALE, aa64_sve, sve_fscalbn)
>          | ^~~~~~~~~~
>    ../target/arm/tcg/translate.h:875:47: error: pasting "arg_" and "(" does not give a valid preprocessing token
>      875 |     static bool trans_##NAME(DisasContext *s, arg_##NAME *a) \
>          |                                               ^~~~
>    ../target/arm/tcg/translate-sve.c:4205:5: note: in expansion of macro 'TRANS_FEAT'
>     4205 |     TRANS_FEAT(NAME, FEAT, gen_gvec_fpst_arg_zpzz, name##_zpzz_fns[a->esz], a)
>          |     ^~~~~~~~~~
>    ../target/arm/tcg/translate-sve.c:4249:1: note: in expansion of macro 'DO_ZPZZ_FP'
>     4249 | DO_ZPZZ_FP(FSCALE, aa64_sve, sve_fscalbn)
>          | ^~~~~~~~~~
>    In file included from ../target/arm/tcg/translate-sve.c:100:
>    libqemu-aarch64-softmmu.a.p/decode-sve.c.inc:1227:13: warning: 'trans_FSCALE' used but never defined
>     1227 | static bool trans_FSCALE(DisasContext *ctx, arg_FSCALE *a);
>          |             ^~~~~~~~~~~~
>    ../target/arm/tcg/translate-sve.c:4249:30: warning: 'sve_fscalbn_zpzz_fns' defined but not used [-Wunused-const-variable=]
>     4249 | DO_ZPZZ_FP(FSCALE, aa64_sve, sve_fscalbn)
>          |                              ^~~~~~~~~~~
>    ../target/arm/tcg/translate-sve.c:4201:42: note: in definition of macro 'DO_ZPZZ_FP'
>     4201 |     static gen_helper_gvec_4_ptr * const name##_zpzz_fns[4] = { \
>          |                                          ^~~~
> 
> As a kludge, undefine it globally in <qemu/osdep.h>.
> 
> Suggested-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/qemu/osdep.h | 6 ++++++
>   1 file changed, 6 insertions(+)

Per IRC:
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-12-09 19:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-03 12:03 [PATCH-for-10.2 v2] osdep: Undefine FSCALE definition to fix Solaris builds Philippe Mathieu-Daudé
2025-12-09 19:37 ` Philippe Mathieu-Daudé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).