diff options
author | 2015-06-29 16:13:33 +0200 | |
---|---|---|
committer | 2015-07-01 10:09:41 +0200 | |
commit | ee35402244fc463cedc470baa0f5f1a6080d905d (patch) | |
tree | 8a127c0f8762f5b07129d97dd2fba584fef20431 /src/google/protobuf/stubs | |
parent | d40a0db202433ba002a3e104165d4414e8929432 (diff) |
MinGW64+MSYS2 compilation issues and portable isnan using MathLimits
Diffstat (limited to 'src/google/protobuf/stubs')
-rw-r--r-- | src/google/protobuf/stubs/common.h | 16 | ||||
-rw-r--r-- | src/google/protobuf/stubs/strutil.cc | 10 |
2 files changed, 11 insertions, 15 deletions
diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h index c3620146..3eb57a9b 100644 --- a/src/google/protobuf/stubs/common.h +++ b/src/google/protobuf/stubs/common.h @@ -1459,14 +1459,14 @@ static inline uint32 bswap_32(uint32 x) { } #define bswap_32(x) bswap_32(x) static inline uint64 bswap_64(uint64 x) { - return (((x & GG_ULONGLONG(0xFF)) << 56) | - ((x & GG_ULONGLONG(0xFF00)) << 40) | - ((x & GG_ULONGLONG(0xFF0000)) << 24) | - ((x & GG_ULONGLONG(0xFF000000)) << 8) | - ((x & GG_ULONGLONG(0xFF00000000)) >> 8) | - ((x & GG_ULONGLONG(0xFF0000000000)) >> 24) | - ((x & GG_ULONGLONG(0xFF000000000000)) >> 40) | - ((x & GG_ULONGLONG(0xFF00000000000000)) >> 56)); + return (((x & GOOGLE_ULONGLONG(0xFF)) << 56) | + ((x & GOOGLE_ULONGLONG(0xFF00)) << 40) | + ((x & GOOGLE_ULONGLONG(0xFF0000)) << 24) | + ((x & GOOGLE_ULONGLONG(0xFF000000)) << 8) | + ((x & GOOGLE_ULONGLONG(0xFF00000000)) >> 8) | + ((x & GOOGLE_ULONGLONG(0xFF0000000000)) >> 24) | + ((x & GOOGLE_ULONGLONG(0xFF000000000000)) >> 40) | + ((x & GOOGLE_ULONGLONG(0xFF00000000000000)) >> 56)); } #define bswap_64(x) bswap_64(x) diff --git a/src/google/protobuf/stubs/strutil.cc b/src/google/protobuf/stubs/strutil.cc index 99e8bf1d..2ec62b42 100644 --- a/src/google/protobuf/stubs/strutil.cc +++ b/src/google/protobuf/stubs/strutil.cc @@ -31,6 +31,7 @@ // from google3/strings/strutil.cc #include <google/protobuf/stubs/strutil.h> +#include <google/protobuf/stubs/mathlimits.h> #include <errno.h> #include <float.h> // FLT_DIG and DBL_DIG @@ -58,11 +59,6 @@ namespace google { namespace protobuf { -inline bool IsNaN(double value) { - // NaN is never equal to anything, even itself. - return value != value; -} - // These are defined as macros on some platforms. #undef them so that we can // redefine them. #undef isxdigit @@ -1210,7 +1206,7 @@ char* DoubleToBuffer(double value, char* buffer) { } else if (value == -numeric_limits<double>::infinity()) { strcpy(buffer, "-inf"); return buffer; - } else if (IsNaN(value)) { + } else if (MathLimits<double>::IsNaN(value)) { strcpy(buffer, "nan"); return buffer; } @@ -1328,7 +1324,7 @@ char* FloatToBuffer(float value, char* buffer) { } else if (value == -numeric_limits<double>::infinity()) { strcpy(buffer, "-inf"); return buffer; - } else if (IsNaN(value)) { + } else if (MathLimits<float>::IsNaN(value)) { strcpy(buffer, "nan"); return buffer; } |