mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-07-31 05:44:41 +08:00
* doublest.c (convert_doublest_to_floatformat): Rename
floatformat_from_doublest. Make static. (convert_floatformat_to_doublest): Rename floatformat_to_doublest. Make static. (floatformat_to_doublest): New function. (floatformat_from_doublest): New function. (host_float_format, host_double_format, host_long_double_format): New static variables. (store_floating, extract_floating): Always use floatformat_to_doublest and floatformat_from_doublest. * doublest.h (HOST_LONG_DOUBLE_FORMAT): Delete macro.
This commit is contained in:
@ -1,3 +1,17 @@
|
|||||||
|
2001-08-11 Andrew Cagney <ac131313@redhat.com>
|
||||||
|
|
||||||
|
* doublest.c (convert_doublest_to_floatformat): Rename
|
||||||
|
floatformat_from_doublest. Make static.
|
||||||
|
(convert_floatformat_to_doublest): Rename floatformat_to_doublest.
|
||||||
|
Make static.
|
||||||
|
(floatformat_to_doublest): New function.
|
||||||
|
(floatformat_from_doublest): New function.
|
||||||
|
(host_float_format, host_double_format, host_long_double_format):
|
||||||
|
New static variables.
|
||||||
|
(store_floating, extract_floating): Always use
|
||||||
|
floatformat_to_doublest and floatformat_from_doublest.
|
||||||
|
* doublest.h (HOST_LONG_DOUBLE_FORMAT): Delete macro.
|
||||||
|
|
||||||
2001-08-11 Andrew Cagney <ac131313@redhat.com>
|
2001-08-11 Andrew Cagney <ac131313@redhat.com>
|
||||||
|
|
||||||
* config/mn10300/tm-mn10300.h (INIT_FRAME_PC): Delete.
|
* config/mn10300/tm-mn10300.h (INIT_FRAME_PC): Delete.
|
||||||
|
151
gdb/doublest.c
151
gdb/doublest.c
@ -104,10 +104,10 @@ get_field (unsigned char *data, enum floatformat_byteorders order,
|
|||||||
FROM is the address of the extended float.
|
FROM is the address of the extended float.
|
||||||
Store the DOUBLEST in *TO. */
|
Store the DOUBLEST in *TO. */
|
||||||
|
|
||||||
void
|
static void
|
||||||
floatformat_to_doublest (const struct floatformat *fmt,
|
convert_floatformat_to_doublest (const struct floatformat *fmt,
|
||||||
const void *from,
|
const void *from,
|
||||||
DOUBLEST *to)
|
DOUBLEST *to)
|
||||||
{
|
{
|
||||||
unsigned char *ufrom = (unsigned char *) from;
|
unsigned char *ufrom = (unsigned char *) from;
|
||||||
DOUBLEST dto;
|
DOUBLEST dto;
|
||||||
@ -325,10 +325,10 @@ ldfrexp (long double value, int *eptr)
|
|||||||
and store where TO points. Neither FROM nor TO have any alignment
|
and store where TO points. Neither FROM nor TO have any alignment
|
||||||
restrictions. */
|
restrictions. */
|
||||||
|
|
||||||
void
|
static void
|
||||||
floatformat_from_doublest (CONST struct floatformat *fmt,
|
convert_doublest_to_floatformat (CONST struct floatformat *fmt,
|
||||||
const DOUBLEST *from,
|
const DOUBLEST *from,
|
||||||
void *to)
|
void *to)
|
||||||
{
|
{
|
||||||
DOUBLEST dfrom;
|
DOUBLEST dfrom;
|
||||||
int exponent;
|
int exponent;
|
||||||
@ -533,60 +533,102 @@ floatformat_mantissa (const struct floatformat *fmt, char *val)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Extract a floating-point number from a target-order byte-stream at ADDR.
|
/* Convert TO/FROM target to the hosts DOUBLEST floating-point format.
|
||||||
Returns the value as type DOUBLEST.
|
|
||||||
|
|
||||||
If the host and target formats agree, we just copy the raw data into the
|
If the host and target formats agree, we just copy the raw data
|
||||||
appropriate type of variable and return, letting the host increase precision
|
into the appropriate type of variable and return, letting the host
|
||||||
as necessary. Otherwise, we call the conversion routine and let it do the
|
increase precision as necessary. Otherwise, we call the conversion
|
||||||
dirty work. */
|
routine and let it do the dirty work. */
|
||||||
|
|
||||||
|
#ifndef HOST_FLOAT_FORMAT
|
||||||
|
#define HOST_FLOAT_FORMAT 0
|
||||||
|
#endif
|
||||||
|
#ifndef HOST_DOUBLE_FORMAT
|
||||||
|
#define HOST_DOUBLE_FORMAT 0
|
||||||
|
#endif
|
||||||
|
#ifndef HOST_LONG_DOUBLE_FORMAT
|
||||||
|
#define HOST_LONG_DOUBLE_FORMAT 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static const struct floatformat *host_float_format = HOST_FLOAT_FORMAT;
|
||||||
|
static const struct floatformat *host_double_format = HOST_DOUBLE_FORMAT;
|
||||||
|
static const struct floatformat *host_long_double_format = HOST_LONG_DOUBLE_FORMAT;
|
||||||
|
|
||||||
|
void
|
||||||
|
floatformat_to_doublest (const struct floatformat *fmt,
|
||||||
|
const void *in, DOUBLEST *out)
|
||||||
|
{
|
||||||
|
gdb_assert (fmt != NULL);
|
||||||
|
if (fmt == host_float_format)
|
||||||
|
{
|
||||||
|
float val;
|
||||||
|
memcpy (&val, in, sizeof (val));
|
||||||
|
*out = val;
|
||||||
|
}
|
||||||
|
else if (fmt == host_double_format)
|
||||||
|
{
|
||||||
|
double val;
|
||||||
|
memcpy (&val, in, sizeof (val));
|
||||||
|
*out = val;
|
||||||
|
}
|
||||||
|
else if (fmt == host_long_double_format)
|
||||||
|
{
|
||||||
|
long double val;
|
||||||
|
memcpy (&val, in, sizeof (val));
|
||||||
|
*out = val;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
convert_floatformat_to_doublest (fmt, in, out);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
floatformat_from_doublest (const struct floatformat *fmt,
|
||||||
|
const DOUBLEST *in, void *out)
|
||||||
|
{
|
||||||
|
gdb_assert (fmt != NULL);
|
||||||
|
if (fmt == host_float_format)
|
||||||
|
{
|
||||||
|
float val = *in;
|
||||||
|
memcpy (out, &val, sizeof (val));
|
||||||
|
}
|
||||||
|
else if (fmt == host_double_format)
|
||||||
|
{
|
||||||
|
double val = *in;
|
||||||
|
memcpy (out, &val, sizeof (val));
|
||||||
|
}
|
||||||
|
else if (fmt == host_long_double_format)
|
||||||
|
{
|
||||||
|
long double val = *in;
|
||||||
|
memcpy (out, &val, sizeof (val));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
convert_doublest_to_floatformat (fmt, in, out);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Extract/store a floating-point number from a target-order
|
||||||
|
byte-stream at ADDR. Returns the value as type DOUBLEST. */
|
||||||
|
|
||||||
DOUBLEST
|
DOUBLEST
|
||||||
extract_floating (const void *addr, int len)
|
extract_floating (const void *addr, int len)
|
||||||
{
|
{
|
||||||
DOUBLEST dretval;
|
DOUBLEST dretval;
|
||||||
|
|
||||||
if (len * TARGET_CHAR_BIT == TARGET_FLOAT_BIT)
|
if (len * TARGET_CHAR_BIT == TARGET_FLOAT_BIT)
|
||||||
{
|
{
|
||||||
if (HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT)
|
floatformat_to_doublest (TARGET_FLOAT_FORMAT, addr, &dretval);
|
||||||
{
|
|
||||||
float retval;
|
|
||||||
|
|
||||||
memcpy (&retval, addr, sizeof (retval));
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
floatformat_to_doublest (TARGET_FLOAT_FORMAT, addr, &dretval);
|
|
||||||
}
|
}
|
||||||
else if (len * TARGET_CHAR_BIT == TARGET_DOUBLE_BIT)
|
else if (len * TARGET_CHAR_BIT == TARGET_DOUBLE_BIT)
|
||||||
{
|
{
|
||||||
if (HOST_DOUBLE_FORMAT == TARGET_DOUBLE_FORMAT)
|
floatformat_to_doublest (TARGET_DOUBLE_FORMAT, addr, &dretval);
|
||||||
{
|
|
||||||
double retval;
|
|
||||||
|
|
||||||
memcpy (&retval, addr, sizeof (retval));
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
floatformat_to_doublest (TARGET_DOUBLE_FORMAT, addr, &dretval);
|
|
||||||
}
|
}
|
||||||
else if (len * TARGET_CHAR_BIT == TARGET_LONG_DOUBLE_BIT)
|
else if (len * TARGET_CHAR_BIT == TARGET_LONG_DOUBLE_BIT)
|
||||||
{
|
{
|
||||||
if (HOST_LONG_DOUBLE_FORMAT == TARGET_LONG_DOUBLE_FORMAT)
|
floatformat_to_doublest (TARGET_LONG_DOUBLE_FORMAT, addr, &dretval);
|
||||||
{
|
|
||||||
DOUBLEST retval;
|
|
||||||
|
|
||||||
memcpy (&retval, addr, sizeof (retval));
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
floatformat_to_doublest (TARGET_LONG_DOUBLE_FORMAT, addr, &dretval);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
error ("Can't deal with a floating point number of %d bytes.", len);
|
error ("Can't deal with a floating point number of %d bytes.", len);
|
||||||
}
|
}
|
||||||
|
|
||||||
return dretval;
|
return dretval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -595,32 +637,15 @@ store_floating (void *addr, int len, DOUBLEST val)
|
|||||||
{
|
{
|
||||||
if (len * TARGET_CHAR_BIT == TARGET_FLOAT_BIT)
|
if (len * TARGET_CHAR_BIT == TARGET_FLOAT_BIT)
|
||||||
{
|
{
|
||||||
if (HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT)
|
floatformat_from_doublest (TARGET_FLOAT_FORMAT, &val, addr);
|
||||||
{
|
|
||||||
float floatval = val;
|
|
||||||
|
|
||||||
memcpy (addr, &floatval, sizeof (floatval));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
floatformat_from_doublest (TARGET_FLOAT_FORMAT, &val, addr);
|
|
||||||
}
|
}
|
||||||
else if (len * TARGET_CHAR_BIT == TARGET_DOUBLE_BIT)
|
else if (len * TARGET_CHAR_BIT == TARGET_DOUBLE_BIT)
|
||||||
{
|
{
|
||||||
if (HOST_DOUBLE_FORMAT == TARGET_DOUBLE_FORMAT)
|
floatformat_from_doublest (TARGET_DOUBLE_FORMAT, &val, addr);
|
||||||
{
|
|
||||||
double doubleval = val;
|
|
||||||
|
|
||||||
memcpy (addr, &doubleval, sizeof (doubleval));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
floatformat_from_doublest (TARGET_DOUBLE_FORMAT, &val, addr);
|
|
||||||
}
|
}
|
||||||
else if (len * TARGET_CHAR_BIT == TARGET_LONG_DOUBLE_BIT)
|
else if (len * TARGET_CHAR_BIT == TARGET_LONG_DOUBLE_BIT)
|
||||||
{
|
{
|
||||||
if (HOST_LONG_DOUBLE_FORMAT == TARGET_LONG_DOUBLE_FORMAT)
|
floatformat_from_doublest (TARGET_LONG_DOUBLE_FORMAT, &val, addr);
|
||||||
memcpy (addr, &val, sizeof (val));
|
|
||||||
else
|
|
||||||
floatformat_from_doublest (TARGET_LONG_DOUBLE_FORMAT, &val, addr);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -53,10 +53,6 @@ extern const struct floatformat floatformat_unknown;
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HOST_LONG_DOUBLE_FORMAT
|
|
||||||
#define HOST_LONG_DOUBLE_FORMAT &floatformat_unknown
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Use `long double' if the host compiler supports it. (Note that this is not
|
/* Use `long double' if the host compiler supports it. (Note that this is not
|
||||||
necessarily any longer than `double'. On SunOS/gcc, it's the same as
|
necessarily any longer than `double'. On SunOS/gcc, it's the same as
|
||||||
double.) This is necessary because GDB internally converts all floating
|
double.) This is necessary because GDB internally converts all floating
|
||||||
|
Reference in New Issue
Block a user