diff options
author | Vlad Lesin <vlad_lesin@mail.ru> | 2018-05-25 22:16:04 +0400 |
---|---|---|
committer | Vlad Lesin <vlad_lesin@mail.ru> | 2019-11-19 16:28:15 +0300 |
commit | 6718d3bc3241f72e07504133371cf3813d2e6fe9 (patch) | |
tree | d93a3b16f5559c8bde8649e6348fcc54f606101c | |
parent | b80df9eba23b4eb9694e770a41135127c6dbc5df (diff) | |
download | mariadb-git-6718d3bc3241f72e07504133371cf3813d2e6fe9.tar.gz |
MDEV-21082: isnan/isinf compilation errors, isfinite warnings on MacOS
The fix consists of three commits backported from 10.3:
1) Cleanup isnan() portability checks
(cherry picked from commit 7ffd7fe9627d1f750a3712aebb4503e5ae8aea8e)
2) Cleanup isinf() portability checks
Original problem reported by Wlad: re-compilation of 10.3 on top of 10.2
build would cache undefined HAVE_ISINF from 10.2, whereas it is expected
to be 1 in 10.3.
std::isinf() seem to be available on all supported platforms.
(cherry picked from commit bc469a0bdf85400f7a63834f5b7af1a513dcdec9)
3) Use std::isfinite in C++ code
This is addition to parent revision fixing build failures.
(cherry picked from commit 54999f4e75f42baca484ae436b382ca8817df1dd)
-rw-r--r-- | cmake/os/Windows.cmake | 1 | ||||
-rw-r--r-- | config.h.cmake | 2 | ||||
-rw-r--r-- | configure.cmake | 11 | ||||
-rw-r--r-- | include/my_global.h | 20 | ||||
-rw-r--r-- | sql/field.cc | 6 | ||||
-rw-r--r-- | sql/item_func.cc | 6 | ||||
-rw-r--r-- | sql/item_func.h | 2 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 2 | ||||
-rw-r--r-- | sql/item_sum.cc | 4 | ||||
-rw-r--r-- | storage/heap/hp_hash.c | 2 | ||||
-rw-r--r-- | storage/innobase/gis/gis0geo.cc | 2 | ||||
-rw-r--r-- | storage/innobase/gis/gis0rtree.cc | 2 | ||||
-rw-r--r-- | storage/maria/ma_key.c | 2 | ||||
-rw-r--r-- | storage/maria/ma_sp_key.c | 2 | ||||
-rw-r--r-- | storage/myisam/mi_key.c | 2 | ||||
-rw-r--r-- | storage/myisam/sp_key.c | 2 |
16 files changed, 13 insertions, 55 deletions
diff --git a/cmake/os/Windows.cmake b/cmake/os/Windows.cmake index ca6d13e1c1b..1eae92924a6 100644 --- a/cmake/os/Windows.cmake +++ b/cmake/os/Windows.cmake @@ -225,7 +225,6 @@ CHECK_SYMBOL_REPLACEMENT(S_IROTH _S_IREAD sys/stat.h) CHECK_SYMBOL_REPLACEMENT(S_IFIFO _S_IFIFO sys/stat.h) CHECK_SYMBOL_REPLACEMENT(SIGQUIT SIGTERM signal.h) CHECK_SYMBOL_REPLACEMENT(SIGPIPE SIGINT signal.h) -CHECK_SYMBOL_REPLACEMENT(isnan _isnan "math.h;float.h") CHECK_SYMBOL_REPLACEMENT(finite _finite "math;float.h") CHECK_FUNCTION_REPLACEMENT(popen _popen) CHECK_FUNCTION_REPLACEMENT(pclose _pclose) diff --git a/config.h.cmake b/config.h.cmake index ae1431c8abe..6e4af65c40e 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -163,7 +163,6 @@ #cmakedefine HAVE_IN_ADDR_T 1 #cmakedefine HAVE_INITGROUPS 1 #cmakedefine HAVE_ISNAN 1 -#cmakedefine HAVE_ISINF 1 #cmakedefine HAVE_LARGE_PAGE_OPTION 1 #cmakedefine HAVE_LDIV 1 #cmakedefine HAVE_LRAND48 1 @@ -423,7 +422,6 @@ #cmakedefine mode_t @mode_t@ #cmakedefine SIGQUIT @SIGQUIT@ #cmakedefine SIGPIPE @SIGPIPE@ -#cmakedefine isnan @isnan@ #cmakedefine finite @finite@ #cmakedefine popen @popen@ #cmakedefine pclose @pclose@ diff --git a/configure.cmake b/configure.cmake index 8677aec44f1..f94fb3642a5 100644 --- a/configure.cmake +++ b/configure.cmake @@ -475,19 +475,8 @@ ELSE() CHECK_SYMBOL_EXISTS(finite "ieeefp.h" HAVE_FINITE) ENDIF() CHECK_SYMBOL_EXISTS(log2 math.h HAVE_LOG2) -CHECK_SYMBOL_EXISTS(isnan math.h HAVE_ISNAN) CHECK_SYMBOL_EXISTS(rint math.h HAVE_RINT) -# isinf() prototype not found on Solaris -CHECK_CXX_SOURCE_COMPILES( -"#include <math.h> -int main() { - isinf(0.0); - return 0; -}" HAVE_ISINF) - - - # # Test for endianess # diff --git a/include/my_global.h b/include/my_global.h index 4ce4671c571..8103f82a7e2 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -811,26 +811,8 @@ inline unsigned long long my_double2ulonglong(double d) #define SIZE_T_MAX (~((size_t) 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) +#ifdef __cplusplus #include <cmath> -static inline bool isfinite(double x) { return std::isfinite(x); } -#endif /* isfinite */ - -#ifndef HAVE_ISNAN -#define isnan(x) ((x) != (x)) -#endif -#define my_isnan(x) isnan(x) - -#ifdef HAVE_ISINF -#define my_isinf(X) isinf(X) -#else /* !HAVE_ISINF */ -#define my_isinf(X) (!finite(X) && !isnan(X)) #endif /* Define missing math constants. */ diff --git a/sql/field.cc b/sql/field.cc index a23004ebd96..09e82acb009 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -2904,7 +2904,7 @@ int Field_decimal::store(double nr) return 1; } - if (!isfinite(nr)) // Handle infinity as special case + if (!std::isfinite(nr)) // Handle infinity as special case { overflow(nr < 0.0); return 1; @@ -4821,7 +4821,7 @@ int truncate_double(double *nr, uint field_length, uint dec, int error= 0; double res= *nr; - if (isnan(res)) + if (std::isnan(res)) { *nr= 0; return -1; @@ -4843,7 +4843,7 @@ int truncate_double(double *nr, uint field_length, uint dec, max_value-= 1.0 / log_10[dec]; /* Check for infinity so we don't get NaN in calculations */ - if (!my_isinf(res)) + if (!std::isinf(res)) { double tmp= rint((res - floor(res)) * log_10[dec]) / log_10[dec]; res= floor(res) + tmp; diff --git a/sql/item_func.cc b/sql/item_func.cc index 7719e0faa87..6ca74a79b9c 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2553,12 +2553,12 @@ double my_double_round(double value, longlong dec, bool dec_unsigned, volatile double value_div_tmp= value / tmp; volatile double value_mul_tmp= value * tmp; - if (!dec_negative && my_isinf(tmp)) // "dec" is too large positive number + if (!dec_negative && std::isinf(tmp)) // "dec" is too large positive number return value; - if (dec_negative && my_isinf(tmp)) + if (dec_negative && std::isinf(tmp)) tmp2= 0.0; - else if (!dec_negative && my_isinf(value_mul_tmp)) + else if (!dec_negative && std::isinf(value_mul_tmp)) tmp2= value; else if (truncate) { diff --git a/sql/item_func.h b/sql/item_func.h index 1193daea106..496109b0e24 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -241,7 +241,7 @@ public: */ inline double check_float_overflow(double value) { - return isfinite(value) ? value : raise_float_overflow(); + return std::isfinite(value) ? value : raise_float_overflow(); } /** Throw an error if the input BIGINT value represented by the diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index dcfbd272809..8738af7ac56 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -2655,7 +2655,7 @@ String *Item_func_format::val_str_ascii(String *str) return 0; /* purecov: inspected */ nr= my_double_round(nr, (longlong) dec, FALSE, FALSE); str->set_real(nr, dec, &my_charset_numeric); - if (!isfinite(nr)) + if (!std::isfinite(nr)) return str; str_length=str->length(); } diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 5bed0d32009..06c01c58948 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1808,7 +1808,7 @@ double Item_sum_std::val_real() { DBUG_ASSERT(fixed == 1); double nr= Item_sum_variance::val_real(); - if (isnan(nr)) + if (std::isnan(nr)) { /* variance_fp_recurrence_next() can overflow in some cases and return "nan": @@ -1820,7 +1820,7 @@ double Item_sum_std::val_real() null_value= true; // Convert "nan" to NULL return 0; } - if (my_isinf(nr)) + if (std::isinf(nr)) return DBL_MAX; DBUG_ASSERT(nr >= 0.0); return sqrt(nr); diff --git a/storage/heap/hp_hash.c b/storage/heap/hp_hash.c index 848a9881b20..f0238d06010 100644 --- a/storage/heap/hp_hash.c +++ b/storage/heap/hp_hash.c @@ -778,7 +778,6 @@ uint hp_rb_make_key(HP_KEYDEF *keydef, uchar *key, uchar *pos= (uchar*) rec + seg->start; DBUG_ASSERT(seg->type != HA_KEYTYPE_BIT); -#ifdef HAVE_ISNAN if (seg->type == HA_KEYTYPE_FLOAT) { float nr; @@ -802,7 +801,6 @@ uint hp_rb_make_key(HP_KEYDEF *keydef, uchar *key, continue; } } -#endif pos+= length; while (length--) { diff --git a/storage/innobase/gis/gis0geo.cc b/storage/innobase/gis/gis0geo.cc index bd601c2e19e..cad3877d3e9 100644 --- a/storage/innobase/gis/gis0geo.cc +++ b/storage/innobase/gis/gis0geo.cc @@ -367,7 +367,7 @@ mbr_join_square( /* Check if finite (not infinity or NaN), so we don't get NaN in calculations */ - if (!isfinite(square)) { + if (!std::isfinite(square)) { return DBL_MAX; } diff --git a/storage/innobase/gis/gis0rtree.cc b/storage/innobase/gis/gis0rtree.cc index a9c30ae2a38..ce1749820c3 100644 --- a/storage/innobase/gis/gis0rtree.cc +++ b/storage/innobase/gis/gis0rtree.cc @@ -1969,7 +1969,7 @@ rtr_estimate_n_rows_in_range( mtr_commit(&mtr); mem_heap_free(heap); - if (!isfinite(area)) { + if (!std::isfinite(area)) { return(HA_POS_ERROR); } diff --git a/storage/maria/ma_key.c b/storage/maria/ma_key.c index c9db47dd384..9e804a1e9dc 100644 --- a/storage/maria/ma_key.c +++ b/storage/maria/ma_key.c @@ -279,7 +279,6 @@ MARIA_KEY *_ma_make_key(MARIA_HA *info, MARIA_KEY *int_key, uint keynr, } else if (keyseg->flag & HA_SWAP_KEY) { /* Numerical column */ -#ifdef HAVE_ISNAN if (type == HA_KEYTYPE_FLOAT) { float nr; @@ -303,7 +302,6 @@ MARIA_KEY *_ma_make_key(MARIA_HA *info, MARIA_KEY *int_key, uint keynr, continue; } } -#endif pos+=length; while (length--) { diff --git a/storage/maria/ma_sp_key.c b/storage/maria/ma_sp_key.c index 0dc7fe1fe46..1a9abc989ed 100644 --- a/storage/maria/ma_sp_key.c +++ b/storage/maria/ma_sp_key.c @@ -77,7 +77,6 @@ MARIA_KEY *_ma_sp_make_key(MARIA_HA *info, MARIA_KEY *ret_key, uint keynr, DBUG_ASSERT(keyseg->type == HA_KEYTYPE_DOUBLE); val= mbr[start / sizeof (double)]; -#ifdef HAVE_ISNAN if (isnan(val)) { bzero(key, length); @@ -85,7 +84,6 @@ MARIA_KEY *_ma_sp_make_key(MARIA_HA *info, MARIA_KEY *ret_key, uint keynr, len+= length; continue; } -#endif if (keyseg->flag & HA_SWAP_KEY) { diff --git a/storage/myisam/mi_key.c b/storage/myisam/mi_key.c index c81bc674685..9247fae9e3c 100644 --- a/storage/myisam/mi_key.c +++ b/storage/myisam/mi_key.c @@ -150,7 +150,6 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key, } else if (keyseg->flag & HA_SWAP_KEY) { /* Numerical column */ -#ifdef HAVE_ISNAN if (type == HA_KEYTYPE_FLOAT) { float nr; @@ -174,7 +173,6 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key, continue; } } -#endif pos+=length; while (length--) { diff --git a/storage/myisam/sp_key.c b/storage/myisam/sp_key.c index c3aeb7553f2..4c6ef75934e 100644 --- a/storage/myisam/sp_key.c +++ b/storage/myisam/sp_key.c @@ -66,7 +66,6 @@ uint sp_make_key(register MI_INFO *info, uint keynr, uchar *key, DBUG_ASSERT(keyseg->type == HA_KEYTYPE_DOUBLE); val= mbr[start / sizeof (double)]; -#ifdef HAVE_ISNAN if (isnan(val)) { bzero(key, length); @@ -74,7 +73,6 @@ uint sp_make_key(register MI_INFO *info, uint keynr, uchar *key, len+= length; continue; } -#endif if (keyseg->flag & HA_SWAP_KEY) { |