Boost logo

Boost-Commit :

From: john_at_[hidden]
Date: 2007-10-08 05:46:33


Author: johnmaddock
Date: 2007-10-08 05:46:32 EDT (Mon, 08 Oct 2007)
New Revision: 39779
URL: http://svn.boost.org/trac/boost/changeset/39779

Log:
Misc fixes for minimal Borland support.
Text files modified:
   sandbox/math_toolkit/boost/math/policies/policy.hpp | 80 +++++++++++++++++++++++++++++++++++++--
   sandbox/math_toolkit/boost/math/tools/config.hpp | 3 +
   sandbox/math_toolkit/libs/math/test/Jamfile.v2 | 4 ++
   3 files changed, 82 insertions(+), 5 deletions(-)

Modified: sandbox/math_toolkit/boost/math/policies/policy.hpp
==============================================================================
--- sandbox/math_toolkit/boost/math/policies/policy.hpp (original)
+++ sandbox/math_toolkit/boost/math/policies/policy.hpp 2007-10-08 05:46:32 EDT (Mon, 08 Oct 2007)
@@ -17,11 +17,18 @@
 #include <boost/mpl/push_back.hpp>
 #include <boost/mpl/at.hpp>
 #include <boost/mpl/size.hpp>
+#include <boost/mpl/comparison.hpp>
 #include <boost/type_traits/is_same.hpp>
 #include <boost/static_assert.hpp>
 #include <boost/assert.hpp>
 #include <boost/math/tools/config.hpp>
 #include <limits>
+// Sadly we do need the .h versions of these to be sure of getting
+// FLT_MANT_DIG etc.
+#include <limits.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <math.h>
 
 namespace boost{ namespace math{
 
@@ -674,30 +681,93 @@
    typedef typename mpl::if_<typename Policy::promote_double_type, long double, double>::type type;
 };
 
+#ifdef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
+
+template <class Real>
+struct basic_digits : public mpl::int_<0>{ };
+template <>
+struct basic_digits<float> : public mpl::int_<FLT_MANT_DIG>{ };
+template <>
+struct basic_digits<double> : public mpl::int_<DBL_MANT_DIG>{ };
+template <>
+struct basic_digits<long double> : public mpl::int_<LDBL_MANT_DIG>{ };
+
+template <class Real, class Policy>
+struct precision
+{
+ typedef typename Policy::precision_type precision_type;
+ typedef basic_digits<Real> digits_t;
+ typedef typename mpl::if_<
+ mpl::equal_to<digits_t, mpl::int_<0> >,
+ // Possibly unknown precision:
+ precision_type,
+ typename mpl::if_<
+ mpl::or_<mpl::less_equal<digits_t, precision_type>, mpl::less_equal<precision_type, mpl::int_<0> > >,
+ // Default case, full precision for RealType:
+ digits2< ::std::numeric_limits<Real>::digits>,
+ // User customised precision:
+ precision_type
+ >::type
+ >::type type;
+};
+
+template <class Policy>
+struct precision<float, Policy>
+{
+ typedef digits2<FLT_MANT_DIG> type;
+};
+template <class Policy>
+struct precision<double, Policy>
+{
+ typedef digits2<DBL_MANT_DIG> type;
+};
+template <class Policy>
+struct precision<long double, Policy>
+{
+ typedef digits2<LDBL_MANT_DIG> type;
+};
+
+#else
+
 template <class Real, class Policy>
 struct precision
 {
+#ifndef __BORLANDC__
    typedef typename Policy::precision_type precision_type;
    typedef typename mpl::if_c<
- ((std::numeric_limits<Real>::is_specialized == 0) || (std::numeric_limits<Real>::digits == 0)),
+ ((::std::numeric_limits<Real>::is_specialized == 0) || (::std::numeric_limits<Real>::digits == 0)),
       // Possibly unknown precision:
       precision_type,
       typename mpl::if_c<
-#ifndef __BORLANDC__
          ((::std::numeric_limits<Real>::digits <= precision_type::value)
          || (Policy::precision_type::value <= 0)),
+ // Default case, full precision for RealType:
+ digits2< ::std::numeric_limits<Real>::digits>,
+ // User customised precision:
+ precision_type
+ >::type
+ >::type type;
 #else
- ((::std::numeric_limits<Real>::digits <= ::boost::math::policies::precision<Real, Policy>::precision_type::value)
- || (::boost::math::policies::precision<Real, Policy>::precision_type::value <= 0)),
-#endif
+ typedef typename Policy::precision_type precision_type;
+ typedef mpl::int_< ::std::numeric_limits<Real>::digits> digits_t;
+ typedef mpl::bool_< ::std::numeric_limits<Real>::is_specialized> spec_t;
+ typedef typename mpl::if_<
+ mpl::or_<mpl::equal_to<spec_t, mpl::false_>, mpl::equal_to<digits_t, mpl::int_<0> > >,
+ // Possibly unknown precision:
+ precision_type,
+ typename mpl::if_<
+ mpl::or_<mpl::less_equal<digits_t, precision_type>, mpl::less_equal<precision_type, mpl::int_<0> > >,
          // Default case, full precision for RealType:
          digits2< ::std::numeric_limits<Real>::digits>,
          // User customised precision:
          precision_type
>::type
>::type type;
+#endif
 };
 
+#endif
+
 namespace detail{
 
 template <class T, class Policy>

Modified: sandbox/math_toolkit/boost/math/tools/config.hpp
==============================================================================
--- sandbox/math_toolkit/boost/math/tools/config.hpp (original)
+++ sandbox/math_toolkit/boost/math/tools/config.hpp 2007-10-08 05:46:32 EDT (Mon, 08 Oct 2007)
@@ -16,6 +16,9 @@
 #if defined(__CYGWIN__) || defined(__FreeBSD__)
 # define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
 #endif
+#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
+# define BOOST_MATH_NO_REAL_CONCEPT_TESTS
+#endif
 
 #if BOOST_WORKAROUND(BOOST_MSVC, < 1400)
 //

Modified: sandbox/math_toolkit/libs/math/test/Jamfile.v2
==============================================================================
--- sandbox/math_toolkit/libs/math/test/Jamfile.v2 (original)
+++ sandbox/math_toolkit/libs/math/test/Jamfile.v2 2007-10-08 05:46:32 EDT (Mon, 08 Oct 2007)
@@ -25,6 +25,8 @@
       <toolset>msvc:<cxxflags>/wd4127
       <toolset>msvc:<cxxflags>/wd4701 # needed for lexical cast - temporary.
       <toolset>msvc-7.1:<source>../vc71_fix//vc_fix
+ <toolset>borland:<link>static
+ <toolset>borland:<runtime-link>static
       # <toolset>msvc:<cxxflags>/wd4506 has no effect?
       # suppress xstring(237) : warning C4506: no definition for inline function
       <include>../../..
@@ -201,3 +203,5 @@
 
 
 
+
+


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk