From a17367f44a3b592993d2ac5c074ed58fb0ce784c Mon Sep 17 00:00:00 2001 From: Feng Xiao Date: Mon, 25 Jul 2016 10:52:44 -0700 Subject: Define intX as standard exact-width integer types. Fixes https://github.com/google/protobuf/issues/823 Change-Id: I7f4c2bfcac2f81d8b34c030dd3d12ea02aaa2264 --- src/google/protobuf/stubs/port.h | 24 +++++++++++++----------- src/google/protobuf/util/time_util.cc | 9 ++++++++- 2 files changed, 21 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h index 328258b7..371806f1 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 -#define GOOGLE_LONGLONG(x) x##LL -#define GOOGLE_ULONGLONG(x) x##ULL +// By long long, we actually mean int64. +#define GOOGLE_LONGLONG(x) INT64_C(x) +#define GOOGLE_ULONGLONG(x) UINT64_C(x) +// 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); } -- cgit v1.2.3 From 43b36dd98375b6d410996d52a9db4652dfd28997 Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Tue, 26 Jul 2016 10:28:18 -0700 Subject: Fixed Makefile.am for Ruby file rename. --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') 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 -- cgit v1.2.3 From 12581b4c8e94fce78ab517141f086914c251dd12 Mon Sep 17 00:00:00 2001 From: Feng Xiao Date: Tue, 26 Jul 2016 10:57:02 -0700 Subject: Fixes traivs cpp build. Remove the use of INT64_C/UINT64_C and add static_cast when neccessary. --- src/google/protobuf/stubs/int128.cc | 6 +++--- src/google/protobuf/stubs/port.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') 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(GOOGLE_ULONGLONG(0x1000000000000000)); // 16^15 div_base_log = 15; break; case std::ios::oct: - div = GOOGLE_ULONGLONG(01000000000000000000000); // 8^21 + div = static_cast(GOOGLE_ULONGLONG(01000000000000000000000)); // 8^21 div_base_log = 21; break; default: // std::ios::dec - div = GOOGLE_ULONGLONG(10000000000000000000); // 10^19 + div = static_cast(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 371806f1..d7f93b4c 100644 --- a/src/google/protobuf/stubs/port.h +++ b/src/google/protobuf/stubs/port.h @@ -132,8 +132,8 @@ typedef uint64_t uint64; #define GOOGLE_LL_FORMAT "I64" // As in printf("%I64d", ...) #else // By long long, we actually mean int64. -#define GOOGLE_LONGLONG(x) INT64_C(x) -#define GOOGLE_ULONGLONG(x) UINT64_C(x) +#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 -- cgit v1.2.3 From e3fac65addcf0e6d8db2dae13ec40f7a0ba648e6 Mon Sep 17 00:00:00 2001 From: Jisi Liu Date: Thu, 28 Jul 2016 14:24:05 -0700 Subject: Change the build.zip.sh to support lite --- protoc-artifacts/build-zip.sh | 46 +++++++++++++++++++++++++------------------ src/Makefile.am | 4 ++++ 2 files changed, 31 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/protoc-artifacts/build-zip.sh b/protoc-artifacts/build-zip.sh index 054e2ea1..d8686d3b 100755 --- a/protoc-artifacts/build-zip.sh +++ b/protoc-artifacts/build-zip.sh @@ -1,26 +1,30 @@ #!/bin/bash -if [ $# -eq 0 ]; then +if [ $# -ne 2 ]; then cat < +Usage: $0 + +TARGET: protoc | protoc-gen-javalite Example: - $ $0 3.0.0-beta-4 + $ $0 protoc 3.0.0 + $ $0 protoc-gen-javalite 3.0.0 -This script will download pre-built protoc binaries from maven repository -and package them with well-known type .proto files to create .zip packages -suitable to be included in the github release page. Each invocation will -create 5 zip packages: - dist/protoc--win32.zip - dist/protoc--osx-x86_32.zip - dist/protoc--osx-x86_64.zip - dist/protoc--linux-x86_32.zip - dist/protoc--linux-x86_64.zip +This script will download pre-built protoc or protoc plugin binaries from maven +repository and create .zip packages suitable to be included in the github +release page. If the target is protoc, well-known type .proto files will also be +included. Each invocation will create 5 zip packages: + dist/--win32.zip + dist/--osx-x86_32.zip + dist/--osx-x86_64.zip + dist/--linux-x86_32.zip + dist/--linux-x86_64.zip EOF exit 1 fi -VERSION_NUMBER=$1 +TARGET=$1 +VERSION_NUMBER=$2 # pairs. declare -a FILE_NAMES=( \ @@ -79,16 +83,20 @@ mkdir -p ${DIR}/bin for((i=0;i<${#FILE_NAMES[@]};i+=2));do ZIP_NAME=${FILE_NAMES[$i]} BINARY_NAME=${FILE_NAMES[$(($i+1))]} - BINARY_URL=http://repo1.maven.org/maven2/com/google/protobuf/protoc/${VERSION_NUMBER}/protoc-${VERSION_NUMBER}-${BINARY_NAME} - if ! wget ${BINARY_URL} -O ${DIR}/bin/protoc &> /dev/null; then + BINARY_URL=http://repo1.maven.org/maven2/com/google/protobuf/$TARGET/${VERSION_NUMBER}/$TARGET-${VERSION_NUMBER}-${BINARY_NAME} + if ! wget ${BINARY_URL} -O ${DIR}/bin/$TARGET &> /dev/null; then echo "[ERROR] Failed to download ${BINARY_URL}" >&2 - echo "[ERROR] Skipped protoc-${VERSION_NAME}-${ZIP_NAME}" >&2 + echo "[ERROR] Skipped $TARGET-${VERSION_NAME}-${ZIP_NAME}" >&2 continue fi - TARGET_ZIP_FILE=`pwd`/dist/protoc-${VERSION_NUMBER}-${ZIP_NAME} + TARGET_ZIP_FILE=`pwd`/dist/$TARGET-${VERSION_NUMBER}-${ZIP_NAME} pushd $DIR &> /dev/null - chmod +x bin/protoc - zip -r ${TARGET_ZIP_FILE} include bin readme.txt &> /dev/null + chmod +x bin/$TARGET + if [ "$TARGET" = "protoc" ]; then + zip -r ${TARGET_ZIP_FILE} include bin readme.txt &> /dev/null + else + zip -r ${TARGET_ZIP_FILE} bin &> /dev/null + fi popd &> /dev/null echo "[INFO] Successfully created ${TARGET_ZIP_FILE}" done diff --git a/src/Makefile.am b/src/Makefile.am index 524886ea..f70e9550 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -33,6 +33,10 @@ AM_LDFLAGS = $(PTHREAD_CFLAGS) # If I say "dist_include_DATA", automake complains that $(includedir) is not # a "legitimate" directory for DATA. Screw you, automake. protodir = $(includedir) + +# If you are adding new files here, also remember to change the build files for +# all other languages, //protoc-artifacts/build-zip.sh and run +# //update_file_list.sh for bazel. nobase_dist_proto_DATA = google/protobuf/descriptor.proto \ google/protobuf/any.proto \ google/protobuf/api.proto \ -- cgit v1.2.3