diff --git a/src/servers/Server_Common/Database/mysql_util.cpp b/src/servers/Server_Common/Database/mysql_util.cpp index c73b04f3..160b193f 100644 --- a/src/servers/Server_Common/Database/mysql_util.cpp +++ b/src/servers/Server_Common/Database/mysql_util.cpp @@ -1,5 +1,34 @@ #include "mysql_util.h" +long double strtold(const char *nptr, char **endptr) +{ + /* + * Experienced odd compilation errors on one of windows build hosts - + * cmake reported there is strold function. Since double and long double on windows + * are of the same size - we are using strtod on those platforms regardless + * to the HAVE_FUNCTION_STRTOLD value + */ +#ifdef _WIN32 + return ::strtod(nptr, endptr); +#else + # ifndef HAVE_FUNCTION_STRTOLD + return ::strtod(nptr, endptr); +# else +# if defined(__hpux) && defined(_LONG_DOUBLE) + union { + long_double l_d; + long double ld; + } u; + u.l_d = ::strtold( nptr, endptr); + return u.ld; +# else + return ::strtold(nptr, endptr); +# endif +# endif +#endif + +} + long double strtonum( const std::string &str, int radix ) { typedef std::istreambuf_iterator< char > iter_t; diff --git a/src/servers/Server_Common/Database/mysql_util.h b/src/servers/Server_Common/Database/mysql_util.h index f1de1eee..66fffd13 100644 --- a/src/servers/Server_Common/Database/mysql_util.h +++ b/src/servers/Server_Common/Database/mysql_util.h @@ -48,11 +48,11 @@ with this program; if not, write to the Free Software Foundation, Inc., #ifndef _WIN32 # ifndef HAVE_FUNCTION_STRTOLL -# define strtoll(__a, __b, __c) static_cast(sql::mysql::util::strtold((__a), NULL)) +# define strtoll(__a, __b, __c) static_cast(strtold((__a), NULL)) # define HAVE_FUNCTION_STRTOLL 1 # endif # ifndef HAVE_FUNCTION_STRTOULL -# define strtoull(__a, __b, __c) static_cast(sql::mysql::util::strtold((__a), NULL)) +# define strtoull(__a, __b, __c) static_cast(strtold((__a), NULL)) # define HAVE_FUNCTION_STRTOULL 1 # endif #else @@ -106,5 +106,6 @@ with this program; if not, write to the Free Software Foundation, Inc., (((uint32_t) (((unsigned char*) (A))[0])) << 24))) <<\ 32)) +long double strtold(const char *nptr, char **endptr); long double strtonum( const std::string &str, int radix = 10); #endif //SAPPHIRE_MYSQL_UTIL_H