Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/numeric/interval/detail/bcc_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/bcc_rounding_control.hpp file
0002  *
0003  * Copyright 2000 Jens Maurer
0004  * Copyright 2002 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion
0005  *
0006  * Distributed under the Boost Software License, Version 1.0.
0007  * (See accompanying file LICENSE_1_0.txt or
0008  * copy at http://www.boost.org/LICENSE_1_0.txt)
0009  */
0010 
0011 #ifndef BOOST_NUMERIC_INTERVAL_DETAIL_BCC_ROUNDING_CONTROL_HPP
0012 #define BOOST_NUMERIC_INTERVAL_DETAIL_BCC_ROUNDING_CONTROL_HPP
0013 
0014 #if !defined(__BORLANDC__) || defined(__clang__)
0015 #  error This header is only intended for Borland C++.
0016 #endif
0017 
0018 #ifndef _M_IX86
0019 #  error This header only works on x86 CPUs.
0020 #endif
0021 
0022 #include <float.h>      // Borland C++ rounding control
0023 
0024 namespace boost {
0025 namespace numeric {
0026 namespace interval_lib {
0027 namespace detail {
0028 
0029 #ifndef BOOST_NUMERIC_INTERVAL_KEEP_EXCEPTIONS_FOR_BCC
0030 extern "C" { unsigned int _RTLENTRY _fm_init(void); }
0031 
0032 struct borland_workaround {
0033   borland_workaround() { _fm_init(); }
0034 };
0035 
0036 static borland_workaround borland_workaround_exec;
0037 #endif // BOOST_NUMERIC_INTERVAL_KEEP_EXCEPTIONS_FOR_BCC
0038 
0039 __inline double rint(double)
0040 { __emit__(0xD9); __emit__(0xFC); /* asm FRNDINT */ }
0041 
0042 struct x86_rounding
0043 {
0044   typedef unsigned int rounding_mode;
0045   static void get_rounding_mode(rounding_mode& mode)
0046   { mode = _control87(0, 0); }
0047   static void set_rounding_mode(const rounding_mode mode)
0048   { _control87(mode, 0xffff); } 
0049   static double to_int(const double& x) { return rint(x); }
0050 };
0051 
0052 } // namespace detail
0053 } // namespace interval_lib
0054 } // namespace numeric
0055 } // namespace boost
0056 
0057 #endif /* BOOST_NUMERIC_INTERVAL_DETAIL_BCC_ROUNDING_CONTROL_HPP */