diff options
author | 2013-04-29 15:34:35 +0000 | |
---|---|---|
committer | 2013-04-29 15:34:35 +0000 | |
commit | 5c341d1ff1b58cc2b88c52f4ee41faf53a2a7578 (patch) | |
tree | d643182fa710b7dc1df5f9a873881dccbae19119 /include/core | |
parent | bc57a29a7a9757064389bcd31bbc36069208756a (diff) |
reenable __builtin_clz for GNUC (and clang), recognizing that it is undefined for a zero argument,
so we check for that explicitly.
git-svn-id: http://skia.googlecode.com/svn/trunk@8905 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core')
-rw-r--r-- | include/core/SkMath.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/include/core/SkMath.h b/include/core/SkMath.h index 6505b08594..078c8fccdc 100644 --- a/include/core/SkMath.h +++ b/include/core/SkMath.h @@ -53,8 +53,11 @@ int SkCLZ_portable(uint32_t); return 32; } } - #elif defined(SK_CPU_ARM) - #define SkCLZ(mask) __builtin_clz(mask) + #elif defined(SK_CPU_ARM) || defined(__GNUC__) || defined(__clang__) + static inline int SkCLZ(uint32_t mask) { + // __builtin_clz(0) is undefined, so we have to detect that case. + return mask ? __builtin_clz(mask) : 32; + } #else #define SkCLZ(x) SkCLZ_portable(x) #endif |