Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/numeric/interval/detail/x86gcc_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/x86gcc_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_X86GCC_ROUNDING_CONTROL_HPP
0012 #define BOOST_NUMERIC_INTERVAL_DETAIL_X86GCC_ROUNDING_CONTROL_HPP
0013 
0014 #if !defined(__GNUC__) && !(defined(__BORLANDC__) && defined(__clang__))
0015 #  error This header only works with GNU CC.
0016 #endif
0017 
0018 #if !defined(__i386__) && !defined(__x86_64__)
0019 #  error This header only works on x86 CPUs.
0020 #endif
0021 
0022 namespace boost {
0023 namespace numeric {
0024 namespace interval_lib {
0025 namespace detail {
0026 
0027 struct x86_rounding
0028 {
0029   typedef unsigned short rounding_mode;
0030 
0031   static void set_rounding_mode(const rounding_mode& mode)
0032   { __asm__ __volatile__ ("fldcw %0" : : "m"(mode)); }
0033 
0034   static void get_rounding_mode(rounding_mode& mode)
0035   { __asm__ __volatile__ ("fnstcw %0" : "=m"(mode)); }
0036 
0037   template<class T>
0038   static T to_int(T r)
0039   {
0040     T r_;
0041     __asm__ ("frndint" : "=&t"(r_) : "0"(r));
0042     return r_;
0043   }
0044 };
0045 
0046 } // namespace detail
0047 } // namespace interval_lib
0048 } // namespace numeric
0049 } // namespace boost
0050 
0051 #endif /* BOOST_NUMERIC_INTERVAL_DETAIL_X86GCC_ROUNDING_CONTROL_HPP */