hw_rounding.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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/numeric/interval/rounding.hpp>
  13. #include <boost/numeric/interval/rounded_arith.hpp>
  14. #define BOOST_NUMERIC_INTERVAL_NO_HARDWARE
  15. // define appropriate specialization of rounding_control for built-in types
  16. #if defined(__x86_64__) && (defined(__USE_ISOC99) || defined(__APPLE__))
  17. # include <boost/numeric/interval/detail/c99_rounding_control.hpp>
  18. #elif defined(__i386__) || defined(_M_IX86) || defined(__BORLANDC__) && !defined(__clang__) || defined(_M_X64)
  19. # include <boost/numeric/interval/detail/x86_rounding_control.hpp>
  20. #elif defined(__i386) && defined(__SUNPRO_CC)
  21. # include <boost/numeric/interval/detail/x86_rounding_control.hpp>
  22. #elif defined(powerpc) || defined(__powerpc__) || defined(__ppc__)
  23. # include <boost/numeric/interval/detail/ppc_rounding_control.hpp>
  24. #elif defined(sparc) || defined(__sparc__)
  25. # include <boost/numeric/interval/detail/sparc_rounding_control.hpp>
  26. #elif defined(alpha) || defined(__alpha__)
  27. # include <boost/numeric/interval/detail/alpha_rounding_control.hpp>
  28. #elif defined(ia64) || defined(__ia64) || defined(__ia64__)
  29. # include <boost/numeric/interval/detail/ia64_rounding_control.hpp>
  30. #endif
  31. #if defined(BOOST_NUMERIC_INTERVAL_NO_HARDWARE) && (defined(__USE_ISOC99) || defined(__MSL__))
  32. # include <boost/numeric/interval/detail/c99_rounding_control.hpp>
  33. #endif
  34. #if defined(BOOST_NUMERIC_INTERVAL_NO_HARDWARE)
  35. # undef BOOST_NUMERIC_INTERVAL_NO_HARDWARE
  36. # error Boost.Numeric.Interval: Please specify rounding control mechanism.
  37. #endif
  38. namespace boost {
  39. namespace numeric {
  40. namespace interval_lib {
  41. /*
  42. * Three specializations of rounded_math<T>
  43. */
  44. template<>
  45. struct rounded_math<float>
  46. : save_state<rounded_arith_opp<float> >
  47. {};
  48. template<>
  49. struct rounded_math<double>
  50. : save_state<rounded_arith_opp<double> >
  51. {};
  52. template<>
  53. struct rounded_math<long double>
  54. : save_state<rounded_arith_opp<long double> >
  55. {};
  56. } // namespace interval_lib
  57. } // namespace numeric
  58. } // namespace boost
  59. #endif // BOOST_NUMERIC_INTERVAL_HW_ROUNDING_HPP