| 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 |
| 10 #include "src/base/win32-headers.h" |
| 11 #endif |
| 9 | 12 |
| 10 namespace v8 { | 13 namespace v8 { |
| 11 namespace base { | 14 namespace base { |
| 12 namespace bits { | 15 namespace bits { |
| 13 | 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 |
| 14 inline uint32_t RotateRight32(uint32_t value, uint32_t shift) { | 33 inline uint32_t RotateRight32(uint32_t value, uint32_t shift) { |
| 15 if (shift == 0) return value; | 34 if (shift == 0) return value; |
| 16 return (value >> shift) | (value << (32 - shift)); | 35 return (value >> shift) | (value << (32 - shift)); |
| 17 } | 36 } |
| 18 | 37 |
| 19 | 38 |
| 20 inline uint64_t RotateRight64(uint64_t value, uint64_t shift) { | 39 inline uint64_t RotateRight64(uint64_t value, uint32_t shift) { |
| 21 if (shift == 0) return value; | 40 if (shift == 0) return value; |
| 22 return (value >> shift) | (value << (64 - shift)); | 41 return (value >> shift) | (value << (64 - shift)); |
| 23 } | 42 } |
| 24 | 43 |
| 44 #endif // V8_CC_MSVC |
| 45 |
| 25 } // namespace bits | 46 } // namespace bits |
| 26 } // namespace base | 47 } // namespace base |
| 27 } // namespace v8 | 48 } // namespace v8 |
| 28 | 49 |
| 29 #endif // V8_BASE_BITS_H_ | 50 #endif // V8_BASE_BITS_H_ |
| OLD | NEW |