diff mbox

Separate {OS,CPU}_CPP_BUILTINS macros into C-family and language-independent macros

Message ID 1D974441-C894-4F24-A0D1-7B693044B2BF@gmail.com
State New
Headers show

Commit Message

FX Coudert Nov. 3, 2010, 9:26 p.m. UTC
See below for the description of the patch; this take n+1 incorporates suggestions by Michael Meissner and Rainer Orth, with the following exceptions:

  -- As avr.c includes new headers (cpplib.h and cppbuiltin.h), I wanted to update its dependencies in the target configuration file (t-avr), but to my surprise, this file doesn't contain any mention of avr.o. In fact, I failed to find any by grepping the whole tree, so I'm a little unsure how this can work (and apparently it does). Could the maintainers help me here?

  -- Michael is worried about splitting all this stuff:

>> Unless I don't see what you're talking about, this is not possible: the Fortran front-end is not linked with the *-c.c files, only with *.c, so the language-independent functions need to be moved there.
> 
> Yes, but if fortran is going to use the preprocessor, maybe they should be
> linked in.  I'm just worried about the possibility of a macro getting lost in
> the movement.


Well, we do need some separation between CPP built-in macros that are only relevant for C-family languages (for example, because they depend on flag variables that are only declared for C) and the others. Now that the job is done, was discussed beforehand, and it fixes the regression experienced by Fortran, I'd be glad to just have it work.


Tested as indicated below, OK to commit? (needs a global reviewer; pretty pretty please, don't let it bitrot again)  I'd like to highlight that it's nothing conceptualy major, and it'll be easy to fix any eventual fallout.

FX




------------------

The attached patch fixes PR 42954: when Fortran moved to using libcpp directly from the front-end (instead of calling cc1 to do its preprocessing), we lost all target-specific CPP built-in macros. The issue is that part of the code in TARGET_OS_CPP_BUILTINS and TARGET_CPU_CPP_BUILTINS depends on C-only flags, and thus cannot be moved to a directory outside gcc/c-family/.

The patch moves this C-only code to specific TARGET_OS_CPP_BUILTINS_CFAMILY and TARGET_CPU_CPP_BUILTINS_CFAMILY macros. I manually audited all the targets in config/ twice, to check that I did not leave any code behind. I have bootstrapped and regtested an all-language compiler on x86_64-linux and i686-darwin. I have also built C and Fortran cross-compilers (make all-gcc && make fortran) for the following targets (which cover all gcc/config/ files changed):

avr-elf
frv-elf
spu-elf
i386-pc-netware
alpha-linux
alpha-dec-osf5.1
ia64-hpux
mips-linux
mips-sgi-irix6.5
hppa2.0w-hp-hpux11.00
sparc-sun-solaris2.10
i686-pc-mingw32
powerpc-darwin

In all cases, the cross-compiler built successfully and seemed to work. In each case, I checked a few of the target-specific macros (but did not check all of them).

OK to commit?

Comments

Weddington, Eric Nov. 3, 2010, 10:31 p.m. UTC | #1
> -----Original Message-----
> From: FX [mailto:fxcoudert@gmail.com] 
> Sent: Wednesday, November 03, 2010 3:27 PM
> To: gcc-patches@gcc.gnu.org; gfortran List
> Cc: Michael Meissner; Rainer Orth; chertykov@gmail.com; 
> aesok@post.ru; Weddington, Eric
> Subject: [patch] Separate {OS,CPU}_CPP_BUILTINS macros into 
> C-family and language-independent macros
> 
> See below for the description of the patch; this take n+1 
> incorporates suggestions by Michael Meissner and Rainer Orth, 
> with the following exceptions:
> 
>   -- As avr.c includes new headers (cpplib.h and 
> cppbuiltin.h), I wanted to update its dependencies in the 
> target configuration file (t-avr), but to my surprise, this 
> file doesn't contain any mention of avr.o. In fact, I failed 
> to find any by grepping the whole tree, so I'm a little 
> unsure how this can work (and apparently it does). Could the 
> maintainers help me here?

Hmm. AFAICT, in looking through the history of that file, the first time that it contained any dependency information was June 23, 2009 (revision 148868) and it wasn't for avr.o. I don't think it ever contained dependency information for avr.o. 


 
> The attached patch fixes PR 42954: when Fortran moved to 
> using libcpp directly from the front-end (instead of calling 
> cc1 to do its preprocessing), we lost all target-specific CPP 
> built-in macros. The issue is that part of the code in 
> TARGET_OS_CPP_BUILTINS and TARGET_CPU_CPP_BUILTINS depends on 
> C-only flags, and thus cannot be moved to a directory outside 
> gcc/c-family/.
> 
> The patch moves this C-only code to specific 
> TARGET_OS_CPP_BUILTINS_CFAMILY and 
> TARGET_CPU_CPP_BUILTINS_CFAMILY macros. I manually audited 
> all the targets in config/ twice, to check that I did not 
> leave any code behind. I have bootstrapped and regtested an 
> all-language compiler on x86_64-linux and i686-darwin. I have 
> also built C and Fortran cross-compilers (make all-gcc && 
> make fortran) for the following targets (which cover all 
> gcc/config/ files changed):
> 
> avr-elf
<snip>
> 
> In all cases, the cross-compiler built successfully and 
> seemed to work. In each case, I checked a few of the 
> target-specific macros (but did not check all of them).

That's news to me: I didn't know that you could now build the Fortran compiler for the AVR. (Not that anyone would seriously use it, but.. you never know.) Last I heard, the Fortran FE couldn't be built for the AVR because that port only has 32-bit doubles. See gcc bug #34040.

Thanks for doing this work. :-)

Eric Weddington
FX Coudert Nov. 3, 2010, 10:34 p.m. UTC | #2
> That's news to me: I didn't know that you could now build the Fortran compiler for the AVR. (Not that anyone would seriously use it, but.. you never know.) Last I heard, the Fortran FE couldn't be built for the AVR because that port only has 32-bit doubles. See gcc bug #34040.

Oh, it does build, it's just thoroughly unusable!  :)
(Well, it does preprocess code OK, trouble comes later...)

FX
Rainer Orth Nov. 4, 2010, 4:54 p.m. UTC | #3
FX <fxcoudert@gmail.com> writes:

> Tested as indicated below, OK to commit? (needs a global reviewer; pretty pretty please, don't let it bitrot again)  I'd like to highlight that it's nothing conceptualy major, and it'll be easy to fix any eventual fallout.

The Tru64 UNIX, Solaris 2, and IRIX parts still look good.

Thanks.
	Rainer
Jerry DeLisle Nov. 6, 2010, 12:02 a.m. UTC | #4
On 11/03/2010 02:26 PM, FX wrote:
> See below for the description of the patch; this take n+1 incorporates suggestions by Michael Meissner and Rainer Orth, with the following exceptions:
>
>    -- As avr.c includes new headers (cpplib.h and cppbuiltin.h), I wanted to update its dependencies in the target configuration file (t-avr), but to my surprise, this file doesn't contain any mention of avr.o. In fact, I failed to find any by grepping the whole tree, so I'm a little unsure how this can work (and apparently it does). Could the maintainers help me here?
>
>    -- Michael is worried about splitting all this stuff:
>
>>> Unless I don't see what you're talking about, this is not possible: the Fortran front-end is not linked with the *-c.c files, only with *.c, so the language-independent functions need to be moved there.
>>
>> Yes, but if fortran is going to use the preprocessor, maybe they should be
>> linked in.  I'm just worried about the possibility of a macro getting lost in
>> the movement.
>
>
> Well, we do need some separation between CPP built-in macros that are only relevant for C-family languages (for example, because they depend on flag variables that are only declared for C) and the others. Now that the job is done, was discussed beforehand, and it fixes the regression experienced by Fortran, I'd be glad to just have it work.
>
>
> Tested as indicated below, OK to commit? (needs a global reviewer; pretty pretty please, don't let it bitrot again)  I'd like to highlight that it's nothing conceptualy major, and it'll be easy to fix any eventual fallout.
>
> FX

I have reviewed this patch and I have to agree with FX.  There is nothing here 
that makes these workings more obfuscated then they already are and I think the 
splitting actually makes it easier to understand, ie less obfuscated. 
Considering the lessor evil and that it passes testing, and I would like to 
encourage this patch be approved.

I would like to see specific comments as to why not if not, so we can close on this.

Regards,

Jerry
diff mbox

Patch

Index: gcc/c-family/c-common.h
===================================================================
--- gcc/c-family/c-common.h	(revision 166272)
+++ gcc/c-family/c-common.h	(working copy)
@@ -964,7 +964,6 @@  extern void c_common_print_pch_checksum 
 extern const unsigned char executable_checksum[16];
 
 /* In c-cppbuiltin.c  */
-extern void builtin_define_std (const char *macro);
 extern void builtin_define_with_value (const char *, const char *, int);
 extern void c_stddef_cpp_builtins (void);
 extern void fe_file_change (const struct line_map *);
Index: gcc/c-family/c-cppbuiltin.c
===================================================================
--- gcc/c-family/c-cppbuiltin.c	(revision 166272)
+++ gcc/c-family/c-cppbuiltin.c	(working copy)
@@ -35,12 +35,12 @@  along with GCC; see the file COPYING3.  
 #include "cpp-id-data.h"
 #include "cppbuiltin.h"
 
-#ifndef TARGET_OS_CPP_BUILTINS
-# define TARGET_OS_CPP_BUILTINS()
+#ifndef TARGET_OS_CPP_BUILTINS_CFAMILY
+# define TARGET_OS_CPP_BUILTINS_CFAMILY()
 #endif
 
-#ifndef TARGET_OBJFMT_CPP_BUILTINS
-# define TARGET_OBJFMT_CPP_BUILTINS()
+#ifndef TARGET_CPU_CPP_BUILTINS_CFAMILY
+# define TARGET_CPU_CPP_BUILTINS_CFAMILY()
 #endif
 
 #ifndef REGISTER_PREFIX
@@ -48,7 +48,6 @@  along with GCC; see the file COPYING3.  
 #endif
 
 /* Non-static as some targets don't use it.  */
-void builtin_define_std (const char *) ATTRIBUTE_UNUSED;
 static void builtin_define_with_int_value (const char *, HOST_WIDE_INT);
 static void builtin_define_with_hex_fp_value (const char *, tree,
 					      int, const char *,
@@ -576,7 +575,8 @@  c_cpp_builtins (cpp_reader *pfile)
   if (flag_undef)
     return;
 
-  define_language_independent_builtin_macros (pfile);
+  /* Language-independent builtins.  */
+  define_language_independent_builtin_macros (pfile, flag_iso);
 
   if (c_dialect_cxx ())
   {
@@ -813,9 +813,11 @@  c_cpp_builtins (cpp_reader *pfile)
 # define preprocessing_trad_p() (cpp_get_options (pfile)->traditional)
 # define builtin_define(TXT) cpp_define (pfile, TXT)
 # define builtin_assert(TXT) cpp_assert (pfile, TXT)
-  TARGET_CPU_CPP_BUILTINS ();
-  TARGET_OS_CPP_BUILTINS ();
-  TARGET_OBJFMT_CPP_BUILTINS ();
+# define builtin_define_std(TXT) \
+    define_builtin_macro_std (pfile, TXT, flag_iso)
+
+  TARGET_OS_CPP_BUILTINS_CFAMILY ();
+  TARGET_CPU_CPP_BUILTINS_CFAMILY ();
 
   /* Support the __declspec keyword by turning them into attributes.
      Note that the current way we do this may result in a collision
@@ -833,50 +835,6 @@  c_cpp_builtins (cpp_reader *pfile)
     cpp_define (pfile, "__DECIMAL_BID_FORMAT__");
 }
 
-/* Pass an object-like macro.  If it doesn't lie in the user's
-   namespace, defines it unconditionally.  Otherwise define a version
-   with two leading underscores, and another version with two leading
-   and trailing underscores, and define the original only if an ISO
-   standard was not nominated.
-
-   e.g. passing "unix" defines "__unix", "__unix__" and possibly
-   "unix".  Passing "_mips" defines "__mips", "__mips__" and possibly
-   "_mips".  */
-void
-builtin_define_std (const char *macro)
-{
-  size_t len = strlen (macro);
-  char *buff = (char *) alloca (len + 5);
-  char *p = buff + 2;
-  char *q = p + len;
-
-  /* prepend __ (or maybe just _) if in user's namespace.  */
-  memcpy (p, macro, len + 1);
-  if (!( *p == '_' && (p[1] == '_' || ISUPPER (p[1]))))
-    {
-      if (*p != '_')
-	*--p = '_';
-      if (p[1] != '_')
-	*--p = '_';
-    }
-  cpp_define (parse_in, p);
-
-  /* If it was in user's namespace...  */
-  if (p != buff + 2)
-    {
-      /* Define the macro with leading and following __.  */
-      if (q[-1] != '_')
-	*q++ = '_';
-      if (q[-2] != '_')
-	*q++ = '_';
-      *q = '\0';
-      cpp_define (parse_in, p);
-
-      /* Finally, define the original macro if permitted.  */
-      if (!flag_iso)
-	cpp_define (parse_in, macro);
-    }
-}
 
 /* Pass an object-like macro and a value to define it to.  The third
    parameter says whether or not to turn the value into a string
Index: gcc/cppbuiltin.c
===================================================================
--- gcc/cppbuiltin.c	(revision 166272)
+++ gcc/cppbuiltin.c	(working copy)
@@ -27,6 +27,9 @@  along with GCC; see the file COPYING3.  
 #include "flags.h"
 #include "toplev.h"
 #include "cpp-id-data.h"
+#include "output.h"
+#include "tm_p.h"		/* For TARGET_CPU_CPP_BUILTINS & friends.  */
+#include "target.h"
 #include "cppbuiltin.h"
 
 
@@ -163,13 +166,99 @@  define_builtin_macros_for_type_sizes (cp
 }
 
 
+/* Define target-specific built-in CPP macros.  */
+static void
+define_target_specific_builtins (cpp_reader *pfile, bool iso_c)
+{
+
+#ifndef TARGET_OBJFMT_CPP_BUILTINS
+# define TARGET_OBJFMT_CPP_BUILTINS()
+#endif
+
+#ifndef TARGET_CPU_CPP_BUILTINS
+# define TARGET_CPU_CPP_BUILTINS()
+#endif
+
+#ifndef TARGET_OS_CPP_BUILTINS
+# define TARGET_OS_CPP_BUILTINS()
+#endif
+
+#define builtin_define(TXT) cpp_define (pfile, TXT)
+#define builtin_assert(TXT) cpp_assert (pfile, TXT)
+#define builtin_define_with_value(NAME, VALUE, IS_STR) \
+  cpp_define_formatted (pfile, IS_STR ? NAME"=%s" : NAME"=\"%s\"", VALUE)
+#define builtin_define_with_int_value(NAME, VALUE) \
+  cpp_define_formatted (pfile, NAME"="HOST_WIDE_INT_PRINT_DEC, VALUE)
+#define builtin_define_std(TXT) \
+  define_builtin_macro_std (pfile, TXT, iso_c)
+
+  TARGET_OBJFMT_CPP_BUILTINS ();
+  TARGET_CPU_CPP_BUILTINS ();
+  TARGET_OS_CPP_BUILTINS ();
+
+#undef builtin_define
+#undef builtin_assert
+#undef builtin_define_with_value
+#undef builtin_define_with_int_value
+#undef builtin_define_std
+
+}
+
+
 /* Define macros builtins common to all language performing CPP
    preprocessing.  */
 void
-define_language_independent_builtin_macros (cpp_reader *pfile)
+define_language_independent_builtin_macros (cpp_reader *pfile, bool iso_c)
 {
   define__GNUC__ (pfile);
   define_builtin_macros_for_compilation_flags (pfile);
   define_builtin_macros_for_lp64 (pfile);
   define_builtin_macros_for_type_sizes (pfile);
+  define_target_specific_builtins (pfile, iso_c);
+}
+
+
+/* Pass an object-like macro.  If it doesn't lie in the user's
+   namespace, defines it unconditionally.  Otherwise define a version
+   with two leading underscores, and another version with two leading
+   and trailing underscores, and define the original only if an ISO
+   standard was not nominated.
+
+   e.g. passing "unix" defines "__unix", "__unix__" and possibly
+   "unix".  Passing "_mips" defines "__mips", "__mips__" and possibly
+   "_mips".  */
+void
+define_builtin_macro_std (cpp_reader *pfile, const char *macro, bool iso_c)
+{
+  size_t len = strlen (macro);
+  char *buff = (char *) alloca (len + 5);
+  char *p = buff + 2;
+  char *q = p + len;
+
+  /* prepend __ (or maybe just _) if in user's namespace.  */
+  memcpy (p, macro, len + 1);
+  if (!( *p == '_' && (p[1] == '_' || ISUPPER (p[1]))))
+    {
+      if (*p != '_')
+	*--p = '_';
+      if (p[1] != '_')
+	*--p = '_';
+    }
+  cpp_define (pfile, p);
+
+  /* If it was in user's namespace...  */
+  if (p != buff + 2)
+    {
+      /* Define the macro with leading and following __.  */
+      if (q[-1] != '_')
+	*q++ = '_';
+      if (q[-2] != '_')
+	*q++ = '_';
+      *q = '\0';
+      cpp_define (pfile, p);
+
+      /* Finally, define the original macro if permitted.  */
+      if (iso_c)
+	cpp_define (pfile, macro);
+    }
 }
Index: gcc/cppbuiltin.h
===================================================================
--- gcc/cppbuiltin.h	(revision 166272)
+++ gcc/cppbuiltin.h	(working copy)
@@ -28,9 +28,13 @@  along with GCC; see the file COPYING3.  
    or "major.minor" to extract its components.  */
 extern void parse_basever (int *, int *, int *);
 
-/* Define macros builtins common to all language performing CPP
+/* Define built-in macros common to all language performing CPP
    preprocessing.  */
-extern void define_language_independent_builtin_macros (cpp_reader *);
+extern void define_language_independent_builtin_macros (cpp_reader *, bool);
+
+/* Define a built-in macro, and possible prevent it from polluting the
+   user's namespace.  */
+extern void define_builtin_macro_std (cpp_reader *, const char *, bool);
 
 
 #endif /* ! GCC_CPPBUILTIN_H */
Index: gcc/fortran/cpp.c
===================================================================
--- gcc/fortran/cpp.c	(revision 166272)
+++ gcc/fortran/cpp.c	(working copy)
@@ -38,18 +38,6 @@  along with GCC; see the file COPYING3.  
 #include "cppbuiltin.h"
 #include "mkdeps.h"
 
-#ifndef TARGET_CPU_CPP_BUILTINS
-# define TARGET_CPU_CPP_BUILTINS()
-#endif
-
-#ifndef TARGET_OS_CPP_BUILTINS
-# define TARGET_OS_CPP_BUILTINS()
-#endif
-
-#ifndef TARGET_OBJFMT_CPP_BUILTINS
-# define TARGET_OBJFMT_CPP_BUILTINS()
-#endif
-
 
 /* Holds switches parsed by gfc_cpp_handle_option (), but whose
    handling is deferred to gfc_cpp_init ().  */
@@ -167,40 +155,12 @@  cpp_define_builtins (cpp_reader *pfile)
 
   /* Initialize GFORTRAN specific builtins.
      These are documented.  */
-  define_language_independent_builtin_macros (pfile);
+  define_language_independent_builtin_macros (pfile, false);
   cpp_define (pfile, "__GFORTRAN__=1");
   cpp_define (pfile, "_LANGUAGE_FORTRAN=1");
 
   if (gfc_option.gfc_flag_openmp)
     cpp_define (pfile, "_OPENMP=200805");
-
-  /* The defines below are necessary for the TARGET_* macros.
-
-     FIXME:  Note that builtin_define_std() actually is a function
-     in c-cppbuiltin.c which uses flags undefined for Fortran.
-     Let's skip this for now. If needed, one needs to look into it
-     once more.  */
-
-# define builtin_define(TXT) cpp_define (pfile, TXT)
-# define builtin_define_std(TXT)
-# define builtin_assert(TXT) cpp_assert (pfile, TXT)
-
-  /* FIXME: Pandora's Box
-    Using the macros below results in multiple breakages:
-     - mingw will fail to compile this file as dependent macros
-       assume to be used in c-cppbuiltin.c only. Further, they use
-       flags only valid/defined in C (same as noted above).
-       [config/i386/mingw32.h, config/i386/cygming.h]
-     - other platforms (not as popular) break similarly
-       [grep for 'builtin_define_with_int_value' in gcc/config/]
-
-  TARGET_CPU_CPP_BUILTINS ();
-  TARGET_OS_CPP_BUILTINS ();
-  TARGET_OBJFMT_CPP_BUILTINS (); */
-
-#undef builtin_define
-#undef builtin_define_std
-#undef builtin_assert
 }
 
 bool
Index: gcc/doc/tm.texi.in
===================================================================
--- gcc/doc/tm.texi.in	(revision 166272)
+++ gcc/doc/tm.texi.in	(working copy)
@@ -645,7 +645,10 @@  the functions @code{builtin_define}, @co
 @code{builtin_assert}.  When the front end
 calls this macro it provides a trailing semicolon, and since it has
 finished command line option processing your code can use those
-results freely.
+results freely.  This macro, however, will be used by all front-end using
+CPP for preprocessing, and should only depend on language-independent
+command line option flags (see @code{TARGET_CPU_CPP_BUILTINS_CFAMILY} for
+C-specific preprocessor macros).
 
 @code{builtin_assert} takes a string in the form you pass to the
 command-line option @option{-A}, such as @code{cpu=mips}, and creates
@@ -657,7 +660,8 @@  object-like macro.  If it doesn't lie in
 @code{builtin_define_std} defines it unconditionally.  Otherwise, it
 defines a version with two leading underscores, and another version
 with two leading and trailing underscores, and defines the original
-only if an ISO standard was not requested on the command line.  For
+only if an ISO C standard was not requested on the command line (or if
+we're preprocessing for a language outside the C family).  For
 example, passing @code{unix} defines @code{__unix}, @code{__unix__}
 and possibly @code{unix}; passing @code{_mips} defines @code{__mips},
 @code{__mips__} and possibly @code{_mips}, and passing @code{_ABI64}
@@ -674,11 +678,21 @@  variable @code{flag_iso} can be used.  T
 preprocessing.
 @end defmac
 
+@defmac TARGET_CPU_CPP_BUILTINS_CFAMILY ()
+Similarly to @code{TARGET_CPU_CPP_BUILTINS} but this macro is optional
+and will only be called when compiling languages of the C family.
+@end defmac
+
 @defmac TARGET_OS_CPP_BUILTINS ()
 Similarly to @code{TARGET_CPU_CPP_BUILTINS} but this macro is optional
 and is used for the target operating system instead.
 @end defmac
 
+@defmac TARGET_OS_CPP_BUILTINS_CFAMILY ()
+Similarly to @code{TARGET_OS_CPP_BUILTINS} but this macro is optional
+and will only be called when compiling languages of the C family.
+@end defmac
+
 @defmac TARGET_OBJFMT_CPP_BUILTINS ()
 Similarly to @code{TARGET_CPU_CPP_BUILTINS} but this macro is optional
 and is used for the target object format.  @file{elfos.h} uses this
Index: gcc/config/alpha/linux.h
===================================================================
--- gcc/config/alpha/linux.h	(revision 166272)
+++ gcc/config/alpha/linux.h	(working copy)
@@ -32,6 +32,10 @@  along with GCC; see the file COPYING3.  
 	builtin_assert ("system=linux");			\
 	builtin_assert ("system=unix");				\
 	builtin_assert ("system=posix");			\
+    } while (0)
+
+#define TARGET_OS_CPP_BUILTINS_CFAMILY()			\
+    do {							\
 	/* The GNU C++ standard library requires this.  */	\
 	if (c_dialect_cxx ())					\
 	  builtin_define ("_GNU_SOURCE");			\
Index: gcc/config/alpha/alpha.h
===================================================================
--- gcc/config/alpha/alpha.h	(revision 166272)
+++ gcc/config/alpha/alpha.h	(working copy)
@@ -69,13 +69,11 @@  along with GCC; see the file COPYING3.  
 	  builtin_define ("_IEEE_FP_INEXACT");		\
 	if (TARGET_LONG_DOUBLE_128)			\
 	  builtin_define ("__LONG_DOUBLE_128__");	\
-							\
-	/* Macros dependent on the C dialect.  */	\
-	SUBTARGET_LANGUAGE_CPP_BUILTINS();		\
 } while (0)
 
-#ifndef SUBTARGET_LANGUAGE_CPP_BUILTINS
-#define SUBTARGET_LANGUAGE_CPP_BUILTINS()		\
+/* Macros dependent on the C dialect.  */
+#ifndef TARGET_CPU_CPP_BUILTINS_CFAMILY
+#define TARGET_CPU_CPP_BUILTINS_CFAMILY()		\
   do							\
     {							\
       if (preprocessing_asm_p ())			\
Index: gcc/config/alpha/osf5.h
===================================================================
--- gcc/config/alpha/osf5.h	(revision 166272)
+++ gcc/config/alpha/osf5.h	(working copy)
@@ -63,7 +63,10 @@  along with GCC; see the file COPYING3.  
 	   to be defined for <math.h>.  */		\
         if (LONG_DOUBLE_TYPE_SIZE == 128)		\
           builtin_define ("__X_FLOAT");			\
-							\
+    } while (0)
+
+#define TARGET_OS_CPP_BUILTINS_CFAMILY()		\
+    do {						\
 	/* Tru64 UNIX V4/V5 provide several ISO C94	\
 	   features protected by the corresponding	\
 	   __STDC_VERSION__ macro.  libstdc++ v3	\
Index: gcc/config/alpha/netbsd.h
===================================================================
--- gcc/config/alpha/netbsd.h	(revision 166272)
+++ gcc/config/alpha/netbsd.h	(working copy)
@@ -29,8 +29,8 @@  along with GCC; see the file COPYING3.  
 
 
 /* NetBSD doesn't use the LANGUAGE* built-ins.  */
-#undef SUBTARGET_LANGUAGE_CPP_BUILTINS
-#define SUBTARGET_LANGUAGE_CPP_BUILTINS()	/* nothing */
+#undef TARGET_CPU_CPP_BUILTINS_CFAMILY
+#define TARGET_CPU_CPP_BUILTINS_CFAMILY()	/* nothing */
 
 
 /* Show that we need a GP when profiling.  */
Index: gcc/config/t-darwin
===================================================================
--- gcc/config/t-darwin	(revision 166272)
+++ gcc/config/t-darwin	(working copy)
@@ -21,7 +21,7 @@  darwin.o: $(srcdir)/config/darwin.c $(CO
   $(TM_H) $(RTL_H) $(REGS_H) hard-reg-set.h $(REAL_H) insn-config.h         \
   conditions.h insn-flags.h output.h insn-attr.h flags.h $(TREE_H) expr.h   \
   reload.h function.h $(GGC_H) langhooks.h $(TARGET_H) $(TM_P_H) gt-darwin.h \
-  c-tree.h c-lang.h config/darwin-sections.def
+  c-tree.h c-lang.h config/darwin-sections.def $(CPPLIB_H) cppbuiltin.h
 	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
 		$(srcdir)/config/darwin.c
 
Index: gcc/config/frv/frv.h
===================================================================
--- gcc/config/frv/frv.h	(revision 166272)
+++ gcc/config/frv/frv.h	(working copy)
@@ -235,6 +235,13 @@ 
 	builtin_define ("__FRV_DWORD__");				\
       if (TARGET_FDPIC)							\
 	builtin_define ("__FRV_FDPIC__");				\
+    }									\
+  while (0)
+
+/* Builtins for C languages.  */
+#define TARGET_CPU_CPP_BUILTINS_CFAMILY()				\
+  do									\
+    {									\
       if (flag_leading_underscore > 0)					\
 	builtin_define ("__FRV_UNDERSCORE__");				\
     }									\
Index: gcc/config/spu/spu-protos.h
===================================================================
--- gcc/config/spu/spu-protos.h	(revision 166272)
+++ gcc/config/spu/spu-protos.h	(working copy)
@@ -19,6 +19,7 @@ 
 #define _SPU_PROTOS_
 
 extern void spu_cpu_cpp_builtins (struct cpp_reader * pfile);
+extern void spu_cpu_cpp_builtins_cfamily (struct cpp_reader * pfile);
 extern void builtin_define_std (const char *);
 extern void spu_c_common_override_options (void);
 extern int valid_subreg (rtx op);
Index: gcc/config/spu/spu-c.c
===================================================================
--- gcc/config/spu/spu-c.c	(revision 166272)
+++ gcc/config/spu/spu-c.c	(working copy)
@@ -186,25 +186,9 @@  spu_resolve_overloaded_builtin (location
 
 
 void
-spu_cpu_cpp_builtins (struct cpp_reader *pfile)
+spu_cpu_cpp_builtins_cfamily (struct cpp_reader *pfile)
 {
-  cpp_define (pfile, "__SPU__");
-  cpp_assert (pfile, "cpu=spu");
-  cpp_assert (pfile, "machine=spu");
-  if (spu_arch == PROCESSOR_CELLEDP)
-    cpp_define (pfile, "__SPU_EDP__");
   cpp_define (pfile, "__vector=__attribute__((__spu_vector__))");
-  switch (spu_ea_model)
-    {
-    case 32:
-      cpp_define (pfile, "__EA32__");
-      break;
-    case 64:
-      cpp_define (pfile, "__EA64__");
-      break;
-    default:
-       gcc_unreachable ();
-    }
 
   if (!flag_iso)
     {
Index: gcc/config/spu/spu.c
===================================================================
--- gcc/config/spu/spu.c	(revision 166272)
+++ gcc/config/spu/spu.c	(working copy)
@@ -7117,4 +7117,25 @@  spu_function_profiler (FILE * file, int 
   fprintf (file, "brsl $75,  _mcount\n");
 }
 
+void
+spu_cpu_cpp_builtins (struct cpp_reader *pfile)
+{
+  cpp_define (pfile, "__SPU__");
+  cpp_assert (pfile, "cpu=spu");
+  cpp_assert (pfile, "machine=spu");
+  if (spu_arch == PROCESSOR_CELLEDP)
+    cpp_define (pfile, "__SPU_EDP__");
+  switch (spu_ea_model)
+    {
+    case 32:
+      cpp_define (pfile, "__EA32__");
+      break;
+    case 64:
+      cpp_define (pfile, "__EA64__");
+      break;
+    default:
+       gcc_unreachable ();
+    }
+}
+
 #include "gt-spu.h"
Index: gcc/config/spu/spu.h
===================================================================
--- gcc/config/spu/spu.h	(revision 166272)
+++ gcc/config/spu/spu.h	(working copy)
@@ -16,7 +16,8 @@ 
 
 
 /* Run-time Target */
-#define TARGET_CPU_CPP_BUILTINS()	spu_cpu_cpp_builtins(pfile)
+#define TARGET_CPU_CPP_BUILTINS()          spu_cpu_cpp_builtins(pfile)
+#define TARGET_CPU_CPP_BUILTINS_CFAMILY()  spu_cpu_cpp_builtins_cfamily(pfile)
 
 #define TARGET_VERSION fprintf (stderr, " (spu %s)", __DATE__);
 
Index: gcc/config/darwin-c.c
===================================================================
--- gcc/config/darwin-c.c	(revision 166272)
+++ gcc/config/darwin-c.c	(working copy)
@@ -568,51 +568,14 @@  find_subframework_header (cpp_reader *pf
   return 0;
 }
 
-/* Return the value of darwin_macosx_version_min suitable for the
-   __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ macro,
-   so '10.4.2' becomes 1040.  The lowest digit is always zero.
-   Print a warning if the version number can't be understood.  */
-static const char *
-version_as_macro (void)
-{
-  static char result[] = "1000";
-
-  if (strncmp (darwin_macosx_version_min, "10.", 3) != 0)
-    goto fail;
-  if (! ISDIGIT (darwin_macosx_version_min[3]))
-    goto fail;
-  result[2] = darwin_macosx_version_min[3];
-  if (darwin_macosx_version_min[4] != '\0'
-      && darwin_macosx_version_min[4] != '.')
-    goto fail;
-
-  return result;
-
- fail:
-  error ("Unknown value %qs of -mmacosx-version-min",
-	 darwin_macosx_version_min);
-  return "1000";
-}
 
 /* Define additional CPP flags for Darwin.   */
 
-#define builtin_define(TXT) cpp_define (pfile, TXT)
-
 void
-darwin_cpp_builtins (cpp_reader *pfile)
+darwin_cpp_builtins_cfamily (cpp_reader *pfile)
 {
-  builtin_define ("__MACH__");
-  builtin_define ("__APPLE__");
-
-  /* __APPLE_CC__ is defined as some old Apple include files expect it
-     to be defined and won't work if it isn't.  */
-  builtin_define_with_value ("__APPLE_CC__", "1", false);
-
   if (darwin_constant_cfstrings)
-    builtin_define ("__CONSTANT_CFSTRINGS__");
-
-  builtin_define_with_value ("__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__",
-			     version_as_macro(), false);
+    cpp_define (pfile, "__CONSTANT_CFSTRINGS__");
 
   /* Since we do not (at 4.6) support ObjC gc for the NeXT runtime, the
      following will cause a syntax error if one tries to compile gc attributed
@@ -620,14 +583,14 @@  darwin_cpp_builtins (cpp_reader *pfile)
      properly (on systems >= darwin 9).  */
   if (flag_objc_gc)
     {
-      builtin_define ("__strong=__attribute__((objc_gc(strong)))");
-      builtin_define ("__weak=__attribute__((objc_gc(weak)))");
-      builtin_define ("__OBJC_GC__");
+      cpp_define (pfile, "__strong=__attribute__((objc_gc(strong)))");
+      cpp_define (pfile, "__weak=__attribute__((objc_gc(weak)))");
+      cpp_define (pfile, "__OBJC_GC__");
     }
   else
     {
-      builtin_define ("__strong=");
-      builtin_define ("__weak=");
+      cpp_define (pfile, "__strong=");
+      cpp_define (pfile, "__weak=");
     }
 }
 
Index: gcc/config/i386/i386.h
===================================================================
--- gcc/config/i386/i386.h	(revision 166272)
+++ gcc/config/i386/i386.h	(working copy)
@@ -563,7 +563,7 @@  extern const char *host_detect_local_cpu
 #endif
 
 /* Target CPU builtins.  */
-#define TARGET_CPU_CPP_BUILTINS() ix86_target_macros ()
+#define TARGET_CPU_CPP_BUILTINS() ix86_target_macros (pfile, iso_c)
 
 /* Target Pragmas.  */
 #define REGISTER_TARGET_PRAGMAS() ix86_register_pragmas ()
Index: gcc/config/i386/cygming.h
===================================================================
--- gcc/config/i386/cygming.h	(revision 166272)
+++ gcc/config/i386/cygming.h	(working copy)
@@ -124,6 +124,17 @@  along with GCC; see the file COPYING3.  
 	if (TARGET_SEH)							\
 	  builtin_define ("__SEH__");				\
 	builtin_assert ("system=winnt");				\
+	/* Even though linkonce works with static libs, this is needed 	\
+	    to compare typeinfo symbols across dll boundaries.  */	\
+	builtin_define ("__GXX_MERGED_TYPEINFO_NAMES=0");		\
+	builtin_define ("__GXX_TYPEINFO_EQUALITY_INLINE=0");		\
+	EXTRA_OS_CPP_BUILTINS ();					\
+  }									\
+  while (0)
+
+#define TARGET_OS_CPP_BUILTINS_CFAMILY()				\
+  do									\
+    {									\
 	builtin_define ("__stdcall=__attribute__((__stdcall__))");	\
 	builtin_define ("__fastcall=__attribute__((__fastcall__))");	\
 	builtin_define ("__thiscall=__attribute__((__thiscall__))");	\
@@ -135,12 +146,8 @@  along with GCC; see the file COPYING3.  
 	    builtin_define ("_thiscall=__attribute__((__thiscall__))");	\
 	    builtin_define ("_cdecl=__attribute__((__cdecl__))");	\
 	  }								\
-	/* Even though linkonce works with static libs, this is needed 	\
-	    to compare typeinfo symbols across dll boundaries.  */	\
-	builtin_define ("__GXX_MERGED_TYPEINFO_NAMES=0");		\
-	builtin_define ("__GXX_TYPEINFO_EQUALITY_INLINE=0");		\
-	EXTRA_OS_CPP_BUILTINS ();					\
-  }									\
+	EXTRA_OS_CPP_BUILTINS_CFAMILY ();				\
+    }									\
   while (0)
 
 /* Get tree.c to declare a target-specific specialization of
Index: gcc/config/i386/cygwin.h
===================================================================
--- gcc/config/i386/cygwin.h	(revision 166272)
+++ gcc/config/i386/cygwin.h	(working copy)
@@ -22,6 +22,7 @@  along with GCC; see the file COPYING3.  
 #define TARGET_VERSION fprintf (stderr, " (x86 Cygwin)");
 
 #define EXTRA_OS_CPP_BUILTINS()  /* Nothing.  */
+#define EXTRA_OS_CPP_BUILTINS_CFAMILY()  /* Nothing.  */
 
 #undef CPP_SPEC
 #define CPP_SPEC "%(cpp_cpu) %{posix:-D_POSIX_SOURCE} \
Index: gcc/config/i386/netware.h
===================================================================
--- gcc/config/i386/netware.h	(revision 166272)
+++ gcc/config/i386/netware.h	(working copy)
@@ -51,6 +51,12 @@  along with GCC; see the file COPYING3.  
 	builtin_define ("__netware__");					\
 	builtin_assert ("system=netware");				\
 	builtin_define ("__ELF__");					\
+    }									\
+  while (0)
+
+#define TARGET_OS_CPP_BUILTINS_CFAMILY()				\
+  do									\
+    {									\
 	builtin_define ("__cdecl=__attribute__((__cdecl__))");		\
 	builtin_define ("__stdcall=__attribute__((__stdcall__))");	\
 	builtin_define ("__fastcall=__attribute__((__fastcall__))");	\
Index: gcc/config/i386/i386-interix.h
===================================================================
--- gcc/config/i386/i386-interix.h	(revision 166272)
+++ gcc/config/i386/i386-interix.h	(working copy)
@@ -63,10 +63,16 @@  along with GCC; see the file COPYING3.  
 	builtin_define ("__OPENNT");					\
 	builtin_define ("_M_IX86=300");					\
 	builtin_define ("_X86_=1");					\
-	builtin_define ("__stdcall=__attribute__((__stdcall__))");	\
-	builtin_define ("__cdecl=__attribute__((__cdecl__))");		\
 	builtin_assert ("system=unix");					\
 	builtin_assert ("system=interix");				\
+    }									\
+  while (0)
+
+#define TARGET_OS_CPP_BUILTINS_CFAMILY()				\
+  do									\
+    {									\
+	builtin_define ("__stdcall=__attribute__((__stdcall__))");	\
+	builtin_define ("__cdecl=__attribute__((__cdecl__))");		\
 	if (preprocessing_asm_p ())					\
 	  builtin_define_std ("LANGUAGE_ASSEMBLY");			\
 	else								\
Index: gcc/config/i386/i386-c.c
===================================================================
--- gcc/config/i386/i386-c.c	(revision 166272)
+++ gcc/config/i386/i386-c.c	(working copy)
@@ -30,242 +30,10 @@  along with GCC; see the file COPYING3.  
 #include "target.h"
 #include "target-def.h"
 #include "cpplib.h"
+#include "cppbuiltin.h"
 #include "c-family/c-pragma.h"
 
 static bool ix86_pragma_target_parse (tree, tree);
-static void ix86_target_macros_internal
-  (int, enum processor_type, enum processor_type, enum fpmath_unit,
-   void (*def_or_undef) (cpp_reader *, const char *));
-
-
-/* Internal function to either define or undef the appropriate system
-   macros.  */
-static void
-ix86_target_macros_internal (int isa_flag,
-			     enum processor_type arch,
-			     enum processor_type tune,
-			     enum fpmath_unit fpmath,
-			     void (*def_or_undef) (cpp_reader *,
-						   const char *))
-{
-  /* For some of the k6/pentium varients there weren't seperate ISA bits to
-     identify which tune/arch flag was passed, so figure it out here.  */
-  size_t arch_len = strlen (ix86_arch_string);
-  size_t tune_len = strlen (ix86_tune_string);
-  int last_arch_char = ix86_arch_string[arch_len - 1];
-  int last_tune_char = ix86_tune_string[tune_len - 1];
-
-  /* Built-ins based on -march=.  */
-  switch (arch)
-    {
-    case PROCESSOR_I386:
-      break;
-    case PROCESSOR_I486:
-      def_or_undef (parse_in, "__i486");
-      def_or_undef (parse_in, "__i486__");
-      break;
-    case PROCESSOR_PENTIUM:
-      def_or_undef (parse_in, "__i586");
-      def_or_undef (parse_in, "__i586__");
-      def_or_undef (parse_in, "__pentium");
-      def_or_undef (parse_in, "__pentium__");
-      if (isa_flag & OPTION_MASK_ISA_MMX)
-	def_or_undef (parse_in, "__pentium_mmx__");
-      break;
-    case PROCESSOR_PENTIUMPRO:
-      def_or_undef (parse_in, "__i686");
-      def_or_undef (parse_in, "__i686__");
-      def_or_undef (parse_in, "__pentiumpro");
-      def_or_undef (parse_in, "__pentiumpro__");
-      break;
-    case PROCESSOR_GEODE:
-      def_or_undef (parse_in, "__geode");
-      def_or_undef (parse_in, "__geode__");
-      break;
-    case PROCESSOR_K6:
-      def_or_undef (parse_in, "__k6");
-      def_or_undef (parse_in, "__k6__");
-      if (last_arch_char == '2')
-	def_or_undef (parse_in, "__k6_2__");
-      else if (last_arch_char == '3')
-	def_or_undef (parse_in, "__k6_3__");
-      else if (isa_flag & OPTION_MASK_ISA_3DNOW)
-	def_or_undef (parse_in, "__k6_3__");
-      break;
-    case PROCESSOR_ATHLON:
-      def_or_undef (parse_in, "__athlon");
-      def_or_undef (parse_in, "__athlon__");
-      if (isa_flag & OPTION_MASK_ISA_SSE)
-	def_or_undef (parse_in, "__athlon_sse__");
-      break;
-    case PROCESSOR_K8:
-      def_or_undef (parse_in, "__k8");
-      def_or_undef (parse_in, "__k8__");
-      break;
-    case PROCESSOR_AMDFAM10:
-      def_or_undef (parse_in, "__amdfam10");
-      def_or_undef (parse_in, "__amdfam10__");
-      break;
-    case PROCESSOR_BDVER1:
-      def_or_undef (parse_in, "__bdver1");
-      def_or_undef (parse_in, "__bdver1__");
-      break;
-    case PROCESSOR_PENTIUM4:
-      def_or_undef (parse_in, "__pentium4");
-      def_or_undef (parse_in, "__pentium4__");
-      break;
-    case PROCESSOR_NOCONA:
-      def_or_undef (parse_in, "__nocona");
-      def_or_undef (parse_in, "__nocona__");
-      break;
-    case PROCESSOR_CORE2:
-      def_or_undef (parse_in, "__core2");
-      def_or_undef (parse_in, "__core2__");
-      break;
-    case PROCESSOR_COREI7_32:
-    case PROCESSOR_COREI7_64:
-      def_or_undef (parse_in, "__corei7");
-      def_or_undef (parse_in, "__corei7__");
-      break;
-    case PROCESSOR_ATOM:
-      def_or_undef (parse_in, "__atom");
-      def_or_undef (parse_in, "__atom__");
-      break;
-    /* use PROCESSOR_max to not set/unset the arch macro.  */
-    case PROCESSOR_max:
-      break;
-    case PROCESSOR_GENERIC32:
-    case PROCESSOR_GENERIC64:
-      gcc_unreachable ();
-    }
-
-  /* Built-ins based on -mtune=.  */
-  switch (tune)
-    {
-    case PROCESSOR_I386:
-      def_or_undef (parse_in, "__tune_i386__");
-      break;
-    case PROCESSOR_I486:
-      def_or_undef (parse_in, "__tune_i486__");
-      break;
-    case PROCESSOR_PENTIUM:
-      def_or_undef (parse_in, "__tune_i586__");
-      def_or_undef (parse_in, "__tune_pentium__");
-      if (last_tune_char == 'x')
-	def_or_undef (parse_in, "__tune_pentium_mmx__");
-      break;
-    case PROCESSOR_PENTIUMPRO:
-      def_or_undef (parse_in, "__tune_i686__");
-      def_or_undef (parse_in, "__tune_pentiumpro__");
-      switch (last_tune_char)
-	{
-	case '3':
-	  def_or_undef (parse_in, "__tune_pentium3__");
-	  /* FALLTHRU */
-	case '2':
-	  def_or_undef (parse_in, "__tune_pentium2__");
-	  break;
-	}
-      break;
-    case PROCESSOR_GEODE:
-      def_or_undef (parse_in, "__tune_geode__");
-      break;
-    case PROCESSOR_K6:
-      def_or_undef (parse_in, "__tune_k6__");
-      if (last_tune_char == '2')
-	def_or_undef (parse_in, "__tune_k6_2__");
-      else if (last_tune_char == '3')
-	def_or_undef (parse_in, "__tune_k6_3__");
-      else if (isa_flag & OPTION_MASK_ISA_3DNOW)
-	def_or_undef (parse_in, "__tune_k6_3__");
-      break;
-    case PROCESSOR_ATHLON:
-      def_or_undef (parse_in, "__tune_athlon__");
-      if (isa_flag & OPTION_MASK_ISA_SSE)
-	def_or_undef (parse_in, "__tune_athlon_sse__");
-      break;
-    case PROCESSOR_K8:
-      def_or_undef (parse_in, "__tune_k8__");
-      break;
-    case PROCESSOR_AMDFAM10:
-      def_or_undef (parse_in, "__tune_amdfam10__");
-      break;
-    case PROCESSOR_BDVER1:
-      def_or_undef (parse_in, "__tune_bdver1__");
-      break;
-    case PROCESSOR_PENTIUM4:
-      def_or_undef (parse_in, "__tune_pentium4__");
-      break;
-    case PROCESSOR_NOCONA:
-      def_or_undef (parse_in, "__tune_nocona__");
-      break;
-    case PROCESSOR_CORE2:
-      def_or_undef (parse_in, "__tune_core2__");
-      break;
-    case PROCESSOR_COREI7_32:
-    case PROCESSOR_COREI7_64:
-      def_or_undef (parse_in, "__tune_corei7__");
-      break;
-    case PROCESSOR_ATOM:
-      def_or_undef (parse_in, "__tune_atom__");
-      break;
-    case PROCESSOR_GENERIC32:
-    case PROCESSOR_GENERIC64:
-      break;
-    /* use PROCESSOR_max to not set/unset the tune macro.  */
-    case PROCESSOR_max:
-      break;
-    }
-
-  if (isa_flag & OPTION_MASK_ISA_MMX)
-    def_or_undef (parse_in, "__MMX__");
-  if (isa_flag & OPTION_MASK_ISA_3DNOW)
-    def_or_undef (parse_in, "__3dNOW__");
-  if (isa_flag & OPTION_MASK_ISA_3DNOW_A)
-    def_or_undef (parse_in, "__3dNOW_A__");
-  if (isa_flag & OPTION_MASK_ISA_SSE)
-    def_or_undef (parse_in, "__SSE__");
-  if (isa_flag & OPTION_MASK_ISA_SSE2)
-    def_or_undef (parse_in, "__SSE2__");
-  if (isa_flag & OPTION_MASK_ISA_SSE3)
-    def_or_undef (parse_in, "__SSE3__");
-  if (isa_flag & OPTION_MASK_ISA_SSSE3)
-    def_or_undef (parse_in, "__SSSE3__");
-  if (isa_flag & OPTION_MASK_ISA_SSE4_1)
-    def_or_undef (parse_in, "__SSE4_1__");
-  if (isa_flag & OPTION_MASK_ISA_SSE4_2)
-    def_or_undef (parse_in, "__SSE4_2__");
-  if (isa_flag & OPTION_MASK_ISA_AES)
-    def_or_undef (parse_in, "__AES__");
-  if (isa_flag & OPTION_MASK_ISA_PCLMUL)
-    def_or_undef (parse_in, "__PCLMUL__");
-  if (isa_flag & OPTION_MASK_ISA_AVX)
-    def_or_undef (parse_in, "__AVX__");
-  if (isa_flag & OPTION_MASK_ISA_FMA)
-    def_or_undef (parse_in, "__FMA__");
-  if (isa_flag & OPTION_MASK_ISA_SSE4A)
-    def_or_undef (parse_in, "__SSE4A__");
-  if (isa_flag & OPTION_MASK_ISA_FMA4)
-    def_or_undef (parse_in, "__FMA4__");
-  if (isa_flag & OPTION_MASK_ISA_XOP)
-    def_or_undef (parse_in, "__XOP__");
-  if (isa_flag & OPTION_MASK_ISA_LWP)
-    def_or_undef (parse_in, "__LWP__");
-  if (isa_flag & OPTION_MASK_ISA_ABM)
-    def_or_undef (parse_in, "__ABM__");
-  if (isa_flag & OPTION_MASK_ISA_POPCNT)
-    def_or_undef (parse_in, "__POPCNT__");
-  if (isa_flag & OPTION_MASK_ISA_FSGSBASE)
-    def_or_undef (parse_in, "__FSGSBASE__");
-  if (isa_flag & OPTION_MASK_ISA_RDRND)
-    def_or_undef (parse_in, "__RDRND__");
-  if (isa_flag & OPTION_MASK_ISA_F16C)
-    def_or_undef (parse_in, "__F16C__");
-  if ((fpmath & FPMATH_SSE) && (isa_flag & OPTION_MASK_ISA_SSE))
-    def_or_undef (parse_in, "__SSE_MATH__");
-  if ((fpmath & FPMATH_SSE) && (isa_flag & OPTION_MASK_ISA_SSE2))
-    def_or_undef (parse_in, "__SSE2_MATH__");
-}
 
 
 /* Hook to validate the current #pragma GCC target and set the state, and
@@ -328,6 +96,7 @@  ix86_pragma_target_parse (tree args, tre
 			       prev_arch,
 			       prev_tune,
 			       (enum fpmath_unit) prev_opt->fpmath,
+			       parse_in,
 			       cpp_undef);
 
   /* Define all of the macros for new options that were just turned on.  */
@@ -335,42 +104,12 @@  ix86_pragma_target_parse (tree args, tre
 			       cur_arch,
 			       cur_tune,
 			       (enum fpmath_unit) cur_opt->fpmath,
+			       parse_in,
 			       cpp_define);
 
   return true;
 }
 
-/* Function to tell the preprocessor about the defines for the current target.  */
-
-void
-ix86_target_macros (void)
-{
-  /* 32/64-bit won't change with target specific options, so do the assert and
-     builtin_define_std calls here.  */
-  if (TARGET_64BIT)
-    {
-      cpp_assert (parse_in, "cpu=x86_64");
-      cpp_assert (parse_in, "machine=x86_64");
-      cpp_define (parse_in, "__amd64");
-      cpp_define (parse_in, "__amd64__");
-      cpp_define (parse_in, "__x86_64");
-      cpp_define (parse_in, "__x86_64__");
-    }
-  else
-    {
-      cpp_assert (parse_in, "cpu=i386");
-      cpp_assert (parse_in, "machine=i386");
-      builtin_define_std ("i386");
-    }
-
-  ix86_target_macros_internal (ix86_isa_flags,
-			       ix86_arch,
-			       ix86_tune,
-			       ix86_fpmath,
-			       cpp_define);
-}
-
-
 /* Register target pragmas.  We need to add the hook for parsing #pragma GCC
    option here rather than in i386.c since it will pull in various preprocessor
    functions, and those are not present in languages like fortran without a
Index: gcc/config/i386/darwin.h
===================================================================
--- gcc/config/i386/darwin.h	(revision 166272)
+++ gcc/config/i386/darwin.h	(working copy)
@@ -54,6 +54,13 @@  along with GCC; see the file COPYING3.  
     }                                           \
   while (0)
 
+#define TARGET_OS_CPP_BUILTINS_CFAMILY()        \
+  do                                            \
+    {                                           \
+      darwin_cpp_builtins_cfamily (pfile);	\
+    }                                           \
+  while (0)
+
 #undef PTRDIFF_TYPE
 #define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
 
Index: gcc/config/i386/mingw32.h
===================================================================
--- gcc/config/i386/mingw32.h	(revision 166272)
+++ gcc/config/i386/mingw32.h	(working copy)
@@ -36,8 +36,6 @@  along with GCC; see the file COPYING3.  
       builtin_define ("_WIN32");				\
       builtin_define_std ("WIN32");				\
       builtin_define_std ("WINNT");				\
-      builtin_define_with_int_value ("_INTEGRAL_MAX_BITS",	\
-				     TYPE_PRECISION (intmax_type_node));\
       if (TARGET_64BIT && ix86_abi == MS_ABI)			\
 	{							\
 	  builtin_define ("__MINGW64__");			\
@@ -47,6 +45,15 @@  along with GCC; see the file COPYING3.  
     }								\
   while (0)
 
+#define EXTRA_OS_CPP_BUILTINS_CFAMILY()				\
+  do								\
+    {								\
+      builtin_define_with_int_value ("_INTEGRAL_MAX_BITS",	\
+				     TYPE_PRECISION (intmax_type_node));\
+    }								\
+  while (0)
+
+
 #undef SUB_LINK_ENTRY32
 #undef SUB_LINK_ENTRY64
 #define SUB_LINK_ENTRY32 "-e _DllMainCRTStartup@12"
Index: gcc/config/i386/t-i386
===================================================================
--- gcc/config/i386/t-i386	(revision 166272)
+++ gcc/config/i386/t-i386	(working copy)
@@ -23,12 +23,12 @@  i386.o: $(CONFIG_H) $(SYSTEM_H) coretype
   $(RECOG_H) $(EXPR_H) $(OPTABS_H) toplev.h $(BASIC_BLOCK_H) \
   $(GGC_H) $(TARGET_H) $(TARGET_DEF_H) langhooks.h $(CGRAPH_H) \
   $(TREE_GIMPLE_H) $(DWARF2_H) $(DF_H) tm-constrs.h $(PARAMS_H) \
-  i386-builtin-types.inc debug.h dwarf2out.h
+  i386-builtin-types.inc debug.h dwarf2out.h $(CPPLIB_H) cppbuiltin.h
 
 i386-c.o: $(srcdir)/config/i386/i386-c.c \
   $(srcdir)/config/i386/i386-protos.h $(CONFIG_H) $(SYSTEM_H) coretypes.h \
   $(TM_H) $(TREE_H) $(TM_P_H) $(FLAGS_H) $(C_COMMON_H) $(GGC_H) \
-  $(TARGET_H) $(TARGET_DEF_H) $(CPPLIB_H) $(C_PRAGMA_H)
+  $(TARGET_H) $(TARGET_DEF_H) $(CPPLIB_H) $(C_PRAGMA_H) cppbuiltin.h
 	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
 		$(srcdir)/config/i386/i386-c.c
 
Index: gcc/config/i386/i386-protos.h
===================================================================
--- gcc/config/i386/i386-protos.h	(revision 166272)
+++ gcc/config/i386/i386-protos.h	(working copy)
@@ -206,8 +206,13 @@  extern void ix86_expand_reduc_v4sf (rtx 
 
 extern void ix86_expand_vec_extract_even_odd (rtx, rtx, rtx, unsigned);
 
+extern void ix86_target_macros_internal
+  (int, enum processor_type, enum processor_type, enum fpmath_unit,
+   struct cpp_reader *,
+   void (*def_or_undef) (struct cpp_reader *, const char *));
+extern void ix86_target_macros (struct cpp_reader *, bool);
+
 /* In i386-c.c  */
-extern void ix86_target_macros (void);
 extern void ix86_register_pragmas (void);
 
 /* In winnt.c  */
Index: gcc/config/i386/i386.c
===================================================================
--- gcc/config/i386/i386.c	(revision 166272)
+++ gcc/config/i386/i386.c	(working copy)
@@ -56,6 +56,8 @@  along with GCC; see the file COPYING3.  
 #include "debug.h"
 #include "dwarf2out.h"
 #include "sched-int.h"
+#include "cpplib.h"
+#include "cppbuiltin.h"
 
 typedef struct block_info_def
 {
@@ -34170,6 +34172,261 @@  ix86_preferred_simd_mode (enum machine_m
   return word_mode;
 }
 
+
+/* Internal function to either define or undef the appropriate system
+   macros.  */
+void
+ix86_target_macros_internal (int isa_flag,
+			     enum processor_type arch,
+			     enum processor_type tune,
+			     enum fpmath_unit fpmath,
+			     cpp_reader *pfile,
+			     void (*def_or_undef) (cpp_reader *,
+						   const char *))
+{
+  /* For some of the k6/pentium varients there weren't seperate ISA bits to
+     identify which tune/arch flag was passed, so figure it out here.  */
+  size_t arch_len = strlen (ix86_arch_string);
+  size_t tune_len = strlen (ix86_tune_string);
+  int last_arch_char = ix86_arch_string[arch_len - 1];
+  int last_tune_char = ix86_tune_string[tune_len - 1];
+
+  /* Built-ins based on -march=.  */
+  switch (arch)
+    {
+    case PROCESSOR_I386:
+      break;
+    case PROCESSOR_I486:
+      def_or_undef (pfile, "__i486");
+      def_or_undef (pfile, "__i486__");
+      break;
+    case PROCESSOR_PENTIUM:
+      def_or_undef (pfile, "__i586");
+      def_or_undef (pfile, "__i586__");
+      def_or_undef (pfile, "__pentium");
+      def_or_undef (pfile, "__pentium__");
+      if (isa_flag & OPTION_MASK_ISA_MMX)
+	def_or_undef (pfile, "__pentium_mmx__");
+      break;
+    case PROCESSOR_PENTIUMPRO:
+      def_or_undef (pfile, "__i686");
+      def_or_undef (pfile, "__i686__");
+      def_or_undef (pfile, "__pentiumpro");
+      def_or_undef (pfile, "__pentiumpro__");
+      break;
+    case PROCESSOR_GEODE:
+      def_or_undef (pfile, "__geode");
+      def_or_undef (pfile, "__geode__");
+      break;
+    case PROCESSOR_K6:
+      def_or_undef (pfile, "__k6");
+      def_or_undef (pfile, "__k6__");
+      if (last_arch_char == '2')
+	def_or_undef (pfile, "__k6_2__");
+      else if (last_arch_char == '3')
+	def_or_undef (pfile, "__k6_3__");
+      else if (isa_flag & OPTION_MASK_ISA_3DNOW)
+	def_or_undef (pfile, "__k6_3__");
+      break;
+    case PROCESSOR_ATHLON:
+      def_or_undef (pfile, "__athlon");
+      def_or_undef (pfile, "__athlon__");
+      if (isa_flag & OPTION_MASK_ISA_SSE)
+	def_or_undef (pfile, "__athlon_sse__");
+      break;
+    case PROCESSOR_K8:
+      def_or_undef (pfile, "__k8");
+      def_or_undef (pfile, "__k8__");
+      break;
+    case PROCESSOR_AMDFAM10:
+      def_or_undef (pfile, "__amdfam10");
+      def_or_undef (pfile, "__amdfam10__");
+      break;
+    case PROCESSOR_BDVER1:
+      def_or_undef (pfile, "__bdver1");
+      def_or_undef (pfile, "__bdver1__");
+      break;
+    case PROCESSOR_PENTIUM4:
+      def_or_undef (pfile, "__pentium4");
+      def_or_undef (pfile, "__pentium4__");
+      break;
+    case PROCESSOR_NOCONA:
+      def_or_undef (pfile, "__nocona");
+      def_or_undef (pfile, "__nocona__");
+      break;
+    case PROCESSOR_CORE2:
+      def_or_undef (pfile, "__core2");
+      def_or_undef (pfile, "__core2__");
+      break;
+    case PROCESSOR_ATOM:
+      def_or_undef (pfile, "__atom");
+      def_or_undef (pfile, "__atom__");
+      break;
+    /* use PROCESSOR_max to not set/unset the arch macro.  */
+    case PROCESSOR_max:
+      break;
+    case PROCESSOR_GENERIC32:
+    case PROCESSOR_GENERIC64:
+      gcc_unreachable ();
+    }
+
+  /* Built-ins based on -mtune=.  */
+  switch (tune)
+    {
+    case PROCESSOR_I386:
+      def_or_undef (pfile, "__tune_i386__");
+      break;
+    case PROCESSOR_I486:
+      def_or_undef (pfile, "__tune_i486__");
+      break;
+    case PROCESSOR_PENTIUM:
+      def_or_undef (pfile, "__tune_i586__");
+      def_or_undef (pfile, "__tune_pentium__");
+      if (last_tune_char == 'x')
+	def_or_undef (pfile, "__tune_pentium_mmx__");
+      break;
+    case PROCESSOR_PENTIUMPRO:
+      def_or_undef (pfile, "__tune_i686__");
+      def_or_undef (pfile, "__tune_pentiumpro__");
+      switch (last_tune_char)
+	{
+	case '3':
+	  def_or_undef (pfile, "__tune_pentium3__");
+	  /* FALLTHRU */
+	case '2':
+	  def_or_undef (pfile, "__tune_pentium2__");
+	  break;
+	}
+      break;
+    case PROCESSOR_GEODE:
+      def_or_undef (pfile, "__tune_geode__");
+      break;
+    case PROCESSOR_K6:
+      def_or_undef (pfile, "__tune_k6__");
+      if (last_tune_char == '2')
+	def_or_undef (pfile, "__tune_k6_2__");
+      else if (last_tune_char == '3')
+	def_or_undef (pfile, "__tune_k6_3__");
+      else if (isa_flag & OPTION_MASK_ISA_3DNOW)
+	def_or_undef (pfile, "__tune_k6_3__");
+      break;
+    case PROCESSOR_ATHLON:
+      def_or_undef (pfile, "__tune_athlon__");
+      if (isa_flag & OPTION_MASK_ISA_SSE)
+	def_or_undef (pfile, "__tune_athlon_sse__");
+      break;
+    case PROCESSOR_K8:
+      def_or_undef (pfile, "__tune_k8__");
+      break;
+    case PROCESSOR_AMDFAM10:
+      def_or_undef (pfile, "__tune_amdfam10__");
+      break;
+    case PROCESSOR_BDVER1:
+      def_or_undef (pfile, "__tune_bdver1__");
+      break;
+    case PROCESSOR_PENTIUM4:
+      def_or_undef (pfile, "__tune_pentium4__");
+      break;
+    case PROCESSOR_NOCONA:
+      def_or_undef (pfile, "__tune_nocona__");
+      break;
+    case PROCESSOR_CORE2:
+      def_or_undef (pfile, "__tune_core2__");
+      break;
+    case PROCESSOR_ATOM:
+      def_or_undef (pfile, "__tune_atom__");
+      break;
+    case PROCESSOR_GENERIC32:
+    case PROCESSOR_GENERIC64:
+      break;
+    /* use PROCESSOR_max to not set/unset the tune macro.  */
+    case PROCESSOR_max:
+      break;
+    }
+
+  if (isa_flag & OPTION_MASK_ISA_MMX)
+    def_or_undef (pfile, "__MMX__");
+  if (isa_flag & OPTION_MASK_ISA_3DNOW)
+    def_or_undef (pfile, "__3dNOW__");
+  if (isa_flag & OPTION_MASK_ISA_3DNOW_A)
+    def_or_undef (pfile, "__3dNOW_A__");
+  if (isa_flag & OPTION_MASK_ISA_SSE)
+    def_or_undef (pfile, "__SSE__");
+  if (isa_flag & OPTION_MASK_ISA_SSE2)
+    def_or_undef (pfile, "__SSE2__");
+  if (isa_flag & OPTION_MASK_ISA_SSE3)
+    def_or_undef (pfile, "__SSE3__");
+  if (isa_flag & OPTION_MASK_ISA_SSSE3)
+    def_or_undef (pfile, "__SSSE3__");
+  if (isa_flag & OPTION_MASK_ISA_SSE4_1)
+    def_or_undef (pfile, "__SSE4_1__");
+  if (isa_flag & OPTION_MASK_ISA_SSE4_2)
+    def_or_undef (pfile, "__SSE4_2__");
+  if (isa_flag & OPTION_MASK_ISA_AES)
+    def_or_undef (pfile, "__AES__");
+  if (isa_flag & OPTION_MASK_ISA_PCLMUL)
+    def_or_undef (pfile, "__PCLMUL__");
+  if (isa_flag & OPTION_MASK_ISA_AVX)
+    def_or_undef (pfile, "__AVX__");
+  if (isa_flag & OPTION_MASK_ISA_FMA)
+    def_or_undef (pfile, "__FMA__");
+  if (isa_flag & OPTION_MASK_ISA_SSE4A)
+    def_or_undef (pfile, "__SSE4A__");
+  if (isa_flag & OPTION_MASK_ISA_FMA4)
+    def_or_undef (pfile, "__FMA4__");
+  if (isa_flag & OPTION_MASK_ISA_XOP)
+    def_or_undef (pfile, "__XOP__");
+  if (isa_flag & OPTION_MASK_ISA_LWP)
+    def_or_undef (pfile, "__LWP__");
+  if (isa_flag & OPTION_MASK_ISA_ABM)
+    def_or_undef (pfile, "__ABM__");
+  if (isa_flag & OPTION_MASK_ISA_POPCNT)
+    def_or_undef (pfile, "__POPCNT__");
+  if (isa_flag & OPTION_MASK_ISA_FSGSBASE)
+    def_or_undef (pfile, "__FSGSBASE__");
+  if (isa_flag & OPTION_MASK_ISA_RDRND)
+    def_or_undef (pfile, "__RDRND__");
+  if (isa_flag & OPTION_MASK_ISA_F16C)
+    def_or_undef (pfile, "__F16C__");
+  if ((fpmath & FPMATH_SSE) && (isa_flag & OPTION_MASK_ISA_SSE))
+    def_or_undef (pfile, "__SSE_MATH__");
+  if ((fpmath & FPMATH_SSE) && (isa_flag & OPTION_MASK_ISA_SSE2))
+    def_or_undef (pfile, "__SSE2_MATH__");
+}
+
+
+/* Function to tell the preprocessor about the defines for the current
+   target.  */
+void
+ix86_target_macros (cpp_reader *pfile, bool iso_c)
+{
+  /* 32/64-bit won't change with target specific options, so do the assert and
+     builtin_define_std calls here.  */
+  if (TARGET_64BIT)
+    {
+      cpp_assert (pfile, "cpu=x86_64");
+      cpp_assert (pfile, "machine=x86_64");
+      cpp_define (pfile, "__amd64");
+      cpp_define (pfile, "__amd64__");
+      cpp_define (pfile, "__x86_64");
+      cpp_define (pfile, "__x86_64__");
+    }
+  else
+    {
+      cpp_assert (pfile, "cpu=i386");
+      cpp_assert (pfile, "machine=i386");
+      define_builtin_macro_std (pfile, "i386", iso_c);
+    }
+
+  ix86_target_macros_internal (ix86_isa_flags,
+                               ix86_arch,
+                               ix86_tune,
+                               ix86_fpmath,
+                               pfile,
+                               cpp_define);
+}
+
+
 /* If AVX is enabled then try vectorizing with both 256bit and 128bit
    vectors.  */
 
Index: gcc/config/darwin-protos.h
===================================================================
--- gcc/config/darwin-protos.h	(revision 166272)
+++ gcc/config/darwin-protos.h	(working copy)
@@ -92,6 +92,7 @@  extern void darwin_asm_declare_constant_
 					      const_tree, HOST_WIDE_INT);
 extern bool darwin_binds_local_p (const_tree);
 extern void darwin_cpp_builtins (struct cpp_reader *);
+extern void darwin_cpp_builtins_cfamily (struct cpp_reader *);
 
 extern void darwin_init_cfstring_builtins (unsigned);
 extern tree darwin_fold_builtin (tree, int, tree *, bool);
Index: gcc/config/sol2.h
===================================================================
--- gcc/config/sol2.h	(revision 166272)
+++ gcc/config/sol2.h	(working copy)
@@ -94,6 +94,10 @@  along with GCC; see the file COPYING3.  
 	builtin_define ("__SVR4");			\
 	builtin_assert ("system=unix");			\
 	builtin_assert ("system=svr4");			\
+	TARGET_SUB_OS_CPP_BUILTINS();			\
+    } while (0)
+#define TARGET_OS_CPP_BUILTINS_CFAMILY()		\
+    do {						\
 	/* For C++ we need to add some additional macro	\
 	   definitions required by the C++ standard	\
 	   library.  */					\
@@ -105,7 +109,6 @@  along with GCC; see the file COPYING3.  
 	    builtin_define ("_LARGEFILE64_SOURCE=1");	\
 	    builtin_define ("__EXTENSIONS__");		\
 	  }						\
-	TARGET_SUB_OS_CPP_BUILTINS();			\
     } while (0)
 
 /* The system headers under Solaris 2 are C++-aware since 2.0.  */
Index: gcc/config/avr/avr-protos.h
===================================================================
--- gcc/config/avr/avr-protos.h	(revision 166272)
+++ gcc/config/avr/avr-protos.h	(working copy)
@@ -22,7 +22,7 @@ 
 
 
 extern int function_arg_regno_p (int r);
-extern void avr_cpu_cpp_builtins (struct cpp_reader * pfile);
+extern void avr_cpu_cpp_builtins (struct cpp_reader * pfile, bool iso_c);
 extern int avr_ret_register (void);
 extern enum reg_class avr_regno_reg_class (int r);
 extern void asm_globalize_label (FILE *file, const char *name);
Index: gcc/config/avr/avr.c
===================================================================
--- gcc/config/avr/avr.c	(revision 166272)
+++ gcc/config/avr/avr.c	(working copy)
@@ -45,6 +45,8 @@ 
 #include "target-def.h"
 #include "params.h"
 #include "df.h"
+#include "cpplib.h"
+#include "cppbuiltin.h"
 
 /* Maximal allowed offset for an address in the LD command */
 #define MAX_LD_OFFSET(MODE) (64 - (signed)GET_MODE_SIZE (MODE))
@@ -6157,4 +6159,58 @@  unsigned int avr_case_values_threshold (
   return (!AVR_HAVE_JMP_CALL || TARGET_CALL_PROLOGUES) ? 8 : 17;
 }
 
+
+/* Worker function for TARGET_CPU_CPP_BUILTINS.  */
+
+void
+avr_cpu_cpp_builtins (struct cpp_reader *pfile, bool iso_c)
+{
+  define_builtin_macro_std (pfile, "AVR", iso_c);
+
+  if (avr_current_arch->macro)
+    cpp_define (pfile, avr_current_arch->macro);
+  if (avr_extra_arch_macro)
+    cpp_define (pfile, avr_extra_arch_macro);
+  if (avr_current_arch->have_elpm)
+    cpp_define (pfile, "__AVR_HAVE_RAMPZ__");
+  if (avr_current_arch->have_elpm)
+    cpp_define (pfile, "__AVR_HAVE_ELPM__");
+  if (avr_current_arch->have_elpmx)
+    cpp_define (pfile, "__AVR_HAVE_ELPMX__");
+  if (avr_current_arch->have_movw_lpmx)
+    {
+      cpp_define (pfile, "__AVR_HAVE_MOVW__");
+      cpp_define (pfile, "__AVR_HAVE_LPMX__");
+    }
+  if (avr_current_arch->asm_only)
+    cpp_define (pfile, "__AVR_ASM_ONLY__");
+  if (avr_current_arch->have_mul)
+    {
+      cpp_define (pfile, "__AVR_ENHANCED__");
+      cpp_define (pfile, "__AVR_HAVE_MUL__");
+    }
+  if (avr_current_arch->have_jmp_call)
+    {
+      cpp_define (pfile, "__AVR_MEGA__");
+      cpp_define (pfile, "__AVR_HAVE_JMP_CALL__");
+    }
+  if (avr_current_arch->have_eijmp_eicall)
+    {
+      cpp_define (pfile, "__AVR_HAVE_EIJMP_EICALL__");
+      cpp_define (pfile, "__AVR_3_BYTE_PC__");
+    }
+  else
+    {
+      cpp_define (pfile, "__AVR_2_BYTE_PC__");
+    }
+
+  if (avr_current_device->short_sp)
+    cpp_define (pfile, "__AVR_HAVE_8BIT_SP__");
+  else
+    cpp_define (pfile, "__AVR_HAVE_16BIT_SP__");
+
+  if (TARGET_NO_INTERRUPTS)
+    cpp_define (pfile, "__NO_INTERRUPTS__");
+}
+
 #include "gt-avr.h"
Index: gcc/config/avr/t-avr
===================================================================
--- gcc/config/avr/t-avr	(revision 166272)
+++ gcc/config/avr/t-avr	(working copy)
@@ -26,11 +26,6 @@  avr-devices.o: $(srcdir)/config/avr/avr-
 	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
 	
 
-avr-c.o: $(srcdir)/config/avr/avr-c.c \
-  $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(C_COMMON_H)
-	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
-	
-
 
 LIB1ASMSRC = avr/libgcc.S
 LIB1ASMFUNCS = \
Index: gcc/config/avr/avr-c.c
===================================================================
--- gcc/config/avr/avr-c.c	(revision 166272)
+++ gcc/config/avr/avr-c.c	(working copy)
@@ -1,85 +0,0 @@ 
-/* Copyright (C) 2009
-   Free Software Foundation, Inc.
-   Contributed by Anatoly Sokolov (aesok@post.ru)
-
-   This file is part of GCC.
-
-   GCC is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3, or (at your option)
-   any later version.
-   
-   GCC is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-   
-   You should have received a copy of the GNU General Public License
-   along with GCC; see the file COPYING3.  If not see
-   <http://www.gnu.org/licenses/>.  */
-
-
-#include "config.h"
-#include "system.h"
-#include "coretypes.h"
-#include "tm.h"
-#include "tm_p.h"
-#include "cpplib.h"
-#include "tree.h"
-#include "c-family/c-common.h"
-
-/* Not included in avr.c since this requires C front end.  */
-
-/* Worker function for TARGET_CPU_CPP_BUILTINS.  */
-
-void
-avr_cpu_cpp_builtins (struct cpp_reader *pfile)
-{
-  builtin_define_std ("AVR");
-
-  if (avr_current_arch->macro)
-    cpp_define (pfile, avr_current_arch->macro);
-  if (avr_extra_arch_macro)
-    cpp_define (pfile, avr_extra_arch_macro);
-  if (avr_current_arch->have_elpm)
-    cpp_define (pfile, "__AVR_HAVE_RAMPZ__");
-  if (avr_current_arch->have_elpm)
-    cpp_define (pfile, "__AVR_HAVE_ELPM__");
-  if (avr_current_arch->have_elpmx)
-    cpp_define (pfile, "__AVR_HAVE_ELPMX__");
-  if (avr_current_arch->have_movw_lpmx)
-    {
-      cpp_define (pfile, "__AVR_HAVE_MOVW__");
-      cpp_define (pfile, "__AVR_HAVE_LPMX__");
-    }
-  if (avr_current_arch->asm_only)
-    cpp_define (pfile, "__AVR_ASM_ONLY__");
-  if (avr_current_arch->have_mul)
-    {
-      cpp_define (pfile, "__AVR_ENHANCED__");
-      cpp_define (pfile, "__AVR_HAVE_MUL__");
-    }
-  if (avr_current_arch->have_jmp_call)
-    {
-      cpp_define (pfile, "__AVR_MEGA__");
-      cpp_define (pfile, "__AVR_HAVE_JMP_CALL__");
-    }
-  if (avr_current_arch->have_eijmp_eicall)
-    {
-      cpp_define (pfile, "__AVR_HAVE_EIJMP_EICALL__");
-      cpp_define (pfile, "__AVR_3_BYTE_PC__");
-    }
-  else
-    {
-      cpp_define (pfile, "__AVR_2_BYTE_PC__");
-    }
-
-  if (avr_current_device->short_sp)
-    cpp_define (pfile, "__AVR_HAVE_8BIT_SP__");
-  else
-    cpp_define (pfile, "__AVR_HAVE_16BIT_SP__");
-
-  if (TARGET_NO_INTERRUPTS)
-    cpp_define (pfile, "__NO_INTERRUPTS__");
-}
-
Index: gcc/config/avr/avr.h
===================================================================
--- gcc/config/avr/avr.h	(revision 166272)
+++ gcc/config/avr/avr.h	(working copy)
@@ -105,7 +105,7 @@  extern const struct mcu_type_s *avr_curr
 extern const struct mcu_type_s avr_mcu_types[];
 extern const struct base_arch_s avr_arch_types[];
 
-#define TARGET_CPU_CPP_BUILTINS()	avr_cpu_cpp_builtins (pfile)
+#define TARGET_CPU_CPP_BUILTINS()	avr_cpu_cpp_builtins (pfile, iso_c)
 
 #if !defined(IN_LIBGCC2) && !defined(IN_TARGET_LIBS)
 extern GTY(()) section *progmem_section;
Index: gcc/config/ia64/hpux.h
===================================================================
--- gcc/config/ia64/hpux.h	(revision 166272)
+++ gcc/config/ia64/hpux.h	(working copy)
@@ -48,14 +48,18 @@  do {							\
 	builtin_define("_INCLUDE_LONGLONG");		\
 	builtin_define("__STDC_EXT__");			\
 	builtin_define("_UINT128_T");			\
+	if (TARGET_ILP32)				\
+	  builtin_define("_ILP32");			\
+} while (0)
+
+#define TARGET_OS_CPP_BUILTINS_CFAMILY()		\
+do {							\
 	if (c_dialect_cxx () || !flag_iso)		\
 	  {						\
 	    builtin_define("_HPUX_SOURCE");		\
 	    builtin_define("__STDCPP__");		\
 	    builtin_define("_INCLUDE__STDC_A1_SOURCE");	\
 	  }						\
-	if (TARGET_ILP32)				\
-	  builtin_define("_ILP32");			\
 } while (0)
 
 #undef CPP_SPEC
Index: gcc/config/rs6000/t-rs6000
===================================================================
--- gcc/config/rs6000/t-rs6000	(revision 166272)
+++ gcc/config/rs6000/t-rs6000	(working copy)
@@ -27,7 +27,7 @@  rs6000.o: $(CONFIG_H) $(SYSTEM_H) corety
   $(OBSTACK_H) $(TREE_H) $(EXPR_H) $(OPTABS_H) except.h function.h \
   output.h $(BASIC_BLOCK_H) $(INTEGRATE_H) toplev.h $(GGC_H) $(HASHTAB_H) \
   $(TM_P_H) $(TARGET_H) $(TARGET_DEF_H) langhooks.h reload.h gt-rs6000.h \
-  cfglayout.h
+  cfglayout.h $(CPPLIB_H) cppbuiltin.h
 
 rs6000-c.o: $(srcdir)/config/rs6000/rs6000-c.c \
     $(srcdir)/config/rs6000/rs6000-protos.h \
Index: gcc/config/rs6000/rs6000-c.c
===================================================================
--- gcc/config/rs6000/rs6000-c.c	(revision 166272)
+++ gcc/config/rs6000/rs6000-c.c	(working copy)
@@ -82,7 +82,6 @@  rs6000_pragma_longcall (cpp_reader *pfil
    #define for, it's better to define a flag for everything.  */
 
 #define builtin_define(TXT) cpp_define (pfile, TXT)
-#define builtin_assert(TXT) cpp_assert (pfile, TXT)
 
 /* Keep the AltiVec keywords handy for fast comparisons.  */
 static GTY(()) tree __vector_keyword;
@@ -259,39 +258,10 @@  rs6000_macro_to_expand (cpp_reader *pfil
 }
 
 void
-rs6000_cpu_cpp_builtins (cpp_reader *pfile)
+rs6000_cpu_cpp_builtins_cfamily (cpp_reader *pfile)
 {
-  if (TARGET_POWER2)
-    builtin_define ("_ARCH_PWR2");
-  else if (TARGET_POWER)
-    builtin_define ("_ARCH_PWR");
-  if (TARGET_POWERPC)
-    builtin_define ("_ARCH_PPC");
-  if (TARGET_PPC_GPOPT)
-    builtin_define ("_ARCH_PPCSQ");
-  if (TARGET_PPC_GFXOPT)
-    builtin_define ("_ARCH_PPCGR");
-  if (TARGET_POWERPC64)
-    builtin_define ("_ARCH_PPC64");
-  if (TARGET_MFCRF)
-    builtin_define ("_ARCH_PWR4");
-  if (TARGET_POPCNTB)
-    builtin_define ("_ARCH_PWR5");
-  if (TARGET_FPRND)
-    builtin_define ("_ARCH_PWR5X");
-  if (TARGET_CMPB)
-    builtin_define ("_ARCH_PWR6");
-  if (TARGET_MFPGPR)
-    builtin_define ("_ARCH_PWR6X");
-  if (! TARGET_POWER && ! TARGET_POWER2 && ! TARGET_POWERPC)
-    builtin_define ("_ARCH_COM");
-  if (TARGET_POPCNTD)
-    builtin_define ("_ARCH_PWR7");
   if (TARGET_ALTIVEC)
     {
-      builtin_define ("__ALTIVEC__");
-      builtin_define ("__VEC__=10206");
-
       /* Define the AltiVec syntactic elements.  */
       builtin_define ("__vector=__attribute__((altivec(vector__)))");
       builtin_define ("__pixel=__attribute__((altivec(pixel__))) unsigned short");
@@ -312,27 +282,8 @@  rs6000_cpu_cpp_builtins (cpp_reader *pfi
 	  cpp_get_callbacks (pfile)->macro_to_expand = rs6000_macro_to_expand;
 	}
     }
-  if (rs6000_cpu == PROCESSOR_CELL)
-    builtin_define ("__PPU__");
-  if (TARGET_SPE)
-    builtin_define ("__SPE__");
-  if (TARGET_PAIRED_FLOAT)
-    builtin_define ("__PAIRED__");
-  if (TARGET_SOFT_FLOAT)
-    builtin_define ("_SOFT_FLOAT");
-  if ((!(TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)))
-      ||(TARGET_HARD_FLOAT && TARGET_FPRS && !TARGET_DOUBLE_FLOAT))
-    builtin_define ("_SOFT_DOUBLE");
-  /* Used by lwarx/stwcx. errata work-around.  */
-  if (rs6000_cpu == PROCESSOR_PPC405)
-    builtin_define ("__PPC405__");
-  /* Used by libstdc++.  */
-  if (TARGET_NO_LWSYNC)
-    builtin_define ("__NO_LWSYNC__");
   if (TARGET_VSX)
     {
-      builtin_define ("__VSX__");
-
       /* For the VSX builtin functions identical to Altivec functions, just map
 	 the altivec builtin into the vsx version (the altivec functions
 	 generate VSX code if -mvsx).  */
@@ -363,68 +314,6 @@  rs6000_cpu_cpp_builtins (cpp_reader *pfi
       builtin_define ("__builtin_vsx_xvnmsubasp=__builtin_vsx_xvnmsubsp");
       builtin_define ("__builtin_vsx_xvnmsubmsp=__builtin_vsx_xvnmsubsp");
     }
-  if (RS6000_RECIP_HAVE_RE_P (DFmode))
-    builtin_define ("__RECIP__");
-  if (RS6000_RECIP_HAVE_RE_P (SFmode))
-    builtin_define ("__RECIPF__");
-  if (RS6000_RECIP_HAVE_RSQRTE_P (DFmode))
-    builtin_define ("__RSQRTE__");
-  if (RS6000_RECIP_HAVE_RSQRTE_P (SFmode))
-    builtin_define ("__RSQRTEF__");
-  if (TARGET_RECIP_PRECISION)
-    builtin_define ("__RECIP_PRECISION__");
-
-  /* Tell users they can use __builtin_bswap{16,64}.  */
-  builtin_define ("__HAVE_BSWAP__");
-
-  /* May be overridden by target configuration.  */
-  RS6000_CPU_CPP_ENDIAN_BUILTINS();
-
-  if (TARGET_LONG_DOUBLE_128)
-    {
-      builtin_define ("__LONG_DOUBLE_128__");
-      builtin_define ("__LONGDOUBLE128");
-    }
-
-  switch (rs6000_current_abi)
-    {
-    case ABI_V4:
-      builtin_define ("_CALL_SYSV");
-      break;
-    case ABI_AIX:
-      builtin_define ("_CALL_AIXDESC");
-      builtin_define ("_CALL_AIX");
-      break;
-    case ABI_DARWIN:
-      builtin_define ("_CALL_DARWIN");
-      break;
-    default:
-      break;
-    }
-
-  /* Let the compiled code know if 'f' class registers will not be available.  */
-  if (TARGET_SOFT_FLOAT || !TARGET_FPRS)
-    builtin_define ("__NO_FPRS__");
-
-  /* Generate defines for Xilinx FPU. */
-  if (rs6000_xilinx_fpu) 
-    {
-      builtin_define ("_XFPU");
-      if (rs6000_single_float && ! rs6000_double_float)
-	{
-	  if (rs6000_simple_fpu) 
-	    builtin_define ("_XFPU_SP_LITE"); 
-	  else 
-	    builtin_define ("_XFPU_SP_FULL");
-	}
-      if (rs6000_double_float)
-	{
-	  if (rs6000_simple_fpu) 
-	    builtin_define ("_XFPU_DP_LITE");
-	  else
-	    builtin_define ("_XFPU_DP_FULL");
-        }
-    }
 }
 
 
Index: gcc/config/rs6000/darwin.h
===================================================================
--- gcc/config/rs6000/darwin.h	(revision 166272)
+++ gcc/config/rs6000/darwin.h	(working copy)
@@ -65,6 +65,13 @@ 
     }							\
   while (0)
 
+#define TARGET_OS_CPP_BUILTINS_CFAMILY()		\
+  do							\
+    {							\
+      darwin_cpp_builtins_cfamily (pfile);		\
+    }							\
+  while (0)
+
 /* Generate branch islands stubs if this is true.  */
 extern int darwin_emit_branch_islands;
 
Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c	(revision 166272)
+++ gcc/config/rs6000/rs6000.c	(working copy)
@@ -57,6 +57,8 @@ 
 #include "intl.h"
 #include "params.h"
 #include "tm-constrs.h"
+#include "cpplib.h"
+#include "cppbuiltin.h"
 #if TARGET_XCOFF
 #include "xcoffout.h"  /* get declarations of xcoff_*_section_name */
 #endif
@@ -27260,4 +27262,124 @@  rs6000_expand_convert_si_to_sfdf (rtx de
     }
 }
 
+#define builtin_define(TXT) cpp_define (pfile, TXT)
+#define builtin_assert(TXT) cpp_assert (pfile, TXT)
+
+void
+rs6000_cpu_cpp_builtins (cpp_reader *pfile)
+{
+  if (TARGET_POWER2)
+    builtin_define ("_ARCH_PWR2");
+  else if (TARGET_POWER)
+    builtin_define ("_ARCH_PWR");
+  if (TARGET_POWERPC)
+    builtin_define ("_ARCH_PPC");
+  if (TARGET_PPC_GPOPT)
+    builtin_define ("_ARCH_PPCSQ");
+  if (TARGET_PPC_GFXOPT)
+    builtin_define ("_ARCH_PPCGR");
+  if (TARGET_POWERPC64)
+    builtin_define ("_ARCH_PPC64");
+  if (TARGET_MFCRF)
+    builtin_define ("_ARCH_PWR4");
+  if (TARGET_POPCNTB)
+    builtin_define ("_ARCH_PWR5");
+  if (TARGET_FPRND)
+    builtin_define ("_ARCH_PWR5X");
+  if (TARGET_CMPB)
+    builtin_define ("_ARCH_PWR6");
+  if (TARGET_MFPGPR)
+    builtin_define ("_ARCH_PWR6X");
+  if (! TARGET_POWER && ! TARGET_POWER2 && ! TARGET_POWERPC)
+    builtin_define ("_ARCH_COM");
+  if (TARGET_POPCNTD)
+    builtin_define ("_ARCH_PWR7");
+  if (TARGET_ALTIVEC)
+    {
+      builtin_define ("__ALTIVEC__");
+      builtin_define ("__VEC__=10206");
+    }
+  if (rs6000_cpu == PROCESSOR_CELL)
+    builtin_define ("__PPU__");
+  if (TARGET_SPE)
+    builtin_define ("__SPE__");
+  if (TARGET_PAIRED_FLOAT)
+    builtin_define ("__PAIRED__");
+  if (TARGET_SOFT_FLOAT)
+    builtin_define ("_SOFT_FLOAT");
+  if ((!(TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)))
+      ||(TARGET_HARD_FLOAT && TARGET_FPRS && !TARGET_DOUBLE_FLOAT))
+    builtin_define ("_SOFT_DOUBLE");
+  /* Used by lwarx/stwcx. errata work-around.  */
+  if (rs6000_cpu == PROCESSOR_PPC405)
+    builtin_define ("__PPC405__");
+  /* Used by libstdc++.  */
+  if (TARGET_NO_LWSYNC)
+    builtin_define ("__NO_LWSYNC__");
+  if (TARGET_VSX)
+    builtin_define ("__VSX__");
+  if (RS6000_RECIP_HAVE_RE_P (DFmode))
+    builtin_define ("__RECIP__");
+  if (RS6000_RECIP_HAVE_RE_P (SFmode))
+    builtin_define ("__RECIPF__");
+  if (RS6000_RECIP_HAVE_RSQRTE_P (DFmode))
+    builtin_define ("__RSQRTE__");
+  if (RS6000_RECIP_HAVE_RSQRTE_P (SFmode))
+    builtin_define ("__RSQRTEF__");
+  if (TARGET_RECIP_PRECISION)
+    builtin_define ("__RECIP_PRECISION__");
+
+  /* Tell users they can use __builtin_bswap{16,64}.  */
+  builtin_define ("__HAVE_BSWAP__");
+
+  /* May be overridden by target configuration.  */
+  RS6000_CPU_CPP_ENDIAN_BUILTINS();
+
+  if (TARGET_LONG_DOUBLE_128)
+    {
+      builtin_define ("__LONG_DOUBLE_128__");
+      builtin_define ("__LONGDOUBLE128");
+    }
+
+  switch (rs6000_current_abi)
+    {
+    case ABI_V4:
+      builtin_define ("_CALL_SYSV");
+      break;
+    case ABI_AIX:
+      builtin_define ("_CALL_AIXDESC");
+      builtin_define ("_CALL_AIX");
+      break;
+    case ABI_DARWIN:
+      builtin_define ("_CALL_DARWIN");
+      break;
+    default:
+      break;
+    }
+
+  /* Let the compiled code know if 'f' class registers will not be available.  */
+  if (TARGET_SOFT_FLOAT || !TARGET_FPRS)
+    builtin_define ("__NO_FPRS__");
+
+  /* Generate defines for Xilinx FPU. */
+  if (rs6000_xilinx_fpu) 
+    {
+      builtin_define ("_XFPU");
+      if (rs6000_single_float && ! rs6000_double_float)
+	{
+	  if (rs6000_simple_fpu) 
+	    builtin_define ("_XFPU_SP_LITE"); 
+	  else 
+	    builtin_define ("_XFPU_SP_FULL");
+	}
+      if (rs6000_double_float)
+	{
+	  if (rs6000_simple_fpu) 
+	    builtin_define ("_XFPU_DP_LITE");
+	  else
+	    builtin_define ("_XFPU_DP_FULL");
+        }
+    }
+}
+
 #include "gt-rs6000.h"
Index: gcc/config/rs6000/rs6000.h
===================================================================
--- gcc/config/rs6000/rs6000.h	(revision 166272)
+++ gcc/config/rs6000/rs6000.h	(working copy)
@@ -634,6 +634,8 @@  extern unsigned char rs6000_recip_bits[]
 /* Target #defines.  */
 #define TARGET_CPU_CPP_BUILTINS() \
   rs6000_cpu_cpp_builtins (pfile)
+#define TARGET_CPU_CPP_BUILTINS_CFAMILY() \
+  rs6000_cpu_cpp_builtins_cfamily (pfile)
 
 /* This is used by rs6000_cpu_cpp_builtins to indicate the byte order
    we're compiling for.  Some configurations may need to override it.  */
Index: gcc/config/darwin.c
===================================================================
--- gcc/config/darwin.c	(revision 166272)
+++ gcc/config/darwin.c	(working copy)
@@ -50,6 +50,8 @@  along with GCC; see the file COPYING3.  
 #include "debug.h"
 #include "obstack.h"
 #include "lto-streamer.h"
+#include "cpplib.h"
+#include "cppbuiltin.h"
 
 /* Darwin supports a feature called fix-and-continue, which is used
    for rapid turn around debugging.  When code is compiled with the
@@ -2017,6 +2019,49 @@  darwin_override_options (void)
   darwin_running_cxx = (strstr (lang_hooks.name, "C++") != 0);
 }
 
+/* Return the value of darwin_macosx_version_min suitable for the
+   __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ macro,
+   so '10.4.2' becomes 1040.  The lowest digit is always zero.
+   Print a warning if the version number can't be understood.  */
+static const char *
+version_as_macro (void)
+{
+  static char result[] = "1000";
+
+  if (strncmp (darwin_macosx_version_min, "10.", 3) != 0)
+    goto fail;
+  if (! ISDIGIT (darwin_macosx_version_min[3]))
+    goto fail;
+  result[2] = darwin_macosx_version_min[3];
+  if (darwin_macosx_version_min[4] != '\0'
+      && darwin_macosx_version_min[4] != '.')
+    goto fail;
+
+  return result;
+
+ fail:
+  error ("Unknown value %qs of -mmacosx-version-min",
+	 darwin_macosx_version_min);
+  return "1000";
+}
+
+/* Define additional CPP flags for Darwin.   */
+
+void
+darwin_cpp_builtins (cpp_reader *pfile)
+{
+  cpp_define (pfile, "__MACH__");
+  cpp_define (pfile, "__APPLE__");
+
+  /* __APPLE_CC__ is defined as some old Apple include files expect it
+     to be defined and won't work if it isn't.  */
+  cpp_define (pfile, "__APPLE_CC__=1");
+
+  cpp_define_formatted (pfile,
+			"__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__=%s",
+			version_as_macro());
+}
+
 /* Add $LDBL128 suffix to long double builtins.  */
 
 static void
Index: gcc/config/darwin.h
===================================================================
--- gcc/config/darwin.h	(revision 166272)
+++ gcc/config/darwin.h	(working copy)
@@ -222,7 +222,7 @@  extern GTY(()) int darwin_ms_struct;
   } while (0)
 
 /* Machine dependent cpp options.  Don't add more options here, add
-   them to darwin_cpp_builtins in darwin-c.c.  */
+   them to darwin_cpp_builtins in darwin.c.  */
 
 #undef	CPP_SPEC
 #define CPP_SPEC "%{static:%{!dynamic:-D__STATIC__}}%{!static:-D__DYNAMIC__}" \
Index: gcc/config/pa/pa-hpux.h
===================================================================
--- gcc/config/pa/pa-hpux.h	(revision 166272)
+++ gcc/config/pa/pa-hpux.h	(working copy)
@@ -57,6 +57,21 @@  along with GCC; see the file COPYING3.  
 	builtin_define ("__unix");				\
 	builtin_define ("__unix__");				\
 	builtin_define ("__STDC_EXT__");			\
+	if (TARGET_SIO)						\
+	  builtin_define ("_SIO");				\
+	else							\
+	  {							\
+	    builtin_define ("__hp9000s700");			\
+	    builtin_define ("__hp9000s700__");			\
+	    builtin_define ("_WSIO");				\
+	  }							\
+    }								\
+  while (0)
+
+#undef TARGET_OS_CPP_BUILTINS_CFAMILY
+#define TARGET_OS_CPP_BUILTINS_CFAMILY()			\
+  do								\
+    {								\
 	if (c_dialect_cxx ())					\
 	  {							\
 	    builtin_define ("_HPUX_SOURCE");			\
@@ -77,14 +92,6 @@  along with GCC; see the file COPYING3.  
 		builtin_define ("PWB");				\
 	      }							\
 	  }							\
-	if (TARGET_SIO)						\
-	  builtin_define ("_SIO");				\
-	else							\
-	  {							\
-	    builtin_define ("__hp9000s700");			\
-	    builtin_define ("__hp9000s700__");			\
-	    builtin_define ("_WSIO");				\
-	  }							\
     }								\
   while (0)
 
Index: gcc/config/pa/pa-hpux10.h
===================================================================
--- gcc/config/pa/pa-hpux10.h	(revision 166272)
+++ gcc/config/pa/pa-hpux10.h	(working copy)
@@ -39,6 +39,26 @@  along with GCC; see the file COPYING3.  
 	builtin_define ("__unix");					\
 	builtin_define ("__unix__");					\
 	builtin_define ("__STDC_EXT__");				\
+	if (flag_pa_unix >= 1995)					\
+	  {								\
+	    builtin_define ("_XOPEN_UNIX");				\
+	    builtin_define ("_XOPEN_SOURCE_EXTENDED");			\
+	  }								\
+	if (TARGET_SIO)							\
+	  builtin_define ("_SIO");					\
+	else								\
+	  {								\
+	    builtin_define ("__hp9000s700");				\
+	    builtin_define ("__hp9000s700__");				\
+	    builtin_define ("_WSIO");					\
+	  }								\
+    }									\
+  while (0)
+
+#undef TARGET_OS_CPP_BUILTINS_CFAMILY
+#define TARGET_OS_CPP_BUILTINS_CFAMILY()				\
+  do									\
+    {									\
 	if (c_dialect_cxx ())						\
 	  {								\
 	    builtin_define ("_HPUX_SOURCE");				\
@@ -59,19 +79,6 @@  along with GCC; see the file COPYING3.  
 		builtin_define ("PWB");					\
 	      }								\
 	  }								\
-	if (flag_pa_unix >= 1995)					\
-	  {								\
-	    builtin_define ("_XOPEN_UNIX");				\
-	    builtin_define ("_XOPEN_SOURCE_EXTENDED");			\
-	  }								\
-	if (TARGET_SIO)							\
-	  builtin_define ("_SIO");					\
-	else								\
-	  {								\
-	    builtin_define ("__hp9000s700");				\
-	    builtin_define ("__hp9000s700__");				\
-	    builtin_define ("_WSIO");					\
-	  }								\
     }									\
   while (0)
 
Index: gcc/config/pa/pa-hpux11.h
===================================================================
--- gcc/config/pa/pa-hpux11.h	(revision 166272)
+++ gcc/config/pa/pa-hpux11.h	(working copy)
@@ -38,6 +38,23 @@  along with GCC; see the file COPYING3.  
 	builtin_define ("__unix");					\
 	builtin_define ("__unix__");					\
 	builtin_define ("__STDC_EXT__");				\
+	if (!TARGET_64BIT)						\
+	  builtin_define ("_ILP32");					\
+	if (TARGET_SIO)							\
+	  builtin_define ("_SIO");					\
+	else								\
+	  {								\
+	    builtin_define ("__hp9000s700");				\
+	    builtin_define ("__hp9000s700__");				\
+	    builtin_define ("_WSIO");					\
+	  }								\
+    }									\
+  while (0)
+
+#undef TARGET_OS_CPP_BUILTINS_CFAMILY
+#define TARGET_OS_CPP_BUILTINS_CFAMILY()				\
+  do									\
+    {									\
 	if (c_dialect_cxx ())						\
 	  {								\
 	    builtin_define ("_HPUX_SOURCE");				\
@@ -61,8 +78,6 @@  along with GCC; see the file COPYING3.  
 		  }							\
 	      }								\
 	  }								\
-	if (!TARGET_64BIT)						\
-	  builtin_define ("_ILP32");					\
 	if (flag_pa_unix >= 1995 && !flag_iso)				\
 	  {								\
 	    builtin_define ("_XOPEN_UNIX");				\
@@ -82,14 +97,6 @@  along with GCC; see the file COPYING3.  
 	      warning (0, "-munix=98 option required for C89 "		\
 		       "Amendment 1 features.\n");			\
 	  }								\
-	if (TARGET_SIO)							\
-	  builtin_define ("_SIO");					\
-	else								\
-	  {								\
-	    builtin_define ("__hp9000s700");				\
-	    builtin_define ("__hp9000s700__");				\
-	    builtin_define ("_WSIO");					\
-	  }								\
     }									\
   while (0)
 
Index: gcc/config/pa/pa.h
===================================================================
--- gcc/config/pa/pa.h	(revision 166272)
+++ gcc/config/pa/pa.h	(working copy)
@@ -202,8 +202,6 @@  do {								\
 	builtin_define_std ("hp800");				\
 	builtin_define_std ("hp9000");				\
 	builtin_define_std ("hp9k8");				\
-	if (!c_dialect_cxx () && !flag_iso)			\
-	  builtin_define ("hppa");				\
 	builtin_define_std ("spectrum");			\
 	builtin_define_std ("unix");				\
 	builtin_assert ("system=bsd");				\
@@ -211,6 +209,14 @@  do {								\
     }								\
   while (0)
 
+#define TARGET_OS_CPP_BUILTINS_CFAMILY()			\
+  do								\
+    {								\
+	if (!c_dialect_cxx () && !flag_iso)			\
+	  builtin_define ("hppa");				\
+    }								\
+  while (0)
+
 #define CC1_SPEC "%{pg:} %{p:}"
 
 #define LINK_SPEC "%{mlinker-opt:-O} %{!shared:-u main} %{shared:-b}"
Index: gcc/config/mips/linux.h
===================================================================
--- gcc/config/mips/linux.h	(revision 166272)
+++ gcc/config/mips/linux.h	(working copy)
@@ -44,6 +44,10 @@  along with GCC; see the file COPYING3.  
 #define TARGET_OS_CPP_BUILTINS()				\
   do {								\
     LINUX_TARGET_OS_CPP_BUILTINS();				\
+  } while (0)
+
+#define TARGET_OS_CPP_BUILTINS_CFAMILY()			\
+  do {								\
     /* The GNU C++ standard library requires this.  */		\
     if (c_dialect_cxx ())					\
       builtin_define ("_GNU_SOURCE");				\
Index: gcc/config/mips/iris6.h
===================================================================
--- gcc/config/mips/iris6.h	(revision 166272)
+++ gcc/config/mips/iris6.h	(working copy)
@@ -171,7 +171,12 @@  along with GCC; see the file COPYING3.  
 	 An alternative would be to support the SGI builtin	\
 	 type __long_long.  */					\
       builtin_define ("_LONGLONG");				\
-								\
+    }								\
+  while (0)
+
+#define TARGET_OS_CPP_BUILTINS_CFAMILY()			\
+  do								\
+    {								\
       /* IRIX 6.5.18 and above provide many ISO C99		\
 	 features protected by the __c99 macro.			\
 	 libstdc++ v3 needs them as well.  */			\
Index: gcc/config/mips/mips.h
===================================================================
--- gcc/config/mips/mips.h	(revision 166272)
+++ gcc/config/mips/mips.h	(working copy)
@@ -320,14 +320,15 @@  enum mips_code_readable_setting {
 #define MIPS_CPP_SET_PROCESSOR(PREFIX, INFO)			\
   do								\
     {								\
-      char *macro, *p;						\
+      char *macro, *p, *s;					\
 								\
       macro = concat ((PREFIX), "_", (INFO)->name, NULL);	\
       for (p = macro; *p != 0; p++)				\
 	*p = TOUPPER (*p);					\
 								\
       builtin_define (macro);					\
-      builtin_define_with_value ((PREFIX), (INFO)->name, 1);	\
+      s = concat ((PREFIX), "=\"", (INFO)->name, "\"", NULL);	\
+      builtin_define (s);					\
       free (macro);						\
     }								\
   while (0)
@@ -344,16 +345,6 @@  enum mips_code_readable_setting {
       builtin_define ("__mips__");     					\
       builtin_define ("_mips");						\
 									\
-      /* We do this here because __mips is defined below and so we	\
-	 can't use builtin_define_std.  We don't ever want to define	\
-	 "mips" for VxWorks because some of the VxWorks headers		\
-	 construct include filenames from a root directory macro,	\
-	 an architecture macro and a filename, where the architecture	\
-	 macro expands to 'mips'.  If we define 'mips' to 1, the	\
-	 architecture macro expands to 1 as well.  */			\
-      if (!flag_iso && !TARGET_VXWORKS)					\
-	builtin_define ("mips");					\
-									\
       if (TARGET_64BIT)							\
 	builtin_define ("__mips64");					\
 									\
@@ -515,6 +506,27 @@  enum mips_code_readable_setting {
       if (TARGET_OCTEON)						\
 	builtin_define ("__OCTEON__");					\
 									\
+      if (mips_abi == ABI_EABI)						\
+	builtin_define ("__mips_eabi");					\
+									\
+      if (TARGET_CACHE_BUILTIN)						\
+	builtin_define ("__GCC_HAVE_BUILTIN_MIPS_CACHE");		\
+    }									\
+  while (0)
+
+#define TARGET_CPU_CPP_BUILTINS_CFAMILY()				\
+  do									\
+    {									\
+      /* We do this here because __mips is already defined and so we	\
+	 can't use builtin_define_std.  We don't ever want to define	\
+	 "mips" for VxWorks because some of the VxWorks headers		\
+	 construct include filenames from a root directory macro,	\
+	 an architecture macro and a filename, where the architecture	\
+	 macro expands to 'mips'.  If we define 'mips' to 1, the	\
+	 architecture macro expands to 1 as well.  */			\
+      if (!flag_iso && !TARGET_VXWORKS)					\
+	builtin_define ("mips");					\
+									\
       /* Macros dependent on the C dialect.  */				\
       if (preprocessing_asm_p ())					\
 	{								\
@@ -540,12 +552,6 @@  enum mips_code_readable_setting {
 	  builtin_define_std ("LANGUAGE_C");				\
 	  builtin_define ("_LANGUAGE_C");				\
 	}								\
-									\
-      if (mips_abi == ABI_EABI)						\
-	builtin_define ("__mips_eabi");					\
-									\
-      if (TARGET_CACHE_BUILTIN)						\
-	builtin_define ("__GCC_HAVE_BUILTIN_MIPS_CACHE");		\
     }									\
   while (0)
 
Index: gcc/config.gcc
===================================================================
--- gcc/config.gcc	(revision 166272)
+++ gcc/config.gcc	(working copy)
@@ -289,8 +289,6 @@  arm*-*-*)
 	;;
 avr-*-*)
 	cpu_type=avr
-	c_target_objs="avr-c.o"
-	cxx_target_objs="avr-c.o"
 	;;
 bfin*-*)
 	cpu_type=bfin