OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkMath_DEFINED | 10 #ifndef SkMath_DEFINED |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 int SkCLZ_portable(uint32_t); | 72 int SkCLZ_portable(uint32_t); |
73 | 73 |
74 #ifndef SkCLZ | 74 #ifndef SkCLZ |
75 #if defined(_MSC_VER) && _MSC_VER >= 1400 | 75 #if defined(_MSC_VER) && _MSC_VER >= 1400 |
76 #include <intrin.h> | 76 #include <intrin.h> |
77 | 77 |
78 static inline int SkCLZ(uint32_t mask) { | 78 static inline int SkCLZ(uint32_t mask) { |
79 if (mask) { | 79 if (mask) { |
80 DWORD index; | 80 DWORD index; |
81 _BitScanReverse(&index, mask); | 81 _BitScanReverse(&index, mask); |
| 82 // Suppress this bogus /analyze warning. The check for non-zero |
| 83 // guarantees that _BitScanReverse will succeed. |
| 84 #pragma warning(suppress : 6102) // Using 'index' from failed function call |
82 return index ^ 0x1F; | 85 return index ^ 0x1F; |
83 } else { | 86 } else { |
84 return 32; | 87 return 32; |
85 } | 88 } |
86 } | 89 } |
87 #elif defined(SK_CPU_ARM32) || defined(__GNUC__) || defined(__clang__) | 90 #elif defined(SK_CPU_ARM32) || defined(__GNUC__) || defined(__clang__) |
88 static inline int SkCLZ(uint32_t mask) { | 91 static inline int SkCLZ(uint32_t mask) { |
89 // __builtin_clz(0) is undefined, so we have to detect that case. | 92 // __builtin_clz(0) is undefined, so we have to detect that case. |
90 return mask ? __builtin_clz(mask) : 32; | 93 return mask ? __builtin_clz(mask) : 32; |
91 } | 94 } |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 *div = static_cast<Out>(d); | 223 *div = static_cast<Out>(d); |
221 *mod = static_cast<Out>(numer-d*denom); | 224 *mod = static_cast<Out>(numer-d*denom); |
222 #else | 225 #else |
223 // On x86 this will just be a single idiv. | 226 // On x86 this will just be a single idiv. |
224 *div = static_cast<Out>(numer/denom); | 227 *div = static_cast<Out>(numer/denom); |
225 *mod = static_cast<Out>(numer%denom); | 228 *mod = static_cast<Out>(numer%denom); |
226 #endif | 229 #endif |
227 } | 230 } |
228 | 231 |
229 #endif | 232 #endif |
OLD | NEW |