This is the mail archive of the gdb@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: bug in arm_push_arguments()


Scott Bambrough wrote:
> 
> Hi guys,
> 

>           /* Convert the double to TARGET byte order and swap things to
>              conform to the ARM floating point layout.  */
>           memcpy (bufd, bufo + len / 2, len / 2);
>           SWAP_TARGET_AND_HOST (bufd, len / 2);  /* adjust endianess */
>           memcpy (bufd + len / 2, bufo, len / 2);
>           SWAP_TARGET_AND_HOST (bufd + len / 2, len / 2); /* adjust endianess */
>           val = (char *) &dbl_arg;
> 
> This is ok, but the code for the last step is unnecessarily complex.  I think
> something similar to the following should suffice.
> 
>           int tmp;
>	    int *buf = &d;
>           SWAP_TARGET_AND_HOST (&d, sizeof (double));
>           tmp = buf[0];
>           buf[0] = buf[1];
>           buf[1] = tmp;
> 
> I think this will result in better code from the compiler.  There are a couple
> of problems though with this code.  First what happens if sizeof (TARGET_DOUBLE)
> != sizeof (HOST_DOUBLE).  Second, this breaks in the native case, because the
> double is already in the right format. This is why I have regressions I believe
> (I have yet to test my theory).  Is there a clean way to solve these problems?

FYI, my guess would be that the author didn't want to make any
assumptions about sizeof(int), sizeof(double) and their ratios.  Those
things are just too changeable.

(The cast/memory poke ``(f = *(float*)d)'' is also non-portable but I
won't mention that :-)

Kevin Buttner wrote:
> It seems to me that you should be able to use store_floating() to do
> what you want.  It'll handle both the conversion and the byte swapping.

Yes, that looks correct. I'm just not 100% sure on it working - would
one of those if()'s before the TARGET_EXTRACT_FLOATING() get in the way?

	Andrew

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]