source: NonGTP/Boost/boost/numeric/interval/detail/bcc_rounding_control.hpp @ 857

Revision 857, 1.6 KB checked in by igarcia, 19 years ago (diff)
Line 
1/* Boost interval/detail/bcc_rounding_control.hpp file
2 *
3 * Copyright 2000 Jens Maurer
4 * Copyright 2002 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion
5 *
6 * Distributed under the Boost Software License, Version 1.0.
7 * (See accompanying file LICENSE_1_0.txt or
8 * copy at http://www.boost.org/LICENSE_1_0.txt)
9 */
10
11#ifndef BOOST_NUMERIC_INTERVAL_DETAIL_BCC_ROUNDING_CONTROL_HPP
12#define BOOST_NUMERIC_INTERVAL_DETAIL_BCC_ROUNDING_CONTROL_HPP
13
14#ifndef __BORLANDC__
15#  error This header is only intended for Borland C++.
16#endif
17
18#ifndef _M_IX86
19#  error This header only works on x86 CPUs.
20#endif
21
22#include <float.h>      // Borland C++ rounding control
23
24namespace boost {
25namespace numeric {
26namespace interval_lib {
27namespace detail {
28
29#ifndef BOOST_NUMERIC_INTERVAL_KEEP_EXCEPTIONS_FOR_BCC
30extern "C" { unsigned int _RTLENTRY _fm_init(void); }
31
32struct borland_workaround {
33  borland_workaround() { _fm_init(); }
34};
35
36static borland_workaround borland_workaround_exec;
37#endif // BOOST_NUMERIC_INTERVAL_KEEP_EXCEPTIONS_FOR_BCC
38
39__inline double rint(double)
40{ __emit__(0xD9); __emit__(0xFC); /* asm FRNDINT */ }
41
42struct x86_rounding
43{
44  typedef unsigned int rounding_mode;
45  static void get_rounding_mode(rounding_mode& mode)
46  { mode = _control87(0, 0); }
47  static void set_rounding_mode(const rounding_mode mode)
48  { _control87(mode, 0xffff); }
49  static double to_int(const double& x) { return rint(x); }
50};
51
52} // namespace detail
53} // namespace interval_lib
54} // namespace numeric
55} // namespace boost
56
57#endif /* BOOST_NUMERIC_INTERVAL_DETAIL_BCC_ROUNDING_CONTROL_HPP */
Note: See TracBrowser for help on using the repository browser.