OLD | NEW |
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 /* This Source Code Form is subject to the terms of the Mozilla Public | 2 /* This Source Code Form is subject to the terms of the Mozilla Public |
3 * License, v. 2.0. If a copy of the MPL was not distributed with this | 3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
5 | 5 |
6 #ifndef prbit_h___ | 6 #ifndef prbit_h___ |
7 #define prbit_h___ | 7 #define prbit_h___ |
8 | 8 |
9 #include "prtypes.h" | 9 #include "prtypes.h" |
10 PR_BEGIN_EXTERN_C | 10 PR_BEGIN_EXTERN_C |
11 | 11 |
12 /* | 12 /* |
13 ** Replace compare/jump/add/shift sequence with compiler built-in/intrinsic | 13 ** Replace compare/jump/add/shift sequence with compiler built-in/intrinsic |
14 ** functions. | 14 ** functions. |
15 */ | 15 */ |
16 #if defined(_WIN32) && (_MSC_VER >= 1300) && \ | 16 #if defined(_WIN32) && (_MSC_VER >= 1300) && \ |
17 (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_ARM)) | 17 (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_ARM)) |
18 unsigned char _BitScanForward(unsigned long * Index, unsigned long Mask); | 18 # include <intrin.h> |
19 unsigned char _BitScanReverse(unsigned long * Index, unsigned long Mask); | |
20 # pragma intrinsic(_BitScanForward,_BitScanReverse) | 19 # pragma intrinsic(_BitScanForward,_BitScanReverse) |
21 __forceinline static int __prBitScanForward32(unsigned int val) | 20 __forceinline static int __prBitScanForward32(unsigned int val) |
22 { | 21 { |
23 unsigned long idx; | 22 unsigned long idx; |
24 _BitScanForward(&idx, (unsigned long)val); | 23 _BitScanForward(&idx, (unsigned long)val); |
25 return( (int)idx ); | 24 return( (int)idx ); |
26 } | 25 } |
27 __forceinline static int __prBitScanReverse32(unsigned int val) | 26 __forceinline static int __prBitScanReverse32(unsigned int val) |
28 { | 27 { |
29 unsigned long idx; | 28 unsigned long idx; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 #pragma intrinsic(_rotl, _rotr) | 141 #pragma intrinsic(_rotl, _rotr) |
143 #define PR_ROTATE_LEFT32(a, bits) _rotl(a, bits) | 142 #define PR_ROTATE_LEFT32(a, bits) _rotl(a, bits) |
144 #define PR_ROTATE_RIGHT32(a, bits) _rotr(a, bits) | 143 #define PR_ROTATE_RIGHT32(a, bits) _rotr(a, bits) |
145 #else | 144 #else |
146 #define PR_ROTATE_LEFT32(a, bits) (((a) << (bits)) | ((a) >> (32 - (bits)))) | 145 #define PR_ROTATE_LEFT32(a, bits) (((a) << (bits)) | ((a) >> (32 - (bits)))) |
147 #define PR_ROTATE_RIGHT32(a, bits) (((a) >> (bits)) | ((a) << (32 - (bits)))) | 146 #define PR_ROTATE_RIGHT32(a, bits) (((a) >> (bits)) | ((a) << (32 - (bits)))) |
148 #endif | 147 #endif |
149 | 148 |
150 PR_END_EXTERN_C | 149 PR_END_EXTERN_C |
151 #endif /* prbit_h___ */ | 150 #endif /* prbit_h___ */ |
OLD | NEW |