Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/numeric/interval/detail/ia64_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 /* Boost interval/detail/ia64_rounding_control.hpp file
0002  *
0003  * Copyright 2006-2007 Boris Gubenko
0004  *
0005  * Distributed under the Boost Software License, Version 1.0.
0006  * (See accompanying file LICENSE_1_0.txt or
0007  * copy at http://www.boost.org/LICENSE_1_0.txt)
0008  */
0009 
0010 #ifndef BOOST_NUMERIC_INTERVAL_DETAIL_IA64_ROUNDING_CONTROL_HPP
0011 #define BOOST_NUMERIC_INTERVAL_DETAIL_IA64_ROUNDING_CONTROL_HPP
0012 
0013 #if !defined(ia64) && !defined(__ia64) && !defined(__ia64__)
0014 #error This header only works on ia64 CPUs.
0015 #endif
0016 
0017 #if defined(__hpux)
0018 
0019 #   include <fenv.h>
0020 
0021 namespace boost {
0022 namespace numeric {
0023 namespace interval_lib {
0024 namespace detail {
0025 
0026 
0027     struct ia64_rounding_control
0028     {
0029     typedef unsigned int rounding_mode;
0030 
0031     static void set_rounding_mode(const rounding_mode& mode)  { 
0032 fesetround(mode); }
0033     static void get_rounding_mode(rounding_mode& mode)  { mode = fegetround(); }
0034 
0035     static void downward()    { set_rounding_mode(FE_DOWNWARD); }
0036     static void upward()      { set_rounding_mode(FE_UPWARD); }
0037     static void to_nearest()  { set_rounding_mode(FE_TONEAREST); }
0038     static void toward_zero() { set_rounding_mode(FE_TOWARDZERO); }
0039     };
0040 
0041 } // namespace detail
0042 
0043 extern "C" {
0044   float rintf(float);
0045   double rint(double);
0046   long double rintl(long double);
0047 }
0048 
0049 template<>
0050 struct rounding_control<float>:
0051   detail::ia64_rounding_control
0052 {
0053   static float force_rounding(const float r)
0054   { volatile float _r = r; return _r; }
0055   static float to_int(const float& x) { return rintf(x); }
0056 };
0057 
0058 template<>
0059 struct rounding_control<double>:
0060   detail::ia64_rounding_control
0061 {
0062   static const double & force_rounding(const double& r) { return r; }
0063   static double to_int(const double& r) { return rint(r); }
0064 };
0065 
0066 template<>
0067 struct rounding_control<long double>:
0068   detail::ia64_rounding_control
0069 {
0070   static const long double & force_rounding(const long double& r) { return r; }
0071   static long double to_int(const long double& r) { return rintl(r); }
0072 };
0073 
0074 } // namespace interval_lib
0075 } // namespace numeric
0076 } // namespace boost
0077 
0078 #undef BOOST_NUMERIC_INTERVAL_NO_HARDWARE
0079 
0080 #endif /* __hpux */
0081 
0082 #endif /* BOOST_NUMERIC_INTERVAL_DETAIL_IA64_ROUNDING_CONTROL_HPP */
0083