Skip to content

Commit

Permalink
compilation failure in oqgraph after 4aaa38d
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vuvova committed Aug 25, 2017
1 parent 578b2b0 commit add44e6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 23 deletions.
31 changes: 20 additions & 11 deletions include/my_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <cmath>
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 <cmath>
#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. */
Expand Down
12 changes: 0 additions & 12 deletions storage/oqgraph/oqgraph_thunk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,6 @@

#include <boost/tuple/tuple.hpp>

/* 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 <cmath>
static inline bool isfinite(double x) { return std::isfinite(x); }
#endif /* isfinite */

#include "unireg.h"
#include "sql_base.h"
#include "table.h"
Expand Down

0 comments on commit add44e6

Please sign in to comment.