32 #ifndef __TOMMYTYPES_H 33 #define __TOMMYTYPES_H 75 #define tommy_cast(type, value) static_cast<type>(value) 77 #define tommy_cast(type, value) (value) 89 #if !defined(tommy_malloc) || !defined(tommy_calloc) || !defined(tommy_realloc) || !defined(tommy_free) 92 #if !defined(tommy_malloc) 93 #define tommy_malloc malloc 95 #if !defined(tommy_calloc) 96 #define tommy_calloc calloc 98 #if !defined(tommy_realloc) 99 #define tommy_realloc realloc 101 #if !defined(tommy_free) 102 #define tommy_free free 111 #if !defined(tommy_inline) 112 #if defined(_MSC_VER) || defined(__GNUC__) 113 #define tommy_inline static __inline 115 #define tommy_inline static 122 #if !defined(tommy_restrict) 123 #if __STDC_VERSION__ >= 199901L 124 #define tommy_restrict restrict 125 #elif defined(_MSC_VER) || defined(__GNUC__) 126 #define tommy_restrict __restrict 128 #define tommy_restrict 135 #if !defined(tommy_likely) 136 #if defined(__GNUC__) 137 #define tommy_likely(x) __builtin_expect(!!(x), 1) 139 #define tommy_likely(x) (x) 146 #if !defined(tommy_unlikely) 147 #if defined(__GNUC__) 148 #define tommy_unlikely(x) __builtin_expect(!!(x), 0) 150 #define tommy_unlikely(x) (x) 165 #define TOMMY_KEY_BIT (sizeof(tommy_key_t) * 8) 296 #if defined(_MSC_VER) && !defined(__cplusplus) 298 #pragma intrinsic(_BitScanReverse) 299 #pragma intrinsic(_BitScanForward) 306 #define TOMMY_ILOG2(value) ((value) == 256 ? 8 : (value) == 128 ? 7 : (value) == 64 ? 6 : (value) == 32 ? 5 : (value) == 16 ? 4 : (value) == 8 ? 3 : (value) == 4 ? 2 : (value) == 2 ? 1 : 0) 328 #if defined(_MSC_VER) 330 _BitScanReverse(&count, value);
332 #elif defined(__GNUC__) 342 return __builtin_clz(value) ^ 31;
346 static unsigned char TOMMY_DE_BRUIJN_INDEX_ILOG2[32] = {
347 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30,
348 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31
355 value |= value >> 16;
357 return TOMMY_DE_BRUIJN_INDEX_ILOG2[(
tommy_uint32_t)(value * 0x07C4ACDDU) >> 27];
371 #if defined(_MSC_VER) 373 _BitScanForward(&count, value);
375 #elif defined(__GNUC__) 376 return __builtin_ctz(value);
380 static const unsigned char TOMMY_DE_BRUIJN_INDEX_CTZ[32] = {
381 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
382 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9
385 return TOMMY_DE_BRUIJN_INDEX_CTZ[(
tommy_uint32_t)(((value & - value) * 0x077CB531U)) >> 27];
404 value |= value >> 16;
struct tommy_node_struct tommy_node
tommy_uint32_t tommy_key_t
tommy_uint32_t tommy_count_t
ptrdiff_t tommy_ptrdiff_t
struct tommy_node_struct * next
struct tommy_node_struct * prev
tommy_inline tommy_uint_t tommy_ctz_u32(tommy_uint32_t value)
uintptr_t tommy_uintptr_t
int tommy_search_func(const void *arg, const void *obj)
int tommy_compare_func(const void *obj_a, const void *obj_b)
tommy_inline tommy_uint32_t tommy_roundup_pow2_u32(tommy_uint32_t value)
tommy_uint32_t tommy_uint_t
void tommy_foreach_func(void *obj)
tommy_inline tommy_uint_t tommy_ilog2_u32(tommy_uint32_t value)
void tommy_foreach_arg_func(void *arg, void *obj)