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