76 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// Picolibc does not define some of the floating point environment macros for10// arm platforms without hardware floating point support.11// UNSUPPORTED: LIBCXX-PICOLIBC-FIXME12 13// <fenv.h>14 15#include <fenv.h>16 17#include "test_macros.h"18 19#ifndef FE_DIVBYZERO20#error FE_DIVBYZERO not defined21#endif22 23#ifndef FE_INEXACT24#error FE_INEXACT not defined25#endif26 27#ifndef FE_INVALID28#error FE_INVALID not defined29#endif30 31#ifndef FE_OVERFLOW32#error FE_OVERFLOW not defined33#endif34 35#ifndef FE_UNDERFLOW36#error FE_UNDERFLOW not defined37#endif38 39#ifndef FE_ALL_EXCEPT40#error FE_ALL_EXCEPT not defined41#endif42 43#ifndef FE_DOWNWARD44#error FE_DOWNWARD not defined45#endif46 47#ifndef FE_TONEAREST48#error FE_TONEAREST not defined49#endif50 51#ifndef FE_TOWARDZERO52#error FE_TOWARDZERO not defined53#endif54 55#ifndef FE_UPWARD56#error FE_UPWARD not defined57#endif58 59#ifndef FE_DFL_ENV60#error FE_DFL_ENV not defined61#endif62 63fenv_t fenv = {};64fexcept_t fex = fexcept_t();65ASSERT_SAME_TYPE(int, decltype(::feclearexcept(0)));66ASSERT_SAME_TYPE(int, decltype(::fegetexceptflag(&fex, 0)));67ASSERT_SAME_TYPE(int, decltype(::feraiseexcept(0)));68ASSERT_SAME_TYPE(int, decltype(::fesetexceptflag(&fex, 0)));69ASSERT_SAME_TYPE(int, decltype(::fetestexcept(0)));70ASSERT_SAME_TYPE(int, decltype(::fegetround()));71ASSERT_SAME_TYPE(int, decltype(::fesetround(0)));72ASSERT_SAME_TYPE(int, decltype(::fegetenv(&fenv)));73ASSERT_SAME_TYPE(int, decltype(::feholdexcept(&fenv)));74ASSERT_SAME_TYPE(int, decltype(::fesetenv(&fenv)));75ASSERT_SAME_TYPE(int, decltype(::feupdateenv(&fenv)));76