Chris@16
|
1 /*=============================================================================
|
Chris@16
|
2 Copyright (c) 2010 Bryce Lelbach
|
Chris@16
|
3
|
Chris@16
|
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
6 =============================================================================*/
|
Chris@16
|
7
|
Chris@16
|
8 #include <boost/config.hpp>
|
Chris@16
|
9
|
Chris@16
|
10 #if defined(BOOST_NO_FENV_H)
|
Chris@16
|
11 #error This platform does not have a floating point environment
|
Chris@16
|
12 #endif
|
Chris@16
|
13
|
Chris@16
|
14 #if !defined(BOOST_DETAIL_FENV_HPP)
|
Chris@16
|
15 #define BOOST_DETAIL_FENV_HPP
|
Chris@16
|
16
|
Chris@101
|
17 /* If we're using clang + glibc, we have to get hacky.
|
Chris@16
|
18 * See http://llvm.org/bugs/show_bug.cgi?id=6907 */
|
Chris@16
|
19 #if defined(__clang__) && (__clang_major__ < 3) && \
|
Chris@16
|
20 defined(__GNU_LIBRARY__) && /* up to version 5 */ \
|
Chris@16
|
21 defined(__GLIBC__) && /* version 6 + */ \
|
Chris@16
|
22 !defined(_FENV_H)
|
Chris@16
|
23 #define _FENV_H
|
Chris@16
|
24
|
Chris@16
|
25 #include <features.h>
|
Chris@16
|
26 #include <bits/fenv.h>
|
Chris@16
|
27
|
Chris@16
|
28 extern "C" {
|
Chris@16
|
29 extern int fegetexceptflag (fexcept_t*, int) __THROW;
|
Chris@16
|
30 extern int fesetexceptflag (__const fexcept_t*, int) __THROW;
|
Chris@16
|
31 extern int feclearexcept (int) __THROW;
|
Chris@16
|
32 extern int feraiseexcept (int) __THROW;
|
Chris@16
|
33 extern int fetestexcept (int) __THROW;
|
Chris@16
|
34 extern int fegetround (void) __THROW;
|
Chris@16
|
35 extern int fesetround (int) __THROW;
|
Chris@16
|
36 extern int fegetenv (fenv_t*) __THROW;
|
Chris@16
|
37 extern int fesetenv (__const fenv_t*) __THROW;
|
Chris@16
|
38 extern int feupdateenv (__const fenv_t*) __THROW;
|
Chris@16
|
39 extern int feholdexcept (fenv_t*) __THROW;
|
Chris@16
|
40
|
Chris@16
|
41 #ifdef __USE_GNU
|
Chris@16
|
42 extern int feenableexcept (int) __THROW;
|
Chris@16
|
43 extern int fedisableexcept (int) __THROW;
|
Chris@16
|
44 extern int fegetexcept (void) __THROW;
|
Chris@16
|
45 #endif
|
Chris@16
|
46 }
|
Chris@16
|
47
|
Chris@16
|
48 namespace std { namespace tr1 {
|
Chris@16
|
49 using ::fenv_t;
|
Chris@16
|
50 using ::fexcept_t;
|
Chris@16
|
51 using ::fegetexceptflag;
|
Chris@16
|
52 using ::fesetexceptflag;
|
Chris@16
|
53 using ::feclearexcept;
|
Chris@16
|
54 using ::feraiseexcept;
|
Chris@16
|
55 using ::fetestexcept;
|
Chris@16
|
56 using ::fegetround;
|
Chris@16
|
57 using ::fesetround;
|
Chris@16
|
58 using ::fegetenv;
|
Chris@16
|
59 using ::fesetenv;
|
Chris@16
|
60 using ::feupdateenv;
|
Chris@16
|
61 using ::feholdexcept;
|
Chris@16
|
62 } }
|
Chris@16
|
63
|
Chris@101
|
64 #elif defined(__MINGW32__) && defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 408
|
Chris@101
|
65
|
Chris@101
|
66 // MinGW (32-bit) has a bug in mingw32/bits/c++config.h, it does not define _GLIBCXX_HAVE_FENV_H,
|
Chris@101
|
67 // which prevents the C fenv.h header contents to be included in the C++ wrapper header fenv.h. This is at least
|
Chris@101
|
68 // the case with gcc 4.8.1 packages tested so far, up to 4.8.1-4. Note that there is no issue with
|
Chris@101
|
69 // MinGW-w64.
|
Chris@101
|
70 // To work around the bug we avoid including the C++ wrapper header and include the C header directly
|
Chris@101
|
71 // and import all relevant symbols into std:: ourselves.
|
Chris@101
|
72
|
Chris@101
|
73 #include <../include/fenv.h>
|
Chris@101
|
74
|
Chris@101
|
75 namespace std {
|
Chris@101
|
76 using ::fenv_t;
|
Chris@101
|
77 using ::fexcept_t;
|
Chris@101
|
78 using ::fegetexceptflag;
|
Chris@101
|
79 using ::fesetexceptflag;
|
Chris@101
|
80 using ::feclearexcept;
|
Chris@101
|
81 using ::feraiseexcept;
|
Chris@101
|
82 using ::fetestexcept;
|
Chris@101
|
83 using ::fegetround;
|
Chris@101
|
84 using ::fesetround;
|
Chris@101
|
85 using ::fegetenv;
|
Chris@101
|
86 using ::fesetenv;
|
Chris@101
|
87 using ::feupdateenv;
|
Chris@101
|
88 using ::feholdexcept;
|
Chris@101
|
89 }
|
Chris@101
|
90
|
Chris@16
|
91 #else /* if we're not using GNU's C stdlib, fenv.h should work with clang */
|
Chris@101
|
92
|
Chris@16
|
93 #if defined(__SUNPRO_CC) /* lol suncc */
|
Chris@16
|
94 #include <stdio.h>
|
Chris@16
|
95 #endif
|
Chris@101
|
96
|
Chris@16
|
97 #include <fenv.h>
|
Chris@16
|
98
|
Chris@16
|
99 #endif
|
Chris@16
|
100
|
Chris@16
|
101 #endif /* BOOST_DETAIL_FENV_HPP */
|