public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [4.2 PATCH]: backport solaris11 c99-math fixincludes patch
@ 2008-02-27  8:18 Andreas Tobler
  2008-02-27 15:13 ` Kaveh R. GHAZI
  2008-02-29 18:52 ` Mark Mitchell
  0 siblings, 2 replies; 23+ messages in thread
From: Andreas Tobler @ 2008-02-27  8:18 UTC (permalink / raw)
  To: GCC Patches, Kaveh R. GHAZI

[-- Attachment #1: Type: text/plain, Size: 460 bytes --]

Hi all,

this patch implements the c99-math fixes on a different way than done on 
main and (future) 4.3.1.

Tested on solaris11 
(http://gcc.gnu.org/ml/gcc-testresults/2008-02/msg01590.html)

Ok for 4.2 iff the backport went in for 4.3.1?

Thanks,
Andreas

2008-02-27  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
	    Andreas Tobler  <a.tobler@schweiz.org>

	* inclhack.def (solaris_math_10): New.
	* tests/base/iso/math_c99.h: Update.
	* fixincl.x: Regenerate.

[-- Attachment #2: ff.diff --]
[-- Type: text/plain, Size: 2694 bytes --]

Index: inclhack.def
===================================================================
--- inclhack.def	(revision 132531)
+++ inclhack.def	(working copy)
@@ -3089,7 +3089,37 @@
     "#undef	isunordered\n"
     "#define	isunordered(x, y)	((x) __builtin_isunordered(y))";
 };
+/*
+ * On Solaris 11, if you do isinf(NaN) you'll get a floating point
+ * exception. Provide an alternative using GCC's builtin macros.
+ */
 
+fix = {
+    hackname  = solaris_math_10;
+    select    = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
+    files     = iso/math_c99.h;
+    c_fix     = format;
+    c_fix_arg = "#define isinf(x)\t__extension__ ( {\t\t\t\t\\\n"
+		"\t\t\tconst __typeof(x) __x_i = (x);\t\t\t\\\n"
+		"\t\t\t__builtin_expect(sizeof(__x_i) == sizeof(float)\t\\\n"
+		"\t\t\t? isgreater(__builtin_fabsf(__x_i),__FLT_MAX__) \\\n"
+		"\t\t\t: sizeof(__x_i) == sizeof(long double)\t\t\\\n"
+		"\t\t\t? isgreater(__builtin_fabsl(__x_i),__LDBL_MAX__)\\\n"
+		"\t\t\t: isgreater(__builtin_fabs(__x_i),__DBL_MAX__), 0);\\\n"
+		"\t})";
+    c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
+                "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);[ \t]*\\\\\n"
+                "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
+                "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*\\(-INFINITY\\);[ \t]*\\}\\)";
+    test_text =
+    '#pragma ident	"@(#)math_c99.h	1.12	07/01/21 SMI"'"\n"
+    "#undef	isinf\n"
+    "#define	isinf(x)	__extension__( \\\\\n"
+    "			{ __typeof(x) __x_i = (x); \\\\\n"
+    "			__x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
+    "			__x_i == (__typeof(__x_i)) (-INFINITY); })";
+};
+
 /*
  *  Sun Solaris 2.5.1, 2.6 defines PTHREAD_{MUTEX|COND}_INITIALIZER
  *  incorrectly, so we replace them with versions that correspond to
Index: tests/base/iso/math_c99.h
===================================================================
--- tests/base/iso/math_c99.h	(revision 132531)
+++ tests/base/iso/math_c99.h	(working copy)
@@ -117,3 +117,17 @@
 #undef	isunordered
 #define	isunordered(x, y)	__builtin_isunordered(x, y)
 #endif  /* SOLARIS_MATH_9_CHECK */
+
+
+#if defined( SOLARIS_MATH_10_CHECK )
+#pragma ident	"@(#)math_c99.h	1.12	07/01/21 SMI"
+#undef	isinf
+#define isinf(x)	__extension__ ( {				\
+			const __typeof(x) __x_i = (x);			\
+			__builtin_expect(sizeof(__x_i) == sizeof(float)	\
+			? isgreater(__builtin_fabsf(__x_i),__FLT_MAX__) \
+			: sizeof(__x_i) == sizeof(long double)		\
+			? isgreater(__builtin_fabsl(__x_i),__LDBL_MAX__)\
+			: isgreater(__builtin_fabs(__x_i),__DBL_MAX__), 0);\
+	})
+#endif  /* SOLARIS_MATH_10_CHECK */

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2008-03-15  0:05 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-27  8:18 [4.2 PATCH]: backport solaris11 c99-math fixincludes patch Andreas Tobler
2008-02-27 15:13 ` Kaveh R. GHAZI
2008-02-27 19:43   ` Andreas Tobler
2008-02-28  1:01     ` Richard Guenther
2008-03-01 16:06       ` Kaveh R. GHAZI
2008-03-01 16:43         ` Richard Guenther
2008-03-09 20:55       ` Status of the 4.1 branch (was: [4.2 PATCH]: backport solaris11 c99-math fixincludes patch) Gerald Pfeifer
2008-03-09 21:12         ` Richard Guenther
2008-03-09 22:44         ` Kaveh R. Ghazi
2008-03-13 13:03           ` Status of the 4.1 branch Gerald Pfeifer
2008-03-13 13:11             ` Richard Guenther
2008-03-13 15:59               ` Kaveh R. Ghazi
2008-03-13 18:49                 ` Gerald Pfeifer
2008-03-14 23:31                   ` Gabriel Dos Reis
2008-03-14 23:34                     ` Joseph S. Myers
2008-03-14 23:44                       ` Gabriel Dos Reis
2008-03-15  0:15                         ` Richard Guenther
2008-02-28 21:52     ` [4.2 PATCH]: backport solaris11 c99-math fixincludes patch Andreas Tobler
2008-02-29 18:52 ` Mark Mitchell
2008-03-12 21:50   ` Andreas Tobler
2008-03-12 22:27     ` Kaveh R. Ghazi
2008-03-12 22:37       ` Andreas Tobler
2008-03-13 21:37         ` Andreas Tobler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).