X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2Fportability%2FBuiltins.h;h=90179c8f453e2a85447176285516f6438c1f980d;hb=2ccbaf9e215b23a357ad6f07de0d1374597b47b8;hp=932d9c407b17b572ef8348602ff0e4ae6f77f14c;hpb=dfc2add75af7fa3e32da8566fdb0eeca25366c79;p=folly.git diff --git a/folly/portability/Builtins.h b/folly/portability/Builtins.h old mode 100755 new mode 100644 index 932d9c40..90179c8f --- a/folly/portability/Builtins.h +++ b/folly/portability/Builtins.h @@ -43,7 +43,7 @@ FOLLY_ALWAYS_INLINE void __builtin___clear_cache(char* begin, char* end) { FOLLY_ALWAYS_INLINE int __builtin_clz(unsigned int x) { unsigned long index; - return (int)(_BitScanReverse(&index, (unsigned long)x) ? 31 - index : 32); + return int(_BitScanReverse(&index, (unsigned long)x) ? 31 - index : 32); } FOLLY_ALWAYS_INLINE int __builtin_clzl(unsigned long x) { @@ -52,28 +52,34 @@ FOLLY_ALWAYS_INLINE int __builtin_clzl(unsigned long x) { FOLLY_ALWAYS_INLINE int __builtin_clzll(unsigned long long x) { unsigned long index; - return (int)(_BitScanReverse64(&index, x) ? 63 - index : 64); + return int(_BitScanReverse64(&index, x) ? 63 - index : 64); } FOLLY_ALWAYS_INLINE int __builtin_ctzll(unsigned long long x) { unsigned long index; - return (int)(_BitScanForward64(&index, x) ? index : 64); + return int(_BitScanForward64(&index, x) ? index : 64); } FOLLY_ALWAYS_INLINE int __builtin_ffs(int x) { unsigned long index; - return (int)(_BitScanForward(&index, (unsigned long)x) ? index + 1 : 0); + return int(_BitScanForward(&index, (unsigned long)x) ? index + 1 : 0); } -FOLLY_ALWAYS_INLINE int __builtin_ffsl(long x) { return __builtin_ffs((int)x); } +FOLLY_ALWAYS_INLINE int __builtin_ffsl(long x) { + return __builtin_ffs(int(x)); +} FOLLY_ALWAYS_INLINE int __builtin_ffsll(long long x) { unsigned long index; - return (int)(_BitScanForward64(&index, (unsigned long long)x) ? index + 1 : 0); + return int(_BitScanForward64(&index, (unsigned long long)x) ? index + 1 : 0); +} + +FOLLY_ALWAYS_INLINE int __builtin_popcount(unsigned int x) { + return int(__popcnt(x)); } FOLLY_ALWAYS_INLINE int __builtin_popcountll(unsigned long long x) { - return (int)__popcnt64(x); + return int(__popcnt64(x)); } FOLLY_ALWAYS_INLINE void* __builtin_return_address(unsigned int frame) {