diff options
author | Adam Cozzette <acozzette@gmail.com> | 2018-06-25 13:51:42 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-25 13:51:42 -0700 |
commit | d9ccd0c0e6bbda9bf4476088eeb46b02d7dcd327 (patch) | |
tree | af61da1c6ed2652f66b925451ea4084706329fb4 /src | |
parent | 35567c166842cca3ff6af3226ff526f25c79507f (diff) | |
parent | 609f43ce12bbe2cb7e8f0114eaccd6252204d39d (diff) |
Merge pull request #4172 from OskarKinomoto/master
Add guards against bswap_XX redefnitions
Diffstat (limited to 'src')
-rw-r--r-- | src/google/protobuf/stubs/port.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h index 6b52305f..3aa6403b 100644 --- a/src/google/protobuf/stubs/port.h +++ b/src/google/protobuf/stubs/port.h @@ -382,10 +382,14 @@ inline void GOOGLE_UNALIGNED_STORE64(void *p, uint64 v) { #elif !defined(__GLIBC__) && !defined(__BIONIC__) && !defined(__CYGWIN__) +#ifndef bswap_16 static inline uint16 bswap_16(uint16 x) { return static_cast<uint16>(((x & 0xFF) << 8) | ((x & 0xFF00) >> 8)); } #define bswap_16(x) bswap_16(x) +#endif + +#ifndef bswap_32 static inline uint32 bswap_32(uint32 x) { return (((x & 0xFF) << 24) | ((x & 0xFF00) << 8) | @@ -393,6 +397,9 @@ static inline uint32 bswap_32(uint32 x) { ((x & 0xFF000000) >> 24)); } #define bswap_32(x) bswap_32(x) +#endif + +#ifndef bswap_64 static inline uint64 bswap_64(uint64 x) { return (((x & GOOGLE_ULONGLONG(0xFF)) << 56) | ((x & GOOGLE_ULONGLONG(0xFF00)) << 40) | @@ -404,6 +411,7 @@ static inline uint64 bswap_64(uint64 x) { ((x & GOOGLE_ULONGLONG(0xFF00000000000000)) >> 56)); } #define bswap_64(x) bswap_64(x) +#endif #endif |