Move the search for the appropriate AND instruction
[oota-llvm.git] / include / llvm / System / FEnv.h
1 //===- llvm/System/FEnv.h - Host floating-point exceptions ------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file provides an operating system independent interface to
11 // floating-point exception interfaces.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_SYSTEM_FENV_H
16 #define LLVM_SYSTEM_FENV_H
17
18 #include "llvm/Config/config.h"
19 #include <cerrno>
20 #ifdef HAVE_FENV_H
21 #include <fenv.h>
22 #endif
23
24 namespace llvm {
25 namespace sys {
26
27 /// llvm_fenv_clearexcept - Clear the floating-point exception state.
28 static inline void llvm_fenv_clearexcept() {
29 #ifdef HAVE_FENV_H
30   feclearexcept(FE_ALL_EXCEPT);
31 #endif
32   errno = 0;
33 }
34
35 /// llvm_fenv_testexcept - Test if a floating-point exception was raised.
36 static inline bool llvm_fenv_testexcept() {
37   int errno_val = errno;
38   if (errno_val == ERANGE || errno_val == EDOM)
39     return true;
40 #ifdef HAVE_FENV_H
41   if (fetestexcept(FE_ALL_EXCEPT & ~FE_INEXACT))
42     return true;
43 #endif
44   return false;
45 }
46
47 } // End sys namespace
48 } // End llvm namespace
49
50 #endif