//Smallest Object Size with 1 ptr is 32bytes on on 64-bit machine and 24bytes on 32-bit machine
#ifdef BIT64
-#define _truncate_ >>5
+#define SHIFTBITS 5
#else
-#define _truncate_ /24
+#define SHIFTBITS 4
#endif
-
__thread dchashlistnode_t *dc_c_table;
__thread dchashlistnode_t *dc_c_list;
__thread dcliststruct_t *dc_c_structs;
dc_c_loadfactor = loadfactor;
dc_c_size = size;
dc_c_threshold=size*loadfactor;
- dc_c_mask = (size << 4)-1;
+ dc_c_mask = (size << SHIFTBITS)-1;
dc_c_structs=calloc(1, sizeof(dcliststruct_t));
dc_c_numelements = 0; // Initial number of elements in the hash
dc_c_list=NULL;
void hashRCRreset() {
dchashlistnode_t *ptr = dc_c_table;
- if (dc_c_numelements<(dc_c_size>>4)) {
+ if (dc_c_numelements<(dc_c_size>>SHIFTBITS)) {
dchashlistnode_t *top=&ptr[dc_c_size];
dchashlistnode_t *tmpptr=dc_c_list;
while(tmpptr!=NULL) {
unsigned int newsize = dc_c_size << 1;
hashRCRResize(newsize);
}
- ptr = &dc_c_table[(((unsigned INTPTR)key _truncate_ )&dc_c_mask)>>4];
+ ptr = &dc_c_table[(((unsigned INTPTR)key)&dc_c_mask)>>SHIFTBITS];
if(likely(ptr->key==0)) {
ptr->key=key;
ptr->lnext=dc_c_list;
dc_c_table = node; //Update the global hashtable upon resize()
dc_c_size = newsize;
dc_c_threshold = newsize * dc_c_loadfactor;
- mask=dc_c_mask = (newsize << 4)-1;
+ mask=dc_c_mask = (newsize << SHIFTBITS)-1;
for(i = 0; i < oldsize; i++) { //Outer loop for each bin in hash table
curr = &ptr[i];
break; //key = val =0 for element if not present within the hash table
}
- index = (((unsigned INTPTR)key _truncate_ ) & mask) >>4;
+ index = (((unsigned INTPTR)key) & mask) >>SHIFTBITS;
tmp=&node[index];
next = curr->next;
// Insert into the new table
// Search for an address for a given Address
INLINE int hashRCRSearch(void * key) {
//REMOVE HASH FUNCTION CALL TO MAKE SURE IT IS INLINED HERE
- dchashlistnode_t *node = &dc_c_table[(((unsigned INTPTR)key _truncate_) & dc_c_mask)>>4];
+ dchashlistnode_t *node = &dc_c_table[(((unsigned INTPTR)key) & dc_c_mask)>>SHIFTBITS];
do {
if(node->key == key) {