IsInf.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //===-- IsInf.cpp - Platform-independent wrapper around C99 isinf() -------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file was developed by the LLVM research group and is distributed under
  6. // the University of Illinois Open Source License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #include "llvm/Config/config.h"
  10. #if HAVE_ISINF_IN_MATH_H
  11. # include <math.h>
  12. #elif HAVE_ISINF_IN_CMATH
  13. # include <cmath>
  14. #elif HAVE_STD_ISINF_IN_CMATH
  15. # include <cmath>
  16. using std::isinf;
  17. #elif HAVE_FINITE_IN_IEEEFP_H
  18. // A handy workaround I found at http://www.unixguide.net/sun/faq ...
  19. // apparently this has been a problem with Solaris for years.
  20. # include <ieeefp.h>
  21. static int isinf(double x) { return !finite(x) && x==x; }
  22. #elif defined(_MSC_VER)
  23. #include <float.h>
  24. #define isinf(X) (!_finite(X))
  25. #elif defined(_AIX) && defined(__GNUC__)
  26. // GCC's fixincludes seems to be removing the isinf() declaration from the
  27. // system header /usr/include/math.h
  28. # include <math.h>
  29. static int isinf(double x) { return !finite(x) && x==x; }
  30. #elif defined(__hpux)
  31. // HP-UX is "special"
  32. #include <math.h>
  33. static int isinf(double x) { return ((x)==INFINITY)||((x)==-INFINITY); }
  34. #else
  35. # error "Don't know how to get isinf()"
  36. #endif
  37. namespace llvm {
  38. int IsInf (float f) { return isinf (f); }
  39. int IsInf (double d) { return isinf (d); }
  40. } // end namespace llvm;