Signed-off-by: Emmanouil Pitsidianakis <manos.pitsidiana...@linaro.org> --- audio/pwaudio.c | 8 ++++---- hw/arm/smmuv3.c | 2 +- include/qemu/compiler.h | 30 +++++++++++++++++++++++------- include/qemu/osdep.h | 4 ++-- target/loongarch/cpu.c | 4 ++-- target/loongarch/translate.c | 2 +- tcg/optimize.c | 8 ++++---- 7 files changed, 37 insertions(+), 21 deletions(-)
diff --git a/audio/pwaudio.c b/audio/pwaudio.c index 3ce5f6507b..bf26fadb06 100644 --- a/audio/pwaudio.c +++ b/audio/pwaudio.c @@ -8,16 +8,16 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ +#include <spa/param/audio/format-utils.h> +#include <spa/utils/ringbuffer.h> +#include <spa/utils/result.h> +#include <spa/param/props.h> #include "qemu/osdep.h" #include "qemu/module.h" #include "audio.h" #include <errno.h> #include "qemu/error-report.h" #include "qapi/error.h" -#include <spa/param/audio/format-utils.h> -#include <spa/utils/ringbuffer.h> -#include <spa/utils/result.h> -#include <spa/param/props.h> #include <pipewire/pipewire.h> #include "trace.h" diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index 6f2b2bd45f..545d82ff04 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -1291,7 +1291,7 @@ static int smmuv3_cmdq_consume(SMMUv3State *s) cmd_error = SMMU_CERROR_ILL; break; } - QEMU_FALLTHROUGH; + fallthrough; case SMMU_CMD_TLBI_NSNH_ALL: trace_smmuv3_cmdq_tlbi_nh(); smmu_inv_notifiers_all(&s->smmu_state); diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h index 1109482a00..959982805d 100644 --- a/include/qemu/compiler.h +++ b/include/qemu/compiler.h @@ -165,15 +165,31 @@ #define QEMU_ALWAYS_INLINE #endif -/** - * In most cases, normal "fallthrough" comments are good enough for - * switch-case statements, but sometimes the compiler has problems - * with those. In that case you can use QEMU_FALLTHROUGH instead. +/* + * Add the pseudo keyword 'fallthrough' so case statement blocks + * must end with any of these keywords: + * break; + * fallthrough; + * continue; + * goto <label>; + * return [expression]; + * + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes */ -#if __has_attribute(fallthrough) -# define QEMU_FALLTHROUGH __attribute__((fallthrough)) + +/* + * glib_macros.h contains its own definition of fallthrough, so if we define + * the pseudokeyword here it will expand when the glib header checks for the + * attribute. glib headers must be #included after this header. + */ +#ifdef fallthrough +#undef fallthrough +#endif + +#if __has_attribute(__fallthrough__) +# define fallthrough __attribute__((__fallthrough__)) #else -# define QEMU_FALLTHROUGH do {} while (0) /* fallthrough */ +# define fallthrough do {} while (0) /* fallthrough */ #endif #ifdef CONFIG_CFI diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 475a1c62ff..8f790f0deb 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -50,8 +50,6 @@ */ #pragma GCC poison TARGET_WORDS_BIGENDIAN -#include "qemu/compiler.h" - /* Older versions of C++ don't get definitions of various macros from * stdlib.h unless we define these macros before first inclusion of * that system header. @@ -160,6 +158,8 @@ QEMU_EXTERN_C int daemon(int, int); */ #include "glib-compat.h" +#include "qemu/compiler.h" + #ifdef _WIN32 #include "sysemu/os-win32.h" #endif diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index 2bea7ca5d5..e01d626b15 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -178,7 +178,7 @@ static void loongarch_cpu_do_interrupt(CPUState *cs) env->CSR_DBG = FIELD_DP64(env->CSR_DBG, CSR_DBG, DEI, 1); goto set_DERA; } - QEMU_FALLTHROUGH; + fallthrough; case EXCCODE_PIF: case EXCCODE_ADEF: cause = cs->exception_index; @@ -193,7 +193,7 @@ static void loongarch_cpu_do_interrupt(CPUState *cs) case EXCCODE_SXD: case EXCCODE_ASXD: env->CSR_BADV = env->pc; - QEMU_FALLTHROUGH; + fallthrough; case EXCCODE_BCE: case EXCCODE_ADEM: case EXCCODE_PIL: diff --git a/target/loongarch/translate.c b/target/loongarch/translate.c index 21f4db6fbd..36fceb1beb 100644 --- a/target/loongarch/translate.c +++ b/target/loongarch/translate.c @@ -317,7 +317,7 @@ static void loongarch_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) break; case DISAS_EXIT_UPDATE: tcg_gen_movi_tl(cpu_pc, ctx->base.pc_next); - QEMU_FALLTHROUGH; + fallthrough; case DISAS_EXIT: tcg_gen_exit_tb(NULL, 0); break; diff --git a/tcg/optimize.c b/tcg/optimize.c index 3013eb04e6..3da135a353 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1089,7 +1089,7 @@ static bool fold_brcond2(OptContext *ctx, TCGOp *op) case TCG_COND_NE: inv = 1; - QEMU_FALLTHROUGH; + fallthrough; case TCG_COND_EQ: /* * Simplify EQ/NE comparisons where one of the pairs @@ -1445,7 +1445,7 @@ static bool fold_exts(OptContext *ctx, TCGOp *op) break; case INDEX_op_ext_i32_i64: type_change = true; - QEMU_FALLTHROUGH; + fallthrough; case INDEX_op_ext32s_i64: sign = INT32_MIN; z_mask = (uint32_t)z_mask; @@ -1489,7 +1489,7 @@ static bool fold_extu(OptContext *ctx, TCGOp *op) case INDEX_op_extrl_i64_i32: case INDEX_op_extu_i32_i64: type_change = true; - QEMU_FALLTHROUGH; + fallthrough; case INDEX_op_ext32u_i64: z_mask = (uint32_t)z_mask; break; @@ -1861,7 +1861,7 @@ static bool fold_setcond2(OptContext *ctx, TCGOp *op) case TCG_COND_NE: inv = 1; - QEMU_FALLTHROUGH; + fallthrough; case TCG_COND_EQ: /* * Simplify EQ/NE comparisons where one of the pairs -- 2.39.2