blob: 5160110bc2e2828bdece7fdbc5779222b35693f1 [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; }
Duraid Madinaaaad8382005-05-16 06:45:57 +000032#elif defined(__hpux)
33// HP-UX is "special"
34#include <math.h>
35static int isinf(double x) { return ((x)==INFINITY)||((x)==-INFINITY); }
Brian Gaeke418f73c2004-07-21 03:13:50 +000036#else
37# error "Don't know how to get isinf()"
38#endif
39
40namespace llvm {
41
42int IsInf (float f) { return isinf (f); }
43int IsInf (double d) { return isinf (d); }
44
45}; // end namespace llvm;