Chromium Code Reviews| Index: base/sys_byteorder.h |
| diff --git a/base/sys_byteorder.h b/base/sys_byteorder.h |
| index 8d9066c70228bfd7c36ec0cb3a2afe30dc006a2d..d35cbd7fd01332d371deb2009d4ae18a56de28a5 100644 |
| --- a/base/sys_byteorder.h |
| +++ b/base/sys_byteorder.h |
| @@ -46,6 +46,16 @@ inline uint64_t ByteSwap(uint64_t x) { |
| #endif |
| } |
| +inline uintptr_t ByteSwapUintPtrT(uintptr_t x) { |
| +#if defined(ARCH_CPU_64_BITS) |
| + return ByteSwap(static_cast<uint64_t>(x)); |
|
danakj
2016/12/09 04:52:05
can you throw some static_asserts comparing sizeof
|
| +#elif defined(ARCH_CPU_32_BITS) |
| + return ByteSwap(static_cast<uint32_t>(x)); |
| +#else |
| +#error architecture not supported |
| +#endif |
| +} |
| + |
| // Converts the bytes in |x| from host order (endianness) to little endian, and |
| // returns the result. |
| inline uint16_t ByteSwapToLE16(uint16_t x) { |