source:
vendors/XIOS/current/extern/boost/include/boost/numeric/interval/detail/x86gcc_rounding_control.hpp
@
3408
Last change on this file since 3408 was 3408, checked in by rblod, 12 years ago | |
---|---|
|
|
File size: 1.2 KB |
Line | |
---|---|
1 | /* Boost interval/detail/x86gcc_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_X86GCC_ROUNDING_CONTROL_HPP |
12 | #define BOOST_NUMERIC_INTERVAL_DETAIL_X86GCC_ROUNDING_CONTROL_HPP |
13 | |
14 | #ifndef __GNUC__ |
15 | # error This header only works with GNU CC. |
16 | #endif |
17 | |
18 | #ifndef __i386__ |
19 | # error This header only works on x86 CPUs. |
20 | #endif |
21 | |
22 | namespace boost { |
23 | namespace numeric { |
24 | namespace interval_lib { |
25 | namespace detail { |
26 | |
27 | struct x86_rounding |
28 | { |
29 | typedef unsigned short rounding_mode; |
30 | |
31 | static void set_rounding_mode(const rounding_mode& mode) |
32 | { __asm__ __volatile__ ("fldcw %0" : : "m"(mode)); } |
33 | |
34 | static void get_rounding_mode(rounding_mode& mode) |
35 | { __asm__ __volatile__ ("fnstcw %0" : "=m"(mode)); } |
36 | |
37 | template<class T> |
38 | static T to_int(T r) |
39 | { |
40 | T r_; |
41 | __asm__ ("frndint" : "=&t"(r_) : "0"(r)); |
42 | return r_; |
43 | } |
44 | }; |
45 | |
46 | } // namespace detail |
47 | } // namespace interval_lib |
48 | } // namespace numeric |
49 | } // namespace boost |
50 | |
51 | #endif /* BOOST_NUMERIC_INTERVAL_DETAIL_X86GCC_ROUNDING_CONTROL_HPP */ |
Note: See TracBrowser
for help on using the repository browser.