diff src/macros.h @ 8289:6ae3fb4fe7c1 v7.4.1437

commit https://github.com/vim/vim/commit/136f29a91dbafce424e31a4af133155f997e8f78 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Feb 27 20:14:15 2016 +0100 patch 7.4.1437 Problem: Old system doesn't have isinf() and NAN. (Ben Fritz) Solution: Adjust #ifdefs. Detect isnan() and isinf() functions with configure. Use a replacement when missing. (Kazunobu Kuriyama)
author Christian Brabandt <cb@256bit.org>
date Sat, 27 Feb 2016 20:15:04 +0100
parents 6ee794dc950e
children 18fd94bd4eb8
line wrap: on
line diff
--- a/src/macros.h
+++ b/src/macros.h
@@ -320,3 +320,32 @@
 #if defined(FEAT_CHANNEL) || defined(FEAT_JOB) || defined(FEAT_CLIENTSERVER)
 # define MESSAGE_QUEUE
 #endif
+
+#if defined(FEAT_EVAL) && defined(FEAT_FLOAT)
+# include <float.h>
+# if defined(HAVE_MATH_H)
+   /* for isnan() and isinf() */
+#  include <math.h>
+# endif
+# if defined(WIN32) && !defined(isnan)
+#  define isnan(x) _isnan(x)
+#  define isinf(x) (!_finite(x) && !_isnan(x))
+# else
+#  ifndef HAVE_ISNAN
+    static inline int isnan(double x) { return x != x; }
+#  endif
+#  ifndef HAVE_ISINF
+    static inline int isinf(double x) { return !isnan(x) && isnan(x - x); }
+#  endif
+# endif
+# if !defined(INFINITY)
+#  if defined(DBL_MAX)
+#   define INFINITY (DBL_MAX+DBL_MAX)
+#  else
+#   define INFINITY (1.0 / 0.0)
+#  endif
+# endif
+# if !defined(NAN)
+#  define NAN (INFINITY-INFINITY)
+# endif
+#endif