00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #if defined(__i386) || defined(__x86_64) || defined(__ppc__) || \
00012 defined(__ppc64__) || defined(_M_IX86) || defined(_M_AMD64) || \
00013 (defined(_M_MPPC) && !defined(BM_FORBID_UNALIGNED_ACCESS))
00014 #define BM_UNALIGNED_ACCESS_OK 1
00015 #endif
00016
00017 #if defined(__i386) || defined(__x86_64) || defined(_M_AMD64) || defined(BMSSE2OPT) || defined(BMSSE42OPT)
00018 #define BM_x86
00019 #endif
00020
00021
00022
00023
00024 #if(_MSC_VER >= 1400)
00025
00026 # define BM_HASFORCEINLINE
00027 # ifndef BMRESTRICT
00028 # define BMRESTRICT __restrict
00029 # endif
00030 #endif
00031
00032 #ifdef __GNUG__
00033
00034 # ifndef BMRESTRICT
00035 # define BMRESTRICT __restrict__
00036 # endif
00037
00038 # ifdef __OPTIMIZE__
00039 # define BM_NOASSERT
00040 # endif
00041 #endif
00042
00043 #ifndef BM_ASSERT
00044
00045 # ifndef BM_NOASSERT
00046 # include <cassert>
00047 # define BM_ASSERT assert
00048 # else
00049 # ifndef BM_ASSERT
00050 # define BM_ASSERT(x)
00051 # endif
00052 # endif
00053
00054 #endif
00055
00056
00057 #define FULL_BLOCK_ADDR bm::all_set<true>::_block._p
00058 #define IS_VALID_ADDR(addr) (addr && (addr != FULL_BLOCK_ADDR))
00059 #define IS_FULL_BLOCK(addr) (addr == FULL_BLOCK_ADDR)
00060 #define IS_EMPTY_BLOCK(addr) (addr == 0)
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070 #ifdef BM_DISBALE_BIT_IN_PTR
00071
00072 # define BMGAP_PTR(ptr) ((bm::gap_word_t*)ptr)
00073 # define BMSET_PTRGAP(ptr) (void(0))
00074 # define BM_IS_GAP(obj, ptr, idx) ( (obj).is_block_gap(idx) )
00075
00076 #else
00077
00078 # if ULONG_MAX != 0xffffffff || defined(_WIN64) // 64-bit
00079
00080 # define BMPTR_SETBIT0(ptr) ( ((bm::id64_t)ptr) | 1 )
00081 # define BMPTR_CLEARBIT0(ptr) ( ((bm::id64_t)ptr) & ~(bm::id64_t)1 )
00082 # define BMPTR_TESTBIT0(ptr) ( ((bm::id64_t)ptr) & 1 )
00083
00084 # else // 32-bit
00085
00086 # define BMPTR_SETBIT0(ptr) ( ((bm::id_t)ptr) | 1 )
00087 # define BMPTR_CLEARBIT0(ptr) ( ((bm::id_t)ptr) & ~(bm::id_t)1 )
00088 # define BMPTR_TESTBIT0(ptr) ( ((bm::id_t)ptr) & 1 )
00089
00090 # endif
00091
00092 # define BMGAP_PTR(ptr) ((bm::gap_word_t*)BMPTR_CLEARBIT0(ptr))
00093 # define BMSET_PTRGAP(ptr) ptr = (bm::word_t*)BMPTR_SETBIT0(ptr)
00094 # define BM_IS_GAP(obj, ptr, idx) ( BMPTR_TESTBIT0(ptr)!=0 )
00095
00096 #endif
00097
00098
00099
00100 #ifdef BM_HASRESTRICT
00101 # ifndef BMRESTRICT
00102 # define BMRESTRICT restrict
00103 # endif
00104 #else
00105 # ifndef BMRESTRICT
00106 # define BMRESTRICT
00107 # endif
00108 #endif
00109
00110
00111 #ifdef BM_HASFORCEINLINE
00112 # ifndef BMFORCEINLINE
00113 # define BMFORCEINLINE __forceinline
00114 # endif
00115 #else
00116 # define BMFORCEINLINE inline
00117 #endif
00118
00119
00120
00121
00122
00123
00124 #if !(defined(BMSSE2OPT) || defined(BMSSE42OPT))
00125
00126 # ifndef BM_SET_MMX_GUARD
00127 # define BM_SET_MMX_GUARD
00128 # endif
00129
00130 #define BM_ALIGN16
00131 #define BM_ALIGN16ATTR
00132
00133 #else
00134
00135 # ifndef BM_SET_MMX_GUARD
00136 # define BM_SET_MMX_GUARD sse_empty_guard bm_mmx_guard_;
00137 # endif
00138
00139 #ifdef _MSC_VER
00140
00141 #ifndef BM_ALIGN16
00142 # define BM_ALIGN16 __declspec(align(16))
00143 # define BM_ALIGN16ATTR
00144 #endif
00145
00146 # else // GCC
00147
00148 #ifndef BM_ALIGN16
00149 # define BM_ALIGN16
00150 # define BM_ALIGN16ATTR __attribute__((aligned(16)))
00151 #endif
00152
00153 #endif
00154
00155 #endif
00156
00157
00158
00159
00160
00161 #ifndef BM_INCWORD_BITCOUNT
00162
00163 #ifdef BMSSE42OPT
00164
00165 # define BM_INCWORD_BITCOUNT(cnt, w) cnt += _mm_popcnt_u32(w);
00166
00167 #else
00168
00169 # define BM_INCWORD_BITCOUNT(cnt, w) cnt += \
00170 bm::bit_count_table<true>::_count[(unsigned char)(w)] + \
00171 bm::bit_count_table<true>::_count[(unsigned char)((w) >> 8)] + \
00172 bm::bit_count_table<true>::_count[(unsigned char)((w) >> 16)] + \
00173 bm::bit_count_table<true>::_count[(unsigned char)((w) >> 24)];
00174
00175 #endif
00176
00177 #endif
00178
00179
00180
00181