hw_rounding.hpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* Boost interval/hw_rounding.hpp template implementation file
  2. *
  3. * Copyright 2002 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion
  4. * Copyright 2005 Guillaume Melquiond
  5. *
  6. * Distributed under the Boost Software License, Version 1.0.
  7. * (See accompanying file LICENSE_1_0.txt or
  8. * copy at http://www.boost.org/LICENSE_1_0.txt)
  9. */
  10. #ifndef BOOST_NUMERIC_INTERVAL_HW_ROUNDING_HPP
  11. #define BOOST_NUMERIC_INTERVAL_HW_ROUNDING_HPP
  12. #include <boost/config.hpp>
  13. #include <boost/numeric/interval/rounding.hpp>
  14. #include <boost/numeric/interval/rounded_arith.hpp>
  15. #define BOOST_NUMERIC_INTERVAL_NO_HARDWARE
  16. // define appropriate specialization of rounding_control for built-in types
  17. #if defined(__x86_64__) && !defined(BOOST_NO_FENV_H)
  18. # include <boost/numeric/interval/detail/c99_rounding_control.hpp>
  19. #elif defined(__i386__) || defined(_M_IX86) || defined(__BORLANDC__) && !defined(__clang__) || defined(_M_X64)
  20. # include <boost/numeric/interval/detail/x86_rounding_control.hpp>
  21. #elif defined(__i386) && defined(__SUNPRO_CC)
  22. # include <boost/numeric/interval/detail/x86_rounding_control.hpp>
  23. #elif defined(powerpc) || defined(__powerpc__) || defined(__ppc__)
  24. # include <boost/numeric/interval/detail/ppc_rounding_control.hpp>
  25. #elif defined(sparc) || defined(__sparc__)
  26. # include <boost/numeric/interval/detail/sparc_rounding_control.hpp>
  27. #elif defined(alpha) || defined(__alpha__)
  28. # include <boost/numeric/interval/detail/alpha_rounding_control.hpp>
  29. #elif defined(ia64) || defined(__ia64) || defined(__ia64__)
  30. # include <boost/numeric/interval/detail/ia64_rounding_control.hpp>
  31. #endif
  32. #if defined(BOOST_NUMERIC_INTERVAL_NO_HARDWARE) && !defined(BOOST_NO_FENV_H)
  33. # include <boost/numeric/interval/detail/c99_rounding_control.hpp>
  34. #endif
  35. #if defined(BOOST_NUMERIC_INTERVAL_NO_HARDWARE)
  36. # undef BOOST_NUMERIC_INTERVAL_NO_HARDWARE
  37. # error Boost.Numeric.Interval: Please specify rounding control mechanism.
  38. #endif
  39. namespace boost {
  40. namespace numeric {
  41. namespace interval_lib {
  42. /*
  43. * Three specializations of rounded_math<T>
  44. */
  45. template<>
  46. struct rounded_math<float>
  47. : save_state<rounded_arith_opp<float> >
  48. {};
  49. template<>
  50. struct rounded_math<double>
  51. : save_state<rounded_arith_opp<double> >
  52. {};
  53. template<>
  54. struct rounded_math<long double>
  55. : save_state<rounded_arith_opp<long double> >
  56. {};
  57. } // namespace interval_lib
  58. } // namespace numeric
  59. } // namespace boost
  60. #endif // BOOST_NUMERIC_INTERVAL_HW_ROUNDING_HPP