blob: 7087dd94c1421a617ef47b24cf95a4b7ecec9e9d [file] [log] [blame]
Brian Gaeke418f73c2004-07-21 03:13:50 +00001//===-- IsInf.cpp ---------------------------------------------------------===//
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//
10// Platform-independent wrapper around C99 isinf().
11//
12//===----------------------------------------------------------------------===//
13
Reid Spencer551ccae2004-09-01 22:55:40 +000014#include "llvm/Config/config.h"
Brian Gaeke418f73c2004-07-21 03:13:50 +000015#if HAVE_ISINF_IN_MATH_H
16# include <math.h>
17#elif HAVE_ISINF_IN_CMATH
18# include <cmath>
19#elif HAVE_STD_ISINF_IN_CMATH
20# include <cmath>
21using std::isinf;
Brian Gaeke0d3ac4c2004-07-21 03:32:51 +000022#elif HAVE_FINITE_IN_IEEEFP_H
23// A handy workaround I found at http://www.unixguide.net/sun/faq ...
24// apparently this has been a problem with Solaris for years.
25# include <ieeefp.h>
26static int isinf(double x) { return !finite(x) && x==x; }
Chris Lattnerf0ae6c62004-10-25 18:47:10 +000027#elif defined(_MSC_VER)
28#include <float.h>
29#define isinf(X) (!_finite(X))
Brian Gaeke418f73c2004-07-21 03:13:50 +000030#else
31# error "Don't know how to get isinf()"
32#endif
33
34namespace llvm {
35
36int IsInf (float f) { return isinf (f); }
37int IsInf (double d) { return isinf (d); }
38
39}; // end namespace llvm;