mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #27969 from famiu/refactor/misc/xctz
refactor(misc): use MSVC compiler builtin for `xctz()`
This commit is contained in:
commit
2289ecd22e
@ -4,6 +4,10 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
# include <intrin.h> // Required for _BitScanForward64
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "nvim/math.h"
|
#include "nvim/math.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
@ -52,6 +56,10 @@ int xctz(uint64_t x)
|
|||||||
// Use compiler builtin if possible.
|
// Use compiler builtin if possible.
|
||||||
#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 4))
|
#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 4))
|
||||||
return __builtin_ctzll(x);
|
return __builtin_ctzll(x);
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
unsigned long index;
|
||||||
|
_BitScanForward64(&index, x);
|
||||||
|
return (int)index;
|
||||||
#else
|
#else
|
||||||
int count = 0;
|
int count = 0;
|
||||||
// Set x's trailing zeroes to ones and zero the rest.
|
// Set x's trailing zeroes to ones and zero the rest.
|
||||||
|
Loading…
Reference in New Issue
Block a user