This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/3] bitpos: Expand type_field_bitpos to LONGEST and type.length to ULONGEST


On Sun, 05 Aug 2012 04:42:43 -0700, Michael wrote:
> The ChangeLog mentions a modification to microblaze-tdep.c, but the
> patch does not contain any changes to this file.
> 

Oh boy, I took the wrong diff from my repo when posting the patch -- I
had the patch in two changesets. Attached is the real patch for this.
ChangeLog added once again for review benefit.

Thanks,
Siddhesh

Attachment: bitpos-cl-main.txt
Description: Text document

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index aa090af..c350a0e 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -80,7 +80,7 @@ static struct type *desc_bounds_type (struct type *);
 
 static struct value *desc_bounds (struct value *);
 
-static int fat_pntr_bounds_bitpos (struct type *);
+static LONGEST fat_pntr_bounds_bitpos (struct type *);
 
 static int fat_pntr_bounds_bitsize (struct type *);
 
@@ -88,13 +88,13 @@ static struct type *desc_data_target_type (struct type *);
 
 static struct value *desc_data (struct value *);
 
-static int fat_pntr_data_bitpos (struct type *);
+static LONGEST fat_pntr_data_bitpos (struct type *);
 
 static int fat_pntr_data_bitsize (struct type *);
 
 static struct value *desc_one_bound (struct value *, int, int);
 
-static int desc_bound_bitpos (struct type *, int, int);
+static LONGEST desc_bound_bitpos (struct type *, int, int);
 
 static int desc_bound_bitsize (struct type *, int, int);
 
@@ -174,7 +174,7 @@ static struct type *static_unwrap_type (struct type *type);
 
 static struct value *unwrap_value (struct value *);
 
-static struct type *constrained_packed_array_type (struct type *, long *);
+static struct type *constrained_packed_array_type (struct type *, LONGEST *);
 
 static struct type *decode_constrained_packed_array_type (struct type *);
 
@@ -189,7 +189,8 @@ static int ada_is_unconstrained_packed_array_type (struct type *);
 static struct value *value_subscript_packed (struct value *, int,
                                              struct value **);
 
-static void move_bits (gdb_byte *, int, const gdb_byte *, int, int, int);
+static void move_bits (gdb_byte *, int, const gdb_byte *, LONGEST, LONGEST,
+		       int);
 
 static struct value *coerce_unspec_val_to_type (struct value *,
                                                 struct type *);
@@ -217,14 +218,14 @@ static struct value *value_val_atr (struct type *, struct value *);
 static struct symbol *standard_lookup (const char *, const struct block *,
                                        domain_enum);
 
-static struct value *ada_search_struct_field (char *, struct value *, int,
+static struct value *ada_search_struct_field (char *, struct value *, LONGEST,
                                               struct type *);
 
-static struct value *ada_value_primitive_field (struct value *, int, int,
+static struct value *ada_value_primitive_field (struct value *, LONGEST, int,
                                                 struct type *);
 
-static int find_struct_field (const char *, struct type *, int,
-                              struct type **, int *, int *, int *, int *);
+static int find_struct_field (const char *, struct type *, LONGEST,
+			      struct type **, LONGEST *, int *, int *, int *);
 
 static struct value *ada_to_fixed_value_create (struct type *, CORE_ADDR,
                                                 struct value *);
@@ -240,7 +241,7 @@ static void ada_language_arch_info (struct gdbarch *,
 
 static void check_size (const struct type *);
 
-static struct value *ada_index_struct_field (int, struct value *, int,
+static struct value *ada_index_struct_field (LONGEST, struct value *, LONGEST,
 					     struct type *);
 
 static struct value *assign_aggregate (struct value *, struct value *, 
@@ -586,7 +587,7 @@ coerce_unspec_val_to_type (struct value *val, struct type *type)
 }
 
 static const gdb_byte *
-cond_offset_host (const gdb_byte *valaddr, long offset)
+cond_offset_host (const gdb_byte *valaddr, LONGEST offset)
 {
   if (valaddr == NULL)
     return NULL;
@@ -595,7 +596,7 @@ cond_offset_host (const gdb_byte *valaddr, long offset)
 }
 
 static CORE_ADDR
-cond_offset_target (CORE_ADDR address, long offset)
+cond_offset_target (CORE_ADDR address, LONGEST offset)
 {
   if (address == 0)
     return 0;
@@ -1601,7 +1602,7 @@ desc_bounds (struct value *arr)
 /* If TYPE is the type of an array-descriptor (fat pointer),  the bit
    position of the field containing the address of the bounds data.  */
 
-static int
+static LONGEST
 fat_pntr_bounds_bitpos (struct type *type)
 {
   return TYPE_FIELD_BITPOS (desc_base_type (type), 1);
@@ -1667,7 +1668,7 @@ desc_data (struct value *arr)
 /* If TYPE is the type of an array-descriptor (fat pointer), the bit
    position of the field containing the address of the data.  */
 
-static int
+static LONGEST
 fat_pntr_data_bitpos (struct type *type)
 {
   return TYPE_FIELD_BITPOS (desc_base_type (type), 0);
@@ -1702,7 +1703,7 @@ desc_one_bound (struct value *bounds, int i, int which)
    of the Ith lower bound stored in it, if WHICH is 0, and the Ith upper
    bound, if WHICH is 1.  The first bound is I=1.  */
 
-static int
+static LONGEST
 desc_bound_bitpos (struct type *type, int i, int which)
 {
   return TYPE_FIELD_BITPOS (desc_base_type (type), 2 * i + which - 2);
@@ -1892,7 +1893,7 @@ ada_type_of_array (struct value *arr, int bounds)
 	         zero, and does not need to be recomputed.  */
 	      if (lo < hi)
 		{
-		  int array_bitsize =
+		  LONGEST array_bitsize =
 		        (hi - lo + 1) * TYPE_FIELD_BITSIZE (elt_type, 0);
 
 		  TYPE_LENGTH (array_type) = (array_bitsize + 7) / 8;
@@ -2044,7 +2045,7 @@ decode_packed_array_bitsize (struct type *type)
    in bits.  */
 
 static struct type *
-constrained_packed_array_type (struct type *type, long *elt_bits)
+constrained_packed_array_type (struct type *type, LONGEST *elt_bits)
 {
   struct type *new_elt_type;
   struct type *new_type;
@@ -2096,7 +2097,7 @@ decode_constrained_packed_array_type (struct type *type)
   char *name;
   const char *tail;
   struct type *shadow_type;
-  long bits;
+  LONGEST bits;
 
   if (!raw_name)
     raw_name = ada_type_name (desc_base_type (type));
@@ -2167,7 +2168,8 @@ decode_constrained_packed_array (struct value *arr)
  	 array with no wrapper.  In order to interpret the value through
  	 the (left-justified) packed array type we just built, we must
  	 first left-justify it.  */
-      int bit_size, bit_pos;
+      int bit_size;
+      LONGEST bit_pos;
       ULONGEST mod;
 
       mod = ada_modulus (value_type (arr)) - 1;
@@ -2268,15 +2270,16 @@ has_negatives (struct type *type)
 
 struct value *
 ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr,
-				long offset, int bit_offset, int bit_size,
+				LONGEST offset, int bit_offset, int bit_size,
                                 struct type *type)
 {
   struct value *v;
-  int src,                      /* Index into the source area */
-    targ,                       /* Index into the target area */
-    srcBitsLeft,                /* Number of source bits left to move */
-    nsrc, ntarg,                /* Number of source and target bytes */
-    unusedLS,                   /* Number of bits in next significant
+  int src;                      /* Index into the source area */
+  LONGEST targ;                 /* Index into the target area */
+  int srcBitsLeft,              /* Number of source bits left to move */
+    nsrc;                       /* Number of source bytes */
+  LONGEST ntarg;                /* Number of target bytes */
+  int unusedLS,                 /* Number of bits in next significant
                                    byte of source that are unused */
     accumSize;                  /* Number of meaningful bits in accum */
   unsigned char *bytes;         /* First byte containing data to unpack */
@@ -2426,7 +2429,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr,
    not overlap.  */
 static void
 move_bits (gdb_byte *target, int targ_offset, const gdb_byte *source,
-	   int src_offset, int n, int bits_big_endian_p)
+	   LONGEST src_offset, LONGEST n, int bits_big_endian_p)
 {
   unsigned int accum, mask;
   int accum_bits, chunk_size;
@@ -2516,7 +2519,7 @@ ada_value_assign (struct value *toval, struct value *fromval)
     {
       int len = (value_bitpos (toval)
 		 + bits + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT;
-      int from_size;
+      LONGEST from_size;
       char *buffer = (char *) alloca (len);
       struct value *val;
       CORE_ADDR to_addr = value_address (toval);
@@ -2561,7 +2564,7 @@ value_assign_to_component (struct value *container, struct value *component,
     (LONGEST)  (value_address (component) - value_address (container));
   int bit_offset_in_container = 
     value_bitpos (component) - value_bitpos (container);
-  int bits;
+  LONGEST bits;
   
   val = value_cast (value_type (component), val);
 
@@ -4081,7 +4084,7 @@ ensure_lval (struct value *val)
   if (VALUE_LVAL (val) == not_lval
       || VALUE_LVAL (val) == lval_internalvar)
     {
-      int len = TYPE_LENGTH (ada_check_typedef (value_type (val)));
+      LONGEST len = TYPE_LENGTH (ada_check_typedef (value_type (val)));
       const CORE_ADDR addr =
         value_as_long (value_allocate_space_in_inferior (len));
 
@@ -4155,7 +4158,7 @@ static CORE_ADDR
 value_pointer (struct value *value, struct type *type)
 {
   struct gdbarch *gdbarch = get_type_arch (type);
-  unsigned len = TYPE_LENGTH (type);
+  ULONGEST len = TYPE_LENGTH (type);
   gdb_byte *buf = alloca (len);
   CORE_ADDR addr;
 
@@ -6024,7 +6027,7 @@ value_tag_from_contents_and_address (struct type *type,
 				     const gdb_byte *valaddr,
                                      CORE_ADDR address)
 {
-  int tag_byte_offset;
+  LONGEST tag_byte_offset;
   struct type *tag_type;
 
   if (find_struct_field ("_tag", type, 0, &tag_type, &tag_byte_offset,
@@ -6407,7 +6410,7 @@ ada_in_variant (LONGEST val, struct type *type, int field_num)
    only in that it can handle packed values of arbitrary type.  */
 
 static struct value *
-ada_value_primitive_field (struct value *arg1, int offset, int fieldno,
+ada_value_primitive_field (struct value *arg1, LONGEST offset, int fieldno,
                            struct type *arg_type)
 {
   struct type *type;
@@ -6419,7 +6422,7 @@ ada_value_primitive_field (struct value *arg1, int offset, int fieldno,
 
   if (TYPE_FIELD_BITSIZE (arg_type, fieldno) != 0)
     {
-      int bit_pos = TYPE_FIELD_BITPOS (arg_type, fieldno);
+      LONGEST bit_pos = TYPE_FIELD_BITPOS (arg_type, fieldno);
       int bit_size = TYPE_FIELD_BITSIZE (arg_type, fieldno);
 
       return ada_value_primitive_packed_val (arg1, value_contents (arg1),
@@ -6446,9 +6449,9 @@ ada_value_primitive_field (struct value *arg1, int offset, int fieldno,
    Returns 1 if found, 0 otherwise.  */
 
 static int
-find_struct_field (const char *name, struct type *type, int offset,
+find_struct_field (const char *name, struct type *type, LONGEST offset,
                    struct type **field_type_p,
-                   int *byte_offset_p, int *bit_offset_p, int *bit_size_p,
+		   LONGEST *byte_offset_p, int *bit_offset_p, int *bit_size_p,
 		   int *index_p)
 {
   int i;
@@ -6466,8 +6469,8 @@ find_struct_field (const char *name, struct type *type, int offset,
 
   for (i = 0; i < TYPE_NFIELDS (type); i += 1)
     {
-      int bit_pos = TYPE_FIELD_BITPOS (type, i);
-      int fld_offset = offset + bit_pos / 8;
+      LONGEST bit_pos = TYPE_FIELD_BITPOS (type, i);
+      LONGEST fld_offset = offset + bit_pos / 8;
       const char *t_field_name = TYPE_FIELD_NAME (type, i);
 
       if (t_field_name == NULL)
@@ -6537,7 +6540,7 @@ num_visible_fields (struct type *type)
    Searches recursively through wrapper fields (e.g., '_parent').  */
 
 static struct value *
-ada_search_struct_field (char *name, struct value *arg, int offset,
+ada_search_struct_field (char *name, struct value *arg, LONGEST offset,
                          struct type *type)
 {
   int i;
@@ -6570,7 +6573,7 @@ ada_search_struct_field (char *name, struct value *arg, int offset,
           int j;
           struct type *field_type = ada_check_typedef (TYPE_FIELD_TYPE (type,
 									i));
-          int var_offset = offset + TYPE_FIELD_BITPOS (type, i) / 8;
+	  LONGEST var_offset = offset + TYPE_FIELD_BITPOS (type, i) / 8;
 
           for (j = 0; j < TYPE_NFIELDS (field_type); j += 1)
             {
@@ -6588,8 +6591,8 @@ ada_search_struct_field (char *name, struct value *arg, int offset,
   return NULL;
 }
 
-static struct value *ada_index_struct_field_1 (int *, struct value *,
-					       int, struct type *);
+static struct value *ada_index_struct_field_1 (LONGEST *, struct value *,
+					       LONGEST, struct type *);
 
 
 /* Return field #INDEX in ARG, where the index is that returned by
@@ -6598,7 +6601,7 @@ static struct value *ada_index_struct_field_1 (int *, struct value *,
  * If found, return value, else return NULL.  */
 
 static struct value *
-ada_index_struct_field (int index, struct value *arg, int offset,
+ada_index_struct_field (LONGEST index, struct value *arg, LONGEST offset,
 			struct type *type)
 {
   return ada_index_struct_field_1 (&index, arg, offset, type);
@@ -6610,7 +6613,7 @@ ada_index_struct_field (int index, struct value *arg, int offset,
  * *INDEX_P.  */
 
 static struct value *
-ada_index_struct_field_1 (int *index_p, struct value *arg, int offset,
+ada_index_struct_field_1 (LONGEST *index_p, struct value *arg, LONGEST offset,
 			  struct type *type)
 {
   int i;
@@ -6700,7 +6703,8 @@ ada_value_struct_elt (struct value *arg, char *name, int no_err)
     v = ada_search_struct_field (name, arg, 0, t);
   else
     {
-      int bit_offset, bit_size, byte_offset;
+      int bit_offset, bit_size;
+      LONGEST byte_offset;
       struct type *field_type;
       CORE_ADDR address;
 
@@ -7006,8 +7010,8 @@ ada_coerce_ref (struct value *val0)
 /* Return OFF rounded upward if necessary to a multiple of
    ALIGNMENT (a power of 2).  */
 
-static unsigned int
-align_value (unsigned int off, unsigned int alignment)
+static ULONGEST
+align_value (ULONGEST off, ULONGEST alignment)
 {
   return (off + alignment - 1) & ~(alignment - 1);
 }
@@ -7386,10 +7390,9 @@ ada_template_to_fixed_record_type_1 (struct type *type,
   struct value *mark = value_mark ();
   struct value *dval;
   struct type *rtype;
-  int nfields, bit_len;
+  int nfields;
   int variant_field;
-  long off;
-  int fld_bit_len;
+  LONGEST off, bit_len, fld_bit_len;
   int f;
 
   /* Compute the number of fields in this record type that are going
@@ -7460,7 +7463,7 @@ ada_template_to_fixed_record_type_1 (struct type *type,
 	     that follow this one.  */
 	  if (ada_is_aligner_type (field_type))
 	    {
-	      long field_offset = TYPE_FIELD_BITPOS (field_type, f);
+	      LONGEST field_offset = TYPE_FIELD_BITPOS (field_type, f);
 
 	      field_valaddr = cond_offset_host (field_valaddr, field_offset);
 	      field_address = cond_offset_target (field_address, field_offset);
@@ -7579,11 +7582,11 @@ ada_template_to_fixed_record_type_1 (struct type *type,
   if (TYPE_LENGTH (type) <= 0)
     {
       if (TYPE_NAME (rtype))
-	warning (_("Invalid type size for `%s' detected: %d."),
-		 TYPE_NAME (rtype), TYPE_LENGTH (type));
+	warning (_("Invalid type size for `%s' detected: %s."),
+		 TYPE_NAME (rtype), pulongest (TYPE_LENGTH (type)));
       else
-	warning (_("Invalid type size for <unnamed> detected: %d."),
-		 TYPE_LENGTH (type));
+	warning (_("Invalid type size for <unnamed> detected: %s."),
+		 pulongest (TYPE_LENGTH (type)));
     }
   else
     {
@@ -7920,7 +7923,8 @@ to_fixed_array_type (struct type *type0, struct value *dval,
 	 type was a regular (non-packed) array type.  As a result, the
 	 bitsize of the array elements needs to be set again, and the array
 	 length needs to be recomputed based on that bitsize.  */
-      int len = TYPE_LENGTH (result) / TYPE_LENGTH (TYPE_TARGET_TYPE (result));
+      LONGEST len = (TYPE_LENGTH (result)
+		     / TYPE_LENGTH (TYPE_TARGET_TYPE (result)));
       int elt_bitsize = TYPE_FIELD_BITSIZE (type0, 0);
 
       TYPE_FIELD_BITSIZE (result, 0) = TYPE_FIELD_BITSIZE (type0, 0);
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index 9a93c50..3de0723 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -168,7 +168,7 @@ extern void ada_print_type (struct type *, const char *, struct ui_file *, int,
 extern void ada_print_typedef (struct type *type, struct symbol *new_symbol,
 			       struct ui_file *stream);
 
-extern void ada_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
+extern void ada_val_print (struct type *, const gdb_byte *, LONGEST, CORE_ADDR,
 			   struct ui_file *, int,
 			   const struct value *,
 			   const struct value_print_options *);
@@ -183,7 +183,7 @@ extern void ada_emit_char (int, struct type *, struct ui_file *, int, int);
 extern void ada_printchar (int, struct type *, struct ui_file *);
 
 extern void ada_printstr (struct ui_file *, struct type *, const gdb_byte *,
-			  unsigned int, const char *, int,
+			  ULONGEST, const char *, int,
 			  const struct value_print_options *);
 
 struct value *ada_convert_actual (struct value *actual,
@@ -257,7 +257,7 @@ extern int ada_is_constrained_packed_array_type (struct type *);
 
 extern struct value *ada_value_primitive_packed_val (struct value *,
 						     const gdb_byte *,
-                                                     long, int, int,
+						     LONGEST, int, int,
                                                      struct type *);
 
 extern struct type *ada_coerce_to_simple_array_type (struct type *);
diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c
index 40f3058..10acc5e 100644
--- a/gdb/ada-typeprint.c
+++ b/gdb/ada-typeprint.c
@@ -815,8 +815,8 @@ ada_print_type (struct type *type0, const char *varstring,
 	    const char *name = ada_type_name (type);
 
 	    if (!ada_is_range_type_name (name))
-	      fprintf_filtered (stream, _("<%d-byte integer>"),
-				TYPE_LENGTH (type));
+	      fprintf_filtered (stream, _("<%s-byte integer>"),
+				pulongest (TYPE_LENGTH (type)));
 	    else
 	      {
 		fprintf_filtered (stream, "range ");
@@ -837,7 +837,8 @@ ada_print_type (struct type *type0, const char *varstring,
 	  }
 	break;
       case TYPE_CODE_FLT:
-	fprintf_filtered (stream, _("<%d-byte float>"), TYPE_LENGTH (type));
+	fprintf_filtered (stream, _("<%s-byte float>"),
+			  pulongest (TYPE_LENGTH (type)));
 	break;
       case TYPE_CODE_ENUM:
 	if (show < 0)
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 95ec7ec..4845fcc 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -42,16 +42,16 @@ static void print_record (struct type *, const gdb_byte *, int,
 			  const struct value_print_options *);
 
 static int print_field_values (struct type *, const gdb_byte *,
-			       int,
+			       LONGEST,
 			       struct ui_file *, int,
 			       const struct value *,
 			       const struct value_print_options *,
-			       int, struct type *, int);
+			       int, struct type *, LONGEST);
 
 static void adjust_type_signedness (struct type *);
 
-static void ada_val_print_1 (struct type *, const gdb_byte *, int, CORE_ADDR,
-			     struct ui_file *, int,
+static void ada_val_print_1 (struct type *, const gdb_byte *, LONGEST,
+			     CORE_ADDR, struct ui_file *, int,
 			     const struct value *,
 			     const struct value_print_options *);
 
@@ -144,7 +144,7 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
   unsigned int things_printed = 0;
   unsigned len;
   struct type *elttype, *index_type;
-  unsigned eltlen;
+  ULONGEST eltlen;
   unsigned long bitsize = TYPE_FIELD_BITSIZE (type, 0);
   struct value *mark = value_mark ();
   LONGEST low = 0;
@@ -293,7 +293,7 @@ ada_emit_char (int c, struct type *type, struct ui_file *stream,
    of a character.  */
 
 static int
-char_at (const gdb_byte *string, int i, int type_len,
+char_at (const gdb_byte *string, LONGEST i, int type_len,
 	 enum bfd_endian byte_order)
 {
   if (type_len == 1)
@@ -465,11 +465,11 @@ ada_print_scalar (struct type *type, LONGEST val, struct ui_file *stream)
 
 static void
 printstr (struct ui_file *stream, struct type *elttype, const gdb_byte *string,
-	  unsigned int length, int force_ellipses, int type_len,
+	  ULONGEST length, int force_ellipses, int type_len,
 	  const struct value_print_options *options)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (elttype));
-  unsigned int i;
+  ULONGEST i;
   unsigned int things_printed = 0;
   int in_quotes = 0;
   int need_comma = 0;
@@ -484,9 +484,9 @@ printstr (struct ui_file *stream, struct type *elttype, const gdb_byte *string,
     {
       /* Position of the character we are examining
          to see whether it is repeated.  */
-      unsigned int rep1;
+      ULONGEST rep1;
       /* Number of repetitions we have detected so far.  */
-      unsigned int reps;
+      ULONGEST reps;
 
       QUIT;
 
@@ -520,7 +520,8 @@ printstr (struct ui_file *stream, struct type *elttype, const gdb_byte *string,
 	  ada_emit_char (char_at (string, i, type_len, byte_order),
 			 elttype, stream, '\'', type_len);
 	  fputs_filtered ("'", stream);
-	  fprintf_filtered (stream, _(" <repeats %u times>"), reps);
+	  fprintf_filtered (stream, _(" <repeats %s times>"),
+			    pulongest (reps));
 	  i = rep1 - 1;
 	  things_printed += options->repeat_count_threshold;
 	  need_comma = 1;
@@ -556,7 +557,7 @@ printstr (struct ui_file *stream, struct type *elttype, const gdb_byte *string,
 
 void
 ada_printstr (struct ui_file *stream, struct type *type,
-	      const gdb_byte *string, unsigned int length,
+	      const gdb_byte *string, ULONGEST length,
 	      const char *encoding, int force_ellipses,
 	      const struct value_print_options *options)
 {
@@ -570,7 +571,7 @@ ada_printstr (struct ui_file *stream, struct type *type,
 
 void
 ada_val_print (struct type *type, const gdb_byte *valaddr,
-	       int embedded_offset, CORE_ADDR address,
+	       LONGEST embedded_offset, CORE_ADDR address,
 	       struct ui_file *stream, int recurse,
 	       const struct value *val,
 	       const struct value_print_options *options)
@@ -602,8 +603,8 @@ ada_val_print_array (struct type *type, const gdb_byte *valaddr,
     {
       enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
       struct type *elttype = TYPE_TARGET_TYPE (type);
-      unsigned int eltlen;
-      unsigned int len;
+      ULONGEST eltlen;
+      ULONGEST len;
 
       /* We know that ELTTYPE cannot possibly be null, because we found
 	 that TYPE is a string-like type.  Similarly, the size of ELTTYPE
@@ -621,7 +622,7 @@ ada_val_print_array (struct type *type, const gdb_byte *valaddr,
          elements up to it.  */
       if (options->stop_print_at_null)
         {
-          int temp_len;
+          LONGEST temp_len;
 
           /* Look for a NULL char.  */
           for (temp_len = 0;
@@ -654,7 +655,7 @@ ada_val_print_array (struct type *type, const gdb_byte *valaddr,
 
 static void
 ada_val_print_1 (struct type *type, const gdb_byte *valaddr,
-		 int offset, CORE_ADDR address,
+		 LONGEST offset, CORE_ADDR address,
 		 struct ui_file *stream, int recurse,
 		 const struct value *original_value,
 		 const struct value_print_options *options)
@@ -730,7 +731,7 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr,
       if (ada_is_fixed_point_type (type))
 	{
 	  LONGEST v = unpack_long (type, valaddr + offset_aligned);
-	  int len = TYPE_LENGTH (type);
+	  LONGEST len = TYPE_LENGTH (type);
 
 	  fprintf_filtered (stream, len < 4 ? "%.11g" : "%.17g",
 			    (double) ada_fixed_to_float (type, v));
@@ -924,12 +925,12 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr,
 
 static int
 print_variant_part (struct type *type, int field_num,
-		    const gdb_byte *valaddr, int offset,
+		    const gdb_byte *valaddr, LONGEST offset,
 		    struct ui_file *stream, int recurse,
 		    const struct value *val,
 		    const struct value_print_options *options,
 		    int comma_needed,
-		    struct type *outer_type, int outer_offset)
+		    struct type *outer_type, LONGEST outer_offset)
 {
   struct type *var_type = TYPE_FIELD_TYPE (type, field_num);
   int which = ada_which_variant_applies (var_type, outer_type,
@@ -1036,11 +1037,11 @@ print_record (struct type *type, const gdb_byte *valaddr,
 
 static int
 print_field_values (struct type *type, const gdb_byte *valaddr,
-		    int offset, struct ui_file *stream, int recurse,
+		    LONGEST offset, struct ui_file *stream, int recurse,
 		    const struct value *val,
 		    const struct value_print_options *options,
 		    int comma_needed,
-		    struct type *outer_type, int outer_offset)
+		    struct type *outer_type, LONGEST outer_offset)
 {
   int i, len;
 
@@ -1121,7 +1122,7 @@ print_field_values (struct type *type, const gdb_byte *valaddr,
 	    }
 	  else
 	    {
-	      int bit_pos = TYPE_FIELD_BITPOS (type, i);
+	      LONGEST bit_pos = TYPE_FIELD_BITPOS (type, i);
 	      int bit_size = TYPE_FIELD_BITSIZE (type, i);
 	      struct value_print_options opts;
 
diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c
index 5d3affa..7a6f38d 100644
--- a/gdb/alpha-tdep.c
+++ b/gdb/alpha-tdep.c
@@ -299,18 +299,18 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int i;
-  int accumulate_size = struct_return ? 8 : 0;
+  ssize_t accumulate_size = struct_return ? 8 : 0;
   struct alpha_arg
     {
       const gdb_byte *contents;
-      int len;
-      int offset;
+      ssize_t len;
+      ssize_t offset;
     };
   struct alpha_arg *alpha_args
     = (struct alpha_arg *) alloca (nargs * sizeof (struct alpha_arg));
   struct alpha_arg *m_arg;
   gdb_byte arg_reg_buffer[ALPHA_REGISTER_SIZE * ALPHA_NUM_ARG_REGS];
-  int required_arg_regs;
+  ssize_t required_arg_regs;
   CORE_ADDR func_addr = find_function_addr (function, NULL);
 
   /* The ABI places the address of the called function in T12.  */
@@ -423,8 +423,8 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   for (i = nargs; m_arg--, --i >= 0;)
     {
       const gdb_byte *contents = m_arg->contents;
-      int offset = m_arg->offset;
-      int len = m_arg->len;
+      ssize_t offset = m_arg->offset;
+      ssize_t len = m_arg->len;
 
       /* Copy the bytes destined for registers into arg_reg_buffer.  */
       if (offset < sizeof(arg_reg_buffer))
@@ -436,7 +436,7 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 	    }
 	  else
 	    {
-	      int tlen = sizeof(arg_reg_buffer) - offset;
+	      ssize_t tlen = sizeof(arg_reg_buffer) - offset;
 	      memcpy (arg_reg_buffer + offset, contents, tlen);
 	      offset += tlen;
 	      contents += tlen;
@@ -475,7 +475,7 @@ alpha_extract_return_value (struct type *valtype, struct regcache *regcache,
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  int length = TYPE_LENGTH (valtype);
+  LONGEST length = TYPE_LENGTH (valtype);
   gdb_byte raw_buffer[ALPHA_REGISTER_SIZE];
   ULONGEST l;
 
@@ -544,7 +544,7 @@ alpha_store_return_value (struct type *valtype, struct regcache *regcache,
 			  const gdb_byte *valbuf)
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
-  int length = TYPE_LENGTH (valtype);
+  LONGEST length = TYPE_LENGTH (valtype);
   gdb_byte raw_buffer[ALPHA_REGISTER_SIZE];
   ULONGEST l;
 
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 5424926..dfa361b 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -446,7 +446,7 @@ amd64_non_pod_p (struct type *type)
 static void
 amd64_classify_aggregate (struct type *type, enum amd64_reg_class class[2])
 {
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
 
   /* 1. If the size of an object is larger than two eightbytes, or in
         C++, is a non-POD structure or union type, or contains
@@ -485,10 +485,10 @@ amd64_classify_aggregate (struct type *type, enum amd64_reg_class class[2])
       for (i = 0; i < TYPE_NFIELDS (type); i++)
 	{
 	  struct type *subtype = check_typedef (TYPE_FIELD_TYPE (type, i));
-	  int pos = TYPE_FIELD_BITPOS (type, i) / 64;
+	  LONGEST pos = TYPE_FIELD_BITPOS (type, i) / 64;
 	  enum amd64_reg_class subclass[2];
-	  int bitsize = TYPE_FIELD_BITSIZE (type, i);
-	  int endpos;
+	  LONGEST bitsize = TYPE_FIELD_BITSIZE (type, i);
+	  LONGEST endpos;
 
 	  if (bitsize == 0)
 	    bitsize = TYPE_LENGTH (subtype) * 8;
@@ -552,7 +552,7 @@ void
 amd64_classify (struct type *type, enum amd64_reg_class class[2])
 {
   enum type_code code = TYPE_CODE (type);
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
 
   class[0] = class[1] = AMD64_NO_CLASS;
 
@@ -601,7 +601,7 @@ amd64_return_value (struct gdbarch *gdbarch, struct value *function,
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   enum amd64_reg_class class[2];
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
   static int integer_regnum[] = { AMD64_RAX_REGNUM, AMD64_RDX_REGNUM };
   static int sse_regnum[] = { AMD64_XMM0_REGNUM, AMD64_XMM1_REGNUM };
   int integer_reg = 0;
@@ -730,8 +730,8 @@ amd64_push_arguments (struct regcache *regcache, int nargs,
      that register number (or a negative value otherwise).  */
   int *arg_addr_regno = alloca (nargs * sizeof (int));
   int num_stack_args = 0;
-  int num_elements = 0;
-  int element = 0;
+  LONGEST num_elements = 0;
+  LONGEST element = 0;
   int integer_reg = 0;
   int sse_reg = 0;
   int i;
@@ -745,7 +745,7 @@ amd64_push_arguments (struct regcache *regcache, int nargs,
   for (i = 0; i < nargs; i++)
     {
       struct type *type = value_type (args[i]);
-      int len = TYPE_LENGTH (type);
+      LONGEST len = TYPE_LENGTH (type);
       enum amd64_reg_class class[2];
       int needed_integer_regs = 0;
       int needed_sse_regs = 0;
@@ -839,7 +839,7 @@ amd64_push_arguments (struct regcache *regcache, int nargs,
     {
       struct type *type = value_type (stack_args[i]);
       const gdb_byte *valbuf = value_contents (stack_args[i]);
-      int len = TYPE_LENGTH (type);
+      LONGEST len = TYPE_LENGTH (type);
       CORE_ADDR arg_addr = sp + element * 8;
 
       write_memory (arg_addr, valbuf, len);
@@ -2764,7 +2764,7 @@ amd64_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
   CORE_ADDR jb_addr;
   struct gdbarch *gdbarch = get_frame_arch (frame);
   int jb_pc_offset = gdbarch_tdep (gdbarch)->jb_pc_offset;
-  int len = TYPE_LENGTH (builtin_type (gdbarch)->builtin_func_ptr);
+  LONGEST len = TYPE_LENGTH (builtin_type (gdbarch)->builtin_func_ptr);
 
   /* If JB_PC_OFFSET is -1, we have no way to find out where the
      longjmp will land.	 */
diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c
index 528fbb6..e9614fb 100644
--- a/gdb/amd64-windows-tdep.c
+++ b/gdb/amd64-windows-tdep.c
@@ -79,7 +79,7 @@ amd64_windows_return_value (struct gdbarch *gdbarch, struct value *function,
 			    struct type *type, struct regcache *regcache,
 			    gdb_byte *readbuf, const gdb_byte *writebuf)
 {
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
   int regnum = -1;
 
   /* See if our value is returned through a register.  If it is, then
diff --git a/gdb/annotate.c b/gdb/annotate.c
index cd0a94a..9fd649a 100644
--- a/gdb/annotate.c
+++ b/gdb/annotate.c
@@ -522,21 +522,21 @@ annotate_frame_end (void)
 }
 
 void
-annotate_array_section_begin (int idx, struct type *elttype)
+annotate_array_section_begin (LONGEST idx, struct type *elttype)
 {
   if (annotation_level == 2)
     {
-      printf_filtered (("\n\032\032array-section-begin %d "), idx);
+      printf_filtered (("\n\032\032array-section-begin %s "), plongest (idx));
       print_value_flags (elttype);
       printf_filtered (("\n"));
     }
 }
 
 void
-annotate_elt_rep (unsigned int repcount)
+annotate_elt_rep (ULONGEST repcount)
 {
   if (annotation_level == 2)
-    printf_filtered (("\n\032\032elt-rep %u\n"), repcount);
+    printf_filtered (("\n\032\032elt-rep %s\n"), pulongest (repcount));
 }
 
 void
diff --git a/gdb/annotate.h b/gdb/annotate.h
index 0eae524..cd50a65 100644
--- a/gdb/annotate.h
+++ b/gdb/annotate.h
@@ -94,8 +94,8 @@ extern void annotate_frame_source_end (void);
 extern void annotate_frame_where (void);
 extern void annotate_frame_end (void);
 
-extern void annotate_array_section_begin (int, struct type *);
-extern void annotate_elt_rep (unsigned int);
+extern void annotate_array_section_begin (LONGEST, struct type *);
+extern void annotate_elt_rep (ULONGEST);
 extern void annotate_elt_rep_end (void);
 extern void annotate_elt (void);
 extern void annotate_array_section_end (void);
diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c
index bf81c03..231b008 100644
--- a/gdb/arm-linux-nat.c
+++ b/gdb/arm-linux-nat.c
@@ -1073,7 +1073,7 @@ arm_linux_remove_hw_breakpoint (struct gdbarch *gdbarch,
 /* Are we able to use a hardware watchpoint for the LEN bytes starting at 
    ADDR?  */
 static int
-arm_linux_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
+arm_linux_region_ok_for_hw_watchpoint (CORE_ADDR addr, LONGEST len)
 {
   const struct arm_linux_hwbp_cap *cap = arm_linux_get_hwbp_cap ();
   CORE_ADDR max_wp_length, aligned_addr;
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 568ace5..a401c00 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -3377,7 +3377,7 @@ arm_vfp_cprc_reg_char (enum arm_vfp_cprc_base_type b)
    array).  Vectors and complex types are not currently supported,
    matching the generic AAPCS support.  */
 
-static int
+static LONGEST
 arm_vfp_cprc_sub_candidate (struct type *t,
 			    enum arm_vfp_cprc_base_type *base_type)
 {
@@ -3408,7 +3408,7 @@ arm_vfp_cprc_sub_candidate (struct type *t,
 
     case TYPE_CODE_ARRAY:
       {
-	int count;
+	LONGEST count;
 	unsigned unitlen;
 	count = arm_vfp_cprc_sub_candidate (TYPE_TARGET_TYPE (t), base_type);
 	if (count == -1)
@@ -3433,8 +3433,10 @@ arm_vfp_cprc_sub_candidate (struct type *t,
 	int i;
 	for (i = 0; i < TYPE_NFIELDS (t); i++)
 	  {
-	    int sub_count = arm_vfp_cprc_sub_candidate (TYPE_FIELD_TYPE (t, i),
-							base_type);
+	    LONGEST sub_count;
+
+	    sub_count = arm_vfp_cprc_sub_candidate (TYPE_FIELD_TYPE (t, i),
+						    base_type);
 	    if (sub_count == -1)
 	      return -1;
 	    count += sub_count;
@@ -3454,13 +3456,15 @@ arm_vfp_cprc_sub_candidate (struct type *t,
 
     case TYPE_CODE_UNION:
       {
-	int count = 0;
+	LONGEST count = 0;
 	unsigned unitlen;
 	int i;
 	for (i = 0; i < TYPE_NFIELDS (t); i++)
 	  {
-	    int sub_count = arm_vfp_cprc_sub_candidate (TYPE_FIELD_TYPE (t, i),
-							base_type);
+	    LONGEST sub_count;
+
+	    sub_count = arm_vfp_cprc_sub_candidate (TYPE_FIELD_TYPE (t, i),
+						    base_type);
 	    if (sub_count == -1)
 	      return -1;
 	    count = (count > sub_count ? count : sub_count);
@@ -3496,7 +3500,7 @@ arm_vfp_call_candidate (struct type *t, enum arm_vfp_cprc_base_type *base_type,
 			int *count)
 {
   enum arm_vfp_cprc_base_type b = VFP_CPRC_UNKNOWN;
-  int c = arm_vfp_cprc_sub_candidate (t, &b);
+  LONGEST c = arm_vfp_cprc_sub_candidate (t, &b);
   if (c <= 0 || c > 4)
     return 0;
   *base_type = b;
@@ -3577,7 +3581,7 @@ arm_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 
   for (argnum = 0; argnum < nargs; argnum++)
     {
-      int len;
+      LONGEST len;
       struct type *arg_type;
       struct type *target_type;
       enum type_code typecode;
@@ -8771,7 +8775,7 @@ arm_extract_return_value (struct type *type, struct regcache *regs,
       /* If the type is a plain integer, then the access is
 	 straight-forward.  Otherwise we have to play around a bit
 	 more.  */
-      int len = TYPE_LENGTH (type);
+      LONGEST len = TYPE_LENGTH (type);
       int regno = ARM_A1_REGNUM;
       ULONGEST tmp;
 
@@ -8793,7 +8797,7 @@ arm_extract_return_value (struct type *type, struct regcache *regs,
       /* For a structure or union the behaviour is as if the value had
          been stored to word-aligned memory and then loaded into 
          registers with 32-bit load instruction(s).  */
-      int len = TYPE_LENGTH (type);
+      LONGEST len = TYPE_LENGTH (type);
       int regno = ARM_A1_REGNUM;
       bfd_byte tmpbuf[INT_REGISTER_SIZE];
 
@@ -8974,7 +8978,7 @@ arm_store_return_value (struct type *type, struct regcache *regs,
 	  /* Integral values greater than one word are stored in consecutive
 	     registers starting with r0.  This will always be a multiple of
 	     the regiser size.  */
-	  int len = TYPE_LENGTH (type);
+	  LONGEST len = TYPE_LENGTH (type);
 	  int regno = ARM_A1_REGNUM;
 
 	  while (len > 0)
@@ -8990,7 +8994,7 @@ arm_store_return_value (struct type *type, struct regcache *regs,
       /* For a structure or union the behaviour is as if the value had
          been stored to word-aligned memory and then loaded into 
          registers with 32-bit load instruction(s).  */
-      int len = TYPE_LENGTH (type);
+      LONGEST len = TYPE_LENGTH (type);
       int regno = ARM_A1_REGNUM;
       bfd_byte tmpbuf[INT_REGISTER_SIZE];
 
diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c
index 864d288..b9a660a 100644
--- a/gdb/avr-tdep.c
+++ b/gdb/avr-tdep.c
@@ -1170,13 +1170,14 @@ avr_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
 
 struct stack_item
 {
-  int len;
+  ssize_t len;
   struct stack_item *prev;
   void *data;
 };
 
 static struct stack_item *
-push_stack_item (struct stack_item *prev, const bfd_byte *contents, int len)
+push_stack_item (struct stack_item *prev, const bfd_byte *contents,
+		 ssize_t len)
 {
   struct stack_item *si;
   si = xmalloc (sizeof (struct stack_item));
@@ -1265,12 +1266,12 @@ avr_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 
   for (i = 0; i < nargs; i++)
     {
-      int last_regnum;
-      int j;
+      LONGEST last_regnum;
+      LONGEST j;
       struct value *arg = args[i];
       struct type *type = check_typedef (value_type (arg));
       const bfd_byte *contents = value_contents (arg);
-      int len = TYPE_LENGTH (type);
+      LONGEST len = TYPE_LENGTH (type);
 
       /* Calculate the potential last register needed.  */
       last_regnum = regnum - (len + (len & 1));
diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
index f2c5155..11e1b29 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -84,12 +84,12 @@ static void gen_traced_pop (struct gdbarch *, struct agent_expr *,
 static void gen_sign_extend (struct agent_expr *, struct type *);
 static void gen_extend (struct agent_expr *, struct type *);
 static void gen_fetch (struct agent_expr *, struct type *);
-static void gen_left_shift (struct agent_expr *, int);
+static void gen_left_shift (struct agent_expr *, LONGEST);
 
 
 static void gen_frame_args_address (struct gdbarch *, struct agent_expr *);
 static void gen_frame_locals_address (struct gdbarch *, struct agent_expr *);
-static void gen_offset (struct agent_expr *ax, int offset);
+static void gen_offset (struct agent_expr *ax, LONGEST offset);
 static void gen_sym_offset (struct agent_expr *, struct symbol *);
 static void gen_var_ref (struct gdbarch *, struct agent_expr *ax,
 			 struct axs_value *value, struct symbol *var);
@@ -137,15 +137,16 @@ static void gen_deref (struct agent_expr *, struct axs_value *);
 static void gen_address_of (struct agent_expr *, struct axs_value *);
 static void gen_bitfield_ref (struct expression *exp, struct agent_expr *ax,
 			      struct axs_value *value,
-			      struct type *type, int start, int end);
+			      struct type *type, LONGEST start, LONGEST end);
 static void gen_primitive_field (struct expression *exp,
 				 struct agent_expr *ax,
 				 struct axs_value *value,
-				 int offset, int fieldno, struct type *type);
+				 LONGEST offset, int fieldno,
+				 struct type *type);
 static int gen_struct_ref_recursive (struct expression *exp,
 				     struct agent_expr *ax,
 				     struct axs_value *value,
-				     char *field, int offset,
+				     char *field, LONGEST offset,
 				     struct type *type);
 static void gen_struct_ref (struct expression *exp, struct agent_expr *ax,
 			    struct axs_value *value,
@@ -367,7 +368,7 @@ gen_trace_static_fields (struct gdbarch *gdbarch,
 	    {
 	    case axs_lvalue_memory:
 	      {
-		int length = TYPE_LENGTH (check_typedef (value.type));
+		LONGEST length = TYPE_LENGTH (check_typedef (value.type));
 
 		ax_const_l (ax, length);
 		ax_simple (ax, aop_trace);
@@ -425,7 +426,7 @@ gen_traced_pop (struct gdbarch *gdbarch,
 
       case axs_lvalue_memory:
 	{
-	  int length = TYPE_LENGTH (check_typedef (value->type));
+	  LONGEST length = TYPE_LENGTH (check_typedef (value->type));
 
 	  if (string_trace)
 	    ax_simple (ax, aop_dup);
@@ -569,7 +570,7 @@ gen_fetch (struct agent_expr *ax, struct type *type)
    right shift it by -DISTANCE bits if DISTANCE < 0.  This generates
    unsigned (logical) right shifts.  */
 static void
-gen_left_shift (struct agent_expr *ax, int distance)
+gen_left_shift (struct agent_expr *ax, LONGEST distance)
 {
   if (distance > 0)
     {
@@ -623,7 +624,7 @@ gen_frame_locals_address (struct gdbarch *gdbarch, struct agent_expr *ax)
    programming in ML, it would be clearer why these are the same
    thing.  */
 static void
-gen_offset (struct agent_expr *ax, int offset)
+gen_offset (struct agent_expr *ax, LONGEST offset)
 {
   /* It would suffice to simply push the offset and add it, but this
      makes it easier to read positive and negative offsets in the
@@ -1279,7 +1280,7 @@ gen_address_of (struct agent_expr *ax, struct axs_value *value)
 static void
 gen_bitfield_ref (struct expression *exp, struct agent_expr *ax,
 		  struct axs_value *value, struct type *type,
-		  int start, int end)
+		  LONGEST start, LONGEST end)
 {
   /* Note that ops[i] fetches 8 << i bits.  */
   static enum agent_op ops[]
@@ -1314,13 +1315,13 @@ gen_bitfield_ref (struct expression *exp, struct agent_expr *ax,
 
   /* The first and one-after-last bits in the field, but rounded down
      and up to byte boundaries.  */
-  int bound_start = (start / TARGET_CHAR_BIT) * TARGET_CHAR_BIT;
-  int bound_end = (((end + TARGET_CHAR_BIT - 1)
-		    / TARGET_CHAR_BIT)
-		   * TARGET_CHAR_BIT);
+  LONGEST bound_start = (start / TARGET_CHAR_BIT) * TARGET_CHAR_BIT;
+  LONGEST bound_end = (((end + TARGET_CHAR_BIT - 1)
+			/ TARGET_CHAR_BIT)
+		       * TARGET_CHAR_BIT);
 
   /* current bit offset within the structure */
-  int offset;
+  LONGEST offset;
 
   /* The index in ops of the opcode we're considering.  */
   int op;
@@ -1439,7 +1440,7 @@ gen_bitfield_ref (struct expression *exp, struct agent_expr *ax,
 static void
 gen_primitive_field (struct expression *exp,
 		     struct agent_expr *ax, struct axs_value *value,
-		     int offset, int fieldno, struct type *type)
+		     LONGEST offset, int fieldno, struct type *type)
 {
   /* Is this a bitfield?  */
   if (TYPE_FIELD_PACKED (type, fieldno))
@@ -1464,7 +1465,7 @@ gen_primitive_field (struct expression *exp,
 static int
 gen_struct_ref_recursive (struct expression *exp, struct agent_expr *ax,
 			  struct axs_value *value,
-			  char *field, int offset, struct type *type)
+			  char *field, LONGEST offset, struct type *type)
 {
   int i, rslt;
   int nbases = TYPE_N_BASECLASSES (type);
diff --git a/gdb/ax-general.c b/gdb/ax-general.c
index 6ea6f14..8e26ec4 100644
--- a/gdb/ax-general.c
+++ b/gdb/ax-general.c
@@ -192,7 +192,7 @@ ax_zero_ext (struct agent_expr *x, int n)
 
 /* Append a trace_quick instruction to EXPR, to record N bytes.  */
 void
-ax_trace_quick (struct agent_expr *x, int n)
+ax_trace_quick (struct agent_expr *x, LONGEST n)
 {
   /* N must fit in a byte.  */
   if (n < 0 || n > 255)
diff --git a/gdb/ax.h b/gdb/ax.h
index 368f727..9c904af 100644
--- a/gdb/ax.h
+++ b/gdb/ax.h
@@ -190,7 +190,7 @@ extern void ax_ext (struct agent_expr *EXPR, int N);
 extern void ax_zero_ext (struct agent_expr *EXPR, int N);
 
 /* Append a trace_quick instruction to EXPR, to record N bytes.  */
-extern void ax_trace_quick (struct agent_expr *EXPR, int N);
+extern void ax_trace_quick (struct agent_expr *EXPR, LONGEST N);
 
 /* Append a goto op to EXPR.  OP is the actual op (must be aop_goto or
    aop_if_goto).  We assume we don't know the target offset yet,
diff --git a/gdb/bfin-tdep.c b/gdb/bfin-tdep.c
index fb2ead0..77c22e2 100644
--- a/gdb/bfin-tdep.c
+++ b/gdb/bfin-tdep.c
@@ -506,14 +506,14 @@ bfin_push_dummy_call (struct gdbarch *gdbarch,
   char buf[4];
   int i;
   long reg_r0, reg_r1, reg_r2;
-  int total_len = 0;
+  LONGEST total_len = 0;
   enum bfin_abi abi = bfin_abi (gdbarch);
   CORE_ADDR func_addr = find_function_addr (function, NULL);
 
   for (i = nargs - 1; i >= 0; i--)
     {
       struct type *value_type = value_enclosing_type (args[i]);
-      int len = TYPE_LENGTH (value_type);
+      LONGEST len = TYPE_LENGTH (value_type);
 
       total_len += (len + 3) & ~3;
     }
@@ -531,8 +531,8 @@ bfin_push_dummy_call (struct gdbarch *gdbarch,
     {
       struct type *value_type = value_enclosing_type (args[i]);
       struct type *arg_type = check_typedef (value_type);
-      int len = TYPE_LENGTH (value_type);
-      int container_len = (len + 3) & ~3;
+      LONGEST len = TYPE_LENGTH (value_type);
+      LONGEST container_len = (len + 3) & ~3;
 
       sp -= container_len;
       write_memory (sp, value_contents_writeable (args[i]), container_len);
@@ -613,7 +613,7 @@ bfin_extract_return_value (struct type *type,
   struct gdbarch *gdbarch = get_regcache_arch (regs);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   bfd_byte *valbuf = dst;
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
   ULONGEST tmp;
   int regno = BFIN_R0_REGNUM;
 
@@ -642,7 +642,7 @@ bfin_store_return_value (struct type *type,
      registers starting with R0.  This will always be a multiple of
      the register size.  */
 
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
   int regno = BFIN_R0_REGNUM;
 
   gdb_assert (len <= 8);
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 03719d4..5733178 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -1844,7 +1844,8 @@ update_watchpoint (struct watchpoint *b, int reparse)
 		      && TYPE_CODE (vtype) != TYPE_CODE_ARRAY))
 		{
 		  CORE_ADDR addr;
-		  int len, type;
+		  LONGEST len;
+		  int type;
 		  struct bp_location *loc, **tmp;
 
 		  addr = value_address (v);
@@ -6585,7 +6586,7 @@ breakpoint_address_match (struct address_space *aspace1, CORE_ADDR addr1,
 
 static int
 breakpoint_address_match_range (struct address_space *aspace1, CORE_ADDR addr1,
-				int len1, struct address_space *aspace2,
+				LONGEST len1, struct address_space *aspace2,
 				CORE_ADDR addr2)
 {
   return ((gdbarch_has_global_breakpoints (target_gdbarch)
@@ -11078,7 +11079,7 @@ can_use_hardware_watchpoint (struct value *v)
 		      && TYPE_CODE (vtype) != TYPE_CODE_ARRAY))
 		{
 		  CORE_ADDR vaddr = value_address (v);
-		  int len;
+		  LONGEST len;
 		  int num_regs;
 
 		  len = (target_exact_watchpoints
@@ -14695,7 +14696,7 @@ show_breakpoint_cmd (char *args, int from_tty)
    GDB itself.  */
 
 static void
-invalidate_bp_value_on_memory_change (CORE_ADDR addr, int len,
+invalidate_bp_value_on_memory_change (CORE_ADDR addr, LONGEST len,
 				      const bfd_byte *data)
 {
   struct breakpoint *bp;
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 4e4f875..7dec418 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -250,7 +250,7 @@ struct bp_target_info
 
   /* If this is a ranged breakpoint, then this field contains the
      length of the range that will be watched for execution.  */
-  int length;
+  LONGEST length;
 
   /* If the breakpoint lives in memory and reading that memory would
      give back the breakpoint, instead of the original contents, then
@@ -419,7 +419,7 @@ struct bp_location
   /* For hardware watchpoints, the size of the memory region being
      watched.  For hardware ranged breakpoints, the size of the
      breakpoint range.  */
-  int length;
+  LONGEST length;
 
   /* Type of hardware watchpoint.  */
   enum target_hw_bp_type watchpoint_type;
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index b5135d5..ce0f4ef 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -189,7 +189,7 @@ c_printchar (int c, struct type *type, struct ui_file *stream)
 
 void
 c_printstr (struct ui_file *stream, struct type *type, 
-	    const gdb_byte *string, unsigned int length, 
+	    const gdb_byte *string, ULONGEST length,
 	    const char *user_encoding, int force_ellipses,
 	    const struct value_print_options *options)
 {
@@ -678,7 +678,7 @@ evaluate_subexp_c (struct type *expect_type, struct expression *exp,
 	  }
 	else
 	  {
-	    int i;
+	    LONGEST i;
 
 	    /* Write the terminating character.  */
 	    for (i = 0; i < TYPE_LENGTH (type); ++i)
@@ -687,7 +687,7 @@ evaluate_subexp_c (struct type *expect_type, struct expression *exp,
 	    if (satisfy_expected)
 	      {
 		LONGEST low_bound, high_bound;
-		int element_size = TYPE_LENGTH (type);
+		LONGEST element_size = TYPE_LENGTH (type);
 
 		if (get_discrete_bounds (TYPE_INDEX_TYPE (expect_type),
 					 &low_bound, &high_bound) < 0)
diff --git a/gdb/c-lang.h b/gdb/c-lang.h
index 5cbe34d..c02b8f4 100644
--- a/gdb/c-lang.h
+++ b/gdb/c-lang.h
@@ -72,7 +72,7 @@ extern void c_print_typedef (struct type *,
 			     struct ui_file *);
 
 extern void c_val_print (struct type *, const gdb_byte *,
-			 int, CORE_ADDR,
+			 LONGEST, CORE_ADDR,
 			 struct ui_file *, int,
 			 const struct value *,
 			 const struct value_print_options *);
@@ -92,7 +92,7 @@ extern void c_printchar (int, struct type *, struct ui_file *);
 extern void c_printstr (struct ui_file * stream,
 			struct type *elttype,
 			const gdb_byte *string,
-			unsigned int length,
+			ULONGEST length,
 			const char *user_encoding,
 			int force_ellipses,
 			const struct value_print_options *options);
@@ -118,14 +118,14 @@ extern void cp_print_class_member (const gdb_byte *, struct type *,
 				   struct ui_file *, char *);
 
 extern void cp_print_value_fields (struct type *, struct type *,
-				   const gdb_byte *, int, CORE_ADDR,
+				   const gdb_byte *, LONGEST, CORE_ADDR,
 				   struct ui_file *, int,
 				   const struct value *,
 				   const struct value_print_options *,
 				   struct type **, int);
 
 extern void cp_print_value_fields_rtti (struct type *,
-					const gdb_byte *, int, CORE_ADDR,
+					const gdb_byte *, LONGEST, CORE_ADDR,
 					struct ui_file *, int,
 					const struct value *,
 					const struct value_print_options *,
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index a5892b5..7acbb8b 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -625,8 +625,8 @@ c_type_print_varspec_suffix (struct type *type,
 
 	fprintf_filtered (stream, "[");
 	if (get_array_bounds (type, &low_bound, &high_bound))
-	  fprintf_filtered (stream, "%d", 
-			    (int) (high_bound - low_bound + 1));
+	  fprintf_filtered (stream, "%s", 
+			    plongest (high_bound - low_bound + 1));
 	fprintf_filtered (stream, "]");
 
 	c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream,
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 7a1bb02..2de41d7 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -133,7 +133,7 @@ static const struct generic_val_print_decorations c_decorations =
 
 void
 c_val_print (struct type *type, const gdb_byte *valaddr,
-	     int embedded_offset, CORE_ADDR address,
+	     LONGEST embedded_offset, CORE_ADDR address,
 	     struct ui_file *stream, int recurse,
 	     const struct value *original_value,
 	     const struct value_print_options *options)
@@ -144,7 +144,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr,
   unsigned len;
   struct type *elttype, *unresolved_elttype;
   struct type *unresolved_type = type;
-  unsigned eltlen;
+  ULONGEST eltlen;
   CORE_ADDR addr;
 
   CHECK_TYPEDEF (type);
@@ -364,9 +364,9 @@ c_val_print (struct type *type, const gdb_byte *valaddr,
 	  /* Print vtable entry - we only get here if NOT using
 	     -fvtable_thunks.  (Otherwise, look under
 	     TYPE_CODE_PTR.)  */
-	  int offset = (embedded_offset
-			+ TYPE_FIELD_BITPOS (type,
-					     VTBL_FNADDR_OFFSET) / 8);
+	  LONGEST offset = (embedded_offset
+			    + TYPE_FIELD_BITPOS (type,
+					 	 VTBL_FNADDR_OFFSET) / 8);
 	  struct type *field_type = TYPE_FIELD_TYPE (type,
 						     VTBL_FNADDR_OFFSET);
 	  CORE_ADDR addr
@@ -445,7 +445,8 @@ c_value_print (struct value *val, struct ui_file *stream,
 	       const struct value_print_options *options)
 {
   struct type *type, *real_type, *val_type;
-  int full, top, using_enc;
+  int full, using_enc;
+  LONGEST top;
   struct value_print_options opts = *options;
 
   opts.deref_ref = 1;
diff --git a/gdb/cp-abi.c b/gdb/cp-abi.c
index 16b5356..03f4baf 100644
--- a/gdb/cp-abi.c
+++ b/gdb/cp-abi.c
@@ -68,13 +68,13 @@ is_operator_name (const char *name)
   return (*current_cp_abi.is_operator_name) (name);
 }
 
-int
+LONGEST
 baseclass_offset (struct type *type, int index, const gdb_byte *valaddr,
-		  int embedded_offset, CORE_ADDR address,
+		  LONGEST embedded_offset, CORE_ADDR address,
 		  const struct value *val)
 {
   volatile struct gdb_exception ex;
-  int res = 0;
+  LONGEST res = 0;
 
   gdb_assert (current_cp_abi.baseclass_offset != NULL);
 
@@ -98,7 +98,7 @@ baseclass_offset (struct type *type, int index, const gdb_byte *valaddr,
 struct value *
 value_virtual_fn_field (struct value **arg1p,
 			struct fn_field *f, int j,
-			struct type *type, int offset)
+			struct type *type, LONGEST offset)
 {
   if ((current_cp_abi.virtual_fn_field) == NULL)
     return NULL;
@@ -108,7 +108,7 @@ value_virtual_fn_field (struct value **arg1p,
 
 struct type *
 value_rtti_type (struct value *v, int *full,
-		 int *top, int *using_enc)
+		 LONGEST *top, int *using_enc)
 {
   struct type *ret = NULL;
   volatile struct gdb_exception e;
diff --git a/gdb/cp-abi.h b/gdb/cp-abi.h
index 8451450..a34e9fe 100644
--- a/gdb/cp-abi.h
+++ b/gdb/cp-abi.h
@@ -108,7 +108,7 @@ extern struct value *value_virtual_fn_field (struct value **valuep,
 					     struct fn_field *f,
 					     int j,
 					     struct type *type,
-					     int offset);
+					     LONGEST offset);
 
 
 /* Try to find the run-time type of VALUE, using C++ run-time type
@@ -135,7 +135,7 @@ extern struct value *value_virtual_fn_field (struct value **valuep,
    FULL, TOP, and USING_ENC can each be zero, in which case we don't
    provide the corresponding piece of information.  */
 extern struct type *value_rtti_type (struct value *value,
-                                     int *full, int *top,
+                                     int *full, LONGEST *top,
 				     int *using_enc);
 
 /* Compute the offset of the baseclass which is the INDEXth baseclass
@@ -144,11 +144,11 @@ extern struct type *value_rtti_type (struct value *value,
    contents of VAL.  The result is the offset of the baseclass value
    relative to (the address of)(ARG) + OFFSET.  */
 
-extern int baseclass_offset (struct type *type,
-			     int index, const gdb_byte *valaddr,
-			     int embedded_offset,
-			     CORE_ADDR address,
-			     const struct value *val);
+extern LONGEST baseclass_offset (struct type *type,
+				 int index, const gdb_byte *valaddr,
+				 LONGEST embedded_offset,
+				 CORE_ADDR address,
+				 const struct value *val);
 
 /* Describe the target of a pointer to method.  CONTENTS is the byte
    pattern representing the pointer to method.  TYPE is the pointer to
@@ -204,12 +204,13 @@ struct cp_abi_ops
   struct value *(*virtual_fn_field) (struct value **arg1p,
 				     struct fn_field * f,
 				     int j, struct type * type,
-				     int offset);
+				     LONGEST offset);
   struct type *(*rtti_type) (struct value *v, int *full,
-			     int *top, int *using_enc);
-  int (*baseclass_offset) (struct type *type, int index,
-			   const bfd_byte *valaddr, int embedded_offset,
-			   CORE_ADDR address, const struct value *val);
+			     LONGEST *top, int *using_enc);
+  LONGEST (*baseclass_offset) (struct type *type, int index,
+			       const bfd_byte *valaddr,
+			       LONGEST embedded_offset, CORE_ADDR address,
+			       const struct value *val);
   void (*print_method_ptr) (const gdb_byte *contents,
 			    struct type *type,
 			    struct ui_file *stream);
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index c066aa5..8bc329e 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -82,7 +82,7 @@ static void cp_print_static_field (struct type *, struct value *,
 				   const struct value_print_options *);
 
 static void cp_print_value (struct type *, struct type *,
-			    const gdb_byte *, int,
+			    const gdb_byte *, LONGEST,
 			    CORE_ADDR, struct ui_file *,
 			    int, const struct value *,
 			    const struct value_print_options *,
@@ -156,7 +156,7 @@ cp_is_vtbl_member (struct type *type)
 
 void
 cp_print_value_fields (struct type *type, struct type *real_type,
-		       const gdb_byte *valaddr, int offset,
+		       const gdb_byte *valaddr, LONGEST offset,
 		       CORE_ADDR address, struct ui_file *stream,
 		       int recurse, const struct value *val,
 		       const struct value_print_options *options,
@@ -360,7 +360,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 		}
 	      else if (i == TYPE_VPTR_FIELDNO (type))
 		{
-		  int i_offset = offset + TYPE_FIELD_BITPOS (type, i) / 8;
+		  LONGEST i_offset = offset + TYPE_FIELD_BITPOS (type, i) / 8;
 		  struct type *i_type = TYPE_FIELD_TYPE (type, i);
 
 		  if (valprint_check_validity (stream, i_type, i_offset, val))
@@ -443,7 +443,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 
 void
 cp_print_value_fields_rtti (struct type *type,
-			    const gdb_byte *valaddr, int offset,
+			    const gdb_byte *valaddr, LONGEST offset,
 			    CORE_ADDR address,
 			    struct ui_file *stream, int recurse,
 			    const struct value *val,
@@ -459,7 +459,8 @@ cp_print_value_fields_rtti (struct type *type,
 			TARGET_CHAR_BIT * TYPE_LENGTH (type)))
     {
       struct value *value;
-      int full, top, using_enc;
+      int full, using_enc;
+      LONGEST top;
 
       /* Ugh, we have to convert back to a value here.  */
       value = value_from_contents_and_address (type, valaddr + offset,
@@ -483,7 +484,7 @@ cp_print_value_fields_rtti (struct type *type,
 
 static void
 cp_print_value (struct type *type, struct type *real_type,
-		const gdb_byte *valaddr, int offset,
+		const gdb_byte *valaddr, LONGEST offset,
 		CORE_ADDR address, struct ui_file *stream,
 		int recurse, const struct value *val,
 		const struct value_print_options *options,
@@ -493,7 +494,7 @@ cp_print_value (struct type *type, struct type *real_type,
     = (struct type **) obstack_next_free (&dont_print_vb_obstack);
   struct obstack tmp_obstack = dont_print_vb_obstack;
   int i, n_baseclasses = TYPE_N_BASECLASSES (type);
-  int thisoffset;
+  LONGEST thisoffset;
   struct type *thistype;
 
   if (dont_print_vb == 0)
@@ -507,7 +508,7 @@ cp_print_value (struct type *type, struct type *real_type,
 
   for (i = 0; i < n_baseclasses; i++)
     {
-      int boffset = 0;
+      LONGEST boffset = 0;
       int skip;
       struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
       const char *basename = TYPE_NAME (baseclass);
diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
index 6739037..abbcbf1 100644
--- a/gdb/cris-tdep.c
+++ b/gdb/cris-tdep.c
@@ -670,13 +670,13 @@ static CORE_ADDR cris_unwind_sp (struct gdbarch *gdbarch,
 
 struct stack_item
 {
-  int len;
+  ssize_t len;
   struct stack_item *prev;
   void *data;
 };
 
 static struct stack_item *
-push_stack_item (struct stack_item *prev, void *contents, int len)
+push_stack_item (struct stack_item *prev, void *contents, ssize_t len)
 {
   struct stack_item *si;
   si = xmalloc (sizeof (struct stack_item));
@@ -849,10 +849,10 @@ cris_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 
   for (argnum = 0; argnum < nargs; argnum++)
     {
-      int len;
+      LONGEST len;
       char *val;
-      int reg_demand;
-      int i;
+      LONGEST reg_demand;
+      LONGEST i;
       
       len = TYPE_LENGTH (value_type (args[argnum]));
       val = (char *) value_contents (args[argnum]);
@@ -1662,7 +1662,7 @@ cris_store_return_value (struct type *type, struct regcache *regcache,
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   ULONGEST val;
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
   
   if (len <= 4)
     {
@@ -1833,7 +1833,7 @@ cris_extract_return_value (struct type *type, struct regcache *regcache,
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   ULONGEST val;
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
   
   if (len <= 4)
     {
diff --git a/gdb/d-lang.h b/gdb/d-lang.h
index f93405a..84b149f 100644
--- a/gdb/d-lang.h
+++ b/gdb/d-lang.h
@@ -25,7 +25,7 @@
 extern char *d_demangle (const char *mangled, int options);
 
 extern void d_val_print (struct type *type, const gdb_byte *valaddr,
-			 int embedded_offset, CORE_ADDR address,
+			 LONGEST embedded_offset, CORE_ADDR address,
 			 struct ui_file *stream, int recurse,
 			 const struct value *val,
 			 const struct value_print_options *options);
diff --git a/gdb/d-valprint.c b/gdb/d-valprint.c
index 3a8d11d..5d066e7 100644
--- a/gdb/d-valprint.c
+++ b/gdb/d-valprint.c
@@ -29,7 +29,7 @@
 
 static int
 dynamic_array_type (struct type *type, const gdb_byte *valaddr,
-		    int embedded_offset, CORE_ADDR address,
+		    LONGEST embedded_offset, CORE_ADDR address,
 		    struct ui_file *stream, int recurse,
 		    const struct value *val,
 		    const struct value_print_options *options)
@@ -71,9 +71,9 @@ dynamic_array_type (struct type *type, const gdb_byte *valaddr,
 
 /* Implements the la_val_print routine for language D.  */
 void
-d_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
-             CORE_ADDR address, struct ui_file *stream, int recurse,
-	     const struct value *val,
+d_val_print (struct type *type, const gdb_byte *valaddr,
+	     LONGEST embedded_offset, CORE_ADDR address,
+	     struct ui_file *stream, int recurse, const struct value *val,
              const struct value_print_options *options)
 {
   int ret;
diff --git a/gdb/doc/observer.texi b/gdb/doc/observer.texi
index 6827ed8..6370d92 100644
--- a/gdb/doc/observer.texi
+++ b/gdb/doc/observer.texi
@@ -216,7 +216,7 @@ The inferior @var{inf} has been removed from the list of inferiors.
 This method is called immediately before freeing @var{inf}.
 @end deftypefun
 
-@deftypefun void memory_changed (CORE_ADDR @var{addr}, int @var{len}, const bfd_byte *@var{data})
+@deftypefun void memory_changed (CORE_ADDR @var{addr}, LONGEST @var{len}, const bfd_byte *@var{data})
 Bytes from @var{data} to @var{data} + @var{len} have been written
 to the current inferior at @var{addr}.
 @end deftypefun
diff --git a/gdb/doublest.c b/gdb/doublest.c
index f683002..af917b6 100644
--- a/gdb/doublest.c
+++ b/gdb/doublest.c
@@ -792,7 +792,7 @@ floatformat_from_doublest (const struct floatformat *fmt,
    but not passed on by GDB.  This should be fixed.  */
 
 static const struct floatformat *
-floatformat_from_length (struct gdbarch *gdbarch, int len)
+floatformat_from_length (struct gdbarch *gdbarch, LONGEST len)
 {
   const struct floatformat *format;
 
@@ -820,8 +820,8 @@ floatformat_from_length (struct gdbarch *gdbarch, int len)
   else
     format = NULL;
   if (format == NULL)
-    error (_("Unrecognized %d-bit floating-point type."),
-	   len * TARGET_CHAR_BIT);
+    error (_("Unrecognized %s-bit floating-point type."),
+	   plongest (len * TARGET_CHAR_BIT));
   return format;
 }
 
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index e8d39fe..ad12e37 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -1481,19 +1481,19 @@ insert_bits (unsigned int datum,
    BITS_BIG_ENDIAN is taken directly from gdbarch.  */
 
 static void
-copy_bitwise (gdb_byte *dest, unsigned int dest_offset_bits,
-	      const gdb_byte *source, unsigned int source_offset_bits,
-	      unsigned int bit_count,
+copy_bitwise (gdb_byte *dest, ULONGEST dest_offset_bits,
+	      const gdb_byte *source, ULONGEST source_offset,
+	      ULONGEST bit_count,
 	      int bits_big_endian)
 {
-  unsigned int dest_avail;
+  unsigned int dest_avail, source_offset_bits;
   int datum;
 
   /* Reduce everything to byte-size pieces.  */
   dest += dest_offset_bits / 8;
   dest_offset_bits %= 8;
-  source += source_offset_bits / 8;
-  source_offset_bits %= 8;
+  source += source_offset / 8;
+  source_offset_bits = source_offset % 8;
 
   dest_avail = 8 - dest_offset_bits % 8;
 
@@ -1531,13 +1531,13 @@ static void
 read_pieced_value (struct value *v)
 {
   int i;
-  long offset = 0;
+  LONGEST offset = 0;
   ULONGEST bits_to_skip;
   gdb_byte *contents;
   struct piece_closure *c
     = (struct piece_closure *) value_computed_closure (v);
   struct frame_info *frame = frame_find_by_id (VALUE_FRAME_ID (v));
-  size_t type_len;
+  ULONGEST type_len;
   size_t buffer_size = 0;
   char *buffer = NULL;
   struct cleanup *cleanup;
@@ -1564,8 +1564,8 @@ read_pieced_value (struct value *v)
   for (i = 0; i < c->n_pieces && offset < type_len; i++)
     {
       struct dwarf_expr_piece *p = &c->pieces[i];
-      size_t this_size, this_size_bits;
-      long dest_offset_bits, source_offset_bits, source_offset;
+      ULONGEST this_size, this_size_bits;
+      LONGEST dest_offset_bits, source_offset_bits, source_offset;
       const gdb_byte *intermediate_buffer;
 
       /* Compute size, source, and destination offsets for copying, in
@@ -1714,13 +1714,13 @@ static void
 write_pieced_value (struct value *to, struct value *from)
 {
   int i;
-  long offset = 0;
+  LONGEST offset = 0;
   ULONGEST bits_to_skip;
   const gdb_byte *contents;
   struct piece_closure *c
     = (struct piece_closure *) value_computed_closure (to);
   struct frame_info *frame = frame_find_by_id (VALUE_FRAME_ID (to));
-  size_t type_len;
+  ULONGEST type_len;
   size_t buffer_size = 0;
   char *buffer = NULL;
   struct cleanup *cleanup;
@@ -1748,8 +1748,8 @@ write_pieced_value (struct value *to, struct value *from)
   for (i = 0; i < c->n_pieces && offset < type_len; i++)
     {
       struct dwarf_expr_piece *p = &c->pieces[i];
-      size_t this_size_bits, this_size;
-      long dest_offset_bits, source_offset_bits, dest_offset, source_offset;
+      ULONGEST this_size_bits, this_size;
+      LONGEST dest_offset_bits, source_offset_bits, dest_offset, source_offset;
       int need_bitwise;
       const gdb_byte *source_buffer;
 
@@ -1878,8 +1878,8 @@ write_pieced_value (struct value *to, struct value *from)
    implicit pointer.  */
 
 static int
-check_pieced_value_bits (const struct value *value, int bit_offset,
-			 int bit_length,
+check_pieced_value_bits (const struct value *value, LONGEST bit_offset,
+			 LONGEST bit_length,
 			 enum dwarf_value_location check_for)
 {
   struct piece_closure *c
@@ -1895,7 +1895,7 @@ check_pieced_value_bits (const struct value *value, int bit_offset,
   for (i = 0; i < c->n_pieces && bit_length > 0; i++)
     {
       struct dwarf_expr_piece *p = &c->pieces[i];
-      size_t this_size_bits = p->size;
+      ULONGEST this_size_bits = p->size;
 
       if (bit_offset > 0)
 	{
@@ -1933,8 +1933,8 @@ check_pieced_value_bits (const struct value *value, int bit_offset,
 }
 
 static int
-check_pieced_value_validity (const struct value *value, int bit_offset,
-			     int bit_length)
+check_pieced_value_validity (const struct value *value, LONGEST bit_offset,
+			     LONGEST bit_length)
 {
   return check_pieced_value_bits (value, bit_offset, bit_length,
 				  DWARF_VALUE_MEMORY);
@@ -1952,8 +1952,8 @@ check_pieced_value_invalid (const struct value *value)
    a synthetic pointer.  */
 
 static int
-check_pieced_synthetic_pointer (const struct value *value, int bit_offset,
-				int bit_length)
+check_pieced_synthetic_pointer (const struct value *value, LONGEST bit_offset,
+				LONGEST bit_length)
 {
   return check_pieced_value_bits (value, bit_offset, bit_length,
 				  DWARF_VALUE_IMPLICIT_POINTER);
@@ -1978,9 +1978,10 @@ indirect_pieced_value (struct value *value)
   struct type *type;
   struct frame_info *frame;
   struct dwarf2_locexpr_baton baton;
-  int i, bit_offset, bit_length;
+  int i;
+  LONGEST bit_length;
   struct dwarf_expr_piece *piece = NULL;
-  LONGEST byte_offset;
+  LONGEST byte_offset, bit_offset;
 
   type = check_typedef (value_type (value));
   if (TYPE_CODE (type) != TYPE_CODE_PTR)
@@ -2227,7 +2228,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
 	    struct value *value = dwarf_expr_fetch (ctx, 0);
 	    gdb_byte *contents;
 	    const gdb_byte *val_bytes;
-	    size_t n = TYPE_LENGTH (value_type (value));
+	    ULONGEST n = TYPE_LENGTH (value_type (value));
 
 	    if (byte_offset + TYPE_LENGTH (type) > n)
 	      invalid_synthetic_pointer ();
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 04c6ed0..84e0059 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -1127,12 +1127,12 @@ dwarf2_complex_location_expr_complaint (void)
 }
 
 static void
-dwarf2_const_value_length_mismatch_complaint (const char *arg1, int arg2,
-					      int arg3)
+dwarf2_const_value_length_mismatch_complaint (const char *arg1, LONGEST arg2,
+					      LONGEST arg3)
 {
   complaint (&symfile_complaints,
-	     _("const value length mismatch for '%s', got %d, expected %d"),
-	     arg1, arg2, arg3);
+	     _("const value length mismatch for '%s', got %s, expected %s"),
+	     arg1, plongest (arg2), plongest (arg3));
 }
 
 static void
@@ -9843,8 +9843,8 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
 	         object, and then subtract off the number of bits of
 	         the field itself.  The result is the bit offset of
 	         the LSB of the field.  */
-	      int anonymous_size;
-	      int bit_offset = DW_UNSND (attr);
+	      LONGEST anonymous_size;
+	      LONGEST bit_offset = DW_UNSND (attr);
 
 	      attr = dwarf2_attr (die, DW_AT_byte_size, cu);
 	      if (attr)
diff --git a/gdb/eval.c b/gdb/eval.c
index 4253820..33eeb1d 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -319,7 +319,8 @@ evaluate_struct_tuple (struct value *struct_val,
       int pc = *pos;
       struct value *val = NULL;
       int nlabels = 0;
-      int bitpos, bitsize;
+      int bitsize;
+      LONGEST bitpos;
       bfd_byte *addr;
 
       /* Skip past the labels, and count them.  */
@@ -462,7 +463,7 @@ init_array_element (struct value *array, struct value *element,
 		    enum noside noside, LONGEST low_bound, LONGEST high_bound)
 {
   LONGEST index;
-  int element_size = TYPE_LENGTH (value_type (element));
+  LONGEST element_size = TYPE_LENGTH (value_type (element));
 
   if (exp->elts[*pos].opcode == BINOP_COMMA)
     {
@@ -625,11 +626,11 @@ binop_promote (const struct language_defn *language, struct gdbarch *gdbarch,
     /* FIXME: Also mixed integral/booleans, with result an integer.  */
     {
       const struct builtin_type *builtin = builtin_type (gdbarch);
-      unsigned int promoted_len1 = TYPE_LENGTH (type1);
-      unsigned int promoted_len2 = TYPE_LENGTH (type2);
+      ULONGEST promoted_len1 = TYPE_LENGTH (type1);
+      ULONGEST promoted_len2 = TYPE_LENGTH (type2);
       int is_unsigned1 = TYPE_UNSIGNED (type1);
       int is_unsigned2 = TYPE_UNSIGNED (type2);
-      unsigned int result_len;
+      ULONGEST result_len;
       int unsigned_operation;
 
       /* Determine type length and signedness after promotion for
@@ -813,7 +814,7 @@ evaluate_subexp_standard (struct type *expect_type,
   int lower;
   int code;
   int ix;
-  long mem_offset;
+  LONGEST mem_offset;
   struct type **arg_types;
   int save_pos1;
   struct symbol *function = NULL;
@@ -1002,7 +1003,7 @@ evaluate_subexp_standard (struct type *expect_type,
 	  struct type *range_type = TYPE_INDEX_TYPE (type);
 	  struct type *element_type = TYPE_TARGET_TYPE (type);
 	  struct value *array = allocate_value (expect_type);
-	  int element_size = TYPE_LENGTH (check_typedef (element_type));
+	  LONGEST element_size = TYPE_LENGTH (check_typedef (element_type));
 	  LONGEST low_bound, high_bound, index;
 
 	  if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0)
@@ -2010,7 +2011,8 @@ evaluate_subexp_standard (struct type *expect_type,
       {
         struct type *type = value_type (arg1);
         struct type *real_type;
-        int full, top, using_enc;
+        int full, using_enc;
+	LONGEST top;
 	struct value_print_options opts;
 
 	get_user_print_options (&opts);
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 7492149..1522590 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -138,7 +138,7 @@ f_printchar (int c, struct type *type, struct ui_file *stream)
 
 static void
 f_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
-	    unsigned int length, const char *encoding, int force_ellipses,
+	    ULONGEST length, const char *encoding, int force_ellipses,
 	    const struct value_print_options *options)
 {
   const char *type_encoding = f_get_encoding (type);
diff --git a/gdb/f-lang.h b/gdb/f-lang.h
index 4aae3c5..d20a46f 100644
--- a/gdb/f-lang.h
+++ b/gdb/f-lang.h
@@ -28,7 +28,7 @@ extern void f_error (char *);	/* Defined in f-exp.y */
 extern void f_print_type (struct type *, const char *, struct ui_file *, int,
 			  int);
 
-extern void f_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
+extern void f_val_print (struct type *, const gdb_byte *, LONGEST, CORE_ADDR,
 			 struct ui_file *, int,
 			 const struct value *,
 			 const struct value_print_options *);
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index 4359f6f..a422ac2 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -46,7 +46,7 @@ static void f77_create_arrayprint_offset_tbl (struct type *,
 					      struct ui_file *);
 static void f77_get_dynamic_length_of_aggregate (struct type *);
 
-int f77_array_offset_tbl[MAX_FORTRAN_DIMS + 1][2];
+LONGEST f77_array_offset_tbl[MAX_FORTRAN_DIMS + 1][2];
 
 /* Array which holds offsets to be applied to get a row's elements
    for a given array.  Array also holds the size of each subarray.  */
@@ -124,7 +124,7 @@ static void
 f77_create_arrayprint_offset_tbl (struct type *type, struct ui_file *stream)
 {
   struct type *tmp_type;
-  int eltlen;
+  LONGEST eltlen;
   int ndimen = 1;
   int upper, lower;
 
@@ -164,13 +164,13 @@ f77_create_arrayprint_offset_tbl (struct type *type, struct ui_file *stream)
 static void
 f77_print_array_1 (int nss, int ndimensions, struct type *type,
 		   const gdb_byte *valaddr,
-		   int embedded_offset, CORE_ADDR address,
+		   LONGEST embedded_offset, CORE_ADDR address,
 		   struct ui_file *stream, int recurse,
 		   const struct value *val,
 		   const struct value_print_options *options,
 		   int *elts)
 {
-  int i;
+  LONGEST i;
 
   if (nss != ndimensions)
     {
@@ -215,7 +215,7 @@ f77_print_array_1 (int nss, int ndimensions, struct type *type,
 
 static void
 f77_print_array (struct type *type, const gdb_byte *valaddr,
-		 int embedded_offset,
+		 LONGEST embedded_offset,
 		 CORE_ADDR address, struct ui_file *stream,
 		 int recurse,
 		 const struct value *val,
@@ -258,8 +258,9 @@ static const struct generic_val_print_decorations f_decorations =
    function; they are identical.  */
 
 void
-f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
-	     CORE_ADDR address, struct ui_file *stream, int recurse,
+f_val_print (struct type *type, const gdb_byte *valaddr,
+	     LONGEST embedded_offset, CORE_ADDR address,
+	     struct ui_file *stream, int recurse,
 	     const struct value *original_value,
 	     const struct value_print_options *options)
 {
@@ -381,7 +382,7 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       fprintf_filtered (stream, "( ");
       for (index = 0; index < TYPE_NFIELDS (type); index++)
         {
-          int offset = TYPE_FIELD_BITPOS (type, index) / 8;
+	  LONGEST offset = TYPE_FIELD_BITPOS (type, index) / 8;
 
           val_print (TYPE_FIELD_TYPE (type, index), valaddr,
 		     embedded_offset + offset,
diff --git a/gdb/findcmd.c b/gdb/findcmd.c
index 68184aa..0445e4c 100644
--- a/gdb/findcmd.c
+++ b/gdb/findcmd.c
@@ -169,7 +169,7 @@ parse_find_args (char *args, ULONGEST *max_countp,
   while (*s != '\0')
     {
       LONGEST x;
-      int val_bytes;
+      LONGEST val_bytes;
       ULONGEST pattern_buf_size_need;
 
       while (isspace (*s))
diff --git a/gdb/findvar.c b/gdb/findvar.c
index 66bcebe..c269ab5 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -446,7 +446,7 @@ default_read_var_value (struct symbol *var, struct frame_info *frame)
   struct value *v;
   struct type *type = SYMBOL_TYPE (var);
   CORE_ADDR addr;
-  int len;
+  LONGEST len;
 
   /* Call check_typedef on our type to make sure that, if TYPE is
      a TYPE_CODE_TYPEDEF, its length is set to the length of the target type
@@ -653,7 +653,7 @@ default_value_from_register (struct type *type, int regnum,
 			     struct frame_info *frame)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
   struct value *value = allocate_value (type);
 
   VALUE_LVAL (value) = lval_register;
@@ -683,10 +683,10 @@ void
 read_frame_register_value (struct value *value, struct frame_info *frame)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
-  int offset = 0;
-  int reg_offset = value_offset (value);
+  LONGEST offset = 0;
+  LONGEST reg_offset = value_offset (value);
   int regnum = VALUE_REGNUM (value);
-  int len = TYPE_LENGTH (check_typedef (value_type (value)));
+  LONGEST len = TYPE_LENGTH (check_typedef (value_type (value)));
 
   gdb_assert (VALUE_LVAL (value) == lval_register);
 
@@ -701,7 +701,7 @@ read_frame_register_value (struct value *value, struct frame_info *frame)
   while (len > 0)
     {
       struct value *regval = get_frame_register_value (frame, regnum);
-      int reg_len = TYPE_LENGTH (value_type (regval)) - reg_offset;
+      LONGEST reg_len = TYPE_LENGTH (value_type (regval)) - reg_offset;
 
       /* If the register length is larger than the number of bytes
          remaining to copy, then only copy the appropriate bytes.  */
diff --git a/gdb/frame.c b/gdb/frame.c
index 278269d..fdd46e7 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -1111,7 +1111,7 @@ frame_register_read (struct frame_info *frame, int regnum,
 
 int
 get_frame_register_bytes (struct frame_info *frame, int regnum,
-			  CORE_ADDR offset, int len, gdb_byte *myaddr,
+			  CORE_ADDR offset, LONGEST len, gdb_byte *myaddr,
 			  int *optimizedp, int *unavailablep)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
@@ -1140,7 +1140,7 @@ get_frame_register_bytes (struct frame_info *frame, int regnum,
     }
   if (len > maxsize)
     error (_("Bad debug information detected: "
-	     "Attempt to read %d bytes from registers."), len);
+	     "Attempt to read %s bytes from registers."), plongest (len));
 
   /* Copy the data.  */
   while (len > 0)
diff --git a/gdb/frame.h b/gdb/frame.h
index 532fb26..8d88432 100644
--- a/gdb/frame.h
+++ b/gdb/frame.h
@@ -530,7 +530,7 @@ extern void put_frame_register (struct frame_info *frame, int regnum,
    contents are optimized out or unavailable, set *OPTIMIZEDP,
    *UNAVAILABLEP accordingly.  */
 extern int get_frame_register_bytes (struct frame_info *frame, int regnum,
-				     CORE_ADDR offset, int len,
+				     CORE_ADDR offset, LONGEST len,
 				     gdb_byte *myaddr,
 				     int *optimizedp, int *unavailablep);
 
diff --git a/gdb/frv-tdep.c b/gdb/frv-tdep.c
index 9262b10..0873da6 100644
--- a/gdb/frv-tdep.c
+++ b/gdb/frv-tdep.c
@@ -1120,7 +1120,7 @@ frv_extract_return_value (struct type *type, struct regcache *regcache,
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
 
   if (len <= 4)
     {
@@ -1139,7 +1139,7 @@ frv_extract_return_value (struct type *type, struct regcache *regcache,
     }
   else
     internal_error (__FILE__, __LINE__,
-		    _("Illegal return value length: %d"), len);
+		    _("Illegal return value length: %s"), plongest (len));
 }
 
 static CORE_ADDR
@@ -1210,7 +1210,7 @@ frv_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   char valbuf[4];
   struct value *arg;
   struct type *arg_type;
-  int len;
+  LONGEST len;
   enum type_code typecode;
   CORE_ADDR regval;
   int stack_space;
@@ -1328,7 +1328,7 @@ static void
 frv_store_return_value (struct type *type, struct regcache *regcache,
                         const gdb_byte *valbuf)
 {
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
 
   if (len <= 4)
     {
@@ -1344,7 +1344,8 @@ frv_store_return_value (struct type *type, struct regcache *regcache,
     }
   else
     internal_error (__FILE__, __LINE__,
-                    _("Don't know how to return a %d-byte value."), len);
+                    _("Don't know how to return a %s-byte value."),
+		    plongest (len));
 }
 
 static enum return_value_convention
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 0ea4df1..9479098 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -953,7 +953,7 @@ create_array_type (struct type *result_type,
 
 struct type *
 lookup_array_range_type (struct type *element_type,
-			 int low_bound, int high_bound)
+			 LONGEST low_bound, LONGEST high_bound)
 {
   struct gdbarch *gdbarch = get_type_arch (element_type);
   struct type *index_type = builtin_type (gdbarch)->builtin_int;
@@ -989,7 +989,7 @@ create_string_type (struct type *result_type,
 
 struct type *
 lookup_string_range_type (struct type *string_char_type,
-			  int low_bound, int high_bound)
+			  LONGEST low_bound, LONGEST high_bound)
 {
   struct type *result_type;
 
@@ -1935,7 +1935,7 @@ allocate_gnat_aux_type (struct type *type)
    where init_type is called with a NULL value for NAME).  */
 
 struct type *
-init_type (enum type_code code, int length, int flags,
+init_type (enum type_code code, LONGEST length, int flags,
 	   char *name, struct objfile *objfile)
 {
   struct type *type;
@@ -2167,8 +2167,8 @@ is_public_ancestor (struct type *base, struct type *dclass)
 
 static int
 is_unique_ancestor_worker (struct type *base, struct type *dclass,
-			   int *offset,
-			   const gdb_byte *valaddr, int embedded_offset,
+			   LONGEST *offset,
+			   const gdb_byte *valaddr, LONGEST embedded_offset,
 			   CORE_ADDR address, struct value *val)
 {
   int i, count = 0;
@@ -2179,7 +2179,7 @@ is_unique_ancestor_worker (struct type *base, struct type *dclass,
   for (i = 0; i < TYPE_N_BASECLASSES (dclass) && count < 2; ++i)
     {
       struct type *iter;
-      int this_offset;
+      LONGEST this_offset;
 
       iter = check_typedef (TYPE_BASECLASS (dclass, i));
 
@@ -2220,7 +2220,7 @@ is_unique_ancestor_worker (struct type *base, struct type *dclass,
 int
 is_unique_ancestor (struct type *base, struct value *val)
 {
-  int offset = -1;
+  LONGEST offset = -1;
 
   return is_unique_ancestor_worker (base, value_type (val), &offset,
 				    value_contents_for_printing (val),
@@ -3113,7 +3113,7 @@ recursive_dump_type (struct type *type, int spaces)
       break;
     }
   puts_filtered ("\n");
-  printfi_filtered (spaces, "length %d\n", TYPE_LENGTH (type));
+  printfi_filtered (spaces, "length %s\n", pulongest (TYPE_LENGTH (type)));
   if (TYPE_OBJFILE_OWNED (type))
     {
       printfi_filtered (spaces, "objfile ");
@@ -3233,8 +3233,8 @@ recursive_dump_type (struct type *type, int spaces)
 			  idx, plongest (TYPE_FIELD_ENUMVAL (type, idx)));
       else
 	printfi_filtered (spaces + 2,
-			  "[%d] bitpos %d bitsize %d type ",
-			  idx, TYPE_FIELD_BITPOS (type, idx),
+			  "[%d] bitpos %s bitsize %d type ",
+			  idx, plongest (TYPE_FIELD_BITPOS (type, idx)),
 			  TYPE_FIELD_BITSIZE (type, idx));
       gdb_print_host_address (TYPE_FIELD_TYPE (type, idx), gdb_stdout);
       printf_filtered (" name '%s' (",
@@ -3516,7 +3516,7 @@ copy_type (const struct type *type)
    CODE, LENGTH, and NAME fields.  */
 struct type *
 arch_type (struct gdbarch *gdbarch,
-	   enum type_code code, int length, char *name)
+	   enum type_code code, LONGEST length, char *name)
 {
   struct type *type;
 
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 17bfbc5..a0921c5 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -529,7 +529,7 @@ struct main_type
 	   gdbarch_bits_big_endian=0 targets, it is the bit offset to
 	   the LSB.  */
 
-	int bitpos;
+	LONGEST bitpos;
 
 	/* Enum value.  */
 	LONGEST enumval;
@@ -699,7 +699,7 @@ struct type
      HOST_CHAR_BIT.  However, this would still fail to address
      machines based on a ternary or decimal representation.  */
   
-  unsigned length;
+  ULONGEST length;
 
   /* Core type, shared by a group of qualified types.  */
   struct main_type *main_type;
@@ -1436,11 +1436,12 @@ extern struct type *alloc_type_copy (const struct type *);
 extern struct gdbarch *get_type_arch (const struct type *);
 
 /* Helper function to construct objfile-owned types.  */
-extern struct type *init_type (enum type_code, int, int, char *,
+extern struct type *init_type (enum type_code, LONGEST, int, char *,
 			       struct objfile *);
 
 /* Helper functions to construct architecture-owned types.  */
-extern struct type *arch_type (struct gdbarch *, enum type_code, int, char *);
+extern struct type *arch_type (struct gdbarch *, enum type_code, LONGEST,
+			       char *);
 extern struct type *arch_integer_type (struct gdbarch *, int, int, char *);
 extern struct type *arch_character_type (struct gdbarch *, int, int, char *);
 extern struct type *arch_boolean_type (struct gdbarch *, int, int, char *);
diff --git a/gdb/gnu-v2-abi.c b/gdb/gnu-v2-abi.c
index e635e8f..8697c87 100644
--- a/gdb/gnu-v2-abi.c
+++ b/gdb/gnu-v2-abi.c
@@ -86,7 +86,7 @@ gnuv2_is_operator_name (const char *name)
    TYPE is the type in which F is located.  */
 static struct value *
 gnuv2_virtual_fn_field (struct value **arg1p, struct fn_field * f, int j,
-			struct type * type, int offset)
+			struct type *type, LONGEST offset)
 {
   struct value *arg1 = *arg1p;
   struct type *type1 = check_typedef (value_type (arg1));
@@ -187,7 +187,8 @@ gnuv2_virtual_fn_field (struct value **arg1p, struct fn_field * f, int j,
 
 
 static struct type *
-gnuv2_value_rtti_type (struct value *v, int *full, int *top, int *using_enc)
+gnuv2_value_rtti_type (struct value *v, int *full, LONGEST *top,
+		       int *using_enc)
 {
   struct type *known_type;
   struct type *rtti_type;
@@ -342,9 +343,9 @@ vb_match (struct type *type, int index, struct type *basetype)
    target).  The result is the offset of the baseclass value relative
    to (the address of)(ARG) + OFFSET.  */
 
-static int
+static LONGEST
 gnuv2_baseclass_offset (struct type *type, int index,
-			const bfd_byte *valaddr, int embedded_offset,
+			const bfd_byte *valaddr, LONGEST embedded_offset,
 			CORE_ADDR address, const struct value *val)
 {
   struct type *basetype = TYPE_BASECLASS (type, index);
@@ -362,8 +363,8 @@ gnuv2_baseclass_offset (struct type *type, int index,
 	  if (vb_match (type, i, basetype))
 	    {
 	      struct type *field_type;
-	      int field_offset;
-	      int field_length;
+	      LONGEST field_offset;
+	      LONGEST field_length;
 	      CORE_ADDR addr;
 
 	      field_type = check_typedef (TYPE_FIELD_TYPE (type, i));
@@ -387,7 +388,7 @@ gnuv2_baseclass_offset (struct type *type, int index,
 	  /* Don't go through baseclass_offset, as that wraps
 	     exceptions, thus, inner exceptions would be wrapped more
 	     than once.  */
-	  int boffset =
+	  LONGEST boffset =
 	    gnuv2_baseclass_offset (type, i, valaddr,
 				    embedded_offset, address, val);
 
diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index 3a83e2d..e763f29 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -105,7 +105,7 @@ build_gdb_vtable_type (struct gdbarch *arch)
 {
   struct type *t;
   struct field *field_list, *field;
-  int offset;
+  LONGEST offset;
 
   struct type *void_ptr_type
     = builtin_type (arch)->builtin_data_ptr;
@@ -181,7 +181,7 @@ vtable_ptrdiff_type (struct gdbarch *gdbarch)
 /* Return the offset from the start of the imaginary `struct
    gdb_gnu_v3_abi_vtable' object to the vtable's "address point"
    (i.e., where objects' virtual table pointers point).  */
-static int
+static LONGEST
 vtable_address_point_offset (struct gdbarch *gdbarch)
 {
   struct type *vtable_type = gdbarch_data (gdbarch, vtable_type_gdbarch_data);
@@ -272,7 +272,7 @@ gnuv3_get_vtable (struct gdbarch *gdbarch,
 
 static struct type *
 gnuv3_rtti_type (struct value *value,
-                 int *full_p, int *top_p, int *using_enc_p)
+                 int *full_p, LONGEST *top_p, int *using_enc_p)
 {
   struct gdbarch *gdbarch;
   struct type *values_type = check_typedef (value_type (value));
@@ -384,7 +384,7 @@ gnuv3_get_virtual_fn (struct gdbarch *gdbarch, struct value *container,
 static struct value *
 gnuv3_virtual_fn_field (struct value **value_p,
                         struct fn_field *f, int j,
-			struct type *vfn_base, int offset)
+			struct type *vfn_base, LONGEST offset)
 {
   struct type *values_type = check_typedef (value_type (*value_p));
   struct gdbarch *gdbarch;
@@ -414,16 +414,16 @@ gnuv3_virtual_fn_field (struct value **value_p,
 
    -1 is returned on error.  */
 
-static int
+static LONGEST
 gnuv3_baseclass_offset (struct type *type, int index,
-			const bfd_byte *valaddr, int embedded_offset,
+			const bfd_byte *valaddr, LONGEST embedded_offset,
 			CORE_ADDR address, const struct value *val)
 {
   struct gdbarch *gdbarch;
   struct type *ptr_type;
   struct value *vtable;
   struct value *vbase_array;
-  long int cur_base_offset, base_offset;
+  LONGEST cur_base_offset, base_offset;
 
   /* Determine architecture.  */
   gdbarch = get_type_arch (type);
@@ -447,7 +447,7 @@ gnuv3_baseclass_offset (struct type *type, int index,
   cur_base_offset = cur_base_offset + vtable_address_point_offset (gdbarch);
   if ((- cur_base_offset) % TYPE_LENGTH (ptr_type) != 0)
     error (_("Misaligned vbase offset."));
-  cur_base_offset = cur_base_offset / ((int) TYPE_LENGTH (ptr_type));
+  cur_base_offset = cur_base_offset / ((LONGEST) TYPE_LENGTH (ptr_type));
 
   vtable = gnuv3_get_vtable (gdbarch, type, address + embedded_offset);
   gdb_assert (vtable != NULL);
@@ -491,7 +491,7 @@ gnuv3_find_method_in (struct type *domain, CORE_ADDR voffset,
      we're out of luck.  */
   for (i = 0; i < TYPE_N_BASECLASSES (domain); i++)
     {
-      int pos;
+      LONGEST pos;
       struct type *basetype;
 
       if (BASETYPE_VIA_VIRTUAL (domain, i))
diff --git a/gdb/go-lang.h b/gdb/go-lang.h
index 67b5d93..51a1f7a 100644
--- a/gdb/go-lang.h
+++ b/gdb/go-lang.h
@@ -80,7 +80,7 @@ extern void go_print_type (struct type *type, const char *varstring,
 /* Defined in go-valprint.c.  */
 
 extern void go_val_print (struct type *type, const gdb_byte *valaddr,
-			  int embedded_offset, CORE_ADDR address,
+			  LONGEST embedded_offset, CORE_ADDR address,
 			  struct ui_file *stream, int recurse,
 			  const struct value *val,
 			  const struct value_print_options *options);
diff --git a/gdb/go-valprint.c b/gdb/go-valprint.c
index de52e9b..99563c2 100644
--- a/gdb/go-valprint.c
+++ b/gdb/go-valprint.c
@@ -86,9 +86,9 @@ print_go_string (struct type *type, const gdb_byte *valaddr,
 /* Implements the la_val_print routine for language Go.  */
 
 void
-go_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
-	      CORE_ADDR address, struct ui_file *stream, int recurse,
-	      const struct value *val,
+go_val_print (struct type *type, const gdb_byte *valaddr,
+	      LONGEST embedded_offset, CORE_ADDR address,
+	      struct ui_file *stream, int recurse, const struct value *val,
 	      const struct value_print_options *options)
 {
   CHECK_TYPEDEF (type);
diff --git a/gdb/h8300-tdep.c b/gdb/h8300-tdep.c
index 237f4a3..ee5aa2d 100644
--- a/gdb/h8300-tdep.c
+++ b/gdb/h8300-tdep.c
@@ -641,7 +641,7 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 		       int struct_return, CORE_ADDR struct_addr)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  int stack_alloc = 0, stack_offset = 0;
+  LONGEST stack_alloc = 0, stack_offset = 0;
   int wordsize = BINWORD (gdbarch);
   int reg = E_ARG0_REGNUM;
   int argument;
@@ -667,11 +667,11 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   for (argument = 0; argument < nargs; argument++)
     {
       struct type *type = value_type (args[argument]);
-      int len = TYPE_LENGTH (type);
+      LONGEST len = TYPE_LENGTH (type);
       char *contents = (char *) value_contents (args[argument]);
 
       /* Pad the argument appropriately.  */
-      int padded_len = align_up (len, wordsize);
+      LONGEST padded_len = align_up (len, wordsize);
       gdb_byte *padded = alloca (padded_len);
 
       memset (padded, 0, padded_len);
@@ -699,7 +699,7 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 	      /* Heavens to Betsy --- it's really going in registers!
 	         Note that on the h8/300s, there are gaps between the
 	         registers in the register file.  */
-	      int offset;
+	      LONGEST offset;
 
 	      for (offset = 0; offset < padded_len; offset += wordsize)
 		{
@@ -744,7 +744,7 @@ h8300_extract_return_value (struct type *type, struct regcache *regcache,
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
   ULONGEST c, addr;
 
   switch (len)
@@ -781,7 +781,7 @@ h8300h_extract_return_value (struct type *type, struct regcache *regcache,
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
   ULONGEST c;
 
   switch (len)
@@ -848,7 +848,7 @@ h8300_store_return_value (struct type *type, struct regcache *regcache,
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
   ULONGEST val;
 
   switch (len)
@@ -878,7 +878,7 @@ h8300h_store_return_value (struct type *type, struct regcache *regcache,
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
   ULONGEST val;
 
   switch (len)
diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c
index 581ffc7..e66f17f 100644
--- a/gdb/hppa-tdep.c
+++ b/gdb/hppa-tdep.c
@@ -962,7 +962,7 @@ hppa64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
     {
       struct value *arg = args[i];
       struct type *type = value_type (arg);
-      int len = TYPE_LENGTH (type);
+      LONGEST len = TYPE_LENGTH (type);
       const bfd_byte *valbuf;
       bfd_byte fptrbuf[8];
       int regnum;
@@ -1157,7 +1157,7 @@ hppa64_return_value (struct gdbarch *gdbarch, struct value *function,
 		     struct type *type, struct regcache *regcache,
 		     gdb_byte *readbuf, const gdb_byte *writebuf)
 {
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
   int regnum, offset;
 
   if (len > 16)
diff --git a/gdb/i386-darwin-tdep.c b/gdb/i386-darwin-tdep.c
index c353154..a57fe2b 100644
--- a/gdb/i386-darwin-tdep.c
+++ b/gdb/i386-darwin-tdep.c
@@ -119,7 +119,7 @@ i386_m128_p (struct type *type)
 
 /* Return the alignment for TYPE when passed as an argument.  */
 
-static int
+static LONGEST
 i386_darwin_arg_type_alignment (struct type *type)
 {
   type = check_typedef (type);
@@ -139,7 +139,7 @@ i386_darwin_arg_type_alignment (struct type *type)
       || TYPE_CODE (type) == TYPE_CODE_UNION)
     {
       int i;
-      int res = 4;
+      LONGEST res = 4;
       for (i = 0; i < TYPE_NFIELDS (type); i++)
         res = max (res,
                    i386_darwin_arg_type_alignment (TYPE_FIELD_TYPE (type, i)));
@@ -166,7 +166,7 @@ i386_darwin_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 
   for (write_pass = 0; write_pass < 2; write_pass++)
     {
-      int args_space = 0;
+      LONGEST args_space = 0;
       int num_m128 = 0;
 
       if (struct_return)
@@ -196,8 +196,8 @@ i386_darwin_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
             }
           else
             {
-              int len = TYPE_LENGTH (arg_type);
-              int align = i386_darwin_arg_type_alignment (arg_type);
+              LONGEST len = TYPE_LENGTH (arg_type);
+              LONGEST align = i386_darwin_arg_type_alignment (arg_type);
 
               args_space = align_up (args_space, align);
               if (write_pass)
diff --git a/gdb/i386-nat.c b/gdb/i386-nat.c
index 753de67..a10dca0 100644
--- a/gdb/i386-nat.c
+++ b/gdb/i386-nat.c
@@ -293,7 +293,7 @@ static int i386_remove_aligned_watchpoint (struct i386_debug_reg_state *state,
    valid value, bombs through internal_error.  */
 static int i386_handle_nonaligned_watchpoint (struct i386_debug_reg_state *state,
 					      i386_wp_op_t what,
-					      CORE_ADDR addr, int len,
+					      CORE_ADDR addr, LONGEST len,
 					      enum target_hw_bp_type type);
 
 /* Implementation.  */
@@ -505,8 +505,8 @@ i386_remove_aligned_watchpoint (struct i386_debug_reg_state *state,
 
 static int
 i386_handle_nonaligned_watchpoint (struct i386_debug_reg_state *state,
-				   i386_wp_op_t what, CORE_ADDR addr, int len,
-				   enum target_hw_bp_type type)
+				   i386_wp_op_t what, CORE_ADDR addr,
+				   LONGEST len, enum target_hw_bp_type type)
 {
   int retval = 0;
   int max_wp_len = TARGET_HAS_DR_LEN_8 ? 8 : 4;
@@ -663,7 +663,7 @@ i386_remove_watchpoint (CORE_ADDR addr, int len, int type,
    address ADDR and whose length is LEN bytes.  */
 
 static int
-i386_region_ok_for_watchpoint (CORE_ADDR addr, int len)
+i386_region_ok_for_watchpoint (CORE_ADDR addr, LONGEST len)
 {
   struct i386_debug_reg_state *state = i386_debug_reg_state ();
   int nregs;
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 84e9794..19917ad 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -2358,7 +2358,7 @@ i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   gdb_byte buf[4];
   int i;
   int write_pass;
-  int args_space = 0;
+  LONGEST args_space = 0;
 
   /* Determine the total space required for arguments and struct
      return address in a first pass (allowing for 16-byte-aligned
@@ -2366,7 +2366,7 @@ i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 
   for (write_pass = 0; write_pass < 2; write_pass++)
     {
-      int args_space_used = 0;
+      LONGEST args_space_used = 0;
 
       if (struct_return)
 	{
@@ -2383,7 +2383,7 @@ i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 
       for (i = 0; i < nargs; i++)
 	{
-	  int len = TYPE_LENGTH (value_enclosing_type (args[i]));
+	  LONGEST len = TYPE_LENGTH (value_enclosing_type (args[i]));
 
 	  if (write_pass)
 	    {
@@ -2459,7 +2459,7 @@ i386_extract_return_value (struct gdbarch *gdbarch, struct type *type,
 			   struct regcache *regcache, gdb_byte *valbuf)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
   gdb_byte buf[I386_MAX_REGISTER_SIZE];
 
   if (TYPE_CODE (type) == TYPE_CODE_FLT)
@@ -2497,8 +2497,8 @@ i386_extract_return_value (struct gdbarch *gdbarch, struct type *type,
 	}
       else
 	internal_error (__FILE__, __LINE__,
-			_("Cannot extract return value of %d bytes long."),
-			len);
+			_("Cannot extract return value of %s bytes long."),
+			plongest (len));
     }
 }
 
@@ -2510,7 +2510,7 @@ i386_store_return_value (struct gdbarch *gdbarch, struct type *type,
 			 struct regcache *regcache, const gdb_byte *valbuf)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
 
   if (TYPE_CODE (type) == TYPE_CODE_FLT)
     {
@@ -2562,7 +2562,8 @@ i386_store_return_value (struct gdbarch *gdbarch, struct type *type,
 	}
       else
 	internal_error (__FILE__, __LINE__,
-			_("Cannot store return value of %d bytes long."), len);
+			_("Cannot store return value of %s bytes long."),
+			plongest (len));
     }
 }
 
@@ -2590,7 +2591,7 @@ i386_reg_struct_return_p (struct gdbarch *gdbarch, struct type *type)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   enum type_code code = TYPE_CODE (type);
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
 
   gdb_assert (code == TYPE_CODE_STRUCT
               || code == TYPE_CODE_UNION
@@ -3042,7 +3043,7 @@ static int
 i386_convert_register_p (struct gdbarch *gdbarch,
 			 int regnum, struct type *type)
 {
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
 
   /* Values may be spread across multiple registers.  Most debugging
      formats aren't expressive enough to specify the locations, so
@@ -3075,7 +3076,7 @@ i386_register_to_value (struct frame_info *frame, int regnum,
 			int *optimizedp, int *unavailablep)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
 
   if (i386_fp_regnum_p (gdbarch, regnum))
     return i387_register_to_value (frame, regnum, type, to,
@@ -3111,7 +3112,7 @@ static void
 i386_value_to_register (struct frame_info *frame, int regnum,
 			struct type *type, const gdb_byte *from)
 {
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
 
   if (i386_fp_regnum_p (get_frame_arch (frame), regnum))
     {
diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c
index a7a802a..4af53a4 100644
--- a/gdb/ia64-tdep.c
+++ b/gdb/ia64-tdep.c
@@ -3231,7 +3231,7 @@ ia64_extract_return_value (struct type *type, struct regcache *regcache,
       char from[MAX_REGISTER_SIZE];
       int offset = 0;
       int regnum = IA64_FR8_REGNUM;
-      int n = TYPE_LENGTH (type) / TYPE_LENGTH (float_elt_type);
+      LONGEST n = TYPE_LENGTH (type) / TYPE_LENGTH (float_elt_type);
 
       while (n-- > 0)
 	{
@@ -3263,7 +3263,7 @@ ia64_extract_return_value (struct type *type, struct regcache *regcache,
       int offset = 0;
       int regnum = IA64_GR8_REGNUM;
       int reglen = TYPE_LENGTH (register_type (gdbarch, IA64_GR8_REGNUM));
-      int n = TYPE_LENGTH (type) / reglen;
+      LONGEST n = TYPE_LENGTH (type) / reglen;
       int m = TYPE_LENGTH (type) % reglen;
 
       while (n-- > 0)
@@ -3313,7 +3313,7 @@ ia64_store_return_value (struct type *type, struct regcache *regcache,
       int offset = 0;
       int regnum = IA64_GR8_REGNUM;
       int reglen = TYPE_LENGTH (register_type (gdbarch, IA64_GR8_REGNUM));
-      int n = TYPE_LENGTH (type) / reglen;
+      LONGEST n = TYPE_LENGTH (type) / reglen;
       int m = TYPE_LENGTH (type) % reglen;
 
       while (n-- > 0)
@@ -3719,8 +3719,10 @@ ia64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   int argno;
   struct value *arg;
   struct type *type;
-  int len, argoffset;
-  int nslots, rseslots, memslots, slotnum, nfuncargs;
+  LONGEST argoffset;
+  LONGEST len;
+  int rseslots, slotnum, nfuncargs;
+  LONGEST nslots, memslots;
   int floatreg;
   ULONGEST bsp;
   CORE_ADDR funcdescaddr, pc, global_pointer;
diff --git a/gdb/inf-ttrace.c b/gdb/inf-ttrace.c
index 2c620d5..2a3550d 100644
--- a/gdb/inf-ttrace.c
+++ b/gdb/inf-ttrace.c
@@ -364,7 +364,7 @@ inf_ttrace_can_use_hw_breakpoint (int type, int len, int ot)
 }
 
 static int
-inf_ttrace_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
+inf_ttrace_region_ok_for_hw_watchpoint (CORE_ADDR addr, LONGEST len)
 {
   return 1;
 }
diff --git a/gdb/infcall.c b/gdb/infcall.c
index 1b2c3d6..3a3664f 100644
--- a/gdb/infcall.c
+++ b/gdb/infcall.c
@@ -709,7 +709,7 @@ call_function_by_hand (struct value *function, int nargs, struct value **args)
 
   if (struct_return || hidden_first_param_p)
     {
-      int len = TYPE_LENGTH (values_type);
+      LONGEST len = TYPE_LENGTH (values_type);
 
       if (gdbarch_inner_than (gdbarch, 1, 2))
 	{
diff --git a/gdb/infrun.c b/gdb/infrun.c
index cf6c062..b062050 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -6671,7 +6671,7 @@ save_infcall_suspend_state (void)
   if (gdbarch_get_siginfo_type_p (gdbarch))
     {
       struct type *type = gdbarch_get_siginfo_type (gdbarch);
-      size_t len = TYPE_LENGTH (type);
+      ULONGEST len = TYPE_LENGTH (type);
       struct cleanup *back_to;
 
       siginfo_data = xmalloc (len);
@@ -6732,11 +6732,10 @@ restore_infcall_suspend_state (struct infcall_suspend_state *inf_state)
   if (inf_state->siginfo_gdbarch == gdbarch)
     {
       struct type *type = gdbarch_get_siginfo_type (gdbarch);
-      size_t len = TYPE_LENGTH (type);
 
       /* Errors ignored.  */
       target_write (&current_target, TARGET_OBJECT_SIGNAL_INFO, NULL,
-		    inf_state->siginfo_data, 0, len);
+		    inf_state->siginfo_data, 0, TYPE_LENGTH (type));
     }
 
   /* The inferior can be gone if the user types "print exit(0)"
diff --git a/gdb/iq2000-tdep.c b/gdb/iq2000-tdep.c
index 6ecc671..2c646da 100644
--- a/gdb/iq2000-tdep.c
+++ b/gdb/iq2000-tdep.c
@@ -504,7 +504,7 @@ static void
 iq2000_store_return_value (struct type *type, struct regcache *regcache,
 			   const void *valbuf)
 {
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
   int regno = E_FN_RETURN_REGNUM;
 
   while (len > 0)
@@ -550,7 +550,7 @@ iq2000_extract_return_value (struct type *type, struct regcache *regcache,
      returned in a register, and if larger than 8 bytes, it is 
      returned in a stack location which is pointed to by the same
      register.  */
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
 
   if (len <= (2 * 4))
     {
@@ -655,8 +655,9 @@ iq2000_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   const bfd_byte *val;
   bfd_byte buf[4];
   struct type *type;
-  int i, argreg, typelen, slacklen;
-  int stackspace = 0;
+  int i, argreg, slacklen;
+  LONGEST typelen;
+  LONGEST stackspace = 0;
   /* Used to copy struct arguments into the stack.  */
   CORE_ADDR struct_ptr;
 
diff --git a/gdb/jv-lang.c b/gdb/jv-lang.c
index a7cfb76..5ff69ca 100644
--- a/gdb/jv-lang.c
+++ b/gdb/jv-lang.c
@@ -439,7 +439,7 @@ java_link_class_type (struct gdbarch *gdbarch,
   for (i = TYPE_N_BASECLASSES (type); i < nfields; i++)
     {
       int accflags;
-      int boffset;
+      LONGEST boffset;
 
       if (fields == NULL)
 	{
@@ -888,7 +888,7 @@ java_printchar (int c, struct type *type, struct ui_file *stream)
 static void
 java_printstr (struct ui_file *stream, struct type *type,
 	       const gdb_byte *string,
-	       unsigned int length, const char *encoding, int force_ellipses,
+	       ULONGEST length, const char *encoding, int force_ellipses,
 	       const struct value_print_options *options)
 {
   const char *type_encoding = java_get_encoding (type);
diff --git a/gdb/jv-lang.h b/gdb/jv-lang.h
index 8ea9c3c..bf77ccf 100644
--- a/gdb/jv-lang.h
+++ b/gdb/jv-lang.h
@@ -42,8 +42,8 @@ struct builtin_java_type
 
 extern const struct builtin_java_type *builtin_java_type (struct gdbarch *);
 
-extern void java_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
-			    struct ui_file *, int,
+extern void java_val_print (struct type *, const gdb_byte *, LONGEST,
+			    CORE_ADDR, struct ui_file *, int,
 			    const struct value *,
 			    const struct value_print_options *);
 
diff --git a/gdb/jv-valprint.c b/gdb/jv-valprint.c
index d1274dd..42b85dc 100644
--- a/gdb/jv-valprint.c
+++ b/gdb/jv-valprint.c
@@ -266,7 +266,7 @@ java_value_print (struct value *val, struct ui_file *stream,
 
 static void
 java_print_value_fields (struct type *type, const gdb_byte *valaddr,
-			 int offset,
+			 LONGEST offset,
 			 CORE_ADDR address, struct ui_file *stream,
 			 int recurse,
 			 const struct value *val,
@@ -484,7 +484,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 
 void
 java_val_print (struct type *type, const gdb_byte *valaddr,
-		int embedded_offset, CORE_ADDR address,
+		LONGEST embedded_offset, CORE_ADDR address,
 		struct ui_file *stream, int recurse,
 		const struct value *val,
 		const struct value_print_options *options)
diff --git a/gdb/language.c b/gdb/language.c
index f0a8697..9ae020e 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -831,7 +831,7 @@ unk_lang_printchar (int c, struct type *type, struct ui_file *stream)
 
 static void
 unk_lang_printstr (struct ui_file *stream, struct type *type,
-		   const gdb_byte *string, unsigned int length,
+		   const gdb_byte *string, ULONGEST length,
 		   const char *encoding, int force_ellipses,
 		   const struct value_print_options *options)
 {
@@ -849,7 +849,7 @@ unk_lang_print_type (struct type *type, const char *varstring,
 
 static void
 unk_lang_val_print (struct type *type, const gdb_byte *valaddr,
-		    int embedded_offset, CORE_ADDR address,
+		    LONGEST embedded_offset, CORE_ADDR address,
 		    struct ui_file *stream, int recurse,
 		    const struct value *val,
 		    const struct value_print_options *options)
diff --git a/gdb/language.h b/gdb/language.h
index 38c4830..86c5406 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -200,7 +200,7 @@ struct language_defn
 			  struct ui_file * stream);
 
     void (*la_printstr) (struct ui_file * stream, struct type *elttype,
-			 const gdb_byte *string, unsigned int length,
+			 const gdb_byte *string, ULONGEST length,
 			 const char *encoding, int force_ellipses,
 			 const struct value_print_options *);
 
@@ -242,7 +242,7 @@ struct language_defn
 
     void (*la_val_print) (struct type *type,
 			  const gdb_byte *contents,
-			  int embedded_offset, CORE_ADDR address,
+			  LONGEST embedded_offset, CORE_ADDR address,
 			  struct ui_file *stream, int recurse,
 			  const struct value *val,
 			  const struct value_print_options *options);
diff --git a/gdb/lm32-tdep.c b/gdb/lm32-tdep.c
index 57d73b5..a1306a9 100644
--- a/gdb/lm32-tdep.c
+++ b/gdb/lm32-tdep.c
@@ -261,7 +261,7 @@ lm32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
       struct value *arg = args[i];
       struct type *arg_type = check_typedef (value_type (arg));
       gdb_byte *contents;
-      int len;
+      LONGEST len;
       ULONGEST val;
 
       /* Promote small integer types to int.  */
@@ -350,7 +350,7 @@ lm32_store_return_value (struct type *type, struct regcache *regcache,
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   ULONGEST val;
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
 
   if (len <= 4)
     {
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index 8faa6c1..f52ef56 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -104,10 +104,10 @@ m2_printchar (int c, struct type *type, struct ui_file *stream)
 
 static void
 m2_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
-	     unsigned int length, const char *encoding, int force_ellipses,
+	     ULONGEST length, const char *encoding, int force_ellipses,
 	     const struct value_print_options *options)
 {
-  unsigned int i;
+  ULONGEST i;
   unsigned int things_printed = 0;
   int in_quotes = 0;
   int need_comma = 0;
@@ -122,9 +122,9 @@ m2_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
     {
       /* Position of the character we are examining
          to see whether it is repeated.  */
-      unsigned int rep1;
+      ULONGEST rep1;
       /* Number of repetitions we have detected so far.  */
-      unsigned int reps;
+      ULONGEST reps;
 
       QUIT;
 
@@ -153,7 +153,7 @@ m2_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
 	      in_quotes = 0;
 	    }
 	  m2_printchar (string[i], type, stream);
-	  fprintf_filtered (stream, " <repeats %u times>", reps);
+	  fprintf_filtered (stream, " <repeats %s times>", pulongest (reps));
 	  i = rep1 - 1;
 	  things_printed += options->repeat_count_threshold;
 	  need_comma = 1;
diff --git a/gdb/m2-lang.h b/gdb/m2-lang.h
index fc6de34..9d65366 100644
--- a/gdb/m2-lang.h
+++ b/gdb/m2-lang.h
@@ -32,7 +32,7 @@ extern void m2_print_typedef (struct type *, struct symbol *,
 extern int m2_is_long_set (struct type *type);
 extern int m2_is_unbounded_array (struct type *type);
 
-extern void m2_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
+extern void m2_val_print (struct type *, const gdb_byte *, LONGEST, CORE_ADDR,
 			  struct ui_file *, int,
 			  const struct value *,
 			  const struct value_print_options *);
diff --git a/gdb/m2-typeprint.c b/gdb/m2-typeprint.c
index fb3d49c..09c21af 100644
--- a/gdb/m2-typeprint.c
+++ b/gdb/m2-typeprint.c
@@ -228,9 +228,12 @@ static void m2_array (struct type *type, struct ui_file *stream,
 	  m2_print_bounds (TYPE_INDEX_TYPE (type), stream, show, -1, 1);
 	}
       else
-	fprintf_filtered (stream, "%d",
-			  (TYPE_LENGTH (type)
-			   / TYPE_LENGTH (TYPE_TARGET_TYPE (type))));
+        {
+	  ULONGEST val = (TYPE_LENGTH (type)
+			  / TYPE_LENGTH (TYPE_TARGET_TYPE (type)));
+
+	  fprintf_filtered (stream, "%s", pulongest (val));
+	}
     }
   fprintf_filtered (stream, "] OF ");
   m2_print_type (TYPE_TARGET_TYPE (type), "", stream, show, level);
@@ -587,7 +590,8 @@ m2_record_fields (struct type *type, struct ui_file *stream, int show,
 void
 m2_enum (struct type *type, struct ui_file *stream, int show, int level)
 {
-  int lastval, i, len;
+  LONGEST lastval;
+  int i, len;
 
   if (show < 0)
     {
diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c
index e92679f..dae0f0d 100644
--- a/gdb/m2-valprint.c
+++ b/gdb/m2-valprint.c
@@ -36,7 +36,7 @@ static int print_unpacked_pointer (struct type *type,
 				   struct ui_file *stream);
 static void
 m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
-			 int embedded_offset, CORE_ADDR address,
+			 LONGEST embedded_offset, CORE_ADDR address,
 			 struct ui_file *stream, int recurse,
 			 const struct value *val,
 			 const struct value_print_options *options,
@@ -68,7 +68,7 @@ get_long_set_bounds (struct type *type, LONGEST *low, LONGEST *high)
 
 static void
 m2_print_long_set (struct type *type, const gdb_byte *valaddr,
-		   int embedded_offset, CORE_ADDR address,
+		   LONGEST embedded_offset, CORE_ADDR address,
 		   struct ui_file *stream)
 {
   int empty_set        = 1;
@@ -159,7 +159,7 @@ m2_print_long_set (struct type *type, const gdb_byte *valaddr,
 
 static void
 m2_print_unbounded_array (struct type *type, const gdb_byte *valaddr,
-			  int embedded_offset, CORE_ADDR address,
+			  LONGEST embedded_offset, CORE_ADDR address,
 			  struct ui_file *stream, int recurse,
 			  const struct value_print_options *options)
 {
@@ -263,22 +263,20 @@ print_variable_at_address (struct type *type,
 
 static void
 m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
-			 int embedded_offset, CORE_ADDR address,
+			 LONGEST embedded_offset, CORE_ADDR address,
 			 struct ui_file *stream, int recurse,
 			 const struct value *val,
 			 const struct value_print_options *options,
 			 int len)
 {
-  int eltlen;
   CHECK_TYPEDEF (type);
 
   if (TYPE_LENGTH (type) > 0)
     {
-      eltlen = TYPE_LENGTH (type);
       if (options->prettyprint_arrays)
 	print_spaces_filtered (2 + 2 * recurse, stream);
       /* For an array of chars, print with string syntax.  */
-      if (eltlen == 1 &&
+      if (TYPE_LENGTH (type) == 1 &&
 	  ((TYPE_CODE (type) == TYPE_CODE_INT)
 	   || ((current_language->la_language == language_m2)
 	       && (TYPE_CODE (type) == TYPE_CODE_CHAR)))
@@ -311,16 +309,16 @@ static const struct generic_val_print_decorations m2_decorations =
    function; they are identical.  */
 
 void
-m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
-	      CORE_ADDR address, struct ui_file *stream, int recurse,
+m2_val_print (struct type *type, const gdb_byte *valaddr,
+	      LONGEST embedded_offset, CORE_ADDR address,
+	      struct ui_file *stream, int recurse,
 	      const struct value *original_value,
 	      const struct value_print_options *options)
 {
   struct gdbarch *gdbarch = get_type_arch (type);
-  unsigned int i = 0;	/* Number of characters printed.  */
-  unsigned len;
+  ULONGEST i = 0;	/* Number of characters printed.  */
+  ULONGEST len;
   struct type *elttype;
-  unsigned eltlen;
   CORE_ADDR addr;
 
   CHECK_TYPEDEF (type);
@@ -330,12 +328,11 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)
 	{
 	  elttype = check_typedef (TYPE_TARGET_TYPE (type));
-	  eltlen = TYPE_LENGTH (elttype);
-	  len = TYPE_LENGTH (type) / eltlen;
+	  len = TYPE_LENGTH (type) / TYPE_LENGTH (elttype);
 	  if (options->prettyprint_arrays)
 	    print_spaces_filtered (2 + 2 * recurse, stream);
 	  /* For an array of chars, print with string syntax.  */
-	  if (eltlen == 1 &&
+	  if (TYPE_LENGTH (elttype) == 1 &&
 	      ((TYPE_CODE (elttype) == TYPE_CODE_INT)
 	       || ((current_language->la_language == language_m2)
 		   && (TYPE_CODE (elttype) == TYPE_CODE_CHAR)))
@@ -345,7 +342,7 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	         elements up to it.  */
 	      if (options->stop_print_at_null)
 		{
-		  unsigned int temp_len;
+		  ULONGEST temp_len;
 
 		  /* Look for a NULL char.  */
 		  for (temp_len = 0;
diff --git a/gdb/m32r-tdep.c b/gdb/m32r-tdep.c
index 150b9de..4d39534 100644
--- a/gdb/m32r-tdep.c
+++ b/gdb/m32r-tdep.c
@@ -696,7 +696,7 @@ m32r_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   CORE_ADDR regval;
   gdb_byte *val;
   gdb_byte valbuf[MAX_REGISTER_SIZE];
-  int len;
+  LONGEST len;
 
   /* First force sp to a 4-byte alignment.  */
   sp = sp & ~3;
@@ -790,7 +790,7 @@ m32r_extract_return_value (struct type *type, struct regcache *regcache,
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   bfd_byte *valbuf = dst;
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
   ULONGEST tmp;
 
   /* By using store_unsigned_integer we avoid having to do
diff --git a/gdb/m68hc11-tdep.c b/gdb/m68hc11-tdep.c
index 79629ef..f553139 100644
--- a/gdb/m68hc11-tdep.c
+++ b/gdb/m68hc11-tdep.c
@@ -1174,7 +1174,7 @@ m68hc11_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   int first_stack_argnum;
   struct type *type;
   char *val;
-  int len;
+  LONGEST len;
   char buf[2];
   
   first_stack_argnum = 0;
@@ -1266,7 +1266,7 @@ static void
 m68hc11_store_return_value (struct type *type, struct regcache *regcache,
                             const void *valbuf)
 {
-  int len;
+  LONGEST len;
 
   len = TYPE_LENGTH (type);
 
@@ -1291,7 +1291,7 @@ static void
 m68hc11_extract_return_value (struct type *type, struct regcache *regcache,
                               void *valbuf)
 {
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
   char buf[M68HC11_REG_SIZE];
 
   regcache_raw_read (regcache, HARD_D_REGNUM, buf);
diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c
index b507c37..5b3fd26 100644
--- a/gdb/m68k-tdep.c
+++ b/gdb/m68k-tdep.c
@@ -292,7 +292,7 @@ static void
 m68k_extract_return_value (struct type *type, struct regcache *regcache,
 			   gdb_byte *valbuf)
 {
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
   gdb_byte buf[M68K_MAX_REGISTER_SIZE];
 
   if (len <= 4)
@@ -308,14 +308,14 @@ m68k_extract_return_value (struct type *type, struct regcache *regcache,
     }
   else
     internal_error (__FILE__, __LINE__,
-		    _("Cannot extract return value of %d bytes long."), len);
+		    _("Cannot extract return value of %s bytes long."),
+		    plongest (len));
 }
 
 static void
 m68k_svr4_extract_return_value (struct type *type, struct regcache *regcache,
 				gdb_byte *valbuf)
 {
-  int len = TYPE_LENGTH (type);
   gdb_byte buf[M68K_MAX_REGISTER_SIZE];
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
@@ -326,7 +326,7 @@ m68k_svr4_extract_return_value (struct type *type, struct regcache *regcache,
       regcache_raw_read (regcache, M68K_FP0_REGNUM, buf);
       convert_typed_floating (buf, fpreg_type, valbuf, type);
     }
-  else if (TYPE_CODE (type) == TYPE_CODE_PTR && len == 4)
+  else if (TYPE_CODE (type) == TYPE_CODE_PTR && TYPE_LENGTH (type) == 4)
     regcache_raw_read (regcache, M68K_A0_REGNUM, valbuf);
   else
     m68k_extract_return_value (type, regcache, valbuf);
@@ -338,7 +338,7 @@ static void
 m68k_store_return_value (struct type *type, struct regcache *regcache,
 			 const gdb_byte *valbuf)
 {
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
 
   if (len <= 4)
     regcache_raw_write_part (regcache, M68K_D0_REGNUM, 4 - len, len, valbuf);
@@ -350,14 +350,14 @@ m68k_store_return_value (struct type *type, struct regcache *regcache,
     }
   else
     internal_error (__FILE__, __LINE__,
-		    _("Cannot store return value of %d bytes long."), len);
+		    _("Cannot store return value of %s bytes long."),
+		    plongest (len));
 }
 
 static void
 m68k_svr4_store_return_value (struct type *type, struct regcache *regcache,
 			      const gdb_byte *valbuf)
 {
-  int len = TYPE_LENGTH (type);
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
@@ -368,7 +368,7 @@ m68k_svr4_store_return_value (struct type *type, struct regcache *regcache,
       convert_typed_floating (valbuf, type, buf, fpreg_type);
       regcache_raw_write (regcache, M68K_FP0_REGNUM, buf);
     }
-  else if (TYPE_CODE (type) == TYPE_CODE_PTR && len == 4)
+  else if (TYPE_CODE (type) == TYPE_CODE_PTR && TYPE_LENGTH (type) == 4)
     {
       regcache_raw_write (regcache, M68K_A0_REGNUM, valbuf);
       regcache_raw_write (regcache, M68K_D0_REGNUM, valbuf);
@@ -386,7 +386,7 @@ m68k_reg_struct_return_p (struct gdbarch *gdbarch, struct type *type)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   enum type_code code = TYPE_CODE (type);
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
 
   gdb_assert (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION
 	      || code == TYPE_CODE_COMPLEX);
@@ -518,9 +518,9 @@ m68k_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   for (i = nargs - 1; i >= 0; i--)
     {
       struct type *value_type = value_enclosing_type (args[i]);
-      int len = TYPE_LENGTH (value_type);
-      int container_len = (len + 3) & ~3;
-      int offset;
+      LONGEST len = TYPE_LENGTH (value_type);
+      LONGEST container_len = (len + 3) & ~3;
+      LONGEST offset;
 
       /* Non-scalars bigger than 4 bytes are left aligned, others are
 	 right aligned.  */
diff --git a/gdb/m88k-tdep.c b/gdb/m88k-tdep.c
index c4c3266..c990d6b 100644
--- a/gdb/m88k-tdep.c
+++ b/gdb/m88k-tdep.c
@@ -260,13 +260,13 @@ m88k_store_arguments (struct regcache *regcache, int nargs,
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   int num_register_words = 0;
-  int num_stack_words = 0;
+  LONGEST num_stack_words = 0;
   int i;
 
   for (i = 0; i < nargs; i++)
     {
       struct type *type = value_type (args[i]);
-      int len = TYPE_LENGTH (type);
+      LONGEST len = TYPE_LENGTH (type);
 
       if (m88k_integral_or_pointer_p (type) && len < 4)
 	{
@@ -308,8 +308,8 @@ m88k_store_arguments (struct regcache *regcache, int nargs,
     {
       const bfd_byte *valbuf = value_contents (args[i]);
       struct type *type = value_type (args[i]);
-      int len = TYPE_LENGTH (type);
-      int stack_word = num_stack_words;
+      LONGEST len = TYPE_LENGTH (type);
+      LONGEST stack_word = num_stack_words;
 
       if (m88k_in_register_p (type))
 	{
@@ -387,7 +387,7 @@ m88k_return_value (struct gdbarch *gdbarch, struct value *function,
 		   struct type *type, struct regcache *regcache,
 		   gdb_byte *readbuf, const gdb_byte *writebuf)
 {
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
   gdb_byte buf[8];
 
   if (!m88k_integral_or_pointer_p (type) && !m88k_floating_p (type))
diff --git a/gdb/memrange.c b/gdb/memrange.c
index ed41b9a..a87bc85 100644
--- a/gdb/memrange.c
+++ b/gdb/memrange.c
@@ -21,8 +21,8 @@
 #include "memrange.h"
 
 int
-mem_ranges_overlap (CORE_ADDR start1, int len1,
-		    CORE_ADDR start2, int len2)
+mem_ranges_overlap (CORE_ADDR start1, LONGEST len1,
+		    CORE_ADDR start2, LONGEST len2)
 {
   ULONGEST h, l;
 
diff --git a/gdb/memrange.h b/gdb/memrange.h
index 926af22..050a56f 100644
--- a/gdb/memrange.h
+++ b/gdb/memrange.h
@@ -30,7 +30,7 @@ struct mem_range
   CORE_ADDR start;
 
   /* Length of the range.  */
-  int length;
+  LONGEST length;
 };
 
 typedef struct mem_range mem_range_s;
@@ -40,8 +40,8 @@ DEF_VEC_O(mem_range_s);
 /* Returns true if the ranges defined by [start1, start1+len1) and
    [start2, start2+len2) overlap.  */
 
-extern int mem_ranges_overlap (CORE_ADDR start1, int len1,
-			       CORE_ADDR start2, int len2);
+extern int mem_ranges_overlap (CORE_ADDR start1, LONGEST len1,
+			       CORE_ADDR start2, LONGEST len2);
 
 /* Sort ranges by start address, then coalesce contiguous or
    overlapping ranges.  */
diff --git a/gdb/mep-tdep.c b/gdb/mep-tdep.c
index 960500c..e50d8ba 100644
--- a/gdb/mep-tdep.c
+++ b/gdb/mep-tdep.c
@@ -2279,7 +2279,7 @@ push_large_arguments (CORE_ADDR sp, int argc, struct value **argv,
 
   for (i = 0; i < argc; i++)
     {
-      unsigned arg_len = TYPE_LENGTH (value_type (argv[i]));
+      ULONGEST arg_len = TYPE_LENGTH (value_type (argv[i]));
 
       if (arg_len > MEP_GPR_SIZE)
         {
@@ -2337,7 +2337,7 @@ mep_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 
   for (i = 0; i < argc; i++)
     {
-      unsigned arg_size = TYPE_LENGTH (value_type (argv[i]));
+      ULONGEST arg_size = TYPE_LENGTH (value_type (argv[i]));
       ULONGEST value;
 
       /* Arguments that fit in a GPR get expanded to fill the GPR.  */
diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
index 9658400..ada4199 100644
--- a/gdb/microblaze-tdep.c
+++ b/gdb/microblaze-tdep.c
@@ -590,7 +590,7 @@ static void
 microblaze_store_return_value (struct type *type, struct regcache *regcache,
 			       const gdb_byte *valbuf)
 {
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
   gdb_byte buf[8];
 
   memset (buf, 0, sizeof(buf));
diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c
index b9f7f1d..5566d0c 100644
--- a/gdb/mips-linux-nat.c
+++ b/gdb/mips-linux-nat.c
@@ -938,7 +938,7 @@ try_one_watch (struct pt_watch_regs *regs, CORE_ADDR addr,
    the specified region can be covered by the watch registers.  */
 
 static int
-mips_linux_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
+mips_linux_region_ok_for_hw_watchpoint (CORE_ADDR addr, LONGEST len)
 {
   struct pt_watch_regs dummy_regs;
   int i;
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index a001424..4eb91b6 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -396,7 +396,7 @@ static void
 mips_xfer_register (struct gdbarch *gdbarch, struct regcache *regcache,
 		    int reg_num, int length,
 		    enum bfd_endian endian, gdb_byte *in,
-		    const gdb_byte *out, int buf_offset)
+		    const gdb_byte *out, LONGEST buf_offset)
 {
   int reg_offset = 0;
 
@@ -419,8 +419,8 @@ mips_xfer_register (struct gdbarch *gdbarch, struct regcache *regcache,
     }
   if (mips_debug)
     fprintf_unfiltered (gdb_stderr,
-			"xfer $%d, reg offset %d, buf offset %d, length %d, ",
-			reg_num, reg_offset, buf_offset, length);
+			"xfer $%d, reg offset %d, buf offset %s, length %d, ",
+			reg_num, reg_offset, plongest (buf_offset), length);
   if (mips_debug && out != NULL)
     {
       int i;
@@ -4295,13 +4295,13 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
       gdb_byte valbuf[MAX_REGISTER_SIZE];
       struct value *arg = args[argnum];
       struct type *arg_type = check_typedef (value_type (arg));
-      int len = TYPE_LENGTH (arg_type);
+      LONGEST len = TYPE_LENGTH (arg_type);
       enum type_code typecode = TYPE_CODE (arg_type);
 
       if (mips_debug)
 	fprintf_unfiltered (gdb_stdlog,
-			    "mips_eabi_push_dummy_call: %d len=%d type=%d",
-			    argnum + 1, len, (int) typecode);
+			    "mips_eabi_push_dummy_call: %d len=%s type=%d",
+			    argnum + 1, plongest (len), (int) typecode);
 
       /* Function pointer arguments to mips16 code need to be made into
          mips16 pointers.  */
@@ -4586,7 +4586,7 @@ mips_eabi_return_value (struct gdbarch *gdbarch, struct value *function,
 
 static int
 mips_n32n64_fp_arg_chunk_p (struct gdbarch *gdbarch, struct type *arg_type,
-			    int offset)
+			    LONGEST offset)
 {
   int i;
 
@@ -4601,7 +4601,7 @@ mips_n32n64_fp_arg_chunk_p (struct gdbarch *gdbarch, struct type *arg_type,
 
   for (i = 0; i < TYPE_NFIELDS (arg_type); i++)
     {
-      int pos;
+      LONGEST pos;
       struct type *field_type;
 
       /* We're only looking at normal fields.  */
@@ -4643,7 +4643,7 @@ mips_n32n64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   int argreg;
   int float_argreg;
   int argnum;
-  int len = 0;
+  LONGEST len = 0;
   int stack_offset = 0;
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR func_addr = find_function_addr (function, NULL);
@@ -4994,11 +4994,11 @@ mips_n32n64_return_value (struct gdbarch *gdbarch, struct value *function,
 				: MIPS_V0_REGNUM);
 	   field < TYPE_NFIELDS (type); field++, regnum += 2)
 	{
-	  int offset = (FIELD_BITPOS (TYPE_FIELDS (type)[field])
-			/ TARGET_CHAR_BIT);
+	  LONGEST offset = (FIELD_BITPOS (TYPE_FIELDS (type)[field])
+			    / TARGET_CHAR_BIT);
 	  if (mips_debug)
-	    fprintf_unfiltered (gdb_stderr, "Return float struct+%d\n",
-				offset);
+	    fprintf_unfiltered (gdb_stderr, "Return float struct+%s\n",
+				plongest (offset));
 	  if (TYPE_LENGTH (TYPE_FIELD_TYPE (type, field)) == 16)
 	    {
 	      /* A 16-byte long double field goes in two consecutive
@@ -5030,7 +5030,7 @@ mips_n32n64_return_value (struct gdbarch *gdbarch, struct value *function,
       /* A composite type.  Extract the left justified value,
          regardless of the byte order.  I.e. DO NOT USE
          mips_xfer_lower.  */
-      int offset;
+      LONGEST offset;
       int regnum;
       for (offset = 0, regnum = MIPS_V0_REGNUM;
 	   offset < TYPE_LENGTH (type);
@@ -5099,7 +5099,7 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   int argreg;
   int float_argreg;
   int argnum;
-  int len = 0;
+  LONGEST len = 0;
   int stack_offset = 0;
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR func_addr = find_function_addr (function, NULL);
@@ -5125,13 +5125,12 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   for (argnum = 0; argnum < nargs; argnum++)
     {
       struct type *arg_type = check_typedef (value_type (args[argnum]));
-      int arglen = TYPE_LENGTH (arg_type);
 
       /* Align to double-word if necessary.  */
       if (mips_type_needs_double_align (arg_type))
 	len = align_up (len, MIPS32_REGSIZE * 2);
       /* Allocate space on the stack.  */
-      len += align_up (arglen, MIPS32_REGSIZE);
+      len += align_up (TYPE_LENGTH (arg_type), MIPS32_REGSIZE);
     }
   sp -= align_up (len, 16);
 
@@ -5164,13 +5163,13 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
       const gdb_byte *val;
       struct value *arg = args[argnum];
       struct type *arg_type = check_typedef (value_type (arg));
-      int len = TYPE_LENGTH (arg_type);
+      LONGEST len = TYPE_LENGTH (arg_type);
       enum type_code typecode = TYPE_CODE (arg_type);
 
       if (mips_debug)
 	fprintf_unfiltered (gdb_stdlog,
-			    "mips_o32_push_dummy_call: %d len=%d type=%d",
-			    argnum + 1, len, (int) typecode);
+			    "mips_o32_push_dummy_call: %d len=%s type=%d",
+			    argnum + 1, plongest (len), (int) typecode);
 
       val = value_contents (arg);
 
@@ -5628,8 +5627,8 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   int argreg;
   int float_argreg;
   int argnum;
-  int len = 0;
-  int stack_offset = 0;
+  LONGEST len = 0;
+  LONGEST stack_offset = 0;
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR func_addr = find_function_addr (function, NULL);
 
@@ -5654,10 +5653,9 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   for (argnum = 0; argnum < nargs; argnum++)
     {
       struct type *arg_type = check_typedef (value_type (args[argnum]));
-      int arglen = TYPE_LENGTH (arg_type);
 
       /* Allocate space on the stack.  */
-      len += align_up (arglen, MIPS64_REGSIZE);
+      len += align_up (TYPE_LENGTH (arg_type), MIPS64_REGSIZE);
     }
   sp -= align_up (len, 16);
 
@@ -5691,13 +5689,13 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
       gdb_byte valbuf[MAX_REGISTER_SIZE];
       struct value *arg = args[argnum];
       struct type *arg_type = check_typedef (value_type (arg));
-      int len = TYPE_LENGTH (arg_type);
+      LONGEST len = TYPE_LENGTH (arg_type);
       enum type_code typecode = TYPE_CODE (arg_type);
 
       if (mips_debug)
 	fprintf_unfiltered (gdb_stdlog,
-			    "mips_o64_push_dummy_call: %d len=%d type=%d",
-			    argnum + 1, len, (int) typecode);
+			    "mips_o64_push_dummy_call: %d len=%s type=%d",
+			    argnum + 1, plongest (len), (int) typecode);
 
       val = value_contents (arg);
 
diff --git a/gdb/mn10300-tdep.c b/gdb/mn10300-tdep.c
index e292613..51a7de8 100644
--- a/gdb/mn10300-tdep.c
+++ b/gdb/mn10300-tdep.c
@@ -83,10 +83,11 @@ struct mn10300_prologue
 
 /* Compute the alignment required by a type.  */
 
-static int
+static LONGEST
 mn10300_type_align (struct type *type)
 {
-  int i, align = 1;
+  int i;
+  LONGEST align = 1;
 
   switch (TYPE_CODE (type))
     {
@@ -108,7 +109,7 @@ mn10300_type_align (struct type *type)
     case TYPE_CODE_UNION:
       for (i = 0; i < TYPE_NFIELDS (type); i++)
 	{
-	  int falign = mn10300_type_align (TYPE_FIELD_TYPE (type, i));
+	  LONGEST falign = mn10300_type_align (TYPE_FIELD_TYPE (type, i));
 	  while (align < falign)
 	    align <<= 1;
 	}
@@ -170,7 +171,7 @@ static void
 mn10300_store_return_value (struct gdbarch *gdbarch, struct type *type,
 			    struct regcache *regcache, const void *valbuf)
 {
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
   int reg, regsz;
   
   if (TYPE_CODE (type) == TYPE_CODE_PTR)
@@ -191,7 +192,8 @@ mn10300_store_return_value (struct gdbarch *gdbarch, struct type *type,
     }
   else
     internal_error (__FILE__, __LINE__,
-		    _("Cannot store return value %d bytes long."), len);
+		    _("Cannot store return value %s bytes long."),
+		    plongest (len));
 }
 
 static void
@@ -199,7 +201,7 @@ mn10300_extract_return_value (struct gdbarch *gdbarch, struct type *type,
 			      struct regcache *regcache, void *valbuf)
 {
   char buf[MAX_REGISTER_SIZE];
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
   int reg, regsz;
 
   if (TYPE_CODE (type) == TYPE_CODE_PTR)
@@ -223,7 +225,8 @@ mn10300_extract_return_value (struct gdbarch *gdbarch, struct type *type,
     }
   else
     internal_error (__FILE__, __LINE__,
-		    _("Cannot extract return value %d bytes long."), len);
+		    _("Cannot extract return value %s bytes long."),
+		    plongest (len));
 }
 
 /* Determine, for architecture GDBARCH, how a return value of TYPE
@@ -1228,7 +1231,7 @@ mn10300_push_dummy_call (struct gdbarch *gdbarch,
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   const int push_size = register_size (gdbarch, E_PC_REGNUM);
   int regs_used;
-  int len, arg_len; 
+  LONGEST len, arg_len;
   int stack_offset = 0;
   int argnum;
   char *val, valbuf[MAX_REGISTER_SIZE];
diff --git a/gdb/moxie-tdep.c b/gdb/moxie-tdep.c
index 3e08d60..cb2c59b 100644
--- a/gdb/moxie-tdep.c
+++ b/gdb/moxie-tdep.c
@@ -124,7 +124,7 @@ moxie_store_return_value (struct type *type, struct regcache *regcache,
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR regval;
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
 
   /* Things always get returned in RET1_REGNUM, RET2_REGNUM.  */
   regval = extract_unsigned_integer (valbuf, len > 4 ? 4 : len, byte_order);
@@ -321,7 +321,7 @@ moxie_extract_return_value (struct type *type, struct regcache *regcache,
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   bfd_byte *valbuf = dst;
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
   ULONGEST tmp;
 
   /* By using store_unsigned_integer we avoid having to do
diff --git a/gdb/mt-tdep.c b/gdb/mt-tdep.c
index ee4b6eb..e3622aa 100644
--- a/gdb/mt-tdep.c
+++ b/gdb/mt-tdep.c
@@ -783,9 +783,9 @@ mt_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   gdb_byte buf[MT_MAX_STRUCT_SIZE];
   int argreg = MT_1ST_ARGREG;
   int split_param_len = 0;
-  int stack_dest = sp;
+  LONGEST stack_dest = sp;
   int slacklen;
-  int typelen;
+  LONGEST typelen;
   int i, j;
 
   /* First handle however many args we can fit into MT_1ST_ARGREG thru
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 1a07c33..6f2876c 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -347,11 +347,11 @@ objc_printchar (int c, struct type *type, struct ui_file *stream)
 
 static void
 objc_printstr (struct ui_file *stream, struct type *type,
-	       const gdb_byte *string, unsigned int length,
+	       const gdb_byte *string, ULONGEST length,
 	       const char *encoding, int force_ellipses,
 	       const struct value_print_options *options)
 {
-  unsigned int i;
+  ULONGEST i;
   unsigned int things_printed = 0;
   int in_quotes = 0;
   int need_comma = 0;
@@ -372,9 +372,9 @@ objc_printstr (struct ui_file *stream, struct type *type,
     {
       /* Position of the character we are examining to see whether it
 	 is repeated.  */
-      unsigned int rep1;
+      ULONGEST rep1;
       /* Number of repetitions we have detected so far.  */
-      unsigned int reps;
+      ULONGEST reps;
 
       QUIT;
 
@@ -403,7 +403,7 @@ objc_printstr (struct ui_file *stream, struct type *type,
 	      in_quotes = 0;
 	    }
 	  objc_printchar (string[i], type, stream);
-	  fprintf_filtered (stream, " <repeats %u times>", reps);
+	  fprintf_filtered (stream, " <repeats %s times>", pulongest (reps));
 	  i = rep1 - 1;
 	  things_printed += options->repeat_count_threshold;
 	  need_comma = 1;
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index 54075a4..d41f13b 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -80,11 +80,11 @@ builtin_opencl_type (struct gdbarch *gdbarch)
 
 static struct type *
 lookup_opencl_vector_type (struct gdbarch *gdbarch, enum type_code code,
-			   unsigned int el_length, unsigned int flag_unsigned,
+			   ULONGEST el_length, unsigned int flag_unsigned,
 			   int n)
 {
   int i;
-  unsigned int length;
+  ULONGEST length;
   struct type *type = NULL;
   struct type **types = builtin_opencl_type (gdbarch);
 
@@ -174,9 +174,9 @@ lval_func_read (struct value *v)
   struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
   struct type *type = check_typedef (value_type (v));
   struct type *eltype = TYPE_TARGET_TYPE (check_typedef (value_type (c->val)));
-  int offset = value_offset (v);
-  int elsize = TYPE_LENGTH (eltype);
-  int n, i, j = 0;
+  LONGEST offset = value_offset (v);
+  LONGEST elsize = TYPE_LENGTH (eltype);
+  LONGEST n, i, j = 0;
   LONGEST lowb = 0;
   LONGEST highb = 0;
 
@@ -203,9 +203,9 @@ lval_func_write (struct value *v, struct value *fromval)
   struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
   struct type *type = check_typedef (value_type (v));
   struct type *eltype = TYPE_TARGET_TYPE (check_typedef (value_type (c->val)));
-  int offset = value_offset (v);
-  int elsize = TYPE_LENGTH (eltype);
-  int n, i, j = 0;
+  LONGEST offset = value_offset (v);
+  LONGEST elsize = TYPE_LENGTH (eltype);
+  LONGEST n, i, j = 0;
   LONGEST lowb = 0;
   LONGEST highb = 0;
 
@@ -243,17 +243,18 @@ lval_func_write (struct value *v, struct value *fromval)
 /* Return nonzero if all bits in V within OFFSET and LENGTH are valid.  */
 
 static int
-lval_func_check_validity (const struct value *v, int offset, int length)
+lval_func_check_validity (const struct value *v, LONGEST offset,
+			  LONGEST length)
 {
   struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
   /* Size of the target type in bits.  */
-  int elsize =
-      TYPE_LENGTH (TYPE_TARGET_TYPE (check_typedef (value_type (c->val)))) * 8;
-  int startrest = offset % elsize;
-  int start = offset / elsize;
-  int endrest = (offset + length) % elsize;
-  int end = (offset + length) / elsize;
-  int i;
+  LONGEST elsize =
+	   TYPE_LENGTH (TYPE_TARGET_TYPE (check_typedef (value_type (c->val)))) * 8;
+  LONGEST startrest = offset % elsize;
+  LONGEST start = offset / elsize;
+  LONGEST endrest = (offset + length) % elsize;
+  LONGEST end = (offset + length) / elsize;
+  LONGEST i;
 
   if (endrest)
     end++;
@@ -263,8 +264,8 @@ lval_func_check_validity (const struct value *v, int offset, int length)
 
   for (i = start; i < end; i++)
     {
-      int comp_offset = (i == start) ? startrest : 0;
-      int comp_length = (i == end) ? endrest : elsize;
+      LONGEST comp_offset = (i == start) ? startrest : 0;
+      LONGEST comp_length = (i == end) ? endrest : elsize;
 
       if (!value_bits_valid (c->val, c->indices[i] * elsize + comp_offset,
 			     comp_length))
@@ -281,8 +282,8 @@ lval_func_check_any_valid (const struct value *v)
 {
   struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
   /* Size of the target type in bits.  */
-  int elsize =
-      TYPE_LENGTH (TYPE_TARGET_TYPE (check_typedef (value_type (c->val)))) * 8;
+  LONGEST elsize =
+	   TYPE_LENGTH (TYPE_TARGET_TYPE (check_typedef (value_type (c->val)))) * 8;
   int i;
 
   for (i = 0; i < c->n; i++)
@@ -297,17 +298,17 @@ lval_func_check_any_valid (const struct value *v)
 
 static int
 lval_func_check_synthetic_pointer (const struct value *v,
-				   int offset, int length)
+				   LONGEST offset, LONGEST length)
 {
   struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
   /* Size of the target type in bits.  */
-  int elsize =
-      TYPE_LENGTH (TYPE_TARGET_TYPE (check_typedef (value_type (c->val)))) * 8;
-  int startrest = offset % elsize;
-  int start = offset / elsize;
-  int endrest = (offset + length) % elsize;
-  int end = (offset + length) / elsize;
-  int i;
+  LONGEST elsize =
+	   TYPE_LENGTH (TYPE_TARGET_TYPE (check_typedef (value_type (c->val)))) * 8;
+  LONGEST startrest = offset % elsize;
+  LONGEST start = offset / elsize;
+  LONGEST endrest = (offset + length) % elsize;
+  LONGEST end = (offset + length) / elsize;
+  LONGEST i;
 
   if (endrest)
     end++;
@@ -317,8 +318,8 @@ lval_func_check_synthetic_pointer (const struct value *v,
 
   for (i = start; i < end; i++)
     {
-      int comp_offset = (i == start) ? startrest : 0;
-      int comp_length = (i == end) ? endrest : elsize;
+      LONGEST comp_offset = (i == start) ? startrest : 0;
+      LONGEST comp_length = (i == end) ? endrest : elsize;
 
       if (!value_bits_synthetic_pointer (c->val,
 					 c->indices[i] * elsize + comp_offset,
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index c59ba0b..bbdfbf9 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -96,8 +96,8 @@ pascal_main_name (void)
    are not multiple of TARGET_CHAR_BIT then the results are wrong
    but this does not happen for Free Pascal nor for GPC.  */
 int
-is_pascal_string_type (struct type *type,int *length_pos,
-                       int *length_size, int *string_pos,
+is_pascal_string_type (struct type *type, LONGEST *length_pos,
+		       LONGEST *length_size, LONGEST *string_pos,
 		       struct type **char_type,
 		       const char **arrayname)
 {
@@ -217,12 +217,12 @@ pascal_printchar (int c, struct type *type, struct ui_file *stream)
 
 void
 pascal_printstr (struct ui_file *stream, struct type *type,
-		 const gdb_byte *string, unsigned int length,
+		 const gdb_byte *string, ULONGEST length,
 		 const char *encoding, int force_ellipses,
 		 const struct value_print_options *options)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
-  unsigned int i;
+  ULONGEST i;
   unsigned int things_printed = 0;
   int in_quotes = 0;
   int need_comma = 0;
@@ -250,9 +250,9 @@ pascal_printstr (struct ui_file *stream, struct type *type,
     {
       /* Position of the character we are examining
          to see whether it is repeated.  */
-      unsigned int rep1;
+      ULONGEST rep1;
       /* Number of repetitions we have detected so far.  */
-      unsigned int reps;
+      ULONGEST reps;
       unsigned long int current_char;
 
       QUIT;
@@ -287,7 +287,7 @@ pascal_printstr (struct ui_file *stream, struct type *type,
 	      in_quotes = 0;
 	    }
 	  pascal_printchar (current_char, type, stream);
-	  fprintf_filtered (stream, " <repeats %u times>", reps);
+	  fprintf_filtered (stream, " <repeats %s times>", pulongest (reps));
 	  i = rep1 - 1;
 	  things_printed += options->repeat_count_threshold;
 	  need_comma = 1;
diff --git a/gdb/p-lang.h b/gdb/p-lang.h
index b1e218c..b160f53 100644
--- a/gdb/p-lang.h
+++ b/gdb/p-lang.h
@@ -35,7 +35,7 @@ extern void pascal_print_type (struct type *, const char *, struct ui_file *,
 extern void pascal_print_typedef (struct type *, struct symbol *,
 				  struct ui_file *);
 
-extern void pascal_val_print (struct type *, const gdb_byte *, int,
+extern void pascal_val_print (struct type *, const gdb_byte *, LONGEST,
 			      CORE_ADDR, struct ui_file *, int,
 			      const struct value *,
 			      const struct value_print_options *);
@@ -49,13 +49,13 @@ extern void pascal_type_print_method_args (const char *, const char *,
 /* These are in p-lang.c: */
 
 extern int
-  is_pascal_string_type (struct type *, int *, int *, int *,
+  is_pascal_string_type (struct type *, LONGEST *, LONGEST *, LONGEST *,
 			 struct type **, const char **);
 
 extern void pascal_printchar (int, struct type *, struct ui_file *);
 
 extern void pascal_printstr (struct ui_file *, struct type *, const gdb_byte *,
-			     unsigned int, const char *, int,
+			     ULONGEST, const char *, int,
 			     const struct value_print_options *);
 
 extern struct type **const (pascal_builtin_types[]);
@@ -69,7 +69,7 @@ extern void
   pascal_type_print_varspec_prefix (struct type *, struct ui_file *, int, int);
 
 extern void pascal_object_print_value_fields (struct type *, const gdb_byte *,
-					      int,
+					      LONGEST,
 					      CORE_ADDR, struct ui_file *,
 					      int,
 					      const struct value *,
diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c
index a00f5b3..828b0ce 100644
--- a/gdb/p-typeprint.c
+++ b/gdb/p-typeprint.c
@@ -442,7 +442,7 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show,
 {
   int i;
   int len;
-  int lastval;
+  LONGEST lastval;
   enum
     {
       s_none, s_public, s_private, s_protected
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index 9f44617..2f9f60d 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -58,7 +58,7 @@ static const struct generic_val_print_decorations p_decorations =
 
 void
 pascal_val_print (struct type *type, const gdb_byte *valaddr,
-		  int embedded_offset, CORE_ADDR address,
+		  LONGEST embedded_offset, CORE_ADDR address,
 		  struct ui_file *stream, int recurse,
 		  const struct value *original_value,
 		  const struct value_print_options *options)
@@ -69,8 +69,9 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
   unsigned len;
   LONGEST low_bound, high_bound;
   struct type *elttype;
-  unsigned eltlen;
-  int length_pos, length_size, string_pos;
+  ULONGEST eltlen;
+  LONGEST length_pos, string_pos;
+  LONGEST length_size;
   struct type *char_type;
   CORE_ADDR addr;
   int want_space = 0;
@@ -477,7 +478,7 @@ static void pascal_object_print_static_field (struct value *,
 					      const struct value_print_options *);
 
 static void pascal_object_print_value (struct type *, const gdb_byte *,
-				       int,
+				       LONGEST,
 				       CORE_ADDR, struct ui_file *, int,
 				       const struct value *,
 				       const struct value_print_options *,
@@ -536,7 +537,7 @@ pascal_object_is_vtbl_member (struct type *type)
 
 void
 pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
-				  int offset,
+				  LONGEST offset,
 				  CORE_ADDR address, struct ui_file *stream,
 				  int recurse,
 				  const struct value *val,
@@ -731,7 +732,7 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 
 static void
 pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
-			   int offset,
+			   LONGEST offset,
 			   CORE_ADDR address, struct ui_file *stream,
 			   int recurse,
 			   const struct value *val,
@@ -754,11 +755,11 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
 
   for (i = 0; i < n_baseclasses; i++)
     {
-      int boffset = 0;
+      LONGEST boffset = 0;
       struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
       const char *basename = type_name_no_tag (baseclass);
       const gdb_byte *base_valaddr = NULL;
-      int thisoffset;
+      LONGEST thisoffset;
       volatile struct gdb_exception ex;
       int skip = 0;
 
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index 14f4ecb..67e1cac 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -1493,7 +1493,7 @@ ppc_linux_can_use_hw_breakpoint (int type, int cnt, int ot)
 }
 
 static int
-ppc_linux_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
+ppc_linux_region_ok_for_hw_watchpoint (CORE_ADDR addr, LONGEST len)
 {
   /* Handle sub-8-byte quantities.  */
   if (len <= 0)
diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c
index a221b70..3547d3f 100644
--- a/gdb/ppc-sysv-tdep.c
+++ b/gdb/ppc-sysv-tdep.c
@@ -69,7 +69,7 @@ ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int opencl_abi = ppc_sysv_use_opencl_abi (value_type (function));
   ULONGEST saved_sp;
-  int argspace = 0;		/* 0 is an initial wrong guess.  */
+  LONGEST argspace = 0;		/* 0 is an initial wrong guess.  */
   int write_pass;
 
   gdb_assert (tdep->wordsize == 4);
@@ -100,9 +100,9 @@ ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
       /* Next available vector register for vector arguments.  */
       int vreg = 2;
       /* Arguments start above the "LR save word" and "Back chain".  */
-      int argoffset = 2 * tdep->wordsize;
+      LONGEST argoffset = 2 * tdep->wordsize;
       /* Structures start after the arguments.  */
-      int structoffset = argoffset + argspace;
+      LONGEST structoffset = argoffset + argspace;
 
       /* If the function is returning a `struct', then the first word
          (which will be passed in r3) is used for struct return
@@ -121,7 +121,7 @@ ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 	{
 	  struct value *arg = args[argno];
 	  struct type *type = check_typedef (value_type (arg));
-	  int len = TYPE_LENGTH (type);
+	  LONGEST len = TYPE_LENGTH (type);
 	  const bfd_byte *val = value_contents (arg);
 
 	  if (TYPE_CODE (type) == TYPE_CODE_FLT && len <= 8
@@ -353,7 +353,7 @@ ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 	      /* OpenCL vectors shorter than 16 bytes are passed as if
 		 a series of independent scalars.  */
 	      struct type *eltype = check_typedef (TYPE_TARGET_TYPE (type));
-	      int i, nelt = TYPE_LENGTH (type) / TYPE_LENGTH (eltype);
+	      LONGEST i, nelt = TYPE_LENGTH (type) / TYPE_LENGTH (eltype);
 
 	      for (i = 0; i < nelt; i++)
 		{
@@ -841,11 +841,11 @@ do_ppc_sysv_return_value (struct gdbarch *gdbarch, struct type *func_type,
       && opencl_abi)
     {
       struct type *eltype = check_typedef (TYPE_TARGET_TYPE (type));
-      int i, nelt = TYPE_LENGTH (type) / TYPE_LENGTH (eltype);
+      LONGEST i, nelt = TYPE_LENGTH (type) / TYPE_LENGTH (eltype);
 
       for (i = 0; i < nelt; i++)
 	{
-	  int offset = i * TYPE_LENGTH (eltype);
+	  LONGEST offset = i * TYPE_LENGTH (eltype);
 
 	  if (TYPE_CODE (eltype) == TYPE_CODE_FLT)
 	    {
@@ -1557,14 +1557,14 @@ ppc64_sysv_abi_push_dummy_call (struct gdbarch *gdbarch,
 	    }
 	  else
 	    {
-	      int byte;
+	      LONGEST byte;
 	      for (byte = 0; byte < TYPE_LENGTH (type);
 		   byte += tdep->wordsize)
 		{
 		  if (write_pass && greg <= 10)
 		    {
 		      gdb_byte regval[MAX_REGISTER_SIZE];
-		      int len = TYPE_LENGTH (type) - byte;
+		      LONGEST len = TYPE_LENGTH (type) - byte;
 		      if (len > tdep->wordsize)
 			len = tdep->wordsize;
 		      memset (regval, 0, sizeof regval);
@@ -1592,7 +1592,7 @@ ppc64_sysv_abi_push_dummy_call (struct gdbarch *gdbarch,
 		     register.  Work around this by always writing the
 		     value to memory.  Fortunately, doing this
 		     simplifies the code.  */
-		  int len = TYPE_LENGTH (type);
+		  LONGEST len = TYPE_LENGTH (type);
 		  if (len < tdep->wordsize)
 		    write_memory (gparam + tdep->wordsize - len, val, len);
 		  else
@@ -1842,12 +1842,12 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function,
       && TYPE_LENGTH (valtype) >= 16
       && opencl_abi)
     {
-      int n_regs = TYPE_LENGTH (valtype) / 16;
-      int i;
+      LONGEST n_regs = TYPE_LENGTH (valtype) / 16;
+      LONGEST i;
 
       for (i = 0; i < n_regs; i++)
 	{
-	  int offset = i * 16;
+	  LONGEST offset = i * 16;
 	  int regnum = tdep->ppc_vr0_regnum + 2 + i;
 
 	  if (writebuf != NULL)
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index d5b5b63..6efeef9 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -290,7 +290,7 @@ print_formatted (struct value *val, int size,
 		 struct ui_file *stream)
 {
   struct type *type = check_typedef (value_type (val));
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
 
   if (VALUE_LVAL (val) == lval_memory)
     next_address = value_address (val) + len;
@@ -346,7 +346,7 @@ float_type_from_length (struct type *type)
 {
   struct gdbarch *gdbarch = get_type_arch (type);
   const struct builtin_type *builtin = builtin_type (gdbarch);
-  unsigned int len = TYPE_LENGTH (type);
+  ULONGEST len = TYPE_LENGTH (type);
 
   if (len == TYPE_LENGTH (builtin->builtin_float))
     type = builtin->builtin_float;
@@ -369,7 +369,7 @@ print_scalar_formatted (const void *valaddr, struct type *type,
 {
   struct gdbarch *gdbarch = get_type_arch (type);
   LONGEST val_long = 0;
-  unsigned int len = TYPE_LENGTH (type);
+  ULONGEST len = TYPE_LENGTH (type);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 
   /* String printing should go through val_print_scalar_formatted.  */
diff --git a/gdb/procfs.c b/gdb/procfs.c
index 4409e5b..5e5d197 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -4966,7 +4966,7 @@ procfs_remove_watchpoint (CORE_ADDR addr, int len, int type,
 }
 
 static int
-procfs_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
+procfs_region_ok_for_hw_watchpoint (CORE_ADDR addr, LONGEST len)
 {
   /* The man page for proc(4) on Solaris 2.6 and up says that the
      system can support "thousands" of hardware watchpoints, but gives
diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c
index 86d4f2c..1ceb23b 100644
--- a/gdb/python/py-prettyprint.c
+++ b/gdb/python/py-prettyprint.c
@@ -676,7 +676,7 @@ print_children (PyObject *printer, const char *hint,
 
 int
 apply_val_pretty_printer (struct type *type, const gdb_byte *valaddr,
-			  int embedded_offset, CORE_ADDR address,
+			  LONGEST embedded_offset, CORE_ADDR address,
 			  struct ui_file *stream, int recurse,
 			  const struct value *val,
 			  const struct value_print_options *options,
@@ -824,7 +824,7 @@ gdbpy_default_visualizer (PyObject *self, PyObject *args)
 
 int
 apply_val_pretty_printer (struct type *type, const gdb_byte *valaddr,
-			  int embedded_offset, CORE_ADDR address,
+			  LONGEST embedded_offset, CORE_ADDR address,
 			  struct ui_file *stream, int recurse,
 			  const struct value *val,
 			  const struct value_print_options *options,
diff --git a/gdb/python/python.h b/gdb/python/python.h
index dd7066f..2a57409 100644
--- a/gdb/python/python.h
+++ b/gdb/python/python.h
@@ -31,7 +31,7 @@ void eval_python_from_control_command (struct command_line *);
 void source_python_script (FILE *file, const char *filename);
 
 int apply_val_pretty_printer (struct type *type, const gdb_byte *valaddr,
-			      int embedded_offset, CORE_ADDR address,
+			      LONGEST embedded_offset, CORE_ADDR address,
 			      struct ui_file *stream, int recurse,
 			      const struct value *val,
 			      const struct value_print_options *options,
diff --git a/gdb/regcache.c b/gdb/regcache.c
index c716280..800b660 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -902,7 +902,7 @@ typedef void (regcache_write_ftype) (struct regcache *regcache, int regnum,
 
 static enum register_status
 regcache_xfer_part (struct regcache *regcache, int regnum,
-		    int offset, int len, void *in, const void *out,
+		    LONGEST offset, LONGEST len, void *in, const void *out,
 		    enum register_status (*read) (struct regcache *regcache,
 						  int regnum,
 						  gdb_byte *buf),
@@ -946,7 +946,7 @@ regcache_xfer_part (struct regcache *regcache, int regnum,
 
 enum register_status
 regcache_raw_read_part (struct regcache *regcache, int regnum,
-			int offset, int len, gdb_byte *buf)
+			int offset, LONGEST len, gdb_byte *buf)
 {
   struct regcache_descr *descr = regcache->descr;
 
@@ -957,7 +957,7 @@ regcache_raw_read_part (struct regcache *regcache, int regnum,
 
 void
 regcache_raw_write_part (struct regcache *regcache, int regnum,
-			 int offset, int len, const gdb_byte *buf)
+			 int offset, LONGEST len, const gdb_byte *buf)
 {
   struct regcache_descr *descr = regcache->descr;
 
@@ -968,7 +968,7 @@ regcache_raw_write_part (struct regcache *regcache, int regnum,
 
 enum register_status
 regcache_cooked_read_part (struct regcache *regcache, int regnum,
-			   int offset, int len, gdb_byte *buf)
+			   LONGEST offset, LONGEST len, gdb_byte *buf)
 {
   struct regcache_descr *descr = regcache->descr;
 
@@ -979,7 +979,7 @@ regcache_cooked_read_part (struct regcache *regcache, int regnum,
 
 void
 regcache_cooked_write_part (struct regcache *regcache, int regnum,
-			    int offset, int len, const gdb_byte *buf)
+			    LONGEST offset, LONGEST len, const gdb_byte *buf)
 {
   struct regcache_descr *descr = regcache->descr;
 
diff --git a/gdb/regcache.h b/gdb/regcache.h
index 93b4499..44ba350 100644
--- a/gdb/regcache.h
+++ b/gdb/regcache.h
@@ -90,9 +90,9 @@ extern void regcache_raw_write_unsigned (struct regcache *regcache,
 
 extern enum register_status
   regcache_raw_read_part (struct regcache *regcache, int regnum,
-			  int offset, int len, gdb_byte *buf);
+			  int offset, LONGEST len, gdb_byte *buf);
 void regcache_raw_write_part (struct regcache *regcache, int regnum,
-			      int offset, int len, const gdb_byte *buf);
+			      int offset, LONGEST len, const gdb_byte *buf);
 
 void regcache_invalidate (struct regcache *regcache, int regnum);
 
@@ -129,10 +129,11 @@ extern void regcache_cooked_write_unsigned (struct regcache *regcache,
    write style operations.  */
 
 enum register_status regcache_cooked_read_part (struct regcache *regcache,
-						int regnum, int offset,
-						int len, gdb_byte *buf);
+						int regnum, LONGEST offset,
+						LONGEST len, gdb_byte *buf);
 void regcache_cooked_write_part (struct regcache *regcache, int regnum,
-				 int offset, int len, const gdb_byte *buf);
+				 LONGEST offset, LONGEST len,
+				 const gdb_byte *buf);
 
 /* Special routines to read/write the PC.  */
 
diff --git a/gdb/remote.c b/gdb/remote.c
index 6780212..2d52ea3 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -8114,7 +8114,7 @@ int remote_hw_watchpoint_length_limit = -1;
 int remote_hw_breakpoint_limit = -1;
 
 static int
-remote_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
+remote_region_ok_for_hw_watchpoint (CORE_ADDR addr, LONGEST len)
 {
   if (remote_hw_watchpoint_length_limit == 0)
     return 0;
diff --git a/gdb/rl78-tdep.c b/gdb/rl78-tdep.c
index acd36c2..97afb36 100644
--- a/gdb/rl78-tdep.c
+++ b/gdb/rl78-tdep.c
@@ -1019,8 +1019,8 @@ rl78_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   for (i = nargs - 1; i >= 0; i--)
     {
       struct type *value_type = value_enclosing_type (args[i]);
-      int len = TYPE_LENGTH (value_type);
-      int container_len = (len + 1) & ~1;
+      LONGEST len = TYPE_LENGTH (value_type);
+      LONGEST container_len = (len + 1) & ~1;
 
       sp -= container_len;
       write_memory (rl78_make_data_address (sp),
diff --git a/gdb/rs6000-aix-tdep.c b/gdb/rs6000-aix-tdep.c
index 59cfa73..37353f6 100644
--- a/gdb/rs6000-aix-tdep.c
+++ b/gdb/rs6000-aix-tdep.c
@@ -197,9 +197,9 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int ii;
-  int len = 0;
+  LONGEST len = 0;
   int argno;			/* current argument number */
-  int argbytes;			/* current argument byte */
+  LONGEST argbytes;		/* current argument byte */
   gdb_byte tmp_buffer[50];
   int f_argno = 0;		/* current floating point argno */
   int wordsize = gdbarch_tdep (gdbarch)->wordsize;
@@ -327,7 +327,7 @@ ran_out_of_registers_for_arguments:
 
   if ((argno < nargs) || argbytes)
     {
-      int space = 0, jj;
+      LONGEST space = 0, jj;
 
       if (argbytes)
 	{
diff --git a/gdb/s390-nat.c b/gdb/s390-nat.c
index bad1b43..4974bad 100644
--- a/gdb/s390-nat.c
+++ b/gdb/s390-nat.c
@@ -572,7 +572,7 @@ s390_can_use_hw_breakpoint (int type, int cnt, int othertype)
 }
 
 static int
-s390_region_ok_for_hw_watchpoint (CORE_ADDR addr, int cnt)
+s390_region_ok_for_hw_watchpoint (CORE_ADDR addr, LONGEST cnt)
 {
   return 1;
 }
diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c
index 620eaea..8fa7b1b 100644
--- a/gdb/s390-tdep.c
+++ b/gdb/s390-tdep.c
@@ -376,7 +376,7 @@ s390_value_from_register (struct type *type, int regnum,
 			  struct frame_info *frame)
 {
   struct value *value = default_value_from_register (type, regnum, frame);
-  int len = TYPE_LENGTH (check_typedef (type));
+  LONGEST len = TYPE_LENGTH (check_typedef (type));
 
   if (regnum >= S390_F0_REGNUM && regnum <= S390_F15_REGNUM && len < 8)
     set_value_offset (value, 0);
@@ -2479,7 +2479,7 @@ is_float_like (struct type *type)
 
 
 static int
-is_power_of_two (unsigned int n)
+is_power_of_two (ULONGEST n)
 {
   return ((n & (n - 1)) == 0);
 }
@@ -2489,8 +2489,7 @@ is_power_of_two (unsigned int n)
 static int
 s390_function_arg_pass_by_reference (struct type *type)
 {
-  unsigned length = TYPE_LENGTH (type);
-  if (length > 8)
+  if (TYPE_LENGTH (type) > 8)
     return 1;
 
   return (is_struct_like (type) && !is_power_of_two (TYPE_LENGTH (type)))
@@ -2503,8 +2502,7 @@ s390_function_arg_pass_by_reference (struct type *type)
 static int
 s390_function_arg_float (struct type *type)
 {
-  unsigned length = TYPE_LENGTH (type);
-  if (length > 8)
+  if (TYPE_LENGTH (type) > 8)
     return 0;
 
   return is_float_like (type);
@@ -2616,11 +2614,10 @@ s390_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
     {
       struct value *arg = args[i];
       struct type *type = check_typedef (value_type (arg));
-      unsigned length = TYPE_LENGTH (type);
 
       if (s390_function_arg_pass_by_reference (type))
         {
-          sp -= length;
+          sp -= TYPE_LENGTH (type);
           sp = align_down (sp, alignment_of (type));
           copy_addr[i] = sp;
         }
@@ -2669,7 +2666,7 @@ s390_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
       {
         struct value *arg = args[i];
         struct type *type = check_typedef (value_type (arg));
-        unsigned length = TYPE_LENGTH (type);
+        ULONGEST length = TYPE_LENGTH (type);
 
 	if (s390_function_arg_pass_by_reference (type))
 	  {
@@ -2799,8 +2796,7 @@ s390_frame_align (struct gdbarch *gdbarch, CORE_ADDR addr)
 static enum return_value_convention
 s390_return_value_convention (struct gdbarch *gdbarch, struct type *type)
 {
-  int length = TYPE_LENGTH (type);
-  if (length > 8)
+  if (TYPE_LENGTH (type) > 8)
     return RETURN_VALUE_STRUCT_CONVENTION;
 
   switch (TYPE_CODE (type))
@@ -2824,7 +2820,7 @@ s390_return_value (struct gdbarch *gdbarch, struct value *function,
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int word_size = gdbarch_ptr_bit (gdbarch) / 8;
   enum return_value_convention rvc;
-  int length;
+  LONGEST length;
 
   type = check_typedef (type);
   rvc = s390_return_value_convention (gdbarch, type);
diff --git a/gdb/score-tdep.c b/gdb/score-tdep.c
index fb25806..5711d99 100644
--- a/gdb/score-tdep.c
+++ b/gdb/score-tdep.c
@@ -515,7 +515,7 @@ score_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int argnum;
   int argreg;
-  int arglen = 0;
+  LONGEST arglen = 0;
   CORE_ADDR stack_offset = 0;
   CORE_ADDR addr = 0;
 
diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
index 1ede13a..00d7401 100644
--- a/gdb/sh-tdep.c
+++ b/gdb/sh-tdep.c
@@ -805,7 +805,7 @@ sh_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
 static int
 sh_use_struct_convention (int renesas_abi, struct type *type)
 {
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
   int nelem = TYPE_NFIELDS (type);
 
   /* The Renesas ABI returns aggregate types always on stack.  */
@@ -907,7 +907,7 @@ sh_frame_align (struct gdbarch *ignore, CORE_ADDR sp)
 
 /* Helper function to justify value in register according to endianess.  */
 static char *
-sh_justify_value_in_reg (struct gdbarch *gdbarch, struct value *val, int len)
+sh_justify_value_in_reg (struct gdbarch *gdbarch, struct value *val, LONGEST len)
 {
   static char valbuf[4];
 
@@ -1067,7 +1067,8 @@ sh_push_dummy_call_fpu (struct gdbarch *gdbarch,
   struct type *type;
   CORE_ADDR regval;
   char *val;
-  int len, reg_size = 0;
+  LONGEST len;
+  int reg_size = 0;
   int pass_on_stack = 0;
   int treat_as_flt;
   int last_reg_arg = INT_MAX;
@@ -1208,7 +1209,8 @@ sh_push_dummy_call_nofpu (struct gdbarch *gdbarch,
   struct type *type;
   CORE_ADDR regval;
   char *val;
-  int len, reg_size = 0;
+  LONGEST len;
+  int reg_size = 0;
   int pass_on_stack = 0;
   int last_reg_arg = INT_MAX;
 
@@ -1304,7 +1306,7 @@ sh_extract_return_value_nofpu (struct type *type, struct regcache *regcache,
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
   int return_register = R0_REGNUM;
   int offset;
 
@@ -1358,7 +1360,7 @@ sh_store_return_value_nofpu (struct type *type, struct regcache *regcache,
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   ULONGEST val;
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
 
   if (len <= 4)
     {
@@ -1367,7 +1369,8 @@ sh_store_return_value_nofpu (struct type *type, struct regcache *regcache,
     }
   else
     {
-      int i, regnum = R0_REGNUM;
+      LONGEST i;
+      int regnum = R0_REGNUM;
       for (i = 0; i < len; i += 4)
 	regcache_raw_write (regcache, regnum++, (char *) valbuf + i);
     }
diff --git a/gdb/sh64-tdep.c b/gdb/sh64-tdep.c
index 4e6f262..1b64ceb 100644
--- a/gdb/sh64-tdep.c
+++ b/gdb/sh64-tdep.c
@@ -1058,7 +1058,7 @@ sh64_push_dummy_call (struct gdbarch *gdbarch,
 		      CORE_ADDR struct_addr)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  int stack_offset, stack_alloc;
+  LONGEST stack_offset, stack_alloc;
   int int_argreg;
   int float_argreg;
   int double_argreg;
@@ -1069,7 +1069,7 @@ sh64_push_dummy_call (struct gdbarch *gdbarch,
   CORE_ADDR regval;
   char *val;
   char valbuf[8];
-  int len;
+  LONGEST len;
   int argreg_size;
   int fp_args[12];
 
@@ -1228,7 +1228,7 @@ sh64_extract_return_value (struct type *type, struct regcache *regcache,
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
 
   if (TYPE_CODE (type) == TYPE_CODE_FLT)
     {
@@ -1290,7 +1290,7 @@ sh64_store_return_value (struct type *type, struct regcache *regcache,
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   char buf[64];	/* more than enough...  */
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
 
   if (TYPE_CODE (type) == TYPE_CODE_FLT)
     {
diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
index 6da2297..0cacfd7 100644
--- a/gdb/sparc-tdep.c
+++ b/gdb/sparc-tdep.c
@@ -470,7 +470,7 @@ sparc32_store_arguments (struct regcache *regcache, int nargs,
   for (i = 0; i < nargs; i++)
     {
       struct type *type = value_type (args[i]);
-      int len = TYPE_LENGTH (type);
+      LONGEST len = TYPE_LENGTH (type);
 
       if (sparc_structure_or_union_p (type)
 	  || (sparc_floating_p (type) && len == 16)
diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c
index 28c9ca4..d632cd6 100644
--- a/gdb/sparc64-tdep.c
+++ b/gdb/sparc64-tdep.c
@@ -639,7 +639,8 @@ sparc64_16_byte_align_p (struct type *type)
 
 static void
 sparc64_store_floating_fields (struct regcache *regcache, struct type *type,
-			       const gdb_byte *valbuf, int element, int bitpos)
+			       const gdb_byte *valbuf, int element,
+			       LONGEST bitpos)
 {
   int len = TYPE_LENGTH (type);
 
@@ -681,7 +682,7 @@ sparc64_store_floating_fields (struct regcache *regcache, struct type *type,
       for (i = 0; i < TYPE_NFIELDS (type); i++)
 	{
 	  struct type *subtype = check_typedef (TYPE_FIELD_TYPE (type, i));
-	  int subpos = bitpos + TYPE_FIELD_BITPOS (type, i);
+	  LONGEST subpos = bitpos + TYPE_FIELD_BITPOS (type, i);
 
 	  sparc64_store_floating_fields (regcache, subtype, valbuf,
 					 element, subpos);
@@ -713,7 +714,7 @@ sparc64_store_floating_fields (struct regcache *regcache, struct type *type,
 
 static void
 sparc64_extract_floating_fields (struct regcache *regcache, struct type *type,
-				 gdb_byte *valbuf, int bitpos)
+				 gdb_byte *valbuf, LONGEST bitpos)
 {
   if (sparc64_floating_p (type))
     {
@@ -750,7 +751,7 @@ sparc64_extract_floating_fields (struct regcache *regcache, struct type *type,
       for (i = 0; i < TYPE_NFIELDS (type); i++)
 	{
 	  struct type *subtype = check_typedef (TYPE_FIELD_TYPE (type, i));
-	  int subpos = bitpos + TYPE_FIELD_BITPOS (type, i);
+	  LONGEST subpos = bitpos + TYPE_FIELD_BITPOS (type, i);
 
 	  sparc64_extract_floating_fields (regcache, subtype, valbuf, subpos);
 	}
@@ -783,7 +784,7 @@ sparc64_store_arguments (struct regcache *regcache, int nargs,
   for (i = 0; i < nargs; i++)
     {
       struct type *type = value_type (args[i]);
-      int len = TYPE_LENGTH (type);
+      LONGEST len = TYPE_LENGTH (type);
 
       if (sparc64_structure_or_union_p (type)
 	  || (sparc64_complex_floating_p (type) && len == 32))
@@ -883,7 +884,7 @@ sparc64_store_arguments (struct regcache *regcache, int nargs,
     {
       const gdb_byte *valbuf = value_contents (args[i]);
       struct type *type = value_type (args[i]);
-      int len = TYPE_LENGTH (type);
+      LONGEST len = TYPE_LENGTH (type);
       int regnum = -1;
       gdb_byte buf[16];
 
@@ -1020,7 +1021,7 @@ static void
 sparc64_extract_return_value (struct type *type, struct regcache *regcache,
 			      gdb_byte *valbuf)
 {
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
   gdb_byte buf[32];
   int i;
 
@@ -1070,7 +1071,7 @@ static void
 sparc64_store_return_value (struct type *type, struct regcache *regcache,
 			    const gdb_byte *valbuf)
 {
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
   gdb_byte buf[16];
   int i;
 
diff --git a/gdb/spu-multiarch.c b/gdb/spu-multiarch.c
index 8d4ef57..2ab3327 100644
--- a/gdb/spu-multiarch.c
+++ b/gdb/spu-multiarch.c
@@ -118,7 +118,7 @@ spu_thread_architecture (struct target_ops *ops, ptid_t ptid)
 
 /* Override the to_region_ok_for_hw_watchpoint routine.  */
 static int
-spu_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
+spu_region_ok_for_hw_watchpoint (CORE_ADDR addr, LONGEST len)
 {
   struct target_ops *ops_beneath = find_target_beneath (&spu_ops);
   while (ops_beneath && !ops_beneath->to_region_ok_for_hw_watchpoint)
diff --git a/gdb/spu-tdep.c b/gdb/spu-tdep.c
index f05a26b..3bf5c95 100644
--- a/gdb/spu-tdep.c
+++ b/gdb/spu-tdep.c
@@ -316,7 +316,7 @@ spu_value_from_register (struct type *type, int regnum,
 			 struct frame_info *frame)
 {
   struct value *value = default_value_from_register (type, regnum, frame);
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
 
   if (regnum < SPU_NUM_GPRS && len < 16)
     {
@@ -1293,7 +1293,7 @@ static void
 spu_value_to_regcache (struct regcache *regcache, int regnum,
 		       struct type *type, const gdb_byte *in)
 {
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
 
   if (spu_scalar_value_p (type))
     {
@@ -1318,7 +1318,7 @@ static void
 spu_regcache_to_value (struct regcache *regcache, int regnum,
 		       struct type *type, gdb_byte *out)
 {
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
 
   if (spu_scalar_value_p (type))
     {
@@ -1373,8 +1373,7 @@ spu_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
       struct value *arg = args[i];
       struct type *type = check_typedef (value_type (arg));
       const gdb_byte *contents = value_contents (arg);
-      int len = TYPE_LENGTH (type);
-      int n_regs = align_up (len, 16) / 16;
+      LONGEST n_regs = align_up (TYPE_LENGTH (type), 16) / 16;
 
       /* If the argument doesn't wholly fit into registers, it and
 	 all subsequent arguments go to the stack.  */
@@ -1406,7 +1405,7 @@ spu_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 	{
 	  struct value *arg = args[i];
 	  struct type *type = check_typedef (value_type (arg));
-	  int len = TYPE_LENGTH (type);
+	  LONGEST len = TYPE_LENGTH (type);
 	  int preferred_slot;
 	  
 	  if (spu_scalar_value_p (type))
diff --git a/gdb/stack.c b/gdb/stack.c
index 51747ea..9ab981c 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -173,7 +173,7 @@ print_stack_frame (struct frame_info *frame, int print_level,
    argument (not just the first nameless argument).  */
 
 static void
-print_frame_nameless_args (struct frame_info *frame, long start, int num,
+print_frame_nameless_args (struct frame_info *frame, LONGEST start, int num,
 			   int first, struct ui_file *stream)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
@@ -354,7 +354,7 @@ read_frame_arg (struct symbol *sym, struct frame_info *frame,
 
 	  if (val && entryval && !ui_out_is_mi_like_p (current_uiout))
 	    {
-	      unsigned len = TYPE_LENGTH (value_type (val));
+	      ULONGEST len = TYPE_LENGTH (value_type (val));
 
 	      if (!value_optimized_out (val) && value_lazy (val))
 		value_fetch_lazy (val);
@@ -373,7 +373,7 @@ read_frame_arg (struct symbol *sym, struct frame_info *frame,
 
 		  TRY_CATCH (except, RETURN_MASK_ERROR)
 		    {
-		      unsigned len_deref;
+		      ULONGEST len_deref;
 
 		      val_deref = coerce_ref (val);
 		      if (value_lazy (val_deref))
@@ -496,7 +496,7 @@ print_frame_args (struct symbol *func, struct frame_info *frame,
   /* Offset of next stack argument beyond the one we have seen that is
      at the highest offset, or -1 if we haven't come to a stack
      argument yet.  */
-  long highest_offset = -1;
+  LONGEST highest_offset = -1;
   /* Number of ints of arguments that we have printed so far.  */
   int args_printed = 0;
   struct cleanup *old_chain;
@@ -532,8 +532,8 @@ print_frame_args (struct symbol *func, struct frame_info *frame,
 	    case LOC_ARG:
 	    case LOC_REF_ARG:
 	      {
-		long current_offset = SYMBOL_VALUE (sym);
-		int arg_size = TYPE_LENGTH (SYMBOL_TYPE (sym));
+		LONGEST current_offset = SYMBOL_VALUE (sym);
+		LONGEST arg_size = TYPE_LENGTH (SYMBOL_TYPE (sym));
 
 		/* Compute address of next argument by adding the size of
 		   this argument and rounding to an int boundary.  */
@@ -668,7 +668,7 @@ print_frame_args (struct symbol *func, struct frame_info *frame,
      enough about the stack to find them.  */
   if (num != -1)
     {
-      long start;
+      LONGEST start;
 
       if (highest_offset == -1)
 	start = gdbarch_frame_args_skip (get_frame_arch (frame));
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index d3028e6..c172a77 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -516,11 +516,11 @@ print_symbol (void *args)
 
 	case LOC_CONST_BYTES:
 	  {
-	    unsigned i;
+	    ULONGEST i;
 	    struct type *type = check_typedef (SYMBOL_TYPE (symbol));
 
-	    fprintf_filtered (outfile, "const %u hex bytes:",
-			      TYPE_LENGTH (type));
+	    fprintf_filtered (outfile, "const %s hex bytes:",
+			      pulongest (TYPE_LENGTH (type)));
 	    for (i = 0; i < TYPE_LENGTH (type); i++)
 	      fprintf_filtered (outfile, " %02x",
 				(unsigned) SYMBOL_VALUE_BYTES (symbol)[i]);
diff --git a/gdb/target.c b/gdb/target.c
index 1fc8802..f7207c0 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -51,7 +51,7 @@ static void default_terminal_info (char *, int);
 static int default_watchpoint_addr_within_range (struct target_ops *,
 						 CORE_ADDR, CORE_ADDR, int);
 
-static int default_region_ok_for_hw_watchpoint (CORE_ADDR, int);
+static int default_region_ok_for_hw_watchpoint (CORE_ADDR, LONGEST);
 
 static void tcomplain (void) ATTRIBUTE_NORETURN;
 
@@ -127,7 +127,7 @@ static int debug_to_stopped_data_address (struct target_ops *, CORE_ADDR *);
 static int debug_to_watchpoint_addr_within_range (struct target_ops *,
 						  CORE_ADDR, CORE_ADDR, int);
 
-static int debug_to_region_ok_for_hw_watchpoint (CORE_ADDR, int);
+static int debug_to_region_ok_for_hw_watchpoint (CORE_ADDR, LONGEST);
 
 static int debug_to_can_accel_watchpoint_condition (CORE_ADDR, int, int,
 						    struct expression *);
@@ -3550,7 +3550,7 @@ target_fileio_read_stralloc (const char *filename)
 
 
 static int
-default_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
+default_region_ok_for_hw_watchpoint (CORE_ADDR addr, LONGEST len)
 {
   return (len <= gdbarch_ptr_bit (target_gdbarch) / TARGET_CHAR_BIT);
 }
@@ -4249,7 +4249,7 @@ debug_to_can_use_hw_breakpoint (int type, int cnt, int from_tty)
 }
 
 static int
-debug_to_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
+debug_to_region_ok_for_hw_watchpoint (CORE_ADDR addr, LONGEST len)
 {
   CORE_ADDR retval;
 
diff --git a/gdb/target.h b/gdb/target.h
index 95cfbe2..8c0f919 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -482,7 +482,7 @@ struct target_ops
 
     /* Documentation of this routine is provided with the corresponding
        target_* macro.  */
-    int (*to_region_ok_for_hw_watchpoint) (CORE_ADDR, int);
+    int (*to_region_ok_for_hw_watchpoint) (CORE_ADDR, LONGEST);
 
     int (*to_can_accel_watchpoint_condition) (CORE_ADDR, int, int,
 					      struct expression *);
diff --git a/gdb/testsuite/gdb.base/structs-longest-bitpos.c b/gdb/testsuite/gdb.base/structs-longest-bitpos.c
new file mode 100644
index 0000000..1394c08
--- /dev/null
+++ b/gdb/testsuite/gdb.base/structs-longest-bitpos.c
@@ -0,0 +1,28 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2012 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+struct foo
+{
+  char buf[0xffff000000];
+  char buf2[2];
+} *f;
+
+int
+main (void)
+{
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.base/structs-longest-bitpos.exp b/gdb/testsuite/gdb.base/structs-longest-bitpos.exp
new file mode 100644
index 0000000..fa03f64
--- /dev/null
+++ b/gdb/testsuite/gdb.base/structs-longest-bitpos.exp
@@ -0,0 +1,30 @@
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2012 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+set testfile "structs-longest-bitpos"
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+
+if { [prepare_for_testing ${testfile}.exp ${testfile}] } {
+    return -1
+}
+
+# The array size should not overflow
+gdb_test "print &f->buf" {= \(char \(\*\)\[1099494850560\]\) 0x0}
+
+# The offset should not overflow
+gdb_test "print &f->buf2" {= \(char \(\*\)\[2\]\) 0xffff000000}
diff --git a/gdb/tic6x-tdep.c b/gdb/tic6x-tdep.c
index 1fefcf3..8309d58 100644
--- a/gdb/tic6x-tdep.c
+++ b/gdb/tic6x-tdep.c
@@ -916,7 +916,6 @@ tic6x_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 {
   int argreg = 0;
   int argnum;
-  int len = 0;
   int stack_offset = 4;
   int references_offset = 4;
   CORE_ADDR func_addr = find_function_addr (function, NULL);
@@ -952,7 +951,7 @@ tic6x_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   /* Now make space on the stack for the args.  */
   for (argnum = 0; argnum < nargs; argnum++)
     {
-      int len = align_up (TYPE_LENGTH (value_type (args[argnum])), 4);
+      LONGEST len = align_up (TYPE_LENGTH (value_type (args[argnum])), 4);
       if (argnum >= 10 - argreg)
 	references_offset += len;
       stack_offset += len;
@@ -971,7 +970,7 @@ tic6x_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
       const gdb_byte *val;
       struct value *arg = args[argnum];
       struct type *arg_type = check_typedef (value_type (arg));
-      int len = TYPE_LENGTH (arg_type);
+      LONGEST len = TYPE_LENGTH (arg_type);
       enum type_code typecode = TYPE_CODE (arg_type);
 
       val = value_contents (arg);
diff --git a/gdb/tilegx-tdep.c b/gdb/tilegx-tdep.c
index 9ec3aaa..fc1da14 100644
--- a/gdb/tilegx-tdep.c
+++ b/gdb/tilegx-tdep.c
@@ -218,8 +218,8 @@ static void
 tilegx_extract_return_value (struct type *type, struct regcache *regcache,
 			     gdb_byte *valbuf)
 {
-  int len = TYPE_LENGTH (type);
-  int i, regnum = TILEGX_R0_REGNUM;
+  LONGEST i, len = TYPE_LENGTH (type);
+  int regnum = TILEGX_R0_REGNUM;
 
   for (i = 0; i < len; i += tilegx_reg_size)
     regcache_raw_read (regcache, regnum++, valbuf + i);
@@ -243,8 +243,8 @@ tilegx_store_return_value (struct type *type, struct regcache *regcache,
     }
   else
     {
-      int len = TYPE_LENGTH (type);
-      int i, regnum = TILEGX_R0_REGNUM;
+      LONGEST i, len = TYPE_LENGTH (type);
+      int regnum = TILEGX_R0_REGNUM;
 
       for (i = 0; i < len; i += tilegx_reg_size)
 	regcache_raw_write (regcache, regnum++, (gdb_byte *) valbuf + i);
@@ -291,7 +291,8 @@ tilegx_push_dummy_call (struct gdbarch *gdbarch,
   CORE_ADDR stack_dest = sp;
   int argreg = TILEGX_R0_REGNUM;
   int i, j;
-  int typelen, slacklen, alignlen;
+  LONGEST typelen;
+  int slacklen, alignlen;
   static const gdb_byte two_zero_words[8] = { 0 };
 
   /* If struct_return is 1, then the struct return address will
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index e729d6d..3bfac74 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -934,13 +934,13 @@ add_register (struct collection_list *collection, unsigned int regno)
 static void
 add_memrange (struct collection_list *memranges, 
 	      int type, bfd_signed_vma base,
-	      unsigned long len)
+	      ULONGEST len)
 {
   if (info_verbose)
     {
       printf_filtered ("(%d,", type);
       printf_vma (base);
-      printf_filtered (",%ld)\n", len);
+      printf_filtered (",%s)\n", pulongest (len));
     }
 
   /* type: memrange_absolute == memory, other n == basereg */
@@ -969,7 +969,7 @@ collect_symbol (struct collection_list *collect,
 		long frame_regno, long frame_offset,
 		CORE_ADDR scope)
 {
-  unsigned long len;
+  ULONGEST len;
   unsigned int reg;
   bfd_signed_vma offset;
   int treat_as_expr = 0;
@@ -993,8 +993,8 @@ collect_symbol (struct collection_list *collect,
 	  char tmp[40];
 
 	  sprintf_vma (tmp, offset);
-	  printf_filtered ("LOC_STATIC %s: collect %ld bytes at %s.\n",
-			   SYMBOL_PRINT_NAME (sym), len,
+	  printf_filtered ("LOC_STATIC %s: collect %s bytes at %s.\n",
+			   SYMBOL_PRINT_NAME (sym), pulongest (len),
 			   tmp /* address */);
 	}
       /* A struct may be a C++ class with static fields, go to general
@@ -1026,8 +1026,8 @@ collect_symbol (struct collection_list *collect,
       offset = frame_offset + SYMBOL_VALUE (sym);
       if (info_verbose)
 	{
-	  printf_filtered ("LOC_LOCAL %s: Collect %ld bytes at offset ",
-			   SYMBOL_PRINT_NAME (sym), len);
+	  printf_filtered ("LOC_LOCAL %s: Collect %s bytes at offset ",
+			   SYMBOL_PRINT_NAME (sym), pulongest (len));
 	  printf_vma (offset);
 	  printf_filtered (" from frame ptr reg %d\n", reg);
 	}
@@ -1038,8 +1038,8 @@ collect_symbol (struct collection_list *collect,
       offset = 0;
       if (info_verbose)
 	{
-	  printf_filtered ("LOC_REGPARM_ADDR %s: Collect %ld bytes at offset ",
-			   SYMBOL_PRINT_NAME (sym), len);
+	  printf_filtered ("LOC_REGPARM_ADDR %s: Collect %s bytes at offset ",
+			   SYMBOL_PRINT_NAME (sym), pulongest (len));
 	  printf_vma (offset);
 	  printf_filtered (" from reg %d\n", reg);
 	}
@@ -1050,8 +1050,8 @@ collect_symbol (struct collection_list *collect,
       offset = frame_offset + SYMBOL_VALUE (sym);
       if (info_verbose)
 	{
-	  printf_filtered ("LOC_LOCAL %s: Collect %ld bytes at offset ",
-			   SYMBOL_PRINT_NAME (sym), len);
+	  printf_filtered ("LOC_LOCAL %s: Collect %s bytes at offset ",
+			   SYMBOL_PRINT_NAME (sym), pulongest (len));
 	  printf_vma (offset);
 	  printf_filtered (" from frame ptr reg %d\n", reg);
 	}
@@ -1450,7 +1450,8 @@ encode_actions_1 (struct command_line *action,
 		}
 	      else
 		{
-		  unsigned long addr, len;
+		  CORE_ADDR addr;
+		  ULONGEST len;
 		  struct cleanup *old_chain = NULL;
 		  struct cleanup *old_chain1 = NULL;
 
@@ -2615,7 +2616,8 @@ scope_info (char *args, int from_tty)
   const char *symname;
   char *save_args = args;
   struct block_iterator iter;
-  int j, count = 0;
+  int count = 0;
+  LONGEST j;
   struct gdbarch *gdbarch;
   int regno;
 
@@ -2745,8 +2747,11 @@ scope_info (char *args, int from_tty)
 	      break;
 	    }
 	  if (SYMBOL_TYPE (sym))
-	    printf_filtered (", length %d.\n",
-			     TYPE_LENGTH (check_typedef (SYMBOL_TYPE (sym))));
+	    {
+	      ULONGEST len = TYPE_LENGTH (check_typedef (SYMBOL_TYPE (sym)));
+
+	      printf_filtered (", length %s.\n", pulongest (len));
+	    }
 	}
       if (BLOCK_FUNCTION (block))
 	break;
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
index c25e705..4bbf8a7 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -118,7 +118,7 @@ whatis_exp (char *exp, int show)
   struct type *real_type = NULL;
   struct type *type;
   int full = 0;
-  int top = -1;
+  LONGEST top = -1;
   int using_enc = 0;
   struct value_print_options opts;
 
diff --git a/gdb/v850-tdep.c b/gdb/v850-tdep.c
index e374df8..d143bd0 100644
--- a/gdb/v850-tdep.c
+++ b/gdb/v850-tdep.c
@@ -809,7 +809,7 @@ v850_push_dummy_call (struct gdbarch *gdbarch,
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int argreg;
   int argnum;
-  int len = 0;
+  LONGEST len = 0;
   int stack_offset;
 
   /* The offset onto the stack at which we will start copying parameters
@@ -834,7 +834,7 @@ v850_push_dummy_call (struct gdbarch *gdbarch,
      in four registers available.  Loop thru args from first to last.  */
   for (argnum = 0; argnum < nargs; argnum++)
     {
-      int len;
+      LONGEST len;
       gdb_byte *val;
       gdb_byte valbuf[v850_reg_size];
 
@@ -890,7 +890,7 @@ v850_extract_return_value (struct type *type, struct regcache *regcache,
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
 
   if (len <= v850_reg_size)
     {
@@ -917,7 +917,7 @@ v850_store_return_value (struct type *type, struct regcache *regcache,
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
 
   if (len <= v850_reg_size)
       regcache_cooked_write_unsigned
diff --git a/gdb/valarith.c b/gdb/valarith.c
index 96d5411..0d4b5a9 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -196,8 +196,8 @@ value_subscripted_rvalue (struct value *array, LONGEST index, int lowerbound)
 {
   struct type *array_type = check_typedef (value_type (array));
   struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type));
-  unsigned int elt_size = TYPE_LENGTH (elt_type);
-  unsigned int elt_offs = elt_size * longest_to_int (index - lowerbound);
+  ULONGEST elt_size = TYPE_LENGTH (elt_type);
+  ULONGEST elt_offs = elt_size * (index - lowerbound);
   struct value *v;
 
   if (index < lowerbound || (!TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type)
@@ -1474,7 +1474,7 @@ value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
 int
 value_logical_not (struct value *arg1)
 {
-  int len;
+  LONGEST len;
   const gdb_byte *p;
   struct type *type1;
 
@@ -1505,11 +1505,11 @@ value_logical_not (struct value *arg1)
 static int
 value_strcmp (struct value *arg1, struct value *arg2)
 {
-  int len1 = TYPE_LENGTH (value_type (arg1));
-  int len2 = TYPE_LENGTH (value_type (arg2));
+  LONGEST len1 = TYPE_LENGTH (value_type (arg1));
+  LONGEST len2 = TYPE_LENGTH (value_type (arg2));
   const gdb_byte *s1 = value_contents (arg1);
   const gdb_byte *s2 = value_contents (arg2);
-  int i, len = len1 < len2 ? len1 : len2;
+  LONGEST i, len = len1 < len2 ? len1 : len2;
 
   for (i = 0; i < len; i++)
     {
diff --git a/gdb/valops.c b/gdb/valops.c
index 934f381..36fe229 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -53,11 +53,11 @@ static int typecmp (int staticp, int varargs, int nargs,
 		    struct field t1[], struct value *t2[]);
 
 static struct value *search_struct_field (const char *, struct value *, 
-					  int, struct type *, int);
+					  LONGEST, struct type *, int);
 
 static struct value *search_struct_method (const char *, struct value **,
 					   struct value **,
-					   int, int *, struct type *);
+					   LONGEST, int *, struct type *);
 
 static int find_oload_champ_namespace (struct value **, int,
 				       const char *, const char *,
@@ -85,7 +85,7 @@ oload_classification classify_oload_match (struct badness_vector *,
 					   int, int);
 
 static struct value *value_struct_elt_for_reference (struct type *,
-						     int, struct type *,
+						     LONGEST, struct type *,
 						     char *,
 						     struct type *,
 						     int, enum noside);
@@ -102,8 +102,8 @@ static CORE_ADDR allocate_space_in_inferior (int);
 static struct value *cast_into_complex (struct type *, struct value *);
 
 static struct fn_field *find_method_list (struct value **, const char *,
-					  int, struct type *, int *,
-					  struct type **, int *);
+					  LONGEST, struct type *, int *,
+					  struct type **, LONGEST *);
 
 void _initialize_valops (void);
 
@@ -188,7 +188,7 @@ find_function_in_inferior (const char *name, struct objfile **objf_p)
    space.  */
 
 struct value *
-value_allocate_space_in_inferior (int len)
+value_allocate_space_in_inferior (LONGEST len)
 {
   struct objfile *objf;
   struct value *val = find_function_in_inferior ("malloc", &objf);
@@ -261,7 +261,8 @@ value_cast_structs (struct type *type, struct value *v2)
   if (TYPE_NAME (t2) != NULL)
     {
       /* Try downcasting using the run-time type of the value.  */
-      int full, top, using_enc;
+      int full, using_enc;
+      LONGEST top;
       struct type *real_type;
 
       real_type = value_rtti_type (v2, &full, &top, &using_enc);
@@ -400,12 +401,12 @@ value_cast (struct type *type, struct value *arg2)
   if (code1 == TYPE_CODE_ARRAY)
     {
       struct type *element_type = TYPE_TARGET_TYPE (type);
-      unsigned element_length = TYPE_LENGTH (check_typedef (element_type));
+      ULONGEST element_length = TYPE_LENGTH (check_typedef (element_type));
 
       if (element_length > 0 && TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
 	{
 	  struct type *range_type = TYPE_INDEX_TYPE (type);
-	  int val_length = TYPE_LENGTH (type2);
+	  LONGEST val_length = TYPE_LENGTH (type2);
 	  LONGEST low_bound, high_bound, new_length;
 
 	  if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0)
@@ -655,7 +656,7 @@ value_reinterpret_cast (struct type *type, struct value *arg)
 static int
 dynamic_cast_check_1 (struct type *desired_type,
 		      const gdb_byte *valaddr,
-		      int embedded_offset,
+		      LONGEST embedded_offset,
 		      CORE_ADDR address,
 		      struct value *val,
 		      struct type *search_type,
@@ -667,8 +668,8 @@ dynamic_cast_check_1 (struct type *desired_type,
 
   for (i = 0; i < TYPE_N_BASECLASSES (search_type) && result_count < 2; ++i)
     {
-      int offset = baseclass_offset (search_type, i, valaddr, embedded_offset,
-				     address, val);
+      LONGEST offset = baseclass_offset (search_type, i, valaddr,
+					 embedded_offset, address, val);
 
       if (class_types_same_p (desired_type, TYPE_BASECLASS (search_type, i)))
 	{
@@ -702,7 +703,7 @@ dynamic_cast_check_1 (struct type *desired_type,
 static int
 dynamic_cast_check_2 (struct type *desired_type,
 		      const gdb_byte *valaddr,
-		      int embedded_offset,
+		      LONGEST embedded_offset,
 		      CORE_ADDR address,
 		      struct value *val,
 		      struct type *search_type,
@@ -712,7 +713,7 @@ dynamic_cast_check_2 (struct type *desired_type,
 
   for (i = 0; i < TYPE_N_BASECLASSES (search_type) && result_count < 2; ++i)
     {
-      int offset;
+      LONGEST offset;
 
       if (! BASETYPE_VIA_PUBLIC (search_type, i))
 	continue;
@@ -743,7 +744,8 @@ dynamic_cast_check_2 (struct type *desired_type,
 struct value *
 value_dynamic_cast (struct type *type, struct value *arg)
 {
-  int full, top, using_enc;
+  int full, using_enc;
+  LONGEST top;
   struct type *resolved_type = check_typedef (type);
   struct type *arg_type = check_typedef (value_type (arg));
   struct type *class_type, *rtti_type;
@@ -994,7 +996,7 @@ value_fetch_lazy (struct value *val)
       struct value *parent = value_parent (val);
       LONGEST offset = value_offset (val);
       LONGEST num;
-      int length = TYPE_LENGTH (type);
+      LONGEST length = TYPE_LENGTH (type);
 
       if (!value_bits_valid (val,
 			     TARGET_CHAR_BIT * offset + value_bitpos (val),
@@ -1016,7 +1018,8 @@ value_fetch_lazy (struct value *val)
   else if (VALUE_LVAL (val) == lval_memory)
     {
       CORE_ADDR addr = value_address (val);
-      int length = TYPE_LENGTH (check_typedef (value_enclosing_type (val)));
+      struct type *enclosing_type = value_enclosing_type (val);
+      LONGEST length = TYPE_LENGTH (check_typedef (enclosing_type));
 
       if (length)
 	read_value_memory (val, 0, value_stack (val),
@@ -1125,7 +1128,7 @@ value_fetch_lazy (struct value *val)
 }
 
 void
-read_value_memory (struct value *val, int embedded_offset,
+read_value_memory (struct value *val, LONGEST embedded_offset,
 		   int stack, CORE_ADDR memaddr,
 		   gdb_byte *buffer, size_t length)
 {
@@ -1260,7 +1263,7 @@ value_assign (struct value *toval, struct value *fromval)
       {
 	const gdb_byte *dest_buffer;
 	CORE_ADDR changed_addr;
-	int changed_len;
+	LONGEST changed_len;
         gdb_byte buffer[sizeof (LONGEST)];
 
 	if (value_bitsize (toval))
@@ -1331,7 +1334,7 @@ value_assign (struct value *toval, struct value *fromval)
 	    if (value_bitsize (toval))
 	      {
 		struct value *parent = value_parent (toval);
-		int offset = value_offset (parent) + value_offset (toval);
+		LONGEST offset = value_offset (parent) + value_offset (toval);
 		int changed_len;
 		gdb_byte buffer[sizeof (LONGEST)];
 		int optim, unavail;
@@ -1796,7 +1799,7 @@ value_array (int lowbound, int highbound, struct value **elemvec)
 {
   int nelem;
   int idx;
-  unsigned int typelength;
+  ULONGEST typelength;
   struct value *val;
   struct type *arraytype;
 
@@ -1839,11 +1842,11 @@ value_array (int lowbound, int highbound, struct value **elemvec)
 }
 
 struct value *
-value_cstring (char *ptr, int len, struct type *char_type)
+value_cstring (char *ptr, LONGEST len, struct type *char_type)
 {
   struct value *val;
   int lowbound = current_language->string_lower_bound;
-  int highbound = len / TYPE_LENGTH (char_type);
+  LONGEST highbound = len / TYPE_LENGTH (char_type);
   struct type *stringtype
     = lookup_array_range_type (char_type, lowbound, highbound + lowbound - 1);
 
@@ -1862,11 +1865,11 @@ value_cstring (char *ptr, int len, struct type *char_type)
    string may contain embedded null bytes.  */
 
 struct value *
-value_string (char *ptr, int len, struct type *char_type)
+value_string (char *ptr, LONGEST len, struct type *char_type)
 {
   struct value *val;
   int lowbound = current_language->string_lower_bound;
-  int highbound = len / TYPE_LENGTH (char_type);
+  LONGEST highbound = len / TYPE_LENGTH (char_type);
   struct type *stringtype
     = lookup_string_range_type (char_type, lowbound, highbound + lowbound - 1);
 
@@ -1984,7 +1987,7 @@ typecmp (int staticp, int varargs, int nargs,
 
 static void
 update_search_result (struct value **result_ptr, struct value *v,
-		      int *last_boffset, int boffset,
+		      LONGEST *last_boffset, LONGEST boffset,
 		      const char *name, struct type *type)
 {
   if (v != NULL)
@@ -2008,10 +2011,10 @@ update_search_result (struct value **result_ptr, struct value *v,
    lookup is ambiguous.  */
 
 static void
-do_search_struct_field (const char *name, struct value *arg1, int offset,
+do_search_struct_field (const char *name, struct value *arg1, LONGEST offset,
 			struct type *type, int looking_for_baseclass,
 			struct value **result_ptr,
-			int *last_boffset,
+			LONGEST *last_boffset,
 			struct type *outermost_type)
 {
   int i;
@@ -2066,7 +2069,7 @@ do_search_struct_field (const char *name, struct value *arg1, int offset,
 		   <variant field>.  */
 
 		struct value *v = NULL;
-		int new_offset = offset;
+		LONGEST new_offset = offset;
 
 		/* This is pretty gross.  In G++, the offset in an
 		   anonymous union is relative to the beginning of the
@@ -2105,7 +2108,7 @@ do_search_struct_field (const char *name, struct value *arg1, int offset,
 			     && (strcmp_iw (name, 
 					    TYPE_BASECLASS_NAME (type, 
 								 i)) == 0));
-      int boffset = value_embedded_offset (arg1) + offset;
+      LONGEST boffset = value_embedded_offset (arg1) + offset;
 
       if (BASETYPE_VIA_VIRTUAL (type, i))
 	{
@@ -2180,11 +2183,11 @@ do_search_struct_field (const char *name, struct value *arg1, int offset,
    fields, look for a baseclass named NAME.  */
 
 static struct value *
-search_struct_field (const char *name, struct value *arg1, int offset,
+search_struct_field (const char *name, struct value *arg1, LONGEST offset,
 		     struct type *type, int looking_for_baseclass)
 {
   struct value *result = NULL;
-  int boffset = 0;
+  LONGEST boffset = 0;
 
   do_search_struct_field (name, arg1, offset, type, looking_for_baseclass,
 			  &result, &boffset, type);
@@ -2201,7 +2204,7 @@ search_struct_field (const char *name, struct value *arg1, int offset,
 
 static struct value *
 search_struct_method (const char *name, struct value **arg1p,
-		      struct value **args, int offset,
+		      struct value **args, LONGEST offset,
 		      int *static_memfuncp, struct type *type)
 {
   int i;
@@ -2265,9 +2268,9 @@ search_struct_method (const char *name, struct value **arg1p,
 
   for (i = TYPE_N_BASECLASSES (type) - 1; i >= 0; i--)
     {
-      int base_offset;
+      LONGEST base_offset;
       int skip = 0;
-      int this_offset;
+      LONGEST this_offset;
 
       if (BASETYPE_VIA_VIRTUAL (type, i))
 	{
@@ -2449,8 +2452,8 @@ value_struct_elt (struct value **argp, struct value **args,
 
 static struct fn_field *
 find_method_list (struct value **argp, const char *method,
-		  int offset, struct type *type, int *num_fns,
-		  struct type **basetype, int *boffset)
+		  LONGEST offset, struct type *type, int *num_fns,
+		  struct type **basetype, LONGEST *boffset)
 {
   int i;
   struct fn_field *f;
@@ -2483,7 +2486,7 @@ find_method_list (struct value **argp, const char *method,
   /* Not found in object, check in base subobjects.  */
   for (i = TYPE_N_BASECLASSES (type) - 1; i >= 0; i--)
     {
-      int base_offset;
+      LONGEST base_offset;
 
       if (BASETYPE_VIA_VIRTUAL (type, i))
 	{
@@ -2519,7 +2522,7 @@ find_method_list (struct value **argp, const char *method,
 static struct fn_field *
 value_find_oload_method_list (struct value **argp, const char *method,
 			      int offset, int *num_fns, 
-			      struct type **basetype, int *boffset)
+			      struct type **basetype, LONGEST *boffset)
 {
   struct type *t;
 
@@ -2611,7 +2614,7 @@ find_overload_match (struct value **args, int nargs,
   /* Number of overloaded instances being considered.  */
   int num_fns = 0;
   struct type *basetype = NULL;
-  int boffset;
+  LONGEST boffset;
 
   struct cleanup *all_cleanups = make_cleanup (null_cleanup, NULL);
 
@@ -3317,7 +3320,7 @@ compare_parameters (struct type *t1, struct type *t2, int skip_artificial)
    the form "DOMAIN::NAME".  */
 
 static struct value *
-value_struct_elt_for_reference (struct type *domain, int offset,
+value_struct_elt_for_reference (struct type *domain, LONGEST offset,
 				struct type *curtype, char *name,
 				struct type *intype, 
 				int want_address,
@@ -3354,7 +3357,7 @@ value_struct_elt_for_reference (struct type *domain, int offset,
 	  if (want_address)
 	    return value_from_longest
 	      (lookup_memberptr_type (TYPE_FIELD_TYPE (t, i), domain),
-	       offset + (LONGEST) (TYPE_FIELD_BITPOS (t, i) >> 3));
+	       offset + (TYPE_FIELD_BITPOS (t, i) >> 3));
 	  else if (noside == EVAL_AVOID_SIDE_EFFECTS)
 	    return allocate_value (TYPE_FIELD_TYPE (t, i));
 	  else
@@ -3497,7 +3500,7 @@ value_struct_elt_for_reference (struct type *domain, int offset,
   for (i = TYPE_N_BASECLASSES (t) - 1; i >= 0; i--)
     {
       struct value *v;
-      int base_offset;
+      LONGEST base_offset;
 
       if (BASETYPE_VIA_VIRTUAL (t, i))
 	base_offset = 0;
@@ -3587,7 +3590,7 @@ value_maybe_namespace_elt (const struct type *curtype,
 
 struct type *
 value_rtti_indirect_type (struct value *v, int *full, 
-			  int *top, int *using_enc)
+			  LONGEST *top, int *using_enc)
 {
   struct value *target;
   struct type *type, *real_type, *target_type;
@@ -3637,12 +3640,12 @@ value_rtti_indirect_type (struct value *v, int *full,
 struct value *
 value_full_object (struct value *argp, 
 		   struct type *rtype, 
-		   int xfull, int xtop,
+		   int xfull, LONGEST xtop,
 		   int xusing_enc)
 {
   struct type *real_type;
   int full = 0;
-  int top = -1;
+  LONGEST top = -1;
   int using_enc = 0;
   struct value *new_val;
 
diff --git a/gdb/valprint.c b/gdb/valprint.c
index fc5942d..dd1f88e 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -264,7 +264,7 @@ scalar_type_p (struct type *type)
 int
 valprint_check_validity (struct ui_file *stream,
 			 struct type *type,
-			 int embedded_offset,
+			 LONGEST embedded_offset,
 			 const struct value *val)
 {
   CHECK_TYPEDEF (type);
@@ -328,7 +328,7 @@ val_print_invalid_address (struct ui_file *stream)
 
 void
 generic_val_print (struct type *type, const gdb_byte *valaddr,
-		   int embedded_offset, CORE_ADDR address,
+		   LONGEST embedded_offset, CORE_ADDR address,
 		   struct ui_file *stream, int recurse,
 		   const struct value *original_value,
 		   const struct value_print_options *options,
@@ -691,7 +691,7 @@ generic_val_print (struct type *type, const gdb_byte *valaddr,
    RECURSE.  */
 
 void
-val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
+val_print (struct type *type, const gdb_byte *valaddr, LONGEST embedded_offset,
 	   CORE_ADDR address, struct ui_file *stream, int recurse,
 	   const struct value *val,
 	   const struct value_print_options *options,
@@ -903,7 +903,7 @@ val_print_type_code_flags (struct type *type, const gdb_byte *valaddr,
 
 void
 val_print_scalar_formatted (struct type *type,
-			    const gdb_byte *valaddr, int embedded_offset,
+			    const gdb_byte *valaddr, LONGEST embedded_offset,
 			    const struct value *val,
 			    const struct value_print_options *options,
 			    int size,
@@ -1444,7 +1444,7 @@ print_decimal_chars (struct ui_file *stream, const gdb_byte *valaddr,
 
 void
 print_hex_chars (struct ui_file *stream, const gdb_byte *valaddr,
-		 unsigned len, enum bfd_endian byte_order)
+		 ULONGEST len, enum bfd_endian byte_order)
 {
   const gdb_byte *p;
 
@@ -1561,22 +1561,22 @@ maybe_print_array_index (struct type *index_type, LONGEST index,
 
 void
 val_print_array_elements (struct type *type,
-			  const gdb_byte *valaddr, int embedded_offset,
+			  const gdb_byte *valaddr, LONGEST embedded_offset,
 			  CORE_ADDR address, struct ui_file *stream,
 			  int recurse,
 			  const struct value *val,
 			  const struct value_print_options *options,
-			  unsigned int i)
+			  ULONGEST i)
 {
   unsigned int things_printed = 0;
-  unsigned len;
+  ULONGEST len;
   struct type *elttype, *index_type;
-  unsigned eltlen;
+  ULONGEST eltlen;
   /* Position of the array element we are examining to see
      whether it is repeated.  */
-  unsigned int rep1;
+  ULONGEST rep1;
   /* Number of repetitions we have detected so far.  */
-  unsigned int reps;
+  ULONGEST reps;
   LONGEST low_bound, high_bound;
 
   elttype = TYPE_TARGET_TYPE (type);
@@ -1647,7 +1647,7 @@ val_print_array_elements (struct type *type,
 		     address, stream, recurse + 1, val, options,
 		     current_language);
 	  annotate_elt_rep (reps);
-	  fprintf_filtered (stream, " <repeats %u times>", reps);
+	  fprintf_filtered (stream, " <repeats %s times>", pulongest (reps));
 	  annotate_elt_rep_end ();
 
 	  i = rep1 - 1;
@@ -2058,7 +2058,7 @@ generic_emit_char (int c, struct type *type, struct ui_file *stream,
 
 void
 generic_printstr (struct ui_file *stream, struct type *type, 
-		  const gdb_byte *string, unsigned int length, 
+		  const gdb_byte *string, ULONGEST length,
 		  const char *encoding, int force_ellipses,
 		  int quote_char, int c_style_terminator,
 		  const struct value_print_options *options)
diff --git a/gdb/valprint.h b/gdb/valprint.h
index b853b1a..219608b 100644
--- a/gdb/valprint.h
+++ b/gdb/valprint.h
@@ -117,11 +117,11 @@ extern void maybe_print_array_index (struct type *index_type, LONGEST index,
                                      struct ui_file *stream,
 				     const struct value_print_options *);
 
-extern void val_print_array_elements (struct type *, const gdb_byte *, int,
+extern void val_print_array_elements (struct type *, const gdb_byte *, LONGEST,
 				      CORE_ADDR, struct ui_file *, int,
 				      const struct value *,
 				      const struct value_print_options *,
-				      unsigned int);
+				      ULONGEST);
 
 extern void val_print_type_code_int (struct type *, const gdb_byte *,
 				     struct ui_file *);
@@ -131,7 +131,7 @@ extern void val_print_type_code_flags (struct type *type,
 				       struct ui_file *stream);
 
 extern void val_print_scalar_formatted (struct type *,
-					const gdb_byte *, int,
+					const gdb_byte *, LONGEST,
 					const struct value *,
 					const struct value_print_options *,
 					int,
@@ -147,7 +147,7 @@ extern void print_decimal_chars (struct ui_file *, const gdb_byte *,
 				 unsigned int, enum bfd_endian);
 
 extern void print_hex_chars (struct ui_file *, const gdb_byte *,
-			     unsigned int, enum bfd_endian);
+			     ULONGEST, enum bfd_endian);
 
 extern void print_char_chars (struct ui_file *, struct type *,
 			      const gdb_byte *, unsigned int, enum bfd_endian);
@@ -191,7 +191,7 @@ struct generic_val_print_decorations
 
 
 extern void generic_val_print (struct type *type, const gdb_byte *valaddr,
-			       int embedded_offset, CORE_ADDR address,
+			       LONGEST embedded_offset, CORE_ADDR address,
 			       struct ui_file *stream, int recurse,
 			       const struct value *original_value,
 			       const struct value_print_options *options,
@@ -201,7 +201,7 @@ extern void generic_emit_char (int c, struct type *type, struct ui_file *stream,
 			       int quoter, const char *encoding);
 
 extern void generic_printstr (struct ui_file *stream, struct type *type, 
-			      const gdb_byte *string, unsigned int length, 
+			      const gdb_byte *string, ULONGEST length,
 			      const char *encoding, int force_ellipses,
 			      int quote_char, int c_style_terminator,
 			      const struct value_print_options *options);
diff --git a/gdb/value.c b/gdb/value.c
index a6bb718..3fddba0 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -67,10 +67,10 @@ struct internal_function
 struct range
 {
   /* Lowest offset in the range.  */
-  int offset;
+  LONGEST offset;
 
   /* Length of the range.  */
-  int length;
+  LONGEST length;
 };
 
 typedef struct range range_s;
@@ -81,8 +81,8 @@ DEF_VEC_O(range_s);
    [offset2, offset2+len2) overlap.  */
 
 static int
-ranges_overlap (int offset1, int len1,
-		int offset2, int len2)
+ranges_overlap (LONGEST offset1, LONGEST len1,
+		LONGEST offset2, LONGEST len2)
 {
   ULONGEST h, l;
 
@@ -106,7 +106,7 @@ range_lessthan (const range_s *r1, const range_s *r2)
    OFFSET+LENGTH).  */
 
 static int
-ranges_contain (VEC(range_s) *ranges, int offset, int length)
+ranges_contain (VEC(range_s) *ranges, LONGEST offset, LONGEST length)
 {
   range_s what;
   int i;
@@ -239,7 +239,7 @@ struct value
      lval == lval_register, this is a further offset from
      location.address within the registers structure.  Note also the
      member embedded_offset below.  */
-  int offset;
+  LONGEST offset;
 
   /* Only used for bitfields; number of bits contained in them.  */
   int bitsize;
@@ -309,8 +309,8 @@ struct value
      `type', and `embedded_offset' is zero, so everything works
      normally.  */
   struct type *enclosing_type;
-  int embedded_offset;
-  int pointed_to_offset;
+  LONGEST embedded_offset;
+  LONGEST pointed_to_offset;
 
   /* Values are stored in a chain, so that they can be deleted easily
      over calls to the inferior.  Values assigned to internal
@@ -332,7 +332,8 @@ struct value
 };
 
 int
-value_bytes_available (const struct value *value, int offset, int length)
+value_bytes_available (const struct value *value, LONGEST offset,
+		       LONGEST length)
 {
   gdb_assert (!value->lazy);
 
@@ -353,7 +354,8 @@ value_entirely_available (struct value *value)
 }
 
 void
-mark_value_bytes_unavailable (struct value *value, int offset, int length)
+mark_value_bytes_unavailable (struct value *value, LONGEST offset,
+			      LONGEST length)
 {
   range_s newr;
   int i;
@@ -524,7 +526,7 @@ mark_value_bytes_unavailable (struct value *value, int offset, int length)
 
 static int
 find_first_range_overlap (VEC(range_s) *ranges, int pos,
-			  int offset, int length)
+			  LONGEST offset, LONGEST length)
 {
   range_s *r;
   int i;
@@ -537,9 +539,9 @@ find_first_range_overlap (VEC(range_s) *ranges, int pos,
 }
 
 int
-value_available_contents_eq (const struct value *val1, int offset1,
-			     const struct value *val2, int offset2,
-			     int length)
+value_available_contents_eq (const struct value *val1, LONGEST offset1,
+			     const struct value *val2, LONGEST offset2,
+			     LONGEST length)
 {
   int idx1 = 0, idx2 = 0;
 
@@ -767,13 +769,13 @@ deprecated_set_value_type (struct value *value, struct type *type)
   value->type = type;
 }
 
-int
+LONGEST
 value_offset (const struct value *value)
 {
   return value->offset;
 }
 void
-set_value_offset (struct value *value, int offset)
+set_value_offset (struct value *value, LONGEST offset)
 {
   value->offset = offset;
 }
@@ -923,8 +925,9 @@ value_contents_all (struct value *value)
    DST_OFFSET+LENGTH) range are wholly available.  */
 
 void
-value_contents_copy_raw (struct value *dst, int dst_offset,
-			 struct value *src, int src_offset, int length)
+value_contents_copy_raw (struct value *dst, LONGEST dst_offset,
+			 struct value *src, LONGEST src_offset,
+			 LONGEST length)
 {
   range_s *r;
   int i;
@@ -972,8 +975,8 @@ value_contents_copy_raw (struct value *dst, int dst_offset,
    DST_OFFSET+LENGTH) range are wholly available.  */
 
 void
-value_contents_copy (struct value *dst, int dst_offset,
-		     struct value *src, int src_offset, int length)
+value_contents_copy (struct value *dst, LONGEST dst_offset,
+		     struct value *src, LONGEST src_offset, LONGEST length)
 {
   require_not_optimized_out (src);
 
@@ -1033,7 +1036,7 @@ value_contents_equal (struct value *val1, struct value *val2)
 {
   struct type *type1;
   struct type *type2;
-  int len;
+  LONGEST len;
 
   type1 = check_typedef (value_type (val1));
   type2 = check_typedef (value_type (val2));
@@ -1068,7 +1071,7 @@ value_entirely_optimized_out (const struct value *value)
 }
 
 int
-value_bits_valid (const struct value *value, int offset, int length)
+value_bits_valid (const struct value *value, LONGEST offset, LONGEST length)
 {
   if (!value->optimized_out)
     return 1;
@@ -1081,7 +1084,7 @@ value_bits_valid (const struct value *value, int offset, int length)
 
 int
 value_bits_synthetic_pointer (const struct value *value,
-			      int offset, int length)
+			      LONGEST offset, LONGEST length)
 {
   if (value->lval != lval_computed
       || !value->location.computed.funcs->check_synthetic_pointer)
@@ -1091,26 +1094,26 @@ value_bits_synthetic_pointer (const struct value *value,
 								  length);
 }
 
-int
+LONGEST
 value_embedded_offset (struct value *value)
 {
   return value->embedded_offset;
 }
 
 void
-set_value_embedded_offset (struct value *value, int val)
+set_value_embedded_offset (struct value *value, LONGEST val)
 {
   value->embedded_offset = val;
 }
 
-int
+LONGEST
 value_pointed_to_offset (struct value *value)
 {
   return value->pointed_to_offset;
 }
 
 void
-set_value_pointed_to_offset (struct value *value, int val)
+set_value_pointed_to_offset (struct value *value, LONGEST val)
 {
   value->pointed_to_offset = val;
 }
@@ -1936,7 +1939,7 @@ get_internalvar_function (struct internalvar *var,
 }
 
 void
-set_internalvar_component (struct internalvar *var, int offset, int bitpos,
+set_internalvar_component (struct internalvar *var, LONGEST offset, int bitpos,
 			   int bitsize, struct value *newval)
 {
   gdb_byte *addr;
@@ -2605,7 +2608,7 @@ set_value_enclosing_type (struct value *val, struct type *new_encl_type)
    FIELDNO says which field.  */
 
 struct value *
-value_primitive_field (struct value *arg1, int offset,
+value_primitive_field (struct value *arg1, LONGEST offset,
 		       int fieldno, struct type *arg_type)
 {
   struct value *v;
@@ -2635,8 +2638,8 @@ value_primitive_field (struct value *arg1, int offset,
 	 bit.  Assume that the address, offset, and embedded offset
 	 are sufficiently aligned.  */
 
-      int bitpos = TYPE_FIELD_BITPOS (arg_type, fieldno);
-      int container_bitsize = TYPE_LENGTH (type) * 8;
+      LONGEST bitpos = TYPE_FIELD_BITPOS (arg_type, fieldno);
+      LONGEST container_bitsize = TYPE_LENGTH (type) * 8;
 
       v = allocate_value_lazy (type);
       v->bitsize = TYPE_FIELD_BITSIZE (arg_type, fieldno);
@@ -2658,7 +2661,7 @@ value_primitive_field (struct value *arg1, int offset,
       /* This field is actually a base subobject, so preserve the
 	 entire object's contents for later references to virtual
 	 bases, etc.  */
-      int boffset;
+      LONGEST boffset;
 
       /* Lazy register values with offsets are not supported.  */
       if (VALUE_LVAL (arg1) == lval_register && value_lazy (arg1))
@@ -2735,7 +2738,7 @@ value_field (struct value *arg1, int fieldno)
 struct value *
 value_fn_field (struct value **arg1p, struct fn_field *f,
 		int j, struct type *type,
-		int offset)
+		LONGEST offset)
 {
   struct value *v;
   struct type *ftype = TYPE_FN_FIELD_TYPE (f, j);
@@ -2795,8 +2798,8 @@ value_fn_field (struct value **arg1p, struct fn_field *f,
 
 static int
 unpack_value_bits_as_long_1 (struct type *field_type, const gdb_byte *valaddr,
-			     int embedded_offset, int bitpos, int bitsize,
-			     const struct value *original_value,
+			     LONGEST embedded_offset, LONGEST bitpos,
+			     int bitsize, const struct value *original_value,
 			     LONGEST *result)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (field_type));
@@ -2804,7 +2807,7 @@ unpack_value_bits_as_long_1 (struct type *field_type, const gdb_byte *valaddr,
   ULONGEST valmask;
   int lsbcount;
   int bytes_read;
-  int read_offset;
+  LONGEST read_offset;
 
   /* Read the minimum number of bytes required; there may not be
      enough bytes to read an entire ULONGEST.  */
@@ -2874,7 +2877,7 @@ unpack_value_bits_as_long_1 (struct type *field_type, const gdb_byte *valaddr,
 
 int
 unpack_value_bits_as_long (struct type *field_type, const gdb_byte *valaddr,
-			   int embedded_offset, int bitpos, int bitsize,
+			   LONGEST embedded_offset, int bitpos, int bitsize,
 			   const struct value *original_value,
 			   LONGEST *result)
 {
@@ -2892,10 +2895,10 @@ unpack_value_bits_as_long (struct type *field_type, const gdb_byte *valaddr,
 
 static int
 unpack_value_field_as_long_1 (struct type *type, const gdb_byte *valaddr,
-			      int embedded_offset, int fieldno,
+			      LONGEST embedded_offset, int fieldno,
 			      const struct value *val, LONGEST *result)
 {
-  int bitpos = TYPE_FIELD_BITPOS (type, fieldno);
+  LONGEST bitpos = TYPE_FIELD_BITPOS (type, fieldno);
   int bitsize = TYPE_FIELD_BITSIZE (type, fieldno);
   struct type *field_type = TYPE_FIELD_TYPE (type, fieldno);
 
@@ -2911,7 +2914,7 @@ unpack_value_field_as_long_1 (struct type *type, const gdb_byte *valaddr,
 
 int
 unpack_value_field_as_long (struct type *type, const gdb_byte *valaddr,
-			    int embedded_offset, int fieldno,
+			    LONGEST embedded_offset, int fieldno,
 			    const struct value *val, LONGEST *result)
 {
   gdb_assert (val != NULL);
@@ -2943,7 +2946,7 @@ unpack_field_as_long (struct type *type, const gdb_byte *valaddr, int fieldno)
 struct value *
 value_field_bitfield (struct type *type, int fieldno,
 		      const gdb_byte *valaddr,
-		      int embedded_offset, const struct value *val)
+		      LONGEST embedded_offset, const struct value *val)
 {
   LONGEST l;
 
@@ -2970,12 +2973,12 @@ value_field_bitfield (struct type *type, int fieldno,
 
 void
 modify_field (struct type *type, gdb_byte *addr,
-	      LONGEST fieldval, int bitpos, int bitsize)
+	      LONGEST fieldval, LONGEST bitpos, int bitsize)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
   ULONGEST oword;
   ULONGEST mask = (ULONGEST) -1 >> (8 * sizeof (ULONGEST) - bitsize);
-  int bytesize;
+  LONGEST bytesize;
 
   /* Normalize BITPOS.  */
   addr += bitpos / 8;
diff --git a/gdb/value.h b/gdb/value.h
index d8b157f..525f86d 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -82,8 +82,8 @@ extern void set_value_parent (struct value *value, struct value *parent);
    within the registers structure.  Note also the member
    embedded_offset below.  */
 
-extern int value_offset (const struct value *);
-extern void set_value_offset (struct value *, int offset);
+extern LONGEST value_offset (const struct value *);
+extern void set_value_offset (struct value *, LONGEST offset);
 
 /* The comment from "struct value" reads: ``Is it modifiable?  Only
    relevant if lval != not_lval.''.  Shouldn't the value instead be
@@ -154,10 +154,10 @@ extern struct type *value_actual_type (struct value *value,
 				       int resolve_simple_types,
 				       int *real_type_found);
 
-extern int value_pointed_to_offset (struct value *value);
-extern void set_value_pointed_to_offset (struct value *value, int val);
-extern int value_embedded_offset (struct value *value);
-extern void set_value_embedded_offset (struct value *value, int val);
+extern LONGEST value_pointed_to_offset (struct value *value);
+extern void set_value_pointed_to_offset (struct value *value, LONGEST val);
+extern LONGEST value_embedded_offset (struct value *value);
+extern void set_value_embedded_offset (struct value *value, LONGEST val);
 
 /* For lval_computed values, this structure holds functions used to
    retrieve and set the value (or portions of the value).
@@ -185,7 +185,8 @@ struct lval_funcs
   /* Check the validity of some bits in VALUE.  This should return 1
      if all the bits starting at OFFSET and extending for LENGTH bits
      are valid, or 0 if any bit is invalid.  */
-  int (*check_validity) (const struct value *value, int offset, int length);
+  int (*check_validity) (const struct value *value, LONGEST offset,
+			 LONGEST length);
 
   /* Return 1 if any bit in VALUE is valid, 0 if they are all invalid.  */
   int (*check_any_valid) (const struct value *value);
@@ -203,7 +204,7 @@ struct lval_funcs
   /* If non-NULL, this is used to determine whether the indicated bits
      of VALUE are a synthetic pointer.  */
   int (*check_synthetic_pointer) (const struct value *value,
-				  int offset, int length);
+				  LONGEST offset, LONGEST length);
 
   /* Return a duplicate of VALUE's closure, for use in a new value.
      This may simply return the same closure, if VALUE's is
@@ -240,7 +241,7 @@ extern struct value *allocate_computed_value (struct type *type,
    Otherwise, return 1.  */
 
 extern int valprint_check_validity (struct ui_file *stream, struct type *type,
-				    int embedded_offset,
+				    LONGEST embedded_offset,
 				    const struct value *val);
 
 extern struct value *allocate_optimized_out_value (struct type *type);
@@ -411,13 +412,13 @@ extern struct value *coerce_array (struct value *value);
    bits in the given range are valid, zero if any bit is invalid.  */
 
 extern int value_bits_valid (const struct value *value,
-			     int offset, int length);
+			     LONGEST offset, LONGEST length);
 
 /* Given a value, determine whether the bits starting at OFFSET and
    extending for LENGTH bits are a synthetic pointer.  */
 
 extern int value_bits_synthetic_pointer (const struct value *value,
-					 int offset, int length);
+					 LONGEST offset, LONGEST length);
 
 /* Given a value, determine whether the contents bytes starting at
    OFFSET and extending for LENGTH bytes are available.  This returns
@@ -425,7 +426,7 @@ extern int value_bits_synthetic_pointer (const struct value *value,
    byte is unavailable.  */
 
 extern int value_bytes_available (const struct value *value,
-				  int offset, int length);
+				  LONGEST offset, LONGEST length);
 
 /* Like value_bytes_available, but return false if any byte in the
    whole object is unavailable.  */
@@ -435,7 +436,7 @@ extern int value_entirely_available (struct value *value);
    LENGTH bytes as unavailable.  */
 
 extern void mark_value_bytes_unavailable (struct value *value,
-					  int offset, int length);
+					  LONGEST offset, LONGEST length);
 
 /* Compare LENGTH bytes of VAL1's contents starting at OFFSET1 with
    LENGTH bytes of VAL2's contents starting at OFFSET2.
@@ -445,7 +446,7 @@ extern void mark_value_bytes_unavailable (struct value *value,
    example, to compare a complete object value with itself, including
    its enclosing type chunk, you'd do:
 
-     int len = TYPE_LENGTH (check_typedef (value_enclosing_type (val)));
+     ULONGEST len = TYPE_LENGTH (check_typedef (value_enclosing_type (val)));
      value_available_contents (val, 0, val, 0, len);
 
    Returns true iff the set of available contents match.  Unavailable
@@ -467,9 +468,10 @@ extern void mark_value_bytes_unavailable (struct value *value,
    value_available_contents_eq(val, 3, val, 4, 4) => 0
 */
 
-extern int value_available_contents_eq (const struct value *val1, int offset1,
-					const struct value *val2, int offset2,
-					int length);
+extern int value_available_contents_eq (const struct value *val1,
+					LONGEST offset1,
+					const struct value *val2,
+					LONGEST offset2, LONGEST length);
 
 /* Read LENGTH bytes of memory starting at MEMADDR into BUFFER, which
    is (or will be copied to) VAL's contents buffer offset by
@@ -478,7 +480,7 @@ extern int value_available_contents_eq (const struct value *val1, int offset1,
    memory is likewise unavailable.  STACK indicates whether the memory
    is known to be stack memory.  */
 
-extern void read_value_memory (struct value *val, int embedded_offset,
+extern void read_value_memory (struct value *val, LONGEST embedded_offset,
 			       int stack, CORE_ADDR memaddr,
 			       gdb_byte *buffer, size_t length);
 
@@ -506,7 +508,7 @@ extern CORE_ADDR unpack_pointer (struct type *type, const gdb_byte *valaddr);
 
 extern int unpack_value_bits_as_long (struct type *field_type,
 				      const gdb_byte *valaddr,
-				      int embedded_offset, int bitpos,
+				      LONGEST embedded_offset, int bitpos,
 				      int bitsize,
 				      const struct value *original_value,
 				      LONGEST *result);
@@ -515,12 +517,12 @@ extern LONGEST unpack_field_as_long (struct type *type,
 				     const gdb_byte *valaddr,
 				     int fieldno);
 extern int unpack_value_field_as_long (struct type *type, const gdb_byte *valaddr,
-				int embedded_offset, int fieldno,
+				LONGEST embedded_offset, int fieldno,
 				const struct value *val, LONGEST *result);
 
 extern struct value *value_field_bitfield (struct type *type, int fieldno,
 					   const gdb_byte *valaddr,
-					   int embedded_offset,
+					   LONGEST embedded_offset,
 					   const struct value *val);
 
 extern void pack_long (gdb_byte *buf, struct type *type, LONGEST num);
@@ -574,12 +576,12 @@ extern struct value *default_read_var_value (struct symbol *var,
 extern struct value *allocate_value (struct type *type);
 extern struct value *allocate_value_lazy (struct type *type);
 extern void allocate_value_contents (struct value *value);
-extern void value_contents_copy (struct value *dst, int dst_offset,
-				 struct value *src, int src_offset,
-				 int length);
-extern void value_contents_copy_raw (struct value *dst, int dst_offset,
-				     struct value *src, int src_offset,
-				     int length);
+extern void value_contents_copy (struct value *dst, LONGEST dst_offset,
+				 struct value *src, LONGEST src_offset,
+				 LONGEST length);
+extern void value_contents_copy_raw (struct value *dst, LONGEST dst_offset,
+				     struct value *src, LONGEST src_offset,
+				     LONGEST length);
 
 extern struct value *allocate_repeat_value (struct type *type, int count);
 
@@ -587,9 +589,9 @@ extern struct value *value_mark (void);
 
 extern void value_free_to_mark (struct value *mark);
 
-extern struct value *value_cstring (char *ptr, int len,
+extern struct value *value_cstring (char *ptr, LONGEST len,
 				    struct type *char_type);
-extern struct value *value_string (char *ptr, int len,
+extern struct value *value_string (char *ptr, LONGEST len,
 				   struct type *char_type);
 extern struct value *value_bitstring (char *ptr, int len,
 				      struct type *index_type);
@@ -653,16 +655,16 @@ extern int find_overload_match (struct value **args, int nargs,
 
 extern struct value *value_field (struct value *arg1, int fieldno);
 
-extern struct value *value_primitive_field (struct value *arg1, int offset,
+extern struct value *value_primitive_field (struct value *arg1, LONGEST offset,
 					    int fieldno,
 					    struct type *arg_type);
 
 
-extern struct type *value_rtti_indirect_type (struct value *, int *, int *,
+extern struct type *value_rtti_indirect_type (struct value *, int *, LONGEST *,
 					      int *);
 
 extern struct value *value_full_object (struct value *, struct type *, int,
-					int, int);
+					LONGEST, int);
 
 extern struct value *value_cast_pointers (struct type *, struct value *, int);
 
@@ -752,7 +754,7 @@ extern void set_internalvar_string (struct internalvar *var,
 extern void clear_internalvar (struct internalvar *var);
 
 extern void set_internalvar_component (struct internalvar *var,
-				       int offset,
+				       LONGEST offset,
 				       int bitpos, int bitsize,
 				       struct value *newvalue);
 
@@ -834,7 +836,7 @@ extern struct value *value_x_unop (struct value *arg1, enum exp_opcode op,
 				   enum noside noside);
 
 extern struct value *value_fn_field (struct value **arg1p, struct fn_field *f,
-				     int j, struct type *type, int offset);
+				     int j, struct type *type, LONGEST offset);
 
 extern int binop_types_user_defined_p (enum exp_opcode op,
 				       struct type *type1,
@@ -862,7 +864,8 @@ extern void release_value_or_incref (struct value *val);
 extern int record_latest_value (struct value *val);
 
 extern void modify_field (struct type *type, gdb_byte *addr,
-			  LONGEST fieldval, int bitpos, int bitsize);
+			  LONGEST fieldval, LONGEST bitpos,
+			  int bitsize);
 
 extern void type_print (struct type *type, const char *varstring,
 			struct ui_file *stream, int show);
@@ -892,7 +895,7 @@ extern void value_print_array_elements (struct value *val,
 extern struct value *value_release_to_mark (struct value *mark);
 
 extern void val_print (struct type *type, const gdb_byte *valaddr,
-		       int embedded_offset, CORE_ADDR address,
+		       LONGEST embedded_offset, CORE_ADDR address,
 		       struct ui_file *stream, int recurse,
 		       const struct value *val,
 		       const struct value_print_options *options,
@@ -943,7 +946,7 @@ extern struct value *value_literal_complex (struct value *, struct value *,
 extern struct value *find_function_in_inferior (const char *,
 						struct objfile **);
 
-extern struct value *value_allocate_space_in_inferior (int);
+extern struct value *value_allocate_space_in_inferior (LONGEST);
 
 extern struct value *value_subscripted_rvalue (struct value *array,
 					       LONGEST index, int lowerbound);
diff --git a/gdb/vax-tdep.c b/gdb/vax-tdep.c
index 550b56b..f3870c9 100644
--- a/gdb/vax-tdep.c
+++ b/gdb/vax-tdep.c
@@ -116,7 +116,7 @@ vax_store_arguments (struct regcache *regcache, int nargs,
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_byte buf[4];
-  int count = 0;
+  LONGEST count = 0;
   int i;
 
   /* We create an argument list on the stack, and make the argument
@@ -125,7 +125,7 @@ vax_store_arguments (struct regcache *regcache, int nargs,
   /* Push arguments in reverse order.  */
   for (i = nargs - 1; i >= 0; i--)
     {
-      int len = TYPE_LENGTH (value_enclosing_type (args[i]));
+      LONGEST len = TYPE_LENGTH (value_enclosing_type (args[i]));
 
       sp -= (len + 3) & ~3;
       count += (len + 3) / 4;
@@ -208,7 +208,7 @@ vax_return_value (struct gdbarch *gdbarch, struct value *function,
 		  struct type *type, struct regcache *regcache,
 		  gdb_byte *readbuf, const gdb_byte *writebuf)
 {
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
   gdb_byte buf[8];
 
   if (TYPE_CODE (type) == TYPE_CODE_STRUCT
diff --git a/gdb/xstormy16-tdep.c b/gdb/xstormy16-tdep.c
index 47fc86b..d73e2d6 100644
--- a/gdb/xstormy16-tdep.c
+++ b/gdb/xstormy16-tdep.c
@@ -162,8 +162,9 @@ static void
 xstormy16_extract_return_value (struct type *type, struct regcache *regcache,
 				void *valbuf)
 {
-  int len = TYPE_LENGTH (type);
-  int i, regnum = E_1ST_ARG_REGNUM;
+  LONGEST len = TYPE_LENGTH (type);
+  LONGEST i;
+  int regnum = E_1ST_ARG_REGNUM;
 
   for (i = 0; i < len; i += xstormy16_reg_size)
     regcache_raw_read (regcache, regnum++, (char *) valbuf + i);
@@ -188,8 +189,9 @@ xstormy16_store_return_value (struct type *type, struct regcache *regcache,
     }
   else
     {
-      int len = TYPE_LENGTH (type);
-      int i, regnum = E_1ST_ARG_REGNUM;
+      LONGEST len = TYPE_LENGTH (type);
+      LONGEST i;
+      int regnum = E_1ST_ARG_REGNUM;
 
       for (i = 0; i < len; i += xstormy16_reg_size)
         regcache_raw_write (regcache, regnum++, (char *) valbuf + i);
@@ -235,8 +237,9 @@ xstormy16_push_dummy_call (struct gdbarch *gdbarch,
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR stack_dest = sp;
   int argreg = E_1ST_ARG_REGNUM;
-  int i, j;
-  int typelen, slacklen;
+  int i, slacklen;
+  LONGEST j;
+  LONGEST typelen;
   const gdb_byte *val;
   char buf[xstormy16_pc_size];
 
diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c
index 119dc6f..1f234e1 100644
--- a/gdb/xtensa-tdep.c
+++ b/gdb/xtensa-tdep.c
@@ -1580,7 +1580,7 @@ xtensa_extract_return_value (struct type *type,
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   bfd_byte *valbuf = dst;
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
   ULONGEST pc, wb;
   int callsize, areg;
   int offset = 0;
@@ -1598,8 +1598,8 @@ xtensa_extract_return_value (struct type *type,
       /* On Xtensa, we can return up to 4 words (or 2 for call12).  */
       if (len > (callsize > 8 ? 8 : 16))
 	internal_error (__FILE__, __LINE__,
-			_("cannot extract return value of %d bytes long"),
-			len);
+			_("cannot extract return value of %s bytes long"),
+			plongest (len));
 
       /* Get the register offset of the return
 	 register (A2) in the caller window.  */
@@ -1614,7 +1614,8 @@ xtensa_extract_return_value (struct type *type,
       areg = gdbarch_tdep (gdbarch)->a0_base + C0_ARGS;
     }
 
-  DEBUGINFO ("[xtensa_extract_return_value] areg %d len %d\n", areg, len);
+  DEBUGINFO ("[xtensa_extract_return_value] areg %d len %s\n", areg,
+	     plongest (len));
 
   if (len < 4 && gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
     offset = 4 - len;
@@ -1639,7 +1640,7 @@ xtensa_store_return_value (struct type *type,
   unsigned int areg;
   ULONGEST pc, wb;
   int callsize;
-  int len = TYPE_LENGTH (type);
+  LONGEST len = TYPE_LENGTH (type);
   int offset = 0;
 
   DEBUGTRACE ("xtensa_store_return_value (...)\n");
@@ -1653,8 +1654,8 @@ xtensa_store_return_value (struct type *type,
 
       if (len > (callsize > 8 ? 8 : 16))
 	internal_error (__FILE__, __LINE__,
-			_("unimplemented for this length: %d"),
-			TYPE_LENGTH (type));
+			_("unimplemented for this length: %s"),
+			pulongest (TYPE_LENGTH (type)));
       areg = arreg_number (gdbarch,
 			   gdbarch_tdep (gdbarch)->a0_base + 2 + callsize, wb);
 
@@ -1728,18 +1729,18 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch,
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int i;
-  int size, onstack_size;
+  LONGEST size, onstack_size;
   gdb_byte *buf = (gdb_byte *) alloca (16);
   CORE_ADDR ra, ps;
   struct argument_info
   {
     const bfd_byte *contents;
-    int length;
+    LONGEST length;
     int onstack;		/* onstack == 0 => in reg */
     int align;			/* alignment */
     union
     {
-      int offset;		/* stack offset if on stack.  */
+      LONGEST offset;		/* stack offset if on stack.  */
       int regno;		/* regno if in register.  */
     } u;
   };
@@ -1763,9 +1764,10 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch,
         {
 	  struct value *arg = args[i];
 	  struct type *arg_type = check_typedef (value_type (arg));
-	  fprintf_unfiltered (gdb_stdlog, "%2d: %s %3d ", i,
-			      host_address_to_string (arg),
-			      TYPE_LENGTH (arg_type));
+	  const char *arg_type_len_s = pulongest (TYPE_LENGTH (arg_type));
+
+	  fprintf_unfiltered (gdb_stdlog, "%2d: %s %s ", i,
+			      host_address_to_string (arg), arg_type_len_s);
 	  switch (TYPE_CODE (arg_type))
 	    {
 	    case TYPE_CODE_INT:
@@ -1881,7 +1883,7 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch,
 
       if (info->onstack)
 	{
-	  int n = info->length;
+	  LONGEST n = info->length;
 	  CORE_ADDR offset = sp + info->u.offset;
 
 	  /* Odd-sized structs are aligned to the lower side of a memory
@@ -1897,7 +1899,7 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch,
 	}
       else
 	{
-	  int n = info->length;
+	  LONGEST n = info->length;
 	  const bfd_byte *cp = info->contents;
 	  int r = info->u.regno;
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]