Line data Source code
1 : // Protocol Buffers - Google's data interchange format
2 : // Copyright 2008 Google Inc. All rights reserved.
3 : // https://developers.google.com/protocol-buffers/
4 : //
5 : // Redistribution and use in source and binary forms, with or without
6 : // modification, are permitted provided that the following conditions are
7 : // met:
8 : //
9 : // * Redistributions of source code must retain the above copyright
10 : // notice, this list of conditions and the following disclaimer.
11 : // * Redistributions in binary form must reproduce the above
12 : // copyright notice, this list of conditions and the following disclaimer
13 : // in the documentation and/or other materials provided with the
14 : // distribution.
15 : // * Neither the name of Google Inc. nor the names of its
16 : // contributors may be used to endorse or promote products derived from
17 : // this software without specific prior written permission.
18 : //
19 : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 : // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 : // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 : // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 : // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 : // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 : // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 : // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 : // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 : // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 :
31 : #ifndef GOOGLE_PROTOBUF_STUBS_PORT_H_
32 : #define GOOGLE_PROTOBUF_STUBS_PORT_H_
33 :
34 : #include <assert.h>
35 : #include <stdlib.h>
36 : #include <cstddef>
37 : #include <string>
38 : #include <string.h>
39 : #if defined(__osf__)
40 : // Tru64 lacks stdint.h, but has inttypes.h which defines a superset of
41 : // what stdint.h would define.
42 : #include <inttypes.h>
43 : #elif !defined(_MSC_VER)
44 : #include <stdint.h>
45 : #endif
46 :
47 : #include <google/protobuf/stubs/platform_macros.h>
48 :
49 : #undef PROTOBUF_LITTLE_ENDIAN
50 : #ifdef _WIN32
51 : // Assuming windows is always little-endian.
52 : // TODO(xiaofeng): The PROTOBUF_LITTLE_ENDIAN is not only used for
53 : // optimization but also for correctness. We should define an
54 : // different macro to test the big-endian code path in coded_stream.
55 : #if !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST)
56 : #define PROTOBUF_LITTLE_ENDIAN 1
57 : #endif
58 : #if _MSC_VER >= 1300 && !defined(__INTEL_COMPILER)
59 : // If MSVC has "/RTCc" set, it will complain about truncating casts at
60 : // runtime. This file contains some intentional truncating casts.
61 : #pragma runtime_checks("c", off)
62 : #endif
63 : #else
64 : #include <sys/param.h> // __BYTE_ORDER
65 : #if defined(__OpenBSD__)
66 : #include <endian.h>
67 : #endif
68 : #if ((defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)) || \
69 : (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN) || \
70 : (defined(BYTE_ORDER) && BYTE_ORDER == LITTLE_ENDIAN)) && \
71 : !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST)
72 : #define PROTOBUF_LITTLE_ENDIAN 1
73 : #endif
74 : #endif
75 : #if defined(_MSC_VER) && defined(PROTOBUF_USE_DLLS)
76 : #ifdef LIBPROTOBUF_EXPORTS
77 : #define LIBPROTOBUF_EXPORT __declspec(dllexport)
78 : #else
79 : #define LIBPROTOBUF_EXPORT __declspec(dllimport)
80 : #endif
81 : #ifdef LIBPROTOC_EXPORTS
82 : #define LIBPROTOC_EXPORT __declspec(dllexport)
83 : #else
84 : #define LIBPROTOC_EXPORT __declspec(dllimport)
85 : #endif
86 : #else
87 : #define LIBPROTOBUF_EXPORT
88 : #define LIBPROTOC_EXPORT
89 : #endif
90 :
91 : // These #includes are for the byte swap functions declared later on.
92 : #ifdef _MSC_VER
93 : #include <stdlib.h> // NOLINT(build/include)
94 : #include <intrin.h>
95 : #elif defined(__APPLE__)
96 : #include <libkern/OSByteOrder.h>
97 : #elif defined(__GLIBC__) || defined(__BIONIC__) || defined(__CYGWIN__)
98 : #include <byteswap.h> // IWYU pragma: export
99 : #endif
100 :
101 : #define PROTOBUF_RUNTIME_DEPRECATED(message)
102 :
103 : // ===================================================================
104 : // from google3/base/port.h
105 :
106 : #if (defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L || \
107 : (defined(_MSC_VER) && _MSC_VER >= 1900))
108 : // Define this to 1 if the code is compiled in C++11 mode; leave it
109 : // undefined otherwise. Do NOT define it to 0 -- that causes
110 : // '#ifdef LANG_CXX11' to behave differently from '#if LANG_CXX11'.
111 : #define LANG_CXX11 1
112 : #endif
113 :
114 : #if LANG_CXX11 && !defined(__NVCC__)
115 : #define PROTOBUF_CXX11 1
116 : #else
117 : #define PROTOBUF_CXX11 0
118 : #endif
119 :
120 : #if PROTOBUF_CXX11
121 : #define PROTOBUF_FINAL final
122 : #else
123 : #define PROTOBUF_FINAL
124 : #endif
125 :
126 : namespace google {
127 : namespace protobuf {
128 :
129 : typedef unsigned int uint;
130 :
131 : #ifdef _MSC_VER
132 : typedef signed __int8 int8;
133 : typedef __int16 int16;
134 : typedef __int32 int32;
135 : typedef __int64 int64;
136 :
137 : typedef unsigned __int8 uint8;
138 : typedef unsigned __int16 uint16;
139 : typedef unsigned __int32 uint32;
140 : typedef unsigned __int64 uint64;
141 : #else
142 : typedef int8_t int8;
143 : typedef int16_t int16;
144 : typedef int32_t int32;
145 : typedef int64_t int64;
146 :
147 : typedef uint8_t uint8;
148 : typedef uint16_t uint16;
149 : typedef uint32_t uint32;
150 : typedef uint64_t uint64;
151 : #endif
152 :
153 : // long long macros to be used because gcc and vc++ use different suffixes,
154 : // and different size specifiers in format strings
155 : #undef GOOGLE_LONGLONG
156 : #undef GOOGLE_ULONGLONG
157 : #undef GOOGLE_LL_FORMAT
158 :
159 : #ifdef _MSC_VER
160 : #define GOOGLE_LONGLONG(x) x##I64
161 : #define GOOGLE_ULONGLONG(x) x##UI64
162 : #define GOOGLE_LL_FORMAT "I64" // As in printf("%I64d", ...)
163 : #else
164 : // By long long, we actually mean int64.
165 : #define GOOGLE_LONGLONG(x) x##LL
166 : #define GOOGLE_ULONGLONG(x) x##ULL
167 : // Used to format real long long integers.
168 : #define GOOGLE_LL_FORMAT "ll" // As in "%lld". Note that "q" is poor form also.
169 : #endif
170 :
171 : static const int32 kint32max = 0x7FFFFFFF;
172 : static const int32 kint32min = -kint32max - 1;
173 : static const int64 kint64max = GOOGLE_LONGLONG(0x7FFFFFFFFFFFFFFF);
174 : static const int64 kint64min = -kint64max - 1;
175 : static const uint32 kuint32max = 0xFFFFFFFFu;
176 : static const uint64 kuint64max = GOOGLE_ULONGLONG(0xFFFFFFFFFFFFFFFF);
177 :
178 : // -------------------------------------------------------------------
179 : // Annotations: Some parts of the code have been annotated in ways that might
180 : // be useful to some compilers or tools, but are not supported universally.
181 : // You can #define these annotations yourself if the default implementation
182 : // is not right for you.
183 :
184 : #ifndef GOOGLE_ATTRIBUTE_ALWAYS_INLINE
185 : #if defined(__GNUC__) && (__GNUC__ > 3 ||(__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
186 : // For functions we want to force inline.
187 : // Introduced in gcc 3.1.
188 : #define GOOGLE_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((always_inline))
189 : #else
190 : // Other compilers will have to figure it out for themselves.
191 : #define GOOGLE_ATTRIBUTE_ALWAYS_INLINE
192 : #endif
193 : #endif
194 :
195 : #define GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE GOOGLE_ATTRIBUTE_ALWAYS_INLINE
196 :
197 : #ifndef GOOGLE_ATTRIBUTE_NOINLINE
198 : #if defined(__GNUC__) && (__GNUC__ > 3 ||(__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
199 : // For functions we want to force not inline.
200 : // Introduced in gcc 3.1.
201 : #define GOOGLE_ATTRIBUTE_NOINLINE __attribute__ ((noinline))
202 : #elif defined(_MSC_VER) && (_MSC_VER >= 1400)
203 : // Seems to have been around since at least Visual Studio 2005
204 : #define GOOGLE_ATTRIBUTE_NOINLINE __declspec(noinline)
205 : #else
206 : // Other compilers will have to figure it out for themselves.
207 : #define GOOGLE_ATTRIBUTE_NOINLINE
208 : #endif
209 : #endif
210 :
211 : #define GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE GOOGLE_ATTRIBUTE_NOINLINE
212 :
213 : #ifndef GOOGLE_ATTRIBUTE_FUNC_ALIGN
214 : #if defined(__clang__) || \
215 : defined(__GNUC__) && (__GNUC__ > 4 ||(__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
216 : // Function alignment attribute introduced in gcc 4.3
217 : #define GOOGLE_ATTRIBUTE_FUNC_ALIGN(bytes) __attribute__ ((aligned(bytes)))
218 : #else
219 : #define GOOGLE_ATTRIBUTE_FUNC_ALIGN(bytes)
220 : #endif
221 : #endif
222 :
223 : #define GOOGLE_PROTOBUF_ATTRIBUTE_FUNC_ALIGN(bytes) \
224 : GOOGLE_ATTRIBUTE_FUNC_ALIGN(bytes)
225 :
226 : #ifndef GOOGLE_PREDICT_TRUE
227 : #ifdef __GNUC__
228 : // Provided at least since GCC 3.0.
229 : #define GOOGLE_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))
230 : #else
231 : #define GOOGLE_PREDICT_TRUE(x) (x)
232 : #endif
233 : #endif
234 :
235 : #ifndef GOOGLE_PREDICT_FALSE
236 : #ifdef __GNUC__
237 : // Provided at least since GCC 3.0.
238 : #define GOOGLE_PREDICT_FALSE(x) (__builtin_expect(x, 0))
239 : #else
240 : #define GOOGLE_PREDICT_FALSE(x) (x)
241 : #endif
242 : #endif
243 :
244 : #ifndef GOOGLE_PROTOBUF_ATTRIBUTE_RETURNS_NONNULL
245 : #ifdef __GNUC__
246 : #define GOOGLE_PROTOBUF_ATTRIBUTE_RETURNS_NONNULL \
247 : __attribute__((returns_nonnull))
248 : #endif
249 : #endif
250 :
251 : // Delimits a block of code which may write to memory which is simultaneously
252 : // written by other threads, but which has been determined to be thread-safe
253 : // (e.g. because it is an idempotent write).
254 : #ifndef GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN
255 : #define GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN()
256 : #endif
257 : #ifndef GOOGLE_SAFE_CONCURRENT_WRITES_END
258 : #define GOOGLE_SAFE_CONCURRENT_WRITES_END()
259 : #endif
260 :
261 : #define GOOGLE_GUARDED_BY(x)
262 : #define GOOGLE_ATTRIBUTE_COLD
263 :
264 : #ifdef GOOGLE_PROTOBUF_DONT_USE_UNALIGNED
265 : # define GOOGLE_PROTOBUF_USE_UNALIGNED 0
266 : #else
267 : # if defined(_M_X64) || defined(__x86_64__) || defined(_M_IX86) || defined(__i386__)
268 : # define GOOGLE_PROTOBUF_USE_UNALIGNED 1
269 : # else
270 : # define GOOGLE_PROTOBUF_USE_UNALIGNED 0
271 : # endif
272 : #endif
273 :
274 : #define GOOGLE_PROTOBUF_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_COLD
275 :
276 : #if defined(ADDRESS_SANITIZER) || defined(THREAD_SANITIZER) ||\
277 : defined(MEMORY_SANITIZER)
278 :
279 : #ifdef __cplusplus
280 : extern "C" {
281 : #endif // __cplusplus
282 : uint16_t __sanitizer_unaligned_load16(const void *p);
283 : uint32_t __sanitizer_unaligned_load32(const void *p);
284 : uint64_t __sanitizer_unaligned_load64(const void *p);
285 : void __sanitizer_unaligned_store16(void *p, uint16_t v);
286 : void __sanitizer_unaligned_store32(void *p, uint32_t v);
287 : void __sanitizer_unaligned_store64(void *p, uint64_t v);
288 : #ifdef __cplusplus
289 : } // extern "C"
290 : #endif // __cplusplus
291 :
292 : inline uint16 GOOGLE_UNALIGNED_LOAD16(const void *p) {
293 : return __sanitizer_unaligned_load16(p);
294 : }
295 :
296 : inline uint32 GOOGLE_UNALIGNED_LOAD32(const void *p) {
297 : return __sanitizer_unaligned_load32(p);
298 : }
299 :
300 : inline uint64 GOOGLE_UNALIGNED_LOAD64(const void *p) {
301 : return __sanitizer_unaligned_load64(p);
302 : }
303 :
304 : inline void GOOGLE_UNALIGNED_STORE16(void *p, uint16 v) {
305 : __sanitizer_unaligned_store16(p, v);
306 : }
307 :
308 : inline void GOOGLE_UNALIGNED_STORE32(void *p, uint32 v) {
309 : __sanitizer_unaligned_store32(p, v);
310 : }
311 :
312 : inline void GOOGLE_UNALIGNED_STORE64(void *p, uint64 v) {
313 : __sanitizer_unaligned_store64(p, v);
314 : }
315 :
316 : #elif GOOGLE_PROTOBUF_USE_UNALIGNED
317 :
318 : #define GOOGLE_UNALIGNED_LOAD16(_p) (*reinterpret_cast<const uint16 *>(_p))
319 : #define GOOGLE_UNALIGNED_LOAD32(_p) (*reinterpret_cast<const uint32 *>(_p))
320 : #define GOOGLE_UNALIGNED_LOAD64(_p) (*reinterpret_cast<const uint64 *>(_p))
321 :
322 : #define GOOGLE_UNALIGNED_STORE16(_p, _val) (*reinterpret_cast<uint16 *>(_p) = (_val))
323 : #define GOOGLE_UNALIGNED_STORE32(_p, _val) (*reinterpret_cast<uint32 *>(_p) = (_val))
324 : #define GOOGLE_UNALIGNED_STORE64(_p, _val) (*reinterpret_cast<uint64 *>(_p) = (_val))
325 :
326 : #else
327 : inline uint16 GOOGLE_UNALIGNED_LOAD16(const void *p) {
328 : uint16 t;
329 : memcpy(&t, p, sizeof t);
330 : return t;
331 : }
332 :
333 : inline uint32 GOOGLE_UNALIGNED_LOAD32(const void *p) {
334 : uint32 t;
335 : memcpy(&t, p, sizeof t);
336 : return t;
337 : }
338 :
339 : inline uint64 GOOGLE_UNALIGNED_LOAD64(const void *p) {
340 : uint64 t;
341 : memcpy(&t, p, sizeof t);
342 : return t;
343 : }
344 :
345 : inline void GOOGLE_UNALIGNED_STORE16(void *p, uint16 v) {
346 : memcpy(p, &v, sizeof v);
347 : }
348 :
349 : inline void GOOGLE_UNALIGNED_STORE32(void *p, uint32 v) {
350 : memcpy(p, &v, sizeof v);
351 : }
352 :
353 : inline void GOOGLE_UNALIGNED_STORE64(void *p, uint64 v) {
354 : memcpy(p, &v, sizeof v);
355 : }
356 : #endif
357 :
358 : #if defined(GOOGLE_PROTOBUF_OS_NACL) \
359 : || (defined(__ANDROID__) && defined(__clang__) \
360 : && (__clang_major__ == 3 && __clang_minor__ == 8) \
361 : && (__clang_patchlevel__ < 275480))
362 : # define GOOGLE_PROTOBUF_USE_PORTABLE_LOG2
363 : #endif
364 :
365 : #if defined(_MSC_VER)
366 : #define GOOGLE_THREAD_LOCAL __declspec(thread)
367 : #else
368 : #define GOOGLE_THREAD_LOCAL __thread
369 : #endif
370 :
371 : // The following guarantees declaration of the byte swap functions.
372 : #ifdef _MSC_VER
373 : #define bswap_16(x) _byteswap_ushort(x)
374 : #define bswap_32(x) _byteswap_ulong(x)
375 : #define bswap_64(x) _byteswap_uint64(x)
376 :
377 : #elif defined(__APPLE__)
378 : // Mac OS X / Darwin features
379 : #define bswap_16(x) OSSwapInt16(x)
380 : #define bswap_32(x) OSSwapInt32(x)
381 : #define bswap_64(x) OSSwapInt64(x)
382 :
383 : #elif !defined(__GLIBC__) && !defined(__BIONIC__) && !defined(__CYGWIN__)
384 :
385 : static inline uint16 bswap_16(uint16 x) {
386 : return static_cast<uint16>(((x & 0xFF) << 8) | ((x & 0xFF00) >> 8));
387 : }
388 : #define bswap_16(x) bswap_16(x)
389 : static inline uint32 bswap_32(uint32 x) {
390 : return (((x & 0xFF) << 24) |
391 : ((x & 0xFF00) << 8) |
392 : ((x & 0xFF0000) >> 8) |
393 : ((x & 0xFF000000) >> 24));
394 : }
395 : #define bswap_32(x) bswap_32(x)
396 : static inline uint64 bswap_64(uint64 x) {
397 : return (((x & GOOGLE_ULONGLONG(0xFF)) << 56) |
398 : ((x & GOOGLE_ULONGLONG(0xFF00)) << 40) |
399 : ((x & GOOGLE_ULONGLONG(0xFF0000)) << 24) |
400 : ((x & GOOGLE_ULONGLONG(0xFF000000)) << 8) |
401 : ((x & GOOGLE_ULONGLONG(0xFF00000000)) >> 8) |
402 : ((x & GOOGLE_ULONGLONG(0xFF0000000000)) >> 24) |
403 : ((x & GOOGLE_ULONGLONG(0xFF000000000000)) >> 40) |
404 : ((x & GOOGLE_ULONGLONG(0xFF00000000000000)) >> 56));
405 : }
406 : #define bswap_64(x) bswap_64(x)
407 :
408 : #endif
409 :
410 : // ===================================================================
411 : // from google3/util/bits/bits.h
412 :
413 : class Bits {
414 : public:
415 0 : static uint32 Log2FloorNonZero(uint32 n) {
416 : #if defined(__GNUC__)
417 0 : return 31 ^ static_cast<uint32>(__builtin_clz(n));
418 : #elif defined(_MSC_VER)
419 : unsigned long where;
420 : _BitScanReverse(&where, n);
421 : return where;
422 : #else
423 : return Log2FloorNonZero_Portable(n);
424 : #endif
425 : }
426 :
427 : static uint32 Log2FloorNonZero64(uint64 n) {
428 : // Older versions of clang run into an instruction-selection failure when
429 : // it encounters __builtin_clzll:
430 : // https://bugs.chromium.org/p/nativeclient/issues/detail?id=4395
431 : // This includes arm-nacl-clang and clang in older Android NDK versions.
432 : // To work around this, when we build with those we use the portable
433 : // implementation instead.
434 : #if defined(__GNUC__) && !defined(GOOGLE_PROTOBUF_USE_PORTABLE_LOG2)
435 : return 63 ^ static_cast<uint32>(__builtin_clzll(n));
436 : #elif defined(_MSC_VER) && defined(_M_X64)
437 : unsigned long where;
438 : _BitScanReverse64(&where, n);
439 : return where;
440 : #else
441 : return Log2FloorNonZero64_Portable(n);
442 : #endif
443 : }
444 : private:
445 : static int Log2FloorNonZero_Portable(uint32 n) {
446 : if (n == 0)
447 : return -1;
448 : int log = 0;
449 : uint32 value = n;
450 : for (int i = 4; i >= 0; --i) {
451 : int shift = (1 << i);
452 : uint32 x = value >> shift;
453 : if (x != 0) {
454 : value = x;
455 : log += shift;
456 : }
457 : }
458 : assert(value == 1);
459 : return log;
460 : }
461 :
462 : static int Log2FloorNonZero64_Portable(uint64 n) {
463 : const uint32 topbits = static_cast<uint32>(n >> 32);
464 : if (topbits == 0) {
465 : // Top bits are zero, so scan in bottom bits
466 : return static_cast<int>(Log2FloorNonZero(static_cast<uint32>(n)));
467 : } else {
468 : return 32 + static_cast<int>(Log2FloorNonZero(topbits));
469 : }
470 : }
471 : };
472 :
473 : // ===================================================================
474 : // from google3/util/endian/endian.h
475 : LIBPROTOBUF_EXPORT uint32 ghtonl(uint32 x);
476 :
477 : class BigEndian {
478 : public:
479 : #ifdef PROTOBUF_LITTLE_ENDIAN
480 :
481 : static uint16 FromHost16(uint16 x) { return bswap_16(x); }
482 : static uint16 ToHost16(uint16 x) { return bswap_16(x); }
483 :
484 : static uint32 FromHost32(uint32 x) { return bswap_32(x); }
485 : static uint32 ToHost32(uint32 x) { return bswap_32(x); }
486 :
487 : static uint64 FromHost64(uint64 x) { return bswap_64(x); }
488 : static uint64 ToHost64(uint64 x) { return bswap_64(x); }
489 :
490 : static bool IsLittleEndian() { return true; }
491 :
492 : #else
493 :
494 : static uint16 FromHost16(uint16 x) { return x; }
495 : static uint16 ToHost16(uint16 x) { return x; }
496 :
497 : static uint32 FromHost32(uint32 x) { return x; }
498 : static uint32 ToHost32(uint32 x) { return x; }
499 :
500 : static uint64 FromHost64(uint64 x) { return x; }
501 : static uint64 ToHost64(uint64 x) { return x; }
502 :
503 : static bool IsLittleEndian() { return false; }
504 :
505 : #endif /* ENDIAN */
506 :
507 : // Functions to do unaligned loads and stores in big-endian order.
508 : static uint16 Load16(const void *p) {
509 : return ToHost16(GOOGLE_UNALIGNED_LOAD16(p));
510 : }
511 :
512 : static void Store16(void *p, uint16 v) {
513 : GOOGLE_UNALIGNED_STORE16(p, FromHost16(v));
514 : }
515 :
516 : static uint32 Load32(const void *p) {
517 : return ToHost32(GOOGLE_UNALIGNED_LOAD32(p));
518 : }
519 :
520 : static void Store32(void *p, uint32 v) {
521 : GOOGLE_UNALIGNED_STORE32(p, FromHost32(v));
522 : }
523 :
524 : static uint64 Load64(const void *p) {
525 : return ToHost64(GOOGLE_UNALIGNED_LOAD64(p));
526 : }
527 :
528 : static void Store64(void *p, uint64 v) {
529 : GOOGLE_UNALIGNED_STORE64(p, FromHost64(v));
530 : }
531 : };
532 :
533 : #ifndef GOOGLE_ATTRIBUTE_SECTION_VARIABLE
534 : #define GOOGLE_ATTRIBUTE_SECTION_VARIABLE(name)
535 : #endif
536 :
537 : #define GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(name)
538 :
539 : } // namespace protobuf
540 : } // namespace google
541 :
542 : #endif // GOOGLE_PROTOBUF_STUBS_PORT_H_
|