From: Daniel Jacobowitz <drow@false.org>
To: Wu Zhou <woodzltc@cn.ibm.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFC] decimal float point patch based on libdecnumber: gdb patch
Date: Sun, 03 Sep 2006 16:44:00 -0000 [thread overview]
Message-ID: <20060903164410.GA7408@nevyn.them.org> (raw)
In-Reply-To: <44FA97FA.1070100@cn.ibm.com>
On Sun, Sep 03, 2006 at 04:53:14PM +0800, Wu Zhou wrote:
> It is like this. The structures decimal32, decimal64 and decimal128 are
> big-endian in current libdecnumber implementation:
>
> typedef struct
> {
> uint8_t bytes[DECIMAL128_Bytes]; /* decimal128: 1, 5, 12, 110 bits */
> } decimal128;
>
> But variables/constants of _Decimal32, _Decimal64 and _Decimal128 (which
> are the DFP extension to c language types) in the memory are stored in
> little-endian on x86, and big-endian on ppc64. So the byte swapping is
> needed on x86.
OK, that makes sense: note that this is needed precisely when
converting from a target decimal float to a host decimal128. That
is a better time to do the conversion.
> Ben Elliston is planning to change the memory layout of
> decimal32/decimal64/decimal128 to host byte order in later
> libdecnumber/gcc. Then the byte swapping will not be needed in gdb. But
> that is when GCC gets to stage 1 again, which might be around the end of
> this year.
>
> So one option is for us to keep the byte swapping code in gdb, and when the
> byte order in libdecnumber is changed to host byte order, we can easily
> delete them.
This, however, is not correct. Libdecnumber will presumably change to
use host endianness. GDB will fetch numbers in target endianness.
If you're using a native i386 debugger, then you won't need to swap;
but if you're using an i386 <-> powerpc debugger, then you will. The
swap will need to be in the same place, just with a different
condition.
I would recommend that you always store the bytes in struct value in
target endianness. Then, have two functions which convert between a
"struct value" and a "decimal128". Then it should be clear which one
has which representation.
Then, for instance, you can use decimal128 in typed_val_decfloat, and
in the argument of value_from_decfloat. And that function can be
responsible for the exchange. Similarly, in print_decimal_floating,
you have bytes in target endianness; you can convert them to a "struct
value", which will have the same bytes, and convert the value to a
decimal128 which you can print.
The only part of that which is tricky is converting the bytes back to
a struct value. You could write a new function, value_from_bytes,
to do that; just like value_from_longest.
--
Daniel Jacobowitz
CodeSourcery
next prev parent reply other threads:[~2006-09-03 16:44 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-21 16:08 Wu Zhou
2006-08-21 18:30 ` Daniel Jacobowitz
2006-08-21 18:34 ` Wu Zhou
2006-08-22 1:31 ` Daniel Jacobowitz
2006-09-03 8:53 ` Wu Zhou
2006-09-03 16:44 ` Daniel Jacobowitz [this message]
2006-09-05 2:34 ` Wu Zhou
-- strict thread matches above, loose matches on Subject: below --
2006-08-01 9:55 Wu Zhou
2006-08-01 10:51 ` Wu Zhou
2006-08-08 18:16 ` Daniel Jacobowitz
2006-07-23 5:48 Wu Zhou
2006-07-23 14:02 ` Daniel Jacobowitz
2006-06-21 21:03 [RFC] decimal float point patch based on libdecnumber: testcase Wu Zhou
2006-06-21 23:36 ` [RFC] decimal float point patch based on libdecnumber: gdb patch Wu Zhou
2006-06-22 3:27 ` Eli Zaretskii
2006-06-22 14:18 ` Wu Zhou
2006-07-12 20:39 ` Daniel Jacobowitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060903164410.GA7408@nevyn.them.org \
--to=drow@false.org \
--cc=gdb-patches@sourceware.org \
--cc=woodzltc@cn.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox