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 #ifdef _PREFAST_ | |
mtklein
2015/01/30 16:07:54
Can't hurt to add '// /analyze enabled'
brucedawson
2015/01/30 17:38:06
Done.
| |
85 #pragma warning(disable: 6102) // Using 'index' from failed function call | |
bungeman-skia
2015/01/30 15:49:22
Can we push and pop this? I feel uncomfortable mak
brucedawson
2015/01/30 17:38:06
Good catch. I meant to use #pragma warning(suppres
| |
86 #endif | |
82 return index ^ 0x1F; | 87 return index ^ 0x1F; |
83 } else { | 88 } else { |
84 return 32; | 89 return 32; |
85 } | 90 } |
86 } | 91 } |
87 #elif defined(SK_CPU_ARM32) || defined(__GNUC__) || defined(__clang__) | 92 #elif defined(SK_CPU_ARM32) || defined(__GNUC__) || defined(__clang__) |
88 static inline int SkCLZ(uint32_t mask) { | 93 static inline int SkCLZ(uint32_t mask) { |
89 // __builtin_clz(0) is undefined, so we have to detect that case. | 94 // __builtin_clz(0) is undefined, so we have to detect that case. |
90 return mask ? __builtin_clz(mask) : 32; | 95 return mask ? __builtin_clz(mask) : 32; |
91 } | 96 } |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 *div = static_cast<Out>(d); | 225 *div = static_cast<Out>(d); |
221 *mod = static_cast<Out>(numer-d*denom); | 226 *mod = static_cast<Out>(numer-d*denom); |
222 #else | 227 #else |
223 // On x86 this will just be a single idiv. | 228 // On x86 this will just be a single idiv. |
224 *div = static_cast<Out>(numer/denom); | 229 *div = static_cast<Out>(numer/denom); |
225 *mod = static_cast<Out>(numer%denom); | 230 *mod = static_cast<Out>(numer%denom); |
226 #endif | 231 #endif |
227 } | 232 } |
228 | 233 |
229 #endif | 234 #endif |
OLD | NEW |