mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 09:26:30 +00:00

tree-sitter/tree-sitter commit 6cb8d24de2d99c4c50c9a0fd1e719ca5b3abc87f Included files are: lib/include/tree-sitter/*.h lib/src/*.[ch] lib/src/unicode/* LICENSE
30 lines
541 B
C
30 lines
541 B
C
#ifndef TREE_SITTER_BITS_H_
|
|
#define TREE_SITTER_BITS_H_
|
|
|
|
#include <stdint.h>
|
|
|
|
static inline uint32_t bitmask_for_index(uint16_t id) {
|
|
return (1u << (31 - id));
|
|
}
|
|
|
|
#if defined _WIN32 && !defined __GNUC__
|
|
|
|
#include <intrin.h>
|
|
|
|
static inline uint32_t count_leading_zeros(uint32_t x) {
|
|
if (x == 0) return 32;
|
|
uint32_t result;
|
|
_BitScanReverse(&result, x);
|
|
return 31 - result;
|
|
}
|
|
|
|
#else
|
|
|
|
static inline uint32_t count_leading_zeros(uint32_t x) {
|
|
if (x == 0) return 32;
|
|
return __builtin_clz(x);
|
|
}
|
|
|
|
#endif
|
|
#endif // TREE_SITTER_BITS_H_
|