| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_BASE_BITS_H_ | 5 #ifndef V8_BASE_BITS_H_ |
| 6 #define V8_BASE_BITS_H_ | 6 #define V8_BASE_BITS_H_ |
| 7 | 7 |
| 8 #include "include/v8stdint.h" | 8 #include "include/v8stdint.h" |
| 9 #if V8_OS_WIN32 | 9 #if V8_OS_WIN32 |
| 10 #include "src/base/win32-headers.h" | 10 #include "src/base/win32-headers.h" |
| 11 #endif | 11 #endif |
| 12 | 12 |
| 13 namespace v8 { | 13 namespace v8 { |
| 14 namespace base { | 14 namespace base { |
| 15 namespace bits { | 15 namespace bits { |
| 16 | 16 |
| 17 #if V8_CC_MSVC | |
| 18 | |
| 19 #pragma intrinsic(_rotr) | |
| 20 #pragma intrinsic(_rotr64) | |
| 21 | |
| 22 inline uint32_t RotateRight32(uint32_t value, uint32_t shift) { | |
| 23 return _rotr(value, shift); | |
| 24 } | |
| 25 | |
| 26 | |
| 27 inline uint64_t RotateRight64(uint64_t value, uint32_t shift) { | |
| 28 return _rotr64(value, shift); | |
| 29 } | |
| 30 | |
| 31 #else // V8_CC_MSVC | |
| 32 | |
| 33 inline uint32_t RotateRight32(uint32_t value, uint32_t shift) { | 17 inline uint32_t RotateRight32(uint32_t value, uint32_t shift) { |
| 34 if (shift == 0) return value; | 18 if (shift == 0) return value; |
| 35 return (value >> shift) | (value << (32 - shift)); | 19 return (value >> shift) | (value << (32 - shift)); |
| 36 } | 20 } |
| 37 | 21 |
| 38 | 22 |
| 39 inline uint64_t RotateRight64(uint64_t value, uint32_t shift) { | 23 inline uint64_t RotateRight64(uint64_t value, uint64_t shift) { |
| 40 if (shift == 0) return value; | 24 if (shift == 0) return value; |
| 41 return (value >> shift) | (value << (64 - shift)); | 25 return (value >> shift) | (value << (64 - shift)); |
| 42 } | 26 } |
| 43 | 27 |
| 44 #endif // V8_CC_MSVC | |
| 45 | |
| 46 } // namespace bits | 28 } // namespace bits |
| 47 } // namespace base | 29 } // namespace base |
| 48 } // namespace v8 | 30 } // namespace v8 |
| 49 | 31 |
| 50 #endif // V8_BASE_BITS_H_ | 32 #endif // V8_BASE_BITS_H_ |
| OLD | NEW |