aboutsummaryrefslogtreecommitdiff
path: root/fixincludes
diff options
context:
space:
mode:
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>2007-07-18 20:22:32 +0000
committerKaveh Ghazi <ghazi@gcc.gnu.org>2007-07-18 20:22:32 +0000
commitdadda6caba15b21a03e9522ca5cce41e2c2d270b (patch)
treecbf2a3e15dd08f11a41d46289515a304aec79ed0 /fixincludes
parent2a48b790b26895fd7fb56c9ce1d64f083dd278bb (diff)
downloadgcc-dadda6caba15b21a03e9522ca5cce41e2c2d270b.zip
gcc-dadda6caba15b21a03e9522ca5cce41e2c2d270b.tar.gz
gcc-dadda6caba15b21a03e9522ca5cce41e2c2d270b.tar.bz2
re PR target/32641 (C99 fpclassify, isinf, isfinite, isnormal may raise FP exceptions)
fixincludes: PR target/32641 * inclhack.def (solaris_math_4, solaris_math_5, solaris_math_6, solaris_math_7): Constify and make FP exception-safe. * tests/base/iso/math_c99.h: Update. * fixincl.x: Regenerate. gcc/testsuite: * gcc.dg/c99-math-double-1.c: Mark test variables as volatile. Test negative numbers also. * gcc.dg/c99-math-float-1.c: Likewise. * gcc.dg/c99-math-long-double-1.c: Likewise. * gcc.dg/c99-math.h: Check for FP exceptions. Update for negative test inputs. From-SVN: r126730
Diffstat (limited to 'fixincludes')
-rw-r--r--fixincludes/ChangeLog10
-rw-r--r--fixincludes/fixincl.x31
-rw-r--r--fixincludes/inclhack.def27
-rw-r--r--fixincludes/tests/base/iso/math_c99.h27
4 files changed, 63 insertions, 32 deletions
diff --git a/fixincludes/ChangeLog b/fixincludes/ChangeLog
index 526e003..eb1e719 100644
--- a/fixincludes/ChangeLog
+++ b/fixincludes/ChangeLog
@@ -1,3 +1,13 @@
+2007-07-18 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ PR target/32641
+
+ * inclhack.def (solaris_math_4, solaris_math_5, solaris_math_6,
+ solaris_math_7): Constify and make FP exception-safe.
+ * tests/base/iso/math_c99.h: Update.
+
+ * fixincl.x: Regenerate.
+
2007-07-05 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
PR libgcj/28190
diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x
index f6288d2..41818d5 100644
--- a/fixincludes/fixincl.x
+++ b/fixincludes/fixincl.x
@@ -2,11 +2,11 @@
*
* DO NOT EDIT THIS FILE (fixincl.x)
*
- * It has been AutoGen-ed Friday June 29, 2007 at 06:59:26 PM MEST
+ * It has been AutoGen-ed Saturday July 7, 2007 at 11:23:30 PM EDT
* From the definitions inclhack.def
* and the template file fixincl
*/
-/* DO NOT SVN-MERGE THIS FILE, EITHER Fri Jun 29 18:59:26 MEST 2007
+/* DO NOT SVN-MERGE THIS FILE, EITHER Sat Jul 7 23:23:30 EDT 2007
*
* You must regenerate it. Use the ./genfixes script.
*
@@ -5629,7 +5629,7 @@ static tTestDesc aSolaris_Math_4Tests[] = {
static const char* apzSolaris_Math_4Patch[] = {
"format",
"#define\tfpclassify(x) \\\n\
- __extension__ ({ __typeof(x) __x_fp = (x); \\\n\
+ __extension__ ({ const __typeof(x) __x_fp = (x); \\\n\
\t\t isnan(__x_fp) \\\n\
\t\t ? FP_NAN \\\n\
\t\t : isinf(__x_fp) \\\n\
@@ -5682,8 +5682,12 @@ static tTestDesc aSolaris_Math_5Tests[] = {
static const char* apzSolaris_Math_5Patch[] = {
"format",
"#define\tisfinite(x) \\\n\
- __extension__ ({ __typeof (x) __x_f = (x); \\\n\
-\t\t __builtin_expect(!isnan(__x_f - __x_f), 1); })",
+ __extension__ ({ const __typeof (x) __x_f = (x); \\\n\
+\t\t __builtin_expect(sizeof(__x_f) == sizeof(float) \\\n\
+\t\t\t ? islessequal(__builtin_fabsf(__x_f),__FLT_MAX__) \\\n\
+\t\t\t : sizeof(__x_f) == sizeof(long double) \\\n\
+\t\t\t ? islessequal(__builtin_fabsl(__x_f),__LDBL_MAX__) \\\n\
+\t\t\t : islessequal(__builtin_fabs(__x_f),__DBL_MAX__), 1); })",
"^#define[ \t]+isfinite\\(x\\)[ \t]+__builtin_isfinite\\(x\\)",
(char*)NULL };
@@ -5727,8 +5731,12 @@ static tTestDesc aSolaris_Math_6Tests[] = {
static const char* apzSolaris_Math_6Patch[] = {
"format",
"#define\tisinf(x) \\\n\
- __extension__ ({ __typeof (x) __x_i = (x); \\\n\
-\t\t __builtin_expect(!isnan(__x_i) && !isfinite(__x_i), 0); })",
+ __extension__ ({ const __typeof (x) __x_i = (x); \\\n\
+\t\t __builtin_expect(sizeof(__x_i) == sizeof(float) \\\n\
+\t\t\t ? isgreater(__builtin_fabsf(__x_i),__FLT_MAX__) \\\n\
+\t\t\t : sizeof(__x_i) == sizeof(long double) \\\n\
+\t\t\t ? isgreater(__builtin_fabsl(__x_i),__LDBL_MAX__) \\\n\
+\t\t\t : isgreater(__builtin_fabs(__x_i),__DBL_MAX__), 0); })",
"^#define[ \t]+isinf\\(x\\)[ \t]+__builtin_isinf\\(x\\)",
(char*)NULL };
@@ -5772,14 +5780,13 @@ static tTestDesc aSolaris_Math_7Tests[] = {
static const char* apzSolaris_Math_7Patch[] = {
"format",
"#define\tisnormal(x) \\\n\
- __extension__ ({ __typeof(x) __x_n = (x); \\\n\
-\t\t if (__x_n < 0.0) __x_n = -__x_n; \\\n\
+ __extension__ ({ const __typeof(x) __x_n = (x); \\\n\
\t\t __builtin_expect(isfinite(__x_n) \\\n\
\t\t\t\t && (sizeof(__x_n) == sizeof(float) \\\n\
-\t\t\t\t\t ? __x_n >= __FLT_MIN__ \\\n\
+\t\t\t\t\t ? isgreaterequal(__builtin_fabsf(__x_n),__FLT_MIN__) \\\n\
\t\t\t\t\t : sizeof(__x_n) == sizeof(long double) \\\n\
-\t\t\t\t\t ? __x_n >= __LDBL_MIN__ \\\n\
-\t\t\t\t\t : __x_n >= __DBL_MIN__), 1); })",
+\t\t\t\t\t ? isgreaterequal(__builtin_fabsl(__x_n),__LDBL_MIN__) \\\n\
+\t\t\t\t\t : isgreaterequal(__builtin_fabs(__x_n),__DBL_MIN__)), 1); })",
"^#define[ \t]+isnormal\\(x\\)[ \t]+__builtin_isnormal\\(x\\)",
(char*)NULL };
diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def
index f7f9888..fbc1b2a 100644
--- a/fixincludes/inclhack.def
+++ b/fixincludes/inclhack.def
@@ -3088,7 +3088,7 @@ fix = {
files = iso/math_c99.h;
c_fix = format;
c_fix_arg = "#define\tfpclassify(x) \\\n"
- " __extension__ ({ __typeof(x) __x_fp = (x); \\\n"
+ " __extension__ ({ const __typeof(x) __x_fp = (x); \\\n"
"\t\t isnan(__x_fp) \\\n"
"\t\t ? FP_NAN \\\n"
"\t\t : isinf(__x_fp) \\\n"
@@ -3112,8 +3112,12 @@ fix = {
files = iso/math_c99.h;
c_fix = format;
c_fix_arg = "#define\tisfinite(x) \\\n"
- " __extension__ ({ __typeof (x) __x_f = (x); \\\n"
- "\t\t __builtin_expect(!isnan(__x_f - __x_f), 1); })";
+ " __extension__ ({ const __typeof (x) __x_f = (x); \\\n"
+ "\t\t __builtin_expect(sizeof(__x_f) == sizeof(float) \\\n"
+ "\t\t\t ? islessequal(__builtin_fabsf(__x_f),__FLT_MAX__) \\\n"
+ "\t\t\t : sizeof(__x_f) == sizeof(long double) \\\n"
+ "\t\t\t ? islessequal(__builtin_fabsl(__x_f),__LDBL_MAX__) \\\n"
+ "\t\t\t : islessequal(__builtin_fabs(__x_f),__DBL_MAX__), 1); })";
c_fix_arg = "^#define[ \t]+isfinite\\(x\\)[ \t]+__builtin_isfinite\\(x\\)";
test_text =
'#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
@@ -3128,8 +3132,12 @@ fix = {
files = iso/math_c99.h;
c_fix = format;
c_fix_arg = "#define\tisinf(x) \\\n"
- " __extension__ ({ __typeof (x) __x_i = (x); \\\n"
- "\t\t __builtin_expect(!isnan(__x_i) && !isfinite(__x_i), 0); })";
+ " __extension__ ({ const __typeof (x) __x_i = (x); \\\n"
+ "\t\t __builtin_expect(sizeof(__x_i) == sizeof(float) \\\n"
+ "\t\t\t ? isgreater(__builtin_fabsf(__x_i),__FLT_MAX__) \\\n"
+ "\t\t\t : sizeof(__x_i) == sizeof(long double) \\\n"
+ "\t\t\t ? isgreater(__builtin_fabsl(__x_i),__LDBL_MAX__) \\\n"
+ "\t\t\t : isgreater(__builtin_fabs(__x_i),__DBL_MAX__), 0); })";
c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__builtin_isinf\\(x\\)";
test_text =
'#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
@@ -3144,14 +3152,13 @@ fix = {
files = iso/math_c99.h;
c_fix = format;
c_fix_arg = "#define\tisnormal(x) \\\n"
- " __extension__ ({ __typeof(x) __x_n = (x); \\\n"
- "\t\t if (__x_n < 0.0) __x_n = -__x_n; \\\n"
+ " __extension__ ({ const __typeof(x) __x_n = (x); \\\n"
"\t\t __builtin_expect(isfinite(__x_n) \\\n"
"\t\t\t\t && (sizeof(__x_n) == sizeof(float) \\\n"
- "\t\t\t\t\t ? __x_n >= __FLT_MIN__ \\\n"
+ "\t\t\t\t\t ? isgreaterequal(__builtin_fabsf(__x_n),__FLT_MIN__) \\\n"
"\t\t\t\t\t : sizeof(__x_n) == sizeof(long double) \\\n"
- "\t\t\t\t\t ? __x_n >= __LDBL_MIN__ \\\n"
- "\t\t\t\t\t : __x_n >= __DBL_MIN__), 1); })";
+ "\t\t\t\t\t ? isgreaterequal(__builtin_fabsl(__x_n),__LDBL_MIN__) \\\n"
+ "\t\t\t\t\t : isgreaterequal(__builtin_fabs(__x_n),__DBL_MIN__)), 1); })";
c_fix_arg = "^#define[ \t]+isnormal\\(x\\)[ \t]+__builtin_isnormal\\(x\\)";
test_text =
'#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
diff --git a/fixincludes/tests/base/iso/math_c99.h b/fixincludes/tests/base/iso/math_c99.h
index 86b6c20..bc2b653 100644
--- a/fixincludes/tests/base/iso/math_c99.h
+++ b/fixincludes/tests/base/iso/math_c99.h
@@ -38,7 +38,7 @@
#ident "@(#)math_c99.h 1.9 04/11/01 SMI"
#undef fpclassify
#define fpclassify(x) \
- __extension__ ({ __typeof(x) __x_fp = (x); \
+ __extension__ ({ const __typeof(x) __x_fp = (x); \
isnan(__x_fp) \
? FP_NAN \
: isinf(__x_fp) \
@@ -55,8 +55,12 @@
#ident "@(#)math_c99.h 1.9 04/11/01 SMI"
#undef isfinite
#define isfinite(x) \
- __extension__ ({ __typeof (x) __x_f = (x); \
- __builtin_expect(!isnan(__x_f - __x_f), 1); })
+ __extension__ ({ const __typeof (x) __x_f = (x); \
+ __builtin_expect(sizeof(__x_f) == sizeof(float) \
+ ? islessequal(__builtin_fabsf(__x_f),__FLT_MAX__) \
+ : sizeof(__x_f) == sizeof(long double) \
+ ? islessequal(__builtin_fabsl(__x_f),__LDBL_MAX__) \
+ : islessequal(__builtin_fabs(__x_f),__DBL_MAX__), 1); })
#endif /* SOLARIS_MATH_5_CHECK */
@@ -64,8 +68,12 @@
#ident "@(#)math_c99.h 1.9 04/11/01 SMI"
#undef isinf
#define isinf(x) \
- __extension__ ({ __typeof (x) __x_i = (x); \
- __builtin_expect(!isnan(__x_i) && !isfinite(__x_i), 0); })
+ __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_6_CHECK */
@@ -73,14 +81,13 @@
#ident "@(#)math_c99.h 1.9 04/11/01 SMI"
#undef isnormal
#define isnormal(x) \
- __extension__ ({ __typeof(x) __x_n = (x); \
- if (__x_n < 0.0) __x_n = -__x_n; \
+ __extension__ ({ const __typeof(x) __x_n = (x); \
__builtin_expect(isfinite(__x_n) \
&& (sizeof(__x_n) == sizeof(float) \
- ? __x_n >= __FLT_MIN__ \
+ ? isgreaterequal(__builtin_fabsf(__x_n),__FLT_MIN__) \
: sizeof(__x_n) == sizeof(long double) \
- ? __x_n >= __LDBL_MIN__ \
- : __x_n >= __DBL_MIN__), 1); })
+ ? isgreaterequal(__builtin_fabsl(__x_n),__LDBL_MIN__) \
+ : isgreaterequal(__builtin_fabs(__x_n),__DBL_MIN__)), 1); })
#endif /* SOLARIS_MATH_7_CHECK */