Changeset: 41bd8ea955c8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=41bd8ea955c8
Modified Files:
        NT/monetdb_config.h.in
        configure.ag
        gdk/gdk_aggr.c
        gdk/gdk_atoms.c
        gdk/gdk_calc.c
        monetdb5/modules/kernel/mmath.h
Branch: Jul2017
Log Message:

Use C99 interfaces isnan, isinf, isfinite, and provide them on old Visual 
Studio.


diffs (200 lines):

diff --git a/NT/monetdb_config.h.in b/NT/monetdb_config.h.in
--- a/NT/monetdb_config.h.in
+++ b/NT/monetdb_config.h.in
@@ -160,14 +160,6 @@
 /* Define if the fits module is to be enabled */
 /* #undef HAVE_FITS */
 
-/* Define to 1 if you have the `fpclass' function. */
-#define HAVE_FPCLASS 1         /* uses _fpclass, see mmath.c */
-
-/* Define to 1 if you have the `fpclassify' function. */
-#if defined(_MSC_VER) && _MSC_VER > 1600
-#define HAVE_FPCLASSIFY 1
-#endif
-
 /* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
 /* #undef HAVE_FSEEKO */
 
diff --git a/configure.ag b/configure.ag
--- a/configure.ag
+++ b/configure.ag
@@ -2722,8 +2722,6 @@ AC_CHECK_FUNCS([\
        fabsf \
        fallocate \
        fcntl \
-       fpclass \
-       fpclassify \
        fsync \
        ftime \
        getexecname \
diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -10,7 +10,7 @@
 #include "gdk.h"
 #include "gdk_private.h"
 #include "gdk_calc_private.h"
-#ifdef __INTEL_COMPILER
+#if defined(_MSC_VER) && defined(__INTEL_COMPILER)
 #include <mathimf.h>
 #else
 #include <math.h>
@@ -151,13 +151,11 @@ BATgroupaggrinit(BAT *b, BAT *g, BAT *e,
 /* ---------------------------------------------------------------------- */
 /* sum */
 
-#if defined(_MSC_VER) && _MSC_VER < 1800
-#ifndef isnan
+#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && _MSC_VER < 1800
+#include <float.h>
 #define isnan(x)       _isnan(x)
-#endif
-#ifndef isinf
 #define isinf(x)       (_fpclass(x) & (_FPCLASS_NINF | _FPCLASS_PINF))
-#endif
+#define isfinite(x)    _finite(x)
 #endif
 
 static inline int
diff --git a/gdk/gdk_atoms.c b/gdk/gdk_atoms.c
--- a/gdk/gdk_atoms.c
+++ b/gdk/gdk_atoms.c
@@ -23,12 +23,18 @@
 #include "monetdb_config.h"
 #include "gdk.h"
 #include "gdk_private.h"
-#include <math.h>              /* for isfinite macro */
-#ifdef HAVE_IEEEFP_H
-#include <ieeefp.h>            /* for Solaris */
-#ifndef isfinite
-#define isfinite(f)    finite(f)
+#if defined(_MSC_VER) && defined(__INTEL_COMPILER)
+#include <mathimf.h>                   /* Intel compiler on Windows */
+#else
+#include <math.h>                              /* anywhere else */
 #endif
+
+/* these are only for older Visual Studio compilers (VS 2010) */
+#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && _MSC_VER < 1800
+#include <float.h>
+#define isnan(x)       _isnan(x)
+#define isinf(x)       (_fpclass(x) & (_FPCLASS_NINF | _FPCLASS_PINF))
+#define isfinite(x)    _finite(x)
 #endif
 
 static int
@@ -920,10 +926,6 @@ atom_io(ptr, Int, int)
 #else /* SIZEOF_VOID_P == SIZEOF_LNG */
 atom_io(ptr, Lng, lng)
 #endif
-#if defined(_MSC_VER) && !defined(isfinite)
-/* with more recent Visual Studio, isfinite is defined */
-#define isfinite(x)    _finite(x)
-#endif
 
 int
 dblFromStr(const char *src, int *len, dbl **dst)
@@ -956,9 +958,7 @@ dblFromStr(const char *src, int *len, db
                        p = pe;
                n = (int) (p - src);
                if (n == 0 || (errno == ERANGE && (d < -1 || d > 1))
-#ifdef isfinite
                    || !isfinite(d) /* no NaN or Infinte */
-#endif
                    ) {
                        **dst = dbl_nil; /* default return value is nil */
                        n = 0;
@@ -1025,9 +1025,7 @@ fltFromStr(const char *src, int *len, fl
 #else /* no strtof, try sscanf */
                if (sscanf(src, "%f%n", &f, &n) <= 0 || n <= 0
 #endif
-#ifdef isfinite
                    || !isfinite(f) /* no NaN or infinite */
-#endif
                    ) {
                        **dst = flt_nil; /* default return value is nil */
                        n = 0;
diff --git a/gdk/gdk_calc.c b/gdk/gdk_calc.c
--- a/gdk/gdk_calc.c
+++ b/gdk/gdk_calc.c
@@ -10,7 +10,11 @@
 #include "gdk.h"
 #include "gdk_private.h"
 #include "gdk_calc_private.h"
+#if defined(_MSC_VER) && defined(__INTEL_COMPILER)
+#include <mathimf.h>
+#else
 #include <math.h>
+#endif
 
 /* Define symbol FULL_IMPLEMENTATION to get implementations for all
  * sensible output types for +, -, *, /.  Without the symbol, all
diff --git a/monetdb5/modules/kernel/mmath.h b/monetdb5/modules/kernel/mmath.h
--- a/monetdb5/modules/kernel/mmath.h
+++ b/monetdb5/modules/kernel/mmath.h
@@ -10,50 +10,23 @@
 #define __MMATH_H__
 #include "mal.h"
 #include "mal_exception.h"
-#include <math.h>
-
-#ifdef WIN32
-# include <float.h>
-#if _MSC_VER <= 1600
-/* Windows spells these differently */
-# define isnan(x)      _isnan(x)
-#endif
-# define finite(x)     _finite(x)
-/* NOTE: HAVE_FPCLASS assumed... */
-# define fpclass(x)    _fpclass(x)
-# define FP_NINF               _FPCLASS_NINF
-# define FP_PINF               _FPCLASS_PINF
-#else /* !_MSC_VER */
-# ifdef HAVE_IEEEFP_H
-#  include <ieeefp.h>
-# endif
+#if defined(_MSC_VER) && defined(__INTEL_COMPILER)
+#include <mathimf.h>                   /* Intel compiler on Windows */
+#else
+#include <math.h>                              /* anywhere else */
 #endif
 
-#if defined(HAVE_FPCLASSIFY) || defined(fpclassify)
-/* C99 interface: fpclassify */
-# define MNisinf(x)            (fpclassify(x) == FP_INFINITE)
-# define MNisnan(x)            (fpclassify(x) == FP_NAN)
-# define MNfinite(x)   (!MNisinf(x) && !MNisnan(x))
-#else
-# define MNisnan(x)            isnan(x)
-# define MNfinite(x)   finite(x)
-# ifdef HAVE_ISINF
-#  define MNisinf(x)   isinf(x)
-# else
-static inline int
-MNisinf(double x)
-{
-#ifdef HAVE_FPCLASS
-       int cl = fpclass(x);
+/* these are only for older Visual Studio compilers (VS 2010) */
+#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && _MSC_VER < 1800
+#include <float.h>
+#define isnan(x)       _isnan(x)
+#define isinf(x)       (_fpclass(x) & (_FPCLASS_NINF | _FPCLASS_PINF))
+#define isfinite(x)    _finite(x)
+#endif
 
-       return ((cl == FP_NINF) || (cl == FP_PINF));
-#else
-       (void)x;
-       return 0;               /* XXX not correct if infinite */
-#endif
-}
-# endif
-#endif /* HAVE_FPCLASSIFY */
+#define MNisnan(x)     isnan(x)
+#define MNfinite(x)    isfinite(x)
+#define MNisinf(x)     isinf(x)
 
 #define unopbaseM5_export(X1,X2)\
 mal_export str MATHunary##X1##X2(X2 *res, const X2 *a);
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to