This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [libiberty and gdb] floatformat_is_valid
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: Andrew Cagney <ac131313 at redhat dot com>
- Cc: gdb-patches at sources dot redhat dot com, binutils at sources dot redhat dot com,gcc-patches at gcc dot gnu dot org
- Date: Mon, 15 Sep 2003 16:58:15 -0400
- Subject: Re: [libiberty and gdb] floatformat_is_valid
- References: <20030915143933.GA22129@nevyn.them.org> <3F6626F9.90003@redhat.com>
On Mon, Sep 15, 2003 at 04:54:17PM -0400, Andrew Cagney wrote:
> >+/* Return non-zero iff the data at FROM is a valid number in format FMT.
> >*/
> >+
> >+int
> >+floatformat_is_valid (fmt, from)
> >+ const struct floatformat *fmt;
> >+ char *from;
> >+{
>
> Shouldn't this be a new virtual method in floatformat?
Floatformats don't have any virtual methods right now; if you want to
add them, be my guest. Besides, this is more in line with the
libiberty policy of backwards compatibility, since it does not change
the structure layout.
>
> >+ if (fmt == &floatformat_i387_ext)
> >+ {
> >+ /* In the i387 double-extended format, if the exponent is all
> >+ ones, then the integer bit must be set. If the exponent
> >+ is neither 0 nor ~0, the intbit must also be set. Only
> >+ if the exponent is zero can it be zero, and then it must
> >+ be zero. */
> >+ unsigned int exponent, int_bit;
> >+ unsigned char *ufrom = (unsigned char *) from;
> >+
> >+ exponent = get_field (ufrom, fmt->byteorder, fmt->totalsize,
> >+ fmt->exp_start, fmt->exp_len);
> >+ int_bit = get_field (ufrom, fmt->byteorder, fmt->totalsize,
> >+ fmt->man_start, 1);
> >+
> >+ if ((exponent == 0) != (int_bit == 0))
> >+ return 0;
> >+ else
> >+ return 1;
> >+ }
> >+
> >+ /* Other formats with invalid representations should be added
> >+ here. */
> >+ return 1;
> > }
>
> Andrew
>
>
>
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer