Commit 7d99a001df854ef950a128000cbd982c4f6cd616

Authored by blueswir1
1 parent fdf7ed96

Add noreturn function attribute

Introduce noreturn attribute and attach it to cpu_loop_exit as well as
interrupt/exception helpers for i386. This avoids a bunch of gcc4
warnings.

[ Note that this patch comes with a workaround to include qemu-common.h
even in cases where is currently causes conflicts with dyngen-exec.h.
I've been told that these conflicts will get resolved in the future
(/me will try to have a look as well - as time permits). ]

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6303 c046a42c-6fe2-441c-8c8c-71466251a162
cpu-all.h
@@ -20,6 +20,8 @@ @@ -20,6 +20,8 @@
20 #ifndef CPU_ALL_H 20 #ifndef CPU_ALL_H
21 #define CPU_ALL_H 21 #define CPU_ALL_H
22 22
  23 +#include "qemu-common.h"
  24 +
23 #if defined(__arm__) || defined(__sparc__) || defined(__mips__) || defined(__hppa__) 25 #if defined(__arm__) || defined(__sparc__) || defined(__mips__) || defined(__hppa__)
24 #define WORDS_ALIGNED 26 #define WORDS_ALIGNED
25 #endif 27 #endif
@@ -751,9 +753,8 @@ void cpu_dump_statistics (CPUState *env, FILE *f, @@ -751,9 +753,8 @@ void cpu_dump_statistics (CPUState *env, FILE *f,
751 int (*cpu_fprintf)(FILE *f, const char *fmt, ...), 753 int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
752 int flags); 754 int flags);
753 755
754 -void cpu_abort(CPUState *env, const char *fmt, ...)  
755 - __attribute__ ((__format__ (__printf__, 2, 3)))  
756 - __attribute__ ((__noreturn__)); 756 +void noreturn cpu_abort(CPUState *env, const char *fmt, ...)
  757 + __attribute__ ((__format__ (__printf__, 2, 3)));
757 extern CPUState *first_cpu; 758 extern CPUState *first_cpu;
758 extern CPUState *cpu_single_env; 759 extern CPUState *cpu_single_env;
759 extern int64_t qemu_icount; 760 extern int64_t qemu_icount;
darwin-user/signal.c
@@ -37,6 +37,7 @@ @@ -37,6 +37,7 @@
37 #include <signal.h> 37 #include <signal.h>
38 38
39 #include "qemu.h" 39 #include "qemu.h"
  40 +#include "qemu-common.h"
40 41
41 #define DEBUG_SIGNAL 42 #define DEBUG_SIGNAL
42 43
@@ -132,7 +133,7 @@ static inline void free_sigqueue(struct sigqueue *q) @@ -132,7 +133,7 @@ static inline void free_sigqueue(struct sigqueue *q)
132 } 133 }
133 134
134 /* abort execution with signal */ 135 /* abort execution with signal */
135 -void __attribute((noreturn)) force_sig(int sig) 136 +void noreturn force_sig(int sig)
136 { 137 {
137 int host_sig; 138 int host_sig;
138 host_sig = target_to_host_signal(sig); 139 host_sig = target_to_host_signal(sig);
exec-all.h
@@ -20,6 +20,9 @@ @@ -20,6 +20,9 @@
20 20
21 #ifndef _EXEC_ALL_H_ 21 #ifndef _EXEC_ALL_H_
22 #define _EXEC_ALL_H_ 22 #define _EXEC_ALL_H_
  23 +
  24 +#include "qemu-common.h"
  25 +
23 /* allow to see translation results - the slowdown should be negligible, so we leave it */ 26 /* allow to see translation results - the slowdown should be negligible, so we leave it */
24 #define DEBUG_DISAS 27 #define DEBUG_DISAS
25 28
@@ -82,7 +85,7 @@ TranslationBlock *tb_gen_code(CPUState *env, @@ -82,7 +85,7 @@ TranslationBlock *tb_gen_code(CPUState *env,
82 target_ulong pc, target_ulong cs_base, int flags, 85 target_ulong pc, target_ulong cs_base, int flags,
83 int cflags); 86 int cflags);
84 void cpu_exec_init(CPUState *env); 87 void cpu_exec_init(CPUState *env);
85 -void cpu_loop_exit(void); 88 +void noreturn cpu_loop_exit(void);
86 int page_unprotect(target_ulong address, unsigned long pc, void *puc); 89 int page_unprotect(target_ulong address, unsigned long pc, void *puc);
87 void tb_invalidate_phys_page_range(target_phys_addr_t start, target_phys_addr_t end, 90 void tb_invalidate_phys_page_range(target_phys_addr_t start, target_phys_addr_t end,
88 int is_cpu_write_access); 91 int is_cpu_write_access);
linux-user/signal.c
@@ -28,6 +28,7 @@ @@ -28,6 +28,7 @@
28 #include <sys/ucontext.h> 28 #include <sys/ucontext.h>
29 29
30 #include "qemu.h" 30 #include "qemu.h"
  31 +#include "qemu-common.h"
31 #include "target_signal.h" 32 #include "target_signal.h"
32 33
33 //#define DEBUG_SIGNAL 34 //#define DEBUG_SIGNAL
@@ -348,7 +349,7 @@ static inline void free_sigqueue(CPUState *env, struct sigqueue *q) @@ -348,7 +349,7 @@ static inline void free_sigqueue(CPUState *env, struct sigqueue *q)
348 } 349 }
349 350
350 /* abort execution with signal */ 351 /* abort execution with signal */
351 -static void __attribute((noreturn)) force_sig(int sig) 352 +static void noreturn force_sig(int sig)
352 { 353 {
353 int host_sig; 354 int host_sig;
354 host_sig = target_to_host_signal(sig); 355 host_sig = target_to_host_signal(sig);
qemu-common.h
@@ -2,6 +2,13 @@ @@ -2,6 +2,13 @@
2 #ifndef QEMU_COMMON_H 2 #ifndef QEMU_COMMON_H
3 #define QEMU_COMMON_H 3 #define QEMU_COMMON_H
4 4
  5 +#define noreturn __attribute__ ((__noreturn__))
  6 +
  7 +/* Hack around the mess dyngen-exec.h causes: We need noreturn in files that
  8 + cannot include the following headers without conflicts. This condition has
  9 + to be removed once dyngen is gone. */
  10 +#ifndef __DYNGEN_EXEC_H__
  11 +
5 /* we put basic includes here to avoid repeating them in device drivers */ 12 /* we put basic includes here to avoid repeating them in device drivers */
6 #include <stdlib.h> 13 #include <stdlib.h>
7 #include <stdio.h> 14 #include <stdio.h>
@@ -134,9 +141,8 @@ void *get_mmap_addr(unsigned long size); @@ -134,9 +141,8 @@ void *get_mmap_addr(unsigned long size);
134 141
135 /* Error handling. */ 142 /* Error handling. */
136 143
137 -void hw_error(const char *fmt, ...)  
138 - __attribute__ ((__format__ (__printf__, 1, 2)))  
139 - __attribute__ ((__noreturn__)); 144 +void noreturn hw_error(const char *fmt, ...)
  145 + __attribute__ ((__format__ (__printf__, 1, 2)));
140 146
141 /* IO callbacks. */ 147 /* IO callbacks. */
142 typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size); 148 typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
@@ -179,4 +185,6 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id); @@ -179,4 +185,6 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id);
179 /* Force QEMU to stop what it's doing and service IO */ 185 /* Force QEMU to stop what it's doing and service IO */
180 void qemu_service_io(void); 186 void qemu_service_io(void);
181 187
  188 +#endif /* dyngen-exec.h hack */
  189 +
182 #endif 190 #endif
qemu-img.c
@@ -34,7 +34,7 @@ @@ -34,7 +34,7 @@
34 /* Default to cache=writeback as data integrity is not important for qemu-tcg. */ 34 /* Default to cache=writeback as data integrity is not important for qemu-tcg. */
35 #define BRDV_O_FLAGS BDRV_O_CACHE_WB 35 #define BRDV_O_FLAGS BDRV_O_CACHE_WB
36 36
37 -static void __attribute__((noreturn)) error(const char *fmt, ...) 37 +static void noreturn error(const char *fmt, ...)
38 { 38 {
39 va_list ap; 39 va_list ap;
40 va_start(ap, fmt); 40 va_start(ap, fmt);
target-i386/exec.h
@@ -31,6 +31,7 @@ @@ -31,6 +31,7 @@
31 31
32 register struct CPUX86State *env asm(AREG0); 32 register struct CPUX86State *env asm(AREG0);
33 33
  34 +#include "qemu-common.h"
34 #include "qemu-log.h" 35 #include "qemu-log.h"
35 36
36 #define EAX (env->regs[R_EAX]) 37 #define EAX (env->regs[R_EAX])
@@ -62,8 +63,8 @@ void do_interrupt(int intno, int is_int, int error_code, @@ -62,8 +63,8 @@ void do_interrupt(int intno, int is_int, int error_code,
62 target_ulong next_eip, int is_hw); 63 target_ulong next_eip, int is_hw);
63 void do_interrupt_user(int intno, int is_int, int error_code, 64 void do_interrupt_user(int intno, int is_int, int error_code,
64 target_ulong next_eip); 65 target_ulong next_eip);
65 -void raise_exception_err(int exception_index, int error_code);  
66 -void raise_exception(int exception_index); 66 +void noreturn raise_exception_err(int exception_index, int error_code);
  67 +void noreturn raise_exception(int exception_index);
67 void do_smm_enter(void); 68 void do_smm_enter(void);
68 69
69 /* n must be a constant to be efficient */ 70 /* n must be a constant to be efficient */
target-i386/op_helper.c
@@ -1284,8 +1284,8 @@ static int check_exception(int intno, int *error_code) @@ -1284,8 +1284,8 @@ static int check_exception(int intno, int *error_code)
1284 * EIP value AFTER the interrupt instruction. It is only relevant if 1284 * EIP value AFTER the interrupt instruction. It is only relevant if
1285 * is_int is TRUE. 1285 * is_int is TRUE.
1286 */ 1286 */
1287 -static void raise_interrupt(int intno, int is_int, int error_code,  
1288 - int next_eip_addend) 1287 +static void noreturn raise_interrupt(int intno, int is_int, int error_code,
  1288 + int next_eip_addend)
1289 { 1289 {
1290 if (!is_int) { 1290 if (!is_int) {
1291 helper_svm_check_intercept_param(SVM_EXIT_EXCP_BASE + intno, error_code); 1291 helper_svm_check_intercept_param(SVM_EXIT_EXCP_BASE + intno, error_code);