aboutsummaryrefslogtreecommitdiff
path: root/src/tree_sitter/bits.h
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2019-09-28 18:41:49 +0200
committerBjörn Linse <bjorn.linse@gmail.com>2019-12-22 10:35:00 +0100
commit79bd8d2ab6cae1c0be3233a9a7551d0b7bcc5944 (patch)
tree5335e3950295d4342322976a07a76d9a1a642ed9 /src/tree_sitter/bits.h
parent781c708c27816b07f1d20a333151886044534fab (diff)
downloadrneovim-79bd8d2ab6cae1c0be3233a9a7551d0b7bcc5944.tar.gz
rneovim-79bd8d2ab6cae1c0be3233a9a7551d0b7bcc5944.tar.bz2
rneovim-79bd8d2ab6cae1c0be3233a9a7551d0b7bcc5944.zip
tree-sitter: update vendored tree-sitter runtime
tree-sitter/tree-sitter commit edb569310005c66838b7d69fa60850acac6abeee Included files are: lib/include/tree-sitter/*.h lib/src/*.[ch] lib/src/unicode/* LICENSE
Diffstat (limited to 'src/tree_sitter/bits.h')
-rw-r--r--src/tree_sitter/bits.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/tree_sitter/bits.h b/src/tree_sitter/bits.h
new file mode 100644
index 0000000000..3bec455dd1
--- /dev/null
+++ b/src/tree_sitter/bits.h
@@ -0,0 +1,29 @@
+#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));
+}
+
+#ifdef _WIN32
+
+#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_