Warning, file /include/boost/numeric/interval/detail/x86_rounding_control.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_NUMERIC_INTERVAL_DETAIL_X86_ROUNDING_CONTROL_HPP
0012 #define BOOST_NUMERIC_INTERVAL_DETAIL_X86_ROUNDING_CONTROL_HPP
0013
0014 #if defined(__GNUC__) || defined(__BORLANDC__) && defined(__clang__)
0015 # include <boost/numeric/interval/detail/x86gcc_rounding_control.hpp>
0016 #elif defined(__BORLANDC__)
0017 # include <boost/numeric/interval/detail/bcc_rounding_control.hpp>
0018 #elif defined(_MSC_VER)
0019 # include <boost/numeric/interval/detail/msvc_rounding_control.hpp>
0020 #elif defined(__MWERKS__) || defined(__ICC) || defined (__SUNPRO_CC)
0021 # define BOOST_NUMERIC_INTERVAL_USE_C99_SUBSYSTEM
0022 # include <boost/numeric/interval/detail/c99sub_rounding_control.hpp>
0023 #else
0024 # error Unsupported C++ compiler.
0025 #endif
0026
0027 namespace boost {
0028 namespace numeric {
0029 namespace interval_lib {
0030
0031 namespace detail {
0032
0033 #ifdef BOOST_NUMERIC_INTERVAL_USE_C99_SUBSYSTEM
0034 typedef c99_rounding_control x86_rounding_control;
0035 #undef BOOST_NUMERIC_INTERVAL_USE_C99_SUBSYSTEM
0036 #else
0037 struct fpu_rounding_modes
0038 {
0039 unsigned short to_nearest;
0040 unsigned short downward;
0041 unsigned short upward;
0042 unsigned short toward_zero;
0043 };
0044
0045
0046
0047 static const fpu_rounding_modes rnd_mode = { 0x137f, 0x177f, 0x1b7f, 0x1f7f };
0048
0049 struct x86_rounding_control: x86_rounding
0050 {
0051 static void to_nearest() { set_rounding_mode(rnd_mode.to_nearest); }
0052 static void downward() { set_rounding_mode(rnd_mode.downward); }
0053 static void upward() { set_rounding_mode(rnd_mode.upward); }
0054 static void toward_zero() { set_rounding_mode(rnd_mode.toward_zero); }
0055 };
0056 #endif
0057
0058 }
0059
0060 template<>
0061 struct rounding_control<float>: detail::x86_rounding_control
0062 {
0063 static float force_rounding(const float& r)
0064 { volatile float r_ = r; return r_; }
0065 };
0066
0067 template<>
0068 struct rounding_control<double>: detail::x86_rounding_control
0069 {
0070
0071
0072 static double force_rounding(const double& r)
0073 { volatile double r_ = r; return r_; }
0074 };
0075
0076 namespace detail {
0077
0078 template<bool>
0079 struct x86_rounding_control_long_double;
0080
0081 template<>
0082 struct x86_rounding_control_long_double<false>: x86_rounding_control
0083 {
0084 static long double force_rounding(long double const &r)
0085 { volatile long double r_ = r; return r_; }
0086 };
0087
0088 template<>
0089 struct x86_rounding_control_long_double<true>: x86_rounding_control
0090 {
0091 static long double const &force_rounding(long double const &r)
0092 { return r; }
0093 };
0094
0095 }
0096
0097 template<>
0098 struct rounding_control<long double>:
0099 detail::x86_rounding_control_long_double< (sizeof(long double) >= 10) >
0100 {};
0101
0102 }
0103 }
0104 }
0105
0106 #undef BOOST_NUMERIC_INTERVAL_NO_HARDWARE
0107
0108 #endif