gcc -Wundef, TCG bug
RFC PATCH 1/1 gcc -Wundef, TCG bug
The first patch enables gcc flag -Wundef, the second one fixes most warnings caused by this. Nothing spectacular.
Now the third patch is more interesting. It looks like there is a real bug in TCG, exposed by the new warnings. The following code in tcg-opc.h depends on TARGET_LONG_BITS being defined, which is not the case:
/* QEMU specific */
#if TARGET_LONG_BITS > TCG_TARGET_REG_BITS DEF2(debug_insn_start, 0, 0, 2, 0)
#elseDEF2(debug_insn_start, 0, 0, 1, 0)
#endif
Moreover, adding an #include "cpu.h" to get TARGET_LONG_BITS defined, breaks dyngen targets because the prototypes in cpu.h conflict with the generated code.
I propose to enable the gcc flag, even though it causes these warnings with TCG code, just to remind us about the problem. The second patch should be safe to apply. The third one should be applied only after the tcg-opc.h change is judged safe and dyngen targets have been converted to TCG.
Makefile.target +1 -1
@@ -73,7 +73,7 @@ PROGS=$(QEMU_PROG) # We require -O2 to avoid the stack setup prologue in EXIT_TB -OP_CFLAGS := -Wall -Wredundant-decls -Wstrict-prototypes -Wmissing-prototypes -O2 -g -fno-strict-aliasing +OP_CFLAGS := -Wall -Wredundant-decls -Wstrict-prototypes -Wmissing-prototypes -Wundef -O2 -g -fno-strict-aliasing # cc-option # Usage: OP_CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)
configure +1 -1
@@ -355,7 +355,7 @@ done # default flags for all hosts -CFLAGS="$CFLAGS -Wall -Wredundant-decls -Wstrict-prototypes -Wmissing-prototypes -O2 -g -fno-strict-aliasing" +CFLAGS="$CFLAGS -Wall -Wredundant-decls -Wstrict-prototypes -Wmissing-prototypes -Wundef -O2 -g -fno-strict-aliasing" LDFLAGS="$LDFLAGS -g" if test "$werror" = "yes" ; then CFLAGS="$CFLAGS -Werror"
exec.c +2 -2
@@ -2259,7 +2259,7 @@#endif #ifdef TARGET_SPARC do_unassigned_access (addr,0 ,0 ,0 ); -#elif TARGET_CRIS +#elif defined(TARGET_CRIS )do_unassigned_access (addr,0 ,0 ,0 );#endif return 0 ;
@@ -2272,7 +2272,7 @@#endif #ifdef TARGET_SPARC do_unassigned_access (addr,1 ,0 ,0 ); -#elif TARGET_CRIS +#elif defined(TARGET_CRIS )do_unassigned_access (addr,1 ,0 ,0 );#endif }
hw/pc.c +1 -1
@@ -80,7 +80,7 @@/* Note: when using kqemu, it is more logical to return the host TSC because kqemu does not trap the RDTSC instruction for performance reasons */ -#if USE_KQEMU +#ifdef USE_KQEMU if (env->kqemu_enabled) {return cpu_get_real_ticks (); }else
hw/rtl8139.c +2 -2
@@ -3356,7 +3356,7 @@return next_time; } -#if RTL8139_ONBOARD_TIMER +#ifdef RTL8139_ONBOARD_TIMER static void rtl8139_timer (void *opaque) {RTL8139State *s = opaque;
@@ -3456,7 +3456,7 @@register_savevm ("rtl8139" ,-1 ,3 , rtl8139_save, rtl8139_load, s); -#if RTL8139_ONBOARD_TIMER +#ifdef RTL8139_ONBOARD_TIMER s->timer =qemu_new_timer (vm_clock, rtl8139_timer, s); qemu_mod_timer(s->timer,
hw/usb-net.c +5 -5
@@ -1069,7 +1069,7 @@case ClassInterfaceOutRequest |USB_CDC_SEND_ENCAPSULATED_COMMAND :if (!s->rndis || value || index !=0 ) goto fail; -#if TRAFFIC_DEBUG +#ifdef TRAFFIC_DEBUG {unsigned int i;fprintf (stderr,"SEND_ENCAPSULATED_COMMAND:" );
@@ -1092,7 +1092,7 @@ data[0 ] =0 ; ret =1 ; } -#if TRAFFIC_DEBUG +#ifdef TRAFFIC_DEBUG {unsigned int i;fprintf (stderr,"GET_ENCAPSULATED_RESPONSE:" );
@@ -1219,7 +1219,7 @@if (!s->rndis_resp.tqh_first) ret =USB_RET_NAK ; -#if DEBUG +#ifdef TRAFFIC_DEBUG fprintf (stderr,"usbnet: interrupt poll len %u return %d" , p->len, ret); {int i;
@@ -1260,7 +1260,7 @@ s->in_ptr = s->in_len =0 ; } -#if TRAFFIC_DEBUG +#ifdef TRAFFIC_DEBUG fprintf (stderr,"usbnet: data in len %u return %d" , p->len, ret); {int i;
@@ -1285,7 +1285,7 @@ (struct rndis_packet_msg_type *) s->out_buf;uint32_t len; -#if TRAFFIC_DEBUG +#ifdef TRAFFIC_DEBUG fprintf (stderr,"usbnet: data out len %u\n" , p->len); {int i;
hw/usb-ohci.c +1 -1
@@ -1598,7 +1598,7 @@int i;if (usb_frame_time ==0 ) { -#if OHCI_TIME_WARP +#ifdef OHCI_TIME_WARP usb_frame_time = ticks_per_sec; usb_bit_time =muldiv64 (1 , ticks_per_sec,USB_HZ /1000 );#else
slirp/ip_icmp.c +2 -2
@@ -228,7 +228,7 @@/* check msrc */ if (!msrc) goto end_error; ip = mtod(msrc, struct ip *); -#if DEBUG +#ifdef DEBUG {char bufa[20 ], bufb[20 ];strcpy (bufa,inet_ntoa (ip->ip_src));strcpy (bufb,inet_ntoa (ip->ip_dst));
@@ -285,7 +285,7 @@HTONS (icp->icmp_ip.ip_id);HTONS (icp->icmp_ip.ip_off); -#if DEBUG +#ifdef DEBUG if (message) {/* DEBUG : append message to ICMP packet */ int message_len;char *cpnt;
slirp/slirp.h +1 -1
@@ -103,7 +103,7 @@# include <sys/time.h> # include <time.h> #else -# if HAVE_SYS_TIME_H +# ifdef HAVE_SYS_TIME_H # include <sys/time.h> # else # include <time.h>
target-i386/op_helper.c +1 -1
@@ -1217,7 +1217,7 @@ } }if (env->cr[0 ] &CR0_PE_MASK ) { -#if TARGET_X86_64 +#ifdef TARGET_X86_64 if (env->hflags &HF_LMA_MASK ) {do_interrupt64 (intno, is_int, error_code, next_eip, is_hw); }else
vnc.c +20 -20
@@ -35,14 +35,14 @@#include "keymaps.c" #include "d3des.h" -#if CONFIG_VNC_TLS +#ifdef CONFIG_VNC_TLS #include <gnutls/gnutls.h> #include <gnutls/x509.h> #endif /* CONFIG_VNC_TLS */ // #define _VNC_DEBUG 1 -#if _VNC_DEBUG +#ifdef _VNC_DEBUG#define VNC_DEBUG (fmt, ...) do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)#if CONFIG_VNC_TLS && _VNC_DEBUG >=2
@@ -93,7 +93,7 @@VNC_AUTH_VENCRYPT =19 }; -#if CONFIG_VNC_TLS +#ifdef CONFIG_VNC_TLS enum {VNC_WIREMODE_CLEAR , VNC_WIREMODE_TLS,
@@ -143,7 +143,7 @@char *display;char *password;int auth; -#if CONFIG_VNC_TLS +#ifdef CONFIG_VNC_TLS int subauth;int x509verify;
@@ -154,7 +154,7 @@#endif char challenge[VNC_AUTH_CHALLENGE_SIZE ]; -#if CONFIG_VNC_TLS +#ifdef CONFIG_VNC_TLS int wiremode;gnutls_session_t tls_session;#endif
@@ -664,7 +664,7 @@buffer_reset (&vs->input);buffer_reset (&vs->output); vs->need_update =0 ; -#if CONFIG_VNC_TLS +#ifdef CONFIG_VNC_TLS if (vs->tls_session) {gnutls_deinit (vs->tls_session); vs->tls_session =NULL ;
@@ -686,7 +686,7 @@long ret;VncState *vs = opaque; -#if CONFIG_VNC_TLS +#ifdef CONFIG_VNC_TLS if (vs->tls_session) { ret =gnutls_write (vs->tls_session, vs->output.buffer, vs->output.offset);if (ret <0 ) {
@@ -724,7 +724,7 @@buffer_reserve (&vs->input,4096 ); -#if CONFIG_VNC_TLS +#ifdef CONFIG_VNC_TLS if (vs->tls_session) { ret =gnutls_read (vs->tls_session,buffer_end (&vs->input),4096 );if (ret <0 ) {
@@ -831,7 +831,7 @@ (data[offset + 2] << 8) | data[offset + 3]); } -#if CONFIG_VNC_TLS +#ifdef CONFIG_VNC_TLS static ssize_t vnc_tls_push (gnutls_transport_ptr_t transport,const void *data,size_t len) {
@@ -1441,7 +1441,7 @@ } -#if CONFIG_VNC_TLS +#ifdef CONFIG_VNC_TLS #define DH_BITS 1024static gnutls_dh_params_t dh_params;
@@ -1879,7 +1879,7 @@VNC_DEBUG ("Start VNC auth\n" );return start_auth_vnc (vs); -#if CONFIG_VNC_TLS +#ifdef CONFIG_VNC_TLS case VNC_AUTH_VENCRYPT :VNC_DEBUG ("Accept VeNCrypt auth\n" );;return start_auth_vencrypt (vs);
@@ -2032,7 +2032,7 @@vnc_dpy_resize (vs->ds,640 ,400 ); } -#if CONFIG_VNC_TLS +#ifdef CONFIG_VNC_TLS static int vnc_set_x509_credential(VncState *vs, const char *certdir, const char *filename,
@@ -2109,7 +2109,7 @@buffer_reset (&vs->input);buffer_reset (&vs->output); vs->need_update =0 ; -#if CONFIG_VNC_TLS +#ifdef CONFIG_VNC_TLS if (vs->tls_session) {gnutls_deinit (vs->tls_session); vs->tls_session =NULL ;
@@ -2118,7 +2118,7 @@#endif /* CONFIG_VNC_TLS */ } vs->auth =VNC_AUTH_INVALID ; -#if CONFIG_VNC_TLS +#ifdef CONFIG_VNC_TLS vs->subauth =VNC_AUTH_INVALID ; vs->x509verify =0 ;#endif
@@ -2154,7 +2154,7 @@const char *options;int password =0 ;int reverse =0 ; -#if CONFIG_VNC_TLS +#ifdef CONFIG_VNC_TLS int tls =0 , x509 =0 ;#endif
@@ -2172,7 +2172,7 @@ password =1 ;/* Require password auth */ }else if (strncmp (options,"reverse" ,7 ) ==0 ) { reverse =1 ; -#if CONFIG_VNC_TLS +#ifdef CONFIG_VNC_TLS }else if (strncmp (options,"tls" ,3 ) ==0 ) { tls =1 ;/* Require TLS */ }else if (strncmp (options,"x509" ,4 ) ==0 ) {
@@ -2210,7 +2210,7 @@ }if (password) { -#if CONFIG_VNC_TLS +#ifdef CONFIG_VNC_TLS if (tls) { vs->auth =VNC_AUTH_VENCRYPT ;if (x509) {
@@ -2224,12 +2224,12 @@#endif VNC_DEBUG ("Initializing VNC server with password auth\n" ); vs->auth =VNC_AUTH_VNC ; -#if CONFIG_VNC_TLS +#ifdef CONFIG_VNC_TLS vs->subauth =VNC_AUTH_INVALID ; }#endif }else { -#if CONFIG_VNC_TLS +#ifdef CONFIG_VNC_TLS if (tls) { vs->auth =VNC_AUTH_VENCRYPT ;if (x509) {
@@ -2243,7 +2243,7 @@#endif VNC_DEBUG ("Initializing VNC server with no auth\n" ); vs->auth =VNC_AUTH_NONE ; -#if CONFIG_VNC_TLS +#ifdef CONFIG_VNC_TLS vs->subauth = VNC_AUTH_INVALID; }#endif
elf.h +3 -0
@@ -1123,6 +1123,7 @@Elf64_Word n_type;/* Content type */ } Elf64_Nhdr; +#ifdef ELF_CLASS #if ELF_CLASS ==ELFCLASS32 #define elfhdr elf32_hdr
@@ -1165,5 +1166,7 @@# endif #endif +#endif /* ELF_CLASS */ +#endif /* _QEMU_ELF_H */
hw/omap1.c +17 -17
@@ -3478,7 +3478,7 @@switch (offset) {case 0x00 :/* SECONDS_REG */ -#if ALMDEBUG +#ifdef ALMDEBUG printf ("RTC SEC_REG <-- %02x\n" , value);#endif s->ti -= s->current_tm.tm_sec;
@@ -3486,7 +3486,7 @@return ;case 0x04 :/* MINUTES_REG */ -#if ALMDEBUG +#ifdef ALMDEBUG printf ("RTC MIN_REG <-- %02x\n" , value);#endif s->ti -= s->current_tm.tm_min *60 ;
@@ -3494,7 +3494,7 @@return ;case 0x08 :/* HOURS_REG */ -#if ALMDEBUG +#ifdef ALMDEBUG printf ("RTC HRS_REG <-- %02x\n" , value);#endif s->ti -= s->current_tm.tm_hour *3600 ;
@@ -3506,7 +3506,7 @@return ;case 0x0c :/* DAYS_REG */ -#if ALMDEBUG +#ifdef ALMDEBUG printf ("RTC DAY_REG <-- %02x\n" , value);#endif s->ti -= s->current_tm.tm_mday *86400 ;
@@ -3514,7 +3514,7 @@return ;case 0x10 :/* MONTHS_REG */ -#if ALMDEBUG +#ifdef ALMDEBUG printf ("RTC MTH_REG <-- %02x\n" , value);#endif memcpy (&new_tm, &s->current_tm,sizeof (new_tm));
@@ -3533,7 +3533,7 @@return ;case 0x14 :/* YEARS_REG */ -#if ALMDEBUG +#ifdef ALMDEBUG printf ("RTC YRS_REG <-- %02x\n" , value);#endif memcpy (&new_tm, &s->current_tm,sizeof (new_tm));
@@ -3555,7 +3555,7 @@return ;/* Ignored */ case 0x20 :/* ALARM_SECONDS_REG */ -#if ALMDEBUG +#ifdef ALMDEBUG printf ("ALM SEC_REG <-- %02x\n" , value);#endif s->alarm_tm.tm_sec =omap_rtc_bin (value);
@@ -3563,7 +3563,7 @@return ;case 0x24 :/* ALARM_MINUTES_REG */ -#if ALMDEBUG +#ifdef ALMDEBUG printf ("ALM MIN_REG <-- %02x\n" , value);#endif s->alarm_tm.tm_min =omap_rtc_bin (value);
@@ -3571,7 +3571,7 @@return ;case 0x28 :/* ALARM_HOURS_REG */ -#if ALMDEBUG +#ifdef ALMDEBUG printf ("ALM HRS_REG <-- %02x\n" , value);#endif if (s->pm_am)
@@ -3584,7 +3584,7 @@return ;case 0x2c :/* ALARM_DAYS_REG */ -#if ALMDEBUG +#ifdef ALMDEBUG printf ("ALM DAY_REG <-- %02x\n" , value);#endif s->alarm_tm.tm_mday =omap_rtc_bin (value);
@@ -3592,7 +3592,7 @@return ;case 0x30 :/* ALARM_MONTHS_REG */ -#if ALMDEBUG +#ifdef ALMDEBUG printf ("ALM MON_REG <-- %02x\n" , value);#endif s->alarm_tm.tm_mon =omap_rtc_bin (value);
@@ -3600,7 +3600,7 @@return ;case 0x34 :/* ALARM_YEARS_REG */ -#if ALMDEBUG +#ifdef ALMDEBUG printf ("ALM YRS_REG <-- %02x\n" , value);#endif s->alarm_tm.tm_year =omap_rtc_bin (value);
@@ -3608,7 +3608,7 @@return ;case 0x40 :/* RTC_CTRL_REG */ -#if ALMDEBUG +#ifdef ALMDEBUG printf ("RTC CONTROL <-- %02x\n" , value);#endif s->pm_am = (value >>3 ) &1 ;
@@ -3620,7 +3620,7 @@return ;case 0x44 :/* RTC_STATUS_REG */ -#if ALMDEBUG +#ifdef ALMDEBUG printf ("RTC STATUSL <-- %02x\n" , value);#endif s->status &= ~((value &0xc0 ) ^0x80 );
@@ -3628,14 +3628,14 @@return ;case 0x48 :/* RTC_INTERRUPTS_REG */ -#if ALMDEBUG +#ifdef ALMDEBUG printf ("RTC INTRS <-- %02x\n" , value);#endif s->interrupts = value;return ;case 0x4c :/* RTC_COMP_LSB_REG */ -#if ALMDEBUG +#ifdef ALMDEBUG printf ("RTC COMPLSB <-- %02x\n" , value);#endif s->comp_reg &=0xff00 ;
@@ -3643,7 +3643,7 @@return ;case 0x50 :/* RTC_COMP_MSB_REG */ -#if ALMDEBUG +#ifdef ALMDEBUG printf ("RTC COMPMSB <-- %02x\n" , value);#endif s->comp_reg &=0x00ff ;
mips-dis.c +1 -1
@@ -3302,7 +3302,7 @@#endif /* Set ISA, architecture, and cp0 register names as best we can. */ -#if !SYMTAB_AVAILABLE &&0 +#if !defined(SYMTAB_AVAILABLE ) &&0 /* This is running out on a target machine, not in a host tool. FIXME: Where does mips_target_info come from? */ target_processor = mips_target_info.processor;
linux-user/main.c +1 -1
@@ -282,7 +282,7 @@ p[1 ] =tswap32 (e2); } -#if TARGET_X86_64 +#ifdef TARGET_X86_64 uint64_t idt_table[512 ]; static void set_gate64(void *ptr, unsigned int type, unsigned int dpl,
linux-user/arm/nwfpe/fpa11.c +10 -10
@@ -54,7 +54,7 @@ fpa11->fpsr =FP_EMULATOR |BIT_AC ;/* FPCR: set SB, AB and DA bits, clear all others */ -#if MAINTAIN_FPCR +#ifdef MAINTAIN_FPCR fpa11->fpcr =MASK_RESET ;#endif }
@@ -64,7 +64,7 @@int rounding_mode;FPA11 *fpa11 =GET_FPA11 (); -#if MAINTAIN_FPCR +#ifdef MAINTAIN_FPCR fpa11->fpcr &= ~MASK_ROUNDING_MODE ;#endif switch (opcode & MASK_ROUNDING_MODE)
@@ -72,28 +72,28 @@default :case ROUND_TO_NEAREST : rounding_mode = float_round_nearest_even; -#if MAINTAIN_FPCR +#ifdef MAINTAIN_FPCR fpa11->fpcr |=ROUND_TO_NEAREST ;#endif break ;case ROUND_TO_PLUS_INFINITY : rounding_mode = float_round_up; -#if MAINTAIN_FPCR +#ifdef MAINTAIN_FPCR fpa11->fpcr |=ROUND_TO_PLUS_INFINITY ;#endif break ;case ROUND_TO_MINUS_INFINITY : rounding_mode = float_round_down; -#if MAINTAIN_FPCR +#ifdef MAINTAIN_FPCR fpa11->fpcr |=ROUND_TO_MINUS_INFINITY ;#endif break ;case ROUND_TO_ZERO : rounding_mode = float_round_to_zero; -#if MAINTAIN_FPCR +#ifdef MAINTAIN_FPCR fpa11->fpcr |=ROUND_TO_ZERO ;#endif break ;
@@ -105,28 +105,28 @@ {int rounding_precision;FPA11 *fpa11 =GET_FPA11 (); -#if MAINTAIN_FPCR +#ifdef MAINTAIN_FPCR fpa11->fpcr &= ~MASK_ROUNDING_PRECISION ;#endif switch (opcode &MASK_ROUNDING_PRECISION ) {case ROUND_SINGLE : rounding_precision =32 ; -#if MAINTAIN_FPCR +#ifdef MAINTAIN_FPCR fpa11->fpcr |=ROUND_SINGLE ;#endif break ;case ROUND_DOUBLE : rounding_precision =64 ; -#if MAINTAIN_FPCR +#ifdef MAINTAIN_FPCR fpa11->fpcr |=ROUND_DOUBLE ;#endif break ;case ROUND_EXTENDED : rounding_precision =80 ; -#if MAINTAIN_FPCR +#ifdef MAINTAIN_FPCR fpa11->fpcr |=ROUND_EXTENDED ;#endif break ;
tcg/tcg-dyngen.c +1 -0
@@ -31,6 +31,7 @@#include "config.h" #include "osdep.h" +#include "cpu.h" // For TARGET_LONG_BITS #include "tcg.h" int __op_param1, __op_param2, __op_param3;
tcg/tcg-runtime.c +1 -0
@@ -29,6 +29,7 @@#include "config.h" #include "osdep.h" +#include "cpu.h" // For TARGET_LONG_BITS #include "tcg.h" int64_t tcg_helper_shl_i64 (int64_t arg1,int64_t arg2)