This is the mail archive of the
gdb@sourceware.cygnus.com
mailing list for the GDB project.
Re: bug in arm_push_arguments()
- To: Scott Bambrough <scottb at netwinder dot org>
- Subject: Re: bug in arm_push_arguments()
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Mon, 28 Feb 2000 23:03:54 +1100
- CC: "fnasser at cygnus dot com" <fnasser at cygnus dot com>, James Ingham <jingham at cygnus dot com>, GDB Mailing List <gdb at sourceware dot cygnus dot com>
- Organization: Cygnus Solutions
- References: <38B6C4A1.7A1461C4@netwinder.org>
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