Skip to content

Commit

Permalink
compiler.h: replace QEMU_NORETURN with G_NORETURN
Browse files Browse the repository at this point in the history
G_NORETURN was introduced in glib 2.68, fallback to G_GNUC_NORETURN in
glib-compat.

Note that this attribute must be placed before the function declaration
(bringing a bit of consistency in qemu codebase usage).

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Warner Losh <[email protected]>
Message-Id: <[email protected]>
  • Loading branch information
elmarco committed Apr 21, 2022
1 parent 94ae6b5 commit 8905770
Show file tree
Hide file tree
Showing 58 changed files with 214 additions and 191 deletions.
4 changes: 2 additions & 2 deletions accel/stubs/tcg-stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ void *probe_access(CPUArchState *env, target_ulong addr, int size,
g_assert_not_reached();
}

void QEMU_NORETURN cpu_loop_exit(CPUState *cpu)
G_NORETURN void cpu_loop_exit(CPUState *cpu)
{
g_assert_not_reached();
}

void QEMU_NORETURN cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc)
G_NORETURN void cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc)
{
g_assert_not_reached();
}
3 changes: 1 addition & 2 deletions accel/tcg/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
TranslationBlock *tb_gen_code(CPUState *cpu, target_ulong pc,
target_ulong cs_base, uint32_t flags,
int cflags);

void QEMU_NORETURN cpu_io_recompile(CPUState *cpu, uintptr_t retaddr);
G_NORETURN void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr);
void page_init(void);
void tb_htable_init(void);

Expand Down
3 changes: 2 additions & 1 deletion bsd-user/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,8 @@ static int core_dump_signal(int sig)
}

/* Abort execution with signal. */
static void QEMU_NORETURN dump_core_and_abort(int target_sig)
static G_NORETURN
void dump_core_and_abort(int target_sig)
{
CPUArchState *env = thread_cpu->env_ptr;
CPUState *cpu = env_cpu(env);
Expand Down
3 changes: 2 additions & 1 deletion hw/misc/mips_itu.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ static void wake_blocked_threads(ITCStorageCell *c)
c->blocked_threads = 0;
}

static void QEMU_NORETURN block_thread_and_exit(ITCStorageCell *c)
static G_NORETURN
void block_thread_and_exit(ITCStorageCell *c)
{
c->blocked_threads |= 1ULL << current_cpu->cpu_index;
current_cpu->halted = 1;
Expand Down
20 changes: 10 additions & 10 deletions include/exec/exec-all.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ void restore_state_to_opc(CPUArchState *env, TranslationBlock *tb,
*/
bool cpu_restore_state(CPUState *cpu, uintptr_t searched_pc, bool will_exit);

void QEMU_NORETURN cpu_loop_exit_noexc(CPUState *cpu);
void QEMU_NORETURN cpu_loop_exit(CPUState *cpu);
void QEMU_NORETURN cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc);
void QEMU_NORETURN cpu_loop_exit_atomic(CPUState *cpu, uintptr_t pc);
G_NORETURN void cpu_loop_exit_noexc(CPUState *cpu);
G_NORETURN void cpu_loop_exit(CPUState *cpu);
G_NORETURN void cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc);
G_NORETURN void cpu_loop_exit_atomic(CPUState *cpu, uintptr_t pc);

/**
* cpu_loop_exit_requested:
Expand Down Expand Up @@ -669,9 +669,9 @@ bool handle_sigsegv_accerr_write(CPUState *cpu, sigset_t *old_set,
* Use the TCGCPUOps hook to record cpu state, do guest operating system
* specific things to raise SIGSEGV, and jump to the main cpu loop.
*/
void QEMU_NORETURN cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr,
MMUAccessType access_type,
bool maperr, uintptr_t ra);
G_NORETURN void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr,
MMUAccessType access_type,
bool maperr, uintptr_t ra);

/**
* cpu_loop_exit_sigbus:
Expand All @@ -683,9 +683,9 @@ void QEMU_NORETURN cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr,
* Use the TCGCPUOps hook to record cpu state, do guest operating system
* specific things to raise SIGBUS, and jump to the main cpu loop.
*/
void QEMU_NORETURN cpu_loop_exit_sigbus(CPUState *cpu, target_ulong addr,
MMUAccessType access_type,
uintptr_t ra);
G_NORETURN void cpu_loop_exit_sigbus(CPUState *cpu, target_ulong addr,
MMUAccessType access_type,
uintptr_t ra);

#else
static inline void mmap_lock(void) {}
Expand Down
2 changes: 1 addition & 1 deletion include/exec/helper-head.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#define dh_ctype_ptr void *
#define dh_ctype_cptr const void *
#define dh_ctype_void void
#define dh_ctype_noreturn void QEMU_NORETURN
#define dh_ctype_noreturn G_NORETURN void
#define dh_ctype(t) dh_ctype_##t

#ifdef NEED_CPU_H
Expand Down
4 changes: 4 additions & 0 deletions include/glib-compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,8 @@ qemu_g_test_slow(void)

#pragma GCC diagnostic pop

#ifndef G_NORETURN
#define G_NORETURN G_GNUC_NORETURN
#endif

#endif
2 changes: 1 addition & 1 deletion include/hw/core/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ int cpu_watchpoint_address_matches(CPUState *cpu, vaddr addr, vaddr len);
*/
AddressSpace *cpu_get_address_space(CPUState *cpu, int asidx);

void QEMU_NORETURN cpu_abort(CPUState *cpu, const char *fmt, ...)
G_NORETURN void cpu_abort(CPUState *cpu, const char *fmt, ...)
G_GNUC_PRINTF(2, 3);

/* $(top_srcdir)/cpu.c */
Expand Down
6 changes: 3 additions & 3 deletions include/hw/core/tcg-cpu-ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ struct TCGCPUOps {
* @do_unaligned_access: Callback for unaligned access handling
* The callback must exit via raising an exception.
*/
void (*do_unaligned_access)(CPUState *cpu, vaddr addr,
MMUAccessType access_type,
int mmu_idx, uintptr_t retaddr) QEMU_NORETURN;
G_NORETURN void (*do_unaligned_access)(CPUState *cpu, vaddr addr,
MMUAccessType access_type,
int mmu_idx, uintptr_t retaddr);

/**
* @adjust_watchpoint_address: hack for cpu_check_watchpoint used by ARM
Expand Down
2 changes: 1 addition & 1 deletion include/hw/hw.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
#error Cannot include hw/hw.h from user emulation
#endif

void QEMU_NORETURN hw_error(const char *fmt, ...) G_GNUC_PRINTF(1, 2);
G_NORETURN void hw_error(const char *fmt, ...) G_GNUC_PRINTF(1, 2);

#endif
2 changes: 0 additions & 2 deletions include/qemu/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
#define QEMU_EXTERN_C extern
#endif

#define QEMU_NORETURN __attribute__ ((__noreturn__))

#if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__))
# define QEMU_PACKED __attribute__((gcc_struct, packed))
#else
Expand Down
3 changes: 2 additions & 1 deletion include/qemu/osdep.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ extern "C" {
* supports QEMU_ERROR, this will be reported at compile time; otherwise
* this will be reported at link time due to the missing symbol.
*/
extern void QEMU_NORETURN QEMU_ERROR("code path is reachable")
extern G_NORETURN
void QEMU_ERROR("code path is reachable")
qemu_build_not_reached_always(void);
#if defined(__OPTIMIZE__) && !defined(__NO_INLINE__)
#define qemu_build_not_reached() qemu_build_not_reached_always()
Expand Down
2 changes: 1 addition & 1 deletion include/qemu/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ void qemu_thread_create(QemuThread *thread, const char *name,
void *qemu_thread_join(QemuThread *thread);
void qemu_thread_get_self(QemuThread *thread);
bool qemu_thread_is_self(QemuThread *thread);
void qemu_thread_exit(void *retval) QEMU_NORETURN;
G_NORETURN void qemu_thread_exit(void *retval);
void qemu_thread_naming(bool enable);

struct Notifier;
Expand Down
4 changes: 2 additions & 2 deletions include/tcg/tcg-ldst.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ void helper_be_stq_mmu(CPUArchState *env, target_ulong addr, uint64_t val,

#else

void QEMU_NORETURN helper_unaligned_ld(CPUArchState *env, target_ulong addr);
void QEMU_NORETURN helper_unaligned_st(CPUArchState *env, target_ulong addr);
G_NORETURN void helper_unaligned_ld(CPUArchState *env, target_ulong addr);
G_NORETURN void helper_unaligned_st(CPUArchState *env, target_ulong addr);

#endif /* CONFIG_SOFTMMU */
#endif /* TCG_LDST_H */
2 changes: 1 addition & 1 deletion include/tcg/tcg.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ typedef TCGv_ptr TCGv_env;
#define TCG_CALL_NO_WRITE_GLOBALS 0x0002
/* Helper can be safely suppressed if the return value is not used. */
#define TCG_CALL_NO_SIDE_EFFECTS 0x0004
/* Helper is QEMU_NORETURN. */
/* Helper is G_NORETURN. */
#define TCG_CALL_NO_RETURN 0x0008

/* convenience version of most used call flags */
Expand Down
3 changes: 2 additions & 1 deletion linux-user/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,8 @@ void cpu_loop_exit_sigbus(CPUState *cpu, target_ulong addr,
}

/* abort execution with signal */
static void QEMU_NORETURN dump_core_and_abort(int target_sig)
static G_NORETURN
void dump_core_and_abort(int target_sig)
{
CPUState *cpu = thread_cpu;
CPUArchState *env = cpu->env_ptr;
Expand Down
2 changes: 1 addition & 1 deletion linux-user/user-internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
abi_long arg5, abi_long arg6, abi_long arg7,
abi_long arg8);
extern __thread CPUState *thread_cpu;
void QEMU_NORETURN cpu_loop(CPUArchState *env);
G_NORETURN void cpu_loop(CPUArchState *env);
const char *target_strerror(int err);
int get_osversion(void);
void init_qemu_uname_release(void);
Expand Down
4 changes: 2 additions & 2 deletions monitor/hmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@ void help_cmd(Monitor *mon, const char *name)
static const char *pch;
static sigjmp_buf expr_env;

static void G_GNUC_PRINTF(2, 3) QEMU_NORETURN
expr_error(Monitor *mon, const char *fmt, ...)
static G_NORETURN G_GNUC_PRINTF(2, 3)
void expr_error(Monitor *mon, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
Expand Down
12 changes: 8 additions & 4 deletions qemu-img.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ static void format_print(void *opaque, const char *name)
printf(" %s", name);
}

static void QEMU_NORETURN G_GNUC_PRINTF(1, 2) error_exit(const char *fmt, ...)
static G_NORETURN G_GNUC_PRINTF(1, 2)
void error_exit(const char *fmt, ...)
{
va_list ap;

Expand All @@ -112,18 +113,21 @@ static void QEMU_NORETURN G_GNUC_PRINTF(1, 2) error_exit(const char *fmt, ...)
exit(EXIT_FAILURE);
}

static void QEMU_NORETURN missing_argument(const char *option)
static G_NORETURN
void missing_argument(const char *option)
{
error_exit("missing argument for option '%s'", option);
}

static void QEMU_NORETURN unrecognized_option(const char *option)
static G_NORETURN
void unrecognized_option(const char *option)
{
error_exit("unrecognized option '%s'", option);
}

/* Please keep in synch with docs/tools/qemu-img.rst */
static void QEMU_NORETURN help(void)
static G_NORETURN
void help(void)
{
const char *help_msg =
QEMU_IMG_VERSION
Expand Down
2 changes: 1 addition & 1 deletion scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ sub help {
our $Attribute = qr{
const|
volatile|
QEMU_NORETURN|
G_NORETURN|
G_GNUC_WARN_UNUSED_RESULT|
G_GNUC_NULL_TERMINATED|
QEMU_PACKED|
Expand Down
2 changes: 1 addition & 1 deletion scripts/cocci-macro-file.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/

/* From qemu/compiler.h */
#define QEMU_NORETURN __attribute__ ((__noreturn__))
#define G_NORETURN __attribute__ ((__noreturn__))
#define G_GNUC_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
#define G_GNUC_NULL_TERMINATED __attribute__((sentinel))

Expand Down
10 changes: 5 additions & 5 deletions target/alpha/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,8 @@ void alpha_translate_init(void);
#define CPU_RESOLVING_TYPE TYPE_ALPHA_CPU

void alpha_cpu_list(void);
void QEMU_NORETURN dynamic_excp(CPUAlphaState *, uintptr_t, int, int);
void QEMU_NORETURN arith_excp(CPUAlphaState *, uintptr_t, int, uint64_t);
G_NORETURN void dynamic_excp(CPUAlphaState *, uintptr_t, int, int);
G_NORETURN void arith_excp(CPUAlphaState *, uintptr_t, int, uint64_t);

uint64_t cpu_alpha_load_fpcr (CPUAlphaState *env);
void cpu_alpha_store_fpcr (CPUAlphaState *env, uint64_t val);
Expand All @@ -452,9 +452,9 @@ void alpha_cpu_record_sigbus(CPUState *cs, vaddr address,
bool alpha_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
MMUAccessType access_type, int mmu_idx,
bool probe, uintptr_t retaddr);
void alpha_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
MMUAccessType access_type, int mmu_idx,
uintptr_t retaddr) QEMU_NORETURN;
G_NORETURN void alpha_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
MMUAccessType access_type, int mmu_idx,
uintptr_t retaddr);
void alpha_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
vaddr addr, unsigned size,
MMUAccessType access_type,
Expand Down
10 changes: 5 additions & 5 deletions target/alpha/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ void alpha_cpu_dump_state(CPUState *cs, FILE *f, int flags)

/* This should only be called from translate, via gen_excp.
We expect that ENV->PC has already been updated. */
void QEMU_NORETURN helper_excp(CPUAlphaState *env, int excp, int error)
G_NORETURN void helper_excp(CPUAlphaState *env, int excp, int error)
{
CPUState *cs = env_cpu(env);

Expand All @@ -524,8 +524,8 @@ void QEMU_NORETURN helper_excp(CPUAlphaState *env, int excp, int error)
}

/* This may be called from any of the helpers to set up EXCEPTION_INDEX. */
void QEMU_NORETURN dynamic_excp(CPUAlphaState *env, uintptr_t retaddr,
int excp, int error)
G_NORETURN void dynamic_excp(CPUAlphaState *env, uintptr_t retaddr,
int excp, int error)
{
CPUState *cs = env_cpu(env);

Expand All @@ -539,8 +539,8 @@ void QEMU_NORETURN dynamic_excp(CPUAlphaState *env, uintptr_t retaddr,
cpu_loop_exit(cs);
}

void QEMU_NORETURN arith_excp(CPUAlphaState *env, uintptr_t retaddr,
int exc, uint64_t mask)
G_NORETURN void arith_excp(CPUAlphaState *env, uintptr_t retaddr,
int exc, uint64_t mask)
{
env->trap_arg0 = exc;
env->trap_arg1 = mask;
Expand Down
12 changes: 6 additions & 6 deletions target/arm/internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ FIELD(V7M_EXCRET, RES1, 7, 25) /* including the must-be-1 prefix */
* and target exception level. This should be called from helper functions,
* and never returns because we will longjump back up to the CPU main loop.
*/
void QEMU_NORETURN raise_exception(CPUARMState *env, uint32_t excp,
uint32_t syndrome, uint32_t target_el);
G_NORETURN void raise_exception(CPUARMState *env, uint32_t excp,
uint32_t syndrome, uint32_t target_el);

/*
* Similarly, but also use unwinding to restore cpu state.
*/
void QEMU_NORETURN raise_exception_ra(CPUARMState *env, uint32_t excp,
G_NORETURN void raise_exception_ra(CPUARMState *env, uint32_t excp,
uint32_t syndrome, uint32_t target_el,
uintptr_t ra);

Expand Down Expand Up @@ -606,9 +606,9 @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate);
bool arm_s1_regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx);

/* Raise a data fault alignment exception for the specified virtual address */
void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr,
MMUAccessType access_type,
int mmu_idx, uintptr_t retaddr) QEMU_NORETURN;
G_NORETURN void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr,
MMUAccessType access_type,
int mmu_idx, uintptr_t retaddr);

/* arm_cpu_do_transaction_failed: handle a memory system error response
* (eg "no device/memory present at address") by raising an external abort
Expand Down
4 changes: 2 additions & 2 deletions target/arm/pauth_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ static uint64_t pauth_strip(CPUARMState *env, uint64_t ptr, bool data)
return pauth_original_ptr(ptr, param);
}

static void QEMU_NORETURN pauth_trap(CPUARMState *env, int target_el,
uintptr_t ra)
static G_NORETURN
void pauth_trap(CPUARMState *env, int target_el, uintptr_t ra)
{
raise_exception_ra(env, EXCP_UDEF, syn_pactrap(), target_el, ra);
}
Expand Down
7 changes: 4 additions & 3 deletions target/arm/tlb_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ static uint32_t compute_fsr_fsc(CPUARMState *env, ARMMMUFaultInfo *fi,
return fsr;
}

static void QEMU_NORETURN arm_deliver_fault(ARMCPU *cpu, vaddr addr,
MMUAccessType access_type,
int mmu_idx, ARMMMUFaultInfo *fi)
static G_NORETURN
void arm_deliver_fault(ARMCPU *cpu, vaddr addr,
MMUAccessType access_type,
int mmu_idx, ARMMMUFaultInfo *fi)
{
CPUARMState *env = &cpu->env;
int target_el;
Expand Down
9 changes: 5 additions & 4 deletions target/hexagon/op_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,18 @@
#define SF_MANTBITS 23

/* Exceptions processing helpers */
static void QEMU_NORETURN do_raise_exception_err(CPUHexagonState *env,
uint32_t exception,
uintptr_t pc)
static G_NORETURN
void do_raise_exception_err(CPUHexagonState *env,
uint32_t exception,
uintptr_t pc)
{
CPUState *cs = env_cpu(env);
qemu_log_mask(CPU_LOG_INT, "%s: %d\n", __func__, exception);
cs->exception_index = exception;
cpu_loop_exit_restore(cs, pc);
}

void QEMU_NORETURN HELPER(raise_exception)(CPUHexagonState *env, uint32_t excp)
G_NORETURN void HELPER(raise_exception)(CPUHexagonState *env, uint32_t excp)
{
do_raise_exception_err(env, excp, 0);
}
Expand Down
Loading

0 comments on commit 8905770

Please sign in to comment.