changes towards being 64 bit clean
authorbdemsky <bdemsky>
Fri, 13 Feb 2009 22:25:42 +0000 (22:25 +0000)
committerbdemsky <bdemsky>
Fri, 13 Feb 2009 22:25:42 +0000 (22:25 +0000)
Robust/src/Runtime/chash.c
Robust/src/Runtime/chash.h
Robust/src/Runtime/checkpoint.c

index 924c14f4fe4070d415749905473a93f419a4e009..7c8d5c7da5d5a4efaf202d4d02e7c01c6ebb642c 100644 (file)
@@ -33,12 +33,12 @@ ctable_t *cCreate(unsigned int size, float loadfactor) {
 }
 
 //Store objects and their pointers into hash
-INLINE void cInsert(ctable_t *table, unsigned int key, void *val) {
+INLINE void cInsert(ctable_t *table, void * key, void *val) {
   unsigned int newsize;
   int index;
   cnode_t *ptr, *node;
 
-  ptr = &table->table[(key & table->mask)>>2];
+  ptr = &table->table[(((unsigned int)key) & table->mask)>>2];
   if (ptr->key==0) {
     ptr->key=key;
     ptr->val=val;
@@ -63,9 +63,9 @@ INLINE void cInsert(ctable_t *table, unsigned int key, void *val) {
 }
 
 // Search for an address for a given oid
-INLINE void * cSearch(ctable_t *table, unsigned int key) {
+INLINE void * cSearch(ctable_t *table, void * key) {
   //REMOVE HASH FUNCTION CALL TO MAKE SURE IT IS INLINED HERE
-  cnode_t *node = &table->table[(key & table->mask)>>2];
+  cnode_t *node = &table->table[(((unsigned int)key) & table->mask)>>2];
 
   while(node != NULL) {
     if(node->key == key) {
@@ -76,13 +76,13 @@ INLINE void * cSearch(ctable_t *table, unsigned int key) {
   return NULL;
 }
 
-unsigned int cRemove(ctable_t *table, unsigned int key) {
+unsigned int cRemove(ctable_t *table, void * key) {
   int index;
   cnode_t *curr, *prev;
   cnode_t *ptr, *node;
 
   ptr = table->table;
-  index =(key & table->mask)>>2;
+  index =(((unsigned int)key) & table->mask)>>2;
   curr = &ptr[index];
 
   for (; curr != NULL; curr = curr->next) {
@@ -128,7 +128,7 @@ unsigned int cResize(ctable_t *table, unsigned int newsize) {
       continue;
     while(curr!=NULL) {
       cnode_t * next = curr->next;
-      int index =(curr->key & mask)>>2;
+      int index =(((unsigned int)curr->key) & mask)>>2;
       cnode_t * newnode=&ntable[index];
 
       if(newnode->key==0) {
index 23a44247b1f4d60965bc047dbabc9a7b57e8e42d..ca256f22dda7f6caea4153bbb5581406c6d32876 100644 (file)
@@ -7,7 +7,7 @@
 //#define INLINE
 
 typedef struct cnode {
-  unsigned int key;
+  void * key;
   void *val;       //this can be cast to another type or used to point to a larger structure
   struct cnode *next;
   struct cnode *lnext;
@@ -25,9 +25,9 @@ typedef struct ctable {
 
 /* Prototypes for hash*/
 ctable_t *cCreate(unsigned int size, float loadfactor);
-void cInsert(ctable_t *table, unsigned int key, void * val);
-void * cSearch(ctable_t *table, unsigned int key); //returns val, NULL if not found
-unsigned int cRemove(ctable_t *table, unsigned int key); //returns -1 if not found
+void cInsert(ctable_t *table, void * key, void * val);
+void * cSearch(ctable_t *table, void * key); //returns val, NULL if not found
+unsigned int cRemove(ctable_t *table, void * key); //returns -1 if not found
 unsigned int cResize(ctable_t *table, unsigned int newsize);
 void cDelete(ctable_t *table);
 void crehash(ctable_t *table);
index 78d662d38bfeb3ec352d51939ee9f636e7852dae..1ac3507786b7688eb9e93add61b9169fff39d126 100644 (file)
@@ -131,12 +131,12 @@ void ** makecheckpoint(int numparams, void ** srcpointer, struct ctable * forwar
   for(i=0; i<numparams; i++) {
     void * objptr=srcpointer[i];
     void *dst;
-    if ((dst=cSearch(forward, (int) objptr))!=NULL)
+    if ((dst=cSearch(forward, objptr))!=NULL)
       newarray[i]=dst;
     else {
       void * copy=createcopy(objptr);
-      cInsert(forward, (int) objptr, copy);
-      cInsert(reverse, (int) copy, objptr);
+      cInsert(forward, objptr, copy);
+      cInsert(reverse, copy, objptr);
       addNewItem(todo, objptr);
       newarray[i]=copy;
     }
@@ -147,7 +147,7 @@ void ** makecheckpoint(int numparams, void ** srcpointer, struct ctable * forwar
     {
       void *cpy;
       unsigned int * pointer=NULL;
-      cpy=cSearch(forward, (unsigned int)ptr);
+      cpy=cSearch(forward, ptr);
 
       pointer=pointerarray[type];
 #ifdef TASK
@@ -155,10 +155,10 @@ void ** makecheckpoint(int numparams, void ** srcpointer, struct ctable * forwar
        void *objptr=((struct ___TagDescriptor___*)ptr)->flagptr;
        if (objptr!=NULL) {
          void *dst;
-         if ((dst=cSearch(forward, (unsigned int)objptr))==NULL) {
+         if ((dst=cSearch(forward, objptr))==NULL) {
            void *copy=createcopy(objptr);
-           cInsert(forward, (int) objptr, copy);
-           cInsert(reverse, (int) copy,  objptr);
+           cInsert(forward, objptr, copy);
+           cInsert(reverse, copy,  objptr);
            addNewItem(todo, objptr);
            ((struct ___TagDescriptor___*)cpy)->flagptr=copy;
          } else {
@@ -181,12 +181,12 @@ void ** makecheckpoint(int numparams, void ** srcpointer, struct ctable * forwar
          void *objptr=((void **)(((char *)&ao->___length___)+sizeof(int)))[i];
          if (objptr==NULL) {
            ((void **)(((char *)&ao_cpy->___length___)+sizeof(int)))[i]=NULL;
-         } else if ((dst=cSearch(forward, (int)objptr))!=NULL)
+         } else if ((dst=cSearch(forward,objptr))!=NULL)
            ((void **)(((char *)&ao_cpy->___length___)+sizeof(int)))[i]=dst;
          else {
            void * copy=createcopy(objptr);
-           cInsert(forward, (int) objptr, copy);
-           cInsert(reverse, (int) copy, objptr);
+           cInsert(forward, objptr, copy);
+           cInsert(reverse, copy, objptr);
            addNewItem(todo, objptr);
            ((void **)(((char *)&ao_cpy->___length___)+sizeof(int)))[i]=copy;
          }
@@ -200,12 +200,12 @@ void ** makecheckpoint(int numparams, void ** srcpointer, struct ctable * forwar
          void *dst;
          if (objptr==NULL) {
            *((void **)(((int)cpy)+offset))=NULL;
-         } else if ((dst=cSearch(forward, (unsigned int)objptr))!=NULL)
+         } else if ((dst=cSearch(forward, objptr))!=NULL)
            *((void **) &(((char *)cpy)[offset]))=dst;
          else {
            void * copy=createcopy(objptr);
-           cInsert(forward, (int) objptr, copy);
-           cInsert(reverse, (int) copy, objptr);
+           cInsert(forward, objptr, copy);
+           cInsert(reverse, copy, objptr);
            addNewItem(todo, objptr);
            *((void **)(((int)cpy)+offset))=copy;
          }
@@ -257,7 +257,7 @@ void restorecheckpoint(int numparams, void ** original, void ** checkpoint, stru
   for(i=0; i<numparams; i++) {
     if (checkpoint[i]!=NULL) {
       addNewItem(todo, checkpoint[i]);
-      cInsert(visited, (unsigned int) checkpoint[i], checkpoint[i]);
+      cInsert(visited, checkpoint[i], checkpoint[i]);
     }
   }
 
@@ -269,7 +269,7 @@ void restorecheckpoint(int numparams, void ** original, void ** checkpoint, stru
       void *cpy;
       unsigned int *pointer;
       int size;
-      cpy=cSearch(reverse, (int) ptr);
+      cpy=cSearch(reverse, ptr);
       pointer=pointerarray[type];
       size=classsize[type];
 #ifdef TASK
@@ -277,11 +277,11 @@ void restorecheckpoint(int numparams, void ** original, void ** checkpoint, stru
        void *objptr=((struct ___TagDescriptor___*)ptr)->flagptr;
        memcpy(cpy, ptr, size);
        if (objptr!=NULL) {
-         if (cSearch(visited, (unsigned int)objptr)==NULL) {
-           cInsert(visited, (int) objptr, objptr);
+         if (cSearch(visited, objptr)==NULL) {
+           cInsert(visited,  objptr, objptr);
            addNewItem(todo, objptr);
          }
-         *((void **) &(((struct ___TagDescriptor___ *)cpy)->flagptr))=cSearch(reverse, (int) objptr);
+         *((void **) &(((struct ___TagDescriptor___ *)cpy)->flagptr))=cSearch(reverse, objptr);
        }
       } else
 #endif
@@ -305,11 +305,11 @@ void restorecheckpoint(int numparams, void ** original, void ** checkpoint, stru
          if (objptr==NULL)
            ((void **)(((char *)&ao_cpy->___length___)+sizeof(int)))[i]=NULL;
          else {
-           if (cSearch(visited, (int) objptr)==NULL) {
-             cInsert(visited, (int) objptr, objptr);
+           if (cSearch(visited, objptr)==NULL) {
+             cInsert(visited,  objptr, objptr);
              addNewItem(todo, objptr);
            }
-           *((void **) &((void **)(((char *)&ao_cpy->___length___)+sizeof(int)))[i])=cSearch(reverse, (int) objptr);
+           *((void **) &((void **)(((char *)&ao_cpy->___length___)+sizeof(int)))[i])=cSearch(reverse, objptr);
          }
        }
       } else {
@@ -330,11 +330,11 @@ void restorecheckpoint(int numparams, void ** original, void ** checkpoint, stru
          if (objptr==NULL)
            *((void **)(((int)cpy)+offset))=NULL;
          else {
-           if (cSearch(visited, (int)objptr)==NULL) {
-             cInsert(visited, (int) objptr, objptr);
+           if (cSearch(visited, objptr)==NULL) {
+             cInsert(visited, objptr, objptr);
              addNewItem(todo, objptr);
            }
-           *((void **) &(((char *)cpy)[offset]))=cSearch(reverse, (int) objptr);
+           *((void **) &(((char *)cpy)[offset]))=cSearch(reverse, objptr);
          }
        }
        if (hasflags[type]) {