* Rename remote-es1800.c to remote-es.c
[deliverable/binutils-gdb.git] / gdb / values.c
index c399f8b69c8a444fc5252116fdacf4b4dc4bb303..c4a04ff989d49d4e90576f5c9c761a5becc2dcc7 100644 (file)
@@ -637,7 +637,7 @@ unpack_long (type, valaddr)
          SWAP_TARGET_AND_HOST (&retval, sizeof (retval));
          return retval;
        }
-#ifdef LONG_LONG
+#ifdef CC_HAS_LONG_LONG
       if (len == sizeof (long long))
        {
          unsigned long long retval;
@@ -685,7 +685,7 @@ unpack_long (type, valaddr)
          return retval;
        }
 
-#ifdef LONG_LONG
+#ifdef CC_HAS_LONG_LONG
       if (len == sizeof (long long))
        {
          long long retval;
@@ -717,6 +717,15 @@ unpack_long (type, valaddr)
        SWAP_TARGET_AND_HOST (&retval, len);
        return retval;
       }
+#ifdef CC_HAS_LONG_LONG
+      else if (len == sizeof(long long))
+      {
+       unsigned long long retval;
+       memcpy (&retval, valaddr, len);
+       SWAP_TARGET_AND_HOST (&retval, len);
+       return retval;
+      }
+#endif
     }
   else if (code == TYPE_CODE_MEMBER)
     error ("not implemented: member types in unpack_long");
@@ -775,11 +784,7 @@ unpack_double (type, valaddr, invp)
     }
   else if (nosign) {
    /* Unsigned -- be sure we compensate for signed LONGEST.  */
-#ifdef LONG_LONG
-   return (unsigned long long) unpack_long (type, valaddr);
-#else
-   return (unsigned long     ) unpack_long (type, valaddr);
-#endif
+   return (unsigned LONGEST) unpack_long (type, valaddr);
   } else {
     /* Signed -- we are OK with unpack_long.  */
     return unpack_long (type, valaddr);
@@ -1019,13 +1024,13 @@ value_virtual_fn_field (arg1p, f, j, type, offset)
    FIXME-tiemann: should work with dossier entries as well.  */
 
 static value
-value_headof (arg, btype, dtype)
-     value arg;
+value_headof (in_arg, btype, dtype)
+     value in_arg;
      struct type *btype, *dtype;
 {
   /* First collect the vtables we must look at for this object.  */
   /* FIXME-tiemann: right now, just look at top-most vtable.  */
-  value vtbl, entry, best_entry = 0;
+  value arg, vtbl, entry, best_entry = 0;
   int i, nelems;
   int offset, best_offset = 0;
   struct symbol *sym;
@@ -1035,11 +1040,10 @@ value_headof (arg, btype, dtype)
 
   btype = TYPE_VPTR_BASETYPE (dtype);
   check_stub_type (btype);
+  arg = in_arg;
   if (btype != dtype)
-    vtbl = value_cast (lookup_pointer_type (btype), arg);
-  else
-    vtbl = arg;
-  vtbl = value_ind (value_field (value_ind (vtbl), TYPE_VPTR_FIELDNO (btype)));
+    arg = value_cast (lookup_pointer_type (btype), arg);
+  vtbl = value_ind (value_field (value_ind (arg), TYPE_VPTR_FIELDNO (btype)));
 
   /* Check that VTBL looks like it points to a virtual function table.  */
   msymbol = lookup_minimal_symbol_by_pc (VALUE_ADDRESS (vtbl));
@@ -1050,10 +1054,10 @@ value_headof (arg, btype, dtype)
         know that we aren't happy, but don't throw an error.
         FIXME: there has to be a better way to do this.  */
       struct type *error_type = (struct type *)xmalloc (sizeof (struct type));
-      memcpy (error_type, VALUE_TYPE (arg), sizeof (struct type));
+      memcpy (error_type, VALUE_TYPE (in_arg), sizeof (struct type));
       TYPE_NAME (error_type) = savestring ("suspicious *", sizeof ("suspicious *"));
-      VALUE_TYPE (arg) = error_type;
-      return arg;
+      VALUE_TYPE (in_arg) = error_type;
+      return in_arg;
     }
 
   /* Now search through the virtual function table.  */
@@ -1098,6 +1102,7 @@ value_headof (arg, btype, dtype)
       arg = value_add (value_cast (builtin_type_int, arg),
                       value_field (best_entry, 0));
     }
+  else arg = in_arg;
   VALUE_TYPE (arg) = lookup_pointer_type (SYMBOL_TYPE (sym));
   return arg;
 }
@@ -1393,10 +1398,8 @@ value_from_longest (type, num)
        * (int *) VALUE_CONTENTS_RAW (val) = num;
       else if (len == sizeof (long))
        * (long *) VALUE_CONTENTS_RAW (val) = num;
-#ifdef LONG_LONG
-      else if (len == sizeof (long long))
-       * (long long *) VALUE_CONTENTS_RAW (val) = num;
-#endif
+      else if (len == sizeof (LONGEST))
+       * (LONGEST *) VALUE_CONTENTS_RAW (val) = num;
       else
        error ("Integer type encountered with unexpected data length.");
     }
@@ -1484,13 +1487,21 @@ value_being_returned (valtype, retbuf, struct_return)
 
    On most machines, the struct convention is used unless we are
    using gcc and the type is of a special size.  */
+/* As of about 31 Mar 93, GCC was changed to be compatible with the
+   native compiler.  GCC 2.3.3 was the last release that did it the
+   old way.  Since gcc2_compiled was not changed, we have no
+   way to correctly win in all cases, so we just do the right thing
+   for gcc1 and for gcc2 after this change.  Thus it loses for gcc
+   2.0-2.3.3.  This is somewhat unfortunate, but changing gcc2_compiled
+   would cause more chaos than dealing with some struct returns being
+   handled wrong.  */
 #if !defined (USE_STRUCT_CONVENTION)
 #define USE_STRUCT_CONVENTION(gcc_p, type)\
-  (!((gcc_p) && (TYPE_LENGTH (value_type) == 1                \
-                || TYPE_LENGTH (value_type) == 2             \
-                || TYPE_LENGTH (value_type) == 4             \
-                || TYPE_LENGTH (value_type) == 8             \
-                )                                            \
+  (!((gcc_p == 1) && (TYPE_LENGTH (value_type) == 1                \
+                     || TYPE_LENGTH (value_type) == 2             \
+                     || TYPE_LENGTH (value_type) == 4             \
+                     || TYPE_LENGTH (value_type) == 8             \
+                     )                                            \
      ))
 #endif
 
This page took 0.024915 seconds and 4 git commands to generate.