HP-UX system headers make a mess of isinf(), so much so that gcc fixincludes
[oota-llvm.git] / lib / Support / IsInf.cpp
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
10 #include "llvm/Config/config.h"
11
12 #if HAVE_ISINF_IN_MATH_H
13 # include <math.h>
14 #elif HAVE_ISINF_IN_CMATH
15 # include <cmath>
16 #elif HAVE_STD_ISINF_IN_CMATH
17 # include <cmath>
18 using std::isinf;
19 #elif HAVE_FINITE_IN_IEEEFP_H
20 // A handy workaround I found at http://www.unixguide.net/sun/faq ...
21 // apparently this has been a problem with Solaris for years.
22 # include <ieeefp.h>
23 static int isinf(double x) { return !finite(x) && x==x; }
24 #elif defined(_MSC_VER)
25 #include <float.h>
26 #define isinf(X) (!_finite(X))
27 #elif defined(_AIX) && defined(__GNUC__)
28 // GCC's fixincludes seems to be removing the isinf() declaration from the
29 // system header /usr/include/math.h
30 # include <math.h>
31 static int isinf(double x) { return !finite(x) && x==x; }
32 #elif defined(__hpux)
33 // HP-UX is "special"
34 #include <math.h>
35 static int isinf(double x) { return ((x)==INFINITY)||((x)==-INFINITY); }
36 #else
37 # error "Don't know how to get isinf()"
38 #endif
39
40 namespace llvm {
41
42 int IsInf (float f)  { return isinf (f); }
43 int IsInf (double d) { return isinf (d); }
44
45 }; // end namespace llvm;