@samitouri / QOSamiQemu / commits / fe04a3953a

target/ppc: Fix TRANS* macro variadic arguments handling

Use ##__VA_ARGS__ in TRANS* macros to allow variadic arguments to be optional instead of mandatory. "##" removes the preceding comma when __VA_ARGS__ is empty, enabling macros to work with functions that don't need extra parameters. This avoid compilation errors when using a pattern like below: static bool do_wait(DisasContext *ctx, arg_X_wait *a) {...} TRANS_FLAGS(WAIT, WAIT_ISA_2_X, do_wait) Compilation Error: ../target/ppc/translate.c:5526:40: error: expected expression before ‘)’ token 5526 | return FUNC(ctx, a, __VA_ARGS__); \ | ^ ../target/ppc/translate/storage-ctrl-impl.c.inc:368:1: note: in expansion of macro ‘TRANS_FLAGS’ 368 | TRANS_FLAGS(WAIT, WAIT_ISA_2_X, do_wait) Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com> Reviewed-by: Glenn Miles <milesg@linux.ibm.com> Reviewed-by: Amit Machhiwal <amachhiw@linux.ibm.com> Signed-off-by: Chinmay Rath <rathc@linux.ibm.com> Tested-by: Aniket Sahu <asahu1x@linux.ibm.com> Link: https://lore.kernel.org/qemu-devel/20260827133010.278889-17-rathc@linux.ibm.com Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>

Ojaswin Mujoo committed Aug 27, 2026 at 18:59 UTC fe04a3953afe18f67f8eb30ff6af2dc665a0c410
1 file changed +5 -5
target/ppc/translate.c
+5 -5
@@ -4749,29 +4749,29 @@ static int64_t dw_compose_ea(DisasContext *ctx, int x)
4749 */
4750 #define TRANS(NAME, FUNC, ...) \
4751 static bool trans_##NAME(DisasContext *ctx, arg_##NAME *a) \
4752 - { return FUNC(ctx, a, __VA_ARGS__); }
4752 + { return FUNC(ctx, a, ##__VA_ARGS__); }
4753 #define TRANS_FLAGS(FLAGS, NAME, FUNC, ...) \
4754 static bool trans_##NAME(DisasContext *ctx, arg_##NAME *a) \
4755 { \
4756 REQUIRE_INSNS_FLAGS(ctx, FLAGS); \
4757 - return FUNC(ctx, a, __VA_ARGS__); \
4757 + return FUNC(ctx, a, ##__VA_ARGS__); \
4758 }
4759 #define TRANS_FLAGS2(FLAGS2, NAME, FUNC, ...) \
4760 static bool trans_##NAME(DisasContext *ctx, arg_##NAME *a) \
4761 { \
4762 REQUIRE_INSNS_FLAGS2(ctx, FLAGS2); \
4763 - return FUNC(ctx, a, __VA_ARGS__); \
4763 + return FUNC(ctx, a, ##__VA_ARGS__); \
4764 }
4765
4766 #define TRANS64(NAME, FUNC, ...) \
4767 static bool trans_##NAME(DisasContext *ctx, arg_##NAME *a) \
4768 - { REQUIRE_64BIT(ctx); return FUNC(ctx, a, __VA_ARGS__); }
4768 + { REQUIRE_64BIT(ctx); return FUNC(ctx, a, ##__VA_ARGS__); }
4769 #define TRANS64_FLAGS2(FLAGS2, NAME, FUNC, ...) \
4770 static bool trans_##NAME(DisasContext *ctx, arg_##NAME *a) \
4771 { \
4772 REQUIRE_64BIT(ctx); \
4773 REQUIRE_INSNS_FLAGS2(ctx, FLAGS2); \
4774 - return FUNC(ctx, a, __VA_ARGS__); \
4774 + return FUNC(ctx, a, ##__VA_ARGS__); \
4775 }
4776
4777 /* TODO: More TRANS* helpers for extra insn_flags checks. */