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]

PATCH: Fix IRIX 6.5/Solaris 2 <complex.h> for GCC (PR libfortran/41169)


As described in PR libfortan/41169, <complex.h> on IRIX 6.5 and Solaris 2
uses compiler intrinsics/builtins of the system compilers which don't work
with GCC (__I__ on IRIX 6.5 for MIPSpro, _Complex_I and _Imaginary_I on
Solaris 2 for Sun Studio).  As advised by Josef, this patch fixes this by
removing references to imaginary/_Imaginary/_Imaginary_I which are and
probably will remain unsupported by GCC and defining _Complex_I in terms of
a GCC extensions as has been done before on AIX and HP-UX.

With this patch, mainline bootstrapped on sparc-sun-solaris2.11,
i386-pc-solaris2.10 and mips-sgi-irix6.5 where bootstrap failed before in
libfortran.  There's no baseline to compare against, though.

make check in fixincludes passes as well.

Ok for mainline?

	Rainer

-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2009-08-28  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	PR libfortran/41169
	* inclhack.def (irix_complex): New fix.
	(solaris_complex): Likewise.
	* fixincl.x: Regenerate.
	* tests/base/complex.h [IRIX_COMPLEX_CHECK, SOLARIS_COMPLEX_CHECK]:
	New tests.

Index: tests/base/complex.h
===================================================================
--- tests/base/complex.h	(revision 151177)
+++ tests/base/complex.h	(working copy)
@@ -19,3 +19,17 @@
 #define _Complex_I (__extension__ 1.0iF)
 
 #endif  /* HPUX_IMAGINARY_I_CHECK */
+
+
+#if defined( IRIX_COMPLEX_CHECK )
+#define _Complex_I (__extension__ 1.0iF)
+#define I _Complex_I
+#endif  /* IRIX_COMPLEX_CHECK */
+
+
+#if defined( SOLARIS_COMPLEX_CHECK )
+#define _Complex_I (__extension__ 1.0iF)
+#define	complex		_Complex
+#undef	I
+#define	I		_Complex_I
+#endif  /* SOLARIS_COMPLEX_CHECK */
Index: inclhack.def
===================================================================
--- inclhack.def	(revision 151177)
+++ inclhack.def	(working copy)
@@ -2446,6 +2446,29 @@
 
 
 /*
+ * IRIX 6.5 complex.h defines _Complex_I and _Imaginary_I in terms of __I__,
+ * which is a MIPSpro compiler builtin.  Remove _Imaginary_I and imaginary
+ * definitions which are not supported by GCC. 
+ */
+fix = {
+    hackname  = irix_complex;
+    mach      = "mips-sgi-irix6.5";
+    files     = complex.h;
+    select    = "#define[ \t]_Complex_I[ \t]\\(\\(float[ \t]_Complex\\)[ \t]\\(__I__\\)\\)";
+    sed	      = "s/#define[ \t]_Complex_I[ \t]((float[ \t]_Complex)[ \t](__I__))/"
+		"#define _Complex_I (__extension__ 1.0iF)/";
+    sed	      = "/#define[ \t]imaginary[ \t]_Imaginary/d";
+    sed	      = "/#define[ \t]_Imaginary_I/d";
+    sed       = "s/#define[ \t]I[ \t]_Imaginary_I/#define I _Complex_I/";
+    test_text = "#define _Complex_I ((float _Complex) (__I__))\n"
+		"#define imaginary _Imaginary\n"
+		"// #define _Imaginary_I ((float _Imaginary) 1)\n"
+		"#define _Imaginary_I __I__\n"
+		"#define I _Imaginary_I";
+};
+
+
+/*
  *  Non-traditional "const" declaration in Irix's limits.h.
  */
 fix = {
@@ -3229,6 +3252,30 @@
 
 
 /*
+ * Solaris 10+ complex.h defines _Complex_I and _Imaginary_I in terms of
+ * themselves, which are Sun Studio compiler intrinsics.  Remove _Imaginary_I
+ * and imaginary definitions which are not supported by GCC.
+ */
+fix = {
+    hackname  = solaris_complex;
+    mach      = "*-*-solaris2.*";
+    files     = complex.h;
+    select    = "#define[ \t]_Complex_I[ \t]_Complex_I";
+    sed	      = "s/#define[ \t]_Complex_I[ \t]_Complex_I/"
+		"#define\t_Complex_I\t\\(__extension__ 1.0iF\\)/";
+    sed	      = "/#define[ \t]_Imaginary_I[ \t]_Imaginary_I/d";
+    sed	      = "/#define[ \t]imaginary[ \t]_Imaginary/d";
+    sed       = "s/#define[ \t]I[ \t]\\+_Imaginary_I/#define\tI\t\t_Complex_I/";
+    test_text = "#define	_Complex_I	_Complex_I\n"
+    		"#define	complex		_Complex\n"
+		"#define	_Imaginary_I	_Imaginary_I\n"
+		"#define	imaginary	_Imaginary\n"
+		"#undef	I\n"
+		"#define	I		_Imaginary_I";
+};
+
+
+/*
  * Sun Solaris 10 defines several C99 math macros in terms of
  * builtins specific to the Studio compiler, in particular not
  * compatible with the GNU compiler.


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