Re: [hatari-devel] Bug in FPU code

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


Am Mon, 05 Mar 2012 22:05:34 +0100
schrieb Laurent Sallafranque <laurent.sallafranque@xxxxxxx>:

> Hi,
> 
> Eero, Thomas, Nicolas, I've tested the patch with the esquimau demo,
> but I haven't seen any change. (Eskimau does a lot of FPU).
> 
> As I'm not a specialist of #if USE_LONG_DOUBLE defines and the code 
> after, I prefer asking you your advice on this patch before uploading 
> anything.
> 
> Is the fix OK for any case of #if USE_LONG_DOUBLE ? (on every
> computer, ... little / big endian, ...) ?
> 
> At least, the patch doesn't seem to break anything, but I've done
> only one test.

Well, by closely looking at the source code, you can see that the
original code is obviously wrong:

   ... long double src ...
   register uae_u16 *finalword = (uae_u16 *)(&src + 8);

Here they "try" to access the memory at location &src + 8 ... which
should obviously be 8 _bytes_ after &src, but since &src is a "long
double" pointer, they rather access the memory at 8 * 8 = 64 bytes
after &src.

So yes, please apply the patch, IMHO Andreas did a very good job here
by spotting this bug. As an alternative, you could also cast &src to
a "uint8_t *" before adding the "8", that should fix this issue, too.

And don't worry about breaking the endianess, the original code here was
not endianess safe, either, so the endianess issues should maybe be
fixed with another patch later.

 Thomas





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