PageRenderTime 154ms CodeModel.GetById 66ms app.highlight 3ms RepoModel.GetById 35ms app.codeStats 0ms

/3rd_party/llvm/include/llvm/Support/FEnv.h

https://code.google.com/p/softart/
C++ Header | 56 lines | 31 code | 8 blank | 17 comment | 9 complexity | ab6012971bfb57318602157c216efaca MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause, JSON, MPL-2.0-no-copyleft-exception, GPL-2.0, GPL-3.0, LGPL-3.0, BSD-2-Clause
 1//===- llvm/Support/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_SUPPORT_FENV_H
16#define LLVM_SUPPORT_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// 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)
27#undef HAVE_FENV_H
28#endif
29
30namespace llvm {
31namespace sys {
32
33/// llvm_fenv_clearexcept - Clear the floating-point exception state.
34static inline void llvm_fenv_clearexcept() {
35#if defined(HAVE_FENV_H) && HAVE_DECL_FE_ALL_EXCEPT
36  feclearexcept(FE_ALL_EXCEPT);
37#endif
38  errno = 0;
39}
40
41/// llvm_fenv_testexcept - Test if a floating-point exception was raised.
42static inline bool llvm_fenv_testexcept() {
43  int errno_val = errno;
44  if (errno_val == ERANGE || errno_val == EDOM)
45    return true;
46#if defined(HAVE_FENV_H) && HAVE_DECL_FE_ALL_EXCEPT && HAVE_DECL_FE_INEXACT
47  if (fetestexcept(FE_ALL_EXCEPT & ~FE_INEXACT))
48    return true;
49#endif
50  return false;
51}
52
53} // End sys namespace
54} // End llvm namespace
55
56#endif