xref: /aosp_15_r20/external/cronet/third_party/libc++/src/test/std/numerics/cfenv/cfenv.syn/cfenv.pass.cpp (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // Picolibc does not define some of the floating point environment macros for
10 // arm platforms without hardware floating point support.
11 // UNSUPPORTED: LIBCXX-PICOLIBC-FIXME
12 
13 // <cfenv>
14 
15 #include <cfenv>
16 #include <type_traits>
17 
18 #include "test_macros.h"
19 
20 #ifndef FE_DIVBYZERO
21 #error FE_DIVBYZERO not defined
22 #endif
23 
24 #ifndef FE_INEXACT
25 #error FE_INEXACT not defined
26 #endif
27 
28 #ifndef FE_INVALID
29 #error FE_INVALID not defined
30 #endif
31 
32 #ifndef FE_OVERFLOW
33 #error FE_OVERFLOW not defined
34 #endif
35 
36 #ifndef FE_UNDERFLOW
37 #error FE_UNDERFLOW not defined
38 #endif
39 
40 #ifndef FE_ALL_EXCEPT
41 #error FE_ALL_EXCEPT not defined
42 #endif
43 
44 #ifndef FE_DOWNWARD
45 #error FE_DOWNWARD not defined
46 #endif
47 
48 #ifndef FE_TONEAREST
49 #error FE_TONEAREST not defined
50 #endif
51 
52 #ifndef FE_TOWARDZERO
53 #error FE_TOWARDZERO not defined
54 #endif
55 
56 #ifndef FE_UPWARD
57 #error FE_UPWARD not defined
58 #endif
59 
60 #ifndef FE_DFL_ENV
61 #error FE_DFL_ENV not defined
62 #endif
63 
main(int,char **)64 int main(int, char**)
65 {
66     std::fenv_t fenv;
67     std::fexcept_t fex;
68     ((void)fenv); // Prevent unused warning
69     ((void)fex); // Prevent unused warning
70     static_assert((std::is_same<decltype(std::feclearexcept(0)), int>::value), "");
71     static_assert((std::is_same<decltype(std::fegetexceptflag(&fex, 0)), int>::value), "");
72     static_assert((std::is_same<decltype(std::feraiseexcept(0)), int>::value), "");
73     static_assert((std::is_same<decltype(std::fesetexceptflag(&fex, 0)), int>::value), "");
74     static_assert((std::is_same<decltype(std::fetestexcept(0)), int>::value), "");
75     static_assert((std::is_same<decltype(std::fegetround()), int>::value), "");
76     static_assert((std::is_same<decltype(std::fesetround(0)), int>::value), "");
77     static_assert((std::is_same<decltype(std::fegetenv(&fenv)), int>::value), "");
78     static_assert((std::is_same<decltype(std::feholdexcept(&fenv)), int>::value), "");
79     static_assert((std::is_same<decltype(std::fesetenv(&fenv)), int>::value), "");
80     static_assert((std::is_same<decltype(std::feupdateenv(&fenv)), int>::value), "");
81 
82   return 0;
83 }
84