Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Namespace Members | Data Fields | Globals | Examples

bmdef.h

Go to the documentation of this file.
00001 // Copyright(c) 2002-2005 Anatoliy Kuznetsov(anatoliy_kuznetsov at yahoo.com)
00002 
00003 
00004 // BM library internal header
00005 //
00006 // Set all required preprocessor defines
00007 
00008 
00009 
00010 #ifndef BM_ASSERT
00011 
00012 # ifndef BM_NOASSERT
00013 #  include <assert.h>
00014 #  define BM_ASSERT assert
00015 # else
00016 #  define BM_ASSERT(x)
00017 # endif
00018 
00019 #endif
00020 
00021 
00022 #define FULL_BLOCK_ADDR all_set<true>::_block._p
00023 #define IS_VALID_ADDR(addr) (addr && (addr != FULL_BLOCK_ADDR))
00024 #define IS_FULL_BLOCK(addr) (addr == FULL_BLOCK_ADDR)
00025 #define IS_EMPTY_BLOCK(addr) (addr == 0)
00026 
00027 // Macro definitions to manipulate bits in pointers
00028 // This trick is based on the fact that pointers allocated by malloc are
00029 // aligned and bit 0 is never set. It means we are safe to use it.
00030 // BM library keeps GAP flag in pointer.
00031 
00032 // Note: this hack is not universally portable so if it does not work
00033 // in some particular case disable it by defining BM_DISBALE_BIT_IN_PTR
00034 
00035 #ifdef BM_DISBALE_BIT_IN_PTR
00036 
00037 # define BMGAP_PTR(ptr)    ((bm::gap_word_t*)ptr)
00038 # define BMSET_PTRGAP(ptr) (void(0))
00039 # define BM_IS_GAP(obj, ptr, idx) ( obj.is_block_gap(idx) ) 
00040 
00041 #else
00042 
00043 # if ULONG_MAX != 0xffffffff || defined(_WIN64)  // 64-bit
00044 
00045 #  define BMPTR_SETBIT0(ptr)   ( ((bm::id64_t)ptr) | 1 )
00046 #  define BMPTR_CLEARBIT0(ptr) ( ((bm::id64_t)ptr) & ~(bm::id64_t)1 )
00047 #  define BMPTR_TESTBIT0(ptr)  ( ((bm::id64_t)ptr) & 1 )
00048 
00049 # else // 32-bit
00050 
00051 #  define BMPTR_SETBIT0(ptr)   ( ((bm::id_t)ptr) | 1 )
00052 #  define BMPTR_CLEARBIT0(ptr) ( ((bm::id_t)ptr) & ~(bm::id_t)1 )
00053 #  define BMPTR_TESTBIT0(ptr)  ( ((bm::id_t)ptr) & 1 )
00054 
00055 # endif
00056 
00057 # define BMGAP_PTR(ptr) ((bm::gap_word_t*)BMPTR_CLEARBIT0(ptr))
00058 # define BMSET_PTRGAP(ptr) ptr = (bm::word_t*)BMPTR_SETBIT0(ptr)
00059 # define BM_IS_GAP(obj, ptr, idx) ( BMPTR_TESTBIT0(ptr)!=0 )
00060 
00061 #endif
00062 
00063 
00064 
00065 #ifdef BM_HASRESTRICT
00066 # ifndef BMRESTRICT
00067 #  define BMRESTRICT restrict
00068 # endif
00069 #else
00070 # define BMRESTRICT 
00071 #endif
00072 
00073 
00074 #ifdef BM_HASFORCEINLINE
00075 # ifndef BMFORCEINLINE
00076 #  define BMFORCEINLINE __forceinline
00077 # endif
00078 #else
00079 # define BMFORCEINLINE inline
00080 #endif
00081 
00082 
00083 
00084 #ifndef BMSSE2OPT
00085 
00086 # ifndef BM_SET_MMX_GUARD
00087 #  define BM_SET_MMX_GUARD
00088 # endif
00089 
00090 #else
00091 
00092 # ifndef BM_SET_MMX_GUARD
00093 #  define BM_SET_MMX_GUARD  sse2_empty_guard  bm_mmx_guard_;
00094 # endif
00095 
00096 #endif
00097 

Generated on Thu Apr 20 13:28:46 2006 for BitMagic by  doxygen 1.4.1