about summary refs log tree commit diff
path: root/absl
diff options
context:
space:
mode:
authorMatt Calabrese <38107210+mattcalabrese-google@users.noreply.github.com>2018-10-30T15·03-0400
committerGitHub <noreply@github.com>2018-10-30T15·03-0400
commit01174578651b73021d9b8c3820f6fea707dacdf0 (patch)
tree05540d23e508e83f3f4d1f77cf98cf4fd366d01e /absl
parentf86f9413856b65afdd61fea938d684b8ab73115a (diff)
parent297e77fb9092d813fd63a7ba7689869d0a33ee6a (diff)
Merge pull request #201 from ccawley2011/fix-byteswap
Fix compilation of generic byteswap routines
Diffstat (limited to 'absl')
-rw-r--r--absl/base/internal/endian.h25
1 files changed, 14 insertions, 11 deletions
diff --git a/absl/base/internal/endian.h b/absl/base/internal/endian.h
index edc10f10a5aa..d5dc51adb56a 100644
--- a/absl/base/internal/endian.h
+++ b/absl/base/internal/endian.h
@@ -82,14 +82,14 @@ inline uint64_t gbswap_64(uint64_t host_int) {
 #elif defined(__GLIBC__)
   return bswap_64(host_int);
 #else
-  return (((x & uint64_t{(0xFF}) << 56) |
-          ((x & uint64_t{(0xFF00}) << 40) |
-          ((x & uint64_t{(0xFF0000}) << 24) |
-          ((x & uint64_t{(0xFF000000}) << 8) |
-          ((x & uint64_t{(0xFF00000000}) >> 8) |
-          ((x & uint64_t{(0xFF0000000000}) >> 24) |
-          ((x & uint64_t{(0xFF000000000000}) >> 40) |
-          ((x & uint64_t{(0xFF00000000000000}) >> 56));
+  return (((host_int & uint64_t{0xFF}) << 56) |
+          ((host_int & uint64_t{0xFF00}) << 40) |
+          ((host_int & uint64_t{0xFF0000}) << 24) |
+          ((host_int & uint64_t{0xFF000000}) << 8) |
+          ((host_int & uint64_t{0xFF00000000}) >> 8) |
+          ((host_int & uint64_t{0xFF0000000000}) >> 24) |
+          ((host_int & uint64_t{0xFF000000000000}) >> 40) |
+          ((host_int & uint64_t{0xFF00000000000000}) >> 56));
 #endif  // bswap_64
 }
 
@@ -97,8 +97,10 @@ inline uint32_t gbswap_32(uint32_t host_int) {
 #if defined(__GLIBC__)
   return bswap_32(host_int);
 #else
-  return (((x & 0xFF) << 24) | ((x & 0xFF00) << 8) | ((x & 0xFF0000) >> 8) |
-          ((x & 0xFF000000) >> 24));
+  return (((host_int & uint32_t{0xFF}) << 24) |
+          ((host_int & uint32_t{0xFF00}) << 8) |
+          ((host_int & uint32_t{0xFF0000}) >> 8) |
+          ((host_int & uint32_t{0xFF000000}) >> 24));
 #endif
 }
 
@@ -106,7 +108,8 @@ inline uint16_t gbswap_16(uint16_t host_int) {
 #if defined(__GLIBC__)
   return bswap_16(host_int);
 #else
-  return uint16_t{((x & 0xFF) << 8) | ((x & 0xFF00) >> 8)};
+  return (((host_int & uint16_t{0xFF}) << 8) |
+          ((host_int & uint16_t{0xFF00}) >> 8));
 #endif
 }