1 //===- llvm/Support/FEnv.h - Host floating-point exceptions ------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file provides an operating system independent interface to
11 // floating-point exception interfaces.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_SYSTEM_FENV_H
16 #define LLVM_SYSTEM_FENV_H
18 #include "llvm/Config/config.h"
24 // FIXME: Clang's #include handling apparently doesn't work for libstdc++'s
25 // fenv.h; see PR6907 for details.
26 #if defined(__clang__) && defined(_GLIBCXX_FENV_H)
33 /// llvm_fenv_clearexcept - Clear the floating-point exception state.
34 static inline void llvm_fenv_clearexcept() {
36 feclearexcept(FE_ALL_EXCEPT);
41 /// llvm_fenv_testexcept - Test if a floating-point exception was raised.
42 static inline bool llvm_fenv_testexcept() {
43 int errno_val = errno;
44 if (errno_val == ERANGE || errno_val == EDOM)
47 if (fetestexcept(FE_ALL_EXCEPT & ~FE_INEXACT))
53 } // End sys namespace
54 } // End llvm namespace