Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.5 KiB

  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. #ifndef LLVM_SUPPORT_FENV_H
  15. #define LLVM_SUPPORT_FENV_H
  16. #include "llvm/Config/config.h"
  17. #include <cerrno>
  18. #ifdef HAVE_FENV_H
  19. #include <fenv.h>
  20. #endif
  21. // FIXME: Clang's #include handling apparently doesn't work for libstdc++'s
  22. // fenv.h; see PR6907 for details.
  23. #if defined(__clang__) && defined(_GLIBCXX_FENV_H)
  24. #undef HAVE_FENV_H
  25. #endif
  26. namespace llvm {
  27. namespace sys {
  28. /// llvm_fenv_clearexcept - Clear the floating-point exception state.
  29. static inline void llvm_fenv_clearexcept() {
  30. #if defined(HAVE_FENV_H) && HAVE_DECL_FE_ALL_EXCEPT
  31. feclearexcept(FE_ALL_EXCEPT);
  32. #endif
  33. errno = 0;
  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. #if defined(HAVE_FENV_H) && HAVE_DECL_FE_ALL_EXCEPT && HAVE_DECL_FE_INEXACT
  41. if (fetestexcept(FE_ALL_EXCEPT & ~FE_INEXACT))
  42. return true;
  43. #endif
  44. return false;
  45. }
  46. } // End sys namespace
  47. } // End llvm namespace
  48. #endif