qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH/RFC] overflow and register size mismatch in sh4-softmmu
@ 2007-11-11 13:11 Carlo Marcelo Arenas Belon
  2007-11-11 13:33 ` Paul Brook
  0 siblings, 1 reply; 2+ messages in thread
From: Carlo Marcelo Arenas Belon @ 2007-11-11 13:11 UTC (permalink / raw)
  To: qemu-devel

as shown by the following warning when compiling HEAD :

  qemu/target-sh4/translate.c: In function `cpu_sh4_reset':
  qemu/target-sh4/translate.c:139: warning: overflow in implicit constant conversion

the problem was introduced in version 1.11 of that file and is being triggered
by the fact that the following assignment :

  env->fp_status.float_rounding_mode = float_round_to_zero;

is trying to assign the value of float_round_to_zero which is defined in
softfloat-native.h as :

  enum {
    float_round_nearest_even = FE_TONEAREST,
    float_round_down = FE_DOWNWARD,
    float_round_up = FE_UPWARD,
    float_round_to_zero = FE_TOWARDZERO
  };

where FE_TOWARDZERO = 0xc00 and sizeof(env->fp_status.float_rounding_mode) ==
1 as shown by :

  typedef struct float_status {
    signed char float_rounding_mode;
    signed char floatx80_rounding_precision;
  } float_status;

  float_status fp_status;

the following patch changes the logic to use a helper function just like other
targets and has been tested in x86 and amd64 to compile correctly, but I have
no way to test it and should be ideally validated by anyone that knows the sh4
emulation better and has a way to confirm that it is functionally equivalent.

Carlo

---
Index: target-sh4/translate.c
===================================================================
RCS file: /sources/qemu/qemu/target-sh4/translate.c,v
retrieving revision 1.19
diff -u -r1.19 translate.c
--- target-sh4/translate.c	10 Nov 2007 15:15:54 -0000	1.19
+++ target-sh4/translate.c	11 Nov 2007 13:01:31 -0000
@@ -136,7 +136,7 @@
     env->fp_status.float_rounding_mode = float_round_nearest_even; /* ?! */
 #else
     env->fpscr = 0x00040001; /* CPU reset value according to SH4 manual */
-    env->fp_status.float_rounding_mode = float_round_to_zero;
+    set_float_rounding_mode(float_round_to_zero, &env->fp_status);
 #endif
     env->mmucr = 0;
 }

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-11-11 13:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-11 13:11 [Qemu-devel] [PATCH/RFC] overflow and register size mismatch in sh4-softmmu Carlo Marcelo Arenas Belon
2007-11-11 13:33 ` Paul Brook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).