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]

[rfc] Eliminate builtin_type_ macros: combined patch


Hello,

here's a combined patch rolling up the 37 builtin_type_ patches;
this should make it is easier to apply all of them for testing ...

Bye,
Ulrich


Index: gdb-head/gdb/ada-exp.y
===================================================================
--- gdb-head.orig/gdb/ada-exp.y
+++ gdb-head/gdb/ada-exp.y
@@ -52,6 +52,8 @@ Boston, MA 02110-1301, USA.  */
 #include "frame.h"
 #include "block.h"
 
+#define parse_type builtin_type (parse_gdbarch)
+
 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
    as well as gratuitiously global symbol names, so we can have multiple
    yacc generated parsers in gdb.  These are only the variables
@@ -571,7 +573,7 @@ opt_type_prefix :
 		type_prefix
 	| 	/* EMPTY */
 			{ write_exp_elt_opcode (OP_TYPE);
-			  write_exp_elt_type (builtin_type_void);
+			  write_exp_elt_type (parse_type->builtin_void);
 			  write_exp_elt_opcode (OP_TYPE); }
 	;
 
@@ -1081,8 +1083,8 @@ static struct type*
 find_primitive_type (char *name)
 {
   struct type *type;
-  type = language_lookup_primitive_type_by_name (current_language,
-						 current_gdbarch,
+  type = language_lookup_primitive_type_by_name (parse_language,
+						 parse_gdbarch,
 						 name);
   if (type == NULL && strcmp ("system__address", name) == 0)
     type = type_system_address ();
@@ -1370,8 +1372,7 @@ write_var_or_type (struct block *block, 
 		= ada_lookup_simple_minsym (encoded_name);
 	      if (msym != NULL)
 		{
-		  write_exp_msymbol (msym, lookup_function_type (type_int ()),
-				     type_int ());
+		  write_exp_msymbol (msym);
 		  /* Maybe cause error here rather than later? FIXME? */
 		  write_selectors (encoded_name + tail_index);
 		  return NULL;
@@ -1464,59 +1465,59 @@ convert_char_literal (struct type *type,
 static struct type *
 type_int (void)
 {
-  return builtin_type_int;
+  return parse_type->builtin_int;
 }
 
 static struct type *
 type_long (void)
 {
-  return builtin_type_long;
+  return parse_type->builtin_long;
 }
 
 static struct type *
 type_long_long (void)
 {
-  return builtin_type_long_long;
+  return parse_type->builtin_long_long;
 }
 
 static struct type *
 type_float (void)
 {
-  return builtin_type_float;
+  return parse_type->builtin_float;
 }
 
 static struct type *
 type_double (void)
 {
-  return builtin_type_double;
+  return parse_type->builtin_double;
 }
 
 static struct type *
 type_long_double (void)
 {
-  return builtin_type_long_double;
+  return parse_type->builtin_long_double;
 }
 
 static struct type *
 type_char (void)
 {
-  return language_string_char_type (current_language, current_gdbarch);
+  return language_string_char_type (parse_language, parse_gdbarch);
 }
 
 static struct type *
 type_boolean (void)
 {
-  return builtin_type_bool;
+  return parse_type->builtin_bool;
 }
 
 static struct type *
 type_system_address (void)
 {
   struct type *type 
-    = language_lookup_primitive_type_by_name (current_language,
-					      current_gdbarch, 
+    = language_lookup_primitive_type_by_name (parse_language,
+					      parse_gdbarch,
 					      "system__address");
-  return  type != NULL ? type : lookup_pointer_type (builtin_type_void);
+  return  type != NULL ? type : parse_type->builtin_data_ptr;
 }
 
 void
Index: gdb-head/gdb/c-exp.y
===================================================================
--- gdb-head.orig/gdb/c-exp.y
+++ gdb-head/gdb/c-exp.y
@@ -55,6 +55,8 @@ Boston, MA 02110-1301, USA.  */
 #include "cp-support.h"
 #include "dfp.h"
 
+#define parse_type builtin_type (parse_gdbarch)
+
 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
    as well as gratuitiously global symbol names, so we can have multiple
    yacc generated parsers in gdb.  Note that these are only the variables
@@ -554,7 +556,7 @@ exp	:	VARIABLE
 
 exp	:	SIZEOF '(' type ')'	%prec UNARY
 			{ write_exp_elt_opcode (OP_LONG);
-			  write_exp_elt_type (builtin_type (current_gdbarch)->builtin_int);
+			  write_exp_elt_type (parse_type->builtin_int);
 			  CHECK_TYPEDEF ($3);
 			  write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
 			  write_exp_elt_opcode (OP_LONG); }
@@ -570,12 +572,12 @@ exp	:	STRING
 			  while (count-- > 0)
 			    {
 			      write_exp_elt_opcode (OP_LONG);
-			      write_exp_elt_type (builtin_type (current_gdbarch)->builtin_char);
+			      write_exp_elt_type (parse_type->builtin_char);
 			      write_exp_elt_longcst ((LONGEST)(*sp++));
 			      write_exp_elt_opcode (OP_LONG);
 			    }
 			  write_exp_elt_opcode (OP_LONG);
-			  write_exp_elt_type (builtin_type (current_gdbarch)->builtin_char);
+			  write_exp_elt_type (parse_type->builtin_char);
 			  write_exp_elt_longcst ((LONGEST)'\0');
 			  write_exp_elt_opcode (OP_LONG);
 			  write_exp_elt_opcode (OP_ARRAY);
@@ -587,14 +589,14 @@ exp	:	STRING
 /* C++.  */
 exp     :       TRUEKEYWORD    
                         { write_exp_elt_opcode (OP_LONG);
-                          write_exp_elt_type (builtin_type (current_gdbarch)->builtin_bool);
+                          write_exp_elt_type (parse_type->builtin_bool);
                           write_exp_elt_longcst ((LONGEST) 1);
                           write_exp_elt_opcode (OP_LONG); }
 	;
 
 exp     :       FALSEKEYWORD   
                         { write_exp_elt_opcode (OP_LONG);
-                          write_exp_elt_type (builtin_type (current_gdbarch)->builtin_bool);
+                          write_exp_elt_type (parse_type->builtin_bool);
                           write_exp_elt_longcst ((LONGEST) 0);
                           write_exp_elt_opcode (OP_LONG); }
 	;
@@ -700,16 +702,11 @@ variable:	qualified_name
 
 			  msymbol = lookup_minimal_symbol (name, NULL, NULL);
 			  if (msymbol != NULL)
-			    {
-			      write_exp_msymbol (msymbol,
-						 lookup_function_type (builtin_type (current_gdbarch)->builtin_int),
-						 builtin_type (current_gdbarch)->builtin_int);
-			    }
+			    write_exp_msymbol (msymbol);
+			  else if (!have_full_symbols () && !have_partial_symbols ())
+			    error ("No symbol table is loaded.  Use the \"file\" command.");
 			  else
-			    if (!have_full_symbols () && !have_partial_symbols ())
-			      error ("No symbol table is loaded.  Use the \"file\" command.");
-			    else
-			      error ("No symbol \"%s\" in current context.", name);
+			    error ("No symbol \"%s\" in current context.", name);
 			}
 	;
 
@@ -756,11 +753,7 @@ variable:	name_not_typename
 			      msymbol =
 				lookup_minimal_symbol (arg, NULL, NULL);
 			      if (msymbol != NULL)
-				{
-				  write_exp_msymbol (msymbol,
-						     lookup_function_type (builtin_type (current_gdbarch)->builtin_int),
-						     builtin_type (current_gdbarch)->builtin_int);
-				}
+				write_exp_msymbol (msymbol);
 			      else if (!have_full_symbols () && !have_partial_symbols ())
 				error ("No symbol table is loaded.  Use the \"file\" command.");
 			      else
@@ -850,61 +843,61 @@ typebase  /* Implements (approximately):
 	:	TYPENAME
 			{ $$ = $1.type; }
 	|	INT_KEYWORD
-			{ $$ = builtin_type (current_gdbarch)->builtin_int; }
+			{ $$ = parse_type->builtin_int; }
 	|	LONG
-			{ $$ = builtin_type (current_gdbarch)->builtin_long; }
+			{ $$ = parse_type->builtin_long; }
 	|	SHORT
-			{ $$ = builtin_type (current_gdbarch)->builtin_short; }
+			{ $$ = parse_type->builtin_short; }
 	|	LONG INT_KEYWORD
-			{ $$ = builtin_type (current_gdbarch)->builtin_long; }
+			{ $$ = parse_type->builtin_long; }
 	|	LONG SIGNED_KEYWORD INT_KEYWORD
-			{ $$ = builtin_type (current_gdbarch)->builtin_long; }
+			{ $$ = parse_type->builtin_long; }
 	|	LONG SIGNED_KEYWORD
-			{ $$ = builtin_type (current_gdbarch)->builtin_long; }
+			{ $$ = parse_type->builtin_long; }
 	|	SIGNED_KEYWORD LONG INT_KEYWORD
-			{ $$ = builtin_type (current_gdbarch)->builtin_long; }
+			{ $$ = parse_type->builtin_long; }
 	|	UNSIGNED LONG INT_KEYWORD
-			{ $$ = builtin_type (current_gdbarch)->builtin_unsigned_long; }
+			{ $$ = parse_type->builtin_unsigned_long; }
 	|	LONG UNSIGNED INT_KEYWORD
-			{ $$ = builtin_type (current_gdbarch)->builtin_unsigned_long; }
+			{ $$ = parse_type->builtin_unsigned_long; }
 	|	LONG UNSIGNED
-			{ $$ = builtin_type (current_gdbarch)->builtin_unsigned_long; }
+			{ $$ = parse_type->builtin_unsigned_long; }
 	|	LONG LONG
-			{ $$ = builtin_type (current_gdbarch)->builtin_long_long; }
+			{ $$ = parse_type->builtin_long_long; }
 	|	LONG LONG INT_KEYWORD
-			{ $$ = builtin_type (current_gdbarch)->builtin_long_long; }
+			{ $$ = parse_type->builtin_long_long; }
 	|	LONG LONG SIGNED_KEYWORD INT_KEYWORD
-			{ $$ = builtin_type (current_gdbarch)->builtin_long_long; }
+			{ $$ = parse_type->builtin_long_long; }
 	|	LONG LONG SIGNED_KEYWORD
-			{ $$ = builtin_type (current_gdbarch)->builtin_long_long; }
+			{ $$ = parse_type->builtin_long_long; }
 	|	SIGNED_KEYWORD LONG LONG
-			{ $$ = builtin_type (current_gdbarch)->builtin_long_long; }
+			{ $$ = parse_type->builtin_long_long; }
 	|	SIGNED_KEYWORD LONG LONG INT_KEYWORD
-			{ $$ = builtin_type (current_gdbarch)->builtin_long_long; }
+			{ $$ = parse_type->builtin_long_long; }
 	|	UNSIGNED LONG LONG
-			{ $$ = builtin_type (current_gdbarch)->builtin_unsigned_long_long; }
+			{ $$ = parse_type->builtin_unsigned_long_long; }
 	|	UNSIGNED LONG LONG INT_KEYWORD
-			{ $$ = builtin_type (current_gdbarch)->builtin_unsigned_long_long; }
+			{ $$ = parse_type->builtin_unsigned_long_long; }
 	|	LONG LONG UNSIGNED
-			{ $$ = builtin_type (current_gdbarch)->builtin_unsigned_long_long; }
+			{ $$ = parse_type->builtin_unsigned_long_long; }
 	|	LONG LONG UNSIGNED INT_KEYWORD
-			{ $$ = builtin_type (current_gdbarch)->builtin_unsigned_long_long; }
+			{ $$ = parse_type->builtin_unsigned_long_long; }
 	|	SHORT INT_KEYWORD
-			{ $$ = builtin_type (current_gdbarch)->builtin_short; }
+			{ $$ = parse_type->builtin_short; }
 	|	SHORT SIGNED_KEYWORD INT_KEYWORD
-			{ $$ = builtin_type (current_gdbarch)->builtin_short; }
+			{ $$ = parse_type->builtin_short; }
 	|	SHORT SIGNED_KEYWORD
-			{ $$ = builtin_type (current_gdbarch)->builtin_short; }
+			{ $$ = parse_type->builtin_short; }
 	|	UNSIGNED SHORT INT_KEYWORD
-			{ $$ = builtin_type (current_gdbarch)->builtin_unsigned_short; }
+			{ $$ = parse_type->builtin_unsigned_short; }
 	|	SHORT UNSIGNED 
-			{ $$ = builtin_type (current_gdbarch)->builtin_unsigned_short; }
+			{ $$ = parse_type->builtin_unsigned_short; }
 	|	SHORT UNSIGNED INT_KEYWORD
-			{ $$ = builtin_type (current_gdbarch)->builtin_unsigned_short; }
+			{ $$ = parse_type->builtin_unsigned_short; }
 	|	DOUBLE_KEYWORD
-			{ $$ = builtin_type (current_gdbarch)->builtin_double; }
+			{ $$ = parse_type->builtin_double; }
 	|	LONG DOUBLE_KEYWORD
-			{ $$ = builtin_type (current_gdbarch)->builtin_long_double; }
+			{ $$ = parse_type->builtin_long_double; }
 	|	STRUCT name
 			{ $$ = lookup_struct (copy_name ($2),
 					      expression_context_block); }
@@ -920,11 +913,11 @@ typebase  /* Implements (approximately):
 	|	UNSIGNED typename
 			{ $$ = lookup_unsigned_typename (TYPE_NAME($2.type)); }
 	|	UNSIGNED
-			{ $$ = builtin_type (current_gdbarch)->builtin_unsigned_int; }
+			{ $$ = parse_type->builtin_unsigned_int; }
 	|	SIGNED_KEYWORD typename
 			{ $$ = lookup_signed_typename (TYPE_NAME($2.type)); }
 	|	SIGNED_KEYWORD
-			{ $$ = builtin_type (current_gdbarch)->builtin_int; }
+			{ $$ = parse_type->builtin_int; }
                 /* It appears that this rule for templates is never
                    reduced; template recognition happens by lookahead
                    in the token processing code in yylex. */         
@@ -1014,19 +1007,19 @@ typename:	TYPENAME
 		{
 		  $$.stoken.ptr = "int";
 		  $$.stoken.length = 3;
-		  $$.type = builtin_type (current_gdbarch)->builtin_int;
+		  $$.type = parse_type->builtin_int;
 		}
 	|	LONG
 		{
 		  $$.stoken.ptr = "long";
 		  $$.stoken.length = 4;
-		  $$.type = builtin_type (current_gdbarch)->builtin_long;
+		  $$.type = parse_type->builtin_long;
 		}
 	|	SHORT
 		{
 		  $$.stoken.ptr = "short";
 		  $$.stoken.length = 5;
-		  $$.type = builtin_type (current_gdbarch)->builtin_short;
+		  $$.type = parse_type->builtin_short;
 		}
 	;
 
@@ -1129,7 +1122,7 @@ parse_number (p, len, parsed_float, puti
 	{
 	  p[len - 2] = '\0';
 	  putithere->typed_val_decfloat.type
-	    = builtin_type (current_gdbarch)->builtin_decfloat;
+	    = parse_type->builtin_decfloat;
 	  decimal_from_string (putithere->typed_val_decfloat.val, 4, p);
 	  p[len - 2] = 'd';
 	  return DECFLOAT;
@@ -1139,7 +1132,7 @@ parse_number (p, len, parsed_float, puti
 	{
 	  p[len - 2] = '\0';
 	  putithere->typed_val_decfloat.type
-	    = builtin_type (current_gdbarch)->builtin_decdouble;
+	    = parse_type->builtin_decdouble;
 	  decimal_from_string (putithere->typed_val_decfloat.val, 8, p);
 	  p[len - 2] = 'd';
 	  return DECFLOAT;
@@ -1149,7 +1142,7 @@ parse_number (p, len, parsed_float, puti
 	{
 	  p[len - 2] = '\0';
 	  putithere->typed_val_decfloat.type
-	    = builtin_type (current_gdbarch)->builtin_declong;
+	    = parse_type->builtin_declong;
 	  decimal_from_string (putithere->typed_val_decfloat.val, 16, p);
 	  p[len - 2] = 'd';
 	  return DECFLOAT;
@@ -1164,7 +1157,7 @@ parse_number (p, len, parsed_float, puti
 
       if (num == 1)
 	putithere->typed_val_float.type = 
-	  builtin_type (current_gdbarch)->builtin_double;
+	  parse_type->builtin_double;
 
       if (num == 2 )
 	{
@@ -1172,10 +1165,10 @@ parse_number (p, len, parsed_float, puti
 	     double.  */
 	  if (!strcasecmp (s, "f"))
 	    putithere->typed_val_float.type = 
-	      builtin_type (current_gdbarch)->builtin_float;
+	      parse_type->builtin_float;
 	  else if (!strcasecmp (s, "l"))
 	    putithere->typed_val_float.type = 
-	      builtin_type (current_gdbarch)->builtin_long_double;
+	      parse_type->builtin_long_double;
 	  else
 	    {
 	      free (s);
@@ -1286,9 +1279,9 @@ parse_number (p, len, parsed_float, puti
 
   un = (ULONGEST)n >> 2;
   if (long_p == 0
-      && (un >> (gdbarch_int_bit (current_gdbarch) - 2)) == 0)
+      && (un >> (gdbarch_int_bit (parse_gdbarch) - 2)) == 0)
     {
-      high_bit = ((ULONGEST)1) << (gdbarch_int_bit (current_gdbarch) - 1);
+      high_bit = ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch) - 1);
 
       /* A large decimal (not hex or octal) constant (between INT_MAX
 	 and UINT_MAX) is a long or unsigned long, according to ANSI,
@@ -1296,28 +1289,28 @@ parse_number (p, len, parsed_float, puti
 	 int.  This probably should be fixed.  GCC gives a warning on
 	 such constants.  */
 
-      unsigned_type = builtin_type (current_gdbarch)->builtin_unsigned_int;
-      signed_type = builtin_type (current_gdbarch)->builtin_int;
+      unsigned_type = parse_type->builtin_unsigned_int;
+      signed_type = parse_type->builtin_int;
     }
   else if (long_p <= 1
-	   && (un >> (gdbarch_long_bit (current_gdbarch) - 2)) == 0)
+	   && (un >> (gdbarch_long_bit (parse_gdbarch) - 2)) == 0)
     {
-      high_bit = ((ULONGEST)1) << (gdbarch_long_bit (current_gdbarch) - 1);
-      unsigned_type = builtin_type (current_gdbarch)->builtin_unsigned_long;
-      signed_type = builtin_type (current_gdbarch)->builtin_long;
+      high_bit = ((ULONGEST)1) << (gdbarch_long_bit (parse_gdbarch) - 1);
+      unsigned_type = parse_type->builtin_unsigned_long;
+      signed_type = parse_type->builtin_long;
     }
   else
     {
       int shift;
       if (sizeof (ULONGEST) * HOST_CHAR_BIT 
-	  < gdbarch_long_long_bit (current_gdbarch))
+	  < gdbarch_long_long_bit (parse_gdbarch))
 	/* A long long does not fit in a LONGEST.  */
 	shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1);
       else
-	shift = (gdbarch_long_long_bit (current_gdbarch) - 1);
+	shift = (gdbarch_long_long_bit (parse_gdbarch) - 1);
       high_bit = (ULONGEST) 1 << shift;
-      unsigned_type = builtin_type (current_gdbarch)->builtin_unsigned_long_long;
-      signed_type = builtin_type (current_gdbarch)->builtin_long_long;
+      unsigned_type = parse_type->builtin_unsigned_long_long;
+      signed_type = parse_type->builtin_long_long;
     }
 
    putithere->typed_val_int.val = n;
@@ -1490,7 +1483,7 @@ yylex ()
         }
 
       yylval.typed_val_int.val = c;
-      yylval.typed_val_int.type = builtin_type (current_gdbarch)->builtin_char;
+      yylval.typed_val_int.type = parse_type->builtin_char;
 
       c = *lexptr++;
       if (c != '\'')
@@ -1742,7 +1735,7 @@ yylex ()
     case 8:
       if (strncmp (tokstart, "unsigned", 8) == 0)
 	return UNSIGNED;
-      if (current_language->la_language == language_cplus
+      if (parse_language->la_language == language_cplus
 	  && strncmp (tokstart, "template", 8) == 0)
 	return TEMPLATE;
       if (strncmp (tokstart, "volatile", 8) == 0)
@@ -1759,7 +1752,7 @@ yylex ()
 	return DOUBLE_KEYWORD;
       break;
     case 5:
-      if (current_language->la_language == language_cplus)
+      if (parse_language->la_language == language_cplus)
         {
           if (strncmp (tokstart, "false", 5) == 0)
             return FALSEKEYWORD;
@@ -1778,7 +1771,7 @@ yylex ()
 	return ENUM;
       if (strncmp (tokstart, "long", 4) == 0)
 	return LONG;
-      if (current_language->la_language == language_cplus)
+      if (parse_language->la_language == language_cplus)
           {
             if (strncmp (tokstart, "true", 4) == 0)
               return TRUEKEYWORD;
@@ -1814,7 +1807,7 @@ yylex ()
 
     sym = lookup_symbol (tmp, expression_context_block,
 			 VAR_DOMAIN,
-			 current_language->la_language == language_cplus
+			 parse_language->la_language == language_cplus
 			 ? &is_a_field_of_this : (int *) NULL);
     /* Call lookup_symtab, not lookup_partial_symtab, in case there are
        no psymtabs (coff, xcoff, or some future change to blow away the
@@ -1847,8 +1840,8 @@ yylex ()
 	  return TYPENAME;
         }
     yylval.tsym.type
-      = language_lookup_primitive_type_by_name (current_language,
-						current_gdbarch, tmp);
+      = language_lookup_primitive_type_by_name (parse_language,
+						parse_gdbarch, tmp);
     if (yylval.tsym.type != NULL)
       return TYPENAME;
 
Index: gdb-head/gdb/f-exp.y
===================================================================
--- gdb-head.orig/gdb/f-exp.y
+++ gdb-head/gdb/f-exp.y
@@ -57,6 +57,9 @@ Boston, MA 02110-1301, USA.  */
 #include "block.h"
 #include <ctype.h>
 
+#define parse_type builtin_type (parse_gdbarch)
+#define parse_f_type builtin_f_type (parse_gdbarch)
+
 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
    as well as gratuitiously global symbol names, so we can have multiple
    yacc generated parsers in gdb.  Note that these are only the variables
@@ -325,7 +328,9 @@ complexnum:     exp ',' exp 
         ;
 
 exp	:	'(' complexnum ')'
-                	{ write_exp_elt_opcode(OP_COMPLEX); }
+                	{ write_exp_elt_opcode(OP_COMPLEX);
+			  write_exp_elt_type (parse_f_type->builtin_complex_s16);
+                	  write_exp_elt_opcode(OP_COMPLEX); }
 	;
 
 exp	:	'(' type ')' exp  %prec UNARY
@@ -447,7 +452,7 @@ exp	:	NAME_OR_INT
 
 exp	:	FLOAT
 			{ write_exp_elt_opcode (OP_DOUBLE);
-			  write_exp_elt_type (builtin_type_f_real_s8);
+			  write_exp_elt_type (parse_f_type->builtin_real_s8);
 			  write_exp_elt_dblcst ($1);
 			  write_exp_elt_opcode (OP_DOUBLE); }
 	;
@@ -460,7 +465,7 @@ exp	:	VARIABLE
 
 exp	:	SIZEOF '(' type ')'	%prec UNARY
 			{ write_exp_elt_opcode (OP_LONG);
-			  write_exp_elt_type (builtin_type_f_integer);
+			  write_exp_elt_type (parse_f_type->builtin_integer);
 			  CHECK_TYPEDEF ($3);
 			  write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
 			  write_exp_elt_opcode (OP_LONG); }
@@ -510,11 +515,7 @@ variable:	name_not_typename
 			      msymbol =
 				lookup_minimal_symbol (arg, NULL, NULL);
 			      if (msymbol != NULL)
-				{
-				  write_exp_msymbol (msymbol,
-						     lookup_function_type (builtin_type_int),
-						     builtin_type_int);
-				}
+				write_exp_msymbol (msymbol);
 			      else if (!have_full_symbols () && !have_partial_symbols ())
 				error ("No symbol table is loaded.  Use the \"file\" command.");
 			      else
@@ -555,8 +556,8 @@ ptype	:	typebase
 			  {
 			    range_type =
 			      create_range_type ((struct type *) NULL,
-						 builtin_type_f_integer, 0,
-						 array_size - 1);
+						 parse_f_type->builtin_integer,
+						 0, array_size - 1);
 			    follow_type =
 			      create_array_type ((struct type *) NULL,
 						 follow_type, range_type);
@@ -601,29 +602,29 @@ typebase  /* Implements (approximately):
 	:	TYPENAME
 			{ $$ = $1.type; }
 	|	INT_KEYWORD
-			{ $$ = builtin_type_f_integer; }
+			{ $$ = parse_f_type->builtin_integer; }
 	|	INT_S2_KEYWORD 
-			{ $$ = builtin_type_f_integer_s2; }
+			{ $$ = parse_f_type->builtin_integer_s2; }
 	|	CHARACTER 
-			{ $$ = builtin_type_f_character; }
+			{ $$ = parse_f_type->builtin_character; }
 	|	LOGICAL_KEYWORD 
-			{ $$ = builtin_type_f_logical;} 
+			{ $$ = parse_f_type->builtin_logical; }
 	|	LOGICAL_S2_KEYWORD
-			{ $$ = builtin_type_f_logical_s2;}
+			{ $$ = parse_f_type->builtin_logical_s2; }
 	|	LOGICAL_S1_KEYWORD 
-			{ $$ = builtin_type_f_logical_s1;}
+			{ $$ = parse_f_type->builtin_logical_s1; }
 	|	REAL_KEYWORD 
-			{ $$ = builtin_type_f_real;}
+			{ $$ = parse_f_type->builtin_real; }
 	|       REAL_S8_KEYWORD
-			{ $$ = builtin_type_f_real_s8;}
+			{ $$ = parse_f_type->builtin_real_s8; }
 	|	REAL_S16_KEYWORD
-			{ $$ = builtin_type_f_real_s16;}
+			{ $$ = parse_f_type->builtin_real_s16; }
 	|	COMPLEX_S8_KEYWORD
-			{ $$ = builtin_type_f_complex_s8;}
+			{ $$ = parse_f_type->builtin_complex_s8; }
 	|	COMPLEX_S16_KEYWORD 
-			{ $$ = builtin_type_f_complex_s16;}
+			{ $$ = parse_f_type->builtin_complex_s16; }
 	|	COMPLEX_S32_KEYWORD 
-			{ $$ = builtin_type_f_complex_s32;}
+			{ $$ = parse_f_type->builtin_complex_s32; }
 	;
 
 nonempty_typelist
@@ -766,26 +767,26 @@ parse_number (p, len, parsed_float, puti
      target int size is different to the target long size.
      
      In the expression below, we could have tested
-     (n >> gdbarch_int_bit (current_gdbarch))
+     (n >> gdbarch_int_bit (parse_gdbarch))
      to see if it was zero,
      but too many compilers warn about that, when ints and longs
      are the same size.  So we shift it twice, with fewer bits
      each time, for the same result.  */
   
-  if ((gdbarch_int_bit (current_gdbarch) != gdbarch_long_bit (current_gdbarch)
+  if ((gdbarch_int_bit (parse_gdbarch) != gdbarch_long_bit (parse_gdbarch)
        && ((n >> 2)
-	   >> (gdbarch_int_bit (current_gdbarch)-2))) /* Avoid shift warning */
+	   >> (gdbarch_int_bit (parse_gdbarch)-2))) /* Avoid shift warning */
       || long_p)
     {
-      high_bit = ((ULONGEST)1) << (gdbarch_long_bit (current_gdbarch)-1);
-      unsigned_type = builtin_type_unsigned_long;
-      signed_type = builtin_type_long;
+      high_bit = ((ULONGEST)1) << (gdbarch_long_bit (parse_gdbarch)-1);
+      unsigned_type = parse_type->builtin_unsigned_long;
+      signed_type = parse_type->builtin_long;
     }
   else 
     {
-      high_bit = ((ULONGEST)1) << (gdbarch_int_bit (current_gdbarch)-1);
-      unsigned_type = builtin_type_unsigned_int;
-      signed_type = builtin_type_int;
+      high_bit = ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch)-1);
+      unsigned_type = parse_type->builtin_unsigned_int;
+      signed_type = parse_type->builtin_int;
     }    
   
   putithere->typed_val.val = n;
@@ -1174,7 +1175,7 @@ yylex ()
     
     sym = lookup_symbol (tmp, expression_context_block,
 			 VAR_DOMAIN,
-			 current_language->la_language == language_cplus
+			 parse_language->la_language == language_cplus
 			 ? &is_a_field_of_this : NULL);
     if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
       {
@@ -1182,8 +1183,8 @@ yylex ()
 	return TYPENAME;
       }
     yylval.tsym.type
-      = language_lookup_primitive_type_by_name (current_language,
-						current_gdbarch, tmp);
+      = language_lookup_primitive_type_by_name (parse_language,
+						parse_gdbarch, tmp);
     if (yylval.tsym.type != NULL)
       return TYPENAME;
     
Index: gdb-head/gdb/jv-exp.y
===================================================================
--- gdb-head.orig/gdb/jv-exp.y
+++ gdb-head/gdb/jv-exp.y
@@ -51,6 +51,8 @@ Boston, MA 02110-1301, USA.  */
 #include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
 #include "block.h"
 
+#define parse_type builtin_type (parse_gdbarch)
+
 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
    as well as gratuitiously global symbol names, so we can have multiple
    yacc generated parsers in gdb.  Note that these are only the variables
@@ -723,9 +725,9 @@ parse_number (p, len, parsed_float, puti
       c = tolower (p[len - 1]);
 
       if (c == 'f' || c == 'F')
-	putithere->typed_val_float.type = builtin_type_float;
+	putithere->typed_val_float.type = parse_type->builtin_float;
       else if (isdigit (c) || c == '.' || c == 'd' || c == 'D')
-	putithere->typed_val_float.type = builtin_type_double;
+	putithere->typed_val_float.type = parse_type->builtin_double;
       else
 	return ERROR;
 
@@ -1397,11 +1399,7 @@ push_expression_name (name)
 
       msymbol = lookup_minimal_symbol (tmp, NULL, NULL);
       if (msymbol != NULL)
-	{
-	  write_exp_msymbol (msymbol,
-			     lookup_function_type (builtin_type_int),
-			     builtin_type_int);
-	}
+	write_exp_msymbol (msymbol);
       else if (!have_full_symbols () && !have_partial_symbols ())
 	error (_("No symbol table is loaded.  Use the \"file\" command"));
       else
Index: gdb-head/gdb/m2-exp.y
===================================================================
--- gdb-head.orig/gdb/m2-exp.y
+++ gdb-head/gdb/m2-exp.y
@@ -52,6 +52,9 @@ Boston, MA 02110-1301, USA.  */
 #include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
 #include "block.h"
 
+#define parse_type builtin_type (parse_gdbarch)
+#define parse_m2_type builtin_m2_type (parse_gdbarch)
+
 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
    as well as gratuitiously global symbol names, so we can have multiple
    yacc generated parsers in gdb.  Note that these are only the variables
@@ -497,7 +500,7 @@ exp	:	M2_FALSE
 
 exp	:	INT
 			{ write_exp_elt_opcode (OP_LONG);
-			  write_exp_elt_type (builtin_type_m2_int);
+			  write_exp_elt_type (parse_m2_type->builtin_int);
 			  write_exp_elt_longcst ((LONGEST) $1);
 			  write_exp_elt_opcode (OP_LONG); }
 	;
@@ -505,7 +508,7 @@ exp	:	INT
 exp	:	UINT
 			{
 			  write_exp_elt_opcode (OP_LONG);
-			  write_exp_elt_type (builtin_type_m2_card);
+			  write_exp_elt_type (parse_m2_type->builtin_card);
 			  write_exp_elt_longcst ((LONGEST) $1);
 			  write_exp_elt_opcode (OP_LONG);
 			}
@@ -513,7 +516,7 @@ exp	:	UINT
 
 exp	:	CHAR
 			{ write_exp_elt_opcode (OP_LONG);
-			  write_exp_elt_type (builtin_type_m2_char);
+			  write_exp_elt_type (parse_m2_type->builtin_char);
 			  write_exp_elt_longcst ((LONGEST) $1);
 			  write_exp_elt_opcode (OP_LONG); }
 	;
@@ -521,7 +524,7 @@ exp	:	CHAR
 
 exp	:	FLOAT
 			{ write_exp_elt_opcode (OP_DOUBLE);
-			  write_exp_elt_type (builtin_type_m2_real);
+			  write_exp_elt_type (parse_m2_type->builtin_real);
 			  write_exp_elt_dblcst ($1);
 			  write_exp_elt_opcode (OP_DOUBLE); }
 	;
@@ -531,7 +534,7 @@ exp	:	variable
 
 exp	:	SIZE '(' type ')'	%prec UNARY
 			{ write_exp_elt_opcode (OP_LONG);
-			  write_exp_elt_type (builtin_type_int);
+			  write_exp_elt_type (parse_type->builtin_int);
 			  write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
 			  write_exp_elt_opcode (OP_LONG); }
 	;
@@ -630,12 +633,7 @@ variable:	NAME
 			      msymbol =
 				lookup_minimal_symbol (arg, NULL, NULL);
 			      if (msymbol != NULL)
-				{
-				  write_exp_msymbol
-				    (msymbol,
-				     lookup_function_type (builtin_type_int),
-				     builtin_type_int);
-				}
+				write_exp_msymbol (msymbol);
 			      else if (!have_full_symbols () && !have_partial_symbols ())
 				error ("No symbol table is loaded.  Use the \"symbol-file\" command.");
 			      else
@@ -659,14 +657,14 @@ int
 overflow(a,b)
    long a,b;
 {
-   return (MAX_OF_TYPE(builtin_type_m2_int) - b) < a;
+   return (MAX_OF_TYPE(parse_m2_type->builtin_int) - b) < a;
 }
 
 int
 uoverflow(a,b)
    unsigned long a,b;
 {
-   return (MAX_OF_TYPE(builtin_type_m2_card) - b) < a;
+   return (MAX_OF_TYPE(parse_m2_type->builtin_card) - b) < a;
 }
 #endif /* FIXME */
 
Index: gdb-head/gdb/objc-exp.y
===================================================================
--- gdb-head.orig/gdb/objc-exp.y
+++ gdb-head/gdb/objc-exp.y
@@ -54,6 +54,8 @@
 #include "completer.h" /* For skip_quoted().  */
 #include "block.h"
 
+#define parse_type builtin_type (parse_gdbarch)
+
 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror,
    etc), as well as gratuitiously global symbol names, so we can have
    multiple yacc generated parsers in gdb.  Note that these are only
@@ -338,7 +340,7 @@ exp	: 	'[' TYPENAME
 			    error ("%s is not an ObjC Class", 
 				   copy_name ($2.stoken));
 			  write_exp_elt_opcode (OP_LONG);
-			  write_exp_elt_type (builtin_type_int);
+			  write_exp_elt_type (parse_type->builtin_int);
 			  write_exp_elt_longcst ((LONGEST) class);
 			  write_exp_elt_opcode (OP_LONG);
 			  start_msglist();
@@ -353,7 +355,7 @@ exp	: 	'[' TYPENAME
 exp	:	'[' CLASSNAME
 			{
 			  write_exp_elt_opcode (OP_LONG);
-			  write_exp_elt_type (builtin_type_int);
+			  write_exp_elt_type (parse_type->builtin_int);
 			  write_exp_elt_longcst ((LONGEST) $2.class);
 			  write_exp_elt_opcode (OP_LONG);
 			  start_msglist();
@@ -575,7 +577,7 @@ exp	:	SELECTOR 
 
 exp	:	SIZEOF '(' type ')'	%prec UNARY
 			{ write_exp_elt_opcode (OP_LONG);
-			  write_exp_elt_type (builtin_type_int);
+			  write_exp_elt_type (parse_type->builtin_int);
 			  CHECK_TYPEDEF ($3);
 			  write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
 			  write_exp_elt_opcode (OP_LONG); }
@@ -592,12 +594,12 @@ exp	:	STRING
 			  while (count-- > 0)
 			    {
 			      write_exp_elt_opcode (OP_LONG);
-			      write_exp_elt_type (builtin_type_char);
+			      write_exp_elt_type (parse_type->builtin_char);
 			      write_exp_elt_longcst ((LONGEST)(*sp++));
 			      write_exp_elt_opcode (OP_LONG);
 			    }
 			  write_exp_elt_opcode (OP_LONG);
-			  write_exp_elt_type (builtin_type_char);
+			  write_exp_elt_type (parse_type->builtin_char);
 			  write_exp_elt_longcst ((LONGEST)'\0');
 			  write_exp_elt_opcode (OP_LONG);
 			  write_exp_elt_opcode (OP_ARRAY);
@@ -715,16 +717,11 @@ variable:	qualified_name
 
 			  msymbol = lookup_minimal_symbol (name, NULL, NULL);
 			  if (msymbol != NULL)
-			    {
-			      write_exp_msymbol (msymbol,
-						 lookup_function_type (builtin_type_int),
-						 builtin_type_int);
-			    }
+			    write_exp_msymbol (msymbol);
+			  else if (!have_full_symbols () && !have_partial_symbols ())
+			    error ("No symbol table is loaded.  Use the \"file\" command.");
 			  else
-			    if (!have_full_symbols () && !have_partial_symbols ())
-			      error ("No symbol table is loaded.  Use the \"file\" command.");
-			    else
-			      error ("No symbol \"%s\" in current context.", name);
+			    error ("No symbol \"%s\" in current context.", name);
 			}
 	;
 
@@ -771,11 +768,7 @@ variable:	name_not_typename
 			      msymbol =
 				lookup_minimal_symbol (arg, NULL, NULL);
 			      if (msymbol != NULL)
-				{
-				  write_exp_msymbol (msymbol,
-						     lookup_function_type (builtin_type_int),
-						     builtin_type_int);
-				}
+				write_exp_msymbol (msymbol);
 			      else if (!have_full_symbols () && 
 				       !have_partial_symbols ())
 				error ("No symbol table is loaded.  Use the \"file\" command.");
@@ -869,31 +862,31 @@ typebase  /* Implements (approximately):
 			    $$ = $1.type;
 			}
 	|	INT_KEYWORD
-			{ $$ = builtin_type_int; }
+			{ $$ = parse_type->builtin_int; }
 	|	LONG
-			{ $$ = builtin_type_long; }
+			{ $$ = parse_type->builtin_long; }
 	|	SHORT
-			{ $$ = builtin_type_short; }
+			{ $$ = parse_type->builtin_short; }
 	|	LONG INT_KEYWORD
-			{ $$ = builtin_type_long; }
+			{ $$ = parse_type->builtin_long; }
 	|	UNSIGNED LONG INT_KEYWORD
-			{ $$ = builtin_type_unsigned_long; }
+			{ $$ = parse_type->builtin_unsigned_long; }
 	|	LONG LONG
-			{ $$ = builtin_type_long_long; }
+			{ $$ = parse_type->builtin_long_long; }
 	|	LONG LONG INT_KEYWORD
-			{ $$ = builtin_type_long_long; }
+			{ $$ = parse_type->builtin_long_long; }
 	|	UNSIGNED LONG LONG
-			{ $$ = builtin_type_unsigned_long_long; }
+			{ $$ = parse_type->builtin_unsigned_long_long; }
 	|	UNSIGNED LONG LONG INT_KEYWORD
-			{ $$ = builtin_type_unsigned_long_long; }
+			{ $$ = parse_type->builtin_unsigned_long_long; }
 	|	SHORT INT_KEYWORD
-			{ $$ = builtin_type_short; }
+			{ $$ = parse_type->builtin_short; }
 	|	UNSIGNED SHORT INT_KEYWORD
-			{ $$ = builtin_type_unsigned_short; }
+			{ $$ = parse_type->builtin_unsigned_short; }
 	|	DOUBLE_KEYWORD
-			{ $$ = builtin_type_double; }
+			{ $$ = parse_type->builtin_double; }
 	|	LONG DOUBLE_KEYWORD
-			{ $$ = builtin_type_long_double; }
+			{ $$ = parse_type->builtin_long_double; }
 	|	STRUCT name
 			{ $$ = lookup_struct (copy_name ($2),
 					      expression_context_block); }
@@ -909,11 +902,11 @@ typebase  /* Implements (approximately):
 	|	UNSIGNED typename
 			{ $$ = lookup_unsigned_typename (TYPE_NAME($2.type)); }
 	|	UNSIGNED
-			{ $$ = builtin_type_unsigned_int; }
+			{ $$ = parse_type->builtin_unsigned_int; }
 	|	SIGNED_KEYWORD typename
 			{ $$ = lookup_signed_typename (TYPE_NAME($2.type)); }
 	|	SIGNED_KEYWORD
-			{ $$ = builtin_type_int; }
+			{ $$ = parse_type->builtin_int; }
 	|	TEMPLATE name '<' type '>'
 			{ $$ = lookup_template_type(copy_name($2), $4,
 						    expression_context_block);
@@ -930,19 +923,19 @@ typename:	TYPENAME
 		{
 		  $$.stoken.ptr = "int";
 		  $$.stoken.length = 3;
-		  $$.type = builtin_type_int;
+		  $$.type = parse_type->builtin_int;
 		}
 	|	LONG
 		{
 		  $$.stoken.ptr = "long";
 		  $$.stoken.length = 4;
-		  $$.type = builtin_type_long;
+		  $$.type = parse_type->builtin_long;
 		}
 	|	SHORT
 		{
 		  $$.stoken.ptr = "short";
 		  $$.stoken.length = 5;
-		  $$.type = builtin_type_short;
+		  $$.type = parse_type->builtin_short;
 		}
 	;
 
@@ -1028,11 +1021,11 @@ parse_number (p, len, parsed_float, puti
       c = tolower (p[len - 1]);
 
       if (c == 'f')
-	putithere->typed_val_float.type = builtin_type_float;
+	putithere->typed_val_float.type = parse_type->builtin_float;
       else if (c == 'l')
-	putithere->typed_val_float.type = builtin_type_long_double;
+	putithere->typed_val_float.type = parse_type->builtin_long_double;
       else if (isdigit (c) || c == '.')
-	putithere->typed_val_float.type = builtin_type_double;
+	putithere->typed_val_float.type = parse_type->builtin_double;
       else
 	return ERROR;
 
@@ -1138,9 +1131,9 @@ parse_number (p, len, parsed_float, puti
 
   un = (unsigned LONGEST)n >> 2;
   if (long_p == 0
-      && (un >> (gdbarch_int_bit (current_gdbarch) - 2)) == 0)
+      && (un >> (gdbarch_int_bit (parse_gdbarch) - 2)) == 0)
     {
-      high_bit = ((unsigned LONGEST)1) << (gdbarch_int_bit (current_gdbarch) - 1);
+      high_bit = ((unsigned LONGEST)1) << (gdbarch_int_bit (parse_gdbarch) - 1);
 
       /* A large decimal (not hex or octal) constant (between INT_MAX
 	 and UINT_MAX) is a long or unsigned long, according to ANSI,
@@ -1148,28 +1141,28 @@ parse_number (p, len, parsed_float, puti
 	 int.  This probably should be fixed.  GCC gives a warning on
 	 such constants.  */
 
-      unsigned_type = builtin_type_unsigned_int;
-      signed_type = builtin_type_int;
+      unsigned_type = parse_type->builtin_unsigned_int;
+      signed_type = parse_type->builtin_int;
     }
   else if (long_p <= 1
-	   && (un >> (gdbarch_long_bit (current_gdbarch) - 2)) == 0)
+	   && (un >> (gdbarch_long_bit (parse_gdbarch) - 2)) == 0)
     {
-      high_bit = ((unsigned LONGEST)1) << (gdbarch_long_bit (current_gdbarch) - 1);
-      unsigned_type = builtin_type_unsigned_long;
-      signed_type = builtin_type_long;
+      high_bit = ((unsigned LONGEST)1) << (gdbarch_long_bit (parse_gdbarch) - 1);
+      unsigned_type = parse_type->builtin_unsigned_long;
+      signed_type = parse_type->builtin_long;
     }
   else
     {
       high_bit = (((unsigned LONGEST)1)
-		  << (gdbarch_long_long_bit (current_gdbarch) - 32 - 1)
+		  << (gdbarch_long_long_bit (parse_gdbarch) - 32 - 1)
 		  << 16
 		  << 16);
       if (high_bit == 0)
 	/* A long long does not fit in a LONGEST.  */
 	high_bit =
 	  (unsigned LONGEST)1 << (sizeof (LONGEST) * HOST_CHAR_BIT - 1);
-      unsigned_type = builtin_type_unsigned_long_long;
-      signed_type = builtin_type_long_long;
+      unsigned_type = parse_type->builtin_unsigned_long_long;
+      signed_type = parse_type->builtin_long_long;
     }
 
    putithere->typed_val_int.val = n;
@@ -1285,7 +1278,7 @@ yylex ()
 	error ("Empty character constant.");
 
       yylval.typed_val_int.val = c;
-      yylval.typed_val_int.type = builtin_type_char;
+      yylval.typed_val_int.type = parse_type->builtin_char;
 
       c = *lexptr++;
       if (c != '\'')
@@ -1571,7 +1564,7 @@ yylex ()
     case 8:
       if (strncmp (tokstart, "unsigned", 8) == 0)
 	return UNSIGNED;
-      if (current_language->la_language == language_cplus
+      if (parse_language->la_language == language_cplus
 	  && strncmp (tokstart, "template", 8) == 0)
 	return TEMPLATE;
       if (strncmp (tokstart, "volatile", 8) == 0)
@@ -1588,7 +1581,7 @@ yylex ()
 	return DOUBLE_KEYWORD;
       break;
     case 5:
-      if ((current_language->la_language == language_cplus)
+      if ((parse_language->la_language == language_cplus)
 	  && strncmp (tokstart, "class", 5) == 0)
 	return CLASS;
       if (strncmp (tokstart, "union", 5) == 0)
@@ -1632,8 +1625,8 @@ yylex ()
     int is_a_field_of_this = 0, *need_this;
     int hextype;
 
-    if (current_language->la_language == language_cplus ||
-	current_language->la_language == language_objc)
+    if (parse_language->la_language == language_cplus ||
+	parse_language->la_language == language_objc)
       need_this = &is_a_field_of_this;
     else
       need_this = (int *) NULL;
@@ -1745,8 +1738,8 @@ yylex ()
 	  return TYPENAME;
         }
     yylval.tsym.type
-      = language_lookup_primitive_type_by_name (current_language,
-						current_gdbarch, tmp);
+      = language_lookup_primitive_type_by_name (parse_language,
+						parse_gdbarch, tmp);
     if (yylval.tsym.type != NULL)
       return TYPENAME;
 
Index: gdb-head/gdb/parse.c
===================================================================
--- gdb-head.orig/gdb/parse.c
+++ gdb-head/gdb/parse.c
@@ -400,16 +400,10 @@ write_exp_bitstring (struct stoken str)
 }
 
 /* Add the appropriate elements for a minimal symbol to the end of
-   the expression.  The rationale behind passing in text_symbol_type and
-   data_symbol_type was so that Modula-2 could pass in WORD for
-   data_symbol_type.  Perhaps it still is useful to have those types vary
-   based on the language, but they no longer have names like "int", so
-   the initial rationale is gone.  */
+   the expression.  */
 
 void
-write_exp_msymbol (struct minimal_symbol *msymbol, 
-		   struct type *text_symbol_type, 
-		   struct type *data_symbol_type)
+write_exp_msymbol (struct minimal_symbol *msymbol)
 {
   struct objfile *objfile = msymbol_objfile (msymbol);
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
@@ -436,7 +430,7 @@ write_exp_msymbol (struct minimal_symbol
 
   write_exp_elt_opcode (OP_LONG);
   /* Let's make the type big enough to hold a 64-bit address.  */
-  write_exp_elt_type (builtin_type_CORE_ADDR);
+  write_exp_elt_type (builtin_type (gdbarch)->builtin_core_addr);
   write_exp_elt_longcst ((LONGEST) addr);
   write_exp_elt_opcode (OP_LONG);
 
@@ -576,9 +570,7 @@ write_dollar_variable (struct stoken str
   msym = lookup_minimal_symbol (copy_name (str), NULL, NULL);
   if (msym)
     {
-      write_exp_msymbol (msym,
-			 lookup_function_type (builtin_type_int),
-			 builtin_type_int);
+      write_exp_msymbol (msym);
       return;
     }
 
@@ -775,7 +767,7 @@ operator_length_standard (struct express
       break;
 
     case OP_COMPLEX:
-      oplen = 1;
+      oplen = 3;
       args = 2;
       break;
 
@@ -1035,6 +1027,7 @@ parse_exp_in_context (char **stringptr, 
   expout = (struct expression *)
     xmalloc (sizeof (struct expression) + EXP_ELEM_TO_BYTES (expout_size));
   expout->language_defn = current_language;
+  expout->gdbarch = current_gdbarch;
 
   TRY_CATCH (except, RETURN_MASK_ALL)
     {
@@ -1269,7 +1262,7 @@ follow_types (struct type *follow_type)
 	   done with it.  */
 	range_type =
 	  create_range_type ((struct type *) NULL,
-			     builtin_type_int, 0,
+			     builtin_type_int32, 0,
 			     array_size >= 0 ? array_size - 1 : 0);
 	follow_type =
 	  create_array_type ((struct type *) NULL,
Index: gdb-head/gdb/parser-defs.h
===================================================================
--- gdb-head.orig/gdb/parser-defs.h
+++ gdb-head/gdb/parser-defs.h
@@ -32,6 +32,9 @@ extern struct expression *expout;
 extern int expout_size;
 extern int expout_ptr;
 
+#define parse_gdbarch (expout->gdbarch)
+#define parse_language (expout->language_defn)
+
 /* If this is nonzero, this block is used as the lexical context
    for symbol names.  */
 
@@ -133,8 +136,7 @@ extern void write_exp_elt_block (struct 
 
 extern void write_exp_elt_objfile (struct objfile *objfile);
 
-extern void write_exp_msymbol (struct minimal_symbol *,
-			       struct type *, struct type *);
+extern void write_exp_msymbol (struct minimal_symbol *);
 
 extern void write_dollar_variable (struct stoken str);
 
Index: gdb-head/gdb/p-exp.y
===================================================================
--- gdb-head.orig/gdb/p-exp.y
+++ gdb-head/gdb/p-exp.y
@@ -58,6 +58,8 @@ Boston, MA 02110-1301, USA.  */
 #include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
 #include "block.h"
 
+#define parse_type builtin_type (parse_gdbarch)
+
 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
    as well as gratuitiously global symbol names, so we can have multiple
    yacc generated parsers in gdb.  Note that these are only the variables
@@ -381,8 +383,8 @@ exp	:	exp '/' {
 			      && is_integral_type (current_type))
 			    {
 			      write_exp_elt_opcode (UNOP_CAST);
-			      write_exp_elt_type (builtin_type_long_double);
-			      current_type = builtin_type_long_double;
+			      write_exp_elt_type (parse_type->builtin_long_double);
+			      current_type = parse_type->builtin_long_double;
 			      write_exp_elt_opcode (UNOP_CAST);
 			      leftdiv_is_integer = 0;
 			    }
@@ -417,37 +419,37 @@ exp	:	exp RSH exp
 
 exp	:	exp '=' exp
 			{ write_exp_elt_opcode (BINOP_EQUAL); 
-			  current_type = builtin_type_bool;
+			  current_type = parse_type->builtin_bool;
 			}
 	;
 
 exp	:	exp NOTEQUAL exp
 			{ write_exp_elt_opcode (BINOP_NOTEQUAL); 
-			  current_type = builtin_type_bool;
+			  current_type = parse_type->builtin_bool;
 			}
 	;
 
 exp	:	exp LEQ exp
 			{ write_exp_elt_opcode (BINOP_LEQ); 
-			  current_type = builtin_type_bool;
+			  current_type = parse_type->builtin_bool;
 			}
 	;
 
 exp	:	exp GEQ exp
 			{ write_exp_elt_opcode (BINOP_GEQ); 
-			  current_type = builtin_type_bool;
+			  current_type = parse_type->builtin_bool;
 			}
 	;
 
 exp	:	exp '<' exp
 			{ write_exp_elt_opcode (BINOP_LESS); 
-			  current_type = builtin_type_bool;
+			  current_type = parse_type->builtin_bool;
 			}
 	;
 
 exp	:	exp '>' exp
 			{ write_exp_elt_opcode (BINOP_GTR); 
-			  current_type = builtin_type_bool;
+			  current_type = parse_type->builtin_bool;
 			}
 	;
 
@@ -470,14 +472,14 @@ exp	:	exp ASSIGN exp
 exp	:	TRUEKEYWORD
 			{ write_exp_elt_opcode (OP_BOOL);
 			  write_exp_elt_longcst ((LONGEST) $1);
-			  current_type = builtin_type_bool;
+			  current_type = parse_type->builtin_bool;
 			  write_exp_elt_opcode (OP_BOOL); }
 	;
 
 exp	:	FALSEKEYWORD
 			{ write_exp_elt_opcode (OP_BOOL);
 			  write_exp_elt_longcst ((LONGEST) $1);
-			  current_type = builtin_type_bool;
+			  current_type = parse_type->builtin_bool;
 			  write_exp_elt_opcode (OP_BOOL); }
 	;
 
@@ -518,7 +520,7 @@ exp	:	VARIABLE
 
 exp	:	SIZEOF '(' type ')'	%prec UNARY
 			{ write_exp_elt_opcode (OP_LONG);
-			  write_exp_elt_type (builtin_type_int);
+			  write_exp_elt_type (parse_type->builtin_int);
 			  CHECK_TYPEDEF ($3);
 			  write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
 			  write_exp_elt_opcode (OP_LONG); }
@@ -534,12 +536,12 @@ exp	:	STRING
 			  while (count-- > 0)
 			    {
 			      write_exp_elt_opcode (OP_LONG);
-			      write_exp_elt_type (builtin_type_char);
+			      write_exp_elt_type (parse_type->builtin_char);
 			      write_exp_elt_longcst ((LONGEST)(*sp++));
 			      write_exp_elt_opcode (OP_LONG);
 			    }
 			  write_exp_elt_opcode (OP_LONG);
-			  write_exp_elt_type (builtin_type_char);
+			  write_exp_elt_type (parse_type->builtin_char);
 			  write_exp_elt_longcst ((LONGEST)'\0');
 			  write_exp_elt_opcode (OP_LONG);
 			  write_exp_elt_opcode (OP_ARRAY);
@@ -654,16 +656,11 @@ variable:	qualified_name
 
 			  msymbol = lookup_minimal_symbol (name, NULL, NULL);
 			  if (msymbol != NULL)
-			    {
-			      write_exp_msymbol (msymbol,
-						 lookup_function_type (builtin_type_int),
-						 builtin_type_int);
-			    }
+			    write_exp_msymbol (msymbol);
+			  else if (!have_full_symbols () && !have_partial_symbols ())
+			    error ("No symbol table is loaded.  Use the \"file\" command.");
 			  else
-			    if (!have_full_symbols () && !have_partial_symbols ())
-			      error ("No symbol table is loaded.  Use the \"file\" command.");
-			    else
-			      error ("No symbol \"%s\" in current context.", name);
+			    error ("No symbol \"%s\" in current context.", name);
 			}
 	;
 
@@ -725,11 +722,7 @@ variable:	name_not_typename
 			      msymbol =
 				lookup_minimal_symbol (arg, NULL, NULL);
 			      if (msymbol != NULL)
-				{
-				  write_exp_msymbol (msymbol,
-						     lookup_function_type (builtin_type_int),
-						     builtin_type_int);
-				}
+				write_exp_msymbol (msymbol);
 			      else if (!have_full_symbols () && !have_partial_symbols ())
 				error ("No symbol table is loaded.  Use the \"file\" command.");
 			      else
@@ -841,11 +834,11 @@ parse_number (p, len, parsed_float, puti
       c = tolower (p[len - 1]);
 
       if (c == 'f')
-	putithere->typed_val_float.type = builtin_type_float;
+	putithere->typed_val_float.type = parse_type->builtin_float;
       else if (c == 'l')
-	putithere->typed_val_float.type = builtin_type_long_double;
+	putithere->typed_val_float.type = parse_type->builtin_long_double;
       else if (isdigit (c) || c == '.')
-	putithere->typed_val_float.type = builtin_type_double;
+	putithere->typed_val_float.type = parse_type->builtin_double;
       else
 	return ERROR;
 
@@ -951,9 +944,9 @@ parse_number (p, len, parsed_float, puti
 
   un = (ULONGEST)n >> 2;
   if (long_p == 0
-      && (un >> (gdbarch_int_bit (current_gdbarch) - 2)) == 0)
+      && (un >> (gdbarch_int_bit (parse_gdbarch) - 2)) == 0)
     {
-      high_bit = ((ULONGEST)1) << (gdbarch_int_bit (current_gdbarch) - 1);
+      high_bit = ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch) - 1);
 
       /* A large decimal (not hex or octal) constant (between INT_MAX
 	 and UINT_MAX) is a long or unsigned long, according to ANSI,
@@ -961,28 +954,28 @@ parse_number (p, len, parsed_float, puti
 	 int.  This probably should be fixed.  GCC gives a warning on
 	 such constants.  */
 
-      unsigned_type = builtin_type_unsigned_int;
-      signed_type = builtin_type_int;
+      unsigned_type = parse_type->builtin_unsigned_int;
+      signed_type = parse_type->builtin_int;
     }
   else if (long_p <= 1
-	   && (un >> (gdbarch_long_bit (current_gdbarch) - 2)) == 0)
+	   && (un >> (gdbarch_long_bit (parse_gdbarch) - 2)) == 0)
     {
-      high_bit = ((ULONGEST)1) << (gdbarch_long_bit (current_gdbarch) - 1);
-      unsigned_type = builtin_type_unsigned_long;
-      signed_type = builtin_type_long;
+      high_bit = ((ULONGEST)1) << (gdbarch_long_bit (parse_gdbarch) - 1);
+      unsigned_type = parse_type->builtin_unsigned_long;
+      signed_type = parse_type->builtin_long;
     }
   else
     {
       int shift;
       if (sizeof (ULONGEST) * HOST_CHAR_BIT
-	  < gdbarch_long_long_bit (current_gdbarch))
+	  < gdbarch_long_long_bit (parse_gdbarch))
 	/* A long long does not fit in a LONGEST.  */
 	shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1);
       else
-	shift = (gdbarch_long_long_bit (current_gdbarch) - 1);
+	shift = (gdbarch_long_long_bit (parse_gdbarch) - 1);
       high_bit = (ULONGEST) 1 << shift;
-      unsigned_type = builtin_type_unsigned_long_long;
-      signed_type = builtin_type_long_long;
+      unsigned_type = parse_type->builtin_unsigned_long_long;
+      signed_type = parse_type->builtin_long_long;
     }
 
    putithere->typed_val_int.val = n;
@@ -1151,7 +1144,7 @@ yylex ()
 	error ("Empty character constant.");
 
       yylval.typed_val_int.val = c;
-      yylval.typed_val_int.type = builtin_type_char;
+      yylval.typed_val_int.type = parse_type->builtin_char;
 
       c = *lexptr++;
       if (c != '\'')
@@ -1645,8 +1638,8 @@ yylex ()
 	  return TYPENAME;
         }
     yylval.tsym.type
-      = language_lookup_primitive_type_by_name (current_language,
-						current_gdbarch, tmp);
+      = language_lookup_primitive_type_by_name (parse_language,
+						parse_gdbarch, tmp);
     if (yylval.tsym.type != NULL)
       {
 	free (uptokstart);
Index: gdb-head/gdb/ada-lex.l
===================================================================
--- gdb-head.orig/gdb/ada-lex.l
+++ gdb-head/gdb/ada-lex.l
@@ -351,11 +351,11 @@ processInt (const char *base0, const cha
       exp -= 1;
     }
 
-  if ((result >> (gdbarch_int_bit (current_gdbarch)-1)) == 0)
+  if ((result >> (gdbarch_int_bit (parse_gdbarch)-1)) == 0)
     yylval.typed_val.type = type_int ();
-  else if ((result >> (gdbarch_long_bit (current_gdbarch)-1)) == 0)
+  else if ((result >> (gdbarch_long_bit (parse_gdbarch)-1)) == 0)
     yylval.typed_val.type = type_long ();
-  else if (((result >> (gdbarch_long_bit (current_gdbarch)-1)) >> 1) == 0)
+  else if (((result >> (gdbarch_long_bit (parse_gdbarch)-1)) >> 1) == 0)
     {
       /* We have a number representable as an unsigned integer quantity.
          For consistency with the C treatment, we will treat it as an
@@ -364,7 +364,8 @@ processInt (const char *base0, const cha
          for the mess, but C doesn't officially guarantee that a simple
          assignment does the trick (no, it doesn't; read the reference manual).
        */
-      yylval.typed_val.type = builtin_type_unsigned_long;
+      yylval.typed_val.type
+	= builtin_type (parse_gdbarch)->builtin_unsigned_long;
       if (result & LONGEST_SIGN)
 	yylval.typed_val.val =
 	  (LONGEST) (result & ~LONGEST_SIGN)
@@ -386,10 +387,10 @@ processReal (const char *num0)
   sscanf (num0, "%" DOUBLEST_SCAN_FORMAT, &yylval.typed_val_float.dval);
 
   yylval.typed_val_float.type = type_float ();
-  if (sizeof(DOUBLEST) >= gdbarch_double_bit (current_gdbarch)
+  if (sizeof(DOUBLEST) >= gdbarch_double_bit (parse_gdbarch)
 			    / TARGET_CHAR_BIT)
     yylval.typed_val_float.type = type_double ();
-  if (sizeof(DOUBLEST) >= gdbarch_long_double_bit (current_gdbarch)
+  if (sizeof(DOUBLEST) >= gdbarch_long_double_bit (parse_gdbarch)
 			    / TARGET_CHAR_BIT)
     yylval.typed_val_float.type = type_long_double ();
 
Index: gdb-head/gdb/expression.h
===================================================================
--- gdb-head.orig/gdb/expression.h
+++ gdb-head/gdb/expression.h
@@ -193,8 +193,9 @@ enum exp_opcode
        indicates that we have found something of the form <name> ( <stuff> ) */
     OP_F77_UNDETERMINED_ARGLIST,
 
-    /* The following OP is a special one, it introduces a F77 complex
-       literal. It is followed by exactly two args that are doubles.  */
+    /* OP_COMPLEX takes a type in the following element, followed by another
+       OP_COMPLEX, making three exp_elements.  It is followed by two double
+       args, and converts them into a complex number of the given type. */
     OP_COMPLEX,
 
     /* OP_STRING represents a string constant.
@@ -373,6 +374,7 @@ union exp_element
 struct expression
   {
     const struct language_defn *language_defn;	/* language it was entered in */
+    struct gdbarch *gdbarch;  /* architecture it was parsed in */
     int nelts;
     union exp_element elts[1];
   };
Index: gdb-head/gdb/eval.c
===================================================================
--- gdb-head.orig/gdb/eval.c
+++ gdb-head/gdb/eval.c
@@ -439,6 +439,220 @@ value_f90_subarray (struct value *array,
   return value_slice (array, low_bound, high_bound - low_bound + 1);
 }
 
+
+/* Promote value ARG1 as appropriate before performing a unary operation
+   on this argument.
+   If the result is not appropriate for any particular language then it
+   needs to patch this function.  */
+
+void
+unop_promote (const struct language_defn *language, struct gdbarch *gdbarch,
+	      struct value **arg1)
+{
+  struct type *type1;
+
+  *arg1 = coerce_ref (*arg1);
+  type1 = check_typedef (value_type (*arg1));
+
+  if (is_integral_type (type1))
+    {
+      switch (language->la_language)
+	{
+	default:
+	  /* Perform integral promotion for ANSI C/C++.
+	     If not appropropriate for any particular language
+	     it needs to modify this function.  */
+	  {
+	    struct type *builtin_int = builtin_type (gdbarch)->builtin_int;
+	    if (TYPE_LENGTH (type1) < TYPE_LENGTH (builtin_int))
+	      *arg1 = value_cast (builtin_int, *arg1);
+	  }
+	  break;
+	}
+    }
+}
+
+/* Promote values ARG1 and ARG2 as appropriate before performing a binary
+   operation on those two operands.
+   If the result is not appropriate for any particular language then it
+   needs to patch this function.  */
+
+void
+binop_promote (const struct language_defn *language, struct gdbarch *gdbarch,
+	       struct value **arg1, struct value **arg2)
+{
+  struct type *promoted_type = NULL;
+  struct type *type1;
+  struct type *type2;
+
+  *arg1 = coerce_ref (*arg1);
+  *arg2 = coerce_ref (*arg2);
+
+  type1 = check_typedef (value_type (*arg1));
+  type2 = check_typedef (value_type (*arg2));
+
+  if ((TYPE_CODE (type1) != TYPE_CODE_FLT
+       && TYPE_CODE (type1) != TYPE_CODE_DECFLOAT
+       && !is_integral_type (type1))
+      || (TYPE_CODE (type2) != TYPE_CODE_FLT
+	  && TYPE_CODE (type2) != TYPE_CODE_DECFLOAT
+	  && !is_integral_type (type2)))
+    return;
+
+  if (TYPE_CODE (type1) == TYPE_CODE_DECFLOAT
+      || TYPE_CODE (type2) == TYPE_CODE_DECFLOAT)
+    {
+      /* No promotion required.  */
+    }
+  else if (TYPE_CODE (type1) == TYPE_CODE_FLT
+	   || TYPE_CODE (type2) == TYPE_CODE_FLT)
+    {
+      switch (language->la_language)
+	{
+	case language_c:
+	case language_cplus:
+	case language_asm:
+	case language_objc:
+	  /* No promotion required.  */
+	  break;
+
+	default:
+	  /* For other languages the result type is unchanged from gdb
+	     version 6.7 for backward compatibility.
+	     If either arg was long double, make sure that value is also long
+	     double.  Otherwise use double.  */
+	  if (TYPE_LENGTH (type1) * 8 > gdbarch_double_bit (gdbarch)
+	      || TYPE_LENGTH (type2) * 8 > gdbarch_double_bit (gdbarch))
+	    promoted_type = builtin_type (gdbarch)->builtin_long_double;
+	  else
+	    promoted_type = builtin_type (gdbarch)->builtin_double;
+	  break;
+	}
+    }
+  else if (TYPE_CODE (type1) == TYPE_CODE_BOOL
+	   && TYPE_CODE (type2) == TYPE_CODE_BOOL)
+    {
+      /* No promotion required.  */
+    }
+  else
+    /* Integral operations here.  */
+    /* 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);
+      int is_unsigned1 = TYPE_UNSIGNED (type1);
+      int is_unsigned2 = TYPE_UNSIGNED (type2);
+      unsigned int result_len;
+      int unsigned_operation;
+
+      /* Determine type length and signedness after promotion for
+         both operands.  */
+      if (promoted_len1 < TYPE_LENGTH (builtin->builtin_int))
+	{
+	  is_unsigned1 = 0;
+	  promoted_len1 = TYPE_LENGTH (builtin->builtin_int);
+	}
+      if (promoted_len2 < TYPE_LENGTH (builtin->builtin_int))
+	{
+	  is_unsigned2 = 0;
+	  promoted_len2 = TYPE_LENGTH (builtin->builtin_int);
+	}
+
+      if (promoted_len1 > promoted_len2)
+	{
+	  unsigned_operation = is_unsigned1;
+	  result_len = promoted_len1;
+	}
+      else if (promoted_len2 > promoted_len1)
+	{
+	  unsigned_operation = is_unsigned2;
+	  result_len = promoted_len2;
+	}
+      else
+	{
+	  unsigned_operation = is_unsigned1 || is_unsigned2;
+	  result_len = promoted_len1;
+	}
+
+      switch (language->la_language)
+	{
+	case language_c:
+	case language_cplus:
+	case language_asm:
+	case language_objc:
+	  if (result_len <= TYPE_LENGTH (builtin->builtin_int))
+	    {
+	      promoted_type = (unsigned_operation
+			       ? builtin->builtin_unsigned_int
+			       : builtin->builtin_int);
+	    }
+	  else if (result_len <= TYPE_LENGTH (builtin->builtin_long))
+	    {
+	      promoted_type = (unsigned_operation
+			       ? builtin->builtin_unsigned_long
+			       : builtin->builtin_long);
+	    }
+	  else
+	    {
+	      promoted_type = (unsigned_operation
+			       ? builtin->builtin_unsigned_long_long
+			       : builtin->builtin_long_long);
+	    }
+	  break;
+
+	default:
+	  /* For other languages the result type is unchanged from gdb
+	     version 6.7 for backward compatibility.
+	     If either arg was long long, make sure that value is also long
+	     long.  Otherwise use long.  */
+	  if (unsigned_operation)
+	    {
+	      if (result_len > gdbarch_long_bit (gdbarch) / HOST_CHAR_BIT)
+		promoted_type = builtin->builtin_unsigned_long_long;
+	      else
+		promoted_type = builtin->builtin_unsigned_long;
+	    }
+	  else
+	    {
+	      if (result_len > gdbarch_long_bit (gdbarch) / HOST_CHAR_BIT)
+		promoted_type = builtin->builtin_long_long;
+	      else
+		promoted_type = builtin->builtin_long;
+	    }
+	  break;
+	}
+    }
+
+  if (promoted_type)
+    {
+      /* Promote both operands to common type.  */
+      *arg1 = value_cast (promoted_type, *arg1);
+      *arg2 = value_cast (promoted_type, *arg2);
+    }
+}
+
+static int
+ptrmath_type_p (struct type *type)
+{
+  type = check_typedef (type);
+  if (TYPE_CODE (type) == TYPE_CODE_REF)
+    type = TYPE_TARGET_TYPE (type);
+
+  switch (TYPE_CODE (type))
+    {
+    case TYPE_CODE_PTR:
+    case TYPE_CODE_FUNC:
+      return 1;
+
+    case TYPE_CODE_ARRAY:
+      return current_language->c_style_arrays;
+
+    default:
+      return 0;
+    }
+}
+
 struct value *
 evaluate_subexp_standard (struct type *expect_type,
 			  struct expression *exp, int *pos,
@@ -562,8 +776,8 @@ evaluate_subexp_standard (struct type *e
       }
     case OP_BOOL:
       (*pos) += 2;
-      return value_from_longest (LA_BOOL_TYPE,
-				 exp->elts[pc + 1].longconst);
+      type = language_bool_type (exp->language_defn, exp->gdbarch);
+      return value_from_longest (type, exp->elts[pc + 1].longconst);
 
     case OP_INTERNALVAR:
       (*pos) += 2;
@@ -785,6 +999,7 @@ evaluate_subexp_standard (struct type *e
       {				/* Objective C @selector operator.  */
 	char *sel = &exp->elts[pc + 2].string;
 	int len = longest_to_int (exp->elts[pc + 1].longconst);
+	struct type *selector_type;
 
 	(*pos) += 3 + BYTES_TO_EXP_ELEM (len + 1);
 	if (noside == EVAL_SKIP)
@@ -792,8 +1007,9 @@ evaluate_subexp_standard (struct type *e
 
 	if (sel[len] != 0)
 	  sel[len] = 0;		/* Make sure it's terminated.  */
-	return value_from_longest (lookup_pointer_type (builtin_type_void),
-				   lookup_child_selector (sel));
+
+	selector_type = builtin_type (exp->gdbarch)->builtin_data_ptr;
+	return value_from_longest (selector_type, lookup_child_selector (sel));
       }
 
     case OP_OBJC_MSGCALL:
@@ -816,6 +1032,7 @@ evaluate_subexp_standard (struct type *e
 	struct value *called_method = NULL; 
 
 	struct type *selector_type = NULL;
+	struct type *long_type;
 
 	struct value *ret = NULL;
 	CORE_ADDR addr = 0;
@@ -827,7 +1044,9 @@ evaluate_subexp_standard (struct type *e
 
 	(*pos) += 3;
 
-	selector_type = lookup_pointer_type (builtin_type_void);
+	long_type = builtin_type (exp->gdbarch)->builtin_long;
+	selector_type = builtin_type (exp->gdbarch)->builtin_data_ptr;
+
 	if (noside == EVAL_AVOID_SIDE_EFFECTS)
 	  sub_no_side = EVAL_NORMAL;
 	else
@@ -836,7 +1055,7 @@ evaluate_subexp_standard (struct type *e
 	target = evaluate_subexp (selector_type, exp, pos, sub_no_side);
 
 	if (value_as_long (target) == 0)
- 	  return value_from_longest (builtin_type_long, 0);
+ 	  return value_from_longest (long_type, 0);
 	
 	if (lookup_minimal_symbol ("objc_msg_lookup", 0, 0))
 	  gnu_runtime = 1;
@@ -851,15 +1070,15 @@ evaluate_subexp_standard (struct type *e
 	   only).  */
 	if (gnu_runtime)
 	  {
-	    struct type *type;
-	    type = lookup_pointer_type (builtin_type_void);
+	    struct type *type = selector_type;
 	    type = lookup_function_type (type);
 	    type = lookup_pointer_type (type);
 	    type = lookup_function_type (type);
 	    type = lookup_pointer_type (type);
 
-	    msg_send = find_function_in_inferior ("objc_msg_lookup");
-	    msg_send_stret = find_function_in_inferior ("objc_msg_lookup");
+	    msg_send = find_function_in_inferior ("objc_msg_lookup", NULL);
+	    msg_send_stret
+	      = find_function_in_inferior ("objc_msg_lookup", NULL);
 
 	    msg_send = value_from_pointer (type, value_as_address (msg_send));
 	    msg_send_stret = value_from_pointer (type, 
@@ -867,9 +1086,10 @@ evaluate_subexp_standard (struct type *e
 	  }
 	else
 	  {
-	    msg_send = find_function_in_inferior ("objc_msgSend");
+	    msg_send = find_function_in_inferior ("objc_msgSend", NULL);
 	    /* Special dispatcher for methods returning structs */
-	    msg_send_stret = find_function_in_inferior ("objc_msgSend_stret");
+	    msg_send_stret
+	      = find_function_in_inferior ("objc_msgSend_stret", NULL);
 	  }
 
 	/* Verify the target object responds to this method. The
@@ -896,8 +1116,8 @@ evaluate_subexp_standard (struct type *e
 
 	argvec[0] = msg_send;
 	argvec[1] = target;
-	argvec[2] = value_from_longest (builtin_type_long, responds_selector);
-	argvec[3] = value_from_longest (builtin_type_long, selector);
+	argvec[2] = value_from_longest (long_type, responds_selector);
+	argvec[3] = value_from_longest (long_type, selector);
 	argvec[4] = 0;
 
 	ret = call_function_by_hand (argvec[0], 3, argvec + 1);
@@ -918,8 +1138,8 @@ evaluate_subexp_standard (struct type *e
 
 	argvec[0] = msg_send;
 	argvec[1] = target;
-	argvec[2] = value_from_longest (builtin_type_long, method_selector);
-	argvec[3] = value_from_longest (builtin_type_long, selector);
+	argvec[2] = value_from_longest (long_type, method_selector);
+	argvec[3] = value_from_longest (long_type, selector);
 	argvec[4] = 0;
 
 	ret = call_function_by_hand (argvec[0], 3, argvec + 1);
@@ -1038,7 +1258,7 @@ evaluate_subexp_standard (struct type *e
 
 	argvec[0] = called_method;
 	argvec[1] = target;
-	argvec[2] = value_from_longest (builtin_type_long, selector);
+	argvec[2] = value_from_longest (long_type, selector);
 	/* User-supplied arguments.  */
 	for (tem = 0; tem < nargs; tem++)
 	  argvec[tem + 3] = evaluate_subexp_with_coercion (exp, pos, noside);
@@ -1369,10 +1589,11 @@ evaluate_subexp_standard (struct type *e
     case OP_COMPLEX:
       /* We have a complex number, There should be 2 floating 
          point numbers that compose it */
+      (*pos) += 2;
       arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
       arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
 
-      return value_literal_complex (arg1, arg2, builtin_type_f_complex_s16);
+      return value_literal_complex (arg1, arg2, exp->elts[pc + 1].type);
 
     case STRUCTOP_STRUCT:
       tem = longest_to_int (exp->elts[pc + 1].longconst);
@@ -1505,12 +1726,24 @@ evaluate_subexp_standard (struct type *e
       op = exp->elts[pc + 1].opcode;
       if (binop_user_defined_p (op, arg1, arg2))
 	return value_x_binop (arg1, arg2, BINOP_ASSIGN_MODIFY, op, noside);
-      else if (op == BINOP_ADD)
-	arg2 = value_add (arg1, arg2);
-      else if (op == BINOP_SUB)
-	arg2 = value_sub (arg1, arg2);
+      else if (op == BINOP_ADD && ptrmath_type_p (value_type (arg1)))
+	arg2 = value_ptradd (arg1, arg2);
+      else if (op == BINOP_SUB && ptrmath_type_p (value_type (arg1)))
+	arg2 = value_ptrsub (arg1, arg2);
       else
-	arg2 = value_binop (arg1, arg2, op);
+	{
+	  struct value *tmp = arg1;
+
+	  /* For shift and integer exponentiation operations,
+	     only promote the first argument.  */
+	  if ((op == BINOP_LSH || op == BINOP_RSH || op == BINOP_EXP)
+	      && is_integral_type (value_type (arg2)))
+	    unop_promote (exp->language_defn, exp->gdbarch, &tmp);
+	  else
+	    binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2);
+
+	  arg2 = value_binop (tmp, arg2, op);
+	}
       return value_assign (arg1, arg2);
 
     case BINOP_ADD:
@@ -1520,8 +1753,15 @@ evaluate_subexp_standard (struct type *e
 	goto nosideret;
       if (binop_user_defined_p (op, arg1, arg2))
 	return value_x_binop (arg1, arg2, op, OP_NULL, noside);
+      else if (ptrmath_type_p (value_type (arg1)))
+	return value_ptradd (arg1, arg2);
+      else if (ptrmath_type_p (value_type (arg2)))
+	return value_ptradd (arg2, arg1);
       else
-	return value_add (arg1, arg2);
+	{
+	  binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
+	  return value_binop (arg1, arg2, BINOP_ADD);
+	}
 
     case BINOP_SUB:
       arg1 = evaluate_subexp_with_coercion (exp, pos, noside);
@@ -1530,8 +1770,22 @@ evaluate_subexp_standard (struct type *e
 	goto nosideret;
       if (binop_user_defined_p (op, arg1, arg2))
 	return value_x_binop (arg1, arg2, op, OP_NULL, noside);
+      else if (ptrmath_type_p (value_type (arg1))
+	       && ptrmath_type_p (value_type (arg2)))
+	{
+	  /* FIXME -- should be ptrdiff_t */
+	  type = builtin_type (exp->gdbarch)->builtin_long;
+	  return value_from_longest (type, value_ptrdiff (arg1, arg2));
+	}
+      else if (ptrmath_type_p (value_type (arg1)))
+	return value_ptrsub (arg1, arg2);
+      else if (ptrmath_type_p (value_type (arg2)))
+	return value_ptrsub (arg2, arg1);
       else
-	return value_sub (arg1, arg2);
+	{
+	  binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
+	  return value_binop (arg1, arg2, BINOP_SUB);
+	}
 
     case BINOP_EXP:
     case BINOP_MUL:
@@ -1568,11 +1822,22 @@ evaluate_subexp_standard (struct type *e
 	      struct value *v_one, *retval;
 
 	      v_one = value_one (value_type (arg2), not_lval);
+	      binop_promote (exp->language_defn, exp->gdbarch, &arg1, &v_one);
 	      retval = value_binop (arg1, v_one, op);
 	      return retval;
 	    }
 	  else
-	    return value_binop (arg1, arg2, op);
+	    {
+	      /* For shift and integer exponentiation operations,
+		 only promote the first argument.  */
+	      if ((op == BINOP_LSH || op == BINOP_RSH || op == BINOP_EXP)
+		  && is_integral_type (value_type (arg2)))
+		unop_promote (exp->language_defn, exp->gdbarch, &arg1);
+	      else
+		binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
+
+	      return value_binop (arg1, arg2, op);
+	    }
 	}
 
     case BINOP_RANGE:
@@ -1618,7 +1883,8 @@ evaluate_subexp_standard (struct type *e
       arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
       if (noside == EVAL_SKIP)
 	goto nosideret;
-      return value_in (arg1, arg2);
+      type = language_bool_type (exp->language_defn, exp->gdbarch);
+      return value_from_longest (type, (LONGEST) value_in (arg1, arg2));
 
     case MULTI_SUBSCRIPT:
       (*pos) += 2;
@@ -1666,7 +1932,29 @@ evaluate_subexp_standard (struct type *e
 	    }
 	  else
 	    {
-	      arg1 = value_subscript (arg1, arg2);
+	      arg1 = coerce_ref (arg1);
+	      type = check_typedef (value_type (arg1));
+
+	      switch (TYPE_CODE (type))
+		{
+		case TYPE_CODE_PTR:
+		case TYPE_CODE_ARRAY:
+		case TYPE_CODE_STRING:
+		  arg1 = value_subscript (arg1, arg2);
+		  break;
+
+		case TYPE_CODE_BITSTRING:
+		  type = language_bool_type (exp->language_defn, exp->gdbarch);
+		  arg1 = value_bitstring_subscript (type, arg1, arg2);
+		  break;
+
+		default:
+		  if (TYPE_NAME (type))
+		    error (_("cannot subscript something of type `%s'"),
+			   TYPE_NAME (type));
+		  else
+		    error (_("cannot subscript requested type"));
+		}
 	    }
 	}
       return (arg1);
@@ -1742,7 +2030,7 @@ evaluate_subexp_standard (struct type *e
 
 	/* Construct a value node with the value of the offset */
 
-	arg2 = value_from_longest (builtin_type_f_integer, offset_item);
+	arg2 = value_from_longest (builtin_type_int32, offset_item);
 
 	/* Let us now play a dirty trick: we will take arg1 
 	   which is a value node pointing to the topmost level
@@ -1777,7 +2065,8 @@ evaluate_subexp_standard (struct type *e
 	  tem = value_logical_not (arg1);
 	  arg2 = evaluate_subexp (NULL_TYPE, exp, pos,
 				  (tem ? EVAL_SKIP : noside));
-	  return value_from_longest (LA_BOOL_TYPE,
+	  type = language_bool_type (exp->language_defn, exp->gdbarch);
+	  return value_from_longest (type,
 			     (LONGEST) (!tem && !value_logical_not (arg2)));
 	}
 
@@ -1803,7 +2092,8 @@ evaluate_subexp_standard (struct type *e
 	  tem = value_logical_not (arg1);
 	  arg2 = evaluate_subexp (NULL_TYPE, exp, pos,
 				  (!tem ? EVAL_SKIP : noside));
-	  return value_from_longest (LA_BOOL_TYPE,
+	  type = language_bool_type (exp->language_defn, exp->gdbarch);
+	  return value_from_longest (type,
 			     (LONGEST) (!tem || !value_logical_not (arg2)));
 	}
 
@@ -1818,8 +2108,10 @@ evaluate_subexp_standard (struct type *e
 	}
       else
 	{
+	  binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
 	  tem = value_equal (arg1, arg2);
-	  return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem);
+	  type = language_bool_type (exp->language_defn, exp->gdbarch);
+	  return value_from_longest (type, (LONGEST) tem);
 	}
 
     case BINOP_NOTEQUAL:
@@ -1833,8 +2125,10 @@ evaluate_subexp_standard (struct type *e
 	}
       else
 	{
+	  binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
 	  tem = value_equal (arg1, arg2);
-	  return value_from_longest (LA_BOOL_TYPE, (LONGEST) ! tem);
+	  type = language_bool_type (exp->language_defn, exp->gdbarch);
+	  return value_from_longest (type, (LONGEST) ! tem);
 	}
 
     case BINOP_LESS:
@@ -1848,8 +2142,10 @@ evaluate_subexp_standard (struct type *e
 	}
       else
 	{
+	  binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
 	  tem = value_less (arg1, arg2);
-	  return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem);
+	  type = language_bool_type (exp->language_defn, exp->gdbarch);
+	  return value_from_longest (type, (LONGEST) tem);
 	}
 
     case BINOP_GTR:
@@ -1863,8 +2159,10 @@ evaluate_subexp_standard (struct type *e
 	}
       else
 	{
+	  binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
 	  tem = value_less (arg2, arg1);
-	  return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem);
+	  type = language_bool_type (exp->language_defn, exp->gdbarch);
+	  return value_from_longest (type, (LONGEST) tem);
 	}
 
     case BINOP_GEQ:
@@ -1878,8 +2176,10 @@ evaluate_subexp_standard (struct type *e
 	}
       else
 	{
+	  binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
 	  tem = value_less (arg2, arg1) || value_equal (arg1, arg2);
-	  return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem);
+	  type = language_bool_type (exp->language_defn, exp->gdbarch);
+	  return value_from_longest (type, (LONGEST) tem);
 	}
 
     case BINOP_LEQ:
@@ -1893,8 +2193,10 @@ evaluate_subexp_standard (struct type *e
 	}
       else
 	{
+	  binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
 	  tem = value_less (arg1, arg2) || value_equal (arg1, arg2);
-	  return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem);
+	  type = language_bool_type (exp->language_defn, exp->gdbarch);
+	  return value_from_longest (type, (LONGEST) tem);
 	}
 
     case BINOP_REPEAT:
@@ -1924,7 +2226,10 @@ evaluate_subexp_standard (struct type *e
       if (unop_user_defined_p (op, arg1))
 	return value_x_unop (arg1, op, noside);
       else
-	return value_pos (arg1);
+	{
+	  unop_promote (exp->language_defn, exp->gdbarch, &arg1);
+	  return value_pos (arg1);
+	}
       
     case UNOP_NEG:
       arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
@@ -1933,7 +2238,10 @@ evaluate_subexp_standard (struct type *e
       if (unop_user_defined_p (op, arg1))
 	return value_x_unop (arg1, op, noside);
       else
-	return value_neg (arg1);
+	{
+	  unop_promote (exp->language_defn, exp->gdbarch, &arg1);
+	  return value_neg (arg1);
+	}
 
     case UNOP_COMPLEMENT:
       /* C++: check for and handle destructor names.  */
@@ -1945,7 +2253,10 @@ evaluate_subexp_standard (struct type *e
       if (unop_user_defined_p (UNOP_COMPLEMENT, arg1))
 	return value_x_unop (arg1, UNOP_COMPLEMENT, noside);
       else
-	return value_complement (arg1);
+	{
+	  unop_promote (exp->language_defn, exp->gdbarch, &arg1);
+	  return value_complement (arg1);
+	}
 
     case UNOP_LOGICAL_NOT:
       arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
@@ -1954,8 +2265,10 @@ evaluate_subexp_standard (struct type *e
       if (unop_user_defined_p (op, arg1))
 	return value_x_unop (arg1, op, noside);
       else
-	return value_from_longest (LA_BOOL_TYPE,
-				   (LONGEST) value_logical_not (arg1));
+	{
+	  type = language_bool_type (exp->language_defn, exp->gdbarch);
+	  return value_from_longest (type, (LONGEST) value_logical_not (arg1));
+	}
 
     case UNOP_IND:
       if (expect_type && TYPE_CODE (expect_type) == TYPE_CODE_PTR)
@@ -1981,10 +2294,19 @@ evaluate_subexp_standard (struct type *e
 			       lval_memory);
 	  else if (TYPE_CODE (type) == TYPE_CODE_INT)
 	    /* GDB allows dereferencing an int.  */
-	    return value_zero (builtin_type_int, lval_memory);
+	    return value_zero (builtin_type (exp->gdbarch)->builtin_int,
+			       lval_memory);
 	  else
 	    error (_("Attempt to take contents of a non-pointer value."));
 	}
+
+      /* Allow * on an integer so we can cast it to whatever we want.
+	 This returns an int, which seems like the most C-like thing to
+	 do.  "long long" variables are rare enough that
+	 BUILTIN_TYPE_LONGEST would seem to be a mistake.  */
+      if (TYPE_CODE (type) == TYPE_CODE_INT)
+	return value_at_lazy (builtin_type (exp->gdbarch)->builtin_int,
+			      (CORE_ADDR) value_as_address (arg1));
       return value_ind (arg1);
 
     case UNOP_ADDR:
@@ -2057,8 +2379,16 @@ evaluate_subexp_standard (struct type *e
 	}
       else
 	{
-	  arg2 = value_add (arg1, value_from_longest (builtin_type_char,
-						      (LONGEST) 1));
+	  arg2 = value_from_longest (builtin_type_uint8, (LONGEST) 1);
+	  if (ptrmath_type_p (value_type (arg1)))
+	    arg2 = value_ptradd (arg1, arg2);
+	  else
+	    {
+	      struct value *tmp = arg1;
+	      binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2);
+	      arg2 = value_binop (tmp, arg2, BINOP_ADD);
+	    }
+
 	  return value_assign (arg1, arg2);
 	}
 
@@ -2072,8 +2402,16 @@ evaluate_subexp_standard (struct type *e
 	}
       else
 	{
-	  arg2 = value_sub (arg1, value_from_longest (builtin_type_char,
-						      (LONGEST) 1));
+	  arg2 = value_from_longest (builtin_type_uint8, (LONGEST) 1);
+	  if (ptrmath_type_p (value_type (arg1)))
+	    arg2 = value_ptrsub (arg1, arg2);
+	  else
+	    {
+	      struct value *tmp = arg1;
+	      binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2);
+	      arg2 = value_binop (tmp, arg2, BINOP_SUB);
+	    }
+
 	  return value_assign (arg1, arg2);
 	}
 
@@ -2087,8 +2425,16 @@ evaluate_subexp_standard (struct type *e
 	}
       else
 	{
-	  arg2 = value_add (arg1, value_from_longest (builtin_type_char,
-						      (LONGEST) 1));
+	  arg2 = value_from_longest (builtin_type_uint8, (LONGEST) 1);
+	  if (ptrmath_type_p (value_type (arg1)))
+	    arg2 = value_ptradd (arg1, arg2);
+	  else
+	    {
+	      struct value *tmp = arg1;
+	      binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2);
+	      arg2 = value_binop (tmp, arg2, BINOP_ADD);
+	    }
+
 	  value_assign (arg1, arg2);
 	  return arg1;
 	}
@@ -2103,8 +2449,16 @@ evaluate_subexp_standard (struct type *e
 	}
       else
 	{
-	  arg2 = value_sub (arg1, value_from_longest (builtin_type_char,
-						      (LONGEST) 1));
+	  arg2 = value_from_longest (builtin_type_uint8, (LONGEST) 1);
+	  if (ptrmath_type_p (value_type (arg1)))
+	    arg2 = value_ptrsub (arg1, arg2);
+	  else
+	    {
+	      struct value *tmp = arg1;
+	      binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2);
+	      arg2 = value_binop (tmp, arg2, BINOP_SUB);
+	    }
+
 	  value_assign (arg1, arg2);
 	  return arg1;
 	}
@@ -2143,7 +2497,7 @@ GDB does not (yet) know how to evaluate 
     }
 
 nosideret:
-  return value_from_longest (builtin_type_long, (LONGEST) 1);
+  return value_from_longest (builtin_type_int8, (LONGEST) 1);
 }
 
 /* Evaluate a subexpression of EXP, at index *POS,
@@ -2301,6 +2655,8 @@ evaluate_subexp_with_coercion (struct ex
 static struct value *
 evaluate_subexp_for_sizeof (struct expression *exp, int *pos)
 {
+  /* FIXME:  This should size_t.  */
+  struct type *size_type = builtin_type (exp->gdbarch)->builtin_int;
   enum exp_opcode op;
   int pc;
   struct type *type;
@@ -2324,24 +2680,22 @@ evaluate_subexp_for_sizeof (struct expre
 	  && TYPE_CODE (type) != TYPE_CODE_ARRAY)
 	error (_("Attempt to take contents of a non-pointer value."));
       type = check_typedef (TYPE_TARGET_TYPE (type));
-      return value_from_longest (builtin_type_int, (LONGEST)
-				 TYPE_LENGTH (type));
+      return value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type));
 
     case UNOP_MEMVAL:
       (*pos) += 3;
       type = check_typedef (exp->elts[pc + 1].type);
-      return value_from_longest (builtin_type_int,
-				 (LONGEST) TYPE_LENGTH (type));
+      return value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type));
 
     case OP_VAR_VALUE:
       (*pos) += 4;
       type = check_typedef (SYMBOL_TYPE (exp->elts[pc + 2].symbol));
       return
-	value_from_longest (builtin_type_int, (LONGEST) TYPE_LENGTH (type));
+	value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type));
 
     default:
       val = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
-      return value_from_longest (builtin_type_int,
+      return value_from_longest (size_type,
 				 (LONGEST) TYPE_LENGTH (value_type (val)));
     }
 }
Index: gdb-head/gdb/valarith.c
===================================================================
--- gdb-head.orig/gdb/valarith.c
+++ gdb-head/gdb/valarith.c
@@ -39,10 +39,6 @@
 #define TRUNCATION_TOWARDS_ZERO ((-5 / 2) == -2)
 #endif
 
-static struct type *unop_result_type (enum exp_opcode op, struct type *type1);
-static struct type *binop_result_type (enum exp_opcode op, struct type *type1,
-				       struct type *type2);
-
 void _initialize_valarith (void);
 
 
@@ -50,7 +46,7 @@ void _initialize_valarith (void);
    If the pointer type is void *, then return 1.
    If the target type is incomplete, then error out.
    This isn't a general purpose function, but just a 
-   helper for value_sub & value_add.
+   helper for value_ptrsub & value_ptradd.
 */
 
 static LONGEST
@@ -59,6 +55,7 @@ find_size_for_pointer_math (struct type 
   LONGEST sz = -1;
   struct type *ptr_target;
 
+  gdb_assert (TYPE_CODE (ptr_type) == TYPE_CODE_PTR);
   ptr_target = check_typedef (TYPE_TARGET_TYPE (ptr_type));
 
   sz = TYPE_LENGTH (ptr_target);
@@ -84,90 +81,73 @@ find_size_for_pointer_math (struct type 
   return sz;
 }
 
+/* Given a pointer ARG1 and an integral value ARG2, return the
+   result of C-style pointer arithmetic ARG1 + ARG2.  */
+
 struct value *
-value_add (struct value *arg1, struct value *arg2)
+value_ptradd (struct value *arg1, struct value *arg2)
 {
-  struct value *valint;
-  struct value *valptr;
+  struct type *valptrtype;
   LONGEST sz;
-  struct type *type1, *type2, *valptrtype;
 
   arg1 = coerce_array (arg1);
-  arg2 = coerce_array (arg2);
-  type1 = check_typedef (value_type (arg1));
-  type2 = check_typedef (value_type (arg2));
+  valptrtype = check_typedef (value_type (arg1));
+  sz = find_size_for_pointer_math (valptrtype);
 
-  if ((TYPE_CODE (type1) == TYPE_CODE_PTR
-       || TYPE_CODE (type2) == TYPE_CODE_PTR)
-      &&
-      (is_integral_type (type1) || is_integral_type (type2)))
-    /* Exactly one argument is a pointer, and one is an integer.  */
-    {
-      struct value *retval;
-
-      if (TYPE_CODE (type1) == TYPE_CODE_PTR)
-	{
-	  valptr = arg1;
-	  valint = arg2;
-	  valptrtype = type1;
-	}
-      else
-	{
-	  valptr = arg2;
-	  valint = arg1;
-	  valptrtype = type2;
-	}
+  if (!is_integral_type (value_type (arg2)))
+    error (_("Argument to arithmetic operation not a number or boolean."));
 
-      sz = find_size_for_pointer_math (valptrtype);
+  return value_from_pointer (valptrtype,
+			     value_as_address (arg1)
+			       + (sz * value_as_long (arg2)));
+}
 
-      retval = value_from_pointer (valptrtype,
-				   value_as_address (valptr)
-				   + (sz * value_as_long (valint)));
-      return retval;
-    }
+/* Given a pointer ARG1 and an integral value ARG2, return the
+   result of C-style pointer arithmetic ARG1 - ARG2.  */
+
+struct value *
+value_ptrsub (struct value *arg1, struct value *arg2)
+{
+  struct type *valptrtype;
+  LONGEST sz;
 
-  return value_binop (arg1, arg2, BINOP_ADD);
+  arg1 = coerce_array (arg1);
+  valptrtype = check_typedef (value_type (arg1));
+  sz = find_size_for_pointer_math (valptrtype);
+
+  if (!is_integral_type (value_type (arg2)))
+    error (_("Argument to arithmetic operation not a number or boolean."));
+
+  return value_from_pointer (valptrtype,
+			     value_as_address (arg1)
+			       - (sz * value_as_long (arg2)));
 }
 
-struct value *
-value_sub (struct value *arg1, struct value *arg2)
+/* Given two compatible pointer values ARG1 and ARG2, return the
+   result of C-style pointer arithmetic ARG1 - ARG2.  */
+
+LONGEST
+value_ptrdiff (struct value *arg1, struct value *arg2)
 {
   struct type *type1, *type2;
+  LONGEST sz;
+
   arg1 = coerce_array (arg1);
   arg2 = coerce_array (arg2);
   type1 = check_typedef (value_type (arg1));
   type2 = check_typedef (value_type (arg2));
 
-  if (TYPE_CODE (type1) == TYPE_CODE_PTR)
-    {
-      if (is_integral_type (type2))
-	{
-	  /* pointer - integer.  */
-	  LONGEST sz = find_size_for_pointer_math (type1);
+  gdb_assert (TYPE_CODE (type1) == TYPE_CODE_PTR);
+  gdb_assert (TYPE_CODE (type2) == TYPE_CODE_PTR);
 
-	  return value_from_pointer (type1,
-				     (value_as_address (arg1)
-				      - (sz * value_as_long (arg2))));
-	}
-      else if (TYPE_CODE (type2) == TYPE_CODE_PTR
-	       && TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type1)))
-	       == TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type2))))
-	{
-	  /* pointer to <type x> - pointer to <type x>.  */
-	  LONGEST sz = TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type1)));
-	  return value_from_longest
-	    (builtin_type_long,	/* FIXME -- should be ptrdiff_t */
-	     (value_as_long (arg1) - value_as_long (arg2)) / sz);
-	}
-      else
-	{
-	  error (_("\
+  if (TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type1)))
+      != TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type2))))
+    error (_("\
 First argument of `-' is a pointer and second argument is neither\n\
 an integer nor a pointer of the same type."));
-	}
-    }
 
-  return value_binop (arg1, arg2, BINOP_SUB);
+  sz = TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type1)));
+  return (value_as_long (arg1) - value_as_long (arg2)) / sz;
 }
 
 /* Return the value of ARRAY[IDX].
@@ -211,43 +191,15 @@ value_subscript (struct value *array, st
 
       if (lowerbound != 0)
 	{
-	  bound = value_from_longest (builtin_type_int, (LONGEST) lowerbound);
-	  idx = value_sub (idx, bound);
+	  bound = value_from_longest (value_type (idx), (LONGEST) lowerbound);
+	  idx = value_binop (idx, bound, BINOP_SUB);
 	}
 
       array = value_coerce_array (array);
     }
 
-  if (TYPE_CODE (tarray) == TYPE_CODE_BITSTRING)
-    {
-      struct type *range_type = TYPE_INDEX_TYPE (tarray);
-      LONGEST index = value_as_long (idx);
-      struct value *v;
-      int offset, byte, bit_index;
-      LONGEST lowerbound, upperbound;
-      get_discrete_bounds (range_type, &lowerbound, &upperbound);
-      if (index < lowerbound || index > upperbound)
-	error (_("bitstring index out of range"));
-      index -= lowerbound;
-      offset = index / TARGET_CHAR_BIT;
-      byte = *((char *) value_contents (array) + offset);
-      bit_index = index % TARGET_CHAR_BIT;
-      byte >>= (gdbarch_bits_big_endian (current_gdbarch) ?
-		TARGET_CHAR_BIT - 1 - bit_index : bit_index);
-      v = value_from_longest (LA_BOOL_TYPE, byte & 1);
-      set_value_bitpos (v, bit_index);
-      set_value_bitsize (v, 1);
-      VALUE_LVAL (v) = VALUE_LVAL (array);
-      if (VALUE_LVAL (array) == lval_internalvar)
-	VALUE_LVAL (v) = lval_internalvar_component;
-      VALUE_ADDRESS (v) = VALUE_ADDRESS (array);
-      VALUE_FRAME_ID (v) = VALUE_FRAME_ID (array);
-      set_value_offset (v, offset + value_offset (array));
-      return v;
-    }
-
   if (c_style)
-    return value_ind (value_add (array, idx));
+    return value_ind (value_ptradd (array, idx));
   else
     error (_("not an array or string"));
 }
@@ -286,6 +238,52 @@ value_subscripted_rvalue (struct value *
   set_value_offset (v, value_offset (array) + elt_offs);
   return v;
 }
+
+/* Return the value of BITSTRING[IDX] as (boolean) type TYPE.  */
+
+struct value *
+value_bitstring_subscript (struct type *type,
+			   struct value *bitstring, struct value *idx)
+{
+
+  struct type *bitstring_type, *range_type;
+  LONGEST index = value_as_long (idx);
+  struct value *v;
+  int offset, byte, bit_index;
+  LONGEST lowerbound, upperbound;
+
+  bitstring_type = check_typedef (value_type (bitstring));
+  gdb_assert (TYPE_CODE (bitstring_type) == TYPE_CODE_BITSTRING);
+
+  range_type = TYPE_INDEX_TYPE (bitstring_type);
+  get_discrete_bounds (range_type, &lowerbound, &upperbound);
+  if (index < lowerbound || index > upperbound)
+    error (_("bitstring index out of range"));
+
+  index -= lowerbound;
+  offset = index / TARGET_CHAR_BIT;
+  byte = *((char *) value_contents (bitstring) + offset);
+
+  bit_index = index % TARGET_CHAR_BIT;
+  byte >>= (gdbarch_bits_big_endian (current_gdbarch) ?
+	    TARGET_CHAR_BIT - 1 - bit_index : bit_index);
+
+  v = value_from_longest (type, byte & 1);
+
+  set_value_bitpos (v, bit_index);
+  set_value_bitsize (v, 1);
+
+  VALUE_LVAL (v) = VALUE_LVAL (bitstring);
+  if (VALUE_LVAL (bitstring) == lval_internalvar)
+    VALUE_LVAL (v) = lval_internalvar_component;
+  VALUE_ADDRESS (v) = VALUE_ADDRESS (bitstring);
+  VALUE_FRAME_ID (v) = VALUE_FRAME_ID (bitstring);
+
+  set_value_offset (v, offset + value_offset (bitstring));
+
+  return v;
+}
+
 
 /* Check to see if either argument is a structure, or a reference to
    one.  This is called so we know whether to go ahead with the normal
@@ -356,8 +354,6 @@ value_x_binop (struct value *arg1, struc
 
   arg1 = coerce_ref (arg1);
   arg2 = coerce_ref (arg2);
-  arg1 = coerce_enum (arg1);
-  arg2 = coerce_enum (arg2);
 
   /* now we know that what we have to do is construct our
      arg vector and find the right function to call it with.  */
@@ -517,7 +513,6 @@ value_x_unop (struct value *arg1, enum e
   int static_memfuncp, nargs;
 
   arg1 = coerce_ref (arg1);
-  arg1 = coerce_enum (arg1);
 
   /* now we know that what we have to do is construct our
      arg vector and find the right function to call it with.  */
@@ -546,13 +541,13 @@ value_x_unop (struct value *arg1, enum e
       break;
     case UNOP_POSTINCREMENT:
       strcpy (ptr, "++");
-      argvec[2] = value_from_longest (builtin_type_int, 0);
+      argvec[2] = value_from_longest (builtin_type_int8, 0);
       argvec[3] = 0;
       nargs ++;
       break;
     case UNOP_POSTDECREMENT:
       strcpy (ptr, "--");
-      argvec[2] = value_from_longest (builtin_type_int, 0);
+      argvec[2] = value_from_longest (builtin_type_int8, 0);
       argvec[3] = 0;
       nargs ++;
       break;
@@ -744,294 +739,6 @@ value_concat (struct value *arg1, struct
   return (outval);
 }
 
-/* Return result type of OP performed on TYPE1.
-   The result type follows ANSI C rules.
-   If the result is not appropropriate for any particular language then it
-   needs to patch this function to return the correct type.  */
-
-static struct type *
-unop_result_type (enum exp_opcode op, struct type *type1)
-{
-  struct type *result_type;
-
-  type1 = check_typedef (type1);
-  result_type = type1;
-
-  switch (op)
-    {
-    case UNOP_PLUS:
-    case UNOP_NEG:
-      break;
-    case UNOP_COMPLEMENT:
-      /* Reject floats and decimal floats.  */
-      if (!is_integral_type (type1))
-	error (_("Argument to complement operation not an integer or boolean."));
-      break;
-    default:
-      error (_("Invalid unary operation on numbers."));
-    }
-
-  if (TYPE_CODE (type1) == TYPE_CODE_DECFLOAT
-      || TYPE_CODE (type1) == TYPE_CODE_FLT)
-    {
-      return result_type;
-    }
-  else if (is_integral_type (type1))
-    {
-      /* Perform integral promotion for ANSI C/C++.
-	 If not appropropriate for any particular language it needs to
-	 modify this function to return the correct result for it.  */
-      if (TYPE_LENGTH (type1) < TYPE_LENGTH (builtin_type_int))
-	result_type = builtin_type_int;
-
-      return result_type;
-    }
-  else
-    {
-      error (_("Argument to unary operation not a number."));
-      return 0; /* For lint -- never reached */
-    }
-}
-
-/* Return result type of OP performed on TYPE1, TYPE2.
-   If the result is not appropropriate for any particular language then it
-   needs to patch this function to return the correct type.  */
-
-static struct type *
-binop_result_type (enum exp_opcode op, struct type *type1, struct type *type2)
-{
-  type1 = check_typedef (type1);
-  type2 = check_typedef (type2);
-
-  if ((TYPE_CODE (type1) != TYPE_CODE_FLT
-       && TYPE_CODE (type1) != TYPE_CODE_DECFLOAT
-       && !is_integral_type (type1))
-      ||
-      (TYPE_CODE (type2) != TYPE_CODE_FLT
-       && TYPE_CODE (type2) != TYPE_CODE_DECFLOAT
-       && !is_integral_type (type2)))
-    error (_("Argument to arithmetic operation not a number or boolean."));
-
-  if (TYPE_CODE (type1) == TYPE_CODE_DECFLOAT
-      || TYPE_CODE (type2) == TYPE_CODE_DECFLOAT)
-    {
-      switch (op)
-	{
-	case BINOP_ADD:
-	case BINOP_SUB:
-	case BINOP_MUL:
-	case BINOP_DIV:
-	case BINOP_EXP:
-	  break;
-	default:
-	  error (_("Operation not valid for decimal floating point number."));
-	}
-
-      if (TYPE_CODE (type1) != TYPE_CODE_DECFLOAT)
-	/* If type1 is not a decimal float, the type of the result is the type
-	   of the decimal float argument, type2.  */
-	return type2;
-      else if (TYPE_CODE (type2) != TYPE_CODE_DECFLOAT)
-	/* Same logic, for the case where type2 is not a decimal float.  */
-	return type1;
-      else
-	/* Both are decimal floats, the type of the result is the bigger
-	   of the two.  */
-	return (TYPE_LENGTH (type1) > TYPE_LENGTH (type2)) ? type1 : type2;
-    }
-  else if (TYPE_CODE (type1) == TYPE_CODE_FLT
-	   || TYPE_CODE (type2) == TYPE_CODE_FLT)
-    {
-      switch (op)
-	{
-	case BINOP_ADD:
-	case BINOP_SUB:
-	case BINOP_MUL:
-	case BINOP_DIV:
-	case BINOP_EXP:
-	case BINOP_MIN:
-	case BINOP_MAX:
-	  break;
-	default:
-	  error (_("Integer-only operation on floating point number."));
-	}
-
-      switch (current_language->la_language)
-	{
-	case language_c:
-	case language_cplus:
-	case language_asm:
-	case language_objc:
-	  /* Perform ANSI/ISO-C promotions.
-	     If only one type is float, use its type.
-	     Otherwise use the bigger type.  */
-	  if (TYPE_CODE (type1) != TYPE_CODE_FLT)
-	    return type2;
-	  else if (TYPE_CODE (type2) != TYPE_CODE_FLT)
-	    return type1;
-	  else
-	    return (TYPE_LENGTH (type1) > TYPE_LENGTH (type2)) ? type1 : type2;
-
-	default:
-	  /* For other languages the result type is unchanged from gdb
-	     version 6.7 for backward compatibility.
-	     If either arg was long double, make sure that value is also long
-	     double.  Otherwise use double.  */
-	  if (TYPE_LENGTH (type1) * 8 > gdbarch_double_bit (current_gdbarch)
-	      || TYPE_LENGTH (type2) * 8 > gdbarch_double_bit (current_gdbarch))
-	    return builtin_type_long_double;
-	  else
-	    return builtin_type_double;
-	}
-    }
-  else if (TYPE_CODE (type1) == TYPE_CODE_BOOL
-	   && TYPE_CODE (type2) == TYPE_CODE_BOOL)
-    {
-      switch (op)
-	{
-	case BINOP_BITWISE_AND:
-	case BINOP_BITWISE_IOR:
-	case BINOP_BITWISE_XOR:
-        case BINOP_EQUAL:
-        case BINOP_NOTEQUAL:
-	  break;
-	default:
-	  error (_("Invalid operation on booleans."));
-	}
-
-      return type1;
-    }
-  else
-    /* Integral operations here.  */
-    /* FIXME: Also mixed integral/booleans, with result an integer.  */
-    {
-      unsigned int promoted_len1 = TYPE_LENGTH (type1);
-      unsigned int promoted_len2 = TYPE_LENGTH (type2);
-      int is_unsigned1 = TYPE_UNSIGNED (type1);
-      int is_unsigned2 = TYPE_UNSIGNED (type2);
-      unsigned int result_len;
-      int unsigned_operation;
-
-      /* Determine type length and signedness after promotion for
-         both operands.  */
-      if (promoted_len1 < TYPE_LENGTH (builtin_type_int))
-	{
-	  is_unsigned1 = 0;
-	  promoted_len1 = TYPE_LENGTH (builtin_type_int);
-	}
-      if (promoted_len2 < TYPE_LENGTH (builtin_type_int))
-	{
-	  is_unsigned2 = 0;
-	  promoted_len2 = TYPE_LENGTH (builtin_type_int);
-	}
-
-      /* Determine type length of the result, and if the operation should
-	 be done unsigned.  For exponentiation and shift operators,
-	 use the length and type of the left operand.  Otherwise,
-	 use the signedness of the operand with the greater length.
-	 If both operands are of equal length, use unsigned operation
-	 if one of the operands is unsigned.  */
-      if (op == BINOP_RSH || op == BINOP_LSH || op == BINOP_EXP)
-	{
-	  /* In case of the shift operators and exponentiation the type of
-	     the result only depends on the type of the left operand.  */
-	  unsigned_operation = is_unsigned1;
-	  result_len = promoted_len1;
-	}
-      else if (promoted_len1 > promoted_len2)
-	{
-	  unsigned_operation = is_unsigned1;
-	  result_len = promoted_len1;
-	}
-      else if (promoted_len2 > promoted_len1)
-	{
-	  unsigned_operation = is_unsigned2;
-	  result_len = promoted_len2;
-	}
-      else
-	{
-	  unsigned_operation = is_unsigned1 || is_unsigned2;
-	  result_len = promoted_len1;
-	}
-
-      switch (op)
-	{
-	case BINOP_ADD:
-	case BINOP_SUB:
-	case BINOP_MUL:
-	case BINOP_DIV:
-	case BINOP_INTDIV:
-	case BINOP_EXP:
-	case BINOP_REM:
-	case BINOP_MOD:
-	case BINOP_LSH:
-	case BINOP_RSH:
-	case BINOP_BITWISE_AND:
-	case BINOP_BITWISE_IOR:
-	case BINOP_BITWISE_XOR:
-	case BINOP_LOGICAL_AND:
-	case BINOP_LOGICAL_OR:
-	case BINOP_MIN:
-	case BINOP_MAX:
-	case BINOP_EQUAL:
-	case BINOP_NOTEQUAL:
-	case BINOP_LESS:
-	  break;
-
-	default:
-	  error (_("Invalid binary operation on numbers."));
-	}
-
-      switch (current_language->la_language)
-	{
-	case language_c:
-	case language_cplus:
-	case language_asm:
-	case language_objc:
-	  if (result_len <= TYPE_LENGTH (builtin_type_int))
-	    {
-	      return (unsigned_operation
-		      ? builtin_type_unsigned_int
-		      : builtin_type_int);
-	    }
-	  else if (result_len <= TYPE_LENGTH (builtin_type_long))
-	    {
-	      return (unsigned_operation
-		      ? builtin_type_unsigned_long
-		      : builtin_type_long);
-	    }
-	  else
-	    {
-	      return (unsigned_operation
-		      ? builtin_type_unsigned_long_long
-		      : builtin_type_long_long);
-	    }
-
-	default:
-	  /* For other languages the result type is unchanged from gdb
-	     version 6.7 for backward compatibility.
-	     If either arg was long long, make sure that value is also long
-	     long.  Otherwise use long.  */
-	  if (unsigned_operation)
-	    {
-	      if (result_len > gdbarch_long_bit (current_gdbarch) / HOST_CHAR_BIT)
-		return builtin_type_unsigned_long_long;
-	      else
-		return builtin_type_unsigned_long;
-	    }
-	  else
-	    {
-	      if (result_len > gdbarch_long_bit (current_gdbarch) / HOST_CHAR_BIT)
-		return builtin_type_long_long;
-	      else
-		return builtin_type_long;
-	    }
-	}
-    }
-
-  return NULL; /* avoid -Wall warning */
-}
-
 /* Integer exponentiation: V1**V2, where both arguments are
    integers.  Requires V1 != 0 if V2 < 0.  Returns 1 for 0 ** 0.  */
 static LONGEST
@@ -1153,20 +860,30 @@ value_args_as_decimal (struct value *arg
    representations as integers or floats.  This includes booleans,
    characters, integers, or floats.
    Does not support addition and subtraction on pointers;
-   use value_add or value_sub if you want to handle those possibilities.  */
+   use value_ptradd, value_ptrsub or value_ptrdiff for those operations.  */
 
 struct value *
 value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
 {
   struct value *val;
-  struct type *result_type;
+  struct type *type1, *type2, *result_type;
 
   arg1 = coerce_ref (arg1);
   arg2 = coerce_ref (arg2);
 
-  result_type = binop_result_type (op, value_type (arg1), value_type (arg2));
+  type1 = check_typedef (value_type (arg1));
+  type2 = check_typedef (value_type (arg2));
 
-  if (TYPE_CODE (result_type) == TYPE_CODE_DECFLOAT)
+  if ((TYPE_CODE (type1) != TYPE_CODE_FLT
+       && TYPE_CODE (type1) != TYPE_CODE_DECFLOAT
+       && !is_integral_type (type1))
+      || (TYPE_CODE (type2) != TYPE_CODE_FLT
+	  && TYPE_CODE (type2) != TYPE_CODE_DECFLOAT
+	  && !is_integral_type (type2)))
+    error (_("Argument to arithmetic operation not a number or boolean."));
+
+  if (TYPE_CODE (type1) == TYPE_CODE_DECFLOAT
+      || TYPE_CODE (type2) == TYPE_CODE_DECFLOAT)
     {
       struct type *v_type;
       int len_v1, len_v2, len_v;
@@ -1189,9 +906,21 @@ value_binop (struct value *arg1, struct 
 	  error (_("Operation not valid for decimal floating point number."));
 	}
 
+      /* If only one type is decimal float, use its type.
+	 Otherwise use the bigger type.  */
+      if (TYPE_CODE (type1) != TYPE_CODE_DECFLOAT)
+	result_type = type2;
+      else if (TYPE_CODE (type2) != TYPE_CODE_DECFLOAT)
+	result_type = type1;
+      else if (TYPE_LENGTH (type2) > TYPE_LENGTH (type1))
+	result_type = type2;
+      else
+	result_type = type1;
+
       val = value_from_decfloat (result_type, v);
     }
-  else if (TYPE_CODE (result_type) == TYPE_CODE_FLT)
+  else if (TYPE_CODE (type1) == TYPE_CODE_FLT
+	   || TYPE_CODE (type2) == TYPE_CODE_FLT)
     {
       /* FIXME-if-picky-about-floating-accuracy: Should be doing this
          in target format.  real.c in GCC probably has the necessary
@@ -1237,10 +966,22 @@ value_binop (struct value *arg1, struct 
 	  error (_("Integer-only operation on floating point number."));
 	}
 
+      /* If only one type is float, use its type.
+	 Otherwise use the bigger type.  */
+      if (TYPE_CODE (type1) != TYPE_CODE_FLT)
+	result_type = type2;
+      else if (TYPE_CODE (type2) != TYPE_CODE_FLT)
+	result_type = type1;
+      else if (TYPE_LENGTH (type2) > TYPE_LENGTH (type1))
+	result_type = type2;
+      else
+	result_type = type1;
+
       val = allocate_value (result_type);
       store_typed_floating (value_contents_raw (val), value_type (val), v);
     }
-  else if (TYPE_CODE (result_type) == TYPE_CODE_BOOL)
+  else if (TYPE_CODE (type1) == TYPE_CODE_BOOL
+	   || TYPE_CODE (type2) == TYPE_CODE_BOOL)
     {
       LONGEST v1, v2, v = 0;
       v1 = value_as_long (arg1);
@@ -1272,6 +1013,8 @@ value_binop (struct value *arg1, struct 
 	  error (_("Invalid operation on booleans."));
 	}
 
+      result_type = type1;
+
       val = allocate_value (result_type);
       store_signed_integer (value_contents_raw (val),
 			    TYPE_LENGTH (result_type),
@@ -1280,31 +1023,32 @@ value_binop (struct value *arg1, struct 
   else
     /* Integral operations here.  */
     {
-      int unsigned_operation = TYPE_UNSIGNED (result_type);
+      /* Determine type length of the result, and if the operation should
+	 be done unsigned.  For exponentiation and shift operators,
+	 use the length and type of the left operand.  Otherwise,
+	 use the signedness of the operand with the greater length.
+	 If both operands are of equal length, use unsigned operation
+	 if one of the operands is unsigned.  */
+      if (op == BINOP_RSH || op == BINOP_LSH || op == BINOP_EXP)
+	result_type = type1;
+      else if (TYPE_LENGTH (type1) > TYPE_LENGTH (type2))
+	result_type = type1;
+      else if (TYPE_LENGTH (type2) > TYPE_LENGTH (type1))
+	result_type = type2;
+      else if (TYPE_UNSIGNED (type1))
+	result_type = type1;
+      else if (TYPE_UNSIGNED (type2))
+	result_type = type2;
+      else
+	result_type = type1;
 
-      if (unsigned_operation)
+      if (TYPE_UNSIGNED (result_type))
 	{
-	  unsigned int len1, len2, result_len;
 	  LONGEST v2_signed = value_as_long (arg2);
 	  ULONGEST v1, v2, v = 0;
 	  v1 = (ULONGEST) value_as_long (arg1);
 	  v2 = (ULONGEST) v2_signed;
 
-	  /* Truncate values to the type length of the result.
-	     Things are mildly tricky because binop_result_type may
-	     return a long which on amd64 is 8 bytes, and that's a problem if
-	     ARG1, ARG2 are both <= 4 bytes: we need to truncate the values
-	     at 4 bytes not 8.  So fetch the lengths of the original types
-	     and truncate at the larger of the two.  */
-	  len1 = TYPE_LENGTH (value_type (arg1));
-	  len2 = TYPE_LENGTH (value_type (arg1));
-	  result_len = len1 > len2 ? len1 : len2;
-	  if (result_len < sizeof (ULONGEST))
-	    {
-	      v1 &= ((LONGEST) 1 << HOST_CHAR_BIT * result_len) - 1;
-	      v2 &= ((LONGEST) 1 << HOST_CHAR_BIT * result_len) - 1;
-	    }
-
 	  switch (op)
 	    {
 	    case BINOP_ADD:
@@ -1535,7 +1279,7 @@ value_logical_not (struct value *arg1)
   const gdb_byte *p;
   struct type *type1;
 
-  arg1 = coerce_number (arg1);
+  arg1 = coerce_array (arg1);
   type1 = check_typedef (value_type (arg1));
 
   if (TYPE_CODE (type1) == TYPE_CODE_FLT)
@@ -1728,19 +1472,17 @@ struct value *
 value_pos (struct value *arg1)
 {
   struct type *type;
-  struct type *result_type;
 
   arg1 = coerce_ref (arg1);
   type = check_typedef (value_type (arg1));
-  result_type = unop_result_type (UNOP_PLUS, value_type (arg1));
 
   if (TYPE_CODE (type) == TYPE_CODE_FLT)
-    return value_from_double (result_type, value_as_double (arg1));
+    return value_from_double (type, value_as_double (arg1));
   else if (TYPE_CODE (type) == TYPE_CODE_DECFLOAT)
-    return value_from_decfloat (result_type, value_contents (arg1));
+    return value_from_decfloat (type, value_contents (arg1));
   else if (is_integral_type (type))
     {
-      return value_from_longest (result_type, value_as_long (arg1));
+      return value_from_longest (type, value_as_long (arg1));
     }
   else
     {
@@ -1753,15 +1495,13 @@ struct value *
 value_neg (struct value *arg1)
 {
   struct type *type;
-  struct type *result_type;
 
   arg1 = coerce_ref (arg1);
   type = check_typedef (value_type (arg1));
-  result_type = unop_result_type (UNOP_NEG, value_type (arg1));
 
   if (TYPE_CODE (type) == TYPE_CODE_DECFLOAT)
     {
-      struct value *val = allocate_value (result_type);
+      struct value *val = allocate_value (type);
       int len = TYPE_LENGTH (type);
       gdb_byte decbytes[16];  /* a decfloat is at most 128 bits long */
 
@@ -1776,10 +1516,10 @@ value_neg (struct value *arg1)
       return val;
     }
   else if (TYPE_CODE (type) == TYPE_CODE_FLT)
-    return value_from_double (result_type, -value_as_double (arg1));
+    return value_from_double (type, -value_as_double (arg1));
   else if (is_integral_type (type))
     {
-      return value_from_longest (result_type, -value_as_long (arg1));
+      return value_from_longest (type, -value_as_long (arg1));
     }
   else
     {
@@ -1792,16 +1532,14 @@ struct value *
 value_complement (struct value *arg1)
 {
   struct type *type;
-  struct type *result_type;
 
   arg1 = coerce_ref (arg1);
   type = check_typedef (value_type (arg1));
-  result_type = unop_result_type (UNOP_COMPLEMENT, value_type (arg1));
 
   if (!is_integral_type (type))
     error (_("Argument to complement operation not an integer or boolean."));
 
-  return value_from_longest (result_type, ~value_as_long (arg1));
+  return value_from_longest (type, ~value_as_long (arg1));
 }
 
 /* The INDEX'th bit of SET value whose value_type is TYPE,
@@ -1820,15 +1558,14 @@ value_bit_index (struct type *type, cons
   if (index < low_bound || index > high_bound)
     return -1;
   rel_index = index - low_bound;
-  word = unpack_long (builtin_type_unsigned_char,
-		      valaddr + (rel_index / TARGET_CHAR_BIT));
+  word = extract_unsigned_integer (valaddr + (rel_index / TARGET_CHAR_BIT), 1);
   rel_index %= TARGET_CHAR_BIT;
   if (gdbarch_bits_big_endian (current_gdbarch))
     rel_index = TARGET_CHAR_BIT - 1 - rel_index;
   return (word >> rel_index) & 1;
 }
 
-struct value *
+int
 value_in (struct value *element, struct value *set)
 {
   int member;
@@ -1847,7 +1584,7 @@ value_in (struct value *element, struct 
 			    value_as_long (element));
   if (member < 0)
     error (_("First argument of 'IN' not in range"));
-  return value_from_longest (LA_BOOL_TYPE, member);
+  return member;
 }
 
 void
Index: gdb-head/gdb/value.h
===================================================================
--- gdb-head.orig/gdb/value.h
+++ gdb-head/gdb/value.h
@@ -230,17 +230,11 @@ extern short *deprecated_value_regnum_ha
 extern struct value *coerce_ref (struct value *value);
 
 /* If ARG is an array, convert it to a pointer.
-   If ARG is an enum, convert it to an integer.
    If ARG is a function, convert it to a function pointer.
 
    References are dereferenced.  */
 
 extern struct value *coerce_array (struct value *value);
-extern struct value *coerce_number (struct value *value);
-
-/* If ARG is an enum, convert it to an integer.  */
-
-extern struct value *coerce_enum (struct value *value);
 
 /* Internal variables (variables for convenience of use of debugger)
    are recorded as a chain of these structures.  */
@@ -331,9 +325,11 @@ extern struct value *value_concat (struc
 extern struct value *value_binop (struct value *arg1, struct value *arg2,
 				  enum exp_opcode op);
 
-extern struct value *value_add (struct value *arg1, struct value *arg2);
+extern struct value *value_ptradd (struct value *arg1, struct value *arg2);
+
+extern struct value *value_ptrsub (struct value *arg1, struct value *arg2);
 
-extern struct value *value_sub (struct value *arg1, struct value *arg2);
+extern LONGEST value_ptrdiff (struct value *arg1, struct value *arg2);
 
 extern int value_must_coerce_to_target (struct value *arg1);
 
@@ -405,10 +401,14 @@ extern struct value *value_repeat (struc
 
 extern struct value *value_subscript (struct value *array, struct value *idx);
 
+extern struct value *value_bitstring_subscript (struct type *type,
+						struct value *bitstring,
+						struct value *idx);
+
 extern struct value *register_value_being_returned (struct type *valtype,
 						    struct regcache *retbuf);
 
-extern struct value *value_in (struct value *element, struct value *set);
+extern int value_in (struct value *element, struct value *set);
 
 extern int value_bit_index (struct type *type, const gdb_byte *addr,
 			    int index);
@@ -440,6 +440,14 @@ extern CORE_ADDR parse_and_eval_address_
 
 extern LONGEST parse_and_eval_long (char *exp);
 
+extern void unop_promote (const struct language_defn *language,
+			  struct gdbarch *gdbarch,
+			  struct value **arg1);
+
+extern void binop_promote (const struct language_defn *language,
+			   struct gdbarch *gdbarch,
+			   struct value **arg1, struct value **arg2);
+
 extern struct value *access_value_history (int num);
 
 extern struct value *value_of_internalvar (struct internalvar *var);
@@ -563,7 +571,8 @@ extern struct value *value_slice (struct
 extern struct value *value_literal_complex (struct value *, struct value *,
 					    struct type *);
 
-extern struct value *find_function_in_inferior (const char *);
+extern struct value *find_function_in_inferior (const char *,
+						struct objfile **);
 
 extern struct value *value_allocate_space_in_inferior (int);
 
Index: gdb-head/gdb/jv-lang.c
===================================================================
--- gdb-head.orig/gdb/jv-lang.c
+++ gdb-head/gdb/jv-lang.c
@@ -775,7 +775,7 @@ java_array_type (struct type *type, int 
 
   while (dims-- > 0)
     {
-      range_type = create_range_type (NULL, builtin_type_int, 0, 0);
+      range_type = create_range_type (NULL, builtin_type_int32, 0, 0);
       /* FIXME  This is bogus!  Java arrays are not gdb arrays! */
       type = create_array_type (NULL, type, range_type);
     }
@@ -855,6 +855,10 @@ evaluate_subexp_java (struct type *expec
 	}
       if (noside == EVAL_SKIP)
 	goto nosideret;
+      if (TYPE_CODE (value_type (arg1)) == TYPE_CODE_INT)
+        /* GDB allows dereferencing an int.  */
+        return value_at_lazy (builtin_type (exp->gdbarch)->builtin_int,
+                              (CORE_ADDR) value_as_address (arg1));
       return value_ind (arg1);
 
     case BINOP_SUBSCRIPT:
@@ -938,7 +942,7 @@ evaluate_subexp_java (struct type *expec
 standard:
   return evaluate_subexp_standard (expect_type, exp, pos, noside);
 nosideret:
-  return value_from_longest (builtin_type_long, (LONGEST) 1);
+  return value_from_longest (builtin_type_int8, (LONGEST) 1);
 }
 
 static char *java_demangle (const char *mangled, int options)
@@ -1040,6 +1044,51 @@ const struct op_print java_op_print_tab[
   {NULL, 0, 0, 0}
 };
 
+enum java_primitive_types
+{
+  java_primitive_type_int,
+  java_primitive_type_short,
+  java_primitive_type_long,
+  java_primitive_type_byte,
+  java_primitive_type_boolean,
+  java_primitive_type_char,
+  java_primitive_type_float,
+  java_primitive_type_double,
+  java_primitive_type_void,
+  nr_java_primitive_types
+};
+
+void
+java_language_arch_info (struct gdbarch *gdbarch,
+			 struct language_arch_info *lai)
+{
+  lai->string_char_type = java_char_type;
+  lai->primitive_type_vector
+    = GDBARCH_OBSTACK_CALLOC (gdbarch, nr_java_primitive_types + 1,
+                              struct type *);
+  lai->primitive_type_vector [java_primitive_type_int]
+    = java_int_type;
+  lai->primitive_type_vector [java_primitive_type_short]
+    = java_short_type;
+  lai->primitive_type_vector [java_primitive_type_long]
+    = java_long_type;
+  lai->primitive_type_vector [java_primitive_type_byte]
+    = java_byte_type;
+  lai->primitive_type_vector [java_primitive_type_boolean]
+    = java_boolean_type;
+  lai->primitive_type_vector [java_primitive_type_char]
+    = java_char_type;
+  lai->primitive_type_vector [java_primitive_type_float]
+    = java_float_type;
+  lai->primitive_type_vector [java_primitive_type_double]
+    = java_double_type;
+  lai->primitive_type_vector [java_primitive_type_void]
+    = java_void_type;
+
+  lai->bool_type_symbol = "boolean";
+  lai->bool_type_default = java_boolean_type;
+}
+
 const struct exp_descriptor exp_descriptor_java = 
 {
   print_subexp_standard,
@@ -1078,7 +1127,7 @@ const struct language_defn java_language
   0,				/* String lower bound */
   default_word_break_characters,
   default_make_symbol_completion_list,
-  c_language_arch_info,
+  java_language_arch_info,
   default_print_array_index,
   default_pass_by_reference,
   LANG_MAGIC
Index: gdb-head/gdb/ada-lang.c
===================================================================
--- gdb-head.orig/gdb/ada-lang.c
+++ gdb-head/gdb/ada-lang.c
@@ -212,7 +212,7 @@ static struct value *ada_coerce_ref (str
 
 static LONGEST pos_atr (struct value *);
 
-static struct value *value_pos_atr (struct value *);
+static struct value *value_pos_atr (struct type *, struct value *);
 
 static struct value *value_val_atr (struct type *, struct value *);
 
@@ -1768,7 +1768,7 @@ struct type *
 ada_coerce_to_simple_array_type (struct type *type)
 {
   struct value *mark = value_mark ();
-  struct value *dummy = value_from_longest (builtin_type_long, 0);
+  struct value *dummy = value_from_longest (builtin_type_int32, 0);
   struct type *result;
   deprecated_set_value_type (dummy, type);
   result = ada_type_of_array (dummy, 0);
@@ -1968,7 +1968,7 @@ value_subscript_packed (struct value *ar
               lowerbound = upperbound = 0;
             }
 
-          idx = value_as_long (value_pos_atr (ind[i]));
+          idx = pos_atr (ind[i]);
           if (idx < lowerbound || idx > upperbound)
             lim_warning (_("packed array index %ld out of bounds"), (long) idx);
           bits = TYPE_FIELD_BITSIZE (elt_type, 0);
@@ -2344,7 +2344,7 @@ ada_value_subscript (struct value *arr, 
     {
       if (TYPE_CODE (elt_type) != TYPE_CODE_ARRAY)
         error (_("too many subscripts (%d expected)"), k);
-      elt = value_subscript (elt, value_pos_atr (ind[k]));
+      elt = value_subscript (elt, value_pos_atr (builtin_type_int32, ind[k]));
     }
   return elt;
 }
@@ -2369,10 +2369,12 @@ ada_value_ptr_subscript (struct value *a
       arr = value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
                         value_copy (arr));
       get_discrete_bounds (TYPE_INDEX_TYPE (type), &lwb, &upb);
-      idx = value_pos_atr (ind[k]);
+      idx = value_pos_atr (builtin_type_int32, ind[k]);
       if (lwb != 0)
-        idx = value_sub (idx, value_from_longest (builtin_type_int, lwb));
-      arr = value_add (arr, idx);
+	idx = value_binop (idx, value_from_longest (value_type (idx), lwb),
+			   BINOP_SUB);
+
+      arr = value_ptradd (arr, idx);
       type = TYPE_TARGET_TYPE (type);
     }
 
@@ -2507,7 +2509,7 @@ ada_index_type (struct type *type, int n
          has a target type of TYPE_CODE_UNDEF.  We compensate here, but
          perhaps stabsread.c would make more sense.  */
       if (result_type == NULL || TYPE_CODE (result_type) == TYPE_CODE_UNDEF)
-        result_type = builtin_type_int;
+        result_type = builtin_type_int32;
 
       return result_type;
     }
@@ -2535,7 +2537,7 @@ ada_array_bound_from_type (struct type *
   if (arr_type == NULL || !ada_is_simple_array_type (arr_type))
     {
       if (typep != NULL)
-        *typep = builtin_type_int;
+        *typep = builtin_type_int32;
       return (LONGEST) - which;
     }
 
@@ -2631,12 +2633,13 @@ ada_array_length (struct value *arr, int
       return value_from_longest (type, v);
     }
   else
-    return
-      value_from_longest (builtin_type_int,
-                          value_as_long (desc_one_bound (desc_bounds (arr),
-                                                         n, 1))
-                          - value_as_long (desc_one_bound (desc_bounds (arr),
-                                                           n, 0)) + 1);
+    {
+      struct value *high = desc_one_bound (desc_bounds (arr), n, 1);
+      struct value *low = desc_one_bound (desc_bounds (arr), n, 0);
+      return value_from_longest (value_type (high),
+				 value_as_long (high)
+				 - value_as_long (low) + 1);
+    }
 }
 
 /* An empty array whose type is that of ARR_TYPE (an array type),
@@ -5798,7 +5801,8 @@ ada_tag_name_2 (struct tag_args *args)
   valp = value_cast (info_type, args->tag);
   if (valp == NULL)
     return 0;
-  val = value_ind (value_add (valp, value_from_longest (builtin_type_int, -1)));
+  val = value_ind (value_ptradd (valp,
+				 value_from_longest (builtin_type_int8, -1)));
   if (val == NULL)
     return 0;
   val = ada_value_struct_elt (val, "expanded_name", 1);
@@ -5901,7 +5905,7 @@ ada_variant_discrim_type (struct type *v
   struct type *type =
     ada_lookup_struct_elt_type (outer_type, name, 1, 1, NULL);
   if (type == NULL)
-    return builtin_type_int;
+    return builtin_type_int32;
   else
     return type;
 }
@@ -7657,9 +7661,9 @@ pos_atr (struct value *arg)
 }
 
 static struct value *
-value_pos_atr (struct value *arg)
+value_pos_atr (struct type *type, struct value *arg)
 {
-  return value_from_longest (builtin_type_int, pos_atr (arg));
+  return value_from_longest (type, pos_atr (arg));
 }
 
 /* Evaluate the TYPE'VAL attribute applied to ARG.  */
@@ -7941,8 +7945,7 @@ cast_to_fixed (struct type *type, struct
                                                   value_as_long (arg)));
   else
     {
-      DOUBLEST argd =
-        value_as_double (value_cast (builtin_type_double, value_copy (arg)));
+      DOUBLEST argd = value_as_double (arg);
       val = ada_float_to_fixed (type, argd);
     }
 
@@ -7950,11 +7953,11 @@ cast_to_fixed (struct type *type, struct
 }
 
 static struct value *
-cast_from_fixed_to_double (struct value *arg)
+cast_from_fixed (struct type *type, struct value *arg)
 {
   DOUBLEST val = ada_fixed_to_float (value_type (arg),
                                      value_as_long (arg));
-  return value_from_double (builtin_type_double, val);
+  return value_from_double (type, val);
 }
 
 /* Coerce VAL as necessary for assignment to an lval of type TYPE, and
@@ -8114,7 +8117,7 @@ assign_component (struct value *containe
   struct value *elt;
   if (TYPE_CODE (value_type (lhs)) == TYPE_CODE_ARRAY)
     {
-      struct value *index_val = value_from_longest (builtin_type_int, index);
+      struct value *index_val = value_from_longest (builtin_type_int32, index);
       elt = unwrap_value (ada_value_subscript (lhs, 1, &index_val));
     }
   else
@@ -8408,7 +8411,7 @@ ada_value_cast (struct type *type, struc
     return (cast_to_fixed (type, arg2));
 
   if (ada_is_fixed_point_type (value_type (arg2)))
-    return value_cast (type, cast_from_fixed_to_double (arg2));
+    return cast_from_fixed (type, arg2);
 
   return value_cast (type, arg2);
 }
@@ -8518,7 +8521,8 @@ ada_evaluate_subexp (struct type *expect
       type = value_type (arg1);
       while (TYPE_CODE (type) == TYPE_CODE_REF)
         type = TYPE_TARGET_TYPE (type);
-      return value_cast (type, value_add (arg1, arg2));
+      binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
+      return value_cast (type, value_binop (arg1, arg2, BINOP_ADD));
 
     case BINOP_SUB:
       arg1 = evaluate_subexp_with_coercion (exp, pos, noside);
@@ -8535,7 +8539,8 @@ ada_evaluate_subexp (struct type *expect
       type = value_type (arg1);
       while (TYPE_CODE (type) == TYPE_CODE_REF)
         type = TYPE_TARGET_TYPE (type);
-      return value_cast (type, value_sub (arg1, arg2));
+      binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
+      return value_cast (type, value_binop (arg1, arg2, BINOP_SUB));
 
     case BINOP_MUL:
     case BINOP_DIV:
@@ -8548,10 +8553,12 @@ ada_evaluate_subexp (struct type *expect
         return value_zero (value_type (arg1), not_lval);
       else
         {
+          type = builtin_type (exp->gdbarch)->builtin_double;
           if (ada_is_fixed_point_type (value_type (arg1)))
-            arg1 = cast_from_fixed_to_double (arg1);
+            arg1 = cast_from_fixed (type, arg1);
           if (ada_is_fixed_point_type (value_type (arg2)))
-            arg2 = cast_from_fixed_to_double (arg2);
+            arg2 = cast_from_fixed (type, arg2);
+          binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
           return ada_value_binop (arg1, arg2, op);
         }
 
@@ -8565,7 +8572,10 @@ ada_evaluate_subexp (struct type *expect
                && (op == BINOP_DIV || op == BINOP_REM || op == BINOP_MOD))
         return value_zero (value_type (arg1), not_lval);
       else
-        return ada_value_binop (arg1, arg2, op);
+	{
+	  binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
+	  return ada_value_binop (arg1, arg2, op);
+	}
 
     case BINOP_EQUAL:
     case BINOP_NOTEQUAL:
@@ -8576,10 +8586,14 @@ ada_evaluate_subexp (struct type *expect
       if (noside == EVAL_AVOID_SIDE_EFFECTS)
         tem = 0;
       else
-        tem = ada_value_equal (arg1, arg2);
+	{
+	  binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
+	  tem = ada_value_equal (arg1, arg2);
+	}
       if (op == BINOP_NOTEQUAL)
         tem = !tem;
-      return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem);
+      type = language_bool_type (exp->language_defn, exp->gdbarch);
+      return value_from_longest (type, (LONGEST) tem);
 
     case UNOP_NEG:
       arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
@@ -8588,7 +8602,10 @@ ada_evaluate_subexp (struct type *expect
       else if (ada_is_fixed_point_type (value_type (arg1)))
         return value_cast (value_type (arg1), value_neg (arg1));
       else
-        return value_neg (arg1);
+	{
+	  unop_promote (exp->language_defn, exp->gdbarch, &arg1);
+	  return value_neg (arg1);
+	}
 
     case BINOP_LOGICAL_AND:
     case BINOP_LOGICAL_OR:
@@ -8598,7 +8615,8 @@ ada_evaluate_subexp (struct type *expect
 
         *pos -= 1;
         val = evaluate_subexp_standard (expect_type, exp, pos, noside);
-        return value_cast (LA_BOOL_TYPE, val);
+	type = language_bool_type (exp->language_defn, exp->gdbarch);
+        return value_cast (type, val);
       }
 
     case BINOP_BITWISE_AND:
@@ -8850,14 +8868,19 @@ ada_evaluate_subexp (struct type *expect
         default:
           lim_warning (_("Membership test incompletely implemented; "
 			 "always returns true"));
-          return value_from_longest (builtin_type_int, (LONGEST) 1);
+          type = language_bool_type (exp->language_defn, exp->gdbarch);
+          return value_from_longest (type, (LONGEST) 1);
 
         case TYPE_CODE_RANGE:
-          arg2 = value_from_longest (builtin_type_int, TYPE_LOW_BOUND (type));
-          arg3 = value_from_longest (builtin_type_int,
-                                     TYPE_HIGH_BOUND (type));
+	  arg2 = value_from_longest (TYPE_TARGET_TYPE (type),
+				     TYPE_LOW_BOUND (type));
+	  arg3 = value_from_longest (TYPE_TARGET_TYPE (type),
+				     TYPE_HIGH_BOUND (type));
+	  binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
+	  binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg3);
+          type = language_bool_type (exp->language_defn, exp->gdbarch);
           return
-            value_from_longest (builtin_type_int,
+            value_from_longest (type,
                                 (value_less (arg1, arg3)
                                  || value_equal (arg1, arg3))
                                 && (value_less (arg2, arg1)
@@ -8873,7 +8896,10 @@ ada_evaluate_subexp (struct type *expect
         goto nosideret;
 
       if (noside == EVAL_AVOID_SIDE_EFFECTS)
-        return value_zero (builtin_type_int, not_lval);
+	{
+	  type = language_bool_type (exp->language_defn, exp->gdbarch);
+	  return value_zero (type, not_lval);
+	}
 
       tem = longest_to_int (exp->elts[pc + 1].longconst);
 
@@ -8883,8 +8909,11 @@ ada_evaluate_subexp (struct type *expect
       arg3 = ada_array_bound (arg2, tem, 1);
       arg2 = ada_array_bound (arg2, tem, 0);
 
+      binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
+      binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg3);
+      type = language_bool_type (exp->language_defn, exp->gdbarch);
       return
-        value_from_longest (builtin_type_int,
+        value_from_longest (type,
                             (value_less (arg1, arg3)
                              || value_equal (arg1, arg3))
                             && (value_less (arg2, arg1)
@@ -8898,8 +8927,11 @@ ada_evaluate_subexp (struct type *expect
       if (noside == EVAL_SKIP)
         goto nosideret;
 
+      binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
+      binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg3);
+      type = language_bool_type (exp->language_defn, exp->gdbarch);
       return
-        value_from_longest (builtin_type_int,
+        value_from_longest (type,
                             (value_less (arg1, arg3)
                              || value_equal (arg1, arg3))
                             && (value_less (arg2, arg1)
@@ -9044,8 +9076,11 @@ ada_evaluate_subexp (struct type *expect
       else if (noside == EVAL_AVOID_SIDE_EFFECTS)
         return value_zero (value_type (arg1), not_lval);
       else
-        return value_binop (arg1, arg2,
-                            op == OP_ATR_MIN ? BINOP_MIN : BINOP_MAX);
+	{
+	  binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
+	  return value_binop (arg1, arg2,
+			      op == OP_ATR_MIN ? BINOP_MIN : BINOP_MAX);
+	}
 
     case OP_ATR_MODULUS:
       {
@@ -9068,19 +9103,21 @@ ada_evaluate_subexp (struct type *expect
       arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
       if (noside == EVAL_SKIP)
         goto nosideret;
-      else if (noside == EVAL_AVOID_SIDE_EFFECTS)
-        return value_zero (builtin_type_int, not_lval);
+      type = builtin_type (exp->gdbarch)->builtin_int;
+      if (noside == EVAL_AVOID_SIDE_EFFECTS)
+        return value_zero (type, not_lval);
       else
-        return value_pos_atr (arg1);
+        return value_pos_atr (type, arg1);
 
     case OP_ATR_SIZE:
       arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
       if (noside == EVAL_SKIP)
         goto nosideret;
-      else if (noside == EVAL_AVOID_SIDE_EFFECTS)
-        return value_zero (builtin_type_int, not_lval);
+      type = builtin_type (exp->gdbarch)->builtin_int;
+      if (noside == EVAL_AVOID_SIDE_EFFECTS)
+        return value_zero (type, not_lval);
       else
-        return value_from_longest (builtin_type_int,
+        return value_from_longest (type,
                                    TARGET_CHAR_BIT
                                    * TYPE_LENGTH (value_type (arg1)));
 
@@ -9103,7 +9140,16 @@ ada_evaluate_subexp (struct type *expect
       else if (noside == EVAL_AVOID_SIDE_EFFECTS)
         return value_zero (value_type (arg1), not_lval);
       else
-        return value_binop (arg1, arg2, op);
+	{
+	  /* For integer exponentiation operations,
+	     only promote the first argument.  */
+	  if (is_integral_type (value_type (arg2)))
+	    unop_promote (exp->language_defn, exp->gdbarch, &arg1);
+	  else
+	    binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
+
+	  return value_binop (arg1, arg2, op);
+	}
 
     case UNOP_PLUS:
       arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
@@ -9116,6 +9162,7 @@ ada_evaluate_subexp (struct type *expect
       arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
       if (noside == EVAL_SKIP)
         goto nosideret;
+      unop_promote (exp->language_defn, exp->gdbarch, &arg1);
       if (value_less (arg1, value_zero (value_type (arg1), not_lval)))
         return value_neg (arg1);
       else
@@ -9151,7 +9198,8 @@ ada_evaluate_subexp (struct type *expect
             }
           else if (TYPE_CODE (type) == TYPE_CODE_INT)
             /* GDB allows dereferencing an int.  */
-            return value_zero (builtin_type_int, lval_memory);
+            return value_zero (builtin_type (exp->gdbarch)->builtin_int,
+			       lval_memory);
           else
             error (_("Attempt to take contents of a non-pointer value."));
         }
@@ -9161,6 +9209,10 @@ ada_evaluate_subexp (struct type *expect
       if (ada_is_array_descriptor_type (type))
         /* GDB allows dereferencing GNAT array descriptors.  */
         return ada_coerce_to_simple_array (arg1);
+      else if (TYPE_CODE (type) == TYPE_CODE_INT)
+	/* GDB allows dereferencing an int.  */
+	return value_at_lazy (builtin_type (exp->gdbarch)->builtin_int,
+			      (CORE_ADDR) value_as_address (arg1));
       else
         return ada_value_ind (arg1);
 
@@ -9234,7 +9286,7 @@ ada_evaluate_subexp (struct type *expect
     }
 
 nosideret:
-  return value_from_longest (builtin_type_long, (LONGEST) 1);
+  return value_from_longest (builtin_type_int8, (LONGEST) 1);
 }
 
 
@@ -9494,7 +9546,7 @@ to_fixed_range_type (char *name, struct 
   char *subtype_info;
 
   if (raw_type == NULL)
-    base_type = builtin_type_int;
+    base_type = builtin_type_int32;
   else if (TYPE_CODE (raw_type) == TYPE_CODE_RANGE)
     base_type = TYPE_TARGET_TYPE (raw_type);
   else
@@ -10911,6 +10963,9 @@ ada_language_arch_info (struct gdbarch *
                                     (struct objfile *) NULL));
   TYPE_NAME (lai->primitive_type_vector [ada_primitive_type_system_address])
     = "system__address";
+
+  lai->bool_type_symbol = "boolean";
+  lai->bool_type_default = builtin->builtin_bool;
 }
 
 				/* Language vector */
Index: gdb-head/gdb/c-lang.c
===================================================================
--- gdb-head.orig/gdb/c-lang.c
+++ gdb-head/gdb/c-lang.c
@@ -380,6 +380,8 @@ c_language_arch_info (struct gdbarch *gd
   lai->primitive_type_vector [c_primitive_type_decfloat] = builtin->builtin_decfloat;
   lai->primitive_type_vector [c_primitive_type_decdouble] = builtin->builtin_decdouble;
   lai->primitive_type_vector [c_primitive_type_declong] = builtin->builtin_declong;
+
+  lai->bool_type_default = builtin->builtin_int;
 }
 
 const struct language_defn c_language_defn =
@@ -493,6 +495,9 @@ cplus_language_arch_info (struct gdbarch
     = builtin->builtin_decdouble;
   lai->primitive_type_vector [cplus_primitive_type_declong]
     = builtin->builtin_declong;
+
+  lai->bool_type_symbol = "bool";
+  lai->bool_type_default = builtin->builtin_bool;
 }
 
 const struct language_defn cplus_language_defn =
Index: gdb-head/gdb/f-lang.c
===================================================================
--- gdb-head.orig/gdb/f-lang.c
+++ gdb-head/gdb/f-lang.c
@@ -298,6 +298,9 @@ f_language_arch_info (struct gdbarch *gd
     = builtin->builtin_complex_s16;
   lai->primitive_type_vector [f_primitive_type_void]
     = builtin->builtin_void;
+
+  lai->bool_type_symbol = "logical";
+  lai->bool_type_default = builtin->builtin_logical_s2;
 }
 
 /* This is declared in c-lang.h but it is silly to import that file for what
Index: gdb-head/gdb/language.c
===================================================================
--- gdb-head.orig/gdb/language.c
+++ gdb-head/gdb/language.c
@@ -787,51 +787,6 @@ structured_type (struct type *type)
 }
 #endif
 
-struct type *
-lang_bool_type (void)
-{
-  struct symbol *sym;
-  struct type *type;
-  switch (current_language->la_language)
-    {
-    case language_fortran:
-      sym = lookup_symbol ("logical", NULL, VAR_DOMAIN, NULL);
-      if (sym)
-	{
-	  type = SYMBOL_TYPE (sym);
-	  if (type && TYPE_CODE (type) == TYPE_CODE_BOOL)
-	    return type;
-	}
-      return builtin_type_f_logical_s2;
-    case language_cplus:
-    case language_pascal:
-    case language_ada:
-      if (current_language->la_language==language_cplus)
-        {sym = lookup_symbol ("bool", NULL, VAR_DOMAIN, NULL);}
-      else
-        {sym = lookup_symbol ("boolean", NULL, VAR_DOMAIN, NULL);}
-      if (sym)
-	{
-	  type = SYMBOL_TYPE (sym);
-	  if (type && TYPE_CODE (type) == TYPE_CODE_BOOL)
-	    return type;
-	}
-      return builtin_type_bool;
-    case language_java:
-      sym = lookup_symbol ("boolean", NULL, VAR_DOMAIN, NULL);
-      if (sym)
-	{
-	  type = SYMBOL_TYPE (sym);
-	  if (type && TYPE_CODE (type) == TYPE_CODE_BOOL)
-	    return type;
-	}
-      return java_boolean_type;
-      
-    default:
-      return builtin_type_int;
-    }
-}
-
 /* This page contains functions that return info about
    (struct value) values used in GDB. */
 
@@ -1169,6 +1124,7 @@ unknown_language_arch_info (struct gdbar
 			    struct language_arch_info *lai)
 {
   lai->string_char_type = builtin_type (gdbarch)->builtin_char;
+  lai->bool_type_default = builtin_type (gdbarch)->builtin_int;
   lai->primitive_type_vector = GDBARCH_OBSTACK_CALLOC (gdbarch, 1,
 						       struct type *);
 }
@@ -1317,6 +1273,29 @@ language_string_char_type (const struct 
 }
 
 struct type *
+language_bool_type (const struct language_defn *la,
+		    struct gdbarch *gdbarch)
+{
+  struct language_gdbarch *ld = gdbarch_data (gdbarch,
+					      language_gdbarch_data);
+
+  if (ld->arch_info[la->la_language].bool_type_symbol)
+    {
+      struct symbol *sym;
+      sym = lookup_symbol (ld->arch_info[la->la_language].bool_type_symbol,
+			   NULL, VAR_DOMAIN, NULL);
+      if (sym)
+	{
+	  struct type *type = SYMBOL_TYPE (sym);
+	  if (type && TYPE_CODE (type) == TYPE_CODE_BOOL)
+	    return type;
+	}
+    }
+
+  return ld->arch_info[la->la_language].bool_type_default;
+}
+
+struct type *
 language_lookup_primitive_type_by_name (const struct language_defn *la,
 					struct gdbarch *gdbarch,
 					const char *name)
Index: gdb-head/gdb/language.h
===================================================================
--- gdb-head.orig/gdb/language.h
+++ gdb-head/gdb/language.h
@@ -125,6 +125,11 @@ struct language_arch_info
   struct type **primitive_type_vector;
   /* Type of elements of strings. */
   struct type *string_char_type;
+
+  /* Symbol name of type to use as boolean type, if defined.  */
+  const char *bool_type_symbol;
+  /* Otherwise, this is the default boolean builtin type.  */
+  struct type *bool_type_default;
 };
 
 /* Structure tying together assorted information about a language.  */
@@ -306,6 +311,9 @@ extern enum language_mode
   }
 language_mode;
 
+struct type *language_bool_type (const struct language_defn *l,
+				 struct gdbarch *gdbarch);
+
 struct type *language_string_char_type (const struct language_defn *l,
 					struct gdbarch *gdbarch);
 
@@ -416,11 +424,6 @@ extern void range_error (const char *, .
 
 extern int value_true (struct value *);
 
-extern struct type *lang_bool_type (void);
-
-/* The type used for Boolean values in the current language. */
-#define LA_BOOL_TYPE lang_bool_type ()
-
 /* Misc:  The string representing a particular enum language.  */
 
 extern enum language language_enum (char *str);
Index: gdb-head/gdb/m2-lang.c
===================================================================
--- gdb-head.orig/gdb/m2-lang.c
+++ gdb-head/gdb/m2-lang.c
@@ -251,7 +251,7 @@ evaluate_subexp_modula2 (struct type *ex
 	    arg1 = value_cast (type, arg1);
 
 	  type = check_typedef (value_type (arg1));
-	  return value_ind (value_add (arg1, arg2));
+	  return value_ind (value_ptradd (arg1, arg2));
 	}
       else
 	if (TYPE_CODE (type) != TYPE_CODE_ARRAY)
@@ -273,7 +273,7 @@ evaluate_subexp_modula2 (struct type *ex
     }
 
  nosideret:
-  return value_from_longest (builtin_type_long, (LONGEST) 1);
+  return value_from_longest (builtin_type_int8, (LONGEST) 1);
 }
 
 
@@ -345,6 +345,9 @@ m2_language_arch_info (struct gdbarch *g
     = builtin->builtin_real;
   lai->primitive_type_vector [m2_primitive_type_bool]
     = builtin->builtin_bool;
+
+  lai->bool_type_symbol = "BOOLEAN";
+  lai->bool_type_default = builtin->builtin_bool;
 }
 
 const struct exp_descriptor exp_descriptor_modula2 = 
Index: gdb-head/gdb/p-lang.c
===================================================================
--- gdb-head.orig/gdb/p-lang.c
+++ gdb-head/gdb/p-lang.c
@@ -393,6 +393,9 @@ pascal_language_arch_info (struct gdbarc
     = builtin->builtin_complex;
   lai->primitive_type_vector [pascal_primitive_type_double_complex]
     = builtin->builtin_double_complex;
+
+  lai->bool_type_symbol = "boolean";
+  lai->bool_type_default = builtin->builtin_bool;
 }
 
 const struct language_defn pascal_language_defn =
Index: gdb-head/gdb/gnu-v2-abi.c
===================================================================
--- gdb-head.orig/gdb/gnu-v2-abi.c
+++ gdb-head/gdb/gnu-v2-abi.c
@@ -97,7 +97,7 @@ gnuv2_virtual_fn_field (struct value **a
   struct value *entry;
   struct value *vfn;
   struct value *vtbl;
-  struct value *vi = value_from_longest (builtin_type_int,
+  struct value *vi = value_from_longest (builtin_type_int32,
 				     (LONGEST) TYPE_FN_FIELD_VOFFSET (f, j));
   struct type *fcontext = TYPE_FN_FIELD_FCONTEXT (f, j);
   struct type *context;
@@ -151,7 +151,7 @@ gnuv2_virtual_fn_field (struct value **a
   else
     {
       /* Handle the case where the vtbl field points directly to a structure. */
-      vtbl = value_add (vtbl, vi);
+      vtbl = value_ptradd (vtbl, vi);
       entry = value_ind (vtbl);
     }
 
Index: gdb-head/gdb/gnu-v3-abi.c
===================================================================
--- gdb-head.orig/gdb/gnu-v3-abi.c
+++ gdb-head/gdb/gnu-v3-abi.c
@@ -45,6 +45,21 @@ gnuv3_is_operator_name (const char *name
 }
 
 
+/* Determine architecture of class DOMAIN.  This architecture is used
+   to query C++ ABI details (types, method pointer layout, etc.).
+
+   Note that we assume DOMAIN must have been allocated with an OBJFILE;
+   GDB does not provide any built-in class types.  Thus we use the
+   architecture of that OBJFILE to define the C++ ABI.  */
+
+static struct gdbarch *
+get_class_arch (struct type *domain)
+{
+  gdb_assert (TYPE_CODE (domain) == TYPE_CODE_CLASS);
+  gdb_assert (TYPE_OBJFILE (domain) != NULL);
+  return get_objfile_arch (TYPE_OBJFILE (domain));
+}
+
 /* To help us find the components of a vtable, we build ourselves a
    GDB type object representing the vtable structure.  Following the
    V3 ABI, it goes something like this:
@@ -107,9 +122,9 @@ build_gdb_vtable_type (struct gdbarch *a
   int offset;
 
   struct type *void_ptr_type
-    = lookup_pointer_type (builtin_type_void);
+    = builtin_type (arch)->builtin_data_ptr;
   struct type *ptr_to_void_fn_type
-    = lookup_pointer_type (lookup_function_type (builtin_type_void));
+    = builtin_type (arch)->builtin_func_ptr;
 
   /* ARCH can't give us the true ptrdiff_t type, so we guess.  */
   struct type *ptrdiff_type
@@ -132,7 +147,7 @@ build_gdb_vtable_type (struct gdbarch *a
   FIELD_NAME (*field) = "vcall_and_vbase_offsets";
   FIELD_TYPE (*field)
     = create_array_type (0, ptrdiff_type,
-                         create_range_type (0, builtin_type_int, 0, -1));
+                         create_range_type (0, builtin_type_int32, 0, -1));
   FIELD_BITPOS (*field) = offset * TARGET_CHAR_BIT;
   offset += TYPE_LENGTH (FIELD_TYPE (*field));
   field++;
@@ -155,7 +170,7 @@ build_gdb_vtable_type (struct gdbarch *a
   FIELD_NAME (*field) = "virtual_functions";
   FIELD_TYPE (*field)
     = create_array_type (0, ptr_to_void_fn_type,
-                         create_range_type (0, builtin_type_int, 0, -1));
+                         create_range_type (0, builtin_type_int32, 0, -1));
   FIELD_BITPOS (*field) = offset * TARGET_CHAR_BIT;
   offset += TYPE_LENGTH (FIELD_TYPE (*field));
   field++;
@@ -176,10 +191,9 @@ build_gdb_vtable_type (struct gdbarch *a
    gdb_gnu_v3_abi_vtable' object to the vtable's "address point"
    (i.e., where objects' virtual table pointers point).  */
 static int
-vtable_address_point_offset (void)
+vtable_address_point_offset (struct gdbarch *gdbarch)
 {
-  struct type *vtable_type = gdbarch_data (current_gdbarch,
-					   vtable_type_gdbarch_data);
+  struct type *vtable_type = gdbarch_data (gdbarch, vtable_type_gdbarch_data);
 
   return (TYPE_FIELD_BITPOS (vtable_type, vtable_field_virtual_functions)
           / TARGET_CHAR_BIT);
@@ -190,8 +204,8 @@ static struct type *
 gnuv3_rtti_type (struct value *value,
                  int *full_p, int *top_p, int *using_enc_p)
 {
-  struct type *vtable_type = gdbarch_data (current_gdbarch,
-					   vtable_type_gdbarch_data);
+  struct gdbarch *gdbarch;
+  struct type *vtable_type;
   struct type *values_type = check_typedef (value_type (value));
   CORE_ADDR vtable_address;
   struct value *vtable;
@@ -208,6 +222,16 @@ gnuv3_rtti_type (struct value *value,
   if (TYPE_CODE (values_type) != TYPE_CODE_CLASS)
     return NULL;
 
+  /* This routine may be called for Java types that do not have
+     a proper objfile.  Just return NULL for those.  */
+  if (!TYPE_OBJFILE (values_type)
+      || !TYPE_OBJFILE (values_type)->obfd)
+    return NULL;
+
+  /* Determine architecture.  */
+  gdbarch = get_class_arch (values_type);
+  vtable_type = gdbarch_data (gdbarch, vtable_type_gdbarch_data);
+
   /* If we can't find the virtual table pointer for values_type, we
      can't find the RTTI.  */
   values_type_vptr_fieldno = get_vptr_fieldno (values_type,
@@ -229,8 +253,9 @@ gnuv3_rtti_type (struct value *value,
     }
   vtable_address
     = value_as_address (value_field (value, values_type_vptr_fieldno));
-  vtable = value_at_lazy (vtable_type,
-                          vtable_address - vtable_address_point_offset ());
+  vtable
+    = value_at_lazy (vtable_type,
+		     vtable_address - vtable_address_point_offset (gdbarch));
   
   /* Find the linker symbol for this vtable.  */
   vtable_symbol
@@ -282,10 +307,9 @@ gnuv3_rtti_type (struct value *value,
    vtable type for this architecture.  */
 
 static struct value *
-gnuv3_get_vtable (struct value *container)
+gnuv3_get_vtable (struct gdbarch *gdbarch, struct value *container)
 {
-  struct type *vtable_type = gdbarch_data (current_gdbarch,
-					   vtable_type_gdbarch_data);
+  struct type *vtable_type = gdbarch_data (gdbarch, vtable_type_gdbarch_data);
   struct type *vtable_pointer_type;
   struct value *vtable_pointer;
   CORE_ADDR vtable_pointer_address, vtable_address;
@@ -311,29 +335,29 @@ gnuv3_get_vtable (struct value *containe
   /* Correct it to point at the start of the virtual table, rather
      than the address point.  */
   return value_at_lazy (vtable_type,
-			vtable_address - vtable_address_point_offset ());
+			vtable_address - vtable_address_point_offset (gdbarch));
 }
 
 /* Return a function pointer for CONTAINER's VTABLE_INDEX'th virtual
    function, of type FNTYPE.  */
 
 static struct value *
-gnuv3_get_virtual_fn (struct value *container, struct type *fntype,
-		      int vtable_index)
+gnuv3_get_virtual_fn (struct gdbarch *gdbarch, struct value *container,
+		      struct type *fntype, int vtable_index)
 {
-  struct value *vtable = gnuv3_get_vtable (container);
+  struct value *vtable = gnuv3_get_vtable (gdbarch, container);
   struct value *vfn;
 
   /* Fetch the appropriate function pointer from the vtable.  */
   vfn = value_subscript (value_field (vtable, vtable_field_virtual_functions),
-                         value_from_longest (builtin_type_int, vtable_index));
+                         value_from_longest (builtin_type_int32, vtable_index));
 
   /* If this architecture uses function descriptors directly in the vtable,
      then the address of the vtable entry is actually a "function pointer"
      (i.e. points to the descriptor).  We don't need to scale the index
      by the size of a function descriptor; GCC does that before outputing
      debug information.  */
-  if (gdbarch_vtable_function_descriptors (current_gdbarch))
+  if (gdbarch_vtable_function_descriptors (gdbarch))
     vfn = value_addr (vfn);
 
   /* Cast the function pointer to the appropriate type.  */
@@ -351,18 +375,22 @@ gnuv3_virtual_fn_field (struct value **v
 			struct type *vfn_base, int offset)
 {
   struct type *values_type = check_typedef (value_type (*value_p));
+  struct gdbarch *gdbarch;
 
   /* Some simple sanity checks.  */
   if (TYPE_CODE (values_type) != TYPE_CODE_CLASS)
     error (_("Only classes can have virtual functions."));
 
+  /* Determine architecture.  */
+  gdbarch = get_class_arch (values_type);
+
   /* Cast our value to the base class which defines this virtual
      function.  This takes care of any necessary `this'
      adjustments.  */
   if (vfn_base != values_type)
     *value_p = value_cast (vfn_base, *value_p);
 
-  return gnuv3_get_virtual_fn (*value_p, TYPE_FN_FIELD_TYPE (f, j),
+  return gnuv3_get_virtual_fn (gdbarch, *value_p, TYPE_FN_FIELD_TYPE (f, j),
 			       TYPE_FN_FIELD_VOFFSET (f, j));
 }
 
@@ -377,8 +405,9 @@ static int
 gnuv3_baseclass_offset (struct type *type, int index, const bfd_byte *valaddr,
 			CORE_ADDR address)
 {
-  struct type *vtable_type = gdbarch_data (current_gdbarch,
-					   vtable_type_gdbarch_data);
+  struct gdbarch *gdbarch;
+  struct type *vtable_type;
+  struct type *ptr_type;
   struct value *vtable;
   struct type *vbasetype;
   struct value *offset_val, *vbase_array;
@@ -386,6 +415,11 @@ gnuv3_baseclass_offset (struct type *typ
   long int cur_base_offset, base_offset;
   int vbasetype_vptr_fieldno;
 
+  /* Determine architecture.  */
+  gdbarch = get_class_arch (type);
+  vtable_type = gdbarch_data (gdbarch, vtable_type_gdbarch_data);
+  ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
+
   /* If it isn't a virtual base, this is easy.  The offset is in the
      type definition.  */
   if (!BASETYPE_VIA_VIRTUAL (type, index))
@@ -397,14 +431,13 @@ gnuv3_baseclass_offset (struct type *typ
      complete inheritance graph based on the debug info.  Neither is
      worthwhile.  */
   cur_base_offset = TYPE_BASECLASS_BITPOS (type, index) / 8;
-  if (cur_base_offset >= - vtable_address_point_offset ())
+  if (cur_base_offset >= - vtable_address_point_offset (gdbarch))
     error (_("Expected a negative vbase offset (old compiler?)"));
 
-  cur_base_offset = cur_base_offset + vtable_address_point_offset ();
-  if ((- cur_base_offset) % TYPE_LENGTH (builtin_type_void_data_ptr) != 0)
+  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 (builtin_type_void_data_ptr));
+  cur_base_offset = cur_base_offset / ((int) TYPE_LENGTH (ptr_type));
 
   /* We're now looking for the cur_base_offset'th entry (negative index)
      in the vcall_and_vbase_offsets array.  We used to cast the object to
@@ -425,11 +458,11 @@ gnuv3_baseclass_offset (struct type *typ
     error (_("Illegal vptr offset in class %s"),
 	   TYPE_NAME (vbasetype) ? TYPE_NAME (vbasetype) : "<unknown>");
 
-  vtable_address = value_as_address (value_at_lazy (builtin_type_void_data_ptr,
-						    address));
-  vtable = value_at_lazy (vtable_type,
-                          vtable_address - vtable_address_point_offset ());
-  offset_val = value_from_longest(builtin_type_int, cur_base_offset);
+  vtable_address = value_as_address (value_at_lazy (ptr_type, address));
+  vtable
+    = value_at_lazy (vtable_type,
+		     vtable_address - vtable_address_point_offset (gdbarch));
+  offset_val = value_from_longest (builtin_type_int32, cur_base_offset);
   vbase_array = value_field (vtable, vtable_field_vcall_and_vbase_offsets);
   base_offset = value_as_long (value_subscript (vbase_array, offset_val));
   return base_offset;
@@ -496,6 +529,9 @@ gnuv3_print_method_ptr (const gdb_byte *
 			struct type *type,
 			struct ui_file *stream)
 {
+  struct gdbarch *gdbarch;
+  struct type *funcptr_type;
+  struct type *offset_type;
   CORE_ADDR ptr_value;
   LONGEST adjustment;
   struct type *domain;
@@ -503,13 +539,17 @@ gnuv3_print_method_ptr (const gdb_byte *
 
   domain = TYPE_DOMAIN_TYPE (type);
 
+  /* Determine architecture.  */
+  gdbarch = get_class_arch (domain);
+  funcptr_type = builtin_type (gdbarch)->builtin_func_ptr;
+  offset_type = builtin_type (gdbarch)->builtin_long;
+
   /* Extract the pointer to member.  */
-  ptr_value = extract_typed_address (contents, builtin_type_void_func_ptr);
-  contents += TYPE_LENGTH (builtin_type_void_func_ptr);
-  adjustment = extract_signed_integer (contents,
-				       TYPE_LENGTH (builtin_type_long));
+  ptr_value = extract_typed_address (contents, funcptr_type);
+  contents += TYPE_LENGTH (funcptr_type);
+  adjustment = extract_signed_integer (contents, TYPE_LENGTH (offset_type));
 
-  if (!gdbarch_vbit_in_delta (current_gdbarch))
+  if (!gdbarch_vbit_in_delta (gdbarch))
     {
       vbit = ptr_value & 1;
       ptr_value = ptr_value ^ vbit;
@@ -536,7 +576,7 @@ gnuv3_print_method_ptr (const gdb_byte *
       /* It's a virtual table offset, maybe in this class.  Search
 	 for a field with the correct vtable offset.  First convert it
 	 to an index, as used in TYPE_FN_FIELD_VOFFSET.  */
-      voffset = ptr_value / TYPE_LENGTH (builtin_type_long);
+      voffset = ptr_value / TYPE_LENGTH (builtin_type (gdbarch)->builtin_long);
 
       physname = gnuv3_find_method_in (domain, voffset, adjustment);
 
@@ -575,17 +615,22 @@ gnuv3_print_method_ptr (const gdb_byte *
 /* GNU v3 implementation of cplus_method_ptr_size.  */
 
 static int
-gnuv3_method_ptr_size (void)
+gnuv3_method_ptr_size (struct type *type)
 {
-  return 2 * TYPE_LENGTH (builtin_type_void_data_ptr);
+  struct type *domain_type = check_typedef (TYPE_DOMAIN_TYPE (type));
+  struct gdbarch *gdbarch = get_class_arch (domain_type);
+  return 2 * TYPE_LENGTH (builtin_type (gdbarch)->builtin_data_ptr);
 }
 
 /* GNU v3 implementation of cplus_make_method_ptr.  */
 
 static void
-gnuv3_make_method_ptr (gdb_byte *contents, CORE_ADDR value, int is_virtual)
+gnuv3_make_method_ptr (struct type *type, gdb_byte *contents,
+		       CORE_ADDR value, int is_virtual)
 {
-  int size = TYPE_LENGTH (builtin_type_void_data_ptr);
+  struct type *domain_type = check_typedef (TYPE_DOMAIN_TYPE (type));
+  struct gdbarch *gdbarch = get_class_arch (domain_type);
+  int size = TYPE_LENGTH (builtin_type (gdbarch)->builtin_data_ptr);
 
   /* FIXME drow/2006-12-24: The adjustment of "this" is currently
      always zero, since the method pointer is of the correct type.
@@ -596,7 +641,7 @@ gnuv3_make_method_ptr (gdb_byte *content
      support for adjusting pointers to members when casting them -
      not currently supported by GDB.  */
 
-  if (!gdbarch_vbit_in_delta (current_gdbarch))
+  if (!gdbarch_vbit_in_delta (gdbarch))
     {
       store_unsigned_integer (contents, size, value | is_virtual);
       store_unsigned_integer (contents + size, size, 0);
@@ -613,24 +658,30 @@ gnuv3_make_method_ptr (gdb_byte *content
 static struct value *
 gnuv3_method_ptr_to_value (struct value **this_p, struct value *method_ptr)
 {
+  struct gdbarch *gdbarch;
   const gdb_byte *contents = value_contents (method_ptr);
   CORE_ADDR ptr_value;
-  struct type *final_type, *method_type;
+  struct type *domain_type, *final_type, *method_type;
+  struct type *funcptr_type, *offset_type;
   LONGEST adjustment;
   struct value *adjval;
   int vbit;
 
-  final_type = TYPE_DOMAIN_TYPE (check_typedef (value_type (method_ptr)));
-  final_type = lookup_pointer_type (final_type);
+  domain_type = TYPE_DOMAIN_TYPE (check_typedef (value_type (method_ptr)));
+  final_type = lookup_pointer_type (domain_type);
 
   method_type = TYPE_TARGET_TYPE (check_typedef (value_type (method_ptr)));
 
-  ptr_value = extract_typed_address (contents, builtin_type_void_func_ptr);
-  contents += TYPE_LENGTH (builtin_type_void_func_ptr);
-  adjustment = extract_signed_integer (contents,
-				       TYPE_LENGTH (builtin_type_long));
+  /* Determine architecture.  */
+  gdbarch = get_class_arch (domain_type);
+  funcptr_type = builtin_type (gdbarch)->builtin_func_ptr;
+  offset_type = builtin_type (gdbarch)->builtin_long;
+
+  ptr_value = extract_typed_address (contents, funcptr_type);
+  contents += TYPE_LENGTH (funcptr_type);
+  adjustment = extract_signed_integer (contents, TYPE_LENGTH (offset_type));
 
-  if (!gdbarch_vbit_in_delta (current_gdbarch))
+  if (!gdbarch_vbit_in_delta (gdbarch))
     {
       vbit = ptr_value & 1;
       ptr_value = ptr_value ^ vbit;
@@ -660,15 +711,17 @@ gnuv3_method_ptr_to_value (struct value 
 
      You can provoke this case by casting a Base::* to a Derived::*, for
      instance.  */
-  *this_p = value_cast (builtin_type_void_data_ptr, *this_p);
-  adjval = value_from_longest (builtin_type_long, adjustment);
-  *this_p = value_add (*this_p, adjval);
+  *this_p = value_cast (builtin_type (gdbarch)->builtin_data_ptr, *this_p);
+  adjval = value_from_longest (offset_type, adjustment);
+  *this_p = value_ptradd (*this_p, adjval);
   *this_p = value_cast (final_type, *this_p);
 
   if (vbit)
     {
-      LONGEST voffset = ptr_value / TYPE_LENGTH (builtin_type_long);
-      return gnuv3_get_virtual_fn (value_ind (*this_p), method_type, voffset);
+      LONGEST voffset;
+      voffset = ptr_value / TYPE_LENGTH (builtin_type (gdbarch)->builtin_long);
+      return gnuv3_get_virtual_fn (gdbarch, value_ind (*this_p),
+				   method_type, voffset);
     }
   else
     return value_from_pointer (lookup_pointer_type (method_type), ptr_value);
Index: gdb-head/gdb/ax-gdb.c
===================================================================
--- gdb-head.orig/gdb/ax-gdb.c
+++ gdb-head/gdb/ax-gdb.c
@@ -34,6 +34,7 @@
 #include "block.h"
 #include "regcache.h"
 #include "user-regs.h"
+#include "language.h"
 
 /* To make sense of this file, you should read doc/agentexpr.texi.
    Then look at the types and enums in ax-gdb.h.  For the code itself,
@@ -72,11 +73,11 @@ static void gen_fetch (struct agent_expr
 static void gen_left_shift (struct agent_expr *, int);
 
 
-static void gen_frame_args_address (struct agent_expr *);
-static void gen_frame_locals_address (struct agent_expr *);
+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_sym_offset (struct agent_expr *, struct symbol *);
-static void gen_var_ref (struct agent_expr *ax,
+static void gen_var_ref (struct gdbarch *, struct agent_expr *ax,
 			 struct axs_value *value, struct symbol *var);
 
 
@@ -86,35 +87,39 @@ static void gen_int_literal (struct agen
 
 
 static void require_rvalue (struct agent_expr *ax, struct axs_value *value);
-static void gen_usual_unary (struct agent_expr *ax, struct axs_value *value);
+static void gen_usual_unary (struct expression *exp, struct agent_expr *ax,
+			     struct axs_value *value);
 static int type_wider_than (struct type *type1, struct type *type2);
 static struct type *max_type (struct type *type1, struct type *type2);
 static void gen_conversion (struct agent_expr *ax,
 			    struct type *from, struct type *to);
 static int is_nontrivial_conversion (struct type *from, struct type *to);
-static void gen_usual_arithmetic (struct agent_expr *ax,
+static void gen_usual_arithmetic (struct expression *exp,
+				  struct agent_expr *ax,
 				  struct axs_value *value1,
 				  struct axs_value *value2);
-static void gen_integral_promotions (struct agent_expr *ax,
+static void gen_integral_promotions (struct expression *exp,
+				     struct agent_expr *ax,
 				     struct axs_value *value);
 static void gen_cast (struct agent_expr *ax,
 		      struct axs_value *value, struct type *type);
 static void gen_scale (struct agent_expr *ax,
 		       enum agent_op op, struct type *type);
-static void gen_add (struct agent_expr *ax,
-		     struct axs_value *value,
-		     struct axs_value *value1,
-		     struct axs_value *value2, char *name);
-static void gen_sub (struct agent_expr *ax,
-		     struct axs_value *value,
-		     struct axs_value *value1, struct axs_value *value2);
+static void gen_ptradd (struct agent_expr *ax, struct axs_value *value,
+			struct axs_value *value1, struct axs_value *value2);
+static void gen_ptrsub (struct agent_expr *ax, struct axs_value *value,
+			struct axs_value *value1, struct axs_value *value2);
+static void gen_ptrdiff (struct agent_expr *ax, struct axs_value *value,
+			 struct axs_value *value1, struct axs_value *value2,
+			 struct type *result_type);
 static void gen_binop (struct agent_expr *ax,
 		       struct axs_value *value,
 		       struct axs_value *value1,
 		       struct axs_value *value2,
 		       enum agent_op op,
 		       enum agent_op op_unsigned, int may_carry, char *name);
-static void gen_logical_not (struct agent_expr *ax, struct axs_value *value);
+static void gen_logical_not (struct agent_expr *ax, struct axs_value *value,
+			     struct type *result_type);
 static void gen_complement (struct agent_expr *ax, struct axs_value *value);
 static void gen_deref (struct agent_expr *, struct axs_value *);
 static void gen_address_of (struct agent_expr *, struct axs_value *);
@@ -126,11 +131,12 @@ static void gen_struct_ref (struct agent
 			    struct axs_value *value,
 			    char *field,
 			    char *operator_name, char *operand_name);
-static void gen_repeat (union exp_element **pc,
+static void gen_repeat (struct expression *exp, union exp_element **pc,
 			struct agent_expr *ax, struct axs_value *value);
-static void gen_sizeof (union exp_element **pc,
-			struct agent_expr *ax, struct axs_value *value);
-static void gen_expr (union exp_element **pc,
+static void gen_sizeof (struct expression *exp, union exp_element **pc,
+			struct agent_expr *ax, struct axs_value *value,
+			struct type *size_type);
+static void gen_expr (struct expression *exp, union exp_element **pc,
 		      struct agent_expr *ax, struct axs_value *value);
 
 static void agent_command (char *exp, int from_tty);
@@ -455,12 +461,12 @@ gen_left_shift (struct agent_expr *ax, i
 /* Generate code to push the base address of the argument portion of
    the top stack frame.  */
 static void
-gen_frame_args_address (struct agent_expr *ax)
+gen_frame_args_address (struct gdbarch *gdbarch, struct agent_expr *ax)
 {
   int frame_reg;
   LONGEST frame_offset;
 
-  gdbarch_virtual_frame_pointer (current_gdbarch,
+  gdbarch_virtual_frame_pointer (gdbarch,
 				 ax->scope, &frame_reg, &frame_offset);
   ax_reg (ax, frame_reg);
   gen_offset (ax, frame_offset);
@@ -470,12 +476,12 @@ gen_frame_args_address (struct agent_exp
 /* Generate code to push the base address of the locals portion of the
    top stack frame.  */
 static void
-gen_frame_locals_address (struct agent_expr *ax)
+gen_frame_locals_address (struct gdbarch *gdbarch, struct agent_expr *ax)
 {
   int frame_reg;
   LONGEST frame_offset;
 
-  gdbarch_virtual_frame_pointer (current_gdbarch,
+  gdbarch_virtual_frame_pointer (gdbarch,
 				 ax->scope, &frame_reg, &frame_offset);
   ax_reg (ax, frame_reg);
   gen_offset (ax, frame_offset);
@@ -520,7 +526,8 @@ gen_sym_offset (struct agent_expr *ax, s
    symbol VAR.  Set VALUE to describe the result.  */
 
 static void
-gen_var_ref (struct agent_expr *ax, struct axs_value *value, struct symbol *var)
+gen_var_ref (struct gdbarch *gdbarch, struct agent_expr *ax,
+	     struct axs_value *value, struct symbol *var)
 {
   /* Dereference any typedefs. */
   value->type = check_typedef (SYMBOL_TYPE (var));
@@ -550,22 +557,22 @@ gen_var_ref (struct agent_expr *ax, stru
       break;
 
     case LOC_ARG:		/* var lives in argument area of frame */
-      gen_frame_args_address (ax);
+      gen_frame_args_address (gdbarch, ax);
       gen_sym_offset (ax, var);
       value->kind = axs_lvalue_memory;
       break;
 
     case LOC_REF_ARG:		/* As above, but the frame slot really
 				   holds the address of the variable.  */
-      gen_frame_args_address (ax);
+      gen_frame_args_address (gdbarch, ax);
       gen_sym_offset (ax, var);
       /* Don't assume any particular pointer size.  */
-      gen_fetch (ax, lookup_pointer_type (builtin_type_void));
+      gen_fetch (ax, builtin_type (gdbarch)->builtin_data_ptr);
       value->kind = axs_lvalue_memory;
       break;
 
     case LOC_LOCAL:		/* var lives in locals area of frame */
-      gen_frame_locals_address (ax);
+      gen_frame_locals_address (gdbarch, ax);
       gen_sym_offset (ax, var);
       value->kind = axs_lvalue_memory;
       break;
@@ -697,7 +704,8 @@ require_rvalue (struct agent_expr *ax, s
    lvalue through unchanged, and let `+' raise an error.  */
 
 static void
-gen_usual_unary (struct agent_expr *ax, struct axs_value *value)
+gen_usual_unary (struct expression *exp, struct agent_expr *ax,
+		 struct axs_value *value)
 {
   /* We don't have to generate any code for the usual integral
      conversions, since values are always represented as full-width on
@@ -732,7 +740,7 @@ gen_usual_unary (struct agent_expr *ax, 
 
       /* If the value is an enum, call it an integer.  */
     case TYPE_CODE_ENUM:
-      value->type = builtin_type_int;
+      value->type = builtin_type (exp->gdbarch)->builtin_int;
       break;
     }
 
@@ -817,8 +825,8 @@ is_nontrivial_conversion (struct type *f
    and promotes each argument to that type.  *VALUE1 and *VALUE2
    describe the values as they are passed in, and as they are left.  */
 static void
-gen_usual_arithmetic (struct agent_expr *ax, struct axs_value *value1,
-		      struct axs_value *value2)
+gen_usual_arithmetic (struct expression *exp, struct agent_expr *ax,
+		      struct axs_value *value1, struct axs_value *value2)
 {
   /* Do the usual binary conversions.  */
   if (TYPE_CODE (value1->type) == TYPE_CODE_INT
@@ -829,7 +837,7 @@ gen_usual_arithmetic (struct agent_expr 
          unsigned type is considered "wider" than an n-bit signed
          type.  Promote to the "wider" of the two types, and always
          promote at least to int.  */
-      struct type *target = max_type (builtin_type_int,
+      struct type *target = max_type (builtin_type (exp->gdbarch)->builtin_int,
 				      max_type (value1->type, value2->type));
 
       /* Deal with value2, on the top of the stack.  */
@@ -854,17 +862,20 @@ gen_usual_arithmetic (struct agent_expr 
    the value on the top of the stack, as described by VALUE.  Assume
    the value has integral type.  */
 static void
-gen_integral_promotions (struct agent_expr *ax, struct axs_value *value)
+gen_integral_promotions (struct expression *exp, struct agent_expr *ax,
+			 struct axs_value *value)
 {
-  if (!type_wider_than (value->type, builtin_type_int))
+  const struct builtin_type *builtin = builtin_type (exp->gdbarch);
+
+  if (!type_wider_than (value->type, builtin->builtin_int))
     {
-      gen_conversion (ax, value->type, builtin_type_int);
-      value->type = builtin_type_int;
+      gen_conversion (ax, value->type, builtin->builtin_int);
+      value->type = builtin->builtin_int;
     }
-  else if (!type_wider_than (value->type, builtin_type_unsigned_int))
+  else if (!type_wider_than (value->type, builtin->builtin_unsigned_int))
     {
-      gen_conversion (ax, value->type, builtin_type_unsigned_int);
-      value->type = builtin_type_unsigned_int;
+      gen_conversion (ax, value->type, builtin->builtin_unsigned_int);
+      value->type = builtin->builtin_unsigned_int;
     }
 }
 
@@ -937,105 +948,60 @@ gen_scale (struct agent_expr *ax, enum a
 }
 
 
-/* Generate code for an addition; non-trivial because we deal with
-   pointer arithmetic.  We set VALUE to describe the result value; we
-   assume VALUE1 and VALUE2 describe the two operands, and that
-   they've undergone the usual binary conversions.  Used by both
-   BINOP_ADD and BINOP_SUBSCRIPT.  NAME is used in error messages.  */
+/* Generate code for pointer arithmetic PTR + INT.  */
 static void
-gen_add (struct agent_expr *ax, struct axs_value *value,
-	 struct axs_value *value1, struct axs_value *value2, char *name)
+gen_ptradd (struct agent_expr *ax, struct axs_value *value,
+	    struct axs_value *value1, struct axs_value *value2)
 {
-  /* Is it INT+PTR?  */
-  if (TYPE_CODE (value1->type) == TYPE_CODE_INT
-      && TYPE_CODE (value2->type) == TYPE_CODE_PTR)
-    {
-      /* Swap the values and proceed normally.  */
-      ax_simple (ax, aop_swap);
-      gen_scale (ax, aop_mul, value2->type);
-      ax_simple (ax, aop_add);
-      gen_extend (ax, value2->type);	/* Catch overflow.  */
-      value->type = value2->type;
-    }
+  gdb_assert (TYPE_CODE (value1->type) == TYPE_CODE_PTR);
+  gdb_assert (TYPE_CODE (value2->type) == TYPE_CODE_INT);
 
-  /* Is it PTR+INT?  */
-  else if (TYPE_CODE (value1->type) == TYPE_CODE_PTR
-	   && TYPE_CODE (value2->type) == TYPE_CODE_INT)
-    {
-      gen_scale (ax, aop_mul, value1->type);
-      ax_simple (ax, aop_add);
-      gen_extend (ax, value1->type);	/* Catch overflow.  */
-      value->type = value1->type;
-    }
+  gen_scale (ax, aop_mul, value1->type);
+  ax_simple (ax, aop_add);
+  gen_extend (ax, value1->type);	/* Catch overflow.  */
+  value->type = value1->type;
+  value->kind = axs_rvalue;
+}
 
-  /* Must be number + number; the usual binary conversions will have
-     brought them both to the same width.  */
-  else if (TYPE_CODE (value1->type) == TYPE_CODE_INT
-	   && TYPE_CODE (value2->type) == TYPE_CODE_INT)
-    {
-      ax_simple (ax, aop_add);
-      gen_extend (ax, value1->type);	/* Catch overflow.  */
-      value->type = value1->type;
-    }
 
-  else
-    error (_("Invalid combination of types in %s."), name);
+/* Generate code for pointer arithmetic PTR - INT.  */
+static void
+gen_ptrsub (struct agent_expr *ax, struct axs_value *value,
+	    struct axs_value *value1, struct axs_value *value2)
+{
+  gdb_assert (TYPE_CODE (value1->type) == TYPE_CODE_PTR);
+  gdb_assert (TYPE_CODE (value2->type) == TYPE_CODE_INT);
 
+  gen_scale (ax, aop_mul, value1->type);
+  ax_simple (ax, aop_sub);
+  gen_extend (ax, value1->type);	/* Catch overflow.  */
+  value->type = value1->type;
   value->kind = axs_rvalue;
 }
 
 
-/* Generate code for an addition; non-trivial because we have to deal
-   with pointer arithmetic.  We set VALUE to describe the result
-   value; we assume VALUE1 and VALUE2 describe the two operands, and
-   that they've undergone the usual binary conversions.  */
+/* Generate code for pointer arithmetic PTR - PTR.  */
 static void
-gen_sub (struct agent_expr *ax, struct axs_value *value,
-	 struct axs_value *value1, struct axs_value *value2)
-{
-  if (TYPE_CODE (value1->type) == TYPE_CODE_PTR)
-    {
-      /* Is it PTR - INT?  */
-      if (TYPE_CODE (value2->type) == TYPE_CODE_INT)
-	{
-	  gen_scale (ax, aop_mul, value1->type);
-	  ax_simple (ax, aop_sub);
-	  gen_extend (ax, value1->type);	/* Catch overflow.  */
-	  value->type = value1->type;
-	}
-
-      /* Is it PTR - PTR?  Strictly speaking, the types ought to
-         match, but this is what the normal GDB expression evaluator
-         tests for.  */
-      else if (TYPE_CODE (value2->type) == TYPE_CODE_PTR
-	       && (TYPE_LENGTH (TYPE_TARGET_TYPE (value1->type))
-		   == TYPE_LENGTH (TYPE_TARGET_TYPE (value2->type))))
-	{
-	  ax_simple (ax, aop_sub);
-	  gen_scale (ax, aop_div_unsigned, value1->type);
-	  value->type = builtin_type_long;	/* FIXME --- should be ptrdiff_t */
-	}
-      else
-	error (_("\
+gen_ptrdiff (struct agent_expr *ax, struct axs_value *value,
+	     struct axs_value *value1, struct axs_value *value2,
+	     struct type *result_type)
+{
+  gdb_assert (TYPE_CODE (value1->type) == TYPE_CODE_PTR);
+  gdb_assert (TYPE_CODE (value2->type) == TYPE_CODE_PTR);
+
+  if (TYPE_LENGTH (TYPE_TARGET_TYPE (value1->type))
+      != TYPE_LENGTH (TYPE_TARGET_TYPE (value2->type)))
+    error (_("\
 First argument of `-' is a pointer, but second argument is neither\n\
 an integer nor a pointer of the same type."));
-    }
-
-  /* Must be number + number.  */
-  else if (TYPE_CODE (value1->type) == TYPE_CODE_INT
-	   && TYPE_CODE (value2->type) == TYPE_CODE_INT)
-    {
-      ax_simple (ax, aop_sub);
-      gen_extend (ax, value1->type);	/* Catch overflow.  */
-      value->type = value1->type;
-    }
-
-  else
-    error (_("Invalid combination of types in subtraction."));
 
+  ax_simple (ax, aop_sub);
+  gen_scale (ax, aop_div_unsigned, value1->type);
+  value->type = result_type;
   value->kind = axs_rvalue;
 }
 
+
 /* Generate code for a binary operator that doesn't do pointer magic.
    We set VALUE to describe the result value; we assume VALUE1 and
    VALUE2 describe the two operands, and that they've undergone the
@@ -1062,15 +1028,15 @@ gen_binop (struct agent_expr *ax, struct
 
 
 static void
-gen_logical_not (struct agent_expr *ax, struct axs_value *value)
+gen_logical_not (struct agent_expr *ax, struct axs_value *value,
+		 struct type *result_type)
 {
   if (TYPE_CODE (value->type) != TYPE_CODE_INT
       && TYPE_CODE (value->type) != TYPE_CODE_PTR)
     error (_("Invalid type of operand to `!'."));
 
-  gen_usual_unary (ax, value);
   ax_simple (ax, aop_log_not);
-  value->type = builtin_type_int;
+  value->type = result_type;
 }
 
 
@@ -1080,8 +1046,6 @@ gen_complement (struct agent_expr *ax, s
   if (TYPE_CODE (value->type) != TYPE_CODE_INT)
     error (_("Invalid type of operand to `~'."));
 
-  gen_usual_unary (ax, value);
-  gen_integral_promotions (ax, value);
   ax_simple (ax, aop_bit_not);
   gen_extend (ax, value->type);
 }
@@ -1355,7 +1319,7 @@ gen_struct_ref (struct agent_expr *ax, s
      should at least be consistent.  */
   while (TYPE_CODE (value->type) == TYPE_CODE_PTR)
     {
-      gen_usual_unary (ax, value);
+      require_rvalue (ax, value);
       gen_deref (ax, value);
     }
   type = check_typedef (value->type);
@@ -1400,13 +1364,13 @@ gen_struct_ref (struct agent_expr *ax, s
    stack slots, doing weird things with sizeof, etc.  So we require
    the right operand to be a constant expression.  */
 static void
-gen_repeat (union exp_element **pc, struct agent_expr *ax,
-	    struct axs_value *value)
+gen_repeat (struct expression *exp, union exp_element **pc,
+	    struct agent_expr *ax, struct axs_value *value)
 {
   struct axs_value value1;
   /* We don't want to turn this into an rvalue, so no conversions
      here.  */
-  gen_expr (pc, ax, &value1);
+  gen_expr (exp, pc, ax, &value1);
   if (value1.kind != axs_lvalue_memory)
     error (_("Left operand of `@' must be an object in memory."));
 
@@ -1429,7 +1393,7 @@ gen_repeat (union exp_element **pc, stru
       /* FIXME-type-allocation: need a way to free this type when we are
          done with it.  */
       struct type *range
-      = create_range_type (0, builtin_type_int, 0, length - 1);
+      = create_range_type (0, builtin_type_int32, 0, length - 1);
       struct type *array = create_array_type (0, value1.type, range);
 
       value->kind = axs_lvalue_memory;
@@ -1443,8 +1407,9 @@ gen_repeat (union exp_element **pc, stru
    *PC should point at the start of the operand expression; we advance it
    to the first instruction after the operand.  */
 static void
-gen_sizeof (union exp_element **pc, struct agent_expr *ax,
-	    struct axs_value *value)
+gen_sizeof (struct expression *exp, union exp_element **pc,
+	    struct agent_expr *ax, struct axs_value *value,
+	    struct type *size_type)
 {
   /* We don't care about the value of the operand expression; we only
      care about its type.  However, in the current arrangement, the
@@ -1452,14 +1417,14 @@ gen_sizeof (union exp_element **pc, stru
      So we generate code for the operand, and then throw it away,
      replacing it with code that simply pushes its size.  */
   int start = ax->len;
-  gen_expr (pc, ax, value);
+  gen_expr (exp, pc, ax, value);
 
   /* Throw away the code we just generated.  */
   ax->len = start;
 
   ax_const_l (ax, TYPE_LENGTH (value->type));
   value->kind = axs_rvalue;
-  value->type = builtin_type_int;
+  value->type = size_type;
 }
 
 
@@ -1469,8 +1434,8 @@ gen_sizeof (union exp_element **pc, stru
 /* A gen_expr function written by a Gen-X'er guy.
    Append code for the subexpression of EXPR starting at *POS_P to AX.  */
 static void
-gen_expr (union exp_element **pc, struct agent_expr *ax,
-	  struct axs_value *value)
+gen_expr (struct expression *exp, union exp_element **pc,
+	  struct agent_expr *ax, struct axs_value *value)
 {
   /* Used to hold the descriptions of operand expressions.  */
   struct axs_value value1, value2;
@@ -1503,18 +1468,40 @@ gen_expr (union exp_element **pc, struct
     case BINOP_BITWISE_IOR:
     case BINOP_BITWISE_XOR:
       (*pc)++;
-      gen_expr (pc, ax, &value1);
-      gen_usual_unary (ax, &value1);
-      gen_expr (pc, ax, &value2);
-      gen_usual_unary (ax, &value2);
-      gen_usual_arithmetic (ax, &value1, &value2);
+      gen_expr (exp, pc, ax, &value1);
+      gen_usual_unary (exp, ax, &value1);
+      gen_expr (exp, pc, ax, &value2);
+      gen_usual_unary (exp, ax, &value2);
+      gen_usual_arithmetic (exp, ax, &value1, &value2);
       switch (op)
 	{
 	case BINOP_ADD:
-	  gen_add (ax, value, &value1, &value2, "addition");
+	  if (TYPE_CODE (value1.type) == TYPE_CODE_INT
+	      && TYPE_CODE (value2.type) == TYPE_CODE_PTR)
+	    {
+	      /* Swap the values and proceed normally.  */
+	      ax_simple (ax, aop_swap);
+	      gen_ptradd (ax, value, &value2, &value1);
+	    }
+	  else if (TYPE_CODE (value1.type) == TYPE_CODE_PTR
+		   && TYPE_CODE (value2.type) == TYPE_CODE_INT)
+	    gen_ptradd (ax, value, &value1, &value2);
+	  else
+	    gen_binop (ax, value, &value1, &value2,
+		       aop_add, aop_add, 1, "addition");
 	  break;
 	case BINOP_SUB:
-	  gen_sub (ax, value, &value1, &value2);
+	  if (TYPE_CODE (value1.type) == TYPE_CODE_PTR
+	      && TYPE_CODE (value2.type) == TYPE_CODE_INT)
+	    gen_ptrsub (ax,value, &value1, &value2);
+	  else if (TYPE_CODE (value1.type) == TYPE_CODE_PTR
+		   && TYPE_CODE (value2.type) == TYPE_CODE_PTR)
+	    /* FIXME --- result type should be ptrdiff_t */
+	    gen_ptrdiff (ax, value, &value1, &value2,
+		         builtin_type (exp->gdbarch)->builtin_long);
+	  else
+	    gen_binop (ax, value, &value1, &value2,
+		       aop_sub, aop_sub, 1, "subtraction");
 	  break;
 	case BINOP_MUL:
 	  gen_binop (ax, value, &value1, &value2,
@@ -1529,7 +1516,7 @@ gen_expr (union exp_element **pc, struct
 		     aop_rem_signed, aop_rem_unsigned, 1, "remainder");
 	  break;
 	case BINOP_SUBSCRIPT:
-	  gen_add (ax, value, &value1, &value2, "array subscripting");
+	  gen_ptradd (ax, value, &value1, &value2);
 	  if (TYPE_CODE (value->type) != TYPE_CODE_PTR)
 	    error (_("Invalid combination of types in array subscripting."));
 	  gen_deref (ax, value);
@@ -1565,12 +1552,12 @@ gen_expr (union exp_element **pc, struct
          variables it mentions get traced.  */
     case BINOP_COMMA:
       (*pc)++;
-      gen_expr (pc, ax, &value1);
+      gen_expr (exp, pc, ax, &value1);
       /* Don't just dispose of the left operand.  We might be tracing,
          in which case we want to emit code to trace it if it's an
          lvalue.  */
       gen_traced_pop (ax, &value1);
-      gen_expr (pc, ax, value);
+      gen_expr (exp, pc, ax, value);
       /* It's the consumer's responsibility to trace the right operand.  */
       break;
 
@@ -1584,7 +1571,7 @@ gen_expr (union exp_element **pc, struct
       break;
 
     case OP_VAR_VALUE:
-      gen_var_ref (ax, value, (*pc)[2].symbol);
+      gen_var_ref (exp->gdbarch, ax, value, (*pc)[2].symbol);
       (*pc) += 4;
       break;
 
@@ -1593,18 +1580,17 @@ gen_expr (union exp_element **pc, struct
 	const char *name = &(*pc)[2].string;
 	int reg;
 	(*pc) += 4 + BYTES_TO_EXP_ELEM ((*pc)[1].longconst + 1);
-	reg = user_reg_map_name_to_regnum (current_gdbarch,
-					   name, strlen (name));
+	reg = user_reg_map_name_to_regnum (exp->gdbarch, name, strlen (name));
 	if (reg == -1)
 	  internal_error (__FILE__, __LINE__,
 			  _("Register $%s not available"), name);
-	if (reg >= gdbarch_num_regs (current_gdbarch))
+	if (reg >= gdbarch_num_regs (exp->gdbarch))
 	  error (_("'%s' is a pseudo-register; "
 		   "GDB cannot yet trace pseudoregister contents."),
 		 name);
 	value->kind = axs_lvalue_register;
 	value->u.reg = reg;
-	value->type = register_type (current_gdbarch, reg);
+	value->type = register_type (exp->gdbarch, reg);
       }
       break;
 
@@ -1615,14 +1601,14 @@ gen_expr (union exp_element **pc, struct
     case BINOP_REPEAT:
       /* Note that gen_repeat handles its own argument evaluation.  */
       (*pc)++;
-      gen_repeat (pc, ax, value);
+      gen_repeat (exp, pc, ax, value);
       break;
 
     case UNOP_CAST:
       {
 	struct type *type = (*pc)[1].type;
 	(*pc) += 3;
-	gen_expr (pc, ax, value);
+	gen_expr (exp, pc, ax, value);
 	gen_cast (ax, value, type);
       }
       break;
@@ -1631,7 +1617,7 @@ gen_expr (union exp_element **pc, struct
       {
 	struct type *type = check_typedef ((*pc)[1].type);
 	(*pc) += 3;
-	gen_expr (pc, ax, value);
+	gen_expr (exp, pc, ax, value);
 	/* I'm not sure I understand UNOP_MEMVAL entirely.  I think
 	   it's just a hack for dealing with minsyms; you take some
 	   integer constant, pretend it's the address of an lvalue of
@@ -1648,37 +1634,41 @@ gen_expr (union exp_element **pc, struct
     case UNOP_PLUS:
       (*pc)++;
       /* + FOO is equivalent to 0 + FOO, which can be optimized. */
-      gen_expr (pc, ax, value);
-      gen_usual_unary (ax, value);
+      gen_expr (exp, pc, ax, value);
+      gen_usual_unary (exp, ax, value);
       break;
       
     case UNOP_NEG:
       (*pc)++;
       /* -FOO is equivalent to 0 - FOO.  */
-      gen_int_literal (ax, &value1, (LONGEST) 0, builtin_type_int);
-      gen_usual_unary (ax, &value1);	/* shouldn't do much */
-      gen_expr (pc, ax, &value2);
-      gen_usual_unary (ax, &value2);
-      gen_usual_arithmetic (ax, &value1, &value2);
-      gen_sub (ax, value, &value1, &value2);
+      gen_int_literal (ax, &value1, (LONGEST) 0, builtin_type_int8);
+      gen_usual_unary (exp, ax, &value1);	/* shouldn't do much */
+      gen_expr (exp, pc, ax, &value2);
+      gen_usual_unary (exp, ax, &value2);
+      gen_usual_arithmetic (exp, ax, &value1, &value2);
+      gen_binop (ax, value, &value1, &value2, aop_sub, aop_sub, 1, "negation");
       break;
 
     case UNOP_LOGICAL_NOT:
       (*pc)++;
-      gen_expr (pc, ax, value);
-      gen_logical_not (ax, value);
+      gen_expr (exp, pc, ax, value);
+      gen_usual_unary (exp, ax, value);
+      gen_logical_not (ax, value,
+		       language_bool_type (exp->language_defn, exp->gdbarch));
       break;
 
     case UNOP_COMPLEMENT:
       (*pc)++;
-      gen_expr (pc, ax, value);
+      gen_expr (exp, pc, ax, value);
+      gen_usual_unary (exp, ax, value);
+      gen_integral_promotions (exp, ax, value);
       gen_complement (ax, value);
       break;
 
     case UNOP_IND:
       (*pc)++;
-      gen_expr (pc, ax, value);
-      gen_usual_unary (ax, value);
+      gen_expr (exp, pc, ax, value);
+      gen_usual_unary (exp, ax, value);
       if (TYPE_CODE (value->type) != TYPE_CODE_PTR)
 	error (_("Argument of unary `*' is not a pointer."));
       gen_deref (ax, value);
@@ -1686,7 +1676,7 @@ gen_expr (union exp_element **pc, struct
 
     case UNOP_ADDR:
       (*pc)++;
-      gen_expr (pc, ax, value);
+      gen_expr (exp, pc, ax, value);
       gen_address_of (ax, value);
       break;
 
@@ -1695,7 +1685,8 @@ gen_expr (union exp_element **pc, struct
       /* Notice that gen_sizeof handles its own operand, unlike most
          of the other unary operator functions.  This is because we
          have to throw away the code we generate.  */
-      gen_sizeof (pc, ax, value);
+      gen_sizeof (exp, pc, ax, value,
+		  builtin_type (exp->gdbarch)->builtin_int);
       break;
 
     case STRUCTOP_STRUCT:
@@ -1705,7 +1696,7 @@ gen_expr (union exp_element **pc, struct
 	char *name = &(*pc)[2].string;
 
 	(*pc) += 4 + BYTES_TO_EXP_ELEM (length + 1);
-	gen_expr (pc, ax, value);
+	gen_expr (exp, pc, ax, value);
 	if (op == STRUCTOP_STRUCT)
 	  gen_struct_ref (ax, value, name, ".", "structure or union");
 	else if (op == STRUCTOP_PTR)
@@ -1748,7 +1739,7 @@ gen_trace_for_expr (CORE_ADDR scope, str
 
   pc = expr->elts;
   trace_kludge = 1;
-  gen_expr (&pc, ax, &value);
+  gen_expr (expr, &pc, ax, &value);
 
   /* Make sure we record the final object, and get rid of it.  */
   gen_traced_pop (ax, &value);
Index: gdb-head/gdb/value.c
===================================================================
--- gdb-head.orig/gdb/value.c
+++ gdb-head/gdb/value.c
@@ -249,7 +249,7 @@ allocate_repeat_value (struct type *type
   /* FIXME-type-allocation: need a way to free this type when we are
      done with it.  */
   struct type *range_type
-  = create_range_type ((struct type *) NULL, builtin_type_int,
+  = create_range_type ((struct type *) NULL, builtin_type_int32,
 		       low_bound, count + low_bound - 1);
   /* FIXME-type-allocation: need a way to free this type when we are
      done with it.  */
@@ -1638,7 +1638,7 @@ value_from_string (char *ptr)
   struct type *stringtype;
 
   rangetype = create_range_type ((struct type *) NULL,
-				 builtin_type_int,
+				 builtin_type_int32,
 				 lowbound, len + lowbound - 1);
   string_char_type = language_string_char_type (current_language,
 						current_gdbarch);
@@ -1700,22 +1700,6 @@ coerce_array (struct value *arg)
     arg = value_coerce_function (arg);
   return arg;
 }
-
-struct value *
-coerce_number (struct value *arg)
-{
-  arg = coerce_array (arg);
-  arg = coerce_enum (arg);
-  return arg;
-}
-
-struct value *
-coerce_enum (struct value *arg)
-{
-  if (TYPE_CODE (check_typedef (value_type (arg))) == TYPE_CODE_ENUM)
-    arg = value_cast (builtin_type_unsigned_int, arg);
-  return arg;
-}
 
 
 /* Return true if the function returning the specified type is using
Index: gdb-head/gdb/scm-lang.c
===================================================================
--- gdb-head.orig/gdb/scm-lang.c
+++ gdb-head/gdb/scm-lang.c
@@ -32,6 +32,7 @@
 #include "gdb_string.h"
 #include "gdbcore.h"
 #include "infcall.h"
+#include "objfiles.h"
 
 extern void _initialize_scheme_language (void);
 static struct value *evaluate_subexp_scm (struct type *, struct expression *,
@@ -147,13 +148,19 @@ in_eval_c (void)
 static struct value *
 scm_lookup_name (char *str)
 {
+  struct objfile *objf;
+  struct gdbarch *gdbarch;
   struct value *args[3];
   int len = strlen (str);
   struct value *func;
   struct value *val;
   struct symbol *sym;
+
+  func = find_function_in_inferior ("scm_lookup_cstr", &objf);
+  gdbarch = get_objfile_arch (objf);
+
   args[0] = value_allocate_space_in_inferior (len);
-  args[1] = value_from_longest (builtin_type_int, len);
+  args[1] = value_from_longest (builtin_type (gdbarch)->builtin_int, len);
   write_memory (value_as_long (args[0]), (gdb_byte *) str, len);
 
   if (in_eval_c ()
@@ -165,7 +172,6 @@ scm_lookup_name (char *str)
     /* FIXME in this case, we should try lookup_symbol first */
     args[2] = value_from_longest (builtin_type_scm, SCM_EOL);
 
-  func = find_function_in_inferior ("scm_lookup_cstr");
   val = call_function_by_hand (func, 3, args);
   if (!value_logical_not (val))
     return value_ind (val);
@@ -187,7 +193,7 @@ scm_evaluate_string (char *str, int len)
   write_memory (iaddr, (gdb_byte *) str, len);
   /* FIXME - should find and pass env */
   write_memory (iaddr + len, (gdb_byte *) "", 1);
-  func = find_function_in_inferior ("scm_evstr");
+  func = find_function_in_inferior ("scm_evstr", NULL);
   return call_function_by_hand (func, 1, &addr);
 }
 
@@ -220,7 +226,7 @@ evaluate_exp (struct type *expect_type, 
     }
   return evaluate_subexp_standard (expect_type, exp, pos, noside);
 nosideret:
-  return value_from_longest (builtin_type_long, (LONGEST) 1);
+  return value_from_longest (builtin_type_int8, (LONGEST) 1);
 }
 
 const struct exp_descriptor exp_descriptor_scm = 
Index: gdb-head/gdb/ada-valprint.c
===================================================================
--- gdb-head.orig/gdb/ada-valprint.c
+++ gdb-head/gdb/ada-valprint.c
@@ -33,6 +33,7 @@
 #include "c-lang.h"
 #include "infcall.h"
 #include "exceptions.h"
+#include "objfiles.h"
 
 /* Encapsulates arguments to ada_val_print.  */
 struct ada_val_print_args
@@ -121,7 +122,7 @@ print_optional_low_bound (struct ui_file
 	return 0;
       break;
     case TYPE_CODE_UNDEF:
-      index_type = builtin_type_long;
+      index_type = builtin_type_int32;
       /* FALL THROUGH */
     default:
       if (low_bound == 1)
@@ -751,8 +752,8 @@ ada_val_print_1 (struct type *type, cons
 		parray_of_char =
 		  make_pointer_type
 		  (create_array_type
-		   (NULL, builtin_type_char,
-		    create_range_type (NULL, builtin_type_int, 0, 32)), NULL);
+		   (NULL, builtin_type_true_char,
+		    create_range_type (NULL, builtin_type_int32, 0, 32)), NULL);
 
 	      printable_val =
 		value_ind (value_cast (parray_of_char,
@@ -792,18 +793,27 @@ ada_val_print_1 (struct type *type, cons
 	    {
 	      print_scalar_formatted (valaddr, type, format, 0, stream);
 	    }
-          else if (ada_is_system_address_type (type))
+          else if (ada_is_system_address_type (type)
+		   && TYPE_OBJFILE (type) != NULL)
             {
               /* FIXME: We want to print System.Address variables using
                  the same format as for any access type.  But for some
                  reason GNAT encodes the System.Address type as an int,
                  so we have to work-around this deficiency by handling
-                 System.Address values as a special case.  */
+                 System.Address values as a special case.
+
+		 We do this only for System.Address types defined in an
+		 objfile.  For the built-in version of System.Address we
+		 have installed the proper type to begin with.  */
+
+	      struct gdbarch *gdbarch = get_objfile_arch (TYPE_OBJFILE (type));
+	      struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
+
               fprintf_filtered (stream, "(");
               type_print (type, "", stream, -1);
               fprintf_filtered (stream, ") ");
 	      fputs_filtered (paddress (extract_typed_address
-					(valaddr, builtin_type_void_data_ptr)),
+					(valaddr, ptr_type)),
 			      stream);
             }
 	  else
@@ -891,9 +901,7 @@ ada_val_print_1 (struct type *type, cons
       
       if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
         {
-          LONGEST deref_val_int = (LONGEST)
-            unpack_pointer (lookup_pointer_type (builtin_type_void),
-                            valaddr);
+          LONGEST deref_val_int = (LONGEST) unpack_pointer (type, valaddr);
           if (deref_val_int != 0)
             {
               struct value *deref_val =
Index: gdb-head/gdb/c-valprint.c
===================================================================
--- gdb-head.orig/gdb/c-valprint.c
+++ gdb-head/gdb/c-valprint.c
@@ -189,9 +189,7 @@ c_val_print (struct type *type, const gd
 	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
 	  break;
 	}
-      cp_print_class_member (valaddr + embedded_offset,
-			     TYPE_DOMAIN_TYPE (type),
-			     stream, "&");
+      cp_print_class_member (valaddr + embedded_offset, type, stream, "&");
       break;
 
     case TYPE_CODE_METHODPTR:
@@ -310,8 +308,7 @@ c_val_print (struct type *type, const gd
 	      struct value *deref_val =
 	      value_at
 	      (TYPE_TARGET_TYPE (type),
-	       unpack_pointer (lookup_pointer_type (builtin_type_void),
-			       valaddr + embedded_offset));
+	       unpack_pointer (type, valaddr + embedded_offset));
 	      common_val_print (deref_val, stream, format, deref_ref,
 				recurse, pretty, current_language);
 	    }
Index: gdb-head/gdb/f-valprint.c
===================================================================
--- gdb-head.orig/gdb/f-valprint.c
+++ gdb-head/gdb/f-valprint.c
@@ -99,10 +99,11 @@ f77_get_dynamic_lowerbound (struct type 
       current_frame_addr = get_frame_base (frame);
       if (current_frame_addr > 0)
 	{
+	  struct gdbarch *arch = get_frame_arch (frame);
 	  ptr_to_lower_bound =
 	    read_memory_typed_address (current_frame_addr +
 				       TYPE_ARRAY_LOWER_BOUND_VALUE (type),
-				       builtin_type_void_data_ptr);
+				       builtin_type (arch)->builtin_data_ptr);
 	  *lower_bound = read_memory_integer (ptr_to_lower_bound, 4);
 	}
       else
@@ -165,10 +166,11 @@ f77_get_dynamic_upperbound (struct type 
       current_frame_addr = get_frame_base (frame);
       if (current_frame_addr > 0)
 	{
+	  struct gdbarch *arch = get_frame_arch (frame);
 	  ptr_to_upper_bound =
 	    read_memory_typed_address (current_frame_addr +
 				       TYPE_ARRAY_UPPER_BOUND_VALUE (type),
-				       builtin_type_void_data_ptr);
+				       builtin_type (arch)->builtin_data_ptr);
 	  *upper_bound = read_memory_integer (ptr_to_upper_bound, 4);
 	}
       else
@@ -444,8 +446,7 @@ f_val_print (struct type *type, const gd
 	      struct value *deref_val =
 	      value_at
 	      (TYPE_TARGET_TYPE (type),
-	       unpack_pointer (lookup_pointer_type (builtin_type_void),
-			       valaddr + embedded_offset));
+	       unpack_pointer (type, valaddr + embedded_offset));
 	      common_val_print (deref_val, stream, format, deref_ref, recurse,
 				pretty, current_language);
 	    }
@@ -522,26 +523,7 @@ f_val_print (struct type *type, const gd
 	print_scalar_formatted (valaddr, type, format, 0, stream);
       else
 	{
-	  val = 0;
-	  switch (TYPE_LENGTH (type))
-	    {
-	    case 1:
-	      val = unpack_long (builtin_type_f_logical_s1, valaddr);
-	      break;
-
-	    case 2:
-	      val = unpack_long (builtin_type_f_logical_s2, valaddr);
-	      break;
-
-	    case 4:
-	      val = unpack_long (builtin_type_f_logical, valaddr);
-	      break;
-
-	    default:
-	      error (_("Logicals of length %d bytes not supported"),
-		     TYPE_LENGTH (type));
-
-	    }
+	  val = extract_unsigned_integer (valaddr, TYPE_LENGTH (type));
 
 	  if (val == 0)
 	    fprintf_filtered (stream, ".FALSE.");
@@ -561,20 +543,7 @@ f_val_print (struct type *type, const gd
       break;
 
     case TYPE_CODE_COMPLEX:
-      switch (TYPE_LENGTH (type))
-	{
-	case 8:
-	  type = builtin_type_f_real;
-	  break;
-	case 16:
-	  type = builtin_type_f_real_s8;
-	  break;
-	case 32:
-	  type = builtin_type_f_real_s16;
-	  break;
-	default:
-	  error (_("Cannot print out complex*%d variables"), TYPE_LENGTH (type));
-	}
+      type = TYPE_TARGET_TYPE (type);
       fputs_filtered ("(", stream);
       print_floating (valaddr, type, stream);
       fputs_filtered (",", stream);
Index: gdb-head/gdb/m2-valprint.c
===================================================================
--- gdb-head.orig/gdb/m2-valprint.c
+++ gdb-head/gdb/m2-valprint.c
@@ -119,7 +119,7 @@ m2_print_long_set (struct type *type, co
 
   target = TYPE_TARGET_TYPE (range);
   if (target == NULL)
-    target = builtin_type_int;
+    target = builtin_type_int32;
 
   if (get_discrete_bounds (range, &field_low, &field_high) >= 0)
     {
@@ -165,7 +165,7 @@ m2_print_long_set (struct type *type, co
 		break;
 	      target = TYPE_TARGET_TYPE (range);
 	      if (target == NULL)
-		target = builtin_type_int;
+		target = builtin_type_int32;
 	    }
 	}
       if (element_seen)
@@ -258,10 +258,7 @@ print_variable_at_address (struct type *
   if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
     {
       struct value *deref_val =
-	value_at
-	(TYPE_TARGET_TYPE (type),
-	 unpack_pointer (lookup_pointer_type (builtin_type_void),
-			 valaddr));
+	value_at (TYPE_TARGET_TYPE (type), unpack_pointer (type, valaddr));
       common_val_print (deref_val, stream, format, deref_ref,
 			recurse, pretty, current_language);
     }
@@ -420,8 +417,7 @@ m2_val_print (struct type *type, const g
 	      struct value *deref_val =
 		value_at
 		(TYPE_TARGET_TYPE (type),
-		 unpack_pointer (lookup_pointer_type (builtin_type_void),
-				 valaddr + embedded_offset));
+		 unpack_pointer (type, valaddr + embedded_offset));
 	      common_val_print (deref_val, stream, format, deref_ref,
 				recurse, pretty, current_language);
 	    }
Index: gdb-head/gdb/p-valprint.c
===================================================================
--- gdb-head.orig/gdb/p-valprint.c
+++ gdb-head/gdb/p-valprint.c
@@ -267,8 +267,7 @@ pascal_val_print (struct type *type, con
 	      struct value *deref_val =
 	      value_at
 	      (TYPE_TARGET_TYPE (type),
-	       unpack_pointer (lookup_pointer_type (builtin_type_void),
-			       valaddr + embedded_offset));
+	       unpack_pointer (type, valaddr + embedded_offset));
 	      common_val_print (deref_val, stream, format, deref_ref,
 				recurse + 1, pretty, current_language);
 	    }
Index: gdb-head/gdb/valops.c
===================================================================
--- gdb-head.orig/gdb/valops.c
+++ gdb-head/gdb/valops.c
@@ -44,6 +44,8 @@
 #include "gdb_assert.h"
 #include "cp-support.h"
 #include "observer.h"
+#include "objfiles.h"
+#include "symtab.h"
 
 extern int overload_debug;
 /* Local functions.  */
@@ -122,10 +124,12 @@ Overload resolution in evaluating C++ fu
 		    value);
 }
 
-/* Find the address of function name NAME in the inferior.  */
+/* Find the address of function name NAME in the inferior.  If OBJF_P
+   is non-NULL, *OBJF_P will be set to the OBJFILE where the function
+   is defined.  */
 
 struct value *
-find_function_in_inferior (const char *name)
+find_function_in_inferior (const char *name, struct objfile **objf_p)
 {
   struct symbol *sym;
   sym = lookup_symbol (name, 0, VAR_DOMAIN, 0);
@@ -136,6 +140,10 @@ find_function_in_inferior (const char *n
 	  error (_("\"%s\" exists in this program but is not a function."),
 		 name);
 	}
+
+      if (objf_p)
+	*objf_p = SYMBOL_SYMTAB (sym)->objfile;
+
       return value_of_variable (sym, NULL);
     }
   else
@@ -144,12 +152,19 @@ find_function_in_inferior (const char *n
 	lookup_minimal_symbol (name, NULL, NULL);
       if (msymbol != NULL)
 	{
+	  struct objfile *objfile = msymbol_objfile (msymbol);
+	  struct gdbarch *gdbarch = get_objfile_arch (objfile);
+
 	  struct type *type;
 	  CORE_ADDR maddr;
-	  type = lookup_pointer_type (builtin_type_char);
+	  type = lookup_pointer_type (builtin_type (gdbarch)->builtin_char);
 	  type = lookup_function_type (type);
 	  type = lookup_pointer_type (type);
 	  maddr = SYMBOL_VALUE_ADDRESS (msymbol);
+
+	  if (objf_p)
+	    *objf_p = objfile;
+
 	  return value_from_pointer (type, maddr);
 	}
       else
@@ -169,11 +184,12 @@ find_function_in_inferior (const char *n
 struct value *
 value_allocate_space_in_inferior (int len)
 {
+  struct objfile *objf;
+  struct value *val = find_function_in_inferior ("malloc", &objf);
+  struct gdbarch *gdbarch = get_objfile_arch (objf);
   struct value *blocklen;
-  struct value *val = 
-    find_function_in_inferior (gdbarch_name_of_malloc (current_gdbarch));
 
-  blocklen = value_from_longest (builtin_type_int, (LONGEST) len);
+  blocklen = value_from_longest (builtin_type (gdbarch)->builtin_int, len);
   val = call_function_by_hand (val, 1, &blocklen);
   if (value_logical_not (val))
     {
@@ -466,7 +482,7 @@ value_cast (struct type *type, struct va
 	   && value_as_long (arg2) == 0)
     {
       struct value *result = allocate_value (type);
-      cplus_make_method_ptr (value_contents_writeable (result), 0, 0);
+      cplus_make_method_ptr (type, value_contents_writeable (result), 0, 0);
       return result;
     }
   else if (code1 == TYPE_CODE_MEMBERPTR && code2 == TYPE_CODE_INT
@@ -522,11 +538,11 @@ value_one (struct type *type, enum lval_
 
   if (TYPE_CODE (type1) == TYPE_CODE_DECFLOAT)
     {
-      struct value *int_one = value_from_longest (builtin_type_int, 1);
+      struct value *int_one = value_from_longest (builtin_type_int32, 1);
       struct value *val;
       gdb_byte v[16];
 
-      decimal_from_integral (int_one, v, TYPE_LENGTH (builtin_type_int));
+      decimal_from_integral (int_one, v, TYPE_LENGTH (builtin_type_int32));
       val = value_from_decfloat (type, v);
     }
   else if (TYPE_CODE (type1) == TYPE_CODE_FLT)
@@ -1166,14 +1182,7 @@ value_ind (struct value *arg1)
 
   base_type = check_typedef (value_type (arg1));
 
-  /* Allow * on an integer so we can cast it to whatever we want.
-     This returns an int, which seems like the most C-like thing to
-     do.  "long long" variables are rare enough that
-     BUILTIN_TYPE_LONGEST would seem to be a mistake.  */
-  if (TYPE_CODE (base_type) == TYPE_CODE_INT)
-    return value_at_lazy (builtin_type_int,
-			  (CORE_ADDR) value_as_address (arg1));
-  else if (TYPE_CODE (base_type) == TYPE_CODE_PTR)
+  if (TYPE_CODE (base_type) == TYPE_CODE_PTR)
     {
       struct type *enc_type;
       /* We may be pointing to something embedded in a larger object.
@@ -1248,7 +1257,7 @@ value_array (int lowbound, int highbound
     }
 
   rangetype = create_range_type ((struct type *) NULL, 
-				 builtin_type_int,
+				 builtin_type_int32,
 				 lowbound, highbound);
   arraytype = create_array_type ((struct type *) NULL,
 				 value_enclosing_type (elemvec[0]), 
@@ -1292,7 +1301,7 @@ value_string (char *ptr, int len)
   struct value *val;
   int lowbound = current_language->string_lower_bound;
   struct type *rangetype = create_range_type ((struct type *) NULL,
-					      builtin_type_int,
+					      builtin_type_int32,
 					      lowbound, 
 					      len + lowbound - 1);
   struct type *stringtype
@@ -1322,7 +1331,7 @@ value_bitstring (char *ptr, int len)
 {
   struct value *val;
   struct type *domain_type = create_range_type (NULL, 
-						builtin_type_int,
+						builtin_type_int32,
 						0, len - 1);
   struct type *type = create_set_type ((struct type *) NULL, 
 				       domain_type);
@@ -2619,7 +2628,8 @@ value_struct_elt_for_reference (struct t
 		{
 		  result = allocate_value
 		    (lookup_methodptr_type (TYPE_FN_FIELD_TYPE (f, j)));
-		  cplus_make_method_ptr (value_contents_writeable (result),
+		  cplus_make_method_ptr (value_type (result),
+					 value_contents_writeable (result),
 					 TYPE_FN_FIELD_VOFFSET (f, j), 1);
 		}
 	      else if (noside == EVAL_AVOID_SIDE_EFFECTS)
@@ -2642,7 +2652,8 @@ value_struct_elt_for_reference (struct t
 	      else
 		{
 		  result = allocate_value (lookup_methodptr_type (TYPE_FN_FIELD_TYPE (f, j)));
-		  cplus_make_method_ptr (value_contents_writeable (result),
+		  cplus_make_method_ptr (value_type (result),
+					 value_contents_writeable (result),
 					 VALUE_ADDRESS (v), 0);
 		}
 	    }
Index: gdb-head/gdb/objc-lang.c
===================================================================
--- gdb-head.orig/gdb/objc-lang.c
+++ gdb-head/gdb/objc-lang.c
@@ -117,9 +117,9 @@ lookup_objc_class (char *classname)
     }
 
   if (lookup_minimal_symbol("objc_lookUpClass", 0, 0))
-    function = find_function_in_inferior("objc_lookUpClass");
+    function = find_function_in_inferior("objc_lookUpClass", NULL);
   else if (lookup_minimal_symbol ("objc_lookup_class", 0, 0))
-    function = find_function_in_inferior("objc_lookup_class");
+    function = find_function_in_inferior("objc_lookup_class", NULL);
   else
     {
       complaint (&symfile_complaints, _("no way to lookup Objective-C classes"));
@@ -144,9 +144,9 @@ lookup_child_selector (char *selname)
     }
 
   if (lookup_minimal_symbol("sel_getUid", 0, 0))
-    function = find_function_in_inferior("sel_getUid");
+    function = find_function_in_inferior("sel_getUid", NULL);
   else if (lookup_minimal_symbol ("sel_get_any_uid", 0, 0))
-    function = find_function_in_inferior("sel_get_any_uid");
+    function = find_function_in_inferior("sel_get_any_uid", NULL);
   else
     {
       complaint (&symfile_complaints, _("no way to lookup Objective-C selectors"));
@@ -165,43 +165,50 @@ value_nsstring (char *ptr, int len)
   struct value *function, *nsstringValue;
   struct symbol *sym;
   struct type *type;
+  struct objfile *objf;
+  struct gdbarch *gdbarch;
 
   if (!target_has_execution)
     return 0;		/* Can't call into inferior to create NSString.  */
 
-  sym = lookup_struct_typedef("NSString", 0, 1);
-  if (sym == NULL)
-    sym = lookup_struct_typedef("NXString", 0, 1);
-  if (sym == NULL)
-    type = lookup_pointer_type(builtin_type_void);
-  else
-    type = lookup_pointer_type(SYMBOL_TYPE (sym));
-
   stringValue[2] = value_string(ptr, len);
   stringValue[2] = value_coerce_array(stringValue[2]);
   /* _NSNewStringFromCString replaces "istr" after Lantern2A.  */
   if (lookup_minimal_symbol("_NSNewStringFromCString", 0, 0))
     {
-      function = find_function_in_inferior("_NSNewStringFromCString");
+      function = find_function_in_inferior("_NSNewStringFromCString", &objf);
       nsstringValue = call_function_by_hand(function, 1, &stringValue[2]);
     }
   else if (lookup_minimal_symbol("istr", 0, 0))
     {
-      function = find_function_in_inferior("istr");
+      function = find_function_in_inferior("istr", &objf);
       nsstringValue = call_function_by_hand(function, 1, &stringValue[2]);
     }
   else if (lookup_minimal_symbol("+[NSString stringWithCString:]", 0, 0))
     {
-      function = find_function_in_inferior("+[NSString stringWithCString:]");
+      function
+	= find_function_in_inferior("+[NSString stringWithCString:]", &objf);
+      type = builtin_type (get_objfile_arch (objf))->builtin_long;
+
       stringValue[0] = value_from_longest 
-	(builtin_type_long, lookup_objc_class ("NSString"));
+	(type, lookup_objc_class ("NSString"));
       stringValue[1] = value_from_longest 
-	(builtin_type_long, lookup_child_selector ("stringWithCString:"));
+	(type, lookup_child_selector ("stringWithCString:"));
       nsstringValue = call_function_by_hand(function, 3, &stringValue[0]);
     }
   else
     error (_("NSString: internal error -- no way to create new NSString"));
 
+  gdbarch = get_objfile_arch (objf);
+
+  sym = lookup_struct_typedef("NSString", 0, 1);
+  if (sym == NULL)
+    sym = lookup_struct_typedef("NXString", 0, 1);
+  if (sym == NULL)
+    type = builtin_type (gdbarch)->builtin_data_ptr;
+  else
+    type = lookup_pointer_type(SYMBOL_TYPE (sym));
+
   deprecated_set_value_type (nsstringValue, type);
   return nsstringValue;
 }
@@ -1378,7 +1385,7 @@ print_object_command (char *args, int fr
     int pc = 0;
 
     object = expr->language_defn->la_exp_desc->evaluate_exp 
-      (builtin_type_void_data_ptr, expr, &pc, EVAL_NORMAL);
+      (builtin_type (expr->gdbarch)->builtin_data_ptr, expr, &pc, EVAL_NORMAL);
     do_cleanups (old_chain);
   }
 
@@ -1386,7 +1393,7 @@ print_object_command (char *args, int fr
   object_addr = value_as_long (object);
   read_memory (object_addr, &c, 1);
 
-  function = find_function_in_inferior ("_NSPrintForDebugger");
+  function = find_function_in_inferior ("_NSPrintForDebugger", NULL);
   if (function == NULL)
     error (_("Unable to locate _NSPrintForDebugger in child process"));
 
@@ -1679,19 +1686,19 @@ find_implementation (CORE_ADDR object, C
   return find_implementation_from_class (ostr.isa, sel);
 }
 
-#define OBJC_FETCH_POINTER_ARGUMENT(argi) \
-  gdbarch_fetch_pointer_argument (current_gdbarch, get_current_frame (), \
-				  argi, builtin_type_void_func_ptr)
-
 static int
 resolve_msgsend (CORE_ADDR pc, CORE_ADDR *new_pc)
 {
+  struct frame_info *frame = get_current_frame ();
+  struct gdbarch *gdbarch = get_frame_arch (frame);
+  struct type *ptr_type = builtin_type (gdbarch)->builtin_func_ptr;
+
   CORE_ADDR object;
   CORE_ADDR sel;
   CORE_ADDR res;
 
-  object = OBJC_FETCH_POINTER_ARGUMENT (0);
-  sel = OBJC_FETCH_POINTER_ARGUMENT (1);
+  object = gdbarch_fetch_pointer_argument (gdbarch, frame, 0, ptr_type);
+  sel = gdbarch_fetch_pointer_argument (gdbarch, frame, 1, ptr_type);
 
   res = find_implementation (object, sel);
   if (new_pc != 0)
@@ -1704,12 +1711,16 @@ resolve_msgsend (CORE_ADDR pc, CORE_ADDR
 static int
 resolve_msgsend_stret (CORE_ADDR pc, CORE_ADDR *new_pc)
 {
+  struct frame_info *frame = get_current_frame ();
+  struct gdbarch *gdbarch = get_frame_arch (frame);
+  struct type *ptr_type = builtin_type (gdbarch)->builtin_func_ptr;
+
   CORE_ADDR object;
   CORE_ADDR sel;
   CORE_ADDR res;
 
-  object = OBJC_FETCH_POINTER_ARGUMENT (1);
-  sel = OBJC_FETCH_POINTER_ARGUMENT (2);
+  object = gdbarch_fetch_pointer_argument (gdbarch, frame, 1, ptr_type);
+  sel = gdbarch_fetch_pointer_argument (gdbarch, frame, 2, ptr_type);
 
   res = find_implementation (object, sel);
   if (new_pc != 0)
@@ -1722,14 +1733,18 @@ resolve_msgsend_stret (CORE_ADDR pc, COR
 static int
 resolve_msgsend_super (CORE_ADDR pc, CORE_ADDR *new_pc)
 {
+  struct frame_info *frame = get_current_frame ();
+  struct gdbarch *gdbarch = get_frame_arch (frame);
+  struct type *ptr_type = builtin_type (gdbarch)->builtin_func_ptr;
+
   struct objc_super sstr;
 
   CORE_ADDR super;
   CORE_ADDR sel;
   CORE_ADDR res;
 
-  super = OBJC_FETCH_POINTER_ARGUMENT (0);
-  sel = OBJC_FETCH_POINTER_ARGUMENT (1);
+  super = gdbarch_fetch_pointer_argument (gdbarch, frame, 0, ptr_type);
+  sel = gdbarch_fetch_pointer_argument (gdbarch, frame, 1, ptr_type);
 
   read_objc_super (super, &sstr);
   if (sstr.class == 0)
@@ -1746,14 +1761,18 @@ resolve_msgsend_super (CORE_ADDR pc, COR
 static int
 resolve_msgsend_super_stret (CORE_ADDR pc, CORE_ADDR *new_pc)
 {
+  struct frame_info *frame = get_current_frame ();
+  struct gdbarch *gdbarch = get_frame_arch (frame);
+  struct type *ptr_type = builtin_type (gdbarch)->builtin_func_ptr;
+
   struct objc_super sstr;
 
   CORE_ADDR super;
   CORE_ADDR sel;
   CORE_ADDR res;
 
-  super = OBJC_FETCH_POINTER_ARGUMENT (1);
-  sel = OBJC_FETCH_POINTER_ARGUMENT (2);
+  super = gdbarch_fetch_pointer_argument (gdbarch, frame, 1, ptr_type);
+  sel = gdbarch_fetch_pointer_argument (gdbarch, frame, 2, ptr_type);
 
   read_objc_super (super, &sstr);
   if (sstr.class == 0)
Index: gdb-head/gdb/gdbtypes.c
===================================================================
--- gdb-head.orig/gdb/gdbtypes.c
+++ gdb-head/gdb/gdbtypes.c
@@ -108,6 +108,16 @@ struct type *builtin_type_arm_ext;
 struct type *builtin_type_ia64_spill;
 struct type *builtin_type_ia64_quad;
 
+/* Platform-neutral void type.  */
+struct type *builtin_type_void;
+
+/* Platform-neutral void pointer type.  */
+struct type *builtin_type_void_ptr;
+
+/* Platform-neutral character types.  */
+struct type *builtin_type_true_char;
+struct type *builtin_type_true_unsigned_char;
+
 
 int opaque_type_resolution = 1;
 static void
@@ -656,7 +666,7 @@ lookup_methodptr_type (struct type *to_t
   mtype = alloc_type (TYPE_OBJFILE (to_type));
   TYPE_TARGET_TYPE (mtype) = to_type;
   TYPE_DOMAIN_TYPE (mtype) = TYPE_DOMAIN_TYPE (to_type);
-  TYPE_LENGTH (mtype) = cplus_method_ptr_size ();
+  TYPE_LENGTH (mtype) = cplus_method_ptr_size (to_type);
   TYPE_CODE (mtype) = TYPE_CODE_METHODPTR;
   return mtype;
 }
@@ -3106,14 +3116,6 @@ gdbtypes_post_init (struct gdbarch *gdba
 	       (TYPE_FLAG_NOSIGN
                 | (gdbarch_char_signed (gdbarch) ? 0 : TYPE_FLAG_UNSIGNED)),
 	       "char", (struct objfile *) NULL);
-  builtin_type->builtin_true_char =
-    init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
-	       0,
-	       "true character", (struct objfile *) NULL);
-  builtin_type->builtin_true_unsigned_char =
-    init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
-	       TYPE_FLAG_UNSIGNED,
-	       "true character", (struct objfile *) NULL);
   builtin_type->builtin_signed_char =
     init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
 	       0,
@@ -3330,6 +3332,25 @@ _initialize_gdbtypes (void)
   builtin_type_ia64_quad =
     build_flt (-1, "builtin_type_ia64_quad", floatformats_ia64_quad);
 
+  builtin_type_void =
+    init_type (TYPE_CODE_VOID, 1,
+	       0,
+	       "void", (struct objfile *) NULL);
+  builtin_type_void_ptr =
+    init_type (TYPE_CODE_PTR, sizeof (CORE_ADDR),
+	       TYPE_FLAG_UNSIGNED,
+	       NULL, (struct objfile *) NULL);
+  TYPE_TARGET_TYPE (builtin_type_void_ptr) = builtin_type_void;
+
+  builtin_type_true_char =
+    init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
+	       0,
+	       "true character", (struct objfile *) NULL);
+  builtin_type_true_unsigned_char =
+    init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
+	       TYPE_FLAG_UNSIGNED,
+	       "true character", (struct objfile *) NULL);
+
   add_setshow_zinteger_cmd ("overload", no_class, &overload_debug, _("\
 Set debugging of C++ overloading."), _("\
 Show debugging of C++ overloading."), _("\
Index: gdb-head/gdb/gdbtypes.h
===================================================================
--- gdb-head.orig/gdb/gdbtypes.h
+++ gdb-head/gdb/gdbtypes.h
@@ -977,12 +977,6 @@ struct builtin_type
 
   /* Integral types.  */
 
-  /* We use these for the '/c' print format, because c_char is just a
-     one-byte integral type, which languages less laid back than C
-     will print as ... well, a one-byte integral type.  */
-  struct type *builtin_true_char;
-  struct type *builtin_true_unsigned_char;
-
   /* Implicit size/sign (based on the the architecture's ABI).  */
   struct type *builtin_void;
   struct type *builtin_char;
@@ -1011,54 +1005,6 @@ struct builtin_type
 /* Return the type table for the specified architecture.  */
 extern const struct builtin_type *builtin_type (struct gdbarch *gdbarch);
 
-/* Compatibility macros to access types for the current architecture.  */
-#define builtin_type_void_data_ptr \
-	(builtin_type (current_gdbarch)->builtin_data_ptr)
-#define builtin_type_void_func_ptr \
-	(builtin_type (current_gdbarch)->builtin_func_ptr)
-#define builtin_type_CORE_ADDR \
-	(builtin_type (current_gdbarch)->builtin_core_addr)
-#define builtin_type_true_char \
-	(builtin_type (current_gdbarch)->builtin_true_char)
-#define builtin_type_void \
-	(builtin_type (current_gdbarch)->builtin_void)
-#define builtin_type_char \
-	(builtin_type (current_gdbarch)->builtin_char)
-#define builtin_type_short \
-	(builtin_type (current_gdbarch)->builtin_short)
-#define builtin_type_int \
-	(builtin_type (current_gdbarch)->builtin_int)
-#define builtin_type_long \
-	(builtin_type (current_gdbarch)->builtin_long)
-#define builtin_type_signed_char \
-	(builtin_type (current_gdbarch)->builtin_signed_char)
-#define builtin_type_unsigned_char \
-	(builtin_type (current_gdbarch)->builtin_unsigned_char)
-#define builtin_type_unsigned_short \
-	(builtin_type (current_gdbarch)->builtin_unsigned_short)
-#define builtin_type_unsigned_int \
-	(builtin_type (current_gdbarch)->builtin_unsigned_int)
-#define builtin_type_unsigned_long \
-	(builtin_type (current_gdbarch)->builtin_unsigned_long)
-#define builtin_type_float \
-	(builtin_type (current_gdbarch)->builtin_float)
-#define builtin_type_double \
-	(builtin_type (current_gdbarch)->builtin_double)
-#define builtin_type_long_double \
-	(builtin_type (current_gdbarch)->builtin_long_double)
-#define builtin_type_complex \
-	(builtin_type (current_gdbarch)->builtin_complex)
-#define builtin_type_double_complex \
-	(builtin_type (current_gdbarch)->builtin_double_complex)
-#define builtin_type_string \
-	(builtin_type (current_gdbarch)->builtin_string)
-#define builtin_type_bool \
-	(builtin_type (current_gdbarch)->builtin_bool)
-#define builtin_type_long_long \
-	(builtin_type (current_gdbarch)->builtin_long_long)
-#define builtin_type_unsigned_long_long \
-	(builtin_type (current_gdbarch)->builtin_unsigned_long_long)
-
  
 /* Explicit sizes - see C9X <intypes.h> for naming scheme.  The "int0"
    is for when an architecture needs to describe a register that has
@@ -1096,90 +1042,28 @@ extern struct type *builtin_type_arm_ext
 extern struct type *builtin_type_ia64_spill;
 extern struct type *builtin_type_ia64_quad;
 
+/* Platform-neutral void type.  Never attempt to construct a pointer
+   or reference type to this, because those cannot be platform-neutral.
+   You must use builtin_type (...)->builtin_void in those cases.  */
+extern struct type *builtin_type_void;
+
+/* Platform-neutral void pointer type.  The size of this type is chosen
+   so it is large enough to hold every CORE_ADDR value.  */
+extern struct type *builtin_type_void_ptr;
+
+/* Platform-neutral character types.
+   We use these for the '/c' print format, because c_char is just a
+   one-byte integral type, which languages less laid back than C
+   will print as ... well, a one-byte integral type.  */
+extern struct type *builtin_type_true_char;
+extern struct type *builtin_type_true_unsigned_char;
+
+
 /* This type represents a type that was unrecognized in symbol
    read-in.  */
-
 extern struct type *builtin_type_error;
 
 
-/* Modula-2 types */
-
-struct builtin_m2_type
-{
-  struct type *builtin_char;
-  struct type *builtin_int;
-  struct type *builtin_card;
-  struct type *builtin_real;
-  struct type *builtin_bool;
-};
-
-/* Return the Modula-2 type table for the specified architecture.  */
-extern const struct builtin_m2_type *builtin_m2_type (struct gdbarch *gdbarch);
-
-/* Compatibility macros to access types for the current architecture.  */
-#define builtin_type_m2_char \
-	(builtin_m2_type (current_gdbarch)->builtin_char)
-#define builtin_type_m2_int \
-	(builtin_m2_type (current_gdbarch)->builtin_int)
-#define builtin_type_m2_card \
-	(builtin_m2_type (current_gdbarch)->builtin_card)
-#define builtin_type_m2_real \
-	(builtin_m2_type (current_gdbarch)->builtin_real)
-#define builtin_type_m2_bool \
-	(builtin_m2_type (current_gdbarch)->builtin_bool)
-
-
-/* Fortran (F77) types */
-
-struct builtin_f_type
-{
-  struct type *builtin_character;
-  struct type *builtin_integer;
-  struct type *builtin_integer_s2;
-  struct type *builtin_logical;
-  struct type *builtin_logical_s1;
-  struct type *builtin_logical_s2;
-  struct type *builtin_real;
-  struct type *builtin_real_s8;
-  struct type *builtin_real_s16;
-  struct type *builtin_complex_s8;
-  struct type *builtin_complex_s16;
-  struct type *builtin_complex_s32;
-  struct type *builtin_void;
-};
-
-/* Return the Fortran type table for the specified architecture.  */
-extern const struct builtin_f_type *builtin_f_type (struct gdbarch *gdbarch);
-
-/* Compatibility macros to access types for the current architecture.  */
-#define builtin_type_f_character \
-	(builtin_f_type (current_gdbarch)->builtin_character)
-#define builtin_type_f_integer \
-	(builtin_f_type (current_gdbarch)->builtin_integer)
-#define builtin_type_f_integer_s2 \
-	(builtin_f_type (current_gdbarch)->builtin_integer_s2)
-#define builtin_type_f_logical \
-	(builtin_f_type (current_gdbarch)->builtin_logical)
-#define builtin_type_f_logical_s1 \
-	(builtin_f_type (current_gdbarch)->builtin_logical_s1)
-#define builtin_type_f_logical_s2 \
-	(builtin_f_type (current_gdbarch)->builtin_logical_s2)
-#define builtin_type_f_real \
-	(builtin_f_type (current_gdbarch)->builtin_real)
-#define builtin_type_f_real_s8 \
-	(builtin_f_type (current_gdbarch)->builtin_real_s8)
-#define builtin_type_f_real_s16 \
-	(builtin_f_type (current_gdbarch)->builtin_real_s16)
-#define builtin_type_f_complex_s8 \
-	(builtin_f_type (current_gdbarch)->builtin_complex_s8)
-#define builtin_type_f_complex_s16 \
-	(builtin_f_type (current_gdbarch)->builtin_complex_s16)
-#define builtin_type_f_complex_s32 \
-	(builtin_f_type (current_gdbarch)->builtin_complex_s32)
-#define builtin_type_f_void \
-	(builtin_f_type (current_gdbarch)->builtin_void)
-
-
 /* RTTI for C++ */
 /* extern struct type *builtin_type_cxx_typeinfo; */
 
Index: gdb-head/gdb/mt-tdep.c
===================================================================
--- gdb-head.orig/gdb/mt-tdep.c
+++ gdb-head/gdb/mt-tdep.c
@@ -226,9 +226,9 @@ mt_copro_register_type (struct gdbarch *
     case MT_MAC_REGNUM:
       return builtin_type_uint32;
     case MT_CONTEXT_REGNUM:
-      return builtin_type_long_long;
+      return builtin_type (arch)->builtin_long_long;
     case MT_FLAG_REGNUM:
-      return builtin_type_unsigned_char;
+      return builtin_type (arch)->builtin_unsigned_char;
     default:
       if (regnum >= MT_CPR0_REGNUM && regnum <= MT_CPR15_REGNUM)
 	return builtin_type_int16;
@@ -251,20 +251,14 @@ mt_copro_register_type (struct gdbarch *
 static struct type *
 mt_register_type (struct gdbarch *arch, int regnum)
 {
-  static struct type *void_func_ptr = NULL;
-  static struct type *void_ptr = NULL;
-  static struct type *copro_type;
+  static struct type *copro_type = NULL;
 
   if (regnum >= 0 && regnum < MT_NUM_REGS + MT_NUM_PSEUDO_REGS)
     {
-      if (void_func_ptr == NULL)
+      if (copro_type == NULL)
 	{
 	  struct type *temp;
-
-	  void_ptr = lookup_pointer_type (builtin_type_void);
-	  void_func_ptr =
-	    lookup_pointer_type (lookup_function_type (builtin_type_void));
-	  temp = create_range_type (NULL, builtin_type_unsigned_int, 0, 1);
+	  temp = create_range_type (NULL, builtin_type_int32, 0, 1);
 	  copro_type = create_array_type (NULL, builtin_type_int16, temp);
 	}
       switch (regnum)
@@ -272,10 +266,10 @@ mt_register_type (struct gdbarch *arch, 
 	case MT_PC_REGNUM:
 	case MT_RA_REGNUM:
 	case MT_IRA_REGNUM:
-	  return void_func_ptr;
+	  return builtin_type (arch)->builtin_func_ptr;
 	case MT_SP_REGNUM:
 	case MT_FP_REGNUM:
-	  return void_ptr;
+	  return builtin_type (arch)->builtin_data_ptr;
 	case MT_COPRO_REGNUM:
 	case MT_COPRO_PSEUDOREG_REGNUM:
 	  return copro_type;
Index: gdb-head/gdb/printcmd.c
===================================================================
--- gdb-head.orig/gdb/printcmd.c
+++ gdb-head/gdb/printcmd.c
@@ -309,6 +309,24 @@ print_formatted (struct value *val, int 
 			    format, size, stream);
 }
 
+/* Return builtin floating point type of same length as TYPE.
+   If no such type is found, return TYPE itself.  */
+static struct type *
+float_type_from_length (struct gdbarch *gdbarch, struct type *type)
+{
+  const struct builtin_type *builtin = builtin_type (gdbarch);
+  unsigned int len = TYPE_LENGTH (type);
+
+  if (len == TYPE_LENGTH (builtin->builtin_float))
+    type = builtin->builtin_float;
+  else if (len == TYPE_LENGTH (builtin->builtin_double))
+    type = builtin->builtin_double;
+  else if (len == TYPE_LENGTH (builtin->builtin_long_double))
+    type = builtin->builtin_long_double;
+
+  return type;
+}
+
 /* Print a scalar of data of type TYPE, pointed to in GDB by VALADDR,
    according to letters FORMAT and SIZE on STREAM.
    FORMAT may not be zero.  Formats s and i are not supported at this level.
@@ -425,25 +443,16 @@ print_scalar_formatted (const void *vala
 
     case 'c':
       if (TYPE_UNSIGNED (type))
-	{
-	  struct type *utype;
-
-	  utype = builtin_type (current_gdbarch)->builtin_true_unsigned_char;
-	  value_print (value_from_longest (utype, val_long),
-		       stream, 0, Val_pretty_default);
-	}
+	value_print (value_from_longest (builtin_type_true_unsigned_char,
+					 val_long),
+		     stream, 0, Val_pretty_default);
       else
 	value_print (value_from_longest (builtin_type_true_char, val_long),
 		     stream, 0, Val_pretty_default);
       break;
 
     case 'f':
-      if (len == TYPE_LENGTH (builtin_type_float))
-        type = builtin_type_float;
-      else if (len == TYPE_LENGTH (builtin_type_double))
-        type = builtin_type_double;
-      else if (len == TYPE_LENGTH (builtin_type_long_double))
-        type = builtin_type_long_double;
+      type = float_type_from_length (current_gdbarch, type);
       print_floating (valaddr, type, stream);
       break;
 
@@ -513,8 +522,7 @@ set_next_address (CORE_ADDR addr)
 
   /* Make address available to the user as $_.  */
   set_internalvar (lookup_internalvar ("_"),
-		   value_from_pointer (lookup_pointer_type (builtin_type_void),
-				       addr));
+		   value_from_pointer (builtin_type_void_ptr, addr));
 }
 
 /* Optionally print address ADDR symbolically as <SYMBOL+OFFSET> on STREAM,
@@ -1999,17 +2007,6 @@ printf_command (char *arg, int from_tty)
 	s1 = s;
 	val_args[nargs] = parse_to_comma_and_eval (&s1);
 
-	/* If format string wants a float, unchecked-convert the value to
-	   floating point of the same size */
-
-	if (argclass[nargs] == double_arg)
-	  {
-	    struct type *type = value_type (val_args[nargs]);
-	    if (TYPE_LENGTH (type) == sizeof (float))
-	      deprecated_set_value_type (val_args[nargs], builtin_type_float);
-	    if (TYPE_LENGTH (type) == sizeof (double))
-	      deprecated_set_value_type (val_args[nargs], builtin_type_double);
-	  }
 	nargs++;
 	s = s1;
 	if (*s == ',')
@@ -2053,15 +2050,35 @@ printf_command (char *arg, int from_tty)
 	    break;
 	  case double_arg:
 	    {
-	      double val = value_as_double (val_args[i]);
-	      printf_filtered (current_substring, val);
+	      struct type *type = value_type (val_args[i]);
+	      DOUBLEST val;
+	      int inv;
+
+	      /* If format string wants a float, unchecked-convert the value
+		 to floating point of the same size.  */
+	      type = float_type_from_length (current_gdbarch, type);
+	      val = unpack_double (type, value_contents (val_args[i]), &inv);
+	      if (inv)
+		error (_("Invalid floating value found in program."));
+
+	      printf_filtered (current_substring, (double) val);
 	      break;
 	    }
 	  case long_double_arg:
 #ifdef HAVE_LONG_DOUBLE
 	    {
-	      long double val = value_as_double (val_args[i]);
-	      printf_filtered (current_substring, val);
+	      struct type *type = value_type (val_args[i]);
+	      DOUBLEST val;
+	      int inv;
+
+	      /* If format string wants a float, unchecked-convert the value
+		 to floating point of the same size.  */
+	      type = float_type_from_length (current_gdbarch, type);
+	      val = unpack_double (type, value_contents (val_args[i]), &inv);
+	      if (inv)
+		error (_("Invalid floating value found in program."));
+
+	      printf_filtered (current_substring, (long double) val);
 	      break;
 	    }
 #else
Index: gdb-head/gdb/symfile.c
===================================================================
--- gdb-head.orig/gdb/symfile.c
+++ gdb-head/gdb/symfile.c
@@ -898,14 +898,6 @@ syms_from_objfile (struct objfile *objfi
 
   (*objfile->sf->sym_read) (objfile, mainline);
 
-  /* Don't allow char * to have a typename (else would get caddr_t).
-     Ditto void *.  FIXME: Check whether this is now done by all the
-     symbol readers themselves (many of them now do), and if so remove
-     it from here.  */
-
-  TYPE_NAME (lookup_pointer_type (builtin_type_char)) = 0;
-  TYPE_NAME (lookup_pointer_type (builtin_type_void)) = 0;
-
   /* Mark the objfile has having had initial symbol read attempted.  Note
      that this does not mean we found any symbols... */
 
Index: gdb-head/gdb/xtensa-tdep.c
===================================================================
--- gdb-head.orig/gdb/xtensa-tdep.c
+++ gdb-head/gdb/xtensa-tdep.c
@@ -229,11 +229,11 @@ xtensa_register_type (struct gdbarch *gd
 		    + gdbarch_tdep (gdbarch)->num_aregs)
       || (regnum >= gdbarch_tdep (gdbarch)->a0_base
       && regnum < gdbarch_tdep (gdbarch)->a0_base + 16))
-    return builtin_type_int;
+    return builtin_type (gdbarch)->builtin_int;
 
   if (regnum == gdbarch_pc_regnum (gdbarch)
       || regnum == gdbarch_tdep (gdbarch)->a0_base + 1)
-    return lookup_pointer_type (builtin_type_void);
+    return builtin_type (gdbarch)->builtin_data_ptr;
 
   /* Return the stored type for all other registers.  */
   else if (regnum >= 0 && regnum < gdbarch_num_regs (gdbarch)
@@ -1015,15 +1015,16 @@ static CORE_ADDR
 xtensa_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
 {
   gdb_byte buf[8];
+  CORE_ADDR pc;
 
   DEBUGTRACE ("xtensa_unwind_pc (next_frame = %p)\n", next_frame);
 
   frame_unwind_register (next_frame, gdbarch_pc_regnum (gdbarch), buf);
+  pc = extract_typed_address (buf, builtin_type (gdbarch)->builtin_func_ptr);
 
-  DEBUGINFO ("[xtensa_unwind_pc] pc = 0x%08x\n", (unsigned int)
-	     extract_typed_address (buf, builtin_type_void_func_ptr));
+  DEBUGINFO ("[xtensa_unwind_pc] pc = 0x%08x\n", (unsigned int) pc);
 
-  return extract_typed_address (buf, builtin_type_void_func_ptr);
+  return pc;
 }
 
 
@@ -1677,9 +1678,10 @@ xtensa_push_dummy_call (struct gdbarch *
 	case TYPE_CODE_ENUM:
 
 	  /* Cast argument to long if necessary as the mask does it too.  */
-	  if (TYPE_LENGTH (arg_type) < TYPE_LENGTH (builtin_type_long))
+	  if (TYPE_LENGTH (arg_type)
+	      < TYPE_LENGTH (builtin_type (gdbarch)->builtin_long))
 	    {
-	      arg_type = builtin_type_long;
+	      arg_type = builtin_type (gdbarch)->builtin_long;
 	      arg = value_cast (arg_type, arg);
 	    }
 	  /* Aligment is equal to the type length for the basic types.  */
@@ -1689,15 +1691,16 @@ xtensa_push_dummy_call (struct gdbarch *
 	case TYPE_CODE_FLT:
 
 	  /* Align doubles correctly.  */
-	  if (TYPE_LENGTH (arg_type) == TYPE_LENGTH (builtin_type_double))
-	    info->align = TYPE_LENGTH (builtin_type_double);
+	  if (TYPE_LENGTH (arg_type)
+	      == TYPE_LENGTH (builtin_type (gdbarch)->builtin_double))
+	    info->align = TYPE_LENGTH (builtin_type (gdbarch)->builtin_double);
 	  else
-	    info->align = TYPE_LENGTH (builtin_type_long);
+	    info->align = TYPE_LENGTH (builtin_type (gdbarch)->builtin_long);
 	  break;
 
 	case TYPE_CODE_STRUCT:
 	default:
-	  info->align = TYPE_LENGTH (builtin_type_long);
+	  info->align = TYPE_LENGTH (builtin_type (gdbarch)->builtin_long);
 	  break;
 	}
       info->length = TYPE_LENGTH (arg_type);
Index: gdb-head/gdb/breakpoint.c
===================================================================
--- gdb-head.orig/gdb/breakpoint.c
+++ gdb-head/gdb/breakpoint.c
@@ -401,7 +401,7 @@ set_breakpoint_count (int num)
 {
   breakpoint_count = num;
   set_internalvar (lookup_internalvar ("bpnum"),
-		   value_from_longest (builtin_type_int, (LONGEST) num));
+		   value_from_longest (builtin_type_int32, (LONGEST) num));
 }
 
 /* Used in run_command to zero the hit count when a new run starts. */
Index: gdb-head/gdb/findcmd.c
===================================================================
--- gdb-head.orig/gdb/findcmd.c
+++ gdb-head/gdb/findcmd.c
@@ -292,12 +292,12 @@ find_command (char *args, int from_tty)
   /* Record and print the results.  */
 
   set_internalvar (lookup_internalvar ("numfound"),
-		   value_from_longest (builtin_type_int,
+		   value_from_longest (builtin_type_int32,
 				       (LONGEST) found_count));
   if (found_count > 0)
     {
       set_internalvar (lookup_internalvar ("_"),
-		       value_from_pointer (builtin_type_void_data_ptr,
+		       value_from_pointer (builtin_type_void_ptr,
 					   last_found_addr));
     }
 
Index: gdb-head/gdb/infrun.c
===================================================================
--- gdb-head.orig/gdb/infrun.c
+++ gdb-head/gdb/infrun.c
@@ -2017,7 +2017,7 @@ handle_inferior_event (struct execution_
       /* Record the exit code in the convenience variable $_exitcode, so
          that the user can inspect this again later.  */
       set_internalvar (lookup_internalvar ("_exitcode"),
-		       value_from_longest (builtin_type_int,
+		       value_from_longest (builtin_type_int32,
 					   (LONGEST) ecs->ws.value.integer));
       gdb_flush (gdb_stdout);
       target_mourn_inferior ();
Index: gdb-head/gdb/source.c
===================================================================
--- gdb-head.orig/gdb/source.c
+++ gdb-head/gdb/source.c
@@ -1614,7 +1614,7 @@ forward_search_command (char *regex, int
 	  fclose (stream);
 	  print_source_lines (current_source_symtab, line, line + 1, 0);
 	  set_internalvar (lookup_internalvar ("_"),
-			   value_from_longest (builtin_type_int,
+			   value_from_longest (builtin_type_int32,
 					       (LONGEST) line));
 	  current_source_line = max (line - lines_to_list / 2, 1);
 	  return;
@@ -1696,7 +1696,7 @@ reverse_search_command (char *regex, int
 	  fclose (stream);
 	  print_source_lines (current_source_symtab, line, line + 1, 0);
 	  set_internalvar (lookup_internalvar ("_"),
-			   value_from_longest (builtin_type_int,
+			   value_from_longest (builtin_type_int32,
 					       (LONGEST) line));
 	  current_source_line = max (line - lines_to_list / 2, 1);
 	  return;
Index: gdb-head/gdb/tracepoint.c
===================================================================
--- gdb-head.orig/gdb/tracepoint.c
+++ gdb-head/gdb/tracepoint.c
@@ -220,7 +220,7 @@ set_tracepoint_count (int num)
 {
   tracepoint_count = num;
   set_internalvar (lookup_internalvar ("tpnum"),
-		   value_from_longest (builtin_type_int, (LONGEST) num));
+		   value_from_longest (builtin_type_int32, (LONGEST) num));
 }
 
 /* Set traceframe number to NUM.  */
@@ -229,7 +229,7 @@ set_traceframe_num (int num)
 {
   traceframe_number = num;
   set_internalvar (lookup_internalvar ("trace_frame"),
-		   value_from_longest (builtin_type_int, (LONGEST) num));
+		   value_from_longest (builtin_type_int32, (LONGEST) num));
 }
 
 /* Set tracepoint number to NUM.  */
@@ -238,8 +238,7 @@ set_tracepoint_num (int num)
 {
   tracepoint_number = num;
   set_internalvar (lookup_internalvar ("tracepoint"),
-		   value_from_longest (builtin_type_int, 
-				       (LONGEST) num));
+		   value_from_longest (builtin_type_int32, (LONGEST) num));
 }
 
 /* Set externally visible debug variables for querying/printing
@@ -252,23 +251,19 @@ set_traceframe_context (CORE_ADDR trace_
   static struct type *func_range, *file_range;
   struct value *func_val;
   struct value *file_val;
-  static struct type *charstar;
   int len;
 
-  if (charstar == (struct type *) NULL)
-    charstar = lookup_pointer_type (builtin_type_char);
-
   if (trace_pc == -1)		/* Cease debugging any trace buffers.  */
     {
       traceframe_fun = 0;
       traceframe_sal.pc = traceframe_sal.line = 0;
       traceframe_sal.symtab = NULL;
       set_internalvar (lookup_internalvar ("trace_func"),
-		       value_from_pointer (charstar, (LONGEST) 0));
+		       value_from_pointer (builtin_type_void_ptr, 0));
       set_internalvar (lookup_internalvar ("trace_file"),
-		       value_from_pointer (charstar, (LONGEST) 0));
+		       value_from_pointer (builtin_type_void_ptr, 0));
       set_internalvar (lookup_internalvar ("trace_line"),
-		       value_from_longest (builtin_type_int, 
+		       value_from_longest (builtin_type_int32,
 					   (LONGEST) - 1));
       return;
     }
@@ -280,7 +275,7 @@ set_traceframe_context (CORE_ADDR trace_
   /* Save linenumber as "$trace_line", a debugger variable visible to
      users.  */
   set_internalvar (lookup_internalvar ("trace_line"),
-		   value_from_longest (builtin_type_int,
+		   value_from_longest (builtin_type_int32,
 				       (LONGEST) traceframe_sal.line));
 
   /* Save func name as "$trace_func", a debugger variable visible to
@@ -288,14 +283,14 @@ set_traceframe_context (CORE_ADDR trace_
   if (traceframe_fun == NULL ||
       SYMBOL_LINKAGE_NAME (traceframe_fun) == NULL)
     set_internalvar (lookup_internalvar ("trace_func"),
-		     value_from_pointer (charstar, (LONGEST) 0));
+		     value_from_pointer (builtin_type_void_ptr, 0));
   else
     {
       len = strlen (SYMBOL_LINKAGE_NAME (traceframe_fun));
       func_range = create_range_type (func_range,
-				      builtin_type_int, 0, len - 1);
+				      builtin_type_int32, 0, len - 1);
       func_string = create_array_type (func_string,
-				       builtin_type_char, func_range);
+				       builtin_type_true_char, func_range);
       func_val = allocate_value (func_string);
       deprecated_set_value_type (func_val, func_string);
       memcpy (value_contents_raw (func_val),
@@ -310,14 +305,14 @@ set_traceframe_context (CORE_ADDR trace_
   if (traceframe_sal.symtab == NULL ||
       traceframe_sal.symtab->filename == NULL)
     set_internalvar (lookup_internalvar ("trace_file"),
-		     value_from_pointer (charstar, (LONGEST) 0));
+		     value_from_pointer (builtin_type_void_ptr, 0));
   else
     {
       len = strlen (traceframe_sal.symtab->filename);
       file_range = create_range_type (file_range,
-				      builtin_type_int, 0, len - 1);
+				      builtin_type_int32, 0, len - 1);
       file_string = create_array_type (file_string,
-				       builtin_type_char, file_range);
+				       builtin_type_true_char, file_range);
       file_val = allocate_value (file_string);
       deprecated_set_value_type (file_val, file_string);
       memcpy (value_contents_raw (file_val),
Index: gdb-head/gdb/ada-typeprint.c
===================================================================
--- gdb-head.orig/gdb/ada-typeprint.c
+++ gdb-head/gdb/ada-typeprint.c
@@ -149,7 +149,7 @@ print_range (struct type *type, struct u
     case TYPE_CODE_ENUM:
       break;
     default:
-      target_type = builtin_type_int;
+      target_type = builtin_type_int32;
       break;
     }
 
@@ -197,11 +197,11 @@ print_range_bound (struct type *type, ch
          the upper bound of the 0 .. -1 range types to be printed as
          a very large unsigned number instead of -1.
          To workaround this stabs deficiency, we replace the TYPE by
-         builtin_type_long when we detect that the bound is negative,
+         builtin_type_int32 when we detect that the bound is negative,
          and the type is a TYPE_CODE_INT.  The bound is negative when
          'm' is the last character of the number scanned in BOUNDS.  */
       if (bounds[*n - 1] == 'm' && TYPE_CODE (type) == TYPE_CODE_INT)
-	type = builtin_type_long;
+	type = builtin_type_int32;
       ada_print_scalar (type, B, stream);
       if (bounds[*n] == '_')
 	*n += 2;
@@ -258,7 +258,7 @@ print_range_type_named (char *name, stru
   char *subtype_info;
 
   if (raw_type == NULL)
-    base_type = builtin_type_int;
+    base_type = builtin_type_int32;
   else if (TYPE_CODE (raw_type) == TYPE_CODE_RANGE)
     base_type = TYPE_TARGET_TYPE (raw_type);
   else
Index: gdb-head/gdb/m2-typeprint.c
===================================================================
--- gdb-head.orig/gdb/m2-typeprint.c
+++ gdb-head/gdb/m2-typeprint.c
@@ -287,7 +287,7 @@ m2_print_bounds (struct type *type,
   struct type *target = TYPE_TARGET_TYPE (type);
 
   if (target == NULL)
-    target = builtin_type_int;
+    target = builtin_type_int32;
 
   if (TYPE_NFIELDS(type) == 0)
     return;
@@ -394,7 +394,7 @@ m2_is_long_set_of_type (struct type *typ
       range = TYPE_INDEX_TYPE (TYPE_FIELD_TYPE (type, i));
       target = TYPE_TARGET_TYPE (range);
       if (target == NULL)
-	target = builtin_type_int;
+	target = builtin_type_int32;
 
       l1 = TYPE_LOW_BOUND (TYPE_INDEX_TYPE (TYPE_FIELD_TYPE (type, i)));
       h1 = TYPE_HIGH_BOUND (TYPE_INDEX_TYPE (TYPE_FIELD_TYPE (type, len-1)));
Index: gdb-head/gdb/p-typeprint.c
===================================================================
--- gdb-head.orig/gdb/p-typeprint.c
+++ gdb-head/gdb/p-typeprint.c
@@ -756,7 +756,7 @@ pascal_type_print_base (struct type *typ
       {
 	struct type *target = TYPE_TARGET_TYPE (type);
 	if (target == NULL)
-	  target = builtin_type_long;
+	  target = builtin_type_int32;
 	print_type_scalar (target, TYPE_LOW_BOUND (type), stream);
 	fputs_filtered ("..", stream);
 	print_type_scalar (target, TYPE_HIGH_BOUND (type), stream);
Index: gdb-head/gdb/sh64-tdep.c
===================================================================
--- gdb-head.orig/gdb/sh64-tdep.c
+++ gdb-head/gdb/sh64-tdep.c
@@ -1503,12 +1503,12 @@ REGISTER_BYTE returns the register byte 
 */
 
 static struct type *
-sh64_build_float_register_type (int high)
+sh64_build_float_register_type (struct gdbarch *gdbarch, int high)
 {
   struct type *temp;
 
-  temp = create_range_type (NULL, builtin_type_int, 0, high);
-  return create_array_type (NULL, builtin_type_float, temp);
+  temp = create_range_type (NULL, builtin_type_int32, 0, high);
+  return create_array_type (NULL, builtin_type (gdbarch)->builtin_float, temp);
 }
 
 /* Return the GDB type object for the "standard" data type
@@ -1520,27 +1520,27 @@ sh64_register_type (struct gdbarch *gdba
        && reg_nr <= FP_LAST_REGNUM)
       || (reg_nr >= FP0_C_REGNUM
 	  && reg_nr <= FP_LAST_C_REGNUM))
-    return builtin_type_float;
+    return builtin_type (gdbarch)->builtin_float;
   else if ((reg_nr >= DR0_REGNUM 
 	    && reg_nr <= DR_LAST_REGNUM)
 	   || (reg_nr >= DR0_C_REGNUM 
 	       && reg_nr <= DR_LAST_C_REGNUM))
-    return builtin_type_double;
+    return builtin_type (gdbarch)->builtin_double;
   else if  (reg_nr >= FPP0_REGNUM 
 	    && reg_nr <= FPP_LAST_REGNUM)
-    return sh64_build_float_register_type (1);
+    return sh64_build_float_register_type (gdbarch, 1);
   else if ((reg_nr >= FV0_REGNUM
 	    && reg_nr <= FV_LAST_REGNUM)
 	   ||(reg_nr >= FV0_C_REGNUM 
 	      && reg_nr <= FV_LAST_C_REGNUM))
-    return sh64_build_float_register_type (3);
+    return sh64_build_float_register_type (gdbarch, 3);
   else if (reg_nr == FPSCR_REGNUM)
-    return builtin_type_int;
+    return builtin_type (gdbarch)->builtin_int;
   else if (reg_nr >= R0_C_REGNUM
 	   && reg_nr < FP0_C_REGNUM)
-    return builtin_type_int;
+    return builtin_type (gdbarch)->builtin_int;
   else
-    return builtin_type_long_long;
+    return builtin_type (gdbarch)->builtin_long_long;
 }
 
 static void
@@ -1997,7 +1997,7 @@ sh64_do_fp_register (struct gdbarch *gdb
 	   regnum, gdbarch_register_name (gdbarch, regnum));
 
   /* Get the register as a number */ 
-  flt = unpack_double (builtin_type_float, raw_buffer, &inv);
+  flt = unpack_double (builtin_type (gdbarch)->builtin_float, raw_buffer, &inv);
 
   /* Print the name and some spaces.  */
   fputs_filtered (gdbarch_register_name (gdbarch, regnum), file);
Index: gdb-head/gdb/sh-tdep.c
===================================================================
--- gdb-head.orig/gdb/sh-tdep.c
+++ gdb-head/gdb/sh-tdep.c
@@ -2132,11 +2132,11 @@ sh_sh2a_register_type (struct gdbarch *g
 {
   if ((reg_nr >= gdbarch_fp0_regnum (gdbarch)
        && (reg_nr <= FP_LAST_REGNUM)) || (reg_nr == FPUL_REGNUM))
-    return builtin_type_float;
+    return builtin_type (gdbarch)->builtin_float;
   else if (reg_nr >= DR0_REGNUM && reg_nr <= DR_LAST_REGNUM)
-    return builtin_type_double;
+    return builtin_type (gdbarch)->builtin_double;
   else
-    return builtin_type_int;
+    return builtin_type (gdbarch)->builtin_int;
 }
 
 /* Return the GDB type object for the "standard" data type
@@ -2146,18 +2146,18 @@ sh_sh3e_register_type (struct gdbarch *g
 {
   if ((reg_nr >= gdbarch_fp0_regnum (gdbarch)
        && (reg_nr <= FP_LAST_REGNUM)) || (reg_nr == FPUL_REGNUM))
-    return builtin_type_float;
+    return builtin_type (gdbarch)->builtin_float;
   else
-    return builtin_type_int;
+    return builtin_type (gdbarch)->builtin_int;
 }
 
 static struct type *
-sh_sh4_build_float_register_type (int high)
+sh_sh4_build_float_register_type (struct gdbarch *gdbarch, int high)
 {
   struct type *temp;
 
-  temp = create_range_type (NULL, builtin_type_int, 0, high);
-  return create_array_type (NULL, builtin_type_float, temp);
+  temp = create_range_type (NULL, builtin_type_int32, 0, high);
+  return create_array_type (NULL, builtin_type (gdbarch)->builtin_float, temp);
 }
 
 static struct type *
@@ -2165,19 +2165,19 @@ sh_sh4_register_type (struct gdbarch *gd
 {
   if ((reg_nr >= gdbarch_fp0_regnum (gdbarch)
        && (reg_nr <= FP_LAST_REGNUM)) || (reg_nr == FPUL_REGNUM))
-    return builtin_type_float;
+    return builtin_type (gdbarch)->builtin_float;
   else if (reg_nr >= DR0_REGNUM && reg_nr <= DR_LAST_REGNUM)
-    return builtin_type_double;
+    return builtin_type (gdbarch)->builtin_double;
   else if (reg_nr >= FV0_REGNUM && reg_nr <= FV_LAST_REGNUM)
-    return sh_sh4_build_float_register_type (3);
+    return sh_sh4_build_float_register_type (gdbarch, 3);
   else
-    return builtin_type_int;
+    return builtin_type (gdbarch)->builtin_int;
 }
 
 static struct type *
 sh_default_register_type (struct gdbarch *gdbarch, int reg_nr)
 {
-  return builtin_type_int;
+  return builtin_type (gdbarch)->builtin_int;
 }
 
 /* Is a register in a reggroup?
Index: gdb-head/gdb/varobj.c
===================================================================
--- gdb-head.orig/gdb/varobj.c
+++ gdb-head/gdb/varobj.c
@@ -2072,7 +2072,7 @@ c_describe_child (struct varobj *parent,
 	{
 	  int real_index = index + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type));
 	  struct value *indval = 
-	    value_from_longest (builtin_type_int, (LONGEST) real_index);
+	    value_from_longest (builtin_type_int32, (LONGEST) real_index);
 	  gdb_value_subscript (value, indval, cvalue);
 	}
 
Index: gdb-head/gdb/alpha-tdep.c
===================================================================
--- gdb-head.orig/gdb/alpha-tdep.c
+++ gdb-head/gdb/alpha-tdep.c
@@ -95,9 +95,9 @@ static struct type *
 alpha_register_type (struct gdbarch *gdbarch, int regno)
 {
   if (regno == ALPHA_SP_REGNUM || regno == ALPHA_GP_REGNUM)
-    return builtin_type_void_data_ptr;
+    return builtin_type (gdbarch)->builtin_data_ptr;
   if (regno == ALPHA_PC_REGNUM)
-    return builtin_type_void_func_ptr;
+    return builtin_type (gdbarch)->builtin_func_ptr;
 
   /* Don't need to worry about little vs big endian until 
      some jerk tries to port to alpha-unicosmk.  */
Index: gdb-head/gdb/amd64-tdep.c
===================================================================
--- gdb-head.orig/gdb/amd64-tdep.c
+++ gdb-head/gdb/amd64-tdep.c
@@ -90,11 +90,11 @@ amd64_register_type (struct gdbarch *gdb
   if (regnum >= AMD64_RAX_REGNUM && regnum <= AMD64_RDI_REGNUM)
     return builtin_type_int64;
   if (regnum == AMD64_RBP_REGNUM || regnum == AMD64_RSP_REGNUM)
-    return builtin_type_void_data_ptr;
+    return builtin_type (gdbarch)->builtin_data_ptr;
   if (regnum >= AMD64_R8_REGNUM && regnum <= AMD64_R15_REGNUM)
     return builtin_type_int64;
   if (regnum == AMD64_RIP_REGNUM)
-    return builtin_type_void_func_ptr;
+    return builtin_type (gdbarch)->builtin_func_ptr;
   if (regnum == AMD64_EFLAGS_REGNUM)
     return i386_eflags_type;
   if (regnum >= AMD64_CS_REGNUM && regnum <= AMD64_GS_REGNUM)
@@ -1277,7 +1277,7 @@ amd64_get_longjmp_target (struct frame_i
   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_void_func_ptr);
+  int 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.	 */
@@ -1285,11 +1285,12 @@ amd64_get_longjmp_target (struct frame_i
     return 0;
 
   get_frame_register (frame, AMD64_RDI_REGNUM, buf);
-  jb_addr = extract_typed_address (buf, builtin_type_void_data_ptr);
+  jb_addr= extract_typed_address
+	    (buf, builtin_type (gdbarch)->builtin_data_ptr);
   if (target_read_memory (jb_addr + jb_pc_offset, buf, len))
     return 0;
 
-  *pc = extract_typed_address (buf, builtin_type_void_func_ptr);
+  *pc = extract_typed_address (buf, builtin_type (gdbarch)->builtin_func_ptr);
 
   return 1;
 }
Index: gdb-head/gdb/arm-tdep.c
===================================================================
--- gdb-head.orig/gdb/arm-tdep.c
+++ gdb-head/gdb/arm-tdep.c
@@ -1603,9 +1603,9 @@ arm_register_type (struct gdbarch *gdbar
   if (regnum >= ARM_F0_REGNUM && regnum < ARM_F0_REGNUM + NUM_FREGS)
     return builtin_type_arm_ext;
   else if (regnum == ARM_SP_REGNUM)
-    return builtin_type_void_data_ptr;
+    return builtin_type (gdbarch)->builtin_data_ptr;
   else if (regnum == ARM_PC_REGNUM)
-    return builtin_type_void_func_ptr;
+    return builtin_type (gdbarch)->builtin_func_ptr;
   else if (regnum >= ARRAY_SIZE (arm_register_names))
     /* These registers are only supported on targets which supply
        an XML description.  */
Index: gdb-head/gdb/avr-tdep.c
===================================================================
--- gdb-head.orig/gdb/avr-tdep.c
+++ gdb-head/gdb/avr-tdep.c
@@ -213,7 +213,7 @@ avr_register_type (struct gdbarch *gdbar
   if (reg_nr == AVR_PC_REGNUM)
     return builtin_type_uint32;
   if (reg_nr == AVR_SP_REGNUM)
-    return builtin_type_void_data_ptr;
+    return builtin_type (gdbarch)->builtin_data_ptr;
   else
     return builtin_type_uint8;
 }
Index: gdb-head/gdb/cris-tdep.c
===================================================================
--- gdb-head.orig/gdb/cris-tdep.c
+++ gdb-head/gdb/cris-tdep.c
@@ -1658,10 +1658,10 @@ static struct type *
 cris_register_type (struct gdbarch *gdbarch, int regno)
 {
   if (regno == gdbarch_pc_regnum (gdbarch))
-    return builtin_type_void_func_ptr;
+    return builtin_type (gdbarch)->builtin_func_ptr;
   else if (regno == gdbarch_sp_regnum (gdbarch)
 	   || regno == CRIS_FP_REGNUM)
-    return builtin_type_void_data_ptr;
+    return builtin_type (gdbarch)->builtin_data_ptr;
   else if ((regno >= 0 && regno < gdbarch_sp_regnum (gdbarch))
 	   || (regno >= MOF_REGNUM && regno <= USP_REGNUM))
     /* Note: R8 taken care of previous clause.  */
@@ -1679,10 +1679,10 @@ static struct type *
 crisv32_register_type (struct gdbarch *gdbarch, int regno)
 {
   if (regno == gdbarch_pc_regnum (gdbarch))
-    return builtin_type_void_func_ptr;
+    return builtin_type (gdbarch)->builtin_func_ptr;
   else if (regno == gdbarch_sp_regnum (gdbarch)
 	   || regno == CRIS_FP_REGNUM)
-    return builtin_type_void_data_ptr;
+    return builtin_type (gdbarch)->builtin_data_ptr;
   else if ((regno >= 0 && regno <= ACR_REGNUM)
 	   || (regno >= EXS_REGNUM && regno <= SPC_REGNUM)
 	   || (regno == PID_REGNUM)
Index: gdb-head/gdb/frv-tdep.c
===================================================================
--- gdb-head.orig/gdb/frv-tdep.c
+++ gdb-head/gdb/frv-tdep.c
@@ -292,7 +292,7 @@ static struct type *
 frv_register_type (struct gdbarch *gdbarch, int reg)
 {
   if (reg >= first_fpr_regnum && reg <= last_fpr_regnum)
-    return builtin_type_float;
+    return builtin_type (gdbarch)->builtin_float;
   else if (reg == iacc0_regnum)
     return builtin_type_int64;
   else
Index: gdb-head/gdb/h8300-tdep.c
===================================================================
--- gdb-head.orig/gdb/h8300-tdep.c
+++ gdb-head/gdb/h8300-tdep.c
@@ -1112,10 +1112,10 @@ h8300_register_type (struct gdbarch *gdb
       switch (regno)
 	{
 	case E_PC_REGNUM:
-	  return builtin_type_void_func_ptr;
+	  return builtin_type (gdbarch)->builtin_func_ptr;
 	case E_SP_REGNUM:
 	case E_FP_REGNUM:
-	  return builtin_type_void_data_ptr;
+	  return builtin_type (gdbarch)->builtin_data_ptr;
 	default:
 	  if (regno == E_PSEUDO_CCR_REGNUM (gdbarch))
 	    return builtin_type_uint8;
Index: gdb-head/gdb/hppa-tdep.c
===================================================================
--- gdb-head.orig/gdb/hppa-tdep.c
+++ gdb-head/gdb/hppa-tdep.c
@@ -1244,8 +1244,9 @@ hppa32_convert_from_func_ptr_addr (struc
 {
   if (addr & 2)
     {
+      struct type *func_ptr_type = builtin_type (gdbarch)->builtin_func_ptr;
       CORE_ADDR plabel = addr & ~3;
-      return read_memory_typed_address (plabel, builtin_type_void_func_ptr);
+      return read_memory_typed_address (plabel, func_ptr_type);
     }
 
   return addr;
@@ -2897,6 +2898,9 @@ hppa_in_solib_call_trampoline (CORE_ADDR
 CORE_ADDR
 hppa_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
 {
+  struct gdbarch *gdbarch = get_frame_arch (frame);
+  struct type *func_ptr_type = builtin_type (gdbarch)->builtin_func_ptr;
+
   unsigned int insn[HPPA_MAX_INSN_PATTERN_LEN];
   int dp_rel;
 
@@ -2907,7 +2911,7 @@ hppa_skip_trampoline_code (struct frame_
 
       /* PLABELs have bit 30 set; if it's a PLABEL, then dereference it.  */
       if (pc & 0x2)
-	pc = read_memory_typed_address (pc & ~0x3, builtin_type_void_func_ptr);
+	pc = read_memory_typed_address (pc & ~0x3, func_ptr_type);
 
       return pc;
     }
@@ -2928,7 +2932,7 @@ hppa_skip_trampoline_code (struct frame_
 
   if (in_plt_section (pc, NULL))
     {
-      pc = read_memory_typed_address (pc, builtin_type_void_func_ptr);
+      pc = read_memory_typed_address (pc, func_ptr_type);
 
       /* If the PLT slot has not yet been resolved, the target will be
          the PLT stub.  */
@@ -2942,7 +2946,7 @@ hppa_skip_trampoline_code (struct frame_
 	    }
 
 	  /* This should point to the fixup routine.  */
-	  pc = read_memory_typed_address (pc + 8, builtin_type_void_func_ptr);
+	  pc = read_memory_typed_address (pc + 8, func_ptr_type);
 	}
     }
 
Index: gdb-head/gdb/i386-tdep.c
===================================================================
--- gdb-head.orig/gdb/i386-tdep.c
+++ gdb-head/gdb/i386-tdep.c
@@ -1275,7 +1275,7 @@ i386_unwind_pc (struct gdbarch *gdbarch,
   gdb_byte buf[8];
 
   frame_unwind_register (next_frame, gdbarch_pc_regnum (gdbarch), buf);
-  return extract_typed_address (buf, builtin_type_void_func_ptr);
+  return extract_typed_address (buf, builtin_type (gdbarch)->builtin_func_ptr);
 }
 
 
@@ -2071,9 +2071,11 @@ i386_sse_type (struct gdbarch *gdbarch)
 
       t = init_composite_type ("__gdb_builtin_type_vec128i", TYPE_CODE_UNION);
       append_composite_type_field (t, "v4_float",
-				   init_vector_type (builtin_type_float, 4));
+				   init_vector_type (builtin_type (gdbarch)
+						     ->builtin_float, 4));
       append_composite_type_field (t, "v2_double",
-				   init_vector_type (builtin_type_double, 2));
+				   init_vector_type (builtin_type (gdbarch)
+						     ->builtin_double, 2));
       append_composite_type_field (t, "v16_int8",
 				   init_vector_type (builtin_type_int8, 16));
       append_composite_type_field (t, "v8_int16",
@@ -2100,13 +2102,13 @@ static struct type *
 i386_register_type (struct gdbarch *gdbarch, int regnum)
 {
   if (regnum == I386_EIP_REGNUM)
-    return builtin_type_void_func_ptr;
+    return builtin_type (gdbarch)->builtin_func_ptr;
 
   if (regnum == I386_EFLAGS_REGNUM)
     return i386_eflags_type;
 
   if (regnum == I386_EBP_REGNUM || regnum == I386_ESP_REGNUM)
-    return builtin_type_void_data_ptr;
+    return builtin_type (gdbarch)->builtin_data_ptr;
 
   if (i386_fp_regnum_p (gdbarch, regnum))
     return builtin_type_i387_ext;
@@ -2120,7 +2122,7 @@ i386_register_type (struct gdbarch *gdba
   if (regnum == I387_MXCSR_REGNUM (gdbarch_tdep (gdbarch)))
     return i386_mxcsr_type;
 
-  return builtin_type_int;
+  return builtin_type (gdbarch)->builtin_int;
 }
 
 /* Map a cooked register onto a raw register or memory.  For the i386,
Index: gdb-head/gdb/ia64-tdep.c
===================================================================
--- gdb-head.orig/gdb/ia64-tdep.c
+++ gdb-head/gdb/ia64-tdep.c
@@ -309,7 +309,7 @@ ia64_register_type (struct gdbarch *arch
   if (reg >= IA64_FR0_REGNUM && reg <= IA64_FR127_REGNUM)
     return builtin_type_ia64_ext;
   else
-    return builtin_type_long;
+    return builtin_type (arch)->builtin_long;
 }
 
 static int
Index: gdb-head/gdb/m32r-tdep.c
===================================================================
--- gdb-head.orig/gdb/m32r-tdep.c
+++ gdb-head/gdb/m32r-tdep.c
@@ -231,9 +231,9 @@ static struct type *
 m32r_register_type (struct gdbarch *gdbarch, int reg_nr)
 {
   if (reg_nr == M32R_PC_REGNUM)
-    return builtin_type_void_func_ptr;
+    return builtin_type (gdbarch)->builtin_func_ptr;
   else if (reg_nr == M32R_SP_REGNUM || reg_nr == M32R_FP_REGNUM)
-    return builtin_type_void_data_ptr;
+    return builtin_type (gdbarch)->builtin_data_ptr;
   else
     return builtin_type_int32;
 }
Index: gdb-head/gdb/m68k-tdep.c
===================================================================
--- gdb-head.orig/gdb/m68k-tdep.c
+++ gdb-head/gdb/m68k-tdep.c
@@ -120,7 +120,7 @@ m68k_register_type (struct gdbarch *gdba
 	}
 
       if (regnum == M68K_FPI_REGNUM)
-	return builtin_type_void_func_ptr;
+	return builtin_type (gdbarch)->builtin_func_ptr;
 
       if (regnum == M68K_FPC_REGNUM || regnum == M68K_FPS_REGNUM)
 	return builtin_type_int32;
@@ -132,10 +132,10 @@ m68k_register_type (struct gdbarch *gdba
     }
 
   if (regnum == gdbarch_pc_regnum (gdbarch))
-    return builtin_type_void_func_ptr;
+    return builtin_type (gdbarch)->builtin_func_ptr;
 
   if (regnum >= M68K_A0_REGNUM && regnum <= M68K_A0_REGNUM + 7)
-    return builtin_type_void_data_ptr;
+    return builtin_type (gdbarch)->builtin_data_ptr;
 
   if (regnum == M68K_PS_REGNUM)
     return m68k_ps_type;
@@ -832,7 +832,7 @@ m68k_unwind_pc (struct gdbarch *gdbarch,
   gdb_byte buf[8];
 
   frame_unwind_register (next_frame, gdbarch_pc_regnum (gdbarch), buf);
-  return extract_typed_address (buf, builtin_type_void_func_ptr);
+  return extract_typed_address (buf, builtin_type (gdbarch)->builtin_func_ptr);
 }
 
 /* Normal frames.  */
Index: gdb-head/gdb/m88k-tdep.c
===================================================================
--- gdb-head.orig/gdb/m88k-tdep.c
+++ gdb-head/gdb/m88k-tdep.c
@@ -75,11 +75,11 @@ m88k_register_type (struct gdbarch *gdba
   /* SXIP, SNIP, SFIP and R1 contain code addresses.  */
   if ((regnum >= M88K_SXIP_REGNUM && regnum <= M88K_SFIP_REGNUM)
       || regnum == M88K_R1_REGNUM)
-    return builtin_type_void_func_ptr;
+    return builtin_type (gdbarch)->builtin_func_ptr;
 
   /* R30 and R31 typically contains data addresses.  */
   if (regnum == M88K_R30_REGNUM || regnum == M88K_R31_REGNUM)
-    return builtin_type_void_data_ptr;
+    return builtin_type (gdbarch)->builtin_data_ptr;
 
   return builtin_type_int32;
 }
Index: gdb-head/gdb/mep-tdep.c
===================================================================
--- gdb-head.orig/gdb/mep-tdep.c
+++ gdb-head/gdb/mep-tdep.c
@@ -1097,14 +1097,14 @@ mep_register_type (struct gdbarch *gdbar
       if (size == 32)
         {
           if (mep_pseudo_cr_is_float (reg_nr))
-            return builtin_type_float;
+            return builtin_type (gdbarch)->builtin_float;
           else
             return builtin_type_uint32;
         }
       else if (size == 64)
         {
           if (mep_pseudo_cr_is_float (reg_nr))
-            return builtin_type_double;
+            return builtin_type (gdbarch)->builtin_double;
           else
             return builtin_type_uint64;
         }
Index: gdb-head/gdb/mips-tdep.c
===================================================================
--- gdb-head.orig/gdb/mips-tdep.c
+++ gdb-head/gdb/mips-tdep.c
@@ -737,12 +737,13 @@ mips_pseudo_register_type (struct gdbarc
 
   /* Use pointer types for registers if we can.  For n32 we can not,
      since we do not have a 64-bit pointer type.  */
-  if (mips_abi_regsize (gdbarch) == TYPE_LENGTH (builtin_type_void_data_ptr))
+  if (mips_abi_regsize (gdbarch)
+      == TYPE_LENGTH (builtin_type (gdbarch)->builtin_data_ptr))
     {
       if (rawnum == MIPS_SP_REGNUM || rawnum == MIPS_EMBED_BADVADDR_REGNUM)
-	return builtin_type_void_data_ptr;
+	return builtin_type (gdbarch)->builtin_data_ptr;
       else if (rawnum == MIPS_EMBED_PC_REGNUM)
-	return builtin_type_void_func_ptr;
+	return builtin_type (gdbarch)->builtin_func_ptr;
     }
 
   if (mips_abi_regsize (gdbarch) == 4 && TYPE_LENGTH (rawtype) == 8
Index: gdb-head/gdb/mn10300-tdep.c
===================================================================
--- gdb-head.orig/gdb/mn10300-tdep.c
+++ gdb-head/gdb/mn10300-tdep.c
@@ -265,7 +265,7 @@ am33_2_register_name (struct gdbarch *gd
 static struct type *
 mn10300_register_type (struct gdbarch *gdbarch, int reg)
 {
-  return builtin_type_int;
+  return builtin_type (gdbarch)->builtin_int;
 }
 
 static CORE_ADDR
Index: gdb-head/gdb/rs6000-tdep.c
===================================================================
--- gdb-head.orig/gdb/rs6000-tdep.c
+++ gdb-head/gdb/rs6000-tdep.c
@@ -2079,7 +2079,8 @@ rs6000_builtin_type_vec64 (struct gdbarc
       t = init_composite_type ("__ppc_builtin_type_vec64", TYPE_CODE_UNION);
       append_composite_type_field (t, "uint64", builtin_type_int64);
       append_composite_type_field (t, "v2_float",
-				   init_vector_type (builtin_type_float, 2));
+				   init_vector_type (builtin_type (gdbarch)
+						     ->builtin_float, 2));
       append_composite_type_field (t, "v2_int32",
 				   init_vector_type (builtin_type_int32, 2));
       append_composite_type_field (t, "v4_int16",
@@ -2277,7 +2278,8 @@ rs6000_convert_register_p (struct gdbarc
 	  && regnum >= tdep->ppc_fp0_regnum
 	  && regnum < tdep->ppc_fp0_regnum + ppc_num_fprs
 	  && TYPE_CODE (type) == TYPE_CODE_FLT
-	  && TYPE_LENGTH (type) != TYPE_LENGTH (builtin_type_double));
+	  && TYPE_LENGTH (type)
+	     != TYPE_LENGTH (builtin_type (gdbarch)->builtin_double));
 }
 
 static void
@@ -2286,12 +2288,14 @@ rs6000_register_to_value (struct frame_i
                           struct type *type,
                           gdb_byte *to)
 {
+  struct gdbarch *gdbarch = get_frame_arch (frame);
   gdb_byte from[MAX_REGISTER_SIZE];
   
   gdb_assert (TYPE_CODE (type) == TYPE_CODE_FLT);
 
   get_frame_register (frame, regnum, from);
-  convert_typed_floating (from, builtin_type_double, to, type);
+  convert_typed_floating (from, builtin_type (gdbarch)->builtin_double,
+			  to, type);
 }
 
 static void
@@ -2300,11 +2304,13 @@ rs6000_value_to_register (struct frame_i
                           struct type *type,
                           const gdb_byte *from)
 {
+  struct gdbarch *gdbarch = get_frame_arch (frame);
   gdb_byte to[MAX_REGISTER_SIZE];
 
   gdb_assert (TYPE_CODE (type) == TYPE_CODE_FLT);
 
-  convert_typed_floating (from, type, to, builtin_type_double);
+  convert_typed_floating (from, type,
+			  to, builtin_type (gdbarch)->builtin_double);
   put_frame_register (frame, regnum, to);
 }
 
Index: gdb-head/gdb/s390-tdep.c
===================================================================
--- gdb-head.orig/gdb/s390-tdep.c
+++ gdb-head/gdb/s390-tdep.c
@@ -96,19 +96,19 @@ static struct type *
 s390_register_type (struct gdbarch *gdbarch, int regnum)
 {
   if (regnum == S390_PSWM_REGNUM || regnum == S390_PSWA_REGNUM)
-    return builtin_type_long;
+    return builtin_type (gdbarch)->builtin_long;
   if (regnum >= S390_R0_REGNUM && regnum <= S390_R15_REGNUM)
-    return builtin_type_long;
+    return builtin_type (gdbarch)->builtin_long;
   if (regnum >= S390_A0_REGNUM && regnum <= S390_A15_REGNUM)
-    return builtin_type_int;
+    return builtin_type (gdbarch)->builtin_int;
   if (regnum == S390_FPC_REGNUM)
-    return builtin_type_int;
+    return builtin_type (gdbarch)->builtin_int;
   if (regnum >= S390_F0_REGNUM && regnum <= S390_F15_REGNUM)
-    return builtin_type_double;
+    return builtin_type (gdbarch)->builtin_double;
   if (regnum == S390_PC_REGNUM)
-    return builtin_type_void_func_ptr;
+    return builtin_type (gdbarch)->builtin_func_ptr;
   if (regnum == S390_CC_REGNUM)
-    return builtin_type_int;
+    return builtin_type (gdbarch)->builtin_int;
 
   internal_error (__FILE__, __LINE__, _("invalid regnum"));
 }
Index: gdb-head/gdb/sparc64-tdep.c
===================================================================
--- gdb-head.orig/gdb/sparc64-tdep.c
+++ gdb-head/gdb/sparc64-tdep.c
@@ -247,15 +247,15 @@ sparc64_register_type (struct gdbarch *g
   /* Raw registers.  */
 
   if (regnum == SPARC_SP_REGNUM || regnum == SPARC_FP_REGNUM)
-    return builtin_type_void_data_ptr;
+    return builtin_type (gdbarch)->builtin_data_ptr;
   if (regnum >= SPARC_G0_REGNUM && regnum <= SPARC_I7_REGNUM)
     return builtin_type_int64;
   if (regnum >= SPARC_F0_REGNUM && regnum <= SPARC_F31_REGNUM)
-    return builtin_type_float;
+    return builtin_type (gdbarch)->builtin_float;
   if (regnum >= SPARC64_F32_REGNUM && regnum <= SPARC64_F62_REGNUM)
-    return builtin_type_double;
+    return builtin_type (gdbarch)->builtin_double;
   if (regnum == SPARC64_PC_REGNUM || regnum == SPARC64_NPC_REGNUM)
-    return builtin_type_void_func_ptr;
+    return builtin_type (gdbarch)->builtin_func_ptr;
   /* This raw register contains the contents of %cwp, %pstate, %asi
      and %ccr as laid out in a %tstate register.  */
   if (regnum == SPARC64_STATE_REGNUM)
@@ -280,9 +280,9 @@ sparc64_register_type (struct gdbarch *g
   if (regnum == SPARC64_CCR_REGNUM)
     return builtin_type_int64;
   if (regnum >= SPARC64_D0_REGNUM && regnum <= SPARC64_D62_REGNUM)
-    return builtin_type_double;
+    return builtin_type (gdbarch)->builtin_double;
   if (regnum >= SPARC64_Q0_REGNUM && regnum <= SPARC64_Q60_REGNUM)
-    return builtin_type_long_double;
+    return builtin_type (gdbarch)->builtin_long_double;
 
   internal_error (__FILE__, __LINE__, _("invalid regnum"));
 }
Index: gdb-head/gdb/sparc-tdep.c
===================================================================
--- gdb-head.orig/gdb/sparc-tdep.c
+++ gdb-head/gdb/sparc-tdep.c
@@ -332,16 +332,16 @@ static struct type *
 sparc32_register_type (struct gdbarch *gdbarch, int regnum)
 {
   if (regnum >= SPARC_F0_REGNUM && regnum <= SPARC_F31_REGNUM)
-    return builtin_type_float;
+    return builtin_type (gdbarch)->builtin_float;
 
   if (regnum >= SPARC32_D0_REGNUM && regnum <= SPARC32_D30_REGNUM)
-    return builtin_type_double;
+    return builtin_type (gdbarch)->builtin_double;
 
   if (regnum == SPARC_SP_REGNUM || regnum == SPARC_FP_REGNUM)
-    return builtin_type_void_data_ptr;
+    return builtin_type (gdbarch)->builtin_data_ptr;
 
   if (regnum == SPARC32_PC_REGNUM || regnum == SPARC32_NPC_REGNUM)
-    return builtin_type_void_func_ptr;
+    return builtin_type (gdbarch)->builtin_func_ptr;
 
   if (regnum == SPARC32_PSR_REGNUM)
     return sparc_psr_type;
Index: gdb-head/gdb/spu-tdep.c
===================================================================
--- gdb-head.orig/gdb/spu-tdep.c
+++ gdb-head/gdb/spu-tdep.c
@@ -74,9 +74,11 @@ spu_builtin_type_vec128 (struct gdbarch 
       append_composite_type_field (t, "v16_int8",
 				   init_vector_type (builtin_type_int8, 16));
       append_composite_type_field (t, "v2_double",
-				   init_vector_type (builtin_type_double, 2));
+				   init_vector_type (builtin_type (gdbarch)
+						     ->builtin_double, 2));
       append_composite_type_field (t, "v4_float",
-				   init_vector_type (builtin_type_float, 4));
+				   init_vector_type (builtin_type (gdbarch)
+						     ->builtin_float, 4));
 
       TYPE_VECTOR (t) = 1;
       TYPE_NAME (t) = "spu_builtin_type_vec128";
@@ -137,10 +139,10 @@ spu_register_type (struct gdbarch *gdbar
       return builtin_type_uint32;
 
     case SPU_PC_REGNUM:
-      return builtin_type_void_func_ptr;
+      return builtin_type (gdbarch)->builtin_func_ptr;
 
     case SPU_SP_REGNUM:
-      return builtin_type_void_data_ptr;
+      return builtin_type (gdbarch)->builtin_data_ptr;
 
     case SPU_FPSCR_REGNUM:
       return builtin_type_uint128;
Index: gdb-head/gdb/std-regs.c
===================================================================
--- gdb-head.orig/gdb/std-regs.c
+++ gdb-head/gdb/std-regs.c
@@ -42,12 +42,13 @@ value_of_builtin_frame_fp_reg (struct fr
 			      frame);
   else
     {
-      struct value *val = allocate_value (builtin_type_void_data_ptr);
+      struct type *data_ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
+      struct value *val = allocate_value (data_ptr_type);
       gdb_byte *buf = value_contents_raw (val);
       if (frame == NULL)
 	memset (buf, 0, TYPE_LENGTH (value_type (val)));
       else
-	gdbarch_address_to_pointer (gdbarch, builtin_type_void_data_ptr,
+	gdbarch_address_to_pointer (gdbarch, data_ptr_type,
 				    buf, get_frame_base_address (frame));
       return val;
     }
@@ -61,12 +62,13 @@ value_of_builtin_frame_pc_reg (struct fr
     return value_of_register (gdbarch_pc_regnum (gdbarch), frame);
   else
     {
-      struct value *val = allocate_value (builtin_type_void_func_ptr);
+      struct type *func_ptr_type = builtin_type (gdbarch)->builtin_func_ptr;
+      struct value *val = allocate_value (func_ptr_type);
       gdb_byte *buf = value_contents_raw (val);
       if (frame == NULL)
 	memset (buf, 0, TYPE_LENGTH (value_type (val)));
       else
-	gdbarch_address_to_pointer (gdbarch, builtin_type_void_func_ptr,
+	gdbarch_address_to_pointer (gdbarch, func_ptr_type,
 				    buf, get_frame_pc (frame));
       return val;
     }
Index: gdb-head/gdb/target-descriptions.c
===================================================================
--- gdb-head.orig/gdb/target-descriptions.c
+++ gdb-head/gdb/target-descriptions.c
@@ -552,32 +552,32 @@ tdesc_register_type (struct gdbarch *gdb
   if (strcmp (reg->type, "float") == 0)
     {
       if (reg->bitsize == gdbarch_float_bit (gdbarch))
-	return builtin_type_float;
+	return builtin_type (gdbarch)->builtin_float;
       else if (reg->bitsize == gdbarch_double_bit (gdbarch))
-	return builtin_type_double;
+	return builtin_type (gdbarch)->builtin_double;
       else if (reg->bitsize == gdbarch_long_double_bit (gdbarch))
-	return builtin_type_long_double;
+	return builtin_type (gdbarch)->builtin_long_double;
     }
   else if (strcmp (reg->type, "int") == 0)
     {
       if (reg->bitsize == gdbarch_long_bit (gdbarch))
-	return builtin_type_long;
+	return builtin_type (gdbarch)->builtin_long;
       else if (reg->bitsize == TARGET_CHAR_BIT)
-	return builtin_type_char;
+	return builtin_type (gdbarch)->builtin_char;
       else if (reg->bitsize == gdbarch_short_bit (gdbarch))
-	return builtin_type_short;
+	return builtin_type (gdbarch)->builtin_short;
       else if (reg->bitsize == gdbarch_int_bit (gdbarch))
-	return builtin_type_int;
+	return builtin_type (gdbarch)->builtin_int;
       else if (reg->bitsize == gdbarch_long_long_bit (gdbarch))
-	return builtin_type_long_long;
+	return builtin_type (gdbarch)->builtin_long_long;
       else if (reg->bitsize == gdbarch_ptr_bit (gdbarch))
 	/* A bit desperate by this point... */
-	return builtin_type_void_data_ptr;
+	return builtin_type (gdbarch)->builtin_data_ptr;
     }
   else if (strcmp (reg->type, "code_ptr") == 0)
-    return builtin_type_void_func_ptr;
+    return builtin_type (gdbarch)->builtin_func_ptr;
   else if (strcmp (reg->type, "data_ptr") == 0)
-    return builtin_type_void_data_ptr;
+    return builtin_type (gdbarch)->builtin_data_ptr;
   else
     internal_error (__FILE__, __LINE__,
 		    "Register \"%s\" has an unknown type \"%s\"",
@@ -585,7 +585,7 @@ tdesc_register_type (struct gdbarch *gdb
 
   warning (_("Register \"%s\" has an unsupported size (%d bits)"),
 	   reg->name, reg->bitsize);
-  return builtin_type_long;
+  return builtin_type (gdbarch)->builtin_long;
 }
 
 static int
Index: gdb-head/gdb/v850-tdep.c
===================================================================
--- gdb-head.orig/gdb/v850-tdep.c
+++ gdb-head/gdb/v850-tdep.c
@@ -183,7 +183,7 @@ static struct type *
 v850_register_type (struct gdbarch *gdbarch, int regnum)
 {
   if (regnum == E_PC_REGNUM)
-    return builtin_type_void_func_ptr;
+    return builtin_type (gdbarch)->builtin_func_ptr;
   return builtin_type_int32;
 }
 
Index: gdb-head/gdb/vax-tdep.c
===================================================================
--- gdb-head.orig/gdb/vax-tdep.c
+++ gdb-head/gdb/vax-tdep.c
@@ -61,7 +61,7 @@ vax_register_name (struct gdbarch *gdbar
 static struct type *
 vax_register_type (struct gdbarch *gdbarch, int regnum)
 {
-  return builtin_type_int;
+  return builtin_type (gdbarch)->builtin_int;
 }
 
 /* Core file support.  */
Index: gdb-head/gdb/stack.c
===================================================================
--- gdb-head.orig/gdb/stack.c
+++ gdb-head/gdb/stack.c
@@ -1780,11 +1780,13 @@ down_command (char *count_exp, int from_
 void
 return_command (char *retval_exp, int from_tty)
 {
+  struct frame_info *thisframe;
   struct symbol *thisfun;
   struct value *return_value = NULL;
   const char *query_prefix = "";
 
-  thisfun = get_frame_function (get_selected_frame ("No selected frame."));
+  thisframe = get_selected_frame ("No selected frame.");
+  thisfun = get_frame_function (thisframe);
 
   /* Compute the return value.  If the computation triggers an error,
      let it bail.  If the return type can't be handled, set
@@ -1803,7 +1805,7 @@ return_command (char *retval_exp, int fr
       if (thisfun != NULL)
 	return_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (thisfun));
       if (return_type == NULL)
-	return_type = builtin_type_int;
+	return_type = builtin_type (get_frame_arch (thisframe))->builtin_int;
       CHECK_TYPEDEF (return_type);
       return_value = value_cast (return_type, return_value);
 
Index: gdb-head/gdb/cp-abi.c
===================================================================
--- gdb-head.orig/gdb/cp-abi.c
+++ gdb-head/gdb/cp-abi.c
@@ -113,19 +113,20 @@ cplus_print_method_ptr (const gdb_byte *
 }
 
 int
-cplus_method_ptr_size (void)
+cplus_method_ptr_size (struct type *to_type)
 {
   if (current_cp_abi.method_ptr_size == NULL)
     error (_("GDB does not support pointers to methods on this target"));
-  return (*current_cp_abi.method_ptr_size) ();
+  return (*current_cp_abi.method_ptr_size) (to_type);
 }
 
 void
-cplus_make_method_ptr (gdb_byte *contents, CORE_ADDR value, int is_virtual)
+cplus_make_method_ptr (struct type *type, gdb_byte *contents,
+		       CORE_ADDR value, int is_virtual)
 {
   if (current_cp_abi.make_method_ptr == NULL)
     error (_("GDB does not support pointers to methods on this target"));
-  (*current_cp_abi.make_method_ptr) (contents, value, is_virtual);
+  (*current_cp_abi.make_method_ptr) (type, contents, value, is_virtual);
 }
 
 CORE_ADDR
Index: gdb-head/gdb/cp-abi.h
===================================================================
--- gdb-head.orig/gdb/cp-abi.h
+++ gdb-head/gdb/cp-abi.h
@@ -151,21 +151,20 @@ extern int baseclass_offset (struct type
 void cplus_print_method_ptr (const gdb_byte *contents, struct type *type,
 			     struct ui_file *stream);
 
-/* Return the size of a pointer to member function for the current
-   architecture.  */
-int cplus_method_ptr_size (void);
+/* Return the size of a pointer to member function of type TO_TYPE.  */
+int cplus_method_ptr_size (struct type *to_type);
 
 /* Return the method which should be called by applying METHOD_PTR
    to *THIS_P, and adjust *THIS_P if necessary.  */
 struct value *cplus_method_ptr_to_value (struct value **this_p,
 					 struct value *method_ptr);
 
-/* Create the byte pattern in CONTENTS representing a pointer to
-   member function at ADDRESS (if IS_VIRTUAL is 0) or with virtual
-   table offset ADDRESS (if IS_VIRTUAL is 1).  This is the opposite
-   of cplus_method_ptr_to_value.  */
-void cplus_make_method_ptr (gdb_byte *CONTENTS, CORE_ADDR address,
-			    int is_virtual);
+/* Create the byte pattern in CONTENTS representing a pointer of
+   type TYPE to member function at ADDRESS (if IS_VIRTUAL is 0)
+   or with virtual table offset ADDRESS (if IS_VIRTUAL is 1).
+   This is the opposite of cplus_method_ptr_to_value.  */
+void cplus_make_method_ptr (struct type *type, gdb_byte *CONTENTS,
+			    CORE_ADDR address, int is_virtual);
 
 /* Determine if we are currently in a C++ thunk.  If so, get the address
    of the routine we are thunking to and continue to there instead.  */
@@ -195,8 +194,8 @@ struct cp_abi_ops
 			   const bfd_byte *valaddr, CORE_ADDR address);
   void (*print_method_ptr) (const gdb_byte *contents, struct type *type,
 			    struct ui_file *stream);
-  int (*method_ptr_size) (void);
-  void (*make_method_ptr) (gdb_byte *, CORE_ADDR, int);
+  int (*method_ptr_size) (struct type *);
+  void (*make_method_ptr) (struct type *, gdb_byte *, CORE_ADDR, int);
   struct value * (*method_ptr_to_value) (struct value **, struct value *);
   CORE_ADDR (*skip_trampoline) (struct frame_info *, CORE_ADDR);
   int (*pass_by_reference) (struct type *type);
Index: gdb-head/gdb/cp-valprint.c
===================================================================
--- gdb-head.orig/gdb/cp-valprint.c
+++ gdb-head/gdb/cp-valprint.c
@@ -538,16 +538,16 @@ cp_find_class_member (struct type **doma
 }
 
 void
-cp_print_class_member (const gdb_byte *valaddr, struct type *domain,
+cp_print_class_member (const gdb_byte *valaddr, struct type *type,
 		       struct ui_file *stream, char *prefix)
 {
   /* VAL is a byte offset into the structure type DOMAIN.
      Find the name of the field for that offset and
      print it.  */
+  struct type *domain = TYPE_DOMAIN_TYPE (type);
+  LONGEST val = extract_signed_integer (valaddr, TYPE_LENGTH (type));
   unsigned int fieldno;
 
-  LONGEST val = unpack_long (builtin_type_long, valaddr);
-
   /* Pointers to data members are usually byte offsets into an object.
      Because a data member can have offset zero, and a NULL pointer to
      member must be distinct from any valid non-NULL pointer to
Index: gdb-head/gdb/infcall.c
===================================================================
--- gdb-head.orig/gdb/infcall.c
+++ gdb-head/gdb/infcall.c
@@ -100,9 +100,10 @@ Unwinding of stack if a signal is receiv
    its value as needed).  */
 
 static struct value *
-value_arg_coerce (struct value *arg, struct type *param_type,
-		  int is_prototyped, CORE_ADDR *sp)
+value_arg_coerce (struct gdbarch *gdbarch, struct value *arg,
+		  struct type *param_type, int is_prototyped, CORE_ADDR *sp)
 {
+  const struct builtin_type *builtin = builtin_type (gdbarch);
   struct type *arg_type = check_typedef (value_type (arg));
   struct type *type
     = param_type ? check_typedef (param_type) : arg_type;
@@ -141,22 +142,22 @@ value_arg_coerce (struct value *arg, str
       /* If we don't have a prototype, coerce to integer type if necessary.  */
       if (!is_prototyped)
 	{
-	  if (TYPE_LENGTH (type) < TYPE_LENGTH (builtin_type_int))
-	    type = builtin_type_int;
+	  if (TYPE_LENGTH (type) < TYPE_LENGTH (builtin->builtin_int))
+	    type = builtin->builtin_int;
 	}
       /* Currently all target ABIs require at least the width of an integer
          type for an argument.  We may have to conditionalize the following
          type coercion for future targets.  */
-      if (TYPE_LENGTH (type) < TYPE_LENGTH (builtin_type_int))
-	type = builtin_type_int;
+      if (TYPE_LENGTH (type) < TYPE_LENGTH (builtin->builtin_int))
+	type = builtin->builtin_int;
       break;
     case TYPE_CODE_FLT:
       if (!is_prototyped && coerce_float_to_double_p)
 	{
-	  if (TYPE_LENGTH (type) < TYPE_LENGTH (builtin_type_double))
-	    type = builtin_type_double;
-	  else if (TYPE_LENGTH (type) > TYPE_LENGTH (builtin_type_double))
-	    type = builtin_type_long_double;
+	  if (TYPE_LENGTH (type) < TYPE_LENGTH (builtin->builtin_double))
+	    type = builtin->builtin_double;
+	  else if (TYPE_LENGTH (type) > TYPE_LENGTH (builtin->builtin_double))
+	    type = builtin->builtin_long_double;
 	}
       break;
     case TYPE_CODE_FUNC:
@@ -199,7 +200,7 @@ find_function_addr (struct value *functi
 {
   struct type *ftype = check_typedef (value_type (function));
   enum type_code code = TYPE_CODE (ftype);
-  struct type *value_type;
+  struct type *value_type = NULL;
   CORE_ADDR funaddr;
 
   /* If it's a member function, just look at the function
@@ -223,8 +224,6 @@ find_function_addr (struct value *functi
 							&current_target);
 	  value_type = TYPE_TARGET_TYPE (ftype);
 	}
-      else
-	value_type = builtin_type_int;
     }
   else if (code == TYPE_CODE_INT)
     {
@@ -251,8 +250,6 @@ find_function_addr (struct value *functi
 	    /* Handle integer used as address of a function.  */
 	    funaddr = (CORE_ADDR) value_as_long (function);
 	}
-
-      value_type = builtin_type_int;
     }
   else
     error (_("Invalid data type for function to be called."));
@@ -472,6 +469,9 @@ call_function_by_hand (struct value *fun
   funaddr = find_function_addr (function, &values_type);
   CHECK_TYPEDEF (values_type);
 
+  if (!values_type)
+    values_type = builtin_type (gdbarch)->builtin_int;
+
   /* Are we returning a value using a structure return (passing a
      hidden argument pointing to storage) or a normal value return?
      There are two cases: language-mandated structure return and
@@ -590,7 +590,8 @@ call_function_by_hand (struct value *fun
 	else
 	  param_type = NULL;
 
-	args[i] = value_arg_coerce (args[i], param_type, prototyped, &sp);
+	args[i] = value_arg_coerce (gdbarch, args[i],
+				    param_type, prototyped, &sp);
 
 	if (param_type != NULL && language_pass_by_reference (param_type))
 	  args[i] = value_addr (args[i]);
Index: gdb-head/gdb/doc/gdbint.texinfo
===================================================================
--- gdb-head.orig/gdb/doc/gdbint.texinfo
+++ gdb-head/gdb/doc/gdbint.texinfo
@@ -4114,11 +4114,6 @@ not defined, it will default to @code{0x
 @item REMOTE_BPT_VECTOR
 Defaults to @code{1}.
 
-@item const char *gdbarch_name_of_malloc (@var{gdbarch})
-@findex gdbarch_name_of_malloc
-A string containing the name of the function to call in order to
-allocate some memory in the inferior. The default value is "malloc".
-
 @end ftable
 
 @node Adding a New Target
Index: gdb-head/gdb/gdbarch.c
===================================================================
--- gdb-head.orig/gdb/gdbarch.c
+++ gdb-head/gdb/gdbarch.c
@@ -215,7 +215,6 @@ struct gdbarch
   gdbarch_construct_inferior_arguments_ftype *construct_inferior_arguments;
   gdbarch_elf_make_msymbol_special_ftype *elf_make_msymbol_special;
   gdbarch_coff_make_msymbol_special_ftype *coff_make_msymbol_special;
-  const char * name_of_malloc;
   int cannot_step_breakpoint;
   int have_nonsteppable_watchpoint;
   gdbarch_address_class_type_flags_ftype *address_class_type_flags;
@@ -347,7 +346,6 @@ struct gdbarch startup_gdbarch =
   construct_inferior_arguments,  /* construct_inferior_arguments */
   0,  /* elf_make_msymbol_special */
   0,  /* coff_make_msymbol_special */
-  "malloc",  /* name_of_malloc */
   0,  /* cannot_step_breakpoint */
   0,  /* have_nonsteppable_watchpoint */
   0,  /* address_class_type_flags */
@@ -451,7 +449,6 @@ gdbarch_alloc (const struct gdbarch_info
   gdbarch->construct_inferior_arguments = construct_inferior_arguments;
   gdbarch->elf_make_msymbol_special = default_elf_make_msymbol_special;
   gdbarch->coff_make_msymbol_special = default_coff_make_msymbol_special;
-  gdbarch->name_of_malloc = "malloc";
   gdbarch->register_reggroup_p = default_register_reggroup_p;
   gdbarch->displaced_step_fixup = NULL;
   gdbarch->displaced_step_free_closure = NULL;
@@ -600,7 +597,6 @@ verify_gdbarch (struct gdbarch *gdbarch)
   /* Skip verify of construct_inferior_arguments, invalid_p == 0 */
   /* Skip verify of elf_make_msymbol_special, invalid_p == 0 */
   /* Skip verify of coff_make_msymbol_special, invalid_p == 0 */
-  /* Skip verify of name_of_malloc, invalid_p == 0 */
   /* Skip verify of cannot_step_breakpoint, invalid_p == 0 */
   /* Skip verify of have_nonsteppable_watchpoint, invalid_p == 0 */
   /* Skip verify of address_class_type_flags, has predicate */
@@ -881,9 +877,6 @@ gdbarch_dump (struct gdbarch *gdbarch, s
                       "gdbarch_dump: memory_remove_breakpoint = <0x%lx>\n",
                       (long) gdbarch->memory_remove_breakpoint);
   fprintf_unfiltered (file,
-                      "gdbarch_dump: name_of_malloc = %s\n",
-                      gdbarch->name_of_malloc);
-  fprintf_unfiltered (file,
                       "gdbarch_dump: num_pseudo_regs = %s\n",
                       paddr_d (gdbarch->num_pseudo_regs));
   fprintf_unfiltered (file,
@@ -2720,23 +2713,6 @@ set_gdbarch_coff_make_msymbol_special (s
   gdbarch->coff_make_msymbol_special = coff_make_msymbol_special;
 }
 
-const char *
-gdbarch_name_of_malloc (struct gdbarch *gdbarch)
-{
-  gdb_assert (gdbarch != NULL);
-  /* Skip verify of name_of_malloc, invalid_p == 0 */
-  if (gdbarch_debug >= 2)
-    fprintf_unfiltered (gdb_stdlog, "gdbarch_name_of_malloc called\n");
-  return gdbarch->name_of_malloc;
-}
-
-void
-set_gdbarch_name_of_malloc (struct gdbarch *gdbarch,
-                            const char * name_of_malloc)
-{
-  gdbarch->name_of_malloc = name_of_malloc;
-}
-
 int
 gdbarch_cannot_step_breakpoint (struct gdbarch *gdbarch)
 {
Index: gdb-head/gdb/gdbarch.h
===================================================================
--- gdb-head.orig/gdb/gdbarch.h
+++ gdb-head/gdb/gdbarch.h
@@ -591,9 +591,6 @@ typedef void (gdbarch_coff_make_msymbol_
 extern void gdbarch_coff_make_msymbol_special (struct gdbarch *gdbarch, int val, struct minimal_symbol *msym);
 extern void set_gdbarch_coff_make_msymbol_special (struct gdbarch *gdbarch, gdbarch_coff_make_msymbol_special_ftype *coff_make_msymbol_special);
 
-extern const char * gdbarch_name_of_malloc (struct gdbarch *gdbarch);
-extern void set_gdbarch_name_of_malloc (struct gdbarch *gdbarch, const char * name_of_malloc);
-
 extern int gdbarch_cannot_step_breakpoint (struct gdbarch *gdbarch);
 extern void set_gdbarch_cannot_step_breakpoint (struct gdbarch *gdbarch, int cannot_step_breakpoint);
 
Index: gdb-head/gdb/gdbarch.sh
===================================================================
--- gdb-head.orig/gdb/gdbarch.sh
+++ gdb-head/gdb/gdbarch.sh
@@ -586,7 +586,6 @@ m:int:in_function_epilogue_p:CORE_ADDR a
 m:char *:construct_inferior_arguments:int argc, char **argv:argc, argv::construct_inferior_arguments::0
 f:void:elf_make_msymbol_special:asymbol *sym, struct minimal_symbol *msym:sym, msym::default_elf_make_msymbol_special::0
 f:void:coff_make_msymbol_special:int val, struct minimal_symbol *msym:val, msym::default_coff_make_msymbol_special::0
-v:const char *:name_of_malloc:::"malloc":"malloc"::0:gdbarch->name_of_malloc
 v:int:cannot_step_breakpoint:::0:0::0
 v:int:have_nonsteppable_watchpoint:::0:0::0
 F:int:address_class_type_flags:int byte_size, int dwarf2_addr_class:byte_size, dwarf2_addr_class
Index: gdb-head/gdb/gcore.c
===================================================================
--- gdb-head.orig/gdb/gcore.c
+++ gdb-head/gdb/gcore.c
@@ -215,6 +215,8 @@ derive_stack_segment (bfd_vma *bottom, b
 static int
 derive_heap_segment (bfd *abfd, bfd_vma *bottom, bfd_vma *top)
 {
+  struct objfile *sbrk_objf;
+  struct gdbarch *gdbarch;
   bfd_vma top_of_data_memory = 0;
   bfd_vma top_of_heap = 0;
   bfd_size_type sec_size;
@@ -256,20 +258,21 @@ derive_heap_segment (bfd *abfd, bfd_vma 
   /* Now get the top-of-heap by calling sbrk in the inferior.  */
   if (lookup_minimal_symbol ("sbrk", NULL, NULL) != NULL)
     {
-      sbrk = find_function_in_inferior ("sbrk");
+      sbrk = find_function_in_inferior ("sbrk", &sbrk_objf);
       if (sbrk == NULL)
 	return 0;
     }
   else if (lookup_minimal_symbol ("_sbrk", NULL, NULL) != NULL)
     {
-      sbrk = find_function_in_inferior ("_sbrk");
+      sbrk = find_function_in_inferior ("_sbrk", &sbrk_objf);
       if (sbrk == NULL)
 	return 0;
     }
   else
     return 0;
 
-  zero = value_from_longest (builtin_type_int, 0);
+  gdbarch = get_objfile_arch (sbrk_objf);
+  zero = value_from_longest (builtin_type (gdbarch)->builtin_int, 0);
   gdb_assert (zero);
   sbrk = call_function_by_hand (sbrk, 1, &zero);
   if (sbrk == NULL)
Index: gdb-head/gdb/linux-fork.c
===================================================================
--- gdb-head.orig/gdb/linux-fork.c
+++ gdb-head/gdb/linux-fork.c
@@ -22,6 +22,7 @@
 #include "regcache.h"
 #include "gdbcmd.h"
 #include "infcall.h"
+#include "objfiles.h"
 #include "gdb_assert.h"
 #include "gdb_string.h"
 #include "linux-fork.h"
@@ -528,6 +529,8 @@ save_detach_fork (int *saved_val)
 static void
 checkpoint_command (char *args, int from_tty)
 {
+  struct objfile *fork_objf;
+  struct gdbarch *gdbarch;
   struct target_waitstatus last_target_waitstatus;
   ptid_t last_target_ptid;
   struct value *fork_fn = NULL, *ret;
@@ -545,14 +548,15 @@ checkpoint_command (char *args, int from
   /* Make the inferior fork, record its (and gdb's) state.  */
 
   if (lookup_minimal_symbol ("fork", NULL, NULL) != NULL)
-    fork_fn = find_function_in_inferior ("fork");
+    fork_fn = find_function_in_inferior ("fork", &fork_objf);
   if (!fork_fn)
     if (lookup_minimal_symbol ("_fork", NULL, NULL) != NULL)
-      fork_fn = find_function_in_inferior ("fork");
+      fork_fn = find_function_in_inferior ("fork", &fork_objf);
   if (!fork_fn)
     error (_("checkpoint: can't find fork function in inferior."));
 
-  ret = value_from_longest (builtin_type_int, 0);
+  gdbarch = get_objfile_arch (fork_objf);
+  ret = value_from_longest (builtin_type (gdbarch)->builtin_int, 0);
   old_chain = save_detach_fork (&temp_detach_fork);
   detach_fork = 0;
   ret = call_function_by_hand (fork_fn, 0, &ret);
Index: gdb-head/gdb/scm-valprint.c
===================================================================
--- gdb-head.orig/gdb/scm-valprint.c
+++ gdb-head/gdb/scm-valprint.c
@@ -30,6 +30,7 @@
 #include "gdbcore.h"
 #include "c-lang.h"
 #include "infcall.h"
+#include "objfiles.h"
 
 static void scm_ipruk (char *, LONGEST, struct ui_file *);
 static void scm_scmlist_print (LONGEST, struct ui_file *, int, int,
@@ -45,13 +46,16 @@ static int
 scm_inferior_print (LONGEST value, struct ui_file *stream, int format,
 		    int deref_ref, int recurse, enum val_prettyprint pretty)
 {
+  struct objfile *objf;
+  struct gdbarch *gdbarch;
   struct value *func, *arg, *result;
   struct symbol *gdb_output_sym, *gdb_output_len_sym;
   char *output;
   int ret, output_len;
 
-  func = find_function_in_inferior ("gdb_print");
-  arg = value_from_longest (builtin_type_CORE_ADDR, value);
+  func = find_function_in_inferior ("gdb_print", &objf);
+  gdbarch = get_objfile_arch (objf);
+  arg = value_from_longest (builtin_type (gdbarch)->builtin_core_addr, value);
 
   result = call_function_by_hand (func, 1, &arg);
   ret = (int) value_as_long (result);
@@ -73,7 +77,7 @@ scm_inferior_print (LONGEST value, struc
 		       (char *) &output_len, sizeof (output_len));
 
 	  output = (char *) alloca (output_len);
-	  remote_buffer = value_at (builtin_type_CORE_ADDR,
+	  remote_buffer = value_at (builtin_type (gdbarch)->builtin_core_addr,
 				    SYMBOL_VALUE_ADDRESS (gdb_output_sym));
 	  read_memory (value_as_address (remote_buffer),
 		       output, output_len);
Index: gdb-head/gdb/expprint.c
===================================================================
--- gdb-head.orig/gdb/expprint.c
+++ gdb-head/gdb/expprint.c
@@ -237,7 +237,8 @@ print_subexp_standard (struct expression
       nargs++;
       tem = 0;
       if (exp->elts[pc + 4].opcode == OP_LONG
-	  && exp->elts[pc + 5].type == builtin_type_char
+	  && exp->elts[pc + 5].type
+	     == builtin_type (exp->gdbarch)->builtin_char
 	  && exp->language_defn->la_language == language_c)
 	{
 	  /* Attempt to print C character arrays using string syntax.
@@ -252,7 +253,8 @@ print_subexp_standard (struct expression
 	  while (tem < nargs)
 	    {
 	      if (exp->elts[pc].opcode != OP_LONG
-		  || exp->elts[pc + 1].type != builtin_type_char)
+		  || exp->elts[pc + 1].type
+		     != builtin_type (exp->gdbarch)->builtin_char)
 		{
 		  /* Not a simple array of char, use regular array printing. */
 		  tem = 0;
Index: gdb-head/gdb/auxv.c
===================================================================
--- gdb-head.orig/gdb/auxv.c
+++ gdb-head/gdb/auxv.c
@@ -82,7 +82,8 @@ int
 default_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
 		   gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
 {
-  const int sizeof_auxv_field = TYPE_LENGTH (builtin_type_void_data_ptr);
+  const int sizeof_auxv_field = gdbarch_ptr_bit (target_gdbarch)
+				/ TARGET_CHAR_BIT;
   gdb_byte *ptr = *readptr;
 
   if (endptr == ptr)
Index: gdb-head/gdb/target.c
===================================================================
--- gdb-head.orig/gdb/target.c
+++ gdb-head/gdb/target.c
@@ -2152,7 +2152,7 @@ target_supports_non_stop ()
 static int
 default_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
 {
-  return (len <= TYPE_LENGTH (builtin_type_void_data_ptr));
+  return (len <= gdbarch_ptr_bit (target_gdbarch) / TARGET_CHAR_BIT);
 }
 
 static int
Index: gdb-head/gdb/procfs.c
===================================================================
--- gdb-head.orig/gdb/procfs.c
+++ gdb-head/gdb/procfs.c
@@ -160,7 +160,6 @@ static int
 procfs_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
                   gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
 {
-  const int pointer_size = TYPE_LENGTH (builtin_type_void_data_ptr);
   gdb_byte *ptr = *readptr;
 
   if (endptr == ptr)
@@ -2899,11 +2898,11 @@ proc_parent_pid (procinfo *pi)
 static void *
 procfs_address_to_host_pointer (CORE_ADDR addr)
 {
+  struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
   void *ptr;
 
-  gdb_assert (sizeof (ptr) == TYPE_LENGTH (builtin_type_void_data_ptr));
-  gdbarch_address_to_pointer (current_gdbarch, builtin_type_void_data_ptr,
-			      &ptr, addr);
+  gdb_assert (sizeof (ptr) == TYPE_LENGTH (ptr_type));
+  gdbarch_address_to_pointer (target_gdbarch, ptr_type, &ptr, addr);
   return ptr;
 }
 
@@ -5361,7 +5360,8 @@ procfs_can_use_hw_breakpoint (int type, 
      procfs_address_to_host_pointer will reveal that an internal error
      will be generated when the host and target pointer sizes are
      different.  */
-  if (sizeof (void *) != TYPE_LENGTH (builtin_type_void_data_ptr))
+  struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
+  if (sizeof (void *) != TYPE_LENGTH (ptr_type))
     return 0;
 
   /* Other tests here???  */
Index: gdb-head/gdb/bsd-uthread.c
===================================================================
--- gdb-head.orig/gdb/bsd-uthread.c
+++ gdb-head/gdb/bsd-uthread.c
@@ -145,6 +145,13 @@ bsd_uthread_lookup_offset (const char *n
   return read_memory_unsigned_integer (addr, 4);
 }
 
+static CORE_ADDR
+bsd_uthread_read_memory_address (CORE_ADDR addr)
+{
+  struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
+  return read_memory_typed_address (addr, ptr_type);
+}
+
 /* If OBJFILE contains the symbols corresponding to one of the
    supported user-level threads libraries, activate the thread stratum
    implemented by this module.  */
@@ -285,8 +292,7 @@ bsd_uthread_fetch_registers (struct regc
      thread structure.  This can go once we fix the underlying target.  */
   regnum = -1;
 
-  active_addr = read_memory_typed_address (bsd_uthread_thread_run_addr,
-					   builtin_type_void_data_ptr);
+  active_addr = bsd_uthread_read_memory_address (bsd_uthread_thread_run_addr);
   if (addr != 0 && addr != active_addr)
     {
       bsd_uthread_check_magic (addr);
@@ -303,8 +309,7 @@ bsd_uthread_store_registers (struct regc
   CORE_ADDR addr = ptid_get_tid (inferior_ptid);
   CORE_ADDR active_addr;
 
-  active_addr = read_memory_typed_address (bsd_uthread_thread_run_addr,
-					   builtin_type_void_data_ptr);
+  active_addr = bsd_uthread_read_memory_address (bsd_uthread_thread_run_addr);
   if (addr != 0 && addr != active_addr)
     {
       bsd_uthread_check_magic (addr);
@@ -349,8 +354,7 @@ bsd_uthread_wait (ptid_t ptid, struct ta
 
   /* Fetch the corresponding thread ID, and augment the returned
      process ID with it.  */
-  addr = read_memory_typed_address (bsd_uthread_thread_run_addr,
-				    builtin_type_void_data_ptr);
+  addr = bsd_uthread_read_memory_address (bsd_uthread_thread_run_addr);
   if (addr != 0)
     {
       gdb_byte buf[4];
@@ -413,8 +417,7 @@ bsd_uthread_find_new_threads (void)
   int offset = bsd_uthread_thread_next_offset;
   CORE_ADDR addr;
 
-  addr = read_memory_typed_address (bsd_uthread_thread_list_addr,
-				    builtin_type_void_data_ptr);
+  addr = bsd_uthread_read_memory_address (bsd_uthread_thread_list_addr);
   while (addr != 0)
     {
       ptid_t ptid = ptid_build (pid, 0, addr);
@@ -422,8 +425,7 @@ bsd_uthread_find_new_threads (void)
       if (!in_thread_list (ptid))
 	add_thread (ptid);
 
-      addr = read_memory_typed_address (addr + offset,
-					builtin_type_void_data_ptr);
+      addr = bsd_uthread_read_memory_address (addr + offset);
     }
 }
 
Index: gdb-head/gdb/nto-tdep.c
===================================================================
--- gdb-head.orig/gdb/nto-tdep.c
+++ gdb-head/gdb/nto-tdep.c
@@ -280,10 +280,10 @@ LM_ADDR (struct so_list *so)
   if (so->lm_info->l_addr == (CORE_ADDR)-1)
     {
       struct link_map_offsets *lmo = nto_fetch_link_map_offsets ();
+      struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
 
       so->lm_info->l_addr =
-	    extract_typed_address (so->lm_info->lm + lmo->l_addr_offset,
-				   builtin_type_void_data_ptr);
+	extract_typed_address (so->lm_info->lm + lmo->l_addr_offset, ptr_type);
     }
   return so->lm_info->l_addr;
 }
Index: gdb-head/gdb/solib-svr4.c
===================================================================
--- gdb-head.orig/gdb/solib-svr4.c
+++ gdb-head/gdb/solib-svr4.c
@@ -140,9 +140,10 @@ static CORE_ADDR
 LM_ADDR_FROM_LINK_MAP (struct so_list *so)
 {
   struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
+  struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
 
   return extract_typed_address (so->lm_info->lm + lmo->l_addr_offset,
-				builtin_type_void_data_ptr);
+				ptr_type);
 }
 
 static int
@@ -157,9 +158,10 @@ static CORE_ADDR
 LM_DYNAMIC_FROM_LINK_MAP (struct so_list *so)
 {
   struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
+  struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
 
   return extract_typed_address (so->lm_info->lm + lmo->l_ld_offset,
-				builtin_type_void_data_ptr);
+				ptr_type);
 }
 
 static CORE_ADDR
@@ -236,24 +238,27 @@ static CORE_ADDR
 LM_NEXT (struct so_list *so)
 {
   struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
+  struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
 
   return extract_typed_address (so->lm_info->lm + lmo->l_next_offset,
-				builtin_type_void_data_ptr);
+				ptr_type);
 }
 
 static CORE_ADDR
 LM_NAME (struct so_list *so)
 {
   struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
+  struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
 
   return extract_typed_address (so->lm_info->lm + lmo->l_name_offset,
-				builtin_type_void_data_ptr);
+				ptr_type);
 }
 
 static int
 IGNORE_FIRST_LINK_MAP_ENTRY (struct so_list *so)
 {
   struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
+  struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
 
   /* Assume that everything is a library if the dynamic loader was loaded
      late by a static executable.  */
@@ -261,7 +266,7 @@ IGNORE_FIRST_LINK_MAP_ENTRY (struct so_l
     return 0;
 
   return extract_typed_address (so->lm_info->lm + lmo->l_prev_offset,
-				builtin_type_void_data_ptr) == 0;
+				ptr_type) == 0;
 }
 
 static CORE_ADDR debug_base;	/* Base of dynamic linker structures */
@@ -566,13 +571,14 @@ scan_dyntag (int dyntag, bfd *abfd, CORE
 	    entry.  */
 	 if (ptr)
 	   {
+	     struct type *ptr_type;
 	     gdb_byte ptr_buf[8];
 	     CORE_ADDR ptr_addr;
 
+	     ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
 	     ptr_addr = dyn_addr + (buf - bufstart) + arch_size / 8;
 	     if (target_read_memory (ptr_addr, ptr_buf, arch_size / 8) == 0)
-	       dyn_ptr = extract_typed_address (ptr_buf,
-						builtin_type_void_data_ptr);
+	       dyn_ptr = extract_typed_address (ptr_buf, ptr_type);
 	     *ptr = dyn_ptr;
 	   }
 	 return 1;
@@ -672,14 +678,15 @@ elf_locate_base (void)
   if (scan_dyntag (DT_MIPS_RLD_MAP, exec_bfd, &dyn_ptr)
       || scan_dyntag_auxv (DT_MIPS_RLD_MAP, &dyn_ptr))
     {
+      struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
       gdb_byte *pbuf;
-      int pbuf_size = TYPE_LENGTH (builtin_type_void_data_ptr);
+      int pbuf_size = TYPE_LENGTH (ptr_type);
       pbuf = alloca (pbuf_size);
       /* DT_MIPS_RLD_MAP contains a pointer to the address
 	 of the dynamic link structure.  */
       if (target_read_memory (dyn_ptr, pbuf, pbuf_size))
 	return 0;
-      return extract_typed_address (pbuf, builtin_type_void_data_ptr);
+      return extract_typed_address (pbuf, ptr_type);
     }
 
   /* Find DT_DEBUG.  */
@@ -763,9 +770,9 @@ static CORE_ADDR
 solib_svr4_r_map (void)
 {
   struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
+  struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
 
-  return read_memory_typed_address (debug_base + lmo->r_map_offset,
-				    builtin_type_void_data_ptr);
+  return read_memory_typed_address (debug_base + lmo->r_map_offset, ptr_type);
 }
 
 /* Find r_brk from the inferior's debug base.  */
@@ -774,9 +781,9 @@ static CORE_ADDR
 solib_svr4_r_brk (void)
 {
   struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
+  struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
 
-  return read_memory_typed_address (debug_base + lmo->r_brk_offset,
-				    builtin_type_void_data_ptr);
+  return read_memory_typed_address (debug_base + lmo->r_brk_offset, ptr_type);
 }
 
 /* Find the link map for the dynamic linker (if it is not in the
@@ -786,6 +793,7 @@ static CORE_ADDR
 solib_svr4_r_ldsomap (void)
 {
   struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
+  struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
   ULONGEST version;
 
   /* Check version, and return zero if `struct r_debug' doesn't have
@@ -796,7 +804,7 @@ solib_svr4_r_ldsomap (void)
     return 0;
 
   return read_memory_typed_address (debug_base + lmo->r_ldsomap_offset,
-				    builtin_type_void_data_ptr);
+				    ptr_type);
 }
 
 /*
@@ -829,7 +837,8 @@ open_symbol_file_object (void *from_ttyp
   int errcode;
   int from_tty = *(int *)from_ttyp;
   struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
-  int l_name_size = TYPE_LENGTH (builtin_type_void_data_ptr);
+  struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
+  int l_name_size = TYPE_LENGTH (ptr_type);
   gdb_byte *l_name_buf = xmalloc (l_name_size);
   struct cleanup *cleanups = make_cleanup (xfree, l_name_buf);
 
@@ -851,7 +860,7 @@ open_symbol_file_object (void *from_ttyp
   read_memory (lm + lmo->l_name_offset, l_name_buf, l_name_size);
 
   /* Convert the address to host format.  */
-  l_name = extract_typed_address (l_name_buf, builtin_type_void_data_ptr);
+  l_name = extract_typed_address (l_name_buf, ptr_type);
 
   /* Free l_name_buf.  */
   do_cleanups (cleanups);
Index: gdb-head/gdb/f-lang.h
===================================================================
--- gdb-head.orig/gdb/f-lang.h
+++ gdb-head/gdb/f-lang.h
@@ -104,3 +104,27 @@ extern int f77_get_dynamic_lowerbound (s
 extern void f77_get_dynamic_array_length (struct type *);
 
 extern int calc_f77_array_dims (struct type *);
+
+
+/* Fortran (F77) types */
+
+struct builtin_f_type
+{
+  struct type *builtin_character;
+  struct type *builtin_integer;
+  struct type *builtin_integer_s2;
+  struct type *builtin_logical;
+  struct type *builtin_logical_s1;
+  struct type *builtin_logical_s2;
+  struct type *builtin_real;
+  struct type *builtin_real_s8;
+  struct type *builtin_real_s16;
+  struct type *builtin_complex_s8;
+  struct type *builtin_complex_s16;
+  struct type *builtin_complex_s32;
+  struct type *builtin_void;
+};
+
+/* Return the Fortran type table for the specified architecture.  */
+extern const struct builtin_f_type *builtin_f_type (struct gdbarch *gdbarch);
+
Index: gdb-head/gdb/m2-lang.h
===================================================================
--- gdb-head.orig/gdb/m2-lang.h
+++ gdb-head/gdb/m2-lang.h
@@ -35,3 +35,18 @@ extern int m2_val_print (struct type *, 
 
 extern int get_long_set_bounds (struct type *type, LONGEST *low,
 				LONGEST *high);
+
+/* Modula-2 types */
+
+struct builtin_m2_type
+{
+  struct type *builtin_char;
+  struct type *builtin_int;
+  struct type *builtin_card;
+  struct type *builtin_real;
+  struct type *builtin_bool;
+};
+
+/* Return the Modula-2 type table for the specified architecture.  */
+extern const struct builtin_m2_type *builtin_m2_type (struct gdbarch *gdbarch);
+


-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


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