summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2010-01-27 13:36:32 +0000
committerSimon Marlow <marlowsd@gmail.com>2010-01-27 13:36:32 +0000
commit94f8be0021334a1258a137c0e9611d78125ac092 (patch)
tree489cef7245c81c714d2c96a8f0fcefb5f5931b9c /includes
parentf999a6a2fc2954701d1f84684546c97312a9674c (diff)
downloadhaskell-94f8be0021334a1258a137c0e9611d78125ac092.tar.gz
define INFINITY and NAN if they don't exist (#2929)
Diffstat (limited to 'includes')
-rw-r--r--includes/Stg.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/includes/Stg.h b/includes/Stg.h
index 81a034a0e3..cae4a3a4aa 100644
--- a/includes/Stg.h
+++ b/includes/Stg.h
@@ -61,6 +61,27 @@
that depend on config info, such as __USE_FILE_OFFSET64 */
#include <math.h>
+// On Solaris, we don't get the INFINITY and NAN constants unless we
+// #define _STDC_C99, and we can't do that unless we also use -std=c99,
+// because _STDC_C99 causes the headers to use C99 syntax (e.g. restrict).
+// We aren't ready for -std=c99 yet, so define INFINITY/NAN by hand using
+// the gcc builtins.
+#if !defined(INFINITY)
+#if defined(__GNUC__)
+#define INFINITY __builtin_inf()
+#else
+#error No definition for INFINITY
+#endif
+#endif
+
+#if !defined(NAN)
+#if defined(__GNUC__)
+#define NAN __builtin_nan("")
+#else
+#error No definition for NAN
+#endif
+#endif
+
/* -----------------------------------------------------------------------------
Useful definitions
-------------------------------------------------------------------------- */