diff options
author | Feng Xiao <xfxyjwf@gmail.com> | 2015-07-01 10:36:30 -0700 |
---|---|---|
committer | Feng Xiao <xfxyjwf@gmail.com> | 2015-07-01 10:36:30 -0700 |
commit | ec7bbc76beddb04fd49bd4db5821c00d0b235868 (patch) | |
tree | 13b18f9894999650e3a3e0ebe403597a7c3c13fe | |
parent | eb162dad5f4b56dead4fa593e99eaef1b5440bb1 (diff) | |
parent | ee35402244fc463cedc470baa0f5f1a6080d905d (diff) | |
download | protobuf-ec7bbc76beddb04fd49bd4db5821c00d0b235868.tar.gz protobuf-ec7bbc76beddb04fd49bd4db5821c00d0b235868.tar.bz2 protobuf-ec7bbc76beddb04fd49bd4db5821c00d0b235868.zip |
Merge pull request #551 from ostrovsky/master
MinGW64+MSYS2 compilation issues
-rw-r--r-- | src/google/protobuf/compiler/csharp/csharp_field_base.cc | 10 | ||||
-rw-r--r-- | src/google/protobuf/stubs/common.h | 16 | ||||
-rw-r--r-- | src/google/protobuf/stubs/strutil.cc | 10 | ||||
-rw-r--r-- | src/google/protobuf/text_format_unittest.cc | 10 | ||||
-rw-r--r-- | src/google/protobuf/util/internal/datapiece.cc | 3 | ||||
-rw-r--r-- | src/google/protobuf/util/internal/utility.cc | 3 |
6 files changed, 21 insertions, 31 deletions
diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.cc b/src/google/protobuf/compiler/csharp/csharp_field_base.cc index c3ce426b..4c6a3d72 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.cc @@ -38,6 +38,7 @@ #include <google/protobuf/io/printer.h> #include <google/protobuf/io/zero_copy_stream.h> #include <google/protobuf/stubs/strutil.h> +#include <google/protobuf/stubs/mathlimits.h> #include <google/protobuf/compiler/csharp/csharp_field_base.h> #include <google/protobuf/compiler/csharp/csharp_helpers.h> @@ -248,11 +249,6 @@ bool FieldGeneratorBase::is_nullable_type() { } } -inline bool IsNaN(double value) { - // NaN is never equal to anything, even itself. - return value != value; -} - bool AllPrintableAscii(const std::string& text) { for(int i = 0; i < text.size(); i++) { if (text[i] < 0x20 || text[i] > 0x7e) { @@ -309,7 +305,7 @@ std::string FieldGeneratorBase::default_value() { return "double.PositiveInfinity"; } else if (value == -numeric_limits<double>::infinity()) { return "double.NegativeInfinity"; - } else if (IsNaN(value)) { + } else if (MathLimits<double>::IsNaN(value)) { return "double.NaN"; } return SimpleDtoa(value) + "D"; @@ -320,7 +316,7 @@ std::string FieldGeneratorBase::default_value() { return "float.PositiveInfinity"; } else if (value == -numeric_limits<float>::infinity()) { return "float.NegativeInfinity"; - } else if (IsNaN(value)) { + } else if (MathLimits<float>::IsNaN(value)) { return "float.NaN"; } return SimpleFtoa(value) + "F"; 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; } diff --git a/src/google/protobuf/text_format_unittest.cc b/src/google/protobuf/text_format_unittest.cc index 1b18c5ed..76ce9875 100644 --- a/src/google/protobuf/text_format_unittest.cc +++ b/src/google/protobuf/text_format_unittest.cc @@ -46,6 +46,7 @@ #include <google/protobuf/io/tokenizer.h> #include <google/protobuf/io/zero_copy_stream_impl.h> #include <google/protobuf/stubs/strutil.h> +#include <google/protobuf/stubs/mathlimits.h> #include <google/protobuf/stubs/substitute.h> #include <google/protobuf/testing/googletest.h> #include <gtest/gtest.h> @@ -57,11 +58,6 @@ namespace protobuf { // Can't use an anonymous namespace here due to brokenness of Tru64 compiler. namespace text_format_unittest { -inline bool IsNaN(double value) { - // NaN is never equal to anything, even itself. - return value != value; -} - // A basic string with different escapable characters for testing. const string kEscapeTestString = "\"A string with ' characters \n and \r newlines and \t tabs and \001 " @@ -898,8 +894,8 @@ TEST_F(TextFormatTest, ParseExotic) { EXPECT_EQ(message.repeated_double(8), numeric_limits<double>::infinity()); EXPECT_EQ(message.repeated_double(9), -numeric_limits<double>::infinity()); EXPECT_EQ(message.repeated_double(10), -numeric_limits<double>::infinity()); - EXPECT_TRUE(IsNaN(message.repeated_double(11))); - EXPECT_TRUE(IsNaN(message.repeated_double(12))); + EXPECT_TRUE(MathLimits<double>::IsNaN(message.repeated_double(11))); + EXPECT_TRUE(MathLimits<double>::IsNaN(message.repeated_double(12))); // Note: Since these string literals have \0's in them, we must explicitly // pass their sizes to string's constructor. diff --git a/src/google/protobuf/util/internal/datapiece.cc b/src/google/protobuf/util/internal/datapiece.cc index 72b737e9..944fb2e3 100644 --- a/src/google/protobuf/util/internal/datapiece.cc +++ b/src/google/protobuf/util/internal/datapiece.cc @@ -36,6 +36,7 @@ #include <google/protobuf/util/internal/utility.h> #include <google/protobuf/stubs/strutil.h> #include <google/protobuf/stubs/mathutil.h> +#include <google/protobuf/stubs/mathlimits.h> namespace google { namespace protobuf { @@ -78,7 +79,7 @@ StatusOr<To> NumberConvertAndCheck(From before) { // For conversion between double and float only. template <typename To, typename From> StatusOr<To> FloatingPointConvertAndCheck(From before) { - if (isnan(before)) return std::numeric_limits<To>::quiet_NaN(); + if (MathLimits<From>::IsNaN(before)) return std::numeric_limits<To>::quiet_NaN(); To after = static_cast<To>(before); if (MathUtil::AlmostEquals<To>(after, before)) { diff --git a/src/google/protobuf/util/internal/utility.cc b/src/google/protobuf/util/internal/utility.cc index f550f43b..794777d4 100644 --- a/src/google/protobuf/util/internal/utility.cc +++ b/src/google/protobuf/util/internal/utility.cc @@ -41,6 +41,7 @@ #include <google/protobuf/util/internal/constants.h> #include <google/protobuf/stubs/strutil.h> #include <google/protobuf/stubs/map_util.h> +#include <google/protobuf/stubs/mathlimits.h> namespace google { namespace protobuf { @@ -302,7 +303,7 @@ bool IsMap(const google::protobuf::Field& field, string DoubleAsString(double value) { if (value == std::numeric_limits<double>::infinity()) return "Infinity"; if (value == -std::numeric_limits<double>::infinity()) return "-Infinity"; - if (::isnan(value)) return "NaN"; + if (google::protobuf::MathLimits<double>::IsNaN(value)) return "NaN"; return SimpleDtoa(value); } |