Brian Gaeke | 418f73c | 2004-07-21 03:13:50 +0000 | [diff] [blame] | 1 | //===-- IsInf.cpp ---------------------------------------------------------===// |
| 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 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // Platform-independent wrapper around C99 isinf(). |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Reid Spencer | 551ccae | 2004-09-01 22:55:40 +0000 | [diff] [blame] | 14 | #include "llvm/Config/config.h" |
Brian Gaeke | 418f73c | 2004-07-21 03:13:50 +0000 | [diff] [blame] | 15 | #if HAVE_ISINF_IN_MATH_H |
| 16 | # include <math.h> |
| 17 | #elif HAVE_ISINF_IN_CMATH |
| 18 | # include <cmath> |
| 19 | #elif HAVE_STD_ISINF_IN_CMATH |
| 20 | # include <cmath> |
| 21 | using std::isinf; |
Brian Gaeke | 0d3ac4c | 2004-07-21 03:32:51 +0000 | [diff] [blame] | 22 | #elif HAVE_FINITE_IN_IEEEFP_H |
| 23 | // A handy workaround I found at http://www.unixguide.net/sun/faq ... |
| 24 | // apparently this has been a problem with Solaris for years. |
| 25 | # include <ieeefp.h> |
| 26 | static int isinf(double x) { return !finite(x) && x==x; } |
Chris Lattner | f0ae6c6 | 2004-10-25 18:47:10 +0000 | [diff] [blame^] | 27 | #elif defined(_MSC_VER) |
| 28 | #include <float.h> |
| 29 | #define isinf(X) (!_finite(X)) |
Brian Gaeke | 418f73c | 2004-07-21 03:13:50 +0000 | [diff] [blame] | 30 | #else |
| 31 | # error "Don't know how to get isinf()" |
| 32 | #endif |
| 33 | |
| 34 | namespace llvm { |
| 35 | |
| 36 | int IsInf (float f) { return isinf (f); } |
| 37 | int IsInf (double d) { return isinf (d); } |
| 38 | |
| 39 | }; // end namespace llvm; |