/* Intel 387 floating point stuff.
Copyright (C) 1988, 1989, 1991, 1992, 1993, 1994, 1998, 1999, 2000, 2001,
- 2002, 2003, 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+ 2002, 2003, 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
This file is part of GDB.
/* Print the floating point number specified by RAW. */
static void
-print_i387_value (const gdb_byte *raw, struct ui_file *file)
+print_i387_value (struct gdbarch *gdbarch,
+ const gdb_byte *raw, struct ui_file *file)
{
DOUBLEST value;
of certain numbers such as NaNs, even if GDB is running natively.
This is fine since our caller already detects such special
numbers and we print the hexadecimal representation anyway. */
- value = extract_typed_floating (raw, builtin_type_i387_ext);
+ value = extract_typed_floating (raw, i387_ext_type (gdbarch));
/* We try to print 19 digits. The last digit may or may not contain
garbage, but we'd better print one too many. We need enough room
/* Print the classification for the register contents RAW. */
static void
-print_i387_ext (const gdb_byte *raw, struct ui_file *file)
+print_i387_ext (struct gdbarch *gdbarch,
+ const gdb_byte *raw, struct ui_file *file)
{
int sign;
int integer;
}
else if (exponent < 0x7fff && exponent > 0x0000 && integer)
/* Normal. */
- print_i387_value (raw, file);
+ print_i387_value (gdbarch, raw, file);
else if (exponent == 0x0000)
{
/* Denormal or zero. */
- print_i387_value (raw, file);
+ print_i387_value (gdbarch, raw, file);
if (integer)
/* Pseudo-denormal. */
fprintf_filtered (file, "%02x", raw[i]);
if (tag != 3)
- print_i387_ext (raw, file);
+ print_i387_ext (gdbarch, raw, file);
fputs_filtered ("\n", file);
}
{
/* Floating point registers must be converted unless we are
accessing them in their hardware type. */
- if (type == builtin_type_i387_ext)
+ if (type == i387_ext_type (gdbarch))
return 0;
else
return 1;
i387_register_to_value (struct frame_info *frame, int regnum,
struct type *type, gdb_byte *to)
{
+ struct gdbarch *gdbarch = get_frame_arch (frame);
gdb_byte from[I386_MAX_REGISTER_SIZE];
- gdb_assert (i386_fp_regnum_p (get_frame_arch (frame), regnum));
+ gdb_assert (i386_fp_regnum_p (gdbarch, regnum));
/* We only support floating-point values. */
if (TYPE_CODE (type) != TYPE_CODE_FLT)
/* Convert to TYPE. */
get_frame_register (frame, regnum, from);
- convert_typed_floating (from, builtin_type_i387_ext, to, type);
+ convert_typed_floating (from, i387_ext_type (gdbarch), to, type);
}
/* Write the contents FROM of a value of type TYPE into register
i387_value_to_register (struct frame_info *frame, int regnum,
struct type *type, const gdb_byte *from)
{
+ struct gdbarch *gdbarch = get_frame_arch (frame);
gdb_byte to[I386_MAX_REGISTER_SIZE];
- gdb_assert (i386_fp_regnum_p (get_frame_arch (frame), regnum));
+ gdb_assert (i386_fp_regnum_p (gdbarch, regnum));
/* We only support floating-point values. */
if (TYPE_CODE (type) != TYPE_CODE_FLT)
}
/* Convert from TYPE. */
- convert_typed_floating (from, type, to, builtin_type_i387_ext);
+ convert_typed_floating (from, type, to, i387_ext_type (gdbarch));
put_frame_register (frame, regnum, to);
}
\f
void
i387_supply_fsave (struct regcache *regcache, int regnum, const void *fsave)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (get_regcache_arch (regcache));
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
const gdb_byte *regs = fsave;
int i;
{
gdb_byte buf[4];
- store_unsigned_integer (buf, 4, 0x1f80);
+ store_unsigned_integer (buf, 4, byte_order, 0x1f80);
regcache_raw_supply (regcache, I387_MXCSR_REGNUM (tdep), buf);
}
}