Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/numeric/interval/detail/x86gcc_rounding_control.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
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 */ |