diff options
author | bfredl <bjorn.linse@gmail.com> | 2024-03-21 21:29:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-21 21:29:11 +0100 |
commit | 2289ecd22e2c8b516f51eed4a79411c17e0dba86 (patch) | |
tree | b780cab9ef38a579ad52be6e7c6c9fb689119049 /src | |
parent | 563a369a1b254851d84c41838a8562ad7e655fa3 (diff) | |
parent | 1dde678757216b019fff7ac3b6226ab997b86a8b (diff) | |
download | rneovim-2289ecd22e2c8b516f51eed4a79411c17e0dba86.tar.gz rneovim-2289ecd22e2c8b516f51eed4a79411c17e0dba86.tar.bz2 rneovim-2289ecd22e2c8b516f51eed4a79411c17e0dba86.zip |
Merge pull request #27969 from famiu/refactor/misc/xctz
refactor(misc): use MSVC compiler builtin for `xctz()`
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/math.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/nvim/math.c b/src/nvim/math.c index 9a0825823c..39d166bb53 100644 --- a/src/nvim/math.c +++ b/src/nvim/math.c @@ -4,6 +4,10 @@ #include <stdint.h> #include <string.h> +#ifdef _MSC_VER +# include <intrin.h> // Required for _BitScanForward64 +#endif + #include "nvim/math.h" #ifdef INCLUDE_GENERATED_DECLARATIONS @@ -52,6 +56,10 @@ int xctz(uint64_t x) // Use compiler builtin if possible. #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 4)) return __builtin_ctzll(x); +#elif defined(_MSC_VER) + unsigned long index; + _BitScanForward64(&index, x); + return (int)index; #else int count = 0; // Set x's trailing zeroes to ones and zero the rest. |