From: reed@google.com Date: Mon, 29 Apr 2013 15:34:35 +0000 (+0000) Subject: reenable __builtin_clz for GNUC (and clang), recognizing that it is undefined for... X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~12567 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5c341d1ff1b58cc2b88c52f4ee41faf53a2a7578;p=platform%2Fupstream%2FlibSkiaSharp.git 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 --- diff --git a/include/core/SkMath.h b/include/core/SkMath.h index 6505b08..078c8fc 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