Imported Upstream version 1.57.0
[platform/upstream/boost.git] / libs / config / test / boost_no_fenv_h.ipp
1 //  (C) Copyright John Maddock 2001.
2 //  (C) Copyright Bryce Lelbach 2010. 
3 //  Use, modification and distribution are subject to the 
4 //  Boost Software License, Version 1.0. (See accompanying file 
5 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6
7 //  See http://www.boost.org/libs/config for most recent version.
8
9 //  MACRO:         BOOST_NO_FENV_H
10 //  TITLE:         fenv.h
11 //  DESCRIPTION:   There is no standard <fenv.h> available. If <fenv.h> is
12 //                 available, <boost/detail/fenv.hpp> should be included
13 //                 instead of directly including <fenv.h>.
14
15 #include <fenv.h>
16
17 namespace boost_no_fenv_h {
18
19 int test()
20 {
21   /// C++0x required typedefs
22   typedef ::fenv_t has_fenv_t;
23   typedef ::fexcept_t has_fexcept_t;
24
25   /// C++0x required macros
26   #if !defined(FE_DIVBYZERO)
27     #error platform does not define FE_DIVBYZERO
28   #endif
29   
30   #if !defined(FE_INEXACT)
31     #error platform does not define FE_INEXACT
32   #endif
33
34   #if !defined(FE_ALL_EXCEPT)
35     #error platform does not define FE_ALL_EXCEPT
36   #endif
37
38    int i;
39    has_fexcept_t fe;
40    has_fenv_t env;
41   
42    i = feclearexcept(FE_ALL_EXCEPT);
43    i += fetestexcept(FE_ALL_EXCEPT); // All flags should be zero
44    i += fegetexceptflag(&fe, FE_ALL_EXCEPT);
45    i += fesetexceptflag(&fe, FE_ALL_EXCEPT);
46    i += feraiseexcept(0);
47    i += fesetround(fegetround());
48    i += fegetenv(&env);
49    i += fesetenv(&env);
50    i += feholdexcept(&env);
51    if(i)
52       i += feupdateenv(&env);
53
54    return i;
55 }
56
57 }
58