Chris@16: /* Boost interval/detail/bcc_rounding_control.hpp file Chris@16: * Chris@16: * Copyright 2000 Jens Maurer Chris@16: * Copyright 2002 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion Chris@16: * Chris@16: * Distributed under the Boost Software License, Version 1.0. Chris@16: * (See accompanying file LICENSE_1_0.txt or Chris@16: * copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: */ Chris@16: Chris@16: #ifndef BOOST_NUMERIC_INTERVAL_DETAIL_BCC_ROUNDING_CONTROL_HPP Chris@16: #define BOOST_NUMERIC_INTERVAL_DETAIL_BCC_ROUNDING_CONTROL_HPP Chris@16: Chris@16: #ifndef __BORLANDC__ Chris@16: # error This header is only intended for Borland C++. Chris@16: #endif Chris@16: Chris@16: #ifndef _M_IX86 Chris@16: # error This header only works on x86 CPUs. Chris@16: #endif Chris@16: Chris@16: #include // Borland C++ rounding control Chris@16: Chris@16: namespace boost { Chris@16: namespace numeric { Chris@16: namespace interval_lib { Chris@16: namespace detail { Chris@16: Chris@16: #ifndef BOOST_NUMERIC_INTERVAL_KEEP_EXCEPTIONS_FOR_BCC Chris@16: extern "C" { unsigned int _RTLENTRY _fm_init(void); } Chris@16: Chris@16: struct borland_workaround { Chris@16: borland_workaround() { _fm_init(); } Chris@16: }; Chris@16: Chris@16: static borland_workaround borland_workaround_exec; Chris@16: #endif // BOOST_NUMERIC_INTERVAL_KEEP_EXCEPTIONS_FOR_BCC Chris@16: Chris@16: __inline double rint(double) Chris@16: { __emit__(0xD9); __emit__(0xFC); /* asm FRNDINT */ } Chris@16: Chris@16: struct x86_rounding Chris@16: { Chris@16: typedef unsigned int rounding_mode; Chris@16: static void get_rounding_mode(rounding_mode& mode) Chris@16: { mode = _control87(0, 0); } Chris@16: static void set_rounding_mode(const rounding_mode mode) Chris@16: { _control87(mode, 0xffff); } Chris@16: static double to_int(const double& x) { return rint(x); } Chris@16: }; Chris@16: Chris@16: } // namespace detail Chris@16: } // namespace interval_lib Chris@16: } // namespace numeric Chris@16: } // namespace boost Chris@16: Chris@16: #endif /* BOOST_NUMERIC_INTERVAL_DETAIL_BCC_ROUNDING_CONTROL_HPP */