2004-10-30 07:17:45 +08:00
|
|
|
//===-- IsInf.cpp - Platform-independent wrapper around C99 isinf() -------===//
|
2005-04-22 06:55:34 +08:00
|
|
|
//
|
2004-07-21 11:13:50 +08:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 04:36:04 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-22 06:55:34 +08:00
|
|
|
//
|
2004-07-21 11:13:50 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2006-08-12 07:52:54 +08:00
|
|
|
//
|
|
|
|
// Platform-independent wrapper around C99 isinf()
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2004-07-21 11:13:50 +08:00
|
|
|
|
2004-09-02 06:55:40 +08:00
|
|
|
#include "llvm/Config/config.h"
|
2004-10-30 07:17:45 +08:00
|
|
|
|
2004-07-21 11:13:50 +08:00
|
|
|
#if HAVE_ISINF_IN_MATH_H
|
|
|
|
# include <math.h>
|
|
|
|
#elif HAVE_ISINF_IN_CMATH
|
|
|
|
# include <cmath>
|
|
|
|
#elif HAVE_STD_ISINF_IN_CMATH
|
|
|
|
# include <cmath>
|
|
|
|
using std::isinf;
|
2004-07-21 11:32:51 +08:00
|
|
|
#elif HAVE_FINITE_IN_IEEEFP_H
|
|
|
|
// A handy workaround I found at http://www.unixguide.net/sun/faq ...
|
|
|
|
// apparently this has been a problem with Solaris for years.
|
|
|
|
# include <ieeefp.h>
|
|
|
|
static int isinf(double x) { return !finite(x) && x==x; }
|
2004-10-26 02:47:10 +08:00
|
|
|
#elif defined(_MSC_VER)
|
|
|
|
#include <float.h>
|
|
|
|
#define isinf(X) (!_finite(X))
|
2004-10-30 07:17:45 +08:00
|
|
|
#elif defined(_AIX) && defined(__GNUC__)
|
|
|
|
// GCC's fixincludes seems to be removing the isinf() declaration from the
|
2005-04-22 06:55:34 +08:00
|
|
|
// system header /usr/include/math.h
|
2004-10-30 07:17:45 +08:00
|
|
|
# include <math.h>
|
|
|
|
static int isinf(double x) { return !finite(x) && x==x; }
|
2005-05-16 14:45:57 +08:00
|
|
|
#elif defined(__hpux)
|
|
|
|
// HP-UX is "special"
|
|
|
|
#include <math.h>
|
2006-08-12 07:52:54 +08:00
|
|
|
static int isinf(double x) { return ((x) == INFINITY) || ((x) == -INFINITY); }
|
2004-07-21 11:13:50 +08:00
|
|
|
#else
|
|
|
|
# error "Don't know how to get isinf()"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2006-08-12 07:52:54 +08:00
|
|
|
int IsInf(float f) { return isinf(f); }
|
|
|
|
int IsInf(double d) { return isinf(d); }
|
2004-07-21 11:13:50 +08:00
|
|
|
|
2006-05-25 01:04:05 +08:00
|
|
|
} // end namespace llvm;
|