aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Yang <TeBoring@users.noreply.github.com>2015-07-09 15:13:12 -0700
committerPaul Yang <TeBoring@users.noreply.github.com>2015-07-09 15:13:12 -0700
commitfe50044041e8b8bc6b8d8183e8d043ed6dba403e (patch)
tree8475f940f97422dcba951238e93b16f223d94f0b
parent5a020d41a55d2ad44bf0e84c74ba91758ef5d016 (diff)
parent9f563bd0d8863da35524f7d0a6f87abb2ec228a3 (diff)
downloadprotobuf-fe50044041e8b8bc6b8d8183e8d043ed6dba403e.tar.gz
protobuf-fe50044041e8b8bc6b8d8183e8d043ed6dba403e.tar.bz2
protobuf-fe50044041e8b8bc6b8d8183e8d043ed6dba403e.zip
Merge pull request #570 from google/internal-third-party
Internal local modifications.
-rwxr-xr-xpython/google/protobuf/internal/test_util.py7
-rw-r--r--src/Makefile.am1
-rw-r--r--src/google/protobuf/compiler/objectivec/objectivec_helpers.cc1
-rw-r--r--src/google/protobuf/map.h3
-rw-r--r--src/google/protobuf/map_entry_lite.h12
-rw-r--r--src/google/protobuf/stubs/atomicops_internals_generic_gcc.h4
-rw-r--r--src/google/protobuf/stubs/common.h20
-rwxr-xr-xsrc/google/protobuf/stubs/hash.h117
-rw-r--r--src/google/protobuf/stubs/pbconfig.h142
-rw-r--r--src/google/protobuf/testing/zcgunzip.cc9
-rw-r--r--src/google/protobuf/testing/zcgzip.cc9
11 files changed, 167 insertions, 158 deletions
diff --git a/python/google/protobuf/internal/test_util.py b/python/google/protobuf/internal/test_util.py
index 0cbdbad9..fec65382 100755
--- a/python/google/protobuf/internal/test_util.py
+++ b/python/google/protobuf/internal/test_util.py
@@ -602,6 +602,13 @@ def GoldenFile(filename):
return open(full_path, 'rb')
path = os.path.join(path, '..')
+ # Search internally.
+ path = '.'
+ full_path = os.path.join(path, 'third_party/py/google/protobuf/testdata', filename)
+ if os.path.exists(full_path):
+ # Found it. Load the golden file from the testdata directory.
+ return open(full_path, 'rb')
+
raise RuntimeError(
'Could not find golden files. This test must be run from within the '
'protobuf source package so that it can read test data files from the '
diff --git a/src/Makefile.am b/src/Makefile.am
index 5b28579f..effe2a4a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -76,7 +76,6 @@ nobase_include_HEADERS = \
google/protobuf/stubs/fastmem.h \
google/protobuf/stubs/hash.h \
google/protobuf/stubs/once.h \
- google/protobuf/stubs/pbconfig.h \
google/protobuf/stubs/platform_macros.h \
google/protobuf/stubs/shared_ptr.h \
google/protobuf/stubs/singleton.h \
diff --git a/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc b/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc
index 9b645f09..45d122d1 100644
--- a/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc
+++ b/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc
@@ -28,6 +28,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#include <climits>
#include <fstream>
#include <iostream>
#include <sstream>
diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h
index 96d2f201..163ce9dc 100644
--- a/src/google/protobuf/map.h
+++ b/src/google/protobuf/map.h
@@ -168,7 +168,8 @@ class Map {
}
}
-#if __cplusplus >= 201103L && !defined(GOOGLE_PROTOBUF_OS_APPLE)
+#if __cplusplus >= 201103L && !defined(GOOGLE_PROTOBUF_OS_APPLE) && \
+ !defined(GOOGLE_PROTOBUF_OS_NACL) && !defined(GOOGLE_PROTOBUF_OS_ANDROID)
template<class NodeType, class... Args>
void construct(NodeType* p, Args&&... args) {
new (p) NodeType(std::forward<Args>(args)...);
diff --git a/src/google/protobuf/map_entry_lite.h b/src/google/protobuf/map_entry_lite.h
index 52746da5..8de11766 100644
--- a/src/google/protobuf/map_entry_lite.h
+++ b/src/google/protobuf/map_entry_lite.h
@@ -162,7 +162,19 @@ class MapEntryLite : public MessageLite {
if (!KeyWireHandler::Read(input, mutable_key())) return false;
set_has_key();
if (!input->ExpectTag(kValueTag)) break;
+ // BEGIN GOOGLE LOCAL MODIFICATION
+ // Add __has_cpp_attribute and NaCl and Emscripten checks.
+#if defined(__clang__) && defined(__has_cpp_attribute) \
+ && !defined(GOOGLE_PROTOBUF_OS_APPLE)
+#if defined(GOOGLE_PROTOBUF_OS_NACL) || defined(EMSCRIPTEN)
+ [[clang::fallthrough]];
+#elif __has_cpp_attribute(clang::fallthrough)
+ [[clang::fallthrough]];
+#endif
+#else
GOOGLE_FALLTHROUGH_INTENDED;
+#endif
+ // END GOOGLE LOCAL MODIFICATION
case kValueTag:
if (!ValueWireHandler::Read(input, mutable_value())) return false;
diff --git a/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h b/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h
index dd7abf6f..a0116a60 100644
--- a/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h
+++ b/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h
@@ -61,8 +61,8 @@ inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
Atomic32 old_value,
Atomic32 new_value) {
- __atomic_compare_exchange(ptr, &old_value, &new_value, true,
- __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE);
+ __atomic_compare_exchange_n(ptr, &old_value, new_value, true,
+ __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE);
return old_value;
}
diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h
index 3eb57a9b..3a081e60 100644
--- a/src/google/protobuf/stubs/common.h
+++ b/src/google/protobuf/stubs/common.h
@@ -203,14 +203,22 @@ typedef unsigned __int16 uint16;
typedef unsigned __int32 uint32;
typedef unsigned __int64 uint64;
#else
-typedef int8_t int8;
-typedef int16_t int16;
-typedef int32_t int32;
+typedef signed char int8;
+typedef short int16;
+typedef int int32;
+// NOTE: This should be "long long" for consistency with upstream, but
+// something is stacked against this particular type for 64bit hashing.
+// Switching it causes an obvious missing hash function (with an unobvious
+// cause) when building the tests.
typedef int64_t int64;
-typedef uint8_t uint8;
-typedef uint16_t uint16;
-typedef uint32_t uint32;
+typedef unsigned char uint8;
+typedef unsigned short uint16;
+typedef unsigned int uint32;
+// NOTE: This should be "unsigned long long" for consistency with upstream, but
+// something is stacked against this particular type for 64bit hashing.
+// Switching it causes an obvious missing hash function (with an unobvious
+// cause) when building the tests.
typedef uint64_t uint64;
#endif
diff --git a/src/google/protobuf/stubs/hash.h b/src/google/protobuf/stubs/hash.h
index 4da8a5d8..9a6b217a 100755
--- a/src/google/protobuf/stubs/hash.h
+++ b/src/google/protobuf/stubs/hash.h
@@ -37,12 +37,117 @@
#include <string.h>
#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/pbconfig.h>
+
+#define GOOGLE_PROTOBUF_HAVE_HASH_MAP 1
+#define GOOGLE_PROTOBUF_HAVE_HASH_SET 1
+
+// Use C++11 unordered_{map|set} if available. Otherwise, libc++ always support
+// unordered_{map|set}
+#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X) || \
+ defined(_LIBCPP_VERSION)
+# define GOOGLE_PROTOBUF_HAS_CXX11_HASH
+
+// For XCode >= 4.6: the compiler is clang with libc++.
+// For earlier XCode version: the compiler is gcc-4.2.1 with libstdc++.
+// libc++ provides <unordered_map> and friends even in non C++11 mode,
+// and it does not provide the tr1 library. Therefore the following macro
+// checks against this special case.
+// Note that we should not test the __APPLE_CC__ version number or the
+// __clang__ macro, since the new compiler can still use -stdlib=libstdc++, in
+// which case <unordered_map> is not compilable without -std=c++11
+#elif defined(__APPLE_CC__)
+# if __GNUC__ >= 4
+# define GOOGLE_PROTOBUF_HAS_TR1
+# else
+// Not tested for gcc < 4... These setting can compile under 4.2.1 though.
+# define GOOGLE_PROTOBUF_HASH_NAMESPACE __gnu_cxx
+# include <ext/hash_map>
+# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map
+# include <ext/hash_set>
+# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set
+# endif
+
+// Version checks for gcc.
+#elif defined(__GNUC__)
+// For GCC 4.x+, use tr1::unordered_map/set; otherwise, follow the
+// instructions from:
+// https://gcc.gnu.org/onlinedocs/libstdc++/manual/backwards.html
+# if __GNUC__ >= 4
+# define GOOGLE_PROTOBUF_HAS_TR1
+# elif __GNUC__ >= 3
+# include <backward/hash_map>
+# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map
+# include <backward/hash_set>
+# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set
+# if __GNUC__ == 3 && __GNUC_MINOR__ == 0
+# define GOOGLE_PROTOBUF_HASH_NAMESPACE std // GCC 3.0
+# else
+# define GOOGLE_PROTOBUF_HASH_NAMESPACE __gnu_cxx // GCC 3.1 and later
+# endif
+# else
+# define GOOGLE_PROTOBUF_HASH_NAMESPACE
+# include <hash_map>
+# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map
+# include <hash_set>
+# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set
+# endif
+
+// Version checks for MSC.
+// Apparently Microsoft decided to move hash_map *back* to the std namespace in
+// MSVC 2010:
+// http://blogs.msdn.com/vcblog/archive/2009/05/25/stl-breaking-changes-in-visual-studio-2010-beta-1.aspx
+// And.. they are moved back to stdext in MSVC 2013 (haven't checked 2012). That
+// said, use unordered_map for MSVC 2010 and beyond is our safest bet.
+#elif defined(_MSC_VER)
+# if _MSC_VER >= 1600 // Since Visual Studio 2010
+# define GOOGLE_PROTOBUF_HAS_CXX11_HASH
+# define GOOGLE_PROTOBUF_HASH_COMPARE std::hash_compare
+# elif _MSC_VER >= 1500 // Since Visual Studio 2008
+# define GOOGLE_PROTOBUF_HAS_TR1
+# define GOOGLE_PROTOBUF_HASH_COMPARE stdext::hash_compare
+# elif _MSC_VER >= 1310
+# define GOOGLE_PROTOBUF_HASH_NAMESPACE stdext
+# include <hash_map>
+# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map
+# include <hash_set>
+# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set
+# define GOOGLE_PROTOBUF_HASH_COMPARE stdext::hash_compare
+# else
+# define GOOGLE_PROTOBUF_HASH_NAMESPACE std
+# include <hash_map>
+# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map
+# include <hash_set>
+# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set
+# define GOOGLE_PROTOBUF_HASH_COMPARE stdext::hash_compare
+# endif
+
+// **ADD NEW COMPILERS SUPPORT HERE.**
+// For other compilers, undefine the macro and fallback to use std::map, in
+// google/protobuf/stubs/hash.h
+#else
+# undef GOOGLE_PROTOBUF_HAVE_HASH_MAP
+# undef GOOGLE_PROTOBUF_HAVE_HASH_SET
+#endif
+
+#if defined(GOOGLE_PROTOBUF_HAS_CXX11_HASH)
+# define GOOGLE_PROTOBUF_HASH_NAMESPACE std
+# include <unordered_map>
+# define GOOGLE_PROTOBUF_HASH_MAP_CLASS unordered_map
+# include <unordered_set>
+# define GOOGLE_PROTOBUF_HASH_SET_CLASS unordered_set
+#elif defined(GOOGLE_PROTOBUF_HAS_TR1)
+# define GOOGLE_PROTOBUF_HASH_NAMESPACE std::tr1
+# include <tr1/unordered_map>
+# define GOOGLE_PROTOBUF_HASH_MAP_CLASS unordered_map
+# include <tr1/unordered_set>
+# define GOOGLE_PROTOBUF_HASH_SET_CLASS unordered_set
+#endif
+
+#undef GOOGLE_PROTOBUF_HAS_CXX11_HASH
+#undef GOOGLE_PROTOBUF_HAS_TR1
#if defined(GOOGLE_PROTOBUF_HAVE_HASH_MAP) && \
defined(GOOGLE_PROTOBUF_HAVE_HASH_SET)
-#include GOOGLE_PROTOBUF_HASH_MAP_H
-#include GOOGLE_PROTOBUF_HASH_SET_H
#else
#define GOOGLE_PROTOBUF_MISSING_HASH
#include <map>
@@ -92,13 +197,13 @@ template <typename Key, typename Data,
typename HashFcn = hash<Key>,
typename EqualKey = std::equal_to<Key>,
typename Alloc = std::allocator< std::pair<const Key, Data> > >
-class hash_map : public std::map<Key, Data, HashFcn, EqualKey, Alloc> {
- typedef std::map<Key, Data, HashFcn, EqualKey, Alloc> BaseClass;
+class hash_map : public std::map<Key, Data, HashFcn, Alloc> {
+ typedef std::map<Key, Data, HashFcn, Alloc> BaseClass;
public:
hash_map(int a = 0, const HashFcn& b = HashFcn(),
const EqualKey& c = EqualKey(),
- const Alloc& d = Alloc()) : BaseClass(a, b, c, d) {}
+ const Alloc& d = Alloc()) : BaseClass(b, d) {}
};
template <typename Key,
diff --git a/src/google/protobuf/stubs/pbconfig.h b/src/google/protobuf/stubs/pbconfig.h
deleted file mode 100644
index 0f21c560..00000000
--- a/src/google/protobuf/stubs/pbconfig.h
+++ /dev/null
@@ -1,142 +0,0 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#ifndef GOOGLE_PROTOBUF_STUBS_PBCONFIG_H__
-#define GOOGLE_PROTOBUF_STUBS_PBCONFIG_H__
-
-#define GOOGLE_PROTOBUF_HAVE_HASH_MAP 1
-#define GOOGLE_PROTOBUF_HAVE_HASH_SET 1
-
-// Use C++11 unordered_{map|set} if available.
-#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X)
-# define GOOGLE_PROTOBUF_HAS_CXX11_HASH
-
-// For XCode >= 4.6: the compiler is clang with libc++.
-// For earlier XCode version: the compiler is gcc-4.2.1 with libstdc++.
-// libc++ provides <unordered_map> and friends even in non C++11 mode,
-// and it does not provide the tr1 library. Therefore the following macro
-// checks against this special case.
-// Note that we should not test the __APPLE_CC__ version number or the
-// __clang__ macro, since the new compiler can still use -stdlib=libstdc++, in
-// which case <unordered_map> is not compilable without -std=c++11
-#elif defined(__APPLE_CC__)
-# if defined(_LIBCPP_VERSION)
-# define GOOGLE_PROTOBUF_HAS_CXX11_HASH
-# elif __GNUC__ >= 4
-# define GOOGLE_PROTOBUF_HAS_TR1
-# else
-// Not tested for gcc < 4... These setting can compile under 4.2.1 though.
-# define GOOGLE_PROTOBUF_HASH_NAMESPACE __gnu_cxx
-# define GOOGLE_PROTOBUF_HASH_MAP_H <ext/hash_map>
-# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map
-# define GOOGLE_PROTOBUF_HASH_SET_H <ext/hash_set>
-# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set
-# endif
-
-// Version checks for gcc.
-#elif defined(__GNUC__)
-// For GCC 4.x+, use tr1::unordered_map/set; otherwise, follow the
-// instructions from:
-// https://gcc.gnu.org/onlinedocs/libstdc++/manual/backwards.html
-# if __GNUC__ >= 4
-# define GOOGLE_PROTOBUF_HAS_TR1
-# elif __GNUC__ >= 3
-# define GOOGLE_PROTOBUF_HASH_MAP_H <backward/hash_map>
-# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map
-# define GOOGLE_PROTOBUF_HASH_SET_H <backward/hash_set>
-# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set
-# if __GNUC__ == 3 && __GNUC_MINOR__ == 0
-# define GOOGLE_PROTOBUF_HASH_NAMESPACE std // GCC 3.0
-# else
-# define GOOGLE_PROTOBUF_HASH_NAMESPACE __gnu_cxx // GCC 3.1 and later
-# endif
-# else
-# define GOOGLE_PROTOBUF_HASH_NAMESPACE
-# define GOOGLE_PROTOBUF_HASH_MAP_H <hash_map>
-# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map
-# define GOOGLE_PROTOBUF_HASH_SET_H <hash_set>
-# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set
-# endif
-
-// Version checks for MSC.
-// Apparently Microsoft decided to move hash_map *back* to the std namespace in
-// MSVC 2010:
-// http://blogs.msdn.com/vcblog/archive/2009/05/25/stl-breaking-changes-in-visual-studio-2010-beta-1.aspx
-// And.. they are moved back to stdext in MSVC 2013 (haven't checked 2012). That
-// said, use unordered_map for MSVC 2010 and beyond is our safest bet.
-#elif defined(_MSC_VER)
-# if _MSC_VER >= 1600 // Since Visual Studio 2010
-# define GOOGLE_PROTOBUF_HAS_CXX11_HASH
-# define GOOGLE_PROTOBUF_HASH_COMPARE std::hash_compare
-# elif _MSC_VER >= 1500 // Since Visual Studio 2008
-# define GOOGLE_PROTOBUF_HAS_TR1
-# define GOOGLE_PROTOBUF_HASH_COMPARE stdext::hash_compare
-# elif _MSC_VER >= 1310
-# define GOOGLE_PROTOBUF_HASH_NAMESPACE stdext
-# define GOOGLE_PROTOBUF_HASH_MAP_H <hash_map>
-# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map
-# define GOOGLE_PROTOBUF_HASH_SET_H <hash_set>
-# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set
-# define GOOGLE_PROTOBUF_HASH_COMPARE stdext::hash_compare
-# else
-# define GOOGLE_PROTOBUF_HASH_NAMESPACE std
-# define GOOGLE_PROTOBUF_HASH_MAP_H <hash_map>
-# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map
-# define GOOGLE_PROTOBUF_HASH_SET_H <hash_set>
-# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set
-# define GOOGLE_PROTOBUF_HASH_COMPARE stdext::hash_compare
-# endif
-
-// **ADD NEW COMPILERS SUPPORT HERE.**
-// For other compilers, undefine the macro and fallback to use std::map, in
-// google/protobuf/stubs/hash.h
-#else
-# undef GOOGLE_PROTOBUF_HAVE_HASH_MAP
-# undef GOOGLE_PROTOBUF_HAVE_HASH_SET
-#endif
-
-#if defined(GOOGLE_PROTOBUF_HAS_CXX11_HASH)
-# define GOOGLE_PROTOBUF_HASH_NAMESPACE std
-# define GOOGLE_PROTOBUF_HASH_MAP_H <unordered_map>
-# define GOOGLE_PROTOBUF_HASH_MAP_CLASS unordered_map
-# define GOOGLE_PROTOBUF_HASH_SET_H <unordered_set>
-# define GOOGLE_PROTOBUF_HASH_SET_CLASS unordered_set
-#elif defined(GOOGLE_PROTOBUF_HAS_TR1)
-# define GOOGLE_PROTOBUF_HASH_NAMESPACE std::tr1
-# define GOOGLE_PROTOBUF_HASH_MAP_H <tr1/unordered_map>
-# define GOOGLE_PROTOBUF_HASH_MAP_CLASS unordered_map
-# define GOOGLE_PROTOBUF_HASH_SET_H <tr1/unordered_set>
-# define GOOGLE_PROTOBUF_HASH_SET_CLASS unordered_set
-#endif
-
-#undef GOOGLE_PROTOBUF_HAS_CXX11_HASH
-#undef GOOGLE_PROTOBUF_HAS_TR1
-
-#endif // GOOGLE_PROTOBUF_STUBS_PBCONFIG_H__
diff --git a/src/google/protobuf/testing/zcgunzip.cc b/src/google/protobuf/testing/zcgunzip.cc
index c9d085c8..76f8cfe1 100644
--- a/src/google/protobuf/testing/zcgunzip.cc
+++ b/src/google/protobuf/testing/zcgunzip.cc
@@ -43,6 +43,15 @@
#include <stdlib.h>
#include <fcntl.h>
+#ifdef _WIN32
+#ifndef STDIN_FILENO
+#define STDIN_FILENO 0
+#endif
+#ifndef STDOUT_FILENO
+#define STDOUT_FILENO 1
+#endif
+#endif
+
#include <google/protobuf/io/gzip_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
diff --git a/src/google/protobuf/testing/zcgzip.cc b/src/google/protobuf/testing/zcgzip.cc
index e910f321..992ddc6e 100644
--- a/src/google/protobuf/testing/zcgzip.cc
+++ b/src/google/protobuf/testing/zcgzip.cc
@@ -42,6 +42,15 @@
#include <stdlib.h>
#include <fcntl.h>
+#ifdef _WIN32
+#ifndef STDIN_FILENO
+#define STDIN_FILENO 0
+#endif
+#ifndef STDOUT_FILENO
+#define STDOUT_FILENO 1
+#endif
+#endif
+
#include <google/protobuf/io/gzip_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>