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)
79# define BMNOEXCEPT noexcept
80#if defined(__EMSCRIPTEN__)
94#if defined(__EMSCRIPTEN__)
96# define BM_USE_GCC_BUILD
97# define BMNOEXCEPT2 noexcept
106# define BM_HASFORCEINLINE
108# define BMRESTRICT __restrict
114# define BMRESTRICT __restrict__
130# define BM_ASSERT assert
139#if defined(__x86_64) || defined(_M_AMD64) || defined(_WIN64) || \
140 defined(__LP64__) || defined(_LP64) || ( __WORDSIZE == 64 )
148#define FULL_BLOCK_REAL_ADDR bm::all_set<true>::_block._p
149#define FULL_BLOCK_FAKE_ADDR bm::all_set<true>::_block._p_fullp
150#define FULL_SUB_BLOCK_REAL_ADDR bm::all_set<true>::_block._s
151#define BLOCK_ADDR_SAN(addr) (addr == FULL_BLOCK_FAKE_ADDR) ? FULL_BLOCK_REAL_ADDR : addr
152#define IS_VALID_ADDR(addr) bm::all_set<true>::is_valid_block_addr(addr)
153#define IS_FULL_BLOCK(addr) bm::all_set<true>::is_full_block(addr)
154#define IS_EMPTY_BLOCK(addr) bool(addr == 0)
156#define BM_BLOCK_TYPE(addr) bm::all_set<true>::block_type(addr)
165# if ULONG_MAX != 0xffffffff || defined(_WIN64)
167# define BMPTR_SETBIT0(ptr) ( ((bm::id64_t)ptr) | 1 )
168# define BMPTR_CLEARBIT0(ptr) ( ((bm::id64_t)ptr) & ~(bm::id64_t)1 )
169# define BMPTR_TESTBIT0(ptr) ( ((bm::id64_t)ptr) & 1 )
173# define BMPTR_SETBIT0(ptr) ( ((bm::id_t)ptr) | 1 )
174# define BMPTR_CLEARBIT0(ptr) ( ((bm::id_t)ptr) & ~(bm::id_t)1 )
175# define BMPTR_TESTBIT0(ptr) ( ((bm::id_t)ptr) & 1 )
179# define BMGAP_PTR(ptr) ((bm::gap_word_t*)BMPTR_CLEARBIT0(ptr))
180# define BMSET_PTRGAP(ptr) ptr = (bm::word_t*)BMPTR_SETBIT0(ptr)
181# define BM_IS_GAP(ptr) bool(BMPTR_TESTBIT0(ptr)!=0)
189# define BMRESTRICT restrict
198#ifdef BM_HASFORCEINLINE
199# ifndef BMFORCEINLINE
200# define BMFORCEINLINE __forceinline
203# define BMFORCEINLINE inline
212# if defined(BM64OPT) || defined(__x86_64) || defined(_M_AMD64) || defined(_WIN64) || \
213 defined(__LP64__) || defined(_LP64)
221# if defined(BM64OPT) || defined(__x86_64) || defined(_M_AMD64) || defined(_WIN64) || \
222 defined(__LP64__) || defined(_LP64)
232# if defined(BM64OPT) || defined(__x86_64) || defined(_M_AMD64) || defined(_WIN64) || \
233 defined(__LP64__) || defined(_LP64)
245# ifndef BM_SET_MMX_GUARD
246# define BM_SET_MMX_GUARD
250#if (defined(BMSSE2OPT) || defined(BMSSE42OPT) || defined(BMAVX2OPT) || defined(BMAVX512OPT))
252 # ifndef BM_SET_MMX_GUARD
253 # define BM_SET_MMX_GUARD sse_empty_guard bm_mmx_guard_;
259 # define BM_ALIGN16 __declspec(align(16))
260 # define BM_ALIGN16ATTR
264 # define BM_ALIGN32 __declspec(align(32))
265 # define BM_ALIGN32ATTR
269 # define BM_ALIGN64 __declspec(align(64))
270 # define BM_ALIGN64ATTR
277 # define BM_ALIGN16ATTR __attribute__((aligned(16)))
282 # define BM_ALIGN32ATTR __attribute__((aligned(32)))
287 # define BM_ALIGN64ATTR __attribute__((aligned(64)))
294 #define BM_ALIGN16ATTR
296 #define BM_ALIGN32ATTR
298 #define BM_ALIGN64ATTR
358#if (defined(BMSSE2OPT) || defined(BMSSE42OPT))
359# define BM_VECT_ALIGN BM_ALIGN16
360# define BM_VECT_ALIGN_ATTR BM_ALIGN16ATTR
362# if defined(BMAVX2OPT)
363# define BM_VECT_ALIGN BM_ALIGN32
364# define BM_VECT_ALIGN_ATTR BM_ALIGN32ATTR
366# if defined(BMAVX512OPT)
367# define BM_VECT_ALIGN BM_ALIGN64
368# define BM_VECT_ALIGN_ATTR BM_ALIGN64ATTR
370# define BM_VECT_ALIGN
371# define BM_VECT_ALIGN_ATTR
383#ifndef BM_INCWORD_BITCOUNT
385#if (defined(BMSSE42OPT) || defined(BMAVX2OPT) || defined(BMAVX512OPT))
386# define BM_INCWORD_BITCOUNT(cnt, w) cnt += unsigned(_mm_popcnt_u32(w));
389# define BM_INCWORD_BITCOUNT(cnt, w) cnt += \
390 bm::bit_count_table<true>::_count[(unsigned char)(w)] + \
391 bm::bit_count_table<true>::_count[(unsigned char)((w) >> 8)] + \
392 bm::bit_count_table<true>::_count[(unsigned char)((w) >> 16)] + \
393 bm::bit_count_table<true>::_count[(unsigned char)((w) >> 24)];
400#ifndef BM_ASSERT_THROW
401#define BM_ASSERT_THROW(x, xerrcode)
405#ifndef __has_cpp_attribute
406# define __has_cpp_attribute(x) 0
408#ifndef __has_attribute
409# define __has_attribute(x) 0
411#if __has_cpp_attribute(fallthrough)
412# define BM_FALLTHROUGH [[fallthrough]]
413#elif __has_cpp_attribute(gcc::fallthrough)
414# define BM_FALLTHROUGH [[gcc::fallthrough]]
415#elif __has_cpp_attribute(clang::fallthrough)
416# define BM_FALLTHROUGH [[clang::fallthrough]]
417#elif __has_attribute(fallthrough)
418# define BM_FALLTHROUGH __attribute__ ((fallthrough))
420# define BM_FALLTHROUGH