Misha Brukman | 9437db4 | 2004-10-29 23:17:45 +0000 | [diff] [blame] | 1 | //===-- IsInf.cpp - Platform-independent wrapper around C99 isinf() -------===// |
Misha Brukman | f976c85 | 2005-04-21 22:55:34 +0000 | [diff] [blame] | 2 | // |
Brian Gaeke | 418f73c | 2004-07-21 03:13:50 +0000 | [diff] [blame] | 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. |
Misha Brukman | f976c85 | 2005-04-21 22:55:34 +0000 | [diff] [blame] | 7 | // |
Brian Gaeke | 418f73c | 2004-07-21 03:13:50 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
Brian Gaeke | 418f73c | 2004-07-21 03:13:50 +0000 | [diff] [blame] | 9 | |
Reid Spencer | 551ccae | 2004-09-01 22:55:40 +0000 | [diff] [blame] | 10 | #include "llvm/Config/config.h" |
Misha Brukman | 9437db4 | 2004-10-29 23:17:45 +0000 | [diff] [blame] | 11 | |
Brian Gaeke | 418f73c | 2004-07-21 03:13:50 +0000 | [diff] [blame] | 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; |
Brian Gaeke | 0d3ac4c | 2004-07-21 03:32:51 +0000 | [diff] [blame] | 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; } |
Chris Lattner | f0ae6c6 | 2004-10-25 18:47:10 +0000 | [diff] [blame] | 24 | #elif defined(_MSC_VER) |
| 25 | #include <float.h> |
| 26 | #define isinf(X) (!_finite(X)) |
Misha Brukman | 9437db4 | 2004-10-29 23:17:45 +0000 | [diff] [blame] | 27 | #elif defined(_AIX) && defined(__GNUC__) |
| 28 | // GCC's fixincludes seems to be removing the isinf() declaration from the |
Misha Brukman | f976c85 | 2005-04-21 22:55:34 +0000 | [diff] [blame] | 29 | // system header /usr/include/math.h |
Misha Brukman | 9437db4 | 2004-10-29 23:17:45 +0000 | [diff] [blame] | 30 | # include <math.h> |
| 31 | static int isinf(double x) { return !finite(x) && x==x; } |
Duraid Madina | aaad838 | 2005-05-16 06:45:57 +0000 | [diff] [blame] | 32 | #elif defined(__hpux) |
| 33 | // HP-UX is "special" |
| 34 | #include <math.h> |
| 35 | static int isinf(double x) { return ((x)==INFINITY)||((x)==-INFINITY); } |
Brian Gaeke | 418f73c | 2004-07-21 03:13:50 +0000 | [diff] [blame] | 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; |