OLD | NEW |
| (Empty) |
1 diff -ru --new-file protobuf/src/google/protobuf/arena.cc protobuf2/src/google/p
rotobuf/arena.cc | |
2 --- protobuf/src/google/protobuf/arena.cc 2017-03-21 21:50:28.399255503 -0
700 | |
3 +++ protobuf2/src/google/protobuf/arena.cc 2017-03-21 21:50:11.671241466 -0
700 | |
4 @@ -39,24 +39,18 @@ | |
5 namespace protobuf { | |
6 | |
7 | |
8 -google::protobuf::internal::SequenceNumber Arena::lifecycle_id_generator_; | |
9 #if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL) | |
10 -Arena::ThreadCache& Arena::thread_cache() { | |
11 +Arena::ThreadCache& Arena::cr_thread_cache() { | |
12 static internal::ThreadLocalStorage<ThreadCache>* thread_cache_ = | |
13 new internal::ThreadLocalStorage<ThreadCache>(); | |
14 return *thread_cache_->Get(); | |
15 } | |
16 -#elif defined(PROTOBUF_USE_DLLS) | |
17 -Arena::ThreadCache& Arena::thread_cache() { | |
18 - static GOOGLE_THREAD_LOCAL ThreadCache thread_cache_ = { -1, NULL }; | |
19 - return thread_cache_; | |
20 -} | |
21 -#else | |
22 +#elif !defined(PROTOBUF_USE_DLLS) | |
23 GOOGLE_THREAD_LOCAL Arena::ThreadCache Arena::thread_cache_ = { -1, NULL }; | |
24 #endif | |
25 | |
26 void Arena::Init() { | |
27 - lifecycle_id_ = lifecycle_id_generator_.GetNext(); | |
28 + lifecycle_id_ = internal::cr_lifecycle_id_generator_.GetNext(); | |
29 blocks_ = 0; | |
30 hint_ = 0; | |
31 owns_first_block_ = true; | |
32 @@ -74,7 +68,7 @@ | |
33 // Thread which calls Init() owns the first block. This allows the | |
34 // single-threaded case to allocate on the first block without taking any | |
35 // locks. | |
36 - first_block->owner = &thread_cache(); | |
37 + first_block->owner = &cr_thread_cache(); | |
38 SetThreadCacheBlock(first_block); | |
39 AddBlockInternal(first_block); | |
40 owns_first_block_ = false; | |
41 @@ -99,7 +93,7 @@ | |
42 | |
43 uint64 Arena::Reset() { | |
44 // Invalidate any ThreadCaches pointing to any blocks we just destroyed. | |
45 - lifecycle_id_ = lifecycle_id_generator_.GetNext(); | |
46 + lifecycle_id_ = internal::cr_lifecycle_id_generator_.GetNext(); | |
47 return ResetInternal(); | |
48 } | |
49 | |
50 @@ -184,18 +178,18 @@ | |
51 // If this thread already owns a block in this arena then try to use that. | |
52 // This fast path optimizes the case where multiple threads allocate from the | |
53 // same arena. | |
54 - if (thread_cache().last_lifecycle_id_seen == lifecycle_id_ && | |
55 - thread_cache().last_block_used_ != NULL) { | |
56 - if (thread_cache().last_block_used_->avail() < n) { | |
57 + if (cr_thread_cache().last_lifecycle_id_seen == lifecycle_id_ && | |
58 + cr_thread_cache().last_block_used_ != NULL) { | |
59 + if (cr_thread_cache().last_block_used_->avail() < n) { | |
60 return SlowAlloc(n); | |
61 } | |
62 - return AllocFromBlock(thread_cache().last_block_used_, n); | |
63 + return AllocFromBlock(cr_thread_cache().last_block_used_, n); | |
64 } | |
65 | |
66 // Check whether we own the last accessed block on this arena. | |
67 // This fast path optimizes the case where a single thread uses multiple | |
68 // arenas. | |
69 - void* me = &thread_cache(); | |
70 + void* me = &cr_thread_cache(); | |
71 Block* b = reinterpret_cast<Block*>(google::protobuf::internal::Acquire_Load(
&hint_)); | |
72 if (!b || b->owner != me || b->avail() < n) { | |
73 return SlowAlloc(n); | |
74 @@ -213,7 +207,7 @@ | |
75 } | |
76 | |
77 void* Arena::SlowAlloc(size_t n) { | |
78 - void* me = &thread_cache(); | |
79 + void* me = &cr_thread_cache(); | |
80 Block* b = FindBlock(me); // Find block owned by me. | |
81 // See if allocation fits in my latest block. | |
82 if (b != NULL && b->avail() >= n) { | |
83 @@ -290,7 +284,7 @@ | |
84 // Thread which calls Reset() owns the first block. This allows the | |
85 // single-threaded case to allocate on the first block without taking any | |
86 // locks. | |
87 - first_block->owner = &thread_cache(); | |
88 + first_block->owner = &cr_thread_cache(); | |
89 SetThreadCacheBlock(first_block); | |
90 AddBlockInternal(first_block); | |
91 } | |
92 diff -ru --new-file protobuf/src/google/protobuf/arena.h protobuf2/src/google/pr
otobuf/arena.h | |
93 --- protobuf/src/google/protobuf/arena.h 2017-03-21 21:50:28.399255503 -0
700 | |
94 +++ protobuf2/src/google/protobuf/arena.h 2017-03-21 21:50:11.671241466 -0
700 | |
95 @@ -70,6 +70,9 @@ | |
96 template<typename Type> | |
97 class GenericTypeHandler; // repeated_field.h | |
98 | |
99 +LIBPROTOBUF_EXPORT extern google::protobuf::internal::SequenceNumber | |
100 + cr_lifecycle_id_generator_; | |
101 + | |
102 // Templated cleanup methods. | |
103 template<typename T> void arena_destruct_object(void* object) { | |
104 reinterpret_cast<T*>(object)->~T(); | |
105 @@ -552,19 +555,20 @@ | |
106 }; | |
107 | |
108 static const size_t kHeaderSize = sizeof(Block); | |
109 - static google::protobuf::internal::SequenceNumber lifecycle_id_generator_; | |
110 #if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL) | |
111 // Android ndk does not support GOOGLE_THREAD_LOCAL keyword so we use a custo
m thread | |
112 // local storage class we implemented. | |
113 // iOS also does not support the GOOGLE_THREAD_LOCAL keyword. | |
114 - static ThreadCache& thread_cache(); | |
115 + static ThreadCache& cr_thread_cache(); | |
116 #elif defined(PROTOBUF_USE_DLLS) | |
117 // Thread local variables cannot be exposed through DLL interface but we can | |
118 // wrap them in static functions. | |
119 - static ThreadCache& thread_cache(); | |
120 + static ThreadCache& cr_thread_cache(); | |
121 #else | |
122 static GOOGLE_THREAD_LOCAL ThreadCache thread_cache_; | |
123 - static ThreadCache& thread_cache() { return thread_cache_; } | |
124 + static ThreadCache& cr_thread_cache() { | |
125 + return thread_cache_; | |
126 + } | |
127 #endif | |
128 | |
129 // SFINAE for skipping addition to delete list for a message type when create
d | |
130 @@ -872,8 +876,8 @@ | |
131 uint64 ResetInternal(); | |
132 | |
133 inline void SetThreadCacheBlock(Block* block) { | |
134 - thread_cache().last_block_used_ = block; | |
135 - thread_cache().last_lifecycle_id_seen = lifecycle_id_; | |
136 + cr_thread_cache().last_block_used_ = block; | |
137 + cr_thread_cache().last_lifecycle_id_seen = lifecycle_id_; | |
138 } | |
139 | |
140 int64 lifecycle_id_; // Unique for each arena. Changes on Reset(). | |
141 diff -ru --new-file protobuf/src/google/protobuf/extension_set.cc protobuf2/src/
google/protobuf/extension_set.cc | |
142 --- protobuf/src/google/protobuf/extension_set.cc 2017-03-21 21:50:28.3992
55503 -0700 | |
143 +++ protobuf2/src/google/protobuf/extension_set.cc 2017-03-21 21:50:11.6712
41466 -0700 | |
144 @@ -46,6 +46,12 @@ | |
145 namespace protobuf { | |
146 namespace internal { | |
147 | |
148 +// Registry stuff. | |
149 +typedef hash_map<pair<const MessageLite*, int>, ExtensionInfo> | |
150 + ExtensionRegistry; | |
151 +extern ExtensionRegistry* cr_registry_; | |
152 +extern ProtobufOnceType cr_registry_init_; | |
153 + | |
154 namespace { | |
155 | |
156 inline WireFormatLite::FieldType real_type(FieldType type) { | |
157 @@ -75,19 +81,13 @@ | |
158 return false; | |
159 } | |
160 | |
161 -// Registry stuff. | |
162 -typedef hash_map<pair<const MessageLite*, int>, | |
163 - ExtensionInfo> ExtensionRegistry; | |
164 -ExtensionRegistry* registry_ = NULL; | |
165 -GOOGLE_PROTOBUF_DECLARE_ONCE(registry_init_); | |
166 - | |
167 void DeleteRegistry() { | |
168 - delete registry_; | |
169 - registry_ = NULL; | |
170 + delete cr_registry_; | |
171 + cr_registry_ = NULL; | |
172 } | |
173 | |
174 void InitRegistry() { | |
175 - registry_ = new ExtensionRegistry; | |
176 + cr_registry_ = new ExtensionRegistry; | |
177 OnShutdown(&DeleteRegistry); | |
178 } | |
179 | |
180 @@ -95,9 +95,9 @@ | |
181 // safety. | |
182 void Register(const MessageLite* containing_type, | |
183 int number, ExtensionInfo info) { | |
184 - ::google::protobuf::GoogleOnceInit(®istry_init_, &InitRegistry); | |
185 + ::google::protobuf::GoogleOnceInit(&cr_registry_init_, &InitRegistry); | |
186 | |
187 - if (!InsertIfNotPresent(registry_, std::make_pair(containing_type, number), | |
188 + if (!InsertIfNotPresent(cr_registry_, std::make_pair(containing_type, number)
, | |
189 info)) { | |
190 GOOGLE_LOG(FATAL) << "Multiple extension registrations for type \"" | |
191 << containing_type->GetTypeName() | |
192 @@ -107,9 +107,10 @@ | |
193 | |
194 const ExtensionInfo* FindRegisteredExtension( | |
195 const MessageLite* containing_type, int number) { | |
196 - return (registry_ == NULL) | |
197 + return (cr_registry_ == NULL) | |
198 ? NULL | |
199 - : FindOrNull(*registry_, std::make_pair(containing_type, number)); | |
200 + : FindOrNull(*cr_registry_, | |
201 + std::make_pair(containing_type, number)); | |
202 } | |
203 | |
204 } // namespace | |
205 @@ -1748,68 +1749,45 @@ | |
206 // ================================================================== | |
207 // Default repeated field instances for iterator-compatible accessors | |
208 | |
209 -GOOGLE_PROTOBUF_DECLARE_ONCE(repeated_primitive_generic_type_traits_once_init_)
; | |
210 -GOOGLE_PROTOBUF_DECLARE_ONCE(repeated_string_type_traits_once_init_); | |
211 -GOOGLE_PROTOBUF_DECLARE_ONCE(repeated_message_generic_type_traits_once_init_); | |
212 - | |
213 void RepeatedPrimitiveGenericTypeTraits::InitializeDefaultRepeatedFields() { | |
214 - default_repeated_field_int32_ = new RepeatedField<int32>; | |
215 - default_repeated_field_int64_ = new RepeatedField<int64>; | |
216 - default_repeated_field_uint32_ = new RepeatedField<uint32>; | |
217 - default_repeated_field_uint64_ = new RepeatedField<uint64>; | |
218 - default_repeated_field_double_ = new RepeatedField<double>; | |
219 - default_repeated_field_float_ = new RepeatedField<float>; | |
220 - default_repeated_field_bool_ = new RepeatedField<bool>; | |
221 + cr_default_repeated_field_int32_ = new RepeatedField<int32>; | |
222 + cr_default_repeated_field_int64_ = new RepeatedField<int64>; | |
223 + cr_default_repeated_field_uint32_ = new RepeatedField<uint32>; | |
224 + cr_default_repeated_field_uint64_ = new RepeatedField<uint64>; | |
225 + cr_default_repeated_field_double_ = new RepeatedField<double>; | |
226 + cr_default_repeated_field_float_ = new RepeatedField<float>; | |
227 + cr_default_repeated_field_bool_ = new RepeatedField<bool>; | |
228 OnShutdown(&DestroyDefaultRepeatedFields); | |
229 } | |
230 | |
231 void RepeatedPrimitiveGenericTypeTraits::DestroyDefaultRepeatedFields() { | |
232 - delete default_repeated_field_int32_; | |
233 - delete default_repeated_field_int64_; | |
234 - delete default_repeated_field_uint32_; | |
235 - delete default_repeated_field_uint64_; | |
236 - delete default_repeated_field_double_; | |
237 - delete default_repeated_field_float_; | |
238 - delete default_repeated_field_bool_; | |
239 + delete cr_default_repeated_field_int32_; | |
240 + delete cr_default_repeated_field_int64_; | |
241 + delete cr_default_repeated_field_uint32_; | |
242 + delete cr_default_repeated_field_uint64_; | |
243 + delete cr_default_repeated_field_double_; | |
244 + delete cr_default_repeated_field_float_; | |
245 + delete cr_default_repeated_field_bool_; | |
246 } | |
247 | |
248 void RepeatedStringTypeTraits::InitializeDefaultRepeatedFields() { | |
249 - default_repeated_field_ = new RepeatedFieldType; | |
250 + cr_default_repeated_field_ = new RepeatedFieldType; | |
251 OnShutdown(&DestroyDefaultRepeatedFields); | |
252 } | |
253 | |
254 void RepeatedStringTypeTraits::DestroyDefaultRepeatedFields() { | |
255 - delete default_repeated_field_; | |
256 + delete cr_default_repeated_field_; | |
257 } | |
258 | |
259 void RepeatedMessageGenericTypeTraits::InitializeDefaultRepeatedFields() { | |
260 - default_repeated_field_ = new RepeatedFieldType; | |
261 + cr_default_repeated_field_ = new RepeatedFieldType; | |
262 OnShutdown(&DestroyDefaultRepeatedFields); | |
263 } | |
264 | |
265 void RepeatedMessageGenericTypeTraits::DestroyDefaultRepeatedFields() { | |
266 - delete default_repeated_field_; | |
267 + delete cr_default_repeated_field_; | |
268 } | |
269 | |
270 -const RepeatedField<int32>* | |
271 -RepeatedPrimitiveGenericTypeTraits::default_repeated_field_int32_ = NULL; | |
272 -const RepeatedField<int64>* | |
273 -RepeatedPrimitiveGenericTypeTraits::default_repeated_field_int64_ = NULL; | |
274 -const RepeatedField<uint32>* | |
275 -RepeatedPrimitiveGenericTypeTraits::default_repeated_field_uint32_ = NULL; | |
276 -const RepeatedField<uint64>* | |
277 -RepeatedPrimitiveGenericTypeTraits::default_repeated_field_uint64_ = NULL; | |
278 -const RepeatedField<double>* | |
279 -RepeatedPrimitiveGenericTypeTraits::default_repeated_field_double_ = NULL; | |
280 -const RepeatedField<float>* | |
281 -RepeatedPrimitiveGenericTypeTraits::default_repeated_field_float_ = NULL; | |
282 -const RepeatedField<bool>* | |
283 -RepeatedPrimitiveGenericTypeTraits::default_repeated_field_bool_ = NULL; | |
284 -const RepeatedStringTypeTraits::RepeatedFieldType* | |
285 -RepeatedStringTypeTraits::default_repeated_field_ = NULL; | |
286 -const RepeatedMessageGenericTypeTraits::RepeatedFieldType* | |
287 -RepeatedMessageGenericTypeTraits::default_repeated_field_ = NULL; | |
288 - | |
289 } // namespace internal | |
290 } // namespace protobuf | |
291 } // namespace google | |
292 diff -ru --new-file protobuf/src/google/protobuf/extension_set.h protobuf2/src/g
oogle/protobuf/extension_set.h | |
293 --- protobuf/src/google/protobuf/extension_set.h 2017-03-21 21:50:28.3992
55503 -0700 | |
294 +++ protobuf2/src/google/protobuf/extension_set.h 2017-03-21 21:50:11.6792
41474 -0700 | |
295 @@ -731,13 +731,13 @@ | |
296 template<typename Type> friend class RepeatedPrimitiveTypeTraits; | |
297 static void InitializeDefaultRepeatedFields(); | |
298 static void DestroyDefaultRepeatedFields(); | |
299 - static const RepeatedField<int32>* default_repeated_field_int32_; | |
300 - static const RepeatedField<int64>* default_repeated_field_int64_; | |
301 - static const RepeatedField<uint32>* default_repeated_field_uint32_; | |
302 - static const RepeatedField<uint64>* default_repeated_field_uint64_; | |
303 - static const RepeatedField<double>* default_repeated_field_double_; | |
304 - static const RepeatedField<float>* default_repeated_field_float_; | |
305 - static const RepeatedField<bool>* default_repeated_field_bool_; | |
306 + static const RepeatedField<int32>* cr_default_repeated_field_int32_; | |
307 + static const RepeatedField<int64>* cr_default_repeated_field_int64_; | |
308 + static const RepeatedField<uint32>* cr_default_repeated_field_uint32_; | |
309 + static const RepeatedField<uint64>* cr_default_repeated_field_uint64_; | |
310 + static const RepeatedField<double>* cr_default_repeated_field_double_; | |
311 + static const RepeatedField<float>* cr_default_repeated_field_float_; | |
312 + static const RepeatedField<bool>* cr_default_repeated_field_bool_; | |
313 }; | |
314 | |
315 #define PROTOBUF_DEFINE_PRIMITIVE_TYPE(TYPE, METHOD) \ | |
316 @@ -769,7 +769,7 @@ | |
317 &repeated_primitive_generic_type_traits_once_init_, \ | |
318 &RepeatedPrimitiveGenericTypeTraits::InitializeDefaultRepeatedFields); \ | |
319 return RepeatedPrimitiveGenericTypeTraits:: \ | |
320 - default_repeated_field_##TYPE##_; \ | |
321 + cr_default_repeated_field_##TYPE##_; \ | |
322 } \ | |
323 template<> inline const RepeatedField<TYPE>& \ | |
324 RepeatedPrimitiveTypeTraits<TYPE>::GetRepeated(int number, \ | |
325 @@ -821,7 +821,8 @@ | |
326 } | |
327 }; | |
328 | |
329 -LIBPROTOBUF_EXPORT extern ProtobufOnceType repeated_string_type_traits_once_ini
t_; | |
330 +LIBPROTOBUF_EXPORT extern ProtobufOnceType | |
331 + cr_repeated_string_type_traits_once_init_; | |
332 | |
333 class LIBPROTOBUF_EXPORT RepeatedStringTypeTraits { | |
334 public: | |
335 @@ -866,15 +867,16 @@ | |
336 } | |
337 | |
338 static const RepeatedFieldType* GetDefaultRepeatedField() { | |
339 - ::google::protobuf::GoogleOnceInit(&repeated_string_type_traits_once_init_, | |
340 - &InitializeDefaultRepeatedFields); | |
341 - return default_repeated_field_; | |
342 + ::google::protobuf::GoogleOnceInit( | |
343 + &cr_repeated_string_type_traits_once_init_, | |
344 + &InitializeDefaultRepeatedFields); | |
345 + return cr_default_repeated_field_; | |
346 } | |
347 | |
348 private: | |
349 static void InitializeDefaultRepeatedFields(); | |
350 static void DestroyDefaultRepeatedFields(); | |
351 - static const RepeatedFieldType *default_repeated_field_; | |
352 + static const RepeatedFieldType* cr_default_repeated_field_; | |
353 }; | |
354 | |
355 // ------------------------------------------------------------------- | |
356 @@ -1043,7 +1045,7 @@ | |
357 template<typename Type> friend class RepeatedMessageTypeTraits; | |
358 static void InitializeDefaultRepeatedFields(); | |
359 static void DestroyDefaultRepeatedFields(); | |
360 - static const RepeatedFieldType* default_repeated_field_; | |
361 + static const RepeatedFieldType* cr_default_repeated_field_; | |
362 }; | |
363 | |
364 template<typename Type> inline | |
365 @@ -1053,7 +1055,7 @@ | |
366 &repeated_message_generic_type_traits_once_init_, | |
367 &RepeatedMessageGenericTypeTraits::InitializeDefaultRepeatedFields); | |
368 return reinterpret_cast<const RepeatedFieldType*>( | |
369 - RepeatedMessageGenericTypeTraits::default_repeated_field_); | |
370 + RepeatedMessageGenericTypeTraits::cr_default_repeated_field_); | |
371 } | |
372 | |
373 // ------------------------------------------------------------------- | |
374 diff -ru --new-file protobuf/src/google/protobuf/generated_message_util.cc proto
buf2/src/google/protobuf/generated_message_util.cc | |
375 --- protobuf/src/google/protobuf/generated_message_util.cc 2017-03-21 21:50
:28.399255503 -0700 | |
376 +++ protobuf2/src/google/protobuf/generated_message_util.cc 2017-03-21 21:50
:11.695241487 -0700 | |
377 @@ -48,20 +48,18 @@ | |
378 return std::numeric_limits<double>::quiet_NaN(); | |
379 } | |
380 | |
381 -const ::std::string* empty_string_; | |
382 -GOOGLE_PROTOBUF_DECLARE_ONCE(empty_string_once_init_); | |
383 - | |
384 void DeleteEmptyString() { | |
385 - delete empty_string_; | |
386 + delete cr_empty_string_; | |
387 } | |
388 | |
389 void InitEmptyString() { | |
390 - empty_string_ = new string; | |
391 + cr_empty_string_ = new string; | |
392 OnShutdown(&DeleteEmptyString); | |
393 } | |
394 | |
395 const ::std::string& GetEmptyString() { | |
396 - ::google::protobuf::GoogleOnceInit(&empty_string_once_init_, &InitEmptyString
); | |
397 + ::google::protobuf::GoogleOnceInit(&cr_empty_string_once_init_, | |
398 + &InitEmptyString); | |
399 return GetEmptyStringAlreadyInited(); | |
400 } | |
401 | |
402 diff -ru --new-file protobuf/src/google/protobuf/generated_message_util.h protob
uf2/src/google/protobuf/generated_message_util.h | |
403 --- protobuf/src/google/protobuf/generated_message_util.h 2017-03-21 21:50
:28.399255503 -0700 | |
404 +++ protobuf2/src/google/protobuf/generated_message_util.h 2017-03-21 21:50
:11.659241456 -0700 | |
405 @@ -77,14 +77,14 @@ | |
406 | |
407 // Default empty string object. Don't use the pointer directly. Instead, call | |
408 // GetEmptyString() to get the reference. | |
409 -LIBPROTOBUF_EXPORT extern const ::std::string* empty_string_; | |
410 -LIBPROTOBUF_EXPORT extern ProtobufOnceType empty_string_once_init_; | |
411 +LIBPROTOBUF_EXPORT extern const ::std::string* cr_empty_string_; | |
412 +LIBPROTOBUF_EXPORT extern ProtobufOnceType cr_empty_string_once_init_; | |
413 LIBPROTOBUF_EXPORT void InitEmptyString(); | |
414 | |
415 | |
416 LIBPROTOBUF_EXPORT inline const ::std::string& GetEmptyStringAlreadyInited() { | |
417 - assert(empty_string_ != NULL); | |
418 - return *empty_string_; | |
419 + assert(cr_empty_string_ != NULL); | |
420 + return *cr_empty_string_; | |
421 } | |
422 | |
423 LIBPROTOBUF_EXPORT const ::std::string& GetEmptyString(); | |
424 diff -ru --new-file protobuf/src/google/protobuf/globals.cc protobuf2/src/google
/protobuf/globals.cc | |
425 --- protobuf/src/google/protobuf/globals.cc 1969-12-31 16:00:00.000000000 -0
800 | |
426 +++ protobuf2/src/google/protobuf/globals.cc 2017-03-21 21:50:11.659241456 -0
700 | |
427 @@ -0,0 +1,122 @@ | |
428 +// Protocol Buffers - Google's data interchange format | |
429 +// Copyright 2017 Google Inc. All rights reserved. | |
430 +// https://developers.google.com/protocol-buffers/ | |
431 +// | |
432 +// Redistribution and use in source and binary forms, with or without | |
433 +// modification, are permitted provided that the following conditions are | |
434 +// met: | |
435 +// | |
436 +// * Redistributions of source code must retain the above copyright | |
437 +// notice, this list of conditions and the following disclaimer. | |
438 +// * Redistributions in binary form must reproduce the above | |
439 +// copyright notice, this list of conditions and the following disclaimer | |
440 +// in the documentation and/or other materials provided with the | |
441 +// distribution. | |
442 +// * Neither the name of Google Inc. nor the names of its | |
443 +// contributors may be used to endorse or promote products derived from | |
444 +// this software without specific prior written permission. | |
445 +// | |
446 +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
447 +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
448 +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
449 +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
450 +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
451 +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
452 +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
453 +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
454 +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
455 +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
456 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
457 + | |
458 +#include <google/protobuf/arena.h> | |
459 +#include <google/protobuf/extension_set.h> | |
460 +#include <google/protobuf/generated_message_util.h> | |
461 +#include <google/protobuf/stubs/atomicops.h> | |
462 +#include <google/protobuf/stubs/hash.h> | |
463 + | |
464 +namespace google { | |
465 +namespace protobuf { | |
466 + | |
467 +#if !defined(GOOGLE_PROTOBUF_NO_THREADLOCAL) && defined(PROTOBUF_USE_DLLS) | |
468 +Arena::ThreadCache& Arena::cr_thread_cache() { | |
469 + static GOOGLE_THREAD_LOCAL ThreadCache cr_thread_cache_ = {-1, NULL}; | |
470 + return cr_thread_cache_; | |
471 +} | |
472 +#endif | |
473 + | |
474 +namespace internal { | |
475 + | |
476 +SequenceNumber cr_lifecycle_id_generator_; | |
477 + | |
478 +const ::std::string* cr_empty_string_; | |
479 +GOOGLE_PROTOBUF_DECLARE_ONCE(cr_empty_string_once_init_); | |
480 + | |
481 +const RepeatedField<int32>* | |
482 + RepeatedPrimitiveGenericTypeTraits::cr_default_repeated_field_int32_ = NULL
; | |
483 +const RepeatedField<int64>* | |
484 + RepeatedPrimitiveGenericTypeTraits::cr_default_repeated_field_int64_ = NULL
; | |
485 +const RepeatedField<uint32>* | |
486 + RepeatedPrimitiveGenericTypeTraits::cr_default_repeated_field_uint32_ = | |
487 + NULL; | |
488 +const RepeatedField<uint64>* | |
489 + RepeatedPrimitiveGenericTypeTraits::cr_default_repeated_field_uint64_ = | |
490 + NULL; | |
491 +const RepeatedField<double>* | |
492 + RepeatedPrimitiveGenericTypeTraits::cr_default_repeated_field_double_ = | |
493 + NULL; | |
494 +const RepeatedField<float>* | |
495 + RepeatedPrimitiveGenericTypeTraits::cr_default_repeated_field_float_ = NULL
; | |
496 +const RepeatedField<bool>* | |
497 + RepeatedPrimitiveGenericTypeTraits::cr_default_repeated_field_bool_ = NULL; | |
498 +const RepeatedStringTypeTraits::RepeatedFieldType* | |
499 + RepeatedStringTypeTraits::cr_default_repeated_field_ = NULL; | |
500 +const RepeatedMessageGenericTypeTraits::RepeatedFieldType* | |
501 + RepeatedMessageGenericTypeTraits::cr_default_repeated_field_ = NULL; | |
502 + | |
503 +LIBPROTOBUF_EXPORT vector<void (*)()>* cr_shutdown_functions = NULL; | |
504 +LIBPROTOBUF_EXPORT Mutex* cr_shutdown_functions_mutex = NULL; | |
505 +LIBPROTOBUF_EXPORT GOOGLE_PROTOBUF_DECLARE_ONCE(cr_shutdown_functions_init); | |
506 + | |
507 +LIBPROTOBUF_EXPORT LogHandler* cr_log_handler_ = NULL; | |
508 +LIBPROTOBUF_EXPORT int cr_log_silencer_count_ = 0; | |
509 + | |
510 +LIBPROTOBUF_EXPORT Mutex* cr_log_silencer_count_mutex_ = NULL; | |
511 +LIBPROTOBUF_EXPORT GOOGLE_PROTOBUF_DECLARE_ONCE(cr_log_silencer_count_init_); | |
512 + | |
513 +GOOGLE_PROTOBUF_DECLARE_ONCE( | |
514 + cr_repeated_primitive_generic_type_traits_once_init_); | |
515 +GOOGLE_PROTOBUF_DECLARE_ONCE(cr_repeated_string_type_traits_once_init_); | |
516 +GOOGLE_PROTOBUF_DECLARE_ONCE( | |
517 + cr_repeated_message_generic_type_traits_once_init_); | |
518 + | |
519 +LIBPROTOBUF_EXPORT hash_map<pair<const MessageLite*, int>, ExtensionInfo>* | |
520 + cr_registry_ = NULL; | |
521 +LIBPROTOBUF_EXPORT GOOGLE_PROTOBUF_DECLARE_ONCE(cr_registry_init_); | |
522 + | |
523 +LIBPROTOBUF_EXPORT bool cr_module_initialized_ = false; | |
524 +struct InitDetector { | |
525 + InitDetector() { cr_module_initialized_ = true; } | |
526 +}; | |
527 +InitDetector cr_init_detector; | |
528 + | |
529 +#ifdef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_GCC_H_ | |
530 +// Set the flags so that code will run correctly and conservatively, so even | |
531 +// if we haven't been initialized yet, we're probably single threaded, and our | |
532 +// default values should hopefully be pretty safe. | |
533 +LIBPROTOBUF_EXPORT struct AtomicOps_x86CPUFeatureStruct | |
534 + cr_AtomicOps_Internalx86CPUFeatures = { | |
535 + false, // bug can't exist before process spawns multiple threads | |
536 + false, // no SSE2 | |
537 +}; | |
538 + | |
539 +class AtomicOpsx86Initializer { | |
540 + public: | |
541 + AtomicOpsx86Initializer() { AtomicOps_Internalx86CPUFeaturesInit(); } | |
542 +}; | |
543 + | |
544 +AtomicOpsx86Initializer cr_g_initer; | |
545 +#endif | |
546 + | |
547 +} // namespace internal | |
548 +} // namespace protobuf | |
549 +} // namespace google | |
550 diff -ru --new-file protobuf/src/google/protobuf/io/coded_stream.cc protobuf2/sr
c/google/protobuf/io/coded_stream.cc | |
551 --- protobuf/src/google/protobuf/io/coded_stream.cc 2017-03-21 21:50:28.3992
55503 -0700 | |
552 +++ protobuf2/src/google/protobuf/io/coded_stream.cc 2017-03-21 21:50:11.6632
41460 -0700 | |
553 @@ -83,7 +83,7 @@ | |
554 } | |
555 | |
556 // Static. | |
557 -int CodedInputStream::default_recursion_limit_ = 100; | |
558 +int const CodedInputStream::default_recursion_limit_ = 100; | |
559 | |
560 | |
561 void CodedOutputStream::EnableAliasing(bool enabled) { | |
562 diff -ru --new-file protobuf/src/google/protobuf/io/coded_stream.h protobuf2/src
/google/protobuf/io/coded_stream.h | |
563 --- protobuf/src/google/protobuf/io/coded_stream.h 2017-03-21 21:50:28.3992
55503 -0700 | |
564 +++ protobuf2/src/google/protobuf/io/coded_stream.h 2017-03-21 21:50:11.6632
41460 -0700 | |
565 @@ -613,7 +613,7 @@ | |
566 | |
567 static const int kDefaultTotalBytesWarningThreshold = 32 << 20; // 32MB | |
568 | |
569 - static int default_recursion_limit_; // 100 by default. | |
570 + static const int default_recursion_limit_; // 100 by default. | |
571 }; | |
572 | |
573 // Class which encodes and writes binary data which is composed of varint- | |
574 diff -ru --new-file protobuf/src/google/protobuf/stubs/atomicops_internals_x86_g
cc.cc protobuf2/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc | |
575 --- protobuf/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc 2017-03-
21 21:50:28.399255503 -0700 | |
576 +++ protobuf2/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc 2017-03-
21 21:50:11.675241470 -0700 | |
577 @@ -58,23 +58,13 @@ | |
578 : "=a" (a), "=D" (b), "=c" (c), "=d" (d) : "a" (inp)) | |
579 #endif | |
580 | |
581 -#if defined(cpuid) // initialize the struct only on x86 | |
582 - | |
583 namespace google { | |
584 namespace protobuf { | |
585 namespace internal { | |
586 | |
587 -// Set the flags so that code will run correctly and conservatively, so even | |
588 -// if we haven't been initialized yet, we're probably single threaded, and our | |
589 -// default values should hopefully be pretty safe. | |
590 -struct AtomicOps_x86CPUFeatureStruct AtomicOps_Internalx86CPUFeatures = { | |
591 - false, // bug can't exist before process spawns multiple threads | |
592 - false, // no SSE2 | |
593 -}; | |
594 - | |
595 -namespace { | |
596 +#if defined(cpuid) // initialize the struct only on x86 | |
597 | |
598 -// Initialize the AtomicOps_Internalx86CPUFeatures struct. | |
599 +// Initialize the cr_AtomicOps_Internalx86CPUFeatures struct. | |
600 void AtomicOps_Internalx86CPUFeaturesInit() { | |
601 uint32_t eax; | |
602 uint32_t ebx; | |
603 @@ -107,31 +97,20 @@ | |
604 if (strcmp(vendor, "AuthenticAMD") == 0 && // AMD | |
605 family == 15 && | |
606 32 <= model && model <= 63) { | |
607 - AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug = true; | |
608 + cr_AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug = true; | |
609 } else { | |
610 - AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug = false; | |
611 + cr_AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug = false; | |
612 } | |
613 | |
614 // edx bit 26 is SSE2 which we use to tell use whether we can use mfence | |
615 - AtomicOps_Internalx86CPUFeatures.has_sse2 = ((edx >> 26) & 1); | |
616 + cr_AtomicOps_Internalx86CPUFeatures.has_sse2 = ((edx >> 26) & 1); | |
617 } | |
618 - | |
619 -class AtomicOpsx86Initializer { | |
620 - public: | |
621 - AtomicOpsx86Initializer() { | |
622 - AtomicOps_Internalx86CPUFeaturesInit(); | |
623 - } | |
624 -}; | |
625 - | |
626 -// A global to get use initialized on startup via static initialization :/ | |
627 -AtomicOpsx86Initializer g_initer; | |
628 - | |
629 -} // namespace | |
630 +#else | |
631 +void AtomicOps_Internalx86CPUFeaturesInit() {} | |
632 +#endif // __i386__ | |
633 | |
634 } // namespace internal | |
635 } // namespace protobuf | |
636 } // namespace google | |
637 | |
638 -#endif // __i386__ | |
639 - | |
640 #endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_GCC_H_ | |
641 diff -ru --new-file protobuf/src/google/protobuf/stubs/atomicops_internals_x86_g
cc.h protobuf2/src/google/protobuf/stubs/atomicops_internals_x86_gcc.h | |
642 --- protobuf/src/google/protobuf/stubs/atomicops_internals_x86_gcc.h 2017-03-
21 21:50:28.399255503 -0700 | |
643 +++ protobuf2/src/google/protobuf/stubs/atomicops_internals_x86_gcc.h 2017-03-
21 21:50:11.675241470 -0700 | |
644 @@ -46,7 +46,9 @@ | |
645 // after acquire compare-and-swap. | |
646 bool has_sse2; // Processor has SSE2. | |
647 }; | |
648 -extern struct AtomicOps_x86CPUFeatureStruct AtomicOps_Internalx86CPUFeatures; | |
649 +extern struct AtomicOps_x86CPUFeatureStruct cr_AtomicOps_Internalx86CPUFeatures
; | |
650 + | |
651 +void AtomicOps_Internalx86CPUFeaturesInit(); | |
652 | |
653 #define ATOMICOPS_COMPILER_BARRIER() __asm__ __volatile__("" : : : "memory") | |
654 | |
655 @@ -89,7 +91,7 @@ | |
656 : "+r" (temp), "+m" (*ptr) | |
657 : : "memory"); | |
658 // temp now holds the old value of *ptr | |
659 - if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) { | |
660 + if (cr_AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) { | |
661 __asm__ __volatile__("lfence" : : : "memory"); | |
662 } | |
663 return temp + increment; | |
664 @@ -99,7 +101,7 @@ | |
665 Atomic32 old_value, | |
666 Atomic32 new_value) { | |
667 Atomic32 x = NoBarrier_CompareAndSwap(ptr, old_value, new_value); | |
668 - if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) { | |
669 + if (cr_AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) { | |
670 __asm__ __volatile__("lfence" : : : "memory"); | |
671 } | |
672 return x; | |
673 @@ -131,7 +133,7 @@ | |
674 #else | |
675 | |
676 inline void MemoryBarrier() { | |
677 - if (AtomicOps_Internalx86CPUFeatures.has_sse2) { | |
678 + if (cr_AtomicOps_Internalx86CPUFeatures.has_sse2) { | |
679 __asm__ __volatile__("mfence" : : : "memory"); | |
680 } else { // mfence is faster but not present on PIII | |
681 Atomic32 x = 0; | |
682 @@ -140,7 +142,7 @@ | |
683 } | |
684 | |
685 inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) { | |
686 - if (AtomicOps_Internalx86CPUFeatures.has_sse2) { | |
687 + if (cr_AtomicOps_Internalx86CPUFeatures.has_sse2) { | |
688 *ptr = value; | |
689 __asm__ __volatile__("mfence" : : : "memory"); | |
690 } else { | |
691 @@ -213,7 +215,7 @@ | |
692 : "+r" (temp), "+m" (*ptr) | |
693 : : "memory"); | |
694 // temp now contains the previous value of *ptr | |
695 - if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) { | |
696 + if (cr_AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) { | |
697 __asm__ __volatile__("lfence" : : : "memory"); | |
698 } | |
699 return temp + increment; | |
700 @@ -270,7 +272,7 @@ | |
701 Atomic64 old_value, | |
702 Atomic64 new_value) { | |
703 Atomic64 x = NoBarrier_CompareAndSwap(ptr, old_value, new_value); | |
704 - if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) { | |
705 + if (cr_AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) { | |
706 __asm__ __volatile__("lfence" : : : "memory"); | |
707 } | |
708 return x; | |
709 diff -ru --new-file protobuf/src/google/protobuf/stubs/common.cc protobuf2/src/g
oogle/protobuf/stubs/common.cc | |
710 --- protobuf/src/google/protobuf/stubs/common.cc 2017-03-21 21:50:28.3992
55503 -0700 | |
711 +++ protobuf2/src/google/protobuf/stubs/common.cc 2017-03-21 21:50:11.6752
41470 -0700 | |
712 @@ -116,7 +116,8 @@ | |
713 if (level < GOOGLE_PROTOBUF_MIN_LOG_LEVEL) { | |
714 return; | |
715 } | |
716 - static const char* level_names[] = {"INFO", "WARNING", "ERROR", "FATAL"}; | |
717 + static const char* const level_names[] = {"INFO", "WARNING", "ERROR", | |
718 + "FATAL"}; | |
719 | |
720 static const int android_log_levels[] = { | |
721 ANDROID_LOG_INFO, // LOG(INFO), | |
722 @@ -148,7 +149,8 @@ | |
723 #else | |
724 void DefaultLogHandler(LogLevel level, const char* filename, int line, | |
725 const string& message) { | |
726 - static const char* level_names[] = { "INFO", "WARNING", "ERROR", "FATAL" }; | |
727 + static const char* const level_names[] = {"INFO", "WARNING", "ERROR", | |
728 + "FATAL"}; | |
729 | |
730 // We use fprintf() instead of cerr because we want this to work at static | |
731 // initialization time. | |
732 @@ -163,22 +165,22 @@ | |
733 // Nothing. | |
734 } | |
735 | |
736 -static LogHandler* log_handler_ = &DefaultLogHandler; | |
737 -static int log_silencer_count_ = 0; | |
738 +extern LogHandler* cr_log_handler_; | |
739 +extern int cr_log_silencer_count_; | |
740 | |
741 -static Mutex* log_silencer_count_mutex_ = NULL; | |
742 -GOOGLE_PROTOBUF_DECLARE_ONCE(log_silencer_count_init_); | |
743 +extern Mutex* cr_log_silencer_count_mutex_; | |
744 +extern ProtobufOnceType cr_log_silencer_count_init_; | |
745 | |
746 void DeleteLogSilencerCount() { | |
747 - delete log_silencer_count_mutex_; | |
748 - log_silencer_count_mutex_ = NULL; | |
749 + delete cr_log_silencer_count_mutex_; | |
750 + cr_log_silencer_count_mutex_ = NULL; | |
751 } | |
752 void InitLogSilencerCount() { | |
753 - log_silencer_count_mutex_ = new Mutex; | |
754 + cr_log_silencer_count_mutex_ = new Mutex; | |
755 OnShutdown(&DeleteLogSilencerCount); | |
756 } | |
757 void InitLogSilencerCountOnce() { | |
758 - GoogleOnceInit(&log_silencer_count_init_, &InitLogSilencerCount); | |
759 + GoogleOnceInit(&cr_log_silencer_count_init_, &InitLogSilencerCount); | |
760 } | |
761 | |
762 LogMessage& LogMessage::operator<<(const string& value) { | |
763 @@ -246,12 +248,13 @@ | |
764 | |
765 if (level_ != LOGLEVEL_FATAL) { | |
766 InitLogSilencerCountOnce(); | |
767 - MutexLock lock(log_silencer_count_mutex_); | |
768 - suppress = log_silencer_count_ > 0; | |
769 + MutexLock lock(cr_log_silencer_count_mutex_); | |
770 + suppress = cr_log_silencer_count_ > 0; | |
771 } | |
772 | |
773 if (!suppress) { | |
774 - log_handler_(level_, filename_, line_, message_); | |
775 + (cr_log_handler_ ? cr_log_handler_ : DefaultLogHandler)(level_, filename_, | |
776 + line_, message_); | |
777 } | |
778 | |
779 if (level_ == LOGLEVEL_FATAL) { | |
780 @@ -270,28 +273,29 @@ | |
781 } // namespace internal | |
782 | |
783 LogHandler* SetLogHandler(LogHandler* new_func) { | |
784 - LogHandler* old = internal::log_handler_; | |
785 + LogHandler* old = internal::cr_log_handler_ ? internal::cr_log_handler_ | |
786 + : internal::DefaultLogHandler; | |
787 if (old == &internal::NullLogHandler) { | |
788 old = NULL; | |
789 } | |
790 if (new_func == NULL) { | |
791 - internal::log_handler_ = &internal::NullLogHandler; | |
792 + internal::cr_log_handler_ = &internal::NullLogHandler; | |
793 } else { | |
794 - internal::log_handler_ = new_func; | |
795 + internal::cr_log_handler_ = new_func; | |
796 } | |
797 return old; | |
798 } | |
799 | |
800 LogSilencer::LogSilencer() { | |
801 internal::InitLogSilencerCountOnce(); | |
802 - MutexLock lock(internal::log_silencer_count_mutex_); | |
803 - ++internal::log_silencer_count_; | |
804 + MutexLock lock(internal::cr_log_silencer_count_mutex_); | |
805 + ++internal::cr_log_silencer_count_; | |
806 }; | |
807 | |
808 LogSilencer::~LogSilencer() { | |
809 internal::InitLogSilencerCountOnce(); | |
810 - MutexLock lock(internal::log_silencer_count_mutex_); | |
811 - --internal::log_silencer_count_; | |
812 + MutexLock lock(internal::cr_log_silencer_count_mutex_); | |
813 + --internal::cr_log_silencer_count_; | |
814 }; | |
815 | |
816 // =================================================================== | |
817 @@ -407,23 +411,23 @@ | |
818 namespace internal { | |
819 | |
820 typedef void OnShutdownFunc(); | |
821 -vector<void (*)()>* shutdown_functions = NULL; | |
822 -Mutex* shutdown_functions_mutex = NULL; | |
823 -GOOGLE_PROTOBUF_DECLARE_ONCE(shutdown_functions_init); | |
824 +extern vector<void (*)()>* cr_shutdown_functions; | |
825 +extern Mutex* cr_shutdown_functions_mutex; | |
826 +extern ProtobufOnceType cr_shutdown_functions_init; | |
827 | |
828 void InitShutdownFunctions() { | |
829 - shutdown_functions = new vector<void (*)()>; | |
830 - shutdown_functions_mutex = new Mutex; | |
831 + cr_shutdown_functions = new vector<void (*)()>; | |
832 + cr_shutdown_functions_mutex = new Mutex; | |
833 } | |
834 | |
835 inline void InitShutdownFunctionsOnce() { | |
836 - GoogleOnceInit(&shutdown_functions_init, &InitShutdownFunctions); | |
837 + GoogleOnceInit(&cr_shutdown_functions_init, &InitShutdownFunctions); | |
838 } | |
839 | |
840 void OnShutdown(void (*func)()) { | |
841 InitShutdownFunctionsOnce(); | |
842 - MutexLock lock(shutdown_functions_mutex); | |
843 - shutdown_functions->push_back(func); | |
844 + MutexLock lock(cr_shutdown_functions_mutex); | |
845 + cr_shutdown_functions->push_back(func); | |
846 } | |
847 | |
848 } // namespace internal | |
849 @@ -431,20 +435,20 @@ | |
850 void ShutdownProtobufLibrary() { | |
851 internal::InitShutdownFunctionsOnce(); | |
852 | |
853 - // We don't need to lock shutdown_functions_mutex because it's up to the | |
854 + // We don't need to lock cr_shutdown_functions_mutex because it's up to the | |
855 // caller to make sure that no one is using the library before this is | |
856 // called. | |
857 | |
858 // Make it safe to call this multiple times. | |
859 - if (internal::shutdown_functions == NULL) return; | |
860 + if (internal::cr_shutdown_functions == NULL) return; | |
861 | |
862 - for (int i = 0; i < internal::shutdown_functions->size(); i++) { | |
863 - internal::shutdown_functions->at(i)(); | |
864 + for (int i = 0; i < internal::cr_shutdown_functions->size(); i++) { | |
865 + internal::cr_shutdown_functions->at(i)(); | |
866 } | |
867 - delete internal::shutdown_functions; | |
868 - internal::shutdown_functions = NULL; | |
869 - delete internal::shutdown_functions_mutex; | |
870 - internal::shutdown_functions_mutex = NULL; | |
871 + delete internal::cr_shutdown_functions; | |
872 + internal::cr_shutdown_functions = NULL; | |
873 + delete internal::cr_shutdown_functions_mutex; | |
874 + internal::cr_shutdown_functions_mutex = NULL; | |
875 } | |
876 | |
877 #if PROTOBUF_USE_EXCEPTIONS | |
878 diff -ru --new-file protobuf/src/google/protobuf/stubs/structurally_valid.cc pro
tobuf2/src/google/protobuf/stubs/structurally_valid.cc | |
879 --- protobuf/src/google/protobuf/stubs/structurally_valid.cc 2017-03-21 21:50
:28.399255503 -0700 | |
880 +++ protobuf2/src/google/protobuf/stubs/structurally_valid.cc 2017-03-21 21:50
:11.679241474 -0700 | |
881 @@ -511,21 +511,10 @@ | |
882 // UTF-8 strings. Since UTF-8 validation is only used for debugging | |
883 // anyway, we simply always return success if initialization hasn't | |
884 // occurred yet. | |
885 -namespace { | |
886 - | |
887 -bool module_initialized_ = false; | |
888 - | |
889 -struct InitDetector { | |
890 - InitDetector() { | |
891 - module_initialized_ = true; | |
892 - } | |
893 -}; | |
894 -InitDetector init_detector; | |
895 - | |
896 -} // namespace | |
897 +extern bool cr_module_initialized_; | |
898 | |
899 bool IsStructurallyValidUTF8(const char* buf, int len) { | |
900 - if (!module_initialized_) return true; | |
901 + if (!cr_module_initialized_) return true; | |
902 | |
903 int bytes_consumed = 0; | |
904 UTF8GenericScanFastAscii(&utf8acceptnonsurrogates_obj, | |
905 @@ -534,7 +523,7 @@ | |
906 } | |
907 | |
908 int UTF8SpnStructurallyValid(const StringPiece& str) { | |
909 - if (!module_initialized_) return str.size(); | |
910 + if (!cr_module_initialized_) return str.size(); | |
911 | |
912 int bytes_consumed = 0; | |
913 UTF8GenericScanFastAscii(&utf8acceptnonsurrogates_obj, | |
914 diff -ru --new-file protobuf/src/google/protobuf/stubs/strutil.cc protobuf2/src/
google/protobuf/stubs/strutil.cc | |
915 --- protobuf/src/google/protobuf/stubs/strutil.cc 2017-03-21 21:50:28.3992
55503 -0700 | |
916 +++ protobuf2/src/google/protobuf/stubs/strutil.cc 2017-03-21 21:50:11.6752
41470 -0700 | |
917 @@ -528,7 +528,7 @@ | |
918 // Assumes that non-printable characters are escaped using octal sequences, and | |
919 // that UTF-8 bytes are not handled specially. | |
920 static inline size_t CEscapedLength(StringPiece src) { | |
921 - static char c_escaped_len[256] = { | |
922 + static const char c_escaped_len[256] = { | |
923 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 4, 4, 2, 4, 4, // \t, \n, \r | |
924 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, | |
925 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, // ", ' | |
926 @@ -891,7 +891,7 @@ | |
927 char *FastHexToBuffer(int i, char* buffer) { | |
928 GOOGLE_CHECK(i >= 0) << "FastHexToBuffer() wants non-negative integers, not "
<< i; | |
929 | |
930 - static const char *hexdigits = "0123456789abcdef"; | |
931 + static const char hexdigits[] = "0123456789abcdef"; | |
932 char *p = buffer + 21; | |
933 *p-- = '\0'; | |
934 do { | |
935 @@ -902,7 +902,7 @@ | |
936 } | |
937 | |
938 char *InternalFastHexToBuffer(uint64 value, char* buffer, int num_byte) { | |
939 - static const char *hexdigits = "0123456789abcdef"; | |
940 + static const char hexdigits[] = "0123456789abcdef"; | |
941 buffer[num_byte] = '\0'; | |
942 for (int i = num_byte - 1; i >= 0; i--) { | |
943 #ifdef _M_X64 | |
OLD | NEW |