From add44e684cb9f1b46d1d5facdf6255360fa7b656 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 25 Aug 2017 11:28:44 +0200 Subject: [PATCH] compilation failure in oqgraph after 4aaa38d26ed9 on many builders oqgraph failed to compile because isfinite wasn't defined. fix this mess of ifdefs/defines to work properly no matter whether isfinite/isnan/isinf is a function or a macro and whether stl header undefines it or not. and remove the hackish workaround from oqgraph. --- include/my_global.h | 31 ++++++++++++++++++++----------- storage/oqgraph/oqgraph_thunk.cc | 12 ------------ 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/include/my_global.h b/include/my_global.h index 7e31783e3269f..fa9270893e18c 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -803,26 +803,35 @@ inline unsigned long long my_double2ulonglong(double d) #define SIZE_T_MAX (~((size_t) 0)) #endif +#ifndef HAVE_FINITE +#define finite(x) (1.0 / fabs(x) > 0.0) +#endif + #ifndef isfinite -#ifdef HAVE_FINITE #define isfinite(x) finite(x) -#else -#define finite(x) (1.0 / fabs(x) > 0.0) -#endif /* HAVE_FINITE */ -#elif (__cplusplus >= 201103L) -#include -static inline bool isfinite(double x) { return std::isfinite(x); } -#endif /* isfinite */ +#endif #ifndef HAVE_ISNAN #define isnan(x) ((x) != (x)) #endif #define my_isnan(x) isnan(x) -#ifdef HAVE_ISINF +#ifndef HAVE_ISINF +#define isinf(X) (!isfinite(X) && !isnan(X)) +#endif #define my_isinf(X) isinf(X) -#else /* !HAVE_ISINF */ -#define my_isinf(X) (!finite(X) && !isnan(X)) + +#ifdef __cplusplus +#include +#ifndef isfinite +#define isfinite(X) std::isfinite(X) +#endif +#ifndef isnan +#define isnan(X) std::isnan(X) +#endif +#ifndef isinf +#define isinf(X) std::isinf(X) +#endif #endif /* Define missing math constants. */ diff --git a/storage/oqgraph/oqgraph_thunk.cc b/storage/oqgraph/oqgraph_thunk.cc index 1d0c651bec4c8..5e254450a2b19 100644 --- a/storage/oqgraph/oqgraph_thunk.cc +++ b/storage/oqgraph/oqgraph_thunk.cc @@ -28,18 +28,6 @@ #include -/* This is needed as boost undef's isfinite */ -#ifndef isfinite -#ifdef HAVE_FINITE -#define isfinite(x) finite(x) -#else -#define isfinite(x) (1.0 / fabs(x) > 0.0) -#endif /* HAVE_FINITE */ -#elif (__cplusplus >= 201103L) -#include -static inline bool isfinite(double x) { return std::isfinite(x); } -#endif /* isfinite */ - #include "unireg.h" #include "sql_base.h" #include "table.h"