1193323Sed//===-- IsInf.cpp - Platform-independent wrapper around C99 isinf() -------===// 2193323Sed// 3193323Sed// The LLVM Compiler Infrastructure 4193323Sed// 5193323Sed// This file is distributed under the University of Illinois Open Source 6193323Sed// License. See LICENSE.TXT for details. 7193323Sed// 8193323Sed//===----------------------------------------------------------------------===// 9193323Sed// 10193323Sed// Platform-independent wrapper around C99 isinf() 11193323Sed// 12193323Sed//===----------------------------------------------------------------------===// 13193323Sed 14193323Sed#include "llvm/Config/config.h" 15193323Sed 16193323Sed#if HAVE_ISINF_IN_MATH_H 17193323Sed# include <math.h> 18193323Sed#elif HAVE_ISINF_IN_CMATH 19193323Sed# include <cmath> 20193323Sed#elif HAVE_STD_ISINF_IN_CMATH 21193323Sed# include <cmath> 22193323Sedusing std::isinf; 23193323Sed#elif HAVE_FINITE_IN_IEEEFP_H 24193323Sed// A handy workaround I found at http://www.unixguide.net/sun/faq ... 25193323Sed// apparently this has been a problem with Solaris for years. 26193323Sed# include <ieeefp.h> 27193323Sedstatic int isinf(double x) { return !finite(x) && x==x; } 28193323Sed#elif defined(_MSC_VER) 29193323Sed#include <float.h> 30193323Sed#define isinf(X) (!_finite(X)) 31193323Sed#elif defined(_AIX) && defined(__GNUC__) 32193323Sed// GCC's fixincludes seems to be removing the isinf() declaration from the 33193323Sed// system header /usr/include/math.h 34193323Sed# include <math.h> 35193323Sedstatic int isinf(double x) { return !finite(x) && x==x; } 36193323Sed#elif defined(__hpux) 37193323Sed// HP-UX is "special" 38193323Sed#include <math.h> 39193323Sedstatic int isinf(double x) { return ((x) == INFINITY) || ((x) == -INFINITY); } 40193323Sed#else 41193323Sed# error "Don't know how to get isinf()" 42193323Sed#endif 43193323Sed 44193323Sednamespace llvm { 45193323Sed 46193323Sedint IsInf(float f) { return isinf(f); } 47193323Sedint IsInf(double d) { return isinf(d); } 48193323Sed 49193323Sed} // end namespace llvm; 50