diff options
| author | Jason Evans <jasone@canonware.com> | 2017-06-13 19:49:58 (GMT) |
|---|---|---|
| committer | Jason Evans <jasone@canonware.com> | 2017-06-13 19:51:09 (GMT) |
| commit | 5018fe3f0979b7f9db9930accdf7ee31071fd703 (patch) | |
| tree | 894055b5ff4ccde3d9d782861d45af4664f12ad2 /include/msvc_compat/strings.h | |
| parent | 04380e79f1e2428bd0ad000bbc6e3d2dfc6b66a5 (diff) | |
| parent | ba29113e5a58caeb6b4a65b1db6d8efae79cae45 (diff) | |
| download | jemalloc-5.0.0.zip jemalloc-5.0.0.tar.gz jemalloc-5.0.0.tar.bz2 | |
Merge branch 'dev'5.0.0
Diffstat (limited to 'include/msvc_compat/strings.h')
| -rw-r--r-- | include/msvc_compat/strings.h | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/include/msvc_compat/strings.h b/include/msvc_compat/strings.h index a3ee250..996f256 100644 --- a/include/msvc_compat/strings.h +++ b/include/msvc_compat/strings.h @@ -6,32 +6,30 @@ #ifdef _MSC_VER # include <intrin.h> # pragma intrinsic(_BitScanForward) -static __forceinline int ffsl(long x) -{ +static __forceinline int ffsl(long x) { unsigned long i; - if (_BitScanForward(&i, x)) - return (i + 1); - return (0); + if (_BitScanForward(&i, x)) { + return i + 1; + } + return 0; } -static __forceinline int ffs(int x) -{ - - return (ffsl(x)); +static __forceinline int ffs(int x) { + return ffsl(x); } # ifdef _M_X64 # pragma intrinsic(_BitScanForward64) # endif -static __forceinline int ffsll(unsigned __int64 x) -{ +static __forceinline int ffsll(unsigned __int64 x) { unsigned long i; #ifdef _M_X64 - if (_BitScanForward64(&i, x)) - return (i + 1); - return (0); + if (_BitScanForward64(&i, x)) { + return i + 1; + } + return 0; #else // Fallback for 32-bit build where 64-bit version not available // assuming little endian @@ -42,11 +40,12 @@ static __forceinline int ffsll(unsigned __int64 x) s.ll = x; - if (_BitScanForward(&i, s.l[0])) - return (i + 1); - else if(_BitScanForward(&i, s.l[1])) - return (i + 33); - return (0); + if (_BitScanForward(&i, s.l[0])) { + return i + 1; + } else if(_BitScanForward(&i, s.l[1])) { + return i + 33; + } + return 0; #endif } |
