New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
ia64_rounding_control.hpp in vendors/XIOS/current/extern/boost/include/boost/numeric/interval/detail – NEMO

source: vendors/XIOS/current/extern/boost/include/boost/numeric/interval/detail/ia64_rounding_control.hpp @ 3408

Last change on this file since 3408 was 3408, checked in by rblod, 12 years ago

importing initial XIOS vendor drop

  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
1/* Boost interval/detail/ia64_rounding_control.hpp file
2 *
3 * Copyright 2006-2007 Boris Gubenko
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE_1_0.txt or
7 * copy at http://www.boost.org/LICENSE_1_0.txt)
8 */
9
10#ifndef BOOST_NUMERIC_INTERVAL_DETAIL_IA64_ROUNDING_CONTROL_HPP
11#define BOOST_NUMERIC_INTERVAL_DETAIL_IA64_ROUNDING_CONTROL_HPP
12
13#if !defined(ia64) && !defined(__ia64) && !defined(__ia64__)
14#error This header only works on ia64 CPUs.
15#endif
16
17#if defined(__hpux)
18
19#   include <fenv.h>
20
21namespace boost {
22namespace numeric {
23namespace interval_lib {
24namespace detail {
25
26
27    struct ia64_rounding_control
28    {
29    typedef unsigned int rounding_mode;
30
31    static void set_rounding_mode(const rounding_mode& mode)  { 
32fesetround(mode); }
33    static void get_rounding_mode(rounding_mode& mode)  { mode = fegetround(); }
34
35    static void downward()    { set_rounding_mode(FE_DOWNWARD); }
36    static void upward()      { set_rounding_mode(FE_UPWARD); }
37    static void to_nearest()  { set_rounding_mode(FE_TONEAREST); }
38    static void toward_zero() { set_rounding_mode(FE_TOWARDZERO); }
39    };
40
41} // namespace detail
42
43extern "C" {
44  float rintf(float);
45  double rint(double);
46  long double rintl(long double);
47}
48
49template<>
50struct rounding_control<float>:
51  detail::ia64_rounding_control
52{
53  static float force_rounding(const float r)
54  { volatile float _r = r; return _r; }
55  static float to_int(const float& x) { return rintf(x); }
56};
57
58template<>
59struct rounding_control<double>:
60  detail::ia64_rounding_control
61{
62  static const double & force_rounding(const double& r) { return r; }
63  static double to_int(const double& r) { return rint(r); }
64};
65
66template<>
67struct rounding_control<long double>:
68  detail::ia64_rounding_control
69{
70  static const long double & force_rounding(const long double& r) { return r; }
71  static long double to_int(const long double& r) { return rintl(r); }
72};
73
74} // namespace interval_lib
75} // namespace numeric
76} // namespace boost
77
78#undef BOOST_NUMERIC_INTERVAL_NO_HARDWARE
79
80#endif /* __hpux */
81
82#endif /* BOOST_NUMERIC_INTERVAL_DETAIL_IA64_ROUNDING_CONTROL_HPP */
83
Note: See TracBrowser for help on using the repository browser.