blob: 070ed4fcc1c790afdfb765080bf65fd747372d66 [file] [log] [blame]
Misha Brukman9437db42004-10-29 23:17:45 +00001//===-- IsInf.cpp - Platform-independent wrapper around C99 isinf() -------===//
Misha Brukmanf976c852005-04-21 22:55:34 +00002//
Brian Gaeke418f73c2004-07-21 03:13:50 +00003// 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.
Misha Brukmanf976c852005-04-21 22:55:34 +00007//
Brian Gaeke418f73c2004-07-21 03:13:50 +00008//===----------------------------------------------------------------------===//
Brian Gaeke418f73c2004-07-21 03:13:50 +00009
Reid Spencer551ccae2004-09-01 22:55:40 +000010#include "llvm/Config/config.h"
Misha Brukman9437db42004-10-29 23:17:45 +000011
Brian Gaeke418f73c2004-07-21 03:13:50 +000012#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>
18using std::isinf;
Brian Gaeke0d3ac4c2004-07-21 03:32:51 +000019#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>
23static int isinf(double x) { return !finite(x) && x==x; }
Chris Lattnerf0ae6c62004-10-25 18:47:10 +000024#elif defined(_MSC_VER)
25#include <float.h>
26#define isinf(X) (!_finite(X))
Misha Brukman9437db42004-10-29 23:17:45 +000027#elif defined(_AIX) && defined(__GNUC__)
28// GCC's fixincludes seems to be removing the isinf() declaration from the
Misha Brukmanf976c852005-04-21 22:55:34 +000029// system header /usr/include/math.h
Misha Brukman9437db42004-10-29 23:17:45 +000030# include <math.h>
31static int isinf(double x) { return !finite(x) && x==x; }
Brian Gaeke418f73c2004-07-21 03:13:50 +000032#else
33# error "Don't know how to get isinf()"
34#endif
35
36namespace llvm {
37
38int IsInf (float f) { return isinf (f); }
39int IsInf (double d) { return isinf (d); }
40
41}; // end namespace llvm;