You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by se...@apache.org on 2005/11/11 02:12:12 UTC
svn commit: r332411 - in /incubator/stdcxx/trunk:
etc/config/src/NO_INT_TRAPS.cpp include/limits
Author: sebor
Date: Thu Nov 10 17:12:08 2005
New Revision: 332411
URL: http://svn.apache.org/viewcvs?rev=332411&view=rev
Log:
2005-11-10 Martin Sebor <se...@roguewave.com>
STDCXX-65
* limits: Used _RWSTD_NO_INT_TRAPS to define numeric_limits::traps
for all integral T.
* NO_INT_TRAPS.cpp: Used division by zero to trigger an arithmetic
trap on platforms where integer trapping is implemented and enabled.
Modified:
incubator/stdcxx/trunk/etc/config/src/NO_INT_TRAPS.cpp
incubator/stdcxx/trunk/include/limits
Modified: incubator/stdcxx/trunk/etc/config/src/NO_INT_TRAPS.cpp
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/etc/config/src/NO_INT_TRAPS.cpp?rev=332411&r1=332410&r2=332411&view=diff
==============================================================================
--- incubator/stdcxx/trunk/etc/config/src/NO_INT_TRAPS.cpp (original)
+++ incubator/stdcxx/trunk/etc/config/src/NO_INT_TRAPS.cpp Thu Nov 10 17:12:08 2005
@@ -4,27 +4,23 @@
# include "config.h"
#endif // _RWSTD_USE_CONFIG
-int int_get_zero ();
+int get_int ();
-int main ()
+int main (int argc, char*[])
{
- int int_zero = int_get_zero ();
- int int_one = int_get_zero () + 1;
- int int_two = int_get_zero () + 2;
+ int int_zero = get_int ();
+ int int_one = get_int ();
- int x = int_one;
-
- while (int_zero < x)
- x *= int_two;
+ int result = int_one / int_zero;
// NEGATIVE test: successful exit status indicates a failure
- return 0;
+ return argc < 2 ? 0 : result;
}
// foil optimizers
-int int_get_zero ()
-{
- static int value = 0;
+volatile int int_value = 0;
- return value;
+int get_int ()
+{
+ return int_value++;
}
Modified: incubator/stdcxx/trunk/include/limits
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/include/limits?rev=332411&r1=332410&r2=332411&view=diff
==============================================================================
--- incubator/stdcxx/trunk/include/limits (original)
+++ incubator/stdcxx/trunk/include/limits Thu Nov 10 17:12:08 2005
@@ -3,7 +3,7 @@
*
* <limits> - definitions of the numeric_limits template and specializations
*
- * $Id: //stdlib/dev/include/limits#43 $
+ * $Id$
*
***************************************************************************
*
@@ -31,7 +31,14 @@
#endif // _RWSTD_NO_QUIET_NAN
-// do math operations (such as 0.0/0.0) trap?
+// does integer arithmetic trap?
+#ifndef _RWSTD_NO_INT_TRAPS
+# define _RWSTD_INT_TRAPS true
+#else // if defined (_RWSTD_NO_INT_TRAPS)
+# define _RWSTD_INT_TRAPS false
+#endif // _RWSTD_NO_INT_TRAPS
+
+// does floating point arithmetic (such as 0.0/0.0) trap?
#ifndef _RWSTD_NO_DBL_TRAPS
# define _RWSTD_FLT_TRAPS true
# define _RWSTD_DBL_TRAPS true
@@ -221,7 +228,7 @@
_RWSTD_STATIC (type, bool, is_bounded, true); \
_RWSTD_STATIC (type, bool, is_modulo, 1 != cpfx##_MAX); \
\
- _RWSTD_STATIC (type, bool, traps, false); \
+ _RWSTD_STATIC (type, bool, traps, _RWSTD_INT_TRAPS); \
_RWSTD_STATIC (type, bool, tinyness_before, false); \
_RWSTD_STATIC (type, float_round_style, round_style, round_toward_zero);