Go to the documentation of this file.
29 # define BM_ASSERT _ASSERT
31 # ifdef HAVE_RESTRICT_CXX
32 # define BM_HASRESTRICT
33 # define BMRESTRICT NCBI_RESTRICT
36 # if defined(NCBI_FORCEINLINE) && \
37 ( !defined(NCBI_COMPILER_GCC) || NCBI_COMPILER_VERSION >= 400 || \
38 defined(__OPTIMIZE__))
39 # define BM_HASFORCEINLINE
40 # define BMFORCEINLINE NCBI_FORCEINLINE
59 #if defined(__i386) || defined(__x86_64) || defined(__ppc__) || \
60 defined(__ppc64__) || defined(_M_IX86) || defined(_M_AMD64) || \
61 defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64) || \
62 (defined(_M_MPPC) && !defined(BM_FORBID_UNALIGNED_ACCESS))
63 #define BM_UNALIGNED_ACCESS_OK 1
66 #if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64) || \
67 defined(__i386) || defined(__x86_64) || defined(_M_AMD64) || \
68 defined(BMSSE2OPT) || defined(BMSSE42OPT)
74 #if defined(BM_NO_CXX11) || (defined(_MSC_VER) && _MSC_VER < 1900)
78 # define BMNOEXEPT noexcept
93 # define BM_HASFORCEINLINE
95 # define BMRESTRICT __restrict
101 # define BMRESTRICT __restrict__
117 # define BM_ASSERT assert
120 # define BM_ASSERT(x)
126 #if defined(__x86_64) || defined(_M_AMD64) || defined(_WIN64) || \
127 defined(__LP64__) || defined(_LP64) || ( __WORDSIZE == 64 )
135 #define FULL_BLOCK_REAL_ADDR bm::all_set<true>::_block._p
136 #define FULL_BLOCK_FAKE_ADDR bm::all_set<true>::_block._p_fullp
137 #define FULL_SUB_BLOCK_REAL_ADDR bm::all_set<true>::_block._s
138 #define BLOCK_ADDR_SAN(addr) (addr == FULL_BLOCK_FAKE_ADDR) ? FULL_BLOCK_REAL_ADDR : addr
139 #define IS_VALID_ADDR(addr) bm::all_set<true>::is_valid_block_addr(addr)
140 #define IS_FULL_BLOCK(addr) bm::all_set<true>::is_full_block(addr)
141 #define IS_EMPTY_BLOCK(addr) bool(addr == 0)
143 #define BM_BLOCK_TYPE(addr) bm::all_set<true>::block_type(addr)
152 # if ULONG_MAX != 0xffffffff || defined(_WIN64) // 64-bit
154 # define BMPTR_SETBIT0(ptr) ( ((bm::id64_t)ptr) | 1 )
155 # define BMPTR_CLEARBIT0(ptr) ( ((bm::id64_t)ptr) & ~(bm::id64_t)1 )
156 # define BMPTR_TESTBIT0(ptr) ( ((bm::id64_t)ptr) & 1 )
160 # define BMPTR_SETBIT0(ptr) ( ((bm::id_t)ptr) | 1 )
161 # define BMPTR_CLEARBIT0(ptr) ( ((bm::id_t)ptr) & ~(bm::id_t)1 )
162 # define BMPTR_TESTBIT0(ptr) ( ((bm::id_t)ptr) & 1 )
166 # define BMGAP_PTR(ptr) ((bm::gap_word_t*)BMPTR_CLEARBIT0(ptr))
167 # define BMSET_PTRGAP(ptr) ptr = (bm::word_t*)BMPTR_SETBIT0(ptr)
168 # define BM_IS_GAP(ptr) bool(BMPTR_TESTBIT0(ptr)!=0)
174 #ifdef BM_HASRESTRICT
176 # define BMRESTRICT restrict
185 #ifdef BM_HASFORCEINLINE
186 # ifndef BMFORCEINLINE
187 # define BMFORCEINLINE __forceinline
190 # define BMFORCEINLINE inline
199 # if defined(BM64OPT) || defined(__x86_64) || defined(_M_AMD64) || defined(_WIN64) || \
200 defined(__LP64__) || defined(_LP64)
208 # if defined(BM64OPT) || defined(__x86_64) || defined(_M_AMD64) || defined(_WIN64) || \
209 defined(__LP64__) || defined(_LP64)
219 # if defined(BM64OPT) || defined(__x86_64) || defined(_M_AMD64) || defined(_WIN64) || \
220 defined(__LP64__) || defined(_LP64)
232 # ifndef BM_SET_MMX_GUARD
233 # define BM_SET_MMX_GUARD
237 #if (defined(BMSSE2OPT) || defined(BMSSE42OPT) || defined(BMAVX2OPT) || defined(BMAVX512OPT))
239 # ifndef BM_SET_MMX_GUARD
240 # define BM_SET_MMX_GUARD sse_empty_guard bm_mmx_guard_;
246 # define BM_ALIGN16 __declspec(align(16))
247 # define BM_ALIGN16ATTR
251 # define BM_ALIGN32 __declspec(align(32))
252 # define BM_ALIGN32ATTR
256 # define BM_ALIGN64 __declspec(align(64))
257 # define BM_ALIGN64ATTR
264 # define BM_ALIGN16ATTR __attribute__((aligned(16)))
269 # define BM_ALIGN32ATTR __attribute__((aligned(32)))
274 # define BM_ALIGN64ATTR __attribute__((aligned(64)))
281 #define BM_ALIGN16ATTR
283 #define BM_ALIGN32ATTR
285 #define BM_ALIGN64ATTR
345 #if (defined(BMSSE2OPT) || defined(BMSSE42OPT))
346 # define BM_VECT_ALIGN BM_ALIGN16
347 # define BM_VECT_ALIGN_ATTR BM_ALIGN16ATTR
349 # if defined(BMAVX2OPT)
350 # define BM_VECT_ALIGN BM_ALIGN32
351 # define BM_VECT_ALIGN_ATTR BM_ALIGN32ATTR
353 # if defined(BMAVX512OPT)
354 # define BM_VECT_ALIGN BM_ALIGN64
355 # define BM_VECT_ALIGN_ATTR BM_ALIGN64ATTR
357 # define BM_VECT_ALIGN
358 # define BM_VECT_ALIGN_ATTR
370 #ifndef BM_INCWORD_BITCOUNT
372 #if (defined(BMSSE42OPT) || defined(BMAVX2OPT) || defined(BMAVX512OPT))
373 # define BM_INCWORD_BITCOUNT(cnt, w) cnt += unsigned(_mm_popcnt_u32(w));
376 # define BM_INCWORD_BITCOUNT(cnt, w) cnt += \
377 bm::bit_count_table<true>::_count[(unsigned char)(w)] + \
378 bm::bit_count_table<true>::_count[(unsigned char)((w) >> 8)] + \
379 bm::bit_count_table<true>::_count[(unsigned char)((w) >> 16)] + \
380 bm::bit_count_table<true>::_count[(unsigned char)((w) >> 24)];
387 #ifndef BM_ASSERT_THROW
388 #define BM_ASSERT_THROW(x, xerrcode)