blob: 9b0556fcb09f42d218b0d175e2f308dae9385bc5 [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"
Reid Spencer7107c3b2006-07-26 16:18:00 +000011#include "llvm/System/IncludeFile.h"
Misha Brukman9437db42004-10-29 23:17:45 +000012
Brian Gaeke418f73c2004-07-21 03:13:50 +000013#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>
19using std::isinf;
Brian Gaeke0d3ac4c2004-07-21 03:32:51 +000020#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>
24static int isinf(double x) { return !finite(x) && x==x; }
Chris Lattnerf0ae6c62004-10-25 18:47:10 +000025#elif defined(_MSC_VER)
26#include <float.h>
27#define isinf(X) (!_finite(X))
Misha Brukman9437db42004-10-29 23:17:45 +000028#elif defined(_AIX) && defined(__GNUC__)
29// GCC's fixincludes seems to be removing the isinf() declaration from the
Misha Brukmanf976c852005-04-21 22:55:34 +000030// system header /usr/include/math.h
Misha Brukman9437db42004-10-29 23:17:45 +000031# include <math.h>
32static int isinf(double x) { return !finite(x) && x==x; }
Duraid Madinaaaad8382005-05-16 06:45:57 +000033#elif defined(__hpux)
34// HP-UX is "special"
35#include <math.h>
36static int isinf(double x) { return ((x)==INFINITY)||((x)==-INFINITY); }
Brian Gaeke418f73c2004-07-21 03:13:50 +000037#else
38# error "Don't know how to get isinf()"
39#endif
40
41namespace llvm {
42
43int IsInf (float f) { return isinf (f); }
44int IsInf (double d) { return isinf (d); }
45
Chris Lattnerd74ea2b2006-05-24 17:04:05 +000046} // end namespace llvm;
Reid Spencer7107c3b2006-07-26 16:18:00 +000047
48DEFINING_FILE_FOR(SupportIsInf)