MathExtras.h (208954) | MathExtras.h (212904) |
---|---|
1//===-- llvm/Support/MathExtras.h - Useful math functions -------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 112 unchanged lines hidden (view full) --- 121 uint16_t Lo = Value >> 8; 122 return Hi | Lo; 123#endif 124} 125 126/// ByteSwap_32 - This function returns a byte-swapped representation of the 127/// 32-bit argument, Value. 128inline uint32_t ByteSwap_32(uint32_t Value) { | 1//===-- llvm/Support/MathExtras.h - Useful math functions -------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 112 unchanged lines hidden (view full) --- 121 uint16_t Lo = Value >> 8; 122 return Hi | Lo; 123#endif 124} 125 126/// ByteSwap_32 - This function returns a byte-swapped representation of the 127/// 32-bit argument, Value. 128inline uint32_t ByteSwap_32(uint32_t Value) { |
129#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) && !defined(__ICC) | 129#if defined(__llvm__) || \ 130 (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) && !defined(__ICC) |
130 return __builtin_bswap32(Value); 131#elif defined(_MSC_VER) && !defined(_DEBUG) 132 return _byteswap_ulong(Value); 133#else 134 uint32_t Byte0 = Value & 0x000000FF; 135 uint32_t Byte1 = Value & 0x0000FF00; 136 uint32_t Byte2 = Value & 0x00FF0000; 137 uint32_t Byte3 = Value & 0xFF000000; 138 return (Byte0 << 24) | (Byte1 << 8) | (Byte2 >> 8) | (Byte3 >> 24); 139#endif 140} 141 142/// ByteSwap_64 - This function returns a byte-swapped representation of the 143/// 64-bit argument, Value. 144inline uint64_t ByteSwap_64(uint64_t Value) { | 131 return __builtin_bswap32(Value); 132#elif defined(_MSC_VER) && !defined(_DEBUG) 133 return _byteswap_ulong(Value); 134#else 135 uint32_t Byte0 = Value & 0x000000FF; 136 uint32_t Byte1 = Value & 0x0000FF00; 137 uint32_t Byte2 = Value & 0x00FF0000; 138 uint32_t Byte3 = Value & 0xFF000000; 139 return (Byte0 << 24) | (Byte1 << 8) | (Byte2 >> 8) | (Byte3 >> 24); 140#endif 141} 142 143/// ByteSwap_64 - This function returns a byte-swapped representation of the 144/// 64-bit argument, Value. 145inline uint64_t ByteSwap_64(uint64_t Value) { |
145#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) && !defined(__ICC) | 146#if defined(__llvm__) || \ 147 (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) && !defined(__ICC) |
146 return __builtin_bswap64(Value); 147#elif defined(_MSC_VER) && !defined(_DEBUG) 148 return _byteswap_uint64(Value); 149#else 150 uint64_t Hi = ByteSwap_32(uint32_t(Value)); 151 uint32_t Lo = ByteSwap_32(uint32_t(Value >> 32)); 152 return (Hi << 32) | Lo; 153#endif --- 321 unchanged lines hidden --- | 148 return __builtin_bswap64(Value); 149#elif defined(_MSC_VER) && !defined(_DEBUG) 150 return _byteswap_uint64(Value); 151#else 152 uint64_t Hi = ByteSwap_32(uint32_t(Value)); 153 uint32_t Lo = ByteSwap_32(uint32_t(Value >> 32)); 154 return (Hi << 32) | Lo; 155#endif --- 321 unchanged lines hidden --- |