From 609f43ce12bbe2cb7e8f0114eaccd6252204d39d Mon Sep 17 00:00:00 2001 From: Oskar Świtalski Date: Mon, 15 Jan 2018 11:06:23 +0100 Subject: Add guards against bswap_XX redefnitions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Oskar Świtalski --- src/google/protobuf/stubs/port.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h index 30bd7b1d..ebbf7da6 100644 --- a/src/google/protobuf/stubs/port.h +++ b/src/google/protobuf/stubs/port.h @@ -375,10 +375,14 @@ inline void GOOGLE_UNALIGNED_STORE64(void *p, uint64 v) { #elif !defined(__GLIBC__) && !defined(__CYGWIN__) +#ifndef bswap_16 static inline uint16 bswap_16(uint16 x) { return static_cast(((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) | @@ -386,6 +390,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) | @@ -397,6 +404,7 @@ static inline uint64 bswap_64(uint64 x) { ((x & GOOGLE_ULONGLONG(0xFF00000000000000)) >> 56)); } #define bswap_64(x) bswap_64(x) +#endif #endif -- cgit v1.2.3