diff options
author | H. Peter Anvin <hpa@zytor.com> | 2017-04-18 16:05:22 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2017-04-18 16:05:22 -0700 |
commit | e558dfd2498f581125b14a2e7abbac27fe5e7515 (patch) | |
tree | 8993f80b2e86fdfd41d812617f1c157e459fed7b /nasmlib/ilog2.c | |
parent | 5eb528b6c57e082143ed4403285eb301a19b853b (diff) | |
download | nasm-e558dfd2498f581125b14a2e7abbac27fe5e7515.tar.gz |
configure, ilog2: add some MSVC intrinsics
Add MSVC intrinsics for byte swapping and for BSF (ilog2).
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'nasmlib/ilog2.c')
-rw-r--r-- | nasmlib/ilog2.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/nasmlib/ilog2.c b/nasmlib/ilog2.c index 51c3e07a..1467905f 100644 --- a/nasmlib/ilog2.c +++ b/nasmlib/ilog2.c @@ -85,6 +85,14 @@ int ilog2_32(uint32_t v) return __builtin_clz(v) ^ 31; } +#elif defined(HAVE__BITSCANREVERSE) + +int ilog2_32(uint32_t v) +{ + unsigned long ix; + return _BitScanReverse(&ix, v) ? v : 0; +} + #else int ilog2_32(uint32_t v) @@ -124,6 +132,14 @@ int ilog2_64(uint64_t v) return __builtin_clzll(v) ^ 63; } +#elif defined(HAVE__BITSCANREVERSE64) + +int ilog2_64(uint64_t v) +{ + unsigned long ix; + return _BitScanReverse64(&ix, v) ? ix : 0; +} + #else int ilog2_64(uint64_t vv) |