From d5bbfe5c356f1ca25e6026081a863a78b24f2d2c Mon Sep 17 00:00:00 2001 From: bdemsky Date: Fri, 13 Feb 2009 22:25:42 +0000 Subject: [PATCH] changes towards being 64 bit clean --- Robust/src/Runtime/chash.c | 14 +++++----- Robust/src/Runtime/chash.h | 8 +++--- Robust/src/Runtime/checkpoint.c | 48 ++++++++++++++++----------------- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/Robust/src/Runtime/chash.c b/Robust/src/Runtime/chash.c index 924c14f4..7c8d5c7d 100644 --- a/Robust/src/Runtime/chash.c +++ b/Robust/src/Runtime/chash.c @@ -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) { diff --git a/Robust/src/Runtime/chash.h b/Robust/src/Runtime/chash.h index 23a44247..ca256f22 100644 --- a/Robust/src/Runtime/chash.h +++ b/Robust/src/Runtime/chash.h @@ -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); diff --git a/Robust/src/Runtime/checkpoint.c b/Robust/src/Runtime/checkpoint.c index 78d662d3..1ac35077 100644 --- a/Robust/src/Runtime/checkpoint.c +++ b/Robust/src/Runtime/checkpoint.c @@ -131,12 +131,12 @@ void ** makecheckpoint(int numparams, void ** srcpointer, struct ctable * forwar for(i=0; iflagptr; 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; iflagptr; 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]) { -- 2.34.1