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]

__builtin_huge_val, __builtin_inf, and std::numeric_limits


Regression tested on i686-linux; tested that the warnings
worked like I want in C on vax-bsd.



r~


gcc/
        * builtin-types.def (BT_FN_FLOAT): New.
        (BT_FN_DOUBLE, BT_FN_LONG_DOUBLE): New.
        * builtins.def (BUILT_IN_INF, BUILT_IN_INFF, BUILT_IN_INFL,
        BUILT_IN_HUGE_VAL, BUILT_IN_HUGE_VALF, BUILT_IN_HUGE_VALL): New.
        * builtins.c (fold_builtin_inf): New.
        (fold_builtin): Call it.
        * real.c (ereal_inf): New.
        * real.h: Declare it.
        * doc/extend.texi: Document new builtins.

libstdc++/
        * include/std/std_limits.h (__glibcpp_f32_infinity_bytes,
        __glibcpp_f32_has_infinity, __glibcpp_f64_infinity_bytes,
        __glibcpp_f64_has_infinity, __glibcpp_f80_infinity_bytes,
        __glibcpp_f80_has_infinity, __glibcpp_f96_infinity_bytes,
        __glibcpp_f96_has_infinity, __glibcpp_f128_infinity_bytes,
        __glibcpp_f128_has_infinity, __glibcpp_float_infinity_bytes,
        __glibcpp_float_has_infinity, __glibcpp_double_infinity_bytes,
        __glibcpp_double_has_infinity, __glibcpp_long_double_infinity_bytes,
        __glibcpp_long_double_has_infinity): Remove.
        (std::numeric_limits<float>, std::numeric_limits<double>,
        std::numeric_limits<long double>): Use __builtin_huge_val
        to implement has_infinity and infinity().
        * src/limits.cc (__glibcpp_float_infinity, __glibcpp_double_infinity,
        __glibcpp_long_double_infinity): Remove.

Index: gcc/builtin-types.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/builtin-types.def,v
retrieving revision 1.7
diff -c -p -d -u -r1.7 builtin-types.def
--- gcc/builtin-types.def	29 Mar 2002 21:45:56 -0000	1.7
+++ gcc/builtin-types.def	4 Sep 2002 23:20:27 -0000
@@ -84,6 +84,9 @@ DEF_PRIMITIVE_TYPE (BT_VALIST_ARG, va_li
 DEF_FUNCTION_TYPE_0 (BT_FN_VOID, BT_VOID)
 DEF_FUNCTION_TYPE_0 (BT_FN_PTR, BT_PTR)
 DEF_FUNCTION_TYPE_0 (BT_FN_UNSIGNED, BT_UNSIGNED)
+DEF_FUNCTION_TYPE_0 (BT_FN_FLOAT, BT_FLOAT)
+DEF_FUNCTION_TYPE_0 (BT_FN_DOUBLE, BT_DOUBLE)
+DEF_FUNCTION_TYPE_0 (BT_FN_LONG_DOUBLE, BT_LONG_DOUBLE)
 
 DEF_FUNCTION_TYPE_1 (BT_FN_LONG_LONG, BT_LONG, BT_LONG)
 DEF_FUNCTION_TYPE_1 (BT_FN_LONGLONG_LONGLONG, BT_LONGLONG, BT_LONGLONG)
Index: gcc/builtins.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/builtins.c,v
retrieving revision 1.160
diff -c -p -d -u -r1.160 builtins.c
--- gcc/builtins.c	29 Aug 2002 19:19:59 -0000	1.160
+++ gcc/builtins.c	4 Sep 2002 23:20:27 -0000
@@ -148,6 +148,7 @@ static tree stabilize_va_list		PARAMS ((
 static rtx expand_builtin_expect	PARAMS ((tree, rtx));
 static tree fold_builtin_constant_p	PARAMS ((tree));
 static tree fold_builtin_classify_type	PARAMS ((tree));
+static tree fold_builtin_inf		PARAMS ((tree, int));
 static tree build_function_call_expr	PARAMS ((tree, tree));
 static int validate_arglist		PARAMS ((tree, ...));
 
@@ -4132,6 +4133,19 @@ fold_builtin_classify_type (arglist)
   return build_int_2 (type_to_class (TREE_TYPE (TREE_VALUE (arglist))), 0);
 }
 
+/* Fold a call to __builtin_inf or __builtin_huge_val.  */
+
+static tree
+fold_builtin_inf (type, warn)
+     tree type;
+     int warn;
+{
+  if (!MODE_HAS_INFINITIES (TYPE_MODE (type)) && warn)
+    warning ("target format does not support infinity");
+
+  return build_real (type, ereal_inf (TYPE_MODE (type)));
+}
+
 /* Used by constant folding to eliminate some builtin calls early.  EXP is
    the CALL_EXPR of a call to a builtin function.  */
 
@@ -4162,6 +4176,16 @@ fold_builtin (exp)
 	    return len;
 	}
       break;
+
+    case BUILT_IN_INF:
+    case BUILT_IN_INFF:
+    case BUILT_IN_INFL:
+      return fold_builtin_inf (TREE_TYPE (TREE_TYPE (fndecl)), true);
+
+    case BUILT_IN_HUGE_VAL:
+    case BUILT_IN_HUGE_VALF:
+    case BUILT_IN_HUGE_VALL:
+      return fold_builtin_inf (TREE_TYPE (TREE_TYPE (fndecl)), false);
 
     default:
       break;
Index: gcc/builtins.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/builtins.def,v
retrieving revision 1.34
diff -c -p -d -u -r1.34 builtins.def
--- gcc/builtins.def	3 Aug 2002 23:21:30 -0000	1.34
+++ gcc/builtins.def	4 Sep 2002 23:20:27 -0000
@@ -401,6 +401,32 @@ DEF_LIB_BUILTIN(BUILT_IN_LOGL,
 				   ? ATTR_CONST_NOTHROW_LIST
 				   : ATTR_PURE_NOTHROW_LIST))
 
+DEF_GCC_BUILTIN(BUILT_IN_INF,
+		"__builtin_inf",
+		BT_FN_DOUBLE,
+		ATTR_PURE_NOTHROW_LIST)
+DEF_GCC_BUILTIN(BUILT_IN_INFF,
+		"__builtin_inff",
+		BT_FN_FLOAT,
+		ATTR_PURE_NOTHROW_LIST)
+DEF_GCC_BUILTIN(BUILT_IN_INFL,
+		"__builtin_infl",
+		BT_FN_LONG_DOUBLE,
+		ATTR_PURE_NOTHROW_LIST)
+
+DEF_GCC_BUILTIN(BUILT_IN_HUGE_VAL,
+		"__builtin_huge_val",
+		BT_FN_DOUBLE,
+		ATTR_PURE_NOTHROW_LIST)
+DEF_GCC_BUILTIN(BUILT_IN_HUGE_VALF,
+		"__builtin_huge_valf",
+		BT_FN_FLOAT,
+		ATTR_PURE_NOTHROW_LIST)
+DEF_GCC_BUILTIN(BUILT_IN_HUGE_VALL,
+		"__builtin_huge_vall",
+		BT_FN_LONG_DOUBLE,
+		ATTR_PURE_NOTHROW_LIST)
+
 DEF_UNUSED_BUILTIN(BUILT_IN_GETEXP)
 DEF_UNUSED_BUILTIN(BUILT_IN_GETMAN)
 
Index: gcc/real.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/real.c,v
retrieving revision 1.76
diff -c -p -d -u -r1.76 real.c
--- gcc/real.c	4 Sep 2002 16:24:19 -0000	1.76
+++ gcc/real.c	4 Sep 2002 23:20:27 -0000
@@ -1818,8 +1818,8 @@ eisnan (x)
   return (0);
 }
 
-/*  Fill e-type number X with infinity pattern (IEEE)
-    or largest possible number (non-IEEE).  */
+/* Fill e-type number X with infinity pattern (IEEE)
+   or largest possible number (non-IEEE).  */
 
 static void
 einfin (x)
@@ -1858,6 +1858,49 @@ einfin (x)
 	}
     }
 #endif
+}
+
+/* Similar, except return it as a REAL_VALUE_TYPE.  */
+
+REAL_VALUE_TYPE
+ereal_inf (mode)
+     enum machine_mode mode;
+{
+  REAL_VALUE_TYPE r;
+  UEMUSHORT e[NE];
+  int prec, rndsav;
+
+  switch (mode)
+    {
+    case QFmode:
+    case SFmode:
+      prec = 24;
+      break;
+    case HFmode:
+    case DFmode:
+      prec = 53;
+      break;
+    case TFmode:
+      if (!INTEL_EXTENDED_IEEE_FORMAT)
+	{
+	  prec = 113;
+	  break;
+	}
+      /* FALLTHRU */
+    case XFmode:
+      prec = 64;
+      break;
+    default:
+      abort ();
+    }
+
+  rndsav = rndprc;
+  rndprc = prec;
+  einfin (e);
+  rndprc = rndsav;
+
+  PUT_REAL (e, &r);
+  return r;
 }
 
 /* Output an e-type NaN.
Index: gcc/real.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/real.h,v
retrieving revision 1.45
diff -c -p -d -u -r1.45 real.h
--- gcc/real.h	4 Sep 2002 16:24:20 -0000	1.45
+++ gcc/real.h	4 Sep 2002 23:20:27 -0000
@@ -292,6 +292,7 @@ extern int target_isinf		PARAMS ((REAL_V
 extern int target_negative	PARAMS ((REAL_VALUE_TYPE));
 extern void debug_real		PARAMS ((REAL_VALUE_TYPE));
 extern REAL_VALUE_TYPE ereal_atof PARAMS ((const char *, enum machine_mode));
+extern REAL_VALUE_TYPE ereal_inf PARAMS ((enum machine_mode));
 
 /* In tree.c: wrap up a REAL_VALUE_TYPE in a tree node.  */
 extern tree build_real			PARAMS ((tree, REAL_VALUE_TYPE));
Index: gcc/doc/extend.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/extend.texi,v
retrieving revision 1.96
diff -c -p -d -u -r1.96 extend.texi
--- gcc/doc/extend.texi	4 Sep 2002 17:35:58 -0000	1.96
+++ gcc/doc/extend.texi	4 Sep 2002 23:20:27 -0000
@@ -4833,6 +4833,36 @@ is evaluated if it includes side effects
 and GCC does not issue a warning.
 @end deftypefn
 
+@deftypefn {Built-in Function} double __builtin_huge_val (void)
+Returns a positive infinity, if supported by the floating-point format,
+else @code{DBL_MAX}.  This function is suitable for implementing the
+ISO C macro @code{HUGE_VAL}.
+@end deftypefn
+
+@deftypefn {Built-in Function} float __builtin_huge_valf (void)
+Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
+@end deftypefn
+
+@deftypefn {Built-in Function} long double __builtin_huge_vall (void)
+Similar to @code{__builtin_huge_val}, except the return
+type is @code{long double}.
+@end deftypefn
+
+@deftypefn {Built-in Function} double __builtin_inf (void)
+Similar to @code{__builtin_huge_val}, except a warning is generated
+if the target floating-point format does not support infinities.
+This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
+@end deftypefn
+
+@deftypefn {Built-in Function} float __builtin_inff (void)
+Similar to @code{__builtin_inf}, except the return type is @code{float}.
+@end deftypefn
+
+@deftypefn {Built-in Function} long double __builtin_infl (void)
+Similar to @code{__builtin_inf}, except the return
+type is @code{long double}.
+@end deftypefn
+
 @node Target Builtins
 @section Built-in Functions Specific to Particular Target Machines
 
Index: libstdc++-v3/include/std/std_limits.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/std/std_limits.h,v
retrieving revision 1.9
diff -c -p -d -u -r1.9 std_limits.h
--- libstdc++-v3/include/std/std_limits.h	3 Sep 2002 20:22:06 -0000	1.9
+++ libstdc++-v3/include/std/std_limits.h	4 Sep 2002 23:20:27 -0000
@@ -152,8 +152,6 @@
 
 #define __glibcpp_f32_round_error 1.0F
 #if __GCC_FLOAT_FORMAT__ == __IEEE_FORMAT__
-#  define __glibcpp_f32_infinity_bytes { 0x7f800000 }
-#  define __glibcpp_f32_has_infinity true
 #  define __glibcpp_f32_QNaN_bytes { 0x7fc00000 }
 #  define __glibcpp_f32_has_QNaN true
 #  define __glibcpp_f32_SNaN_bytes { 0x7f800001 }
@@ -162,10 +160,6 @@
 #  define __glibcpp_f32_has_denorm denorm_present
 #  define __glibcpp_f32_is_iec559  true
 #endif
-#ifndef __glibcpp_f32_infinity_bytes
-#  define __glibcpp_f32_infinity_bytes { }
-#  define __glibcpp_f32_has_infinity false
-#endif
 #ifndef __glibcpp_f32_QNaN_bytes
 #  define __glibcpp_f32_QNaN_bytes { }
 #  define __glibcpp_f32_has_QNaN false
@@ -184,26 +178,19 @@
 #define __glibcpp_f64_round_error 1.0
 #if __GCC_FLOAT_FORMAT__ == __IEEE_FORMAT__
 #  if __TARGET_FLOAT_WORDS_ORDER__ == __GCC_BIG_ENDIAN__
-#    define __glibcpp_f64_infinity_bytes { 0x7ff00000, 0x0 }
 #    define __glibcpp_f64_QNaN_bytes { 0x7ff80000, 0x0 }
 #    define __glibcpp_f64_SNaN_bytes { 0x7ff00000, 0x1 }
 #    define __glibcpp_f64_denorm_min_bytes { 0x0, 0x1 }
 #  else
-#    define __glibcpp_f64_infinity_bytes { 0x0, 0x7ff00000 }
 #    define __glibcpp_f64_QNaN_bytes { 0x0, 0x7ff80000 }
 #    define __glibcpp_f64_SNaN_bytes { 0x1, 0x7ff00000 }
 #    define __glibcpp_f64_denorm_min_bytes { 0x1, 0x0 }
 #  endif
-#  define __glibcpp_f64_has_infinity true
 #  define __glibcpp_f64_has_QNaN true
 #  define __glibcpp_f64_has_SNaN true
 #  define __glibcpp_f64_has_denorm denorm_present
 #  define __glibcpp_f64_is_iec559 true
 #endif
-#ifndef __glibcpp_f64_infinity_bytes
-#  define __glibcpp_f64_infinity_bytes { }
-#  define __glibcpp_f64_has_infinity false
-#endif
 #ifndef __glibcpp_f64_QNaN_bytes
 #  define __glibcpp_f64_QNaN_bytes { }
 #  define __glibcpp_f64_has_QNaN false
@@ -222,8 +209,6 @@
 #define __glibcpp_f80_round_error 1.0L
 #if __GCC_FLOAT_FORMAT__ == __IEEE_FORMAT__
 #  if __TARGET_BYTES_ORDER__ == __GCC_BIG_ENDIAN__
-#    define __glibcpp_f80_infinity_bytes   \
-       { 0x7f, 0xff, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }
 #    define __glibcpp_f80_QNaN_bytes       \
        { 0x7f, 0xff, 0xC0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }
 #    define __glibcpp_f80_SNaN_bytes       \
@@ -231,8 +216,6 @@
 #    define __glibcpp_f80_denorm_min_bytes \
        { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1 }
 #  else
-#    define __glibcpp_f80_infinity_bytes   \
-       { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x80, 0xff, 0x7f }
 #    define __glibcpp_f80_QNaN_bytes       \
        { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xC0, 0xff, 0x7f }
 #    define __glibcpp_f80_SNaN_bytes       \
@@ -240,16 +223,11 @@
 #    define __glibcpp_f80_denorm_min_bytes \
        { 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }
 #  endif
-#  define __glibcpp_f80_has_infinity true
 #  define __glibcpp_f80_has_QNaN true
 #  define __glibcpp_f80_has_SNaN true
 #  define __glibcpp_f80_has_denorm denorm_present
 #  define __glibcpp_f80_is_iec559 true
 #endif
-#ifndef __glibcpp_f80_infinity_bytes
-#  define __glibcpp_f80_infinity_bytes { }
-#  define __glibcpp_f80_has_infinity false
-#endif
 #ifndef __glibcpp_f80_QNaN_bytes
 #  define __glibcpp_f80_QNaN_bytes { }
 #  define __glibcpp_f80_has_QNaN false
@@ -268,26 +246,19 @@
 #define __glibcpp_f96_round_error 1.0L
 #if __GCC_FLOAT_FORMAT__ == __IEEE_FORMAT__
 #  if __TARGET_BYTES_ORDER__ == __GCC_BIG_ENDIAN__
-#    define __glibcpp_f96_infinity_bytes { 0x7ff0000, 0x0, 0x0 } 
 #    define __glibcpp_f96_QNaN_bytes { 0x7ff80000, 0x0, 0x0 }
 #    define __glibcpp_f96_SNaN_bytes { 0x7ff00000, 0x0, 0x1 }
 #    define __glibcpp_f96_denorm_min_bytes { 0x0, 0x0, 0x1 }
 #  else
-#    define __glibcpp_f96_infinity_bytes { 0x0, 0x0, 0x7ff0000 }
 #    define __glibcpp_f96_QNaN_bytes { 0x0, 0x0, 0x7ff80000 }
 #    define __glibcpp_f96_SNaN_bytes { 0x1, 0x0, 0x7ff00000 }
 #    define __glibcpp_f96_denorm_min_bytes { 0x1, 0x0, 0x0 }
 #  endif
-#  define __glibcpp_f96_has_infinity true
 #  define __glibcpp_f96_has_QNaN true
 #  define __glibcpp_f96_has_SNaN true
 #  define __glibcpp_f96_has_denorm denorm_present
 #  define __glibcpp_f96_is_iec559 true
 #endif
-#ifndef __glibcpp_f96_infinity_bytes
-#  define __glibcpp_f96_infinity_bytes { }
-#  define __glibcpp_f96_has_infinity false
-#endif
 #ifndef __glibcpp_f96_QNaN_bytes
 #  define __glibcpp_f96_QNaN_bytes { }
 #  define __glibcpp_f96_has_QNaN false
@@ -303,25 +274,18 @@
 #define __glibcpp_f128_round_error 1.0L
 #if __GCC_FLOAT_FORMAT__ == __IEEE_FORMAT__
 #  if __TARGET_FLOAT_WORDS_ORDER__ == __GCC_BIG_ENDIAN__
-#    define __glibcpp_f128_infinity_bytes { 0x7fff0000, 0x0, 0x0, 0x0 }
 #    define __glibcpp_f128_QNaN_bytes { 0x7fff0800, 0x0, 0x0, 0x0 }
 #    define __glibcpp_f128_SNaN_bytes { 0x7fff0000, 0x0, 0x0, 0x1 }
 #    define __glibcpp_f128_denorm_min_bytes { 0x0, 0x0, 0x0, 0x1 }
 #  else
-#    define __glibcpp_f128_infinity_bytes { 0x0, 0x0, 0x0, 0x7fff0000 }
 #    define __glibcpp_f128_QNaN_bytes { 0x0, 0x0, 0x0, 0x7fff0800 }
 #    define __glibcpp_f128_SNaN_bytes { 0x1, 0x0, 0x0, 0x7fff0000 }
 #    define __glibcpp_f128_denorm_min_bytes { 0x1, 0x0, 0x0, 0x0 }
 #  endif
-#  define __glibcpp_f128_has_infinity true
 #  define __glibcpp_f128_has_QNaN true
 #  define __glibcpp_f128_has_SNaN true
 #  define __glibcpp_f128_has_denorm denorm_present
 #endif
-#ifndef __glibcpp_f128_infinity_bytes
-#  define __glibcpp_f128_infinity_bytes { }
-#  define __glibcpp_f128_has_infinity false
-#endif
 #ifndef __glibcpp_f128_QNaN_bytes
 #  define __glibcpp_f128_QNaN_bytes { }
 #  define __glibcpp_f128_has_QNaN false
@@ -659,33 +623,27 @@
 
 #if __FLOAT_BIT__ == 32
 #  define __glibcpp_float_round_error __glibcpp_f32_round_error
-#  define __glibcpp_float_infinity_bytes __glibcpp_f32_infinity_bytes
 #  define __glibcpp_float_QNaN_bytes  __glibcpp_f32_QNaN_bytes
 #  define __glibcpp_float_SNaN_bytes  __glibcpp_f32_SNaN_bytes
 #  define __glibcpp_float_denorm_min_bytes  __glibcpp_f32_denorm_min_bytes
-#  define __glibcpp_float_has_infinity __glibcpp_f32_has_infinity
 #  define __glibcpp_float_has_QNaN __glibcpp_f32_has_QNaN
 #  define __glibcpp_float_has_SNaN __glibcpp_f32_has_SNaN
 #  define __glibcpp_float_has_denorm __glibcpp_f32_has_denorm
 #  define __glibcpp_float_is_iec559 __glibcpp_f32_is_iec559
 #elif __FLOAT_BIT__ == 64
 #  define __glibcpp_float_round_error __glibcpp_f64_round_error
-#  define __glibcpp_float_infinity_bytes __glibcpp_f64_infinity_bytes
 #  define __glibcpp_float_QNaN_bytes  __glibcpp_f64_QNaN_bytes
 #  define __glibcpp_float_SNaN_bytes  __glibcpp_f64_SNaN_bytes
 #  define __glibcpp_float_denorm_min_bytes  __glibcpp_f64_denorm_min_bytes
-#  define __glibcpp_float_has_infinity __glibcpp_f64_has_infinity
 #  define __glibcpp_float_has_QNaN __glibcpp_f64_has_QNaN
 #  define __glibcpp_float_has_SNaN __glibcpp_f64_has_SNaN
 #  define __glibcpp_float_has_denorm __glibcpp_f64_has_denorm
 #  define __glibcpp_float_is_iec559 __glibcpp_f64_is_iec559
 #elif __FLOAT_BIT__ == 80
 #  define __glibcpp_float_round_error __glibcpp_f80_round_error
-#  define __glibcpp_float_infinity_bytes __glibcpp_f80_infinity_bytes
 #  define __glibcpp_float_QNaN_bytes  __glibcpp_f80_QNaN_bytes
 #  define __glibcpp_float_SNaN_bytes  __glibcpp_f80_SNaN_bytes
 #  define __glibcpp_float_denorm_min_bytes  __glibcpp_f80_denorm_min_bytes
-#  define __glibcpp_float_has_infinity __glibcpp_f80_has_infinity
 #  define __glibcpp_float_has_QNaN __glibcpp_f80_has_QNaN
 #  define __glibcpp_float_has_SNaN __glibcpp_f80_has_SNaN
 #  define __glibcpp_float_has_denorm __glibcpp_f80_has_denorm
@@ -696,11 +654,6 @@
 
 // Default values.  Should be overriden in configuration files if necessary.
 
-#ifndef __glibcpp_float_infinity_bytes
-#  define __glibcpp_float_infinity_bytes { }
-#  define __glibcpp_float_has_infinty false
-#endif
-
 #ifndef __glibcpp_float_QNaN_bytes
 #  define __glibcpp_float_QNaN_bytes { }
 #  define __glibcpp_float_has_QNaN false
@@ -748,33 +701,27 @@
 
 #if __DOUBLE_BIT__ == 32
 #  define __glibcpp_double_round_error __glibcpp_f32_round_error
-#  define __glibcpp_double_infinity_bytes __glibcpp_f32_infinity_bytes
 #  define __glibcpp_double_QNaN_bytes __glibcpp_f32_QNaN_bytes
 #  define __glibcpp_double_SNaN_bytes __glibcpp_f32_SNaN_bytes
 #  define __glibcpp_double_denorm_min_bytes __glibcpp_f32_denorm_min_bytes
-#  define __glibcpp_double_has_infinity __glibcpp_f32_has_infinity
 #  define __glibcpp_double_has_QNaN __glibcpp_f32_has_QNaN
 #  define __glibcpp_double_has_SNaN __glibcpp_f32_has_SNaN
 #  define __glibcpp_double_has_denorm __glibcpp_f32_has_denorm
 #  define __glibcpp_double_is_iec559 __glibcpp_f32_is_iec559
 #elif __DOUBLE_BIT__ == 64
 #  define __glibcpp_double_round_error __glibcpp_f64_round_error
-#  define __glibcpp_double_infinity_bytes __glibcpp_f64_infinity_bytes
 #  define __glibcpp_double_QNaN_bytes __glibcpp_f64_QNaN_bytes
 #  define __glibcpp_double_SNaN_bytes __glibcpp_f64_SNaN_bytes
 #  define __glibcpp_double_denorm_min_bytes __glibcpp_f64_denorm_min_bytes
-#  define __glibcpp_double_has_infinity __glibcpp_f64_has_infinity
 #  define __glibcpp_double_has_QNaN __glibcpp_f64_has_QNaN
 #  define __glibcpp_double_has_SNaN __glibcpp_f64_has_SNaN
 #  define __glibcpp_double_has_denorm __glibcpp_f64_has_denorm
 #  define __glibcpp_double_is_iec559 __glibcpp_f64_is_iec559
 #elif __DOUBLE_BIT__ == 80
 #  define __glibcpp_double_round_error __glibcpp_f80_round_error
-#  define __glibcpp_double_infinity_bytes __glibcpp_f80_infinity_bytes
 #  define __glibcpp_double_QNaN_bytes __glibcpp_f80_QNaN_bytes
 #  define __glibcpp_double_SNaN_bytes __glibcpp_f80_SNaN_bytes
 #  define __glibcpp_double_denorm_min_bytes __glibcpp_f80_denorm_min_bytes
-#  define __glibcpp_double_has_infinity __glibcpp_f80_has_infinity
 #  define __glibcpp_double_has_QNaN __glibcpp_f80_has_QNaN
 #  define __glibcpp_double_has_SNaN __glibcpp_f80_has_SNaN
 #  define __glibcpp_double_has_denorm __glibcpp_f80_has_denorm
@@ -785,11 +732,6 @@
 
 // Default values.  Should be overriden in configuration files if necessary.
 
-#ifndef __glibcpp_double_infinity_bytes
-#  define __glibcpp_double_infinity_bytes { }
-#  define __glibcpp_double_has_infinty false
-#endif
-
 #ifndef __glibcpp_double_QNaN_bytes
 #  define __glibcpp_double_QNaN_bytes { }
 #  define __glibcpp_double_has_QNaN false
@@ -837,55 +779,45 @@
 
 #if __LONG_DOUBLE_BIT__ == 32
 #  define __glibcpp_long_double_round_error __glibcpp_f32_round_error
-#  define __glibcpp_long_double_infinity_bytes __glibcpp_f32_infinity_bytes
 #  define __glibcpp_long_double_QNaN_bytes __glibcpp_f32_QNaN_bytes
 #  define __glibcpp_long_double_SNaN_bytes __glibcpp_f32_SNaN_bytes
 #  define __glibcpp_long_double_denorm_min_bytes __glibcpp_f32_denorm_min_bytes
-#  define __glibcpp_long_double_has_infinity __glibcpp_f32_has_infinity
 #  define __glibcpp_long_double_has_QNaN __glibcpp_f32_has_QNaN
 #  define __glibcpp_long_double_has_SNaN __glibcpp_f32_has_SNaN
 #  define __glibcpp_long_double_has_denorm __glibcpp_f32_has_denorm
 #  define __glibcpp_long_double_is_iec559 __glibcpp_f32_is_iec559
 #elif __LONG_DOUBLE_BIT__ == 64
 #  define __glibcpp_long_double_round_error __glibcpp_f64_round_error
-#  define __glibcpp_long_double_infinity_bytes __glibcpp_f64_infinity_bytes
 #  define __glibcpp_long_double_QNaN_bytes __glibcpp_f64_QNaN_bytes
 #  define __glibcpp_long_double_SNaN_bytes __glibcpp_f64_SNaN_bytes
 #  define __glibcpp_long_double_denorm_min_bytes __glibcpp_f64_denorm_min_bytes
-#  define __glibcpp_long_double_has_infinity __glibcpp_f64_has_infinity
 #  define __glibcpp_long_double_has_QNaN __glibcpp_f64_has_QNaN
 #  define __glibcpp_long_double_has_SNaN __glibcpp_f64_has_SNaN
 #  define __glibcpp_long_double_has_denorm __glibcpp_f64_has_denorm
 #  define __glibcpp_long_double_is_iec559 __glibcpp_f64_is_iec559
 #elif __LONG_DOUBLE_BIT__ == 80
 #  define __glibcpp_long_double_round_error __glibcpp_f80_round_error
-#  define __glibcpp_long_double_infinity_bytes __glibcpp_f80_infinity_bytes
 #  define __glibcpp_long_double_QNaN_bytes __glibcpp_f80_QNaN_bytes
 #  define __glibcpp_long_double_SNaN_bytes __glibcpp_f80_SNaN_bytes
 #  define __glibcpp_long_double_denorm_min_bytes __glibcpp_f80_denorm_min_bytes
-#  define __glibcpp_long_double_has_infinity __glibcpp_f80_has_infinity
 #  define __glibcpp_long_double_has_QNaN __glibcpp_f80_has_QNaN
 #  define __glibcpp_long_double_has_SNaN __glibcpp_f80_has_SNaN
 #  define __glibcpp_long_double_has_denorm __glibcpp_f80_has_denorm
 #  define __glibcpp_long_double_is_iec559 __glibcpp_f80_is_iec559
 #elif __LONG_DOUBLE_BIT__ == 96
 #  define __glibcpp_long_double_round_error __glibcpp_f96_round_error
-#  define __glibcpp_long_double_infinity_bytes __glibcpp_f96_infinity_bytes
 #  define __glibcpp_long_double_QNaN_bytes __glibcpp_f96_QNaN_bytes
 #  define __glibcpp_long_double_SNaN_bytes __glibcpp_f96_SNaN_bytes
 #  define __glibcpp_long_double_denorm_min_bytes __glibcpp_f96_denorm_min_bytes
-#  define __glibcpp_long_double_has_infinity __glibcpp_f96_has_infinity
 #  define __glibcpp_long_double_has_QNaN __glibcpp_f96_has_QNaN
 #  define __glibcpp_long_double_has_SNaN __glibcpp_f96_has_SNaN
 #  define __glibcpp_long_double_has_denorm __glibcpp_f96_has_denorm
 #  define __glibcpp_long_double_is_iec559 __glibcpp_f96_is_iec559
 #elif __LONG_DOUBLE_BIT__ == 128
 #  define __glibcpp_long_double_round_error __glibcpp_f128_round_error
-#  define __glibcpp_long_double_infinity_bytes __glibcpp_f128_infinity_bytes
 #  define __glibcpp_long_double_QNaN_bytes __glibcpp_f128_QNaN_bytes
 #  define __glibcpp_long_double_SNaN_bytes __glibcpp_f128_SNaN_bytes
 #  define __glibcpp_long_double_denorm_min_bytes __glibcpp_f128_denorm_min_bytes
-#  define __glibcpp_long_double_has_infinity __glibcpp_f128_has_infinity
 #  define __glibcpp_long_double_has_QNaN __glibcpp_f128_has_QNaN
 #  define __glibcpp_long_double_has_SNaN __glibcpp_f128_has_SNaN
 #  define __glibcpp_long_double_has_denorm __glibcpp_f128_has_denorm
@@ -896,11 +828,6 @@
 
 // Default values.  Should be overriden in configuration files if necessary.
 
-#ifndef __glibcpp_long_double_infinity_bytes
-#  define __glibcpp_long_double_infinity_bytes { }
-#  define __glibcpp_long_double_has_infinty false
-#endif
-
 #ifndef __glibcpp_long_double_QNaN_bytes
 #  define __glibcpp_long_double_QNaN_bytes { }
 #  define __glibcpp_long_double_has_QNaN false
@@ -989,17 +916,14 @@ namespace std
 #endif  
     __attribute__((__aligned__(__alignof__(long double))));
 
-  extern const __float_storage __glibcpp_float_infinity;
   extern const __float_storage __glibcpp_float_QNaN;
   extern const __float_storage __glibcpp_float_SNaN;
   extern const __float_storage __glibcpp_float_denorm_min;
   
-  extern const __double_storage __glibcpp_double_infinity;
   extern const __double_storage __glibcpp_double_QNaN;
   extern const __double_storage __glibcpp_double_SNaN;
   extern const __double_storage __glibcpp_double_denorm_min;
 
-  extern const __long_double_storage __glibcpp_long_double_infinity;
   extern const __long_double_storage __glibcpp_long_double_QNaN;
   extern const __long_double_storage __glibcpp_long_double_SNaN;
   extern const __long_double_storage __glibcpp_long_double_denorm_min;
@@ -1830,14 +1754,15 @@ namespace std
       static const int max_exponent = __FLT_MAX_EXP__;
       static const int max_exponent10 = __FLT_MAX_10_EXP__;
 
-      static const bool has_infinity = __glibcpp_float_has_infinity;
+      static const bool has_infinity
+	= __builtin_huge_valf () / 2 == __builtin_huge_valf ();
       static const bool has_quiet_NaN = __glibcpp_float_has_QNaN;
       static const bool has_signaling_NaN = __glibcpp_float_has_SNaN;
       static const float_denorm_style has_denorm = __glibcpp_float_has_denorm;
       static const bool has_denorm_loss = __glibcpp_float_has_denorm_loss;
 
       static float infinity() throw()
-      { return *reinterpret_cast<const float*>(__glibcpp_float_infinity); }
+      { return __builtin_huge_valf (); }
       static float quiet_NaN() throw()
       { return *reinterpret_cast<const float*>(__glibcpp_float_QNaN); }
       static float signaling_NaN() throw()
@@ -1855,7 +1780,6 @@ namespace std
     };
 
 #undef __glibcpp_float_round_error
-#undef __glibcpp_float_has_infinity
 #undef __glibcpp_float_has_QNaN
 #undef __glibcpp_float_has_SNaN
 #undef __glibcpp_float_has_denorm
@@ -1893,7 +1817,8 @@ namespace std
       static const int max_exponent = __DBL_MAX_EXP__;
       static const int max_exponent10 = __DBL_MAX_10_EXP__;
 
-      static const bool has_infinity = __glibcpp_double_has_infinity;
+      static const bool has_infinity
+	= __builtin_huge_val () / 2 == __builtin_huge_val ();
       static const bool has_quiet_NaN = __glibcpp_double_has_QNaN;
       static const bool has_signaling_NaN = __glibcpp_double_has_SNaN;
       static const float_denorm_style has_denorm =
@@ -1901,7 +1826,7 @@ namespace std
       static const bool has_denorm_loss = __glibcpp_double_has_denorm_loss;
 
       static double infinity() throw()
-      { return *reinterpret_cast<const double*>(__glibcpp_double_infinity); }
+      { return __builtin_huge_val(); }
       static double quiet_NaN() throw()
       { return *reinterpret_cast<const double*>(__glibcpp_double_QNaN); }
       static double signaling_NaN() throw()
@@ -1920,7 +1845,6 @@ namespace std
     };
 
 #undef __glibcpp_double_round_error
-#undef __glibcpp_double_has_infinity
 #undef __glibcpp_double_has_QNaN
 #undef __glibcpp_double_has_SNaN
 #undef __glibcpp_double_has_denorm
@@ -1959,7 +1883,8 @@ namespace std
       static const int max_exponent = __LDBL_MAX_EXP__;
       static const int max_exponent10 = __LDBL_MAX_10_EXP__;
 
-      static const bool has_infinity = __glibcpp_long_double_has_infinity;
+      static const bool has_infinity
+	= __builtin_huge_vall () / 2 == __builtin_huge_vall ();
       static const bool has_quiet_NaN = __glibcpp_long_double_has_SNaN;
       static const bool has_signaling_NaN = __glibcpp_long_double_has_SNaN;
       static const float_denorm_style has_denorm =
@@ -1968,10 +1893,7 @@ namespace std
                 __glibcpp_long_double_has_denorm_loss;
 
       static long double infinity() throw()
-      {
-        return *reinterpret_cast<const long double*>
-          (__glibcpp_long_double_infinity);
-      } 
+      { return __builtin_huge_vall (); } 
 
       static long double quiet_NaN() throw()
       {
@@ -2002,7 +1924,6 @@ namespace std
     };
 
 #undef __glibcpp_long_double_round_error
-#undef __glibcpp_long_double_has_infinity
 #undef __glibcpp_long_double_has_QNaN
 #undef __glibcpp_long_double_has_SNaN
 #undef __glibcpp_long_double_has_denorm
Index: libstdc++-v3/src/limits.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/limits.cc,v
retrieving revision 1.6
diff -c -p -d -u -r1.6 limits.cc
--- libstdc++-v3/src/limits.cc	27 Aug 2002 20:30:26 -0000	1.6
+++ libstdc++-v3/src/limits.cc	4 Sep 2002 23:20:27 -0000
@@ -38,22 +38,16 @@
 
 namespace std 
 {
-  const __float_storage __glibcpp_float_infinity =
-    __glibcpp_float_infinity_bytes;
   const __float_storage __glibcpp_float_QNaN = __glibcpp_float_QNaN_bytes;
   const __float_storage __glibcpp_float_SNaN = __glibcpp_float_SNaN_bytes;
   const __float_storage __glibcpp_float_denorm_min =
     __glibcpp_float_denorm_min_bytes;
 
-  const __double_storage __glibcpp_double_infinity =
-    __glibcpp_double_infinity_bytes;
   const __double_storage __glibcpp_double_QNaN = __glibcpp_double_QNaN_bytes;
   const __double_storage __glibcpp_double_SNaN = __glibcpp_double_SNaN_bytes;
   const __double_storage __glibcpp_double_denorm_min =
     __glibcpp_double_denorm_min_bytes;
 
-  const __long_double_storage __glibcpp_long_double_infinity =
-    __glibcpp_long_double_infinity_bytes;
   const __long_double_storage __glibcpp_long_double_QNaN =
     __glibcpp_long_double_QNaN_bytes;
   const __long_double_storage __glibcpp_long_double_SNaN =


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