* archures.c: Update copyright.
[deliverable/binutils-gdb.git] / gdb / value.c
index bb27625e08c97aeb9edcd3c68beb3169a1a742dc..e620550eca3ec768f70f4ffa0ebf4d6cb12967e2 100644 (file)
@@ -72,8 +72,8 @@ struct value
   int bitsize;
 
   /* Only used for bitfields; position of start of field.  For
-     BITS_BIG_ENDIAN=0 targets, it is the position of the LSB.  For
-     BITS_BIG_ENDIAN=1 targets, it is the position of the MSB. */
+     gdbarch_bits_big_endian=0 targets, it is the position of the LSB.  For
+     gdbarch_bits_big_endian=1 targets, it is the position of the MSB. */
   int bitpos;
 
   /* Frame register value is relative to.  This will be described in
@@ -982,6 +982,7 @@ value_as_double (struct value *val)
     error (_("Invalid floating value found in program."));
   return foo;
 }
+
 /* Extract a value as a C pointer. Does not deallocate the value.  
    Note that val's type may not actually be a pointer; value_as_long
    handles all the cases.  */
@@ -1127,6 +1128,11 @@ unpack_long (struct type *type, const gdb_byte *valaddr)
     case TYPE_CODE_FLT:
       return extract_typed_floating (valaddr, type);
 
+    case TYPE_CODE_DECFLOAT:
+      /* libdecnumber has a function to convert from decimal to integer, but
+        it doesn't work when the decimal number has a fractional part.  */
+      return decimal_to_doublest (valaddr, len);
+
     case TYPE_CODE_PTR:
     case TYPE_CODE_REF:
       /* Assume a CORE_ADDR can fit in a LONGEST (for now).  Not sure
@@ -1184,6 +1190,8 @@ unpack_double (struct type *type, const gdb_byte *valaddr, int *invp)
 
       return extract_typed_floating (valaddr, type);
     }
+  else if (code == TYPE_CODE_DECFLOAT)
+    return decimal_to_doublest (valaddr, len);
   else if (nosign)
     {
       /* Unsigned -- be sure we compensate for signed LONGEST.  */
@@ -1473,7 +1481,7 @@ unpack_field_as_long (struct type *type, const gdb_byte *valaddr, int fieldno)
 
   /* Extract bits.  See comment above. */
 
-  if (BITS_BIG_ENDIAN)
+  if (gdbarch_bits_big_endian (current_gdbarch))
     lsbcount = (sizeof val * 8 - bitpos % 8 - bitsize);
   else
     lsbcount = (bitpos % 8);
@@ -1529,7 +1537,7 @@ modify_field (gdb_byte *addr, LONGEST fieldval, int bitpos, int bitsize)
   oword = extract_unsigned_integer (addr, sizeof oword);
 
   /* Shifting for bit field depends on endianness of the target machine.  */
-  if (BITS_BIG_ENDIAN)
+  if (gdbarch_bits_big_endian (current_gdbarch))
     bitpos = sizeof (oword) * 8 - bitpos - bitsize;
 
   oword &= ~(mask << bitpos);
@@ -1643,23 +1651,12 @@ value_from_double (struct type *type, DOUBLEST num)
 }
 
 struct value *
-value_from_decfloat (struct type *expect_type, struct type *type,
-                     gdb_byte decbytes[16])
+value_from_decfloat (struct type *type, const gdb_byte *dec)
 {
   struct value *val = allocate_value (type);
-  int len = TYPE_LENGTH (type);
 
-  if (expect_type)
-    {
-      int expect_len = TYPE_LENGTH (expect_type);
-      char decstr[MAX_DECIMAL_STRING];
-      int real_len;
-
-      decimal_to_string (decbytes, len, decstr);
-      decimal_from_string (decbytes, expect_len, decstr);
-    }
+  memcpy (value_contents_raw (val), dec, TYPE_LENGTH (type));
 
-  memcpy (value_contents_raw (val), decbytes, len);
   return val;
 }
 
This page took 0.057979 seconds and 4 git commands to generate.