Hi,
Compilation currently produces
fpa.c: In function âresetfpaâ:
fpa.c:30: warning: dereferencing type-punned pointer will break
strict-aliasing rules
The patch below stops that warning. I think the code is attempting to
store a float in memory and then read that memory (plus possibly a bit
more depending on the size of a float and a double) back, treating it as
double. It then prints the float and what was read back as a double.
But I think the code is buggy and has never been doing that. Instead,
it stores 0.12f at temp through the float *tfs, then loads a float from
memory, through the tfs pointer again, before casting that float to a
double and assigning it to tf. All that's being tested here is the
compiler casting a float to a double. To work as intended, perhaps
tf = *(double *)temp;
would have been better. Although that was still generate a warning
because it isn't legal in C99 to use casts to treat memory as holding a
float and a double.
So, given the code does nothing useful AFAICS, I've removed those bits.
Cheers,
Ralph.
diff -r 02cb887ed259 src/fpa.c
--- a/src/fpa.c Sat May 29 14:15:29 2010 +0100
+++ b/src/fpa.c Sat May 29 22:54:22 2010 +0100
@@ -24,13 +24,9 @@ static void dumpfpa(void)
void resetfpa(void)
{
- uint32_t temp[3];
- float *tfs;
- double tf;
- tfs=(float *)temp;
- *tfs=0.12f;
- tf=(double)(*tfs);
- rpclog("Double size %i Float size %i %f
%f\n",sizeof(double),sizeof(float),*tfs,tf);
+ rpclog("Double size %i Float size %i\n", sizeof (double),
+ sizeof (float));
+
// fpsr=0;
fpsr=0x81000000; /*FPA system*/
fpcr=0;
_______________________________________________
Rpcemu mailing list
[email protected]
http://www.riscos.info/cgi-bin/mailman/listinfo/rpcemu