diff -ur config.orig-patch/i386/emx.c config/i386/emx.c
--- config.orig-patch/i386/emx.c	2010-07-03 06:14:08.000000000 +0400
+++ config/i386/emx.c	2010-07-09 03:27:56.000000000 +0400
@@ -67,9 +67,7 @@
             case POINTER_TYPE:      return "POINTER_TYPE   ";
             case VOID_TYPE:         return "VOID_TYPE      ";
             case INTEGER_TYPE:      return "INTEGER_TYPE   ";
-            case CHAR_TYPE:         return "CHAR_TYPE      ";
             case BOOLEAN_TYPE:      return "BOOLEAN_TYPE   ";
-            case SET_TYPE:          return "SET_TYPE       ";
             case ARRAY_TYPE:        return "ARRAY_TYPE     ";
             case RECORD_TYPE:       return "RECORD_TYPE    ";
             case QUAL_UNION_TYPE:   return "QUAL_UNION_TYPE";
@@ -137,7 +135,7 @@
 
     fprintf(stderr, "dbg: node=%d %s %p %s '%s'  type=%d %s %p %s '%s'  type_type=%d %s %p %s '%s'  context=%d %s %p %s '%s' (%s)\n",
             TREE_CODE(node), code(node), (void*)node, birddump_callingconv(node), birddump_name(node),
-           g type ? (int)TREE_CODE(type) : -1, code(type), (void*)type, birddump_callingconv(type), birddump_name (type),
+            type ? (int)TREE_CODE(type) : -1, code(type), (void*)type, birddump_callingconv(type), birddump_name (type),
             type2 ? (int)TREE_CODE(type2) : -1, code(type2), (void*)type2, birddump_callingconv(type2), birddump_name (type2),
             context ? (int)TREE_CODE(context) : -1, code(context), (void*)context, birddump_callingconv(context), birddump_name (context),
             pszFunction);
@@ -299,158 +297,6 @@
   return rc;
 }
 
-#if 0 /* choose between the smaller non working version, and the
-         large ugly one which is working. */
-
-tree emx_handle_vacpp_attribute (tree *node, tree name, tree args,
-  int flags, _Bool *no_add_attrs)
-{
-  tree *type;
-  (void) args;
-  (void) flags;
-
-  dfprintf((stderr, "emx_handle_vacpp_attribute\n"));
-  DUMP (*node);
-
-  if (TREE_CODE (*node) != FUNCTION_TYPE
-      && TREE_CODE (*node) != METHOD_TYPE
-      && TREE_CODE (*node) != FIELD_DECL
-      && TREE_CODE (*node) != TYPE_DECL)
-    {
-      warning ("`%s' attribute only applies to functions",
-	       IDENTIFIER_POINTER (name));
-      *no_add_attrs = true;
-    }
-
-  if (TARGET_64BIT)
-    {
-      warning ("`%s' attribute ignored", IDENTIFIER_POINTER (name));
-      *no_add_attrs = true;
-    }
-
-  /* Check if the attributes are compatible */
-  if (ix86_check_append_attr (*node, name, no_add_attrs))
-    return NULL_TREE;
-
-  /* Now, a new type with our attribute please!
-     If the FUNCTION_TYPE/METHOD_TYPE already have the attribute associated,
-     there is no need to duplicate the type.
-     @todo: I'm unsure wether or not we should do this from node and down... */
-  for (type = node;
-       TREE_CODE (*type) != FUNCTION_TYPE && TREE_CODE (*type) != METHOD_TYPE;
-       type = &TREE_TYPE (*type))
-      /* do nothing */;
-
-  if (lookup_attribute (IDENTIFIER_POINTER (name), TYPE_ATTRIBUTES (*type)))
-      return NULL_TREE;
-
-  *type = build_type_copy (*type);
-  *type = build_type_attribute_variant (*type, tree_cons (name, args, TYPE_ATTRIBUTES (*type)) );
-  /**no_add_attrs = true; ?? */
-
-  dfprintf((stderr, "emx_handle_vacpp_attribute: new type (%p)\n", (void*)type));
-  DUMP (*node);
-  return NULL_TREE;
-}
-
-#else
-
-/* This is the working version which we belive duplicate some which could be
-   done by the generic attribute stuff in GCC... */
-tree emx_handle_vacpp_attribute (tree *node, tree name, tree args, int flags, _Bool *no_add_attrs)
-{
-  tree type;
-
-  dfprintf((stderr, "emx_handle_vacpp_attribute: node=%p\n", (void *)node));
-  DUMP (*node);
-
-  switch (TREE_CODE (*node))
-    {
-      /* Declarations!
-         We need to attach the attribute to the type of the declaration.
-         (Name mangling is done by emx_c_set_decl_assembler_name().)  */
-      case FUNCTION_DECL:/* Function declaration. */
-      case TYPE_DECL:    /* Function or function pointer type. */
-      case FIELD_DECL:   /* Function pointer (or function?) as a struct, union or class member. */
-      case PARM_DECL:    /* Function pointer as a parameter. */
-      case VAR_DECL:     /* Function pointer variable. */
-        /* If this is a type declaration with our attribute, we allow it
-           only if it is a pointer-to-a-function type or a function type. */
-        type = TREE_TYPE (*node);
-        if (TREE_CODE (type) == POINTER_TYPE)
-          type = TREE_TYPE(type);
-        if (   TREE_CODE (type) != FUNCTION_TYPE
-            && TREE_CODE (type) != METHOD_TYPE)
-          {
-            warning ("`%s' attribute only applies to functions and function types, not to '%T'.",
-                     IDENTIFIER_POINTER (name), type);
-            *no_add_attrs = true;
-            break;
-          }
-
-        if (ix86_check_append_attr (type, name, no_add_attrs))
-          break;
-
-        /* If required we'll make a variant of the type for this attribute. */
-        if (!lookup_attribute (IDENTIFIER_POINTER (name),
-                               TYPE_ATTRIBUTES (type)))
-          {
-            tree *ptype = node;
-            while (*ptype != type)
-                ptype = &TREE_TYPE (*ptype);
-            *ptype = build_variant_type_copy (*ptype);
-            *ptype = build_type_attribute_variant (
-                *ptype, tree_cons (name, args, TYPE_ATTRIBUTES (*ptype)) );
-            dfprintf((stderr, "emx_handle_vacpp_attribute: new type\n"));
-            DUMP(*node);
-          }
-        else
-          dfprintf((stderr, "emx_handle_vacpp_attribute: use old type\n"));
-        *no_add_attrs = true;
-        break;
-
-      /* Types!
-         For types involving functions we need to convince decl_attributes()
-         (and its callers) to supply a declaration so we safely can change
-         the type. */
-      case POINTER_TYPE:
-        /* We allow:
-           This being the return type of a function which is coming soon.
-           This being a function pointer which declaration is coming next.
-           Everything else is considered inappropriate use of the attribute. */
-        if (   !(flags & ATTR_FLAG_FUNCTION_NEXT)
-            && (    !(flags & ATTR_FLAG_DECL_NEXT)
-                ||  !(type = TREE_TYPE (*node))
-                || (   TREE_CODE (type) != FUNCTION_TYPE
-                    && TREE_CODE (type) != METHOD_TYPE)))
-        {
-            warning ("`%s' attribute only applies to functions and function types",
-                     IDENTIFIER_POINTER (name));
-            *no_add_attrs = true;
-            break;
-        }
-        /* fall thru */
-      case FUNCTION_TYPE:
-      case METHOD_TYPE:
-#if 0 /* bird: This fixes optlink/tst4.c and doesn't seem to break anything.
-               If set to true we are in some cases imposing _Optlink onto following
-               declarations. This is weird stuff!
-            !! This problem is actually what we see with the other implementation!! */
-        *no_add_attrs = true;
-#endif
-        return tree_cons (name, args, NULL_TREE);
-
-      default:
-        warning ("`%s' attribute only applies to functions and function types (code=%d)",
-                 IDENTIFIER_POINTER (name), TREE_CODE (*node));
-        *no_add_attrs = true;
-        break;
-    }
-
-  return NULL_TREE;
-}
-#endif
-
 void
 emx_eh_frame_section ()
 {
diff -ur config.orig-patch/i386/emx.h config/i386/emx.h
--- config.orig-patch/i386/emx.h	2010-07-03 10:25:18.000000000 +0400
+++ config/i386/emx.h	2010-07-09 03:28:02.000000000 +0400
@@ -119,11 +119,9 @@
 
 /* We want the _System attribute */
 #define TARGET_SYSTEM_DECL_ATTRIBUTES
-#define ix86_handle_system_attribute    emx_handle_vacpp_attribute
 
 /* We want the _Optlink attribute */
 #define TARGET_OPTLINK_DECL_ATTRIBUTES
-#define ix86_handle_optlink_attribute   emx_handle_vacpp_attribute
 
 /* Do our own mangling on some kinds of decls */
 #define TARGET_C_SET_DECL_ASSEMBLER_NAME(decl) \
@@ -310,9 +308,6 @@
 extern void emx_eh_frame_section (void);
 extern void emx_output_function_begin_epilogue (FILE *);
 
-/* This function handles both _System and _Optlink attributes. */
-extern tree emx_handle_vacpp_attribute PARAMS ((tree *, tree, tree, int, _Bool *));
-
 /* These functions are for handling dllexport and dllimport. */
 extern void i386_emx_record_exported_symbol (const char *, int);
 extern void i386_emx_file_end (void);
diff -ur config.orig-patch/i386/i386.c config/i386/i386.c
--- config.orig-patch/i386/i386.c	2010-07-09 03:17:58.000000000 +0400
+++ config/i386/i386.c	2010-07-09 03:28:22.000000000 +0400
@@ -29685,16 +29685,6 @@
 static const struct attribute_spec ix86_attribute_table[] =
 {
   /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
-#ifdef EMX /** @todo: ugly stuff, cleanup later. */
-  /* Stdcall attribute says callee is responsible for popping arguments
-     if they are not variable.  */
-  { "stdcall",   0, 0, false, false, false, ix86_handle_system_attribute },
-  /* Fastcall attribute says callee is responsible for popping arguments
-     if they are not variable.  */
-  { "fastcall",  0, 0, false, false,  false,  ix86_handle_system_attribute },
-  /* Cdecl attribute says the callee is a normal C declaration */
-  { "cdecl",     0, 0, false, false, false, ix86_handle_system_attribute },
-#else
   /* Stdcall attribute says callee is responsible for popping arguments
      if they are not variable.  */
   { "stdcall",   0, 0, false, true,  true,  ix86_handle_cconv_attribute },
@@ -29703,7 +29693,6 @@
   { "fastcall",  0, 0, false, true,  true,  ix86_handle_cconv_attribute },
   /* Cdecl attribute says the callee is a normal C declaration */
   { "cdecl",     0, 0, false, true,  true,  ix86_handle_cconv_attribute },
-#endif
   /* Regparm attribute specifies how many integer arguments are to be
      passed in registers.  */
   { "regparm",   1, 1, false, true,  true,  ix86_handle_cconv_attribute },
@@ -29728,24 +29717,13 @@
   { "ms_abi", 0, 0, false, true, true, ix86_handle_abi_attribute },
   { "sysv_abi", 0, 0, false, true, true, ix86_handle_abi_attribute },
   /* End element.  */
-#ifdef EMX /** @todo: ugly stuff, cleanup later. */
 #ifdef TARGET_SYSTEM_DECL_ATTRIBUTES
   /* System says the function is extern "C" and is not underscored. */
-  { "system",    0, 0, false, false, false, ix86_handle_system_attribute },
+  { "system",    0, 0, false, true,  true,  ix86_handle_cconv_attribute },
 #endif
 #ifdef TARGET_OPTLINK_DECL_ATTRIBUTES
   /* Optlink is like regparm with a few differences */
-  { "optlink",   0, 0, false, false, false, ix86_handle_optlink_attribute },
-#endif
-#else
-#ifdef TARGET_SYSTEM_DECL_ATTRIBUTES
-  /* System says the function is extern "C" and is not underscored. */
-  { "system",    0, 0, false, true,  true,  ix86_handle_system_attribute },
-#endif
-#ifdef TARGET_OPTLINK_DECL_ATTRIBUTES
-  /* Optlink is like regparm with a few differences */
-  { "optlink",   0, 0, false, true,  true,  ix86_handle_optlink_attribute },
-#endif
+  { "optlink",   0, 0, false, true,  true,  ix86_handle_cconv_attribute },
 #endif
   { NULL,        0, 0, false, false, false, NULL }
 };
