This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


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

Some extern "C" header fixes for older Darwin versions


Part of what happened here is that in darwin7, the policy was that you
shouldn't be using mach/* headers except through mach/mach.h, but they
happened to work, until IMPLICIT_EXTERN_C went away.

Tested on powerpc-apple-darwin8.  Unfortunately I don't have any
systems which can run darwin7 and is fast enough to build GCC, so any
reports of success would be helpful; but I don't anticipate weird
problems.

-- 
- Geoffrey Keating <geoffk@apple.com>

===File ~/patches/gcc-fixinc-5443305-2.patch================
2007-10-09  Geoffrey Keating  <geoffk@apple.com>

	* inclhack.def (darwin_externc): New.
	* fixincl.x: Regenerate.
	* tests/base/mach-o/swap.h: New.

Index: tests/base/mach-o/swap.h
===================================================================
--- tests/base/mach-o/swap.h	(revision 0)
+++ tests/base/mach-o/swap.h	(revision 0)
@@ -0,0 +1,26 @@
+/*  DO NOT EDIT THIS FILE.
+
+    It has been auto-edited by fixincludes from:
+
+	"fixinc/tests/inc/mach-o/swap.h"
+
+    This had to be done to correct non-standard usages in the
+    original, manufacturer supplied header file.  */
+
+#ifndef FIXINC_WRAP_MACH_O_SWAP_H_DARWIN_EXTERNC
+#define FIXINC_WRAP_MACH_O_SWAP_H_DARWIN_EXTERNC 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#if defined( DARWIN_EXTERNC_CHECK )
+extern void swap_fat_header();
+
+#endif  /* DARWIN_EXTERNC_CHECK */
+#ifdef __cplusplus
+}
+#endif
+
+#endif  /* FIXINC_WRAP_MACH_O_SWAP_H_DARWIN_EXTERNC */
Index: inclhack.def
===================================================================
--- inclhack.def	(revision 129137)
+++ inclhack.def	(working copy)
@@ -1167,6 +1167,32 @@
 
 
 /*
+ *  On darwin8 and earlier, mach-o/swap.h isn't properly guarded
+ *  by 'extern "C"'.  On darwin7 some mach/ headers aren't properly guarded.
+ */
+fix = {
+  hackname  = darwin_externc;
+  mach      = "*-*-darwin*";
+  files     = mach-o/swap.h;
+  files     = mach/mach_time.h;
+  files     = mach/mach_traps.h;
+  files     = mach/message.h;
+  files     = mach/mig.h;
+  files     = mach/semaphore.h;
+  bypass    = "extern \"C\"";
+  bypass    = "__BEGIN_DECLS";
+  c_fix     = wrap;
+  c_fix_arg = "#ifdef __cplusplus\n"
+              "extern \"C\" {\n"
+              "#endif\n";
+  c_fix_arg = "#ifdef __cplusplus\n"
+              "}\n"
+              "#endif\n";
+  test_text = "extern void swap_fat_header();\n";
+};
+
+
+/*
  * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of
  * bad __GNUC__ tests.
  */
============================================================


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