Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: third_party/protobuf/patches/01_build_fixes.patch

Issue 1322483002: Revert https://codereview.chromium.org/1291903002 (protobuf roll). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 diff --git a/third_party/protobuf/README.chromium b/third_party/protobuf/README. chromium
2 index 0375fd1..da9f26f 100644
3 --- a/third_party/protobuf/README.chromium
4 +++ b/third_party/protobuf/README.chromium
5 @@ -19,6 +19,9 @@ Steps used to create the current version:
6 will need to modify the README to include the correct revision, and modif y
7 the buildfiles to reflect the actual files in the source tree, what they
8 #include, what warnings they trigger, etc.
9 + 01: Miscellaneous build fixes to make the upstream sources compile. At this
10 + point you should be able to build the protobuf_* and protoc targets (but
11 + not necessarily anything depending on them).
12 (3) Generate descriptor_pb2.py using something like the following steps. Make
13 sure you've regenerated your buildfiles and will build protoc from the
14 newly-modified sources above.
15 diff --git a/third_party/protobuf/src/google/protobuf/arena.cc b/third_party/pro tobuf/src/google/protobuf/arena.cc
16 index ed1c5ef..ff7b466 100644
17 --- a/third_party/protobuf/src/google/protobuf/arena.cc
18 +++ b/third_party/protobuf/src/google/protobuf/arena.cc
19 @@ -38,17 +38,17 @@ namespace google {
20 namespace protobuf {
21
22 google::protobuf::internal::SequenceNumber Arena::lifecycle_id_generator_;
23 -#ifdef PROTOBUF_USE_DLLS
24 -Arena::ThreadCache& Arena::thread_cache() {
25 - static GOOGLE_THREAD_LOCAL ThreadCache thread_cache_ = { -1, NULL };
26 - return thread_cache_;
27 -}
28 -#elif defined(GOOGLE_PROTOBUF_NO_THREADLOCAL)
29 +#if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL)
30 Arena::ThreadCache& Arena::thread_cache() {
31 static internal::ThreadLocalStorage<ThreadCache>* thread_cache_ =
32 new internal::ThreadLocalStorage<ThreadCache>();
33 return *thread_cache_->Get();
34 }
35 +#elif defined(PROTOBUF_USE_DLLS)
36 +Arena::ThreadCache& Arena::thread_cache() {
37 + static GOOGLE_THREAD_LOCAL ThreadCache thread_cache_ = { -1, NULL };
38 + return thread_cache_;
39 +}
40 #else
41 GOOGLE_THREAD_LOCAL Arena::ThreadCache Arena::thread_cache_ = { -1, NULL };
42 #endif
43 diff --git a/third_party/protobuf/src/google/protobuf/arena.h b/third_party/prot obuf/src/google/protobuf/arena.h
44 index 51149ba..2ef20a3 100644
45 --- a/third_party/protobuf/src/google/protobuf/arena.h
46 +++ b/third_party/protobuf/src/google/protobuf/arena.h
47 @@ -34,7 +34,16 @@
48 #if __cplusplus >= 201103L
49 #include <google/protobuf/stubs/type_traits.h>
50 #endif
51 +#if defined(_MSC_VER) && !_HAS_EXCEPTIONS
52 +// Work around bugs in MSVC <typeinfo> header when _HAS_EXCEPTIONS=0.
53 +#include <exception>
54 #include <typeinfo>
55 +namespace std {
56 +using type_info = ::type_info;
57 +}
58 +#else
59 +#include <typeinfo>
60 +#endif
61
62 #include <google/protobuf/stubs/atomic_sequence_num.h>
63 #include <google/protobuf/stubs/atomicops.h>
64 @@ -525,15 +534,15 @@ class LIBPROTOBUF_EXPORT Arena {
65
66 static const size_t kHeaderSize = sizeof(Block);
67 static google::protobuf::internal::SequenceNumber lifecycle_id_generator_;
68 -#ifdef PROTOBUF_USE_DLLS
69 - // Thread local variables cannot be exposed through DLL interface but we can
70 - // wrap them in static functions.
71 - static ThreadCache& thread_cache();
72 -#elif defined(GOOGLE_PROTOBUF_NO_THREADLOCAL)
73 +#if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL)
74 // Android ndk does not support GOOGLE_THREAD_LOCAL keyword so we use a custo m thread
75 // local storage class we implemented.
76 // iOS also does not support the GOOGLE_THREAD_LOCAL keyword.
77 static ThreadCache& thread_cache();
78 +#elif defined(PROTOBUF_USE_DLLS)
79 + // Thread local variables cannot be exposed through DLL interface but we can
80 + // wrap them in static functions.
81 + static ThreadCache& thread_cache();
82 #else
83 static GOOGLE_THREAD_LOCAL ThreadCache thread_cache_;
84 static ThreadCache& thread_cache() { return thread_cache_; }
85 diff --git a/third_party/protobuf/src/google/protobuf/message_lite.cc b/third_pa rty/protobuf/src/google/protobuf/message_lite.cc
86 index 4f63ad2..da6e933 100644
87 --- a/third_party/protobuf/src/google/protobuf/message_lite.cc
88 +++ b/third_party/protobuf/src/google/protobuf/message_lite.cc
89 @@ -35,6 +35,7 @@
90
91 #include <google/protobuf/message_lite.h>
92 #include <google/protobuf/arena.h>
93 +#include <google/protobuf/repeated_field.h>
94 #include <string>
95 #include <google/protobuf/stubs/common.h>
96 #include <google/protobuf/io/coded_stream.h>
97 @@ -353,5 +354,18 @@ string MessageLite::SerializePartialAsString() const {
98 return output;
99 }
100
101 +namespace internal {
102 +template<>
103 +MessageLite* GenericTypeHandler<MessageLite>::NewFromPrototype(
104 + const MessageLite* prototype, google::protobuf::Arena* arena) {
105 + return prototype->New(arena);
106 +}
107 +template <>
108 +void GenericTypeHandler<MessageLite>::Merge(const MessageLite& from,
109 + MessageLite* to) {
110 + to->CheckTypeAndMergeFrom(from);
111 +}
112 +} // namespace internal
113 +
114 } // namespace protobuf
115 } // namespace google
116 diff --git a/third_party/protobuf/src/google/protobuf/repeated_field.h b/third_p arty/protobuf/src/google/protobuf/repeated_field.h
117 index 14f4629..03577ea 100644
118 --- a/third_party/protobuf/src/google/protobuf/repeated_field.h
119 +++ b/third_party/protobuf/src/google/protobuf/repeated_field.h
120 @@ -545,17 +545,11 @@ class GenericTypeHandler {
121 // constructors and destructors. Note that the GOOGLE_ATTRIBUTE_NOINLINE macr o
122 // requires the 'inline' storage class here, which is somewhat confusing, but
123 // the compiler does the right thing.
124 - static inline GenericType* NewFromPrototype(const GenericType* prototype,
125 - ::google::protobuf::Arena* arena = NULL)
126 - GOOGLE_ATTRIBUTE_NOINLINE {
127 - return New(arena);
128 - }
129 - static inline void Delete(GenericType* value, Arena* arena)
130 - GOOGLE_ATTRIBUTE_NOINLINE {
131 - if (arena == NULL) {
132 - delete value;
133 - }
134 - }
135 + static GenericType* NewFromPrototype(const GenericType* prototype,
136 + ::google::protobuf::Arena* arena = NULL)
137 + GOOGLE_ATTRIBUTE_NOINLINE;
138 + static void Delete(GenericType* value, Arena* arena)
139 + GOOGLE_ATTRIBUTE_NOINLINE;
140 static inline ::google::protobuf::Arena* GetArena(GenericType* value) {
141 return ::google::protobuf::Arena::GetArena<Type>(value);
142 }
143 @@ -564,10 +558,8 @@ class GenericTypeHandler {
144 }
145
146 static inline void Clear(GenericType* value) { value->Clear(); }
147 - static inline void Merge(const GenericType& from, GenericType* to)
148 - GOOGLE_ATTRIBUTE_NOINLINE {
149 - to->MergeFrom(from);
150 - }
151 + static void Merge(const GenericType& from, GenericType* to)
152 + GOOGLE_ATTRIBUTE_NOINLINE;
153 static inline int SpaceUsed(const GenericType& value) {
154 return value.SpaceUsed();
155 }
156 @@ -576,11 +568,32 @@ class GenericTypeHandler {
157 }
158 };
159
160 -template<>
161 -inline MessageLite* GenericTypeHandler<MessageLite>::NewFromPrototype(
162 - const MessageLite* prototype, google::protobuf::Arena* arena) {
163 - return prototype->New(arena);
164 +template<typename GenericType>
165 +GenericType* GenericTypeHandler<GenericType>::NewFromPrototype(
166 + const GenericType* prototype,
167 + ::google::protobuf::Arena* arena) {
168 + return New(arena);
169 +}
170 +template<typename GenericType>
171 +void GenericTypeHandler<GenericType>::Delete(GenericType* value, Arena* arena) {
172 + if (arena == NULL) {
173 + delete value;
174 + }
175 +}
176 +template<typename GenericType>
177 +void GenericTypeHandler<GenericType>::Merge(const GenericType& from,
178 + GenericType* to) {
179 + to->MergeFrom(from);
180 }
181 +
182 +// NewFromPrototype() and Merge() cannot be defined here; if they're declared
183 +// inline the compiler will complain about not matching ATTRIBUTE_NOINLINE
184 +// above, and if not, compilation will result in multiple definitions. These
185 +// are therefore declared as specializations here and defined in
186 +// message_lite.cc.
187 +template<>
188 +MessageLite* GenericTypeHandler<MessageLite>::NewFromPrototype(
189 + const MessageLite* prototype, google::protobuf::Arena* arena);
190 template<>
191 inline google::protobuf::Arena* GenericTypeHandler<MessageLite>::GetArena(
192 MessageLite* value) {
193 @@ -591,14 +604,9 @@ inline void* GenericTypeHandler<MessageLite>::GetMaybeArena Pointer(
194 MessageLite* value) {
195 return value->GetMaybeArenaPointer();
196 }
197 -
198 -// Implements GenericTypeHandler specialization required by RepeatedPtrFields
199 -// to work with MessageLite type.
200 template <>
201 -inline void GenericTypeHandler<MessageLite>::Merge(
202 - const MessageLite& from, MessageLite* to) {
203 - to->CheckTypeAndMergeFrom(from);
204 -}
205 +void GenericTypeHandler<MessageLite>::Merge(const MessageLite& from,
206 + MessageLite* to);
207
208 // Declarations of the specialization as we cannot define them here, as the
209 // header that defines ProtocolMessage depends on types defined in this header.
210 diff --git a/third_party/protobuf/src/google/protobuf/stubs/hash.h b/third_party /protobuf/src/google/protobuf/stubs/hash.h
211 index 9a6b217..3ff7253 100644
212 --- a/third_party/protobuf/src/google/protobuf/stubs/hash.h
213 +++ b/third_party/protobuf/src/google/protobuf/stubs/hash.h
214 @@ -41,10 +41,10 @@
215 #define GOOGLE_PROTOBUF_HAVE_HASH_MAP 1
216 #define GOOGLE_PROTOBUF_HAVE_HASH_SET 1
217
218 -// Use C++11 unordered_{map|set} if available. Otherwise, libc++ always support
219 -// unordered_{map|set}
220 -#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X) || \
221 - defined(_LIBCPP_VERSION)
222 +// Use C++11 unordered_{map|set} if available.
223 +#if ((__cplusplus >= 201103L) && \
224 + ((defined(__GLIBCXX__) && (__GLIBCXX__ > 20090421)) || \
225 + (defined(_LIBCPP_VERSION) && (_LIBCPP_STD_VER >= 11))))
226 # define GOOGLE_PROTOBUF_HAS_CXX11_HASH
227
228 // For XCode >= 4.6: the compiler is clang with libc++.
229 diff --git a/third_party/protobuf/src/google/protobuf/stubs/mathlimits.h b/third _party/protobuf/src/google/protobuf/stubs/mathlimits.h
230 index d984694..090d1c0 100644
231 --- a/third_party/protobuf/src/google/protobuf/stubs/mathlimits.h
232 +++ b/third_party/protobuf/src/google/protobuf/stubs/mathlimits.h
233 @@ -43,15 +43,10 @@
234 #ifndef UTIL_MATH_MATHLIMITS_H__
235 #define UTIL_MATH_MATHLIMITS_H__
236
237 -// <math.h> lacks a lot of prototypes. However, this file needs <math.h> to
238 -// access old-fashioned isinf et al. Even worse more: this file must not
239 -// include <cmath> because that breaks the definition of isinf with gcc 4.9.
240 -//
241 -// TODO(mec): after C++11 everywhere, use <cmath> and std::isinf in this file.
242 -#include <math.h>
243 #include <string.h>
244
245 #include <cfloat>
246 +#include <cmath>
247
248 #include <google/protobuf/stubs/common.h>
249
250 @@ -230,11 +225,11 @@ DECL_UNSIGNED_INT_LIMITS(unsigned long long int)
251 static bool IsNegInf(const Type x) { return _fpclass(x) == _FPCLASS_NINF; }
252 #else
253 #define DECL_FP_LIMIT_FUNCS \
254 - static bool IsFinite(const Type x) { return !isinf(x) && !isnan(x); } \
255 - static bool IsNaN(const Type x) { return isnan(x); } \
256 - static bool IsInf(const Type x) { return isinf(x); } \
257 - static bool IsPosInf(const Type x) { return isinf(x) && x > 0; } \
258 - static bool IsNegInf(const Type x) { return isinf(x) && x < 0; }
259 + static bool IsFinite(const Type x) { return !std::isinf(x) && !std::isnan(x ); } \
260 + static bool IsNaN(const Type x) { return std::isnan(x); } \
261 + static bool IsInf(const Type x) { return std::isinf(x); } \
262 + static bool IsPosInf(const Type x) { return std::isinf(x) && x > 0; } \
263 + static bool IsNegInf(const Type x) { return std::isinf(x) && x < 0; }
264 #endif
265
266 // We can't put floating-point constant values in the header here because
267 diff --git a/third_party/protobuf/src/google/protobuf/stubs/mathutil.h b/third_p arty/protobuf/src/google/protobuf/stubs/mathutil.h
268 index 99c4d45..cfd073b 100644
269 --- a/third_party/protobuf/src/google/protobuf/stubs/mathutil.h
270 +++ b/third_party/protobuf/src/google/protobuf/stubs/mathutil.h
271 @@ -31,7 +31,8 @@
272 #define GOOGLE_PROTOBUF_STUBS_MATHUTIL_H_
273
274 #include <float.h>
275 -#include <math.h>
276 +
277 +#include <cmath>
278
279 #include <google/protobuf/stubs/common.h>
280 #include <google/protobuf/stubs/logging.h>
281 @@ -45,9 +46,9 @@ bool IsNan(T value) {
282 return false;
283 }
284 template<>
285 -inline bool IsNan(float value) { return isnan(value); }
286 +inline bool IsNan(float value) { return std::isnan(value); }
287 template<>
288 -inline bool IsNan(double value) { return isnan(value); }
289 +inline bool IsNan(double value) { return std::isnan(value); }
290
291 template<typename T>
292 bool AlmostEquals(T a, T b) {
293 diff --git a/third_party/protobuf/src/google/protobuf/stubs/port.h b/third_party /protobuf/src/google/protobuf/stubs/port.h
294 index 8a5d1a1..da695ff 100644
295 --- a/third_party/protobuf/src/google/protobuf/stubs/port.h
296 +++ b/third_party/protobuf/src/google/protobuf/stubs/port.h
297 @@ -79,6 +79,15 @@
298 #define LIBPROTOC_EXPORT
299 #endif
300
301 +// These #includes are for the byte swap functions declared later on.
302 +#ifdef _MSC_VER
303 +#include <stdlib.h> // NOLINT(build/include)
304 +#elif defined(__APPLE__)
305 +#include <libkern/OSByteOrder.h>
306 +#elif defined(__GLIBC__) || defined(__CYGWIN__)
307 +#include <byteswap.h> // IWYU pragma: export
308 +#endif
309 +
310 // ===================================================================
311 // from google3/base/port.h
312 namespace google {
313 @@ -272,7 +281,6 @@ inline void GOOGLE_UNALIGNED_STORE64(void *p, uint64 v) {
314 // The following guarantees declaration of the byte swap functions, and
315 // defines __BYTE_ORDER for MSVC
316 #ifdef _MSC_VER
317 -#include <stdlib.h> // NOLINT(build/include)
318 #define __BYTE_ORDER __LITTLE_ENDIAN
319 #define bswap_16(x) _byteswap_ushort(x)
320 #define bswap_32(x) _byteswap_ulong(x)
321 @@ -280,15 +288,11 @@ inline void GOOGLE_UNALIGNED_STORE64(void *p, uint64 v) {
322
323 #elif defined(__APPLE__)
324 // Mac OS X / Darwin features
325 -#include <libkern/OSByteOrder.h>
326 #define bswap_16(x) OSSwapInt16(x)
327 #define bswap_32(x) OSSwapInt32(x)
328 #define bswap_64(x) OSSwapInt64(x)
329
330 -#elif defined(__GLIBC__) || defined(__CYGWIN__)
331 -#include <byteswap.h> // IWYU pragma: export
332 -
333 -#else
334 +#elif !defined(__GLIBC__) && !defined(__CYGWIN__)
335
336 static inline uint16 bswap_16(uint16 x) {
337 return static_cast<uint16>(((x & 0xFF) << 8) | ((x & 0xFF00) >> 8));
338 diff --git a/third_party/protobuf/src/google/protobuf/stubs/time.cc b/third_part y/protobuf/src/google/protobuf/stubs/time.cc
339 index 3319a24..49c0412 100644
340 --- a/third_party/protobuf/src/google/protobuf/stubs/time.cc
341 +++ b/third_party/protobuf/src/google/protobuf/stubs/time.cc
342 @@ -21,7 +21,6 @@ static const int64 kSecondsFromEraToEpoch = 62135596800LL;
343 static const int64 kMinTime = -62135596800LL; // 0001-01-01T00:00:00
344 static const int64 kMaxTime = 253402300799LL; // 9999-12-31T23:59:59
345
346 -static const int kNanosPerSecond = 1000000000;
347 static const int kNanosPerMillisecond = 1000000;
348 static const int kNanosPerMicrosecond = 1000;
349
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698