From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IrCWJ-0000hd-TA for qemu-devel@nongnu.org; Sun, 11 Nov 2007 08:06:35 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IrCWI-0000hI-5g for qemu-devel@nongnu.org; Sun, 11 Nov 2007 08:06:35 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IrCWI-0000hF-3h for qemu-devel@nongnu.org; Sun, 11 Nov 2007 08:06:34 -0500 Received: from tapir.sajinet.com.pe ([66.139.79.212]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IrCWH-00061H-Ar for qemu-devel@nongnu.org; Sun, 11 Nov 2007 08:06:33 -0500 Date: Sun, 11 Nov 2007 07:11:13 -0600 From: Carlo Marcelo Arenas Belon Message-ID: <20071111131113.GC25322@tapir> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] [PATCH/RFC] overflow and register size mismatch in sh4-softmmu Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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; }