Re: [hatari-devel] Bug in FPU code

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


> Datum: Wed, 07 Mar 2012 08:50:20 +0100
> Von: Laurent Sallafranque <laurent.sallafranque@xxxxxxx>
> 
> I've compiled with the patch you suggest.
> Compile runs with 2 warnings:
> 
> [ 21%] Building C object src/cpu/CMakeFiles/UaeCpu.dir/fpp.c.o
> /home/laurent/Atari/hatari/src/cpu/fpp.c: In function ‘to_pack’:
> /home/laurent/Atari/hatari/src/cpu/fpp.c:339:2: attention : format
> ‘%Le’ 
> expects argument of type ‘long double *’, but argument 3 has type 
> ‘fptype *’ [-Wformat]
> /home/laurent/Atari/hatari/src/cpu/fpp.c: In function ‘from_pack’:
> /home/laurent/Atari/hatari/src/cpu/fpp.c:350:2: attention : format
> ‘%Le’ 
> expects argument of type ‘long double’, but argument 3 has type
> ‘fptype’ 
> [-Wformat]

Ah, sorry, my bad, I was working with the "previous" sources when I wrote my mail. Actually that problem only happens when using USE_LONG_DOUBLE=1. This is the case for previous. Since we're using USE_LONG_DOUBLE=0 in Hatari, we are not affected of this format string problem. But to be sure, we should maybe add a patch like this:

diff -r 22d3c9f30097 src/cpu/fpp.c
--- a/src/cpu/fpp.c	Wed Mar 07 10:08:50 2012 +0100
+++ b/src/cpu/fpp.c	Wed Mar 07 18:50:43 2012 +0100
@@ -336,7 +336,11 @@
 	*cp++ = ((wrd1 >> 20) & 0xf) + '0';
 	*cp++ = ((wrd1 >> 16) & 0xf) + '0';
 	*cp = 0;
+#if USE_LONG_DOUBLE
+	sscanf (str, "%Le", &d);
+#else
 	sscanf (str, "%le", &d);
+#endif
 	return d;
 }
 
@@ -347,7 +351,11 @@
 	char *cp;
 	char str[100];
 
+#if USE_LONG_DOUBLE
+	sprintf (str, "%.16Le", src);
+#else
 	sprintf (str, "%.16e", src);
+#endif
 	cp = str;
 	*wrd1 = *wrd2 = *wrd3 = 0;
 	if (*cp == '-') {

What do you think?

 Thomas

-- 
NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!                                  
Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/