1 /* Floating point unit related functions.
2    Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
3    Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
4 
5 This file is part of the Parma Polyhedra Library (PPL).
6 
7 The PPL is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 The PPL is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
20 
21 For the most up-to-date information see the Parma Polyhedra Library
22 site: http://bugseng.com/products/ppl/ . */
23 
24 #ifndef PPL_fpu_defs_hh
25 #define PPL_fpu_defs_hh 1
26 
27 #include "fpu_types.hh"
28 #include "compiler.hh"
29 
30 namespace Parma_Polyhedra_Library {
31 
32 //! \name Functions Controlling Floating Point Unit
33 //@{
34 
35 //! Initializes the FPU control functions.
36 void
37 fpu_initialize_control_functions();
38 
39 //! Returns the current FPU rounding direction.
40 fpu_rounding_direction_type
41 fpu_get_rounding_direction();
42 
43 //! Sets the FPU rounding direction to \p dir.
44 void
45 fpu_set_rounding_direction(fpu_rounding_direction_type dir);
46 
47 /*! \brief
48   Sets the FPU rounding direction to \p dir and returns the rounding
49   control word previously in use.
50 */
51 fpu_rounding_control_word_type
52 fpu_save_rounding_direction(fpu_rounding_direction_type dir);
53 
54 /*! \brief
55   Sets the FPU rounding direction to \p dir, clears the <EM>inexact
56   computation</EM> status, and returns the rounding control word
57   previously in use.
58 */
59 fpu_rounding_control_word_type
60 fpu_save_rounding_direction_reset_inexact(fpu_rounding_direction_type dir);
61 
62 //! Restores the FPU rounding rounding control word to \p cw.
63 void
64 fpu_restore_rounding_direction(fpu_rounding_control_word_type w);
65 
66 //! Clears the <EM>inexact computation</EM> status.
67 void
68 fpu_reset_inexact();
69 
70 /*! \brief
71   Queries the <EM>inexact computation</EM> status.
72 
73   Returns 0 if the computation was definitely exact, 1 if it was
74   definitely inexact, -1 if definite exactness information is unavailable.
75 */
76 int
77 fpu_check_inexact();
78 
79 //@} // Functions Controlling Floating Point Unit
80 
81 } // namespace Parma_Polyhedra_Library
82 
83 #if PPL_CAN_CONTROL_FPU
84 
85 #if defined(__i386__) && (defined(__GNUC__) || defined(__INTEL_COMPILER))
86 #include "fpu-ia32_inlines.hh"
87 #elif defined(PPL_HAVE_IEEEFP_H)                                        \
88   && (defined(__sparc)                                                  \
89       || defined(sparc)                                                 \
90       || defined(__sparc__))
91 #include "fpu-sparc_inlines.hh"
92 #elif defined(PPL_HAVE_FENV_H)
93 #include "fpu-c99_inlines.hh"
94 #else
95 #error "PPL_CAN_CONTROL_FPU evaluates to true: why?"
96 #endif
97 
98 #else // !PPL_CAN_CONTROL_FPU
99 
100 #include "fpu-none_inlines.hh"
101 
102 #endif // !PPL_CAN_CONTROL_FPU
103 
104 #endif // !defined(PPL_fpu_defs_hh)
105