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