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]

[libstdc++] numeric_limits: is_modulo, traps, is_bounded


First, GCC does not support any targets for which is_modulo is false
for an integer type.  This is made obvious by the fact that we do not
distinguish between signed and unsigned rtl modes, and eg do not have
different patterns for signed and unsigned addition.  Thus is_modulo
should always be true for the integral types.

Second, once is_modulo is set to true, the only other exceptional
condition for integral operations is division by zero.  Now, as it
happens, I don't know of any targets for which division by zero is
not signaled in some manner.  But I could go out on a limb and
imagine an embedded target for which the abort in __divsi3 was 
removed for space considerations.  (Of course, I seriously doubt
that that same target will be interested in the size of libstdc++.)
Anyway, I left exactly one target option, __glibcpp_integral_traps,
instead of 17 inconsistently used options.

Finally, is_bounded is, for whatever reason, only defined by LIA-1
for integral types.  I guess floating-point bignums aren't common
enough for them to consider.  And even if it weren't the definition
is "true if the set of values representable by the type is finite."
Which is definitely true of any fixed sized object, which is 
definitely true of any built-in type.


Ok?


r~


	* include/std/std_limits.h (__glibcpp_integral_traps): New.
	(__glibcpp_char_traps, __glibcpp_short_traps, __glibcpp_int_traps,
	__glibcpp_long_traps, __glibcpp_wchar_t_traps,
	__glibcpp_long_long_traps, __glibcpp_plain_char_traps,
	__glibcpp_signed_char_traps, __glibcpp_unsigned_char_traps,
	__glibcpp_signed_short_traps, __glibcpp_unsigned_short_traps,
	__glibcpp_signed_int_traps, __glibcpp_unsigned_int_traps,
	__glibcpp_signed_long_traps, __glibcpp_unsigned_long_traps,
	__glibcpp_signed_long_long_traps, __glibcpp_unsigned_long_long_traps,
	__glibcpp_char_is_modulo, __glibcpp_signed_char_is_modulo,
	__glibcpp_signed_short_is_modulo, __glibcpp_signed_int_is_modulo,
	__glibcpp_signed_long_is_modulo, __glibcpp_signed_long_long_is_modulo,
	__glibcpp_wchar_t_is_modulo, __glibcpp_float_is_bounded,
	__glibcpp_double_is_bounded, __glibcpp_long_double_is_bounded): Kill.
	(numeric_limits<T>::traps, T integral): Use __glibcpp_integral_traps.
	(numeric_limits<T>::is_modulo, T integral): Use true.
	(numeric_limits<T>::is_bounded, T floating): Use true.

--- std_limits.h.orig	Sat Sep 21 11:43:08 2002
+++ std_limits.h	Sat Sep 21 12:28:18 2002
@@ -92,23 +92,11 @@
 // These values can be overridden in the target configuration file.
 // The default values are appropriate for many 32-bit targets.
 
-#ifndef __glibcpp_char_traps
-#  define __glibcpp_char_traps true
-#endif
-#ifndef __glibcpp_short_traps
-#  define __glibcpp_short_traps true
-#endif
-#ifndef __glibcpp_int_traps
-#  define __glibcpp_int_traps true
-#endif
-#ifndef __glibcpp_long_traps
-#  define __glibcpp_long_traps true
-#endif
-#ifndef __glibcpp_wchar_t_traps
-#  define __glibcpp_wchar_t_traps true
-#endif
-#ifndef __glibcpp_long_long_traps
-#  define __glibcpp_long_long_traps true
+// GCC only intrinsicly supports modulo integral types.  The only remaining
+// integral exceptional values is division by zero.  Only targets that do not
+// signal division by zero in some "hard to ignore" way should use false.
+#ifndef __glibcpp_integral_traps
+# define __glibcpp_integral_traps true
 #endif
 
 // You should not need to define any macros below this point, unless
@@ -151,7 +139,7 @@
 #define __glibcpp_u64_digits10 19
 
 // bool-specific hooks:
-//     __glibcpp_bool_digits  __glibcpp_int_traps __glibcpp_long_traps
+//     __glibcpp_bool_digits
 
 #ifndef __glibcpp_bool_digits
 #  define __glibcpp_bool_digits 1
@@ -159,15 +147,6 @@
 
 // char.
 
-#define __glibcpp_plain_char_traps true
-#define __glibcpp_signed_char_traps true
-#define __glibcpp_unsigned_char_traps true
-#ifndef __glibcpp_char_is_modulo
-#  define __glibcpp_char_is_modulo true
-#endif
-#ifndef __glibcpp_signed_char_is_modulo
-#  define __glibcpp_signed_char_is_modulo true
-#endif
 #if __CHAR_BIT__ == 8
 #  define __glibcpp_signed_char_min __glibcpp_s8_min
 #  define __glibcpp_signed_char_max __glibcpp_s8_max
@@ -222,11 +201,6 @@
 
 // short
 
-#define __glibcpp_signed_short_traps true
-#define __glibcpp_unsigned_short_traps true
-#ifndef __glibcpp_signed_short_is_modulo
-#  define __glibcpp_signed_short_is_modulo true
-#endif
 #if __SHRT_BIT__ == 8
 #  define __glibcpp_signed_short_min __glibcpp_s8_min
 #  define __glibcpp_signed_short_max __glibcpp_s8_max
@@ -269,11 +243,6 @@
 
 // int
 
-#define __glibcpp_signed_int_traps true
-#define __glibcpp_unsigned_int_traps true
-#ifndef __glibcpp_signed_int_is_modulo
-#  define __glibcpp_signed_int_is_modulo true
-#endif
 #if __INT_BIT__ == 8
 #  define __glibcpp_signed_int_min __glibcpp_s8_min
 #  define __glibcpp_signed_int_max __glibcpp_s8_max
@@ -316,11 +285,6 @@
 
 // long
 
-#define __glibcpp_signed_long_traps true
-#define __glibcpp_unsigned_long_traps true
-#ifndef __glibcpp_signed_long_is_modulo
-#  define __glibcpp_signed_long_is_modulo true
-#endif
 #if __LONG_BIT__ == 8
 #  define __glibcpp_signed_long_min __glibcpp_s8_min
 #  define __glibcpp_signed_long_max __glibcpp_s8_max
@@ -363,11 +327,6 @@
 
 // long long
 
-#define __glibcpp_signed_long_long_traps true
-#define __glibcpp_signed_long_long_traps true
-#ifndef __glibcpp_signed_long_long_is_modulo
-#  define __glibcpp_signed_long_long_is_modulo true
-#endif
 #if __LONG_LONG_BIT__ == 8
 #  define __glibcpp_signed_long_long_min __glibcpp_s8_min
 #  define __glibcpp_signed_long_long_max __glibcpp_s8_max
@@ -400,22 +359,16 @@
 #  define __glibcpp_signed_long_long_max __glibcpp_s64_max
 #  define __glibcpp_signed_long_long_digits __glibcpp_s64_digits
 #  define __glibcpp_signed_long_long_digits10 __glibcpp_s64_digits10
-#  define __glibcpp_signed_long_long_traps true
 #  define __glibcpp_unsigned_long_long_min __glibcpp_u64_min
 #  define __glibcpp_unsigned_long_long_max __glibcpp_u64_max
 #  define __glibcpp_unsigned_long_long_digits __glibcpp_u64_digits
 #  define __glibcpp_unsigned_long_long_digits10 __glibcpp_u64_digits10
-#  define __glibcpp_unsigned_long_long_traps true
 #else
 // You must define these macros in the configuration file.
 #endif
 
 // wchar_t
 
-#define __glibcpp_wchar_t_traps true
-#ifndef __glibcpp_wchar_t_is_modulo
-#  define __glibcpp_wchar_t_is_modulo true
-#endif
 #if __glibcpp_wchar_t_is_signed
 #  if __WCHAR_BIT__ == 8
 #    define __glibcpp_wchar_t_min __glibcpp_s8_min
@@ -475,10 +428,6 @@
 #  define __glibcpp_float_has_denorm_loss false
 #endif
 
-#ifndef __glibcpp_float_is_bounded
-#  define __glibcpp_float_is_bounded true
-#endif
-
 #ifndef __glibcpp_float_is_modulo
 #  define __glibcpp_float_is_modulo false
 #endif
@@ -499,10 +448,6 @@
 #  define __glibcpp_double_has_denorm_loss false
 #endif
 
-#ifndef __glibcpp_double_is_bounded
-#  define __glibcpp_double_is_bounded true
-#endif
-
 #ifndef __glibcpp_double_is_modulo
 #  define __glibcpp_double_is_modulo false
 #endif
@@ -523,10 +468,6 @@
 #  define __glibcpp_long_double_has_denorm_loss false
 #endif
 
-#ifndef __glibcpp_long_double_is_bounded
-#  define __glibcpp_long_double_is_bounded true
-#endif
-
 #ifndef __glibcpp_long_double_is_modulo
 #  define __glibcpp_long_double_is_modulo false
 #endif
@@ -698,8 +639,7 @@
       // It is not clear what it means for a boolean type to trap.
       // This is a DR on the LWG issue list.  Here, I use integer
       // promotion semantics.
-      static const bool traps = __glibcpp_signed_int_traps
-               || __glibcpp_signed_long_traps;
+      static const bool traps = __glibcpp_integral_traps;
       static const bool tinyness_before = false;
       static const float_round_style round_style = round_toward_zero;
     };
@@ -749,9 +689,9 @@
 
       static const bool is_iec559 = false;
       static const bool is_bounded = true;
-      static const bool is_modulo = __glibcpp_char_is_modulo;
+      static const bool is_modulo = true;
 
-      static const bool traps = __glibcpp_char_traps;
+      static const bool traps = __glibcpp_integral_traps;
       static const bool tinyness_before = false;
       static const float_round_style round_style = round_toward_zero;
     };
@@ -761,8 +701,6 @@
 #undef __glibcpp_char_digits
 #undef __glibcpp_char_digits10
 #undef __glibcpp_char_is_signed
-#undef __glibcpp_char_is_modulo
-#undef __glibcpp_char_traps
 
 
 
@@ -809,9 +747,9 @@
 
       static const bool is_iec559 = false;
       static const bool is_bounded = true;
-      static const bool is_modulo = __glibcpp_signed_char_is_modulo;
+      static const bool is_modulo = true;
 
-      static const bool traps = __glibcpp_signed_char_traps;
+      static const bool traps = __glibcpp_integral_traps;
       static const bool tinyness_before = false;
       static const float_round_style round_style = round_toward_zero;
     };
@@ -820,8 +758,6 @@
 #undef __glibcpp_signed_char_max
 #undef __glibcpp_signed_char_digits
 #undef __glibcpp_signed_char_digits10
-#undef __glibcpp_signed_char_is_modulo  
-#undef __glibcpp_signed_char_traps  
 
   template<>
     struct numeric_limits<unsigned char>
@@ -868,7 +804,7 @@
       static const bool is_bounded = true;
       static const bool is_modulo = true;
 
-      static const bool traps = __glibcpp_unsigned_char_traps;
+      static const bool traps = __glibcpp_integral_traps;
       static const bool tinyness_before = false;
       static const float_round_style round_style = round_toward_zero;
     };
@@ -876,7 +812,6 @@
 #undef __glibcpp_unsigned_char_max
 #undef __glibcpp_unsigned_char_digits
 #undef __glibcpp_unsigned_char_digits10
-#undef __glibcpp_unsigned_char_traps  
 
   template<>
     struct numeric_limits<wchar_t>
@@ -921,9 +856,9 @@
 
       static const bool is_iec559 = false;
       static const bool is_bounded = true;
-      static const bool is_modulo = __glibcpp_wchar_t_is_modulo;
+      static const bool is_modulo = true;
 
-      static const bool traps = __glibcpp_wchar_t_traps;
+      static const bool traps = __glibcpp_integral_traps;
       static const bool tinyness_before = false;
       static const float_round_style round_style = round_toward_zero;
     };
@@ -933,8 +868,6 @@
 #undef __glibcpp_wchar_t_digits
 #undef __glibcpp_wchar_t_digits10  
 #undef __glibcpp_wchar_t_is_signed
-#undef __glibcpp_wchar_t_is_modulo
-#undef __glibcpp_wchar_t_traps  
   
   template<>
     struct numeric_limits<short>
@@ -979,9 +912,9 @@
 
       static const bool is_iec559 = true;
       static const bool is_bounded = true;
-      static const bool is_modulo = __glibcpp_signed_short_is_modulo;
+      static const bool is_modulo = true;
 
-      static const bool traps = __glibcpp_signed_short_traps;
+      static const bool traps = __glibcpp_integral_traps;
       static const bool tinyness_before = false;
       static const float_round_style round_style = round_toward_zero;
     };
@@ -990,8 +923,6 @@
 #undef __glibcpp_signed_short_max
 #undef __glibcpp_signed_short_digits
 #undef __glibcpp_signed_short_digits10
-#undef __glibcpp_signed_short_is_modulo
-#undef __glibcpp_signed_short_traps  
   
   template<>
     struct numeric_limits<unsigned short>
@@ -1038,7 +969,7 @@
       static const bool is_bounded = true;
       static const bool is_modulo = true;
 
-      static const bool traps = __glibcpp_unsigned_short_traps;
+      static const bool traps = __glibcpp_integral_traps;
       static const bool tinyness_before = false;
       static const float_round_style round_style = round_toward_zero;
     };
@@ -1046,7 +977,6 @@
 #undef __glibcpp_unsigned_short_max
 #undef __glibcpp_unsigned_short_digits
 #undef __glibcpp_unsigned_short_digits10
-#undef __glibcpp_unsigned_short_traps  
   
   template<>
     struct numeric_limits<int>
@@ -1091,9 +1021,9 @@
 
       static const bool is_iec559 = true;
       static const bool is_bounded = true;
-      static const bool is_modulo = __glibcpp_signed_int_is_modulo;
+      static const bool is_modulo = true;
 
-      static const bool traps = __glibcpp_signed_int_traps;
+      static const bool traps = __glibcpp_integral_traps;
       static const bool tinyness_before = false;
       static const float_round_style round_style = round_toward_zero;
     };
@@ -1102,8 +1032,6 @@
 #undef __glibcpp_signed_int_max
 #undef __glibcpp_signed_int_digits
 #undef __glibcpp_signed_int_digits10
-#undef __glibcpp_signed_int_is_modulo
-#undef __glibcpp_signed_int_traps  
   
   template<>
     struct numeric_limits<unsigned int>
@@ -1150,7 +1078,7 @@
       static const bool is_bounded = true;
       static const bool is_modulo = true;
 
-      static const bool traps = __glibcpp_unsigned_int_traps;
+      static const bool traps = __glibcpp_integral_traps;
       static const bool tinyness_before = false;
       static const float_round_style round_style = round_toward_zero;
     };
@@ -1158,7 +1086,6 @@
 #undef __glibcpp_unsigned_int_max
 #undef __glibcpp_unsigned_int_digits
 #undef __glibcpp_unsigned_int_digits10
-#undef __glibcpp_unsigned_int_traps  
 
   template<>
     struct numeric_limits<long>
@@ -1203,9 +1130,9 @@
 
       static const bool is_iec559 = true;
       static const bool is_bounded = true;
-      static const bool is_modulo = __glibcpp_signed_long_is_modulo;
+      static const bool is_modulo = true;
 
-      static const bool traps = __glibcpp_signed_long_traps;
+      static const bool traps = __glibcpp_integral_traps;
       static const bool tinyness_before = false;
       static const float_round_style round_style = round_toward_zero;
     };
@@ -1214,8 +1141,6 @@
 #undef __glibcpp_signed_long_max
 #undef __glibcpp_signed_long_digits
 #undef __glibcpp_signed_long_digits10
-#undef __glibcpp_signed_long_is_modulo
-#undef __glibcpp_signed_long_traps  
   
   template<>
     struct numeric_limits<unsigned long>
@@ -1262,7 +1187,7 @@
       static const bool is_bounded = true;
       static const bool is_modulo = true;
 
-      static const bool traps = __glibcpp_unsigned_long_traps;
+      static const bool traps = __glibcpp_integral_traps;
       static const bool tinyness_before = false;
       static const float_round_style round_style = round_toward_zero;
     };
@@ -1270,7 +1195,6 @@
 #undef __glibcpp_unsigned_long_max
 #undef __glibcpp_unsigned_long_digits
 #undef __glibcpp_unsigned_long_digits10
-#undef __glibcpp_unsigned_long_traps  
 
   template<>
     struct numeric_limits<long long>
@@ -1315,9 +1239,9 @@
       
       static const bool is_iec559 = true;
       static const bool is_bounded = true;
-      static const bool is_modulo = __glibcpp_signed_long_long_is_modulo;
+      static const bool is_modulo = true;
 
-      static const bool traps = __glibcpp_signed_long_long_traps;
+      static const bool traps = __glibcpp_integral_traps;
       static const bool tinyness_before = false;
       static const float_round_style round_style = round_toward_zero;
     };
@@ -1326,8 +1250,6 @@
 #undef __glibcpp_signed_long_long_max
 #undef __glibcpp_signed_long_long_digits
 #undef __glibcpp_signed_long_long_digits10
-#undef __glibcpp_signed_long_long_is_modulo
-#undef __glibcpp_signed_long_long_traps  
   
   template<>
     struct numeric_limits<unsigned long long>
@@ -1374,7 +1296,7 @@
       static const bool is_bounded = true;
       static const bool is_modulo = true;
 
-      static const bool traps = true;
+      static const bool traps = __glibcpp_integral_traps;
       static const bool tinyness_before = false;
       static const float_round_style round_style = round_toward_zero;
     };
@@ -1382,7 +1304,6 @@
 #undef __glibcpp_unsigned_long_long_max
 #undef __glibcpp_unsigned_long_long_digits
 #undef __glibcpp_unsigned_long_long_digits10
-#undef __glibcpp_unsigned_long_long_traps  
 
   template<>
     struct numeric_limits<float>
@@ -1429,7 +1350,7 @@
       { return __FLT_DENORM_MIN__; }
 
       static const bool is_iec559 = has_infinity && has_quiet_NaN;
-      static const bool is_bounded = __glibcpp_float_is_bounded;
+      static const bool is_bounded = true;
       static const bool is_modulo = __glibcpp_float_is_modulo;
 
       static const bool traps = __glibcpp_float_traps;
@@ -1438,7 +1359,6 @@
     };
 
 #undef __glibcpp_float_has_denorm_loss
-#undef __glibcpp_float_is_bounded
 #undef __glibcpp_float_is_modulo
 #undef __glibcpp_float_traps
 #undef __glibcpp_float_tinyness_before
@@ -1488,7 +1408,7 @@
       { return __DBL_DENORM_MIN__; }
 
       static const bool is_iec559 = has_infinity && has_quiet_NaN;
-      static const bool is_bounded = __glibcpp_double_is_bounded;
+      static const bool is_bounded = true;
       static const bool is_modulo = __glibcpp_double_is_modulo;
 
       static const bool traps = __glibcpp_double_traps;
@@ -1497,7 +1417,6 @@
     };
 
 #undef __glibcpp_double_has_denorm_loss
-#undef __glibcpp_double_is_bounded
 #undef __glibcpp_double_is_modulo
 #undef __glibcpp_double_traps
 #undef __glibcpp_double_tinyness_before
@@ -1549,7 +1468,7 @@
       { return __LDBL_DENORM_MIN__; }
 
       static const bool is_iec559 = has_infinity && has_quiet_NaN;
-      static const bool is_bounded = __glibcpp_long_double_is_bounded;
+      static const bool is_bounded = true;
       static const bool is_modulo = __glibcpp_long_double_is_modulo;
 
       static const bool traps = __glibcpp_long_double_traps; 
@@ -1558,7 +1477,6 @@
     };
 
 #undef __glibcpp_long_double_has_denorm_loss
-#undef __glibcpp_long_double_is_bounded
 #undef __glibcpp_long_double_is_modulo
 #undef __glibcpp_long_double_traps
 #undef __glibcpp_long_double_tinyness_before


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