diff --git a/lib/src/bits.h b/lib/src/bits.h deleted file mode 100644 index ca8caf30..00000000 --- a/lib/src/bits.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef TREE_SITTER_BITS_H_ -#define TREE_SITTER_BITS_H_ - -#include - -static inline uint32_t bitmask_for_index(uint16_t id) { - return (1u << (31 - id)); -} - -#ifdef __TINYC__ - -// Algorithm taken from the Hacker's Delight book -// See also https://graphics.stanford.edu/~seander/bithacks.html -static inline uint32_t count_leading_zeros(uint32_t x) { - int count = 0; - if (x == 0) return 32; - x = x - ((x >> 1) & 0x55555555); - x = (x & 0x33333333) + ((x >> 2) & 0x33333333); - count = (((x + (x >> 4)) & 0x0f0f0f0f) * 0x01010101) >> 24; - return count; -} - -#elif defined _WIN32 && !defined __GNUC__ - -#include - -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_ diff --git a/lib/src/query.c b/lib/src/query.c index b082234f..cf5b6267 100644 --- a/lib/src/query.c +++ b/lib/src/query.c @@ -1,7 +1,6 @@ #include "tree_sitter/api.h" #include "./alloc.h" #include "./array.h" -#include "./bits.h" #include "./language.h" #include "./point.h" #include "./tree_cursor.h"