annotate DEPENDENCIES/generic/include/boost/numeric/interval/detail/ia64_rounding_control.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 /* Boost interval/detail/ia64_rounding_control.hpp file
Chris@16 2 *
Chris@16 3 * Copyright 2006-2007 Boris Gubenko
Chris@16 4 *
Chris@16 5 * Distributed under the Boost Software License, Version 1.0.
Chris@16 6 * (See accompanying file LICENSE_1_0.txt or
Chris@16 7 * copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 8 */
Chris@16 9
Chris@16 10 #ifndef BOOST_NUMERIC_INTERVAL_DETAIL_IA64_ROUNDING_CONTROL_HPP
Chris@16 11 #define BOOST_NUMERIC_INTERVAL_DETAIL_IA64_ROUNDING_CONTROL_HPP
Chris@16 12
Chris@16 13 #if !defined(ia64) && !defined(__ia64) && !defined(__ia64__)
Chris@16 14 #error This header only works on ia64 CPUs.
Chris@16 15 #endif
Chris@16 16
Chris@16 17 #if defined(__hpux)
Chris@16 18
Chris@16 19 # include <fenv.h>
Chris@16 20
Chris@16 21 namespace boost {
Chris@16 22 namespace numeric {
Chris@16 23 namespace interval_lib {
Chris@16 24 namespace detail {
Chris@16 25
Chris@16 26
Chris@16 27 struct ia64_rounding_control
Chris@16 28 {
Chris@16 29 typedef unsigned int rounding_mode;
Chris@16 30
Chris@16 31 static void set_rounding_mode(const rounding_mode& mode) {
Chris@16 32 fesetround(mode); }
Chris@16 33 static void get_rounding_mode(rounding_mode& mode) { mode = fegetround(); }
Chris@16 34
Chris@16 35 static void downward() { set_rounding_mode(FE_DOWNWARD); }
Chris@16 36 static void upward() { set_rounding_mode(FE_UPWARD); }
Chris@16 37 static void to_nearest() { set_rounding_mode(FE_TONEAREST); }
Chris@16 38 static void toward_zero() { set_rounding_mode(FE_TOWARDZERO); }
Chris@16 39 };
Chris@16 40
Chris@16 41 } // namespace detail
Chris@16 42
Chris@16 43 extern "C" {
Chris@16 44 float rintf(float);
Chris@16 45 double rint(double);
Chris@16 46 long double rintl(long double);
Chris@16 47 }
Chris@16 48
Chris@16 49 template<>
Chris@16 50 struct rounding_control<float>:
Chris@16 51 detail::ia64_rounding_control
Chris@16 52 {
Chris@16 53 static float force_rounding(const float r)
Chris@16 54 { volatile float _r = r; return _r; }
Chris@16 55 static float to_int(const float& x) { return rintf(x); }
Chris@16 56 };
Chris@16 57
Chris@16 58 template<>
Chris@16 59 struct rounding_control<double>:
Chris@16 60 detail::ia64_rounding_control
Chris@16 61 {
Chris@16 62 static const double & force_rounding(const double& r) { return r; }
Chris@16 63 static double to_int(const double& r) { return rint(r); }
Chris@16 64 };
Chris@16 65
Chris@16 66 template<>
Chris@16 67 struct rounding_control<long double>:
Chris@16 68 detail::ia64_rounding_control
Chris@16 69 {
Chris@16 70 static const long double & force_rounding(const long double& r) { return r; }
Chris@16 71 static long double to_int(const long double& r) { return rintl(r); }
Chris@16 72 };
Chris@16 73
Chris@16 74 } // namespace interval_lib
Chris@16 75 } // namespace numeric
Chris@16 76 } // namespace boost
Chris@16 77
Chris@16 78 #undef BOOST_NUMERIC_INTERVAL_NO_HARDWARE
Chris@16 79
Chris@16 80 #endif /* __hpux */
Chris@16 81
Chris@16 82 #endif /* BOOST_NUMERIC_INTERVAL_DETAIL_IA64_ROUNDING_CONTROL_HPP */
Chris@16 83