diff options
author | scottmg <scottmg@chromium.org> | 2015-04-13 18:27:05 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-14 01:27:26 +0000 |
commit | cbe384e1542d4f7bd6482caca6aa4122ff240e3e (patch) | |
tree | 8ecbe681851951e45d27016e03d702953bc273ab | |
parent | 2fb2b0513cf5f6a76be0422075ddb2001846763c (diff) | |
download | chromium_src-cbe384e1542d4f7bd6482caca6aa4122ff240e3e.zip chromium_src-cbe384e1542d4f7bd6482caca6aa4122ff240e3e.tar.gz chromium_src-cbe384e1542d4f7bd6482caca6aa4122ff240e3e.tar.bz2 |
Cherry-pick some protobuf changes to get building on VS2015
R=cpu@chromium.org
BUG=440500
Review URL: https://codereview.chromium.org/1064723003
Cr-Commit-Position: refs/heads/master@{#324977}
-rw-r--r-- | third_party/protobuf/README.chromium | 2 | ||||
-rw-r--r-- | third_party/protobuf/src/google/protobuf/stubs/hash.h | 76 | ||||
-rw-r--r-- | third_party/protobuf/src/google/protobuf/stubs/pbconfig.h | 74 | ||||
-rw-r--r-- | third_party/protobuf/vsprojects/config.h | 29 |
4 files changed, 129 insertions, 52 deletions
diff --git a/third_party/protobuf/README.chromium b/third_party/protobuf/README.chromium index c6bb5c2..e894d79 100644 --- a/third_party/protobuf/README.chromium +++ b/third_party/protobuf/README.chromium @@ -40,3 +40,5 @@ GetEmptyString() and GoogleOnceInit() have been uninlined, for a large savings in binary size. A BUILD.gn file has been added for building with GN. + +Cherry-pick pherl changes to make protobuf build on VS2015. diff --git a/third_party/protobuf/src/google/protobuf/stubs/hash.h b/third_party/protobuf/src/google/protobuf/stubs/hash.h index f7d1071..82d5052 100644 --- a/third_party/protobuf/src/google/protobuf/stubs/hash.h +++ b/third_party/protobuf/src/google/protobuf/stubs/hash.h @@ -1,6 +1,6 @@ // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ +// 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 @@ -37,13 +37,14 @@ #include <string.h> #include <google/protobuf/stubs/common.h> -#include "config.h" +#include <google/protobuf/stubs/pbconfig.h> -#if defined(HAVE_HASH_MAP) && defined(HAVE_HASH_SET) -#include HASH_MAP_H -#include HASH_SET_H +#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 MISSING_HASH +#define GOOGLE_PROTOBUF_MISSING_HASH #include <map> #include <set> #endif @@ -51,7 +52,7 @@ namespace google { namespace protobuf { -#ifdef MISSING_HASH +#ifdef GOOGLE_PROTOBUF_MISSING_HASH // This system doesn't have hash_map or hash_set. Emulate them using map and // set. @@ -88,15 +89,17 @@ struct hash<const char*> { template <typename Key, typename Data, typename HashFcn = hash<Key>, - typename EqualKey = int > -class hash_map : public std::map<Key, Data, HashFcn> { + 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> { public: - hash_map(int = 0) {} + hash_map(int = 0, const HashFcn& = HashFcn(), const EqualKey& = EqualKey(), + const Alloc& = Alloc()) {} }; template <typename Key, typename HashFcn = hash<Key>, - typename EqualKey = int > + typename EqualKey = std::equal_to<Key> > class hash_set : public std::set<Key, HashFcn> { public: hash_set(int = 0) {} @@ -105,7 +108,7 @@ class hash_set : public std::set<Key, HashFcn> { #elif defined(_MSC_VER) && !defined(_STLPORT_VERSION) template <typename Key> -struct hash : public HASH_NAMESPACE::hash_compare<Key> { +struct hash : public GOOGLE_PROTOBUF_HASH_NAMESPACE::hash_compare<Key> { }; // MSVC's hash_compare<const char*> hashes based on the string contents but @@ -119,23 +122,26 @@ class CstringLess { template <> struct hash<const char*> - : public HASH_NAMESPACE::hash_compare<const char*, CstringLess> { -}; + : public GOOGLE_PROTOBUF_HASH_NAMESPACE::hash_compare< + const char*, CstringLess> {}; template <typename Key, typename Data, typename HashFcn = hash<Key>, - typename EqualKey = int > -class hash_map : public HASH_NAMESPACE::hash_map< - Key, Data, HashFcn> { + typename EqualKey = std::equal_to<Key>, + typename Alloc = std::allocator< std::pair<const Key, Data> > > +class hash_map + : public GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_MAP_CLASS< + Key, Data, HashFcn, EqualKey, Alloc> { public: - hash_map(int = 0) {} + hash_map(int = 0, const HashFcn& = HashFcn(), const EqualKey& = EqualKey(), + const Alloc& = Alloc()) {} }; -template <typename Key, - typename HashFcn = hash<Key>, - typename EqualKey = int > -class hash_set : public HASH_NAMESPACE::hash_set< - Key, HashFcn> { +template <typename Key, typename HashFcn = hash<Key>, + typename EqualKey = std::equal_to<Key> > +class hash_set + : public GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_SET_CLASS< + Key, HashFcn, EqualKey> { public: hash_set(int = 0) {} }; @@ -143,7 +149,7 @@ class hash_set : public HASH_NAMESPACE::hash_set< #else template <typename Key> -struct hash : public HASH_NAMESPACE::hash<Key> { +struct hash : public GOOGLE_PROTOBUF_HASH_NAMESPACE::hash<Key> { }; template <typename Key> @@ -168,23 +174,27 @@ struct hash<const char*> { template <typename Key, typename Data, typename HashFcn = hash<Key>, - typename EqualKey = std::equal_to<Key> > -class hash_map : public HASH_NAMESPACE::HASH_MAP_CLASS< - Key, Data, HashFcn, EqualKey> { + typename EqualKey = std::equal_to<Key>, + typename Alloc = std::allocator< std::pair<const Key, Data> > > +class hash_map + : public GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_MAP_CLASS< + Key, Data, HashFcn, EqualKey, Alloc> { public: - hash_map(int = 0) {} + hash_map(int = 0, const HashFcn& = HashFcn(), const EqualKey& = EqualKey(), + const Alloc& = Alloc()) {} }; -template <typename Key, - typename HashFcn = hash<Key>, +template <typename Key, typename HashFcn = hash<Key>, typename EqualKey = std::equal_to<Key> > -class hash_set : public HASH_NAMESPACE::HASH_SET_CLASS< - Key, HashFcn, EqualKey> { +class hash_set + : public GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_SET_CLASS< + Key, HashFcn, EqualKey> { public: hash_set(int = 0) {} }; -#endif +#undef GOOGLE_PROTOBUF_MISSING_HASH +#endif // !GOOGLE_PROTOBUF_MISSING_HASH template <> struct hash<string> { diff --git a/third_party/protobuf/src/google/protobuf/stubs/pbconfig.h b/third_party/protobuf/src/google/protobuf/stubs/pbconfig.h new file mode 100644 index 0000000..1c0cfbe --- /dev/null +++ b/third_party/protobuf/src/google/protobuf/stubs/pbconfig.h @@ -0,0 +1,74 @@ +/* Modified for Chromium to support stlport and libc++ adaptively */ +/* protobuf config.h for MSVC. On other platforms, this is generated + * automatically by autoheader / autoconf / configure. */ + +// NOTE: if you add new macros in this file manually, please propagate the macro +// to vsprojects/config.h. + +/* the namespace of hash_map/hash_set */ +// 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. +#if _MSC_VER >= 1600 +#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 _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 +#else +/* the name of <hash_map> */ +#if defined(_LIBCPP_VERSION) +#define GOOGLE_PROTOBUF_HASH_MAP_CLASS unordered_map +#else +#define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map +#endif + +/* the location of <unordered_map> or <hash_map> */ +#if defined(USE_STLPORT) +#define GOOGLE_PROTOBUF_HASH_MAP_H <hash_map> +#elif defined(_LIBCPP_VERSION) +#define GOOGLE_PROTOBUF_HASH_MAP_H <unordered_map> +#else +#define GOOGLE_PROTOBUF_HASH_MAP_H <ext/hash_map> +#endif + +/* the namespace of hash_map/hash_set */ +#if defined(USE_STLPORT) || defined(_LIBCPP_VERSION) +#define GOOGLE_PROTOBUF_HASH_NAMESPACE std +#else +#define GOOGLE_PROTOBUF_HASH_NAMESPACE __gnu_cxx +#endif + +/* the name of <hash_set> */ +#if defined(_LIBCPP_VERSION) +#define GOOGLE_PROTOBUF_HASH_SET_CLASS unordered_set +#else +#define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set +#endif + +/* the location of <unordered_set> or <hash_set> */ +#if defined(USE_STLPORT) +#define GOOGLE_PROTOBUF_HASH_SET_H <hash_set> +#elif defined(_LIBCPP_VERSION) +#define GOOGLE_PROTOBUF_HASH_SET_H <unordered_set> +#else +#define GOOGLE_PROTOBUF_HASH_SET_H <ext/hash_set> +#endif + +#endif // _MSC_VER >= 1600 + +/* the location of <hash_set> */ + +/* define if the compiler has hash_map */ +#define GOOGLE_PROTOBUF_HAVE_HASH_MAP 1 + +/* define if the compiler has hash_set */ +#define GOOGLE_PROTOBUF_HAVE_HASH_SET 1 diff --git a/third_party/protobuf/vsprojects/config.h b/third_party/protobuf/vsprojects/config.h index 2c64450..a93bb03 100644 --- a/third_party/protobuf/vsprojects/config.h +++ b/third_party/protobuf/vsprojects/config.h @@ -1,28 +1,19 @@ /* protobuf config.h for MSVC. On other platforms, this is generated * automatically by autoheader / autoconf / configure. */ -/* the location of <hash_map> */ -#define HASH_MAP_H <hash_map> +#include <google/protobuf/stubs/pbconfig.h> -/* the namespace of hash_map/hash_set */ -// 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 -// TODO(kenton): Use unordered_map instead, which is available in MSVC 2010. -#if _MSC_VER < 1310 || _MSC_VER >= 1600 -#define HASH_NAMESPACE std -#else -#define HASH_NAMESPACE stdext -#endif - -/* the location of <hash_set> */ -#define HASH_SET_H <hash_set> +#define HASH_MAP_H GOOGLE_PROTOBUF_HASH_MAP_H +#define HASH_NAMESPACE GOOGLE_PROTOBUF_HASH_NAMESPACE +#define HASH_SET_H GOOGLE_PROTOBUF_HASH_SET_H -/* define if the compiler has hash_map */ -#define HAVE_HASH_MAP 1 +#ifdef GOOGLE_PROTOBUF_HAVE_HASH_MAP +#define HAVE_HASH_MAP GOOGLE_PROTOBUF_HAVE_HASH_MAP +#endif -/* define if the compiler has hash_set */ -#define HAVE_HASH_SET 1 +#ifdef GOOGLE_PROTOBUF_HAVE_HASH_SET +#define HAVE_HASH_SET GOOGLE_PROTOBUF_HAVE_HASH_SET +#endif /* define if you want to use zlib. See readme.txt for additional * requirements. */ |