aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJisi Liu <jisi.liu@gmail.com>2016-07-26 16:36:37 -0700
committerJisi Liu <jisi.liu@gmail.com>2016-07-26 16:36:37 -0700
commit0750797db41806db5f51731f17ce8a42fa19b482 (patch)
tree1e711406a3c90e113db8ca969792fdbb0f76a539
parent54feb9ac24b472333f44908939819d675b8e453d (diff)
parentb6b521b6b735a0d88432ac621e618dc837cb9509 (diff)
downloadprotobuf-0750797db41806db5f51731f17ce8a42fa19b482.tar.gz
protobuf-0750797db41806db5f51731f17ce8a42fa19b482.tar.bz2
protobuf-0750797db41806db5f51731f17ce8a42fa19b482.zip
Merge remote-tracking branch 'origin/3.0.0-GA' into 3.0.0-GA
-rw-r--r--src/Makefile.am2
-rw-r--r--src/google/protobuf/stubs/int128.cc6
-rw-r--r--src/google/protobuf/stubs/port.h20
-rw-r--r--src/google/protobuf/util/time_util.cc9
4 files changed, 23 insertions, 14 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 6e7dacfc..524886ea 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -547,7 +547,7 @@ EXTRA_DIST = \
google/protobuf/package_info.h \
google/protobuf/io/package_info.h \
google/protobuf/compiler/ruby/ruby_generated_code.proto \
- google/protobuf/compiler/ruby/ruby_generated_code.rb \
+ google/protobuf/compiler/ruby/ruby_generated_code_pb.rb \
google/protobuf/compiler/package_info.h \
google/protobuf/compiler/zip_output_unittest.sh \
README.md
diff --git a/src/google/protobuf/stubs/int128.cc b/src/google/protobuf/stubs/int128.cc
index 3a36b4b1..a5090801 100644
--- a/src/google/protobuf/stubs/int128.cc
+++ b/src/google/protobuf/stubs/int128.cc
@@ -145,15 +145,15 @@ std::ostream& operator<<(std::ostream& o, const uint128& b) {
std::streamsize div_base_log;
switch (flags & std::ios::basefield) {
case std::ios::hex:
- div = GOOGLE_ULONGLONG(0x1000000000000000); // 16^15
+ div = static_cast<uint64>(GOOGLE_ULONGLONG(0x1000000000000000)); // 16^15
div_base_log = 15;
break;
case std::ios::oct:
- div = GOOGLE_ULONGLONG(01000000000000000000000); // 8^21
+ div = static_cast<uint64>(GOOGLE_ULONGLONG(01000000000000000000000)); // 8^21
div_base_log = 21;
break;
default: // std::ios::dec
- div = GOOGLE_ULONGLONG(10000000000000000000); // 10^19
+ div = static_cast<uint64>(GOOGLE_ULONGLONG(10000000000000000000)); // 10^19
div_base_log = 19;
break;
}
diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h
index 328258b7..d7f93b4c 100644
--- a/src/google/protobuf/stubs/port.h
+++ b/src/google/protobuf/stubs/port.h
@@ -109,15 +109,15 @@ typedef unsigned __int16 uint16;
typedef unsigned __int32 uint32;
typedef unsigned __int64 uint64;
#else
-typedef signed char int8;
-typedef short int16;
-typedef int int32;
-typedef long long int64;
-
-typedef unsigned char uint8;
-typedef unsigned short uint16;
-typedef unsigned int uint32;
-typedef unsigned long long uint64;
+typedef int8_t int8;
+typedef int16_t int16;
+typedef int32_t int32;
+typedef int64_t int64;
+
+typedef uint8_t uint8;
+typedef uint16_t uint16;
+typedef uint32_t uint32;
+typedef uint64_t uint64;
#endif
// long long macros to be used because gcc and vc++ use different suffixes,
@@ -131,8 +131,10 @@ typedef unsigned long long uint64;
#define GOOGLE_ULONGLONG(x) x##UI64
#define GOOGLE_LL_FORMAT "I64" // As in printf("%I64d", ...)
#else
+// By long long, we actually mean int64.
#define GOOGLE_LONGLONG(x) x##LL
#define GOOGLE_ULONGLONG(x) x##ULL
+// Used to format real long long integers.
#define GOOGLE_LL_FORMAT "ll" // As in "%lld". Note that "q" is poor form also.
#endif
diff --git a/src/google/protobuf/util/time_util.cc b/src/google/protobuf/util/time_util.cc
index c782d691..031d019a 100644
--- a/src/google/protobuf/util/time_util.cc
+++ b/src/google/protobuf/util/time_util.cc
@@ -142,6 +142,13 @@ int64 RoundTowardZero(int64 value, int64 divider) {
}
} // namespace
+// Actually define these static const integers. Required by C++ standard (but
+// omitting them may still work with some compilers).
+const int64 TimeUtil::kTimestampMinSeconds;
+const int64 TimeUtil::kTimestampMaxSeconds;
+const int64 TimeUtil::kDurationMaxSeconds;
+const int64 TimeUtil::kDurationMinSeconds;
+
string TimeUtil::ToString(const Timestamp& timestamp) {
return FormatTime(timestamp.seconds(), timestamp.nanos());
}
@@ -174,7 +181,7 @@ string TimeUtil::ToString(const Duration& duration) {
seconds = -seconds;
nanos = -nanos;
}
- result += StringPrintf("%" GOOGLE_LL_FORMAT "d", seconds);
+ result += SimpleItoa(seconds);
if (nanos != 0) {
result += "." + FormatNanos(nanos);
}