Accidentally checked in code.
authorbdemsky <bdemsky>
Thu, 28 Oct 2004 19:30:54 +0000 (19:30 +0000)
committerbdemsky <bdemsky>
Thu, 28 Oct 2004 19:30:54 +0000 (19:30 +0000)
Repair/RepairCompiler/MCC/Runtime/SimpleHash.c [deleted file]
Repair/RepairCompiler/MCC/Runtime/instrument.c [deleted file]
Repair/RepairCompiler/MCC/Runtime/tmap.c [deleted file]

diff --git a/Repair/RepairCompiler/MCC/Runtime/SimpleHash.c b/Repair/RepairCompiler/MCC/Runtime/SimpleHash.c
deleted file mode 100755 (executable)
index b238c22..0000000
+++ /dev/null
@@ -1,594 +0,0 @@
-#include "SimpleHash.h"
-#include <stdio.h>
-
-/* LINKED HASH NODE ****************************************************/
-
-struct LinkedHashNode * allocateLinkedHashNode(int key, int data, struct LinkedHashNode *next) {
-    struct LinkedHashNode *thisvar=(struct LinkedHashNode *)malloc(sizeof(struct LinkedHashNode));
-    thisvar->key = key;
-    thisvar->data = data;
-    thisvar->next = next;
-    thisvar->lnext=0;
-    thisvar->lprev=0;
-    return thisvar;
-}
-
-struct LinkedHashNode * noargallocateLinkedHashNode() {
-    struct LinkedHashNode *thisvar=(struct LinkedHashNode *)malloc(sizeof(struct LinkedHashNode));
-    thisvar->key = -1;
-    thisvar->data = -1;
-    thisvar->next = 0;
-    thisvar->lnext=0;
-    thisvar->lprev=0;
-    return thisvar;
-}
-
-/* SIMPLE LIST ****************************************************/
-
-struct SimpleList * allocateSimpleList() {
-    struct SimpleList *thisvar=(struct SimpleList *)malloc(sizeof(struct SimpleList));
-    thisvar->ptr = 0;
-    thisvar->head.next = 0;
-    return thisvar;
-}
-
-void SimpleListreset(struct SimpleList *thisvar) {
-    thisvar->ptr = &thisvar->head;
-}
-
-int SimpleListhasMoreElements(struct SimpleList *thisvar) {
-    return (thisvar->ptr->next != 0);
-}
-
-int SimpleListnextElement(struct SimpleList *thisvar) {
-  thisvar->ptr = thisvar->ptr->next;
-  return thisvar->ptr->data;
-}
-
-void SimpleListadd(struct SimpleList *thisvar,int data) {
-    struct LinkedHashNode *cur = &thisvar->head;
-    while (cur->next) {
-        cur = cur->next;
-        if (cur->data == data) {
-            return; /* no duplicates */
-        }
-    }
-    cur->next = allocateLinkedHashNode(0, data, 0);
-    return;
-}
-
-int SimpleListcontains(struct SimpleList *thisvar,int data) {
-    struct LinkedHashNode *cur = &thisvar->head;
-    while (cur->next) {
-        cur = cur->next;
-        if (cur->data == data) {
-            return 1; /* found! */
-        }
-    }
-    return 0;
-}
-
-/* WORK LIST ****************************************************/
-
-struct WorkList * allocateWorkList() {
-    struct WorkList *thisvar=(struct WorkList *)malloc(sizeof(struct WorkList));
-    thisvar->head=(struct ListNode *) malloc(sizeof(struct ListNode));
-    thisvar->tail=thisvar->head;
-    thisvar->head->next=0;
-    thisvar->headoffset=0;
-    thisvar->tailoffset=0;
-    return thisvar;
-}
-
-void WorkListreset(struct WorkList *thisvar) {
-    thisvar->head=thisvar->tail;
-    thisvar->headoffset=0;
-    thisvar->tailoffset=0;
-}
-
-int WorkListhasMoreElements(struct WorkList *thisvar) {
-  return ((thisvar->head!=thisvar->tail)||(thisvar->headoffset!=thisvar->tailoffset));
-}
-
-int WorkListgetid(struct WorkList *thisvar) {
-  return thisvar->tail->data[thisvar->tailoffset];
-}
-
-int WorkListgettype(struct WorkList *thisvar) {
-  return thisvar->tail->data[thisvar->tailoffset+1];
-}
-
-int WorkListgetlvalue(struct WorkList *thisvar) {
-  return thisvar->tail->data[thisvar->tailoffset+2];
-}
-
-int WorkListgetrvalue(struct WorkList *thisvar) {
-  return thisvar->tail->data[thisvar->tailoffset+3];
-}
-
-void freeWorkList(struct WorkList *thisvar) {
-  struct ListNode *ptr=thisvar->tail;
-  while(ptr) {
-    struct ListNode *oldptr=ptr;
-    ptr=ptr->next;
-    free(oldptr);
-  }
-  free(thisvar);
-}
-
-void WorkListpop(struct WorkList *thisvar) {
-  int newoffset=thisvar->tailoffset+4;
-  struct ListNode *ptr=thisvar->tail;
-  if (newoffset>=WLISTSIZE) {
-    if (newoffset!=WLISTSIZE||thisvar->head!=thisvar->tail) {
-      struct ListNode *oldptr=ptr;
-      newoffset-=WLISTSIZE;
-      ptr=ptr->next;
-      free(oldptr);
-    }
-  }
-  thisvar->tail=ptr;
-  thisvar->tailoffset=newoffset;
-}
-
-void WorkListadd(struct WorkList *thisvar, int id,int type, int lvalue, int rvalue) {
-  if (thisvar->headoffset==WLISTSIZE) {
-    if (thisvar->head->next==0) {
-      thisvar->head->next=(struct ListNode *)malloc(sizeof(struct ListNode));
-      thisvar->head->next->next=0;
-    }
-    thisvar->headoffset=0;
-    thisvar->head=thisvar->head->next;
-    if (thisvar->tailoffset==WLISTSIZE) { /* roll the tail over also */
-        thisvar->tailoffset=0;
-        thisvar->tail=thisvar->tail->next;
-    }
-  }
-  thisvar->head->data[thisvar->headoffset++]=id;
-  thisvar->head->data[thisvar->headoffset++]=type;
-  thisvar->head->data[thisvar->headoffset++]=lvalue;
-  thisvar->head->data[thisvar->headoffset++]=rvalue;
-}
-
-/* SIMPLE HASH ********************************************************/
-struct SimpleIterator* createiterator(struct SimpleHash * thisvar) {
-    return allocateSimpleIterator(thisvar->listhead,thisvar->listtail,thisvar->tailindex/*,thisvar*/);
-}
-
-void iterator(struct SimpleHash *thisvar, struct SimpleIterator * it) {
-  it->cur=thisvar->listhead;
-  it->index=0;
-  it->tailindex=thisvar->tailindex;
-  it->tail=thisvar->listtail;
-}
-
-struct SimpleHash * noargallocateSimpleHash() {
-    return allocateSimpleHash(100);
-}
-
-struct SimpleHash * allocateSimpleHash(int size) {
-    struct SimpleHash *thisvar=(struct SimpleHash *)malloc(sizeof(struct SimpleHash));
-    if (size <= 0) {
-        printf("Negative Hashtable size Exception\n");
-        exit(-1);
-    }
-    thisvar->size = size;
-    thisvar->bucket = (struct SimpleNode **) calloc(sizeof(struct SimpleNode *)*size,1);
-    /* Set allocation blocks*/
-    thisvar->listhead=(struct ArraySimple *) calloc(sizeof(struct ArraySimple),1);
-    thisvar->listtail=thisvar->listhead;
-    thisvar->tailindex=0;
-    /*Set data counts*/
-    thisvar->numparents = 0;
-    thisvar->numchildren = 0;
-    thisvar->numelements = 0;
-    return thisvar;
-}
-
-void freeSimpleHash(struct SimpleHash *thisvar) {
-    struct ArraySimple *ptr=thisvar->listhead;
-    free(thisvar->bucket);
-    while(ptr) {
-        struct ArraySimple *next=ptr->nextarray;
-        free(ptr);
-        ptr=next;
-    }
-    free(thisvar);
-}
-
-int SimpleHashfirstkey(struct SimpleHash *thisvar) {
-  struct ArraySimple *ptr=thisvar->listhead;
-  int index=0;
-  while((index==ARRAYSIZE)||!ptr->nodes[index].inuse) {
-    if (index==ARRAYSIZE) {
-      index=0;
-      ptr=ptr->nextarray;
-    } else
-      index++;
-  }
-  return ptr->nodes[index].key;
-}
-
-void SimpleHashaddParent(struct SimpleHash *thisvar,struct SimpleHash* parent) {
-    thisvar->parents[thisvar->numparents++] = parent;
-    SimpleHashaddChild(parent,thisvar);
-}
-
-void SimpleHashaddChild(struct SimpleHash *thisvar, struct SimpleHash *child) {
-    thisvar->children[thisvar->numchildren++]=child;
-}
-
-int SimpleHashremove(struct SimpleHash *thisvar, int key, int data) {
-    unsigned int hashkey = (unsigned int)key % thisvar->size;
-
-    struct SimpleNode **ptr = &thisvar->bucket[hashkey];
-    int i;
-    for (i = 0; i < thisvar->numchildren; i++) {
-        SimpleHashremove(thisvar->children[i], key, data);
-    }
-
-    while (*ptr) {
-        if ((*ptr)->key == key && (*ptr)->data == data) {
-         struct SimpleNode *toremove=*ptr;
-         *ptr=(*ptr)->next;
-
-         toremove->inuse=0; /* Marked as unused */
-
-         thisvar->numelements--;
-         return 1;
-        }
-        ptr = &((*ptr)->next);
-    }
-
-    return 0;
-}
-
-void SimpleHashaddAll(struct SimpleHash *thisvar, struct SimpleHash * set) {
-    struct SimpleIterator it;
-    SimpleHashiterator(set, &it);
-    while(hasNext(&it)) {
-        int keyv=key(&it);
-        int data=next(&it);
-        SimpleHashadd(thisvar,keyv,data);
-    }
-}
-
-int SimpleHashadd(struct SimpleHash * thisvar,int key, int data) {
-  /* Rehash code */
-  unsigned int hashkey;
-  struct SimpleNode **ptr;
-
-  if (thisvar->numelements>=thisvar->size) {
-    int newsize=2*thisvar->size+1;
-    struct SimpleNode ** newbucket = (struct SimpleNode **) calloc(sizeof(struct SimpleNode *)*newsize,1);
-    int i;
-    for(i=thisvar->size-1;i>=0;i--) {
-        struct SimpleNode *ptr;
-        for(ptr=thisvar->bucket[i];ptr!=NULL;) {
-            struct SimpleNode * nextptr=ptr->next;
-            unsigned int newhashkey=(unsigned int)ptr->key % newsize;
-            ptr->next=newbucket[newhashkey];
-            newbucket[newhashkey]=ptr;
-            ptr=nextptr;
-        }
-    }
-    thisvar->size=newsize;
-    free(thisvar->bucket);
-    thisvar->bucket=newbucket;
-  }
-
-  hashkey = (unsigned int)key % thisvar->size;
-  ptr = &thisvar->bucket[hashkey];
-
-  /* check that thisvar key/object pair isn't already here */
-  /* TBD can be optimized for set v. relation */
-
-  while (*ptr) {
-    if ((*ptr)->key == key && (*ptr)->data == data) {
-      return 0;
-    }
-    ptr = &((*ptr)->next);
-  }
-  if (thisvar->tailindex==ARRAYSIZE) {
-    thisvar->listtail->nextarray=(struct ArraySimple *) calloc(sizeof(struct ArraySimple),1);
-    thisvar->tailindex=0;
-    thisvar->listtail=thisvar->listtail->nextarray;
-  }
-
-  *ptr = &thisvar->listtail->nodes[thisvar->tailindex++];
-  (*ptr)->key=key;
-  (*ptr)->data=data;
-  (*ptr)->inuse=1;
-
-  thisvar->numelements++;
-  {
-      int i;
-      for (i = 0; i < thisvar->numparents; i++) {
-          SimpleHashadd(thisvar->parents[i], key, data);
-      }
-  }
-  return 1;
-}
-
-bool SimpleHashcontainskey(struct SimpleHash *thisvar,int key) {
-    unsigned int hashkey = (unsigned int)key % thisvar->size;
-
-    struct SimpleNode *ptr = thisvar->bucket[hashkey];
-    while (ptr) {
-        if (ptr->key == key) {
-            /* we already have thisvar object
-               stored in the hash so just return */
-            return true;
-        }
-        ptr = ptr->next;
-    }
-    return false;
-}
-
-bool SimpleHashcontainskeydata(struct SimpleHash *thisvar, int key, int data) {
-    unsigned int hashkey = (unsigned int)key % thisvar->size;
-
-    struct SimpleNode *ptr = thisvar->bucket[hashkey];
-    while (ptr) {
-        if (ptr->key == key && ptr->data == data) {
-            /* we already have thisvar object
-               stored in the hash so just return*/
-            return true;
-        }
-        ptr = ptr->next;
-    }
-    return false;
-}
-
-int SimpleHashcount(struct SimpleHash *thisvar,int key) {
-    unsigned int hashkey = (unsigned int)key % thisvar->size;
-    int count = 0;
-
-    struct SimpleNode *ptr = thisvar->bucket[hashkey];
-    while (ptr) {
-        if (ptr->key == key) {
-            count++;
-        }
-        ptr = ptr->next;
-    }
-    return count;
-}
-
-struct SimpleHash * SimpleHashimageSet(struct SimpleHash *thisvar, int key) {
-  struct SimpleHash * newset=allocateSimpleHash(2*SimpleHashcount(thisvar,key)+4);
-  unsigned int hashkey = (unsigned int)key % thisvar->size;
-
-  struct SimpleNode *ptr = thisvar->bucket[hashkey];
-  while (ptr) {
-    if (ptr->key == key) {
-        SimpleHashadd(newset,ptr->data,ptr->data);
-    }
-    ptr = ptr->next;
-  }
-  return newset;
-}
-
-int SimpleHashget(struct SimpleHash *thisvar, int key, int *data) {
-    unsigned int hashkey = (unsigned int)key % thisvar->size;
-
-    struct SimpleNode *ptr = thisvar->bucket[hashkey];
-    while (ptr) {
-        if (ptr->key == key) {
-            *data = ptr->data;
-            return 1; /* success */
-        }
-        ptr = ptr->next;
-    }
-
-    return 0; /* failure */
-}
-
-int SimpleHashcountdata(struct SimpleHash *thisvar,int data) {
-    int count = 0;
-    struct ArraySimple *ptr = thisvar->listhead;
-    while(ptr) {
-      if (ptr->nextarray) {
-          int i;
-          for(i=0;i<ARRAYSIZE;i++)
-              if (ptr->nodes[i].data == data
-                  &&ptr->nodes[i].inuse) {
-                  count++;
-              }
-      } else {
-          int i;
-          for(i=0;i<thisvar->tailindex;i++)
-              if (ptr->nodes[i].data == data
-                  &&ptr->nodes[i].inuse) {
-                  count++;
-              }
-      }
-      ptr = ptr->nextarray;
-    }
-    return count;
-}
-
-struct RepairHashNode * allocateRepairHashNode(int setrelation, int rule, int lvalue, int rvalue, int data, int data2, int ismodify){
-    struct RepairHashNode * thisvar=(struct RepairHashNode *)malloc(sizeof(struct RepairHashNode));
-    thisvar->setrelation = setrelation;
-    thisvar->lvalue=lvalue;
-    thisvar->rvalue=rvalue;
-    thisvar->data = data;
-    thisvar->data2 = data2;
-    thisvar->next = 0;
-    thisvar->lnext=0;
-    thisvar->rule=rule;
-    thisvar->ismodify=ismodify;
-    return thisvar;
-}
-
-struct RepairHash * allocateRepairHash(int size) {
-    struct RepairHash *thisvar=(struct RepairHash*)malloc(sizeof(struct RepairHash));
-    if (size <= 0) {
-        printf("Negative size for RepairHash\n");
-        exit(-1);
-    }
-
-    thisvar->size = size;
-    thisvar->bucket = (struct RepairHashNode **) calloc(1,sizeof(struct RepairHashNode*)*size);
-    thisvar->nodelist=0;
-    thisvar->numelements = 0;
-    return thisvar;
-}
-
-#define REPAIRSIZE 100
-struct RepairHash * noargallocateRepairHash() {
-    return allocateRepairHash(REPAIRSIZE);
-}
-
-void freeRepairHash(struct RepairHash *thisvar) {
-  struct RepairHashNode *ptr=thisvar->nodelist;
-  free(thisvar->bucket);
-  while(ptr) {
-      struct RepairHashNode *next=ptr->lnext;
-      free(ptr);
-      ptr=next;
-  }
-  free(thisvar);
-}
-
-#define SETFLAG (1<<31)
-
-int addset(struct RepairHash *thisvar, int setv, int rule, int value, int data) {
-  return addrelation(thisvar, setv||SETFLAG, rule, value,0,data);
-}
-
-int addrelation(struct RepairHash *thisvar, int relation, int rule, int lvalue, int rvalue, int data) {
-    unsigned int hashkey = ((unsigned int)(relation ^ rule ^ lvalue ^ rvalue)) % thisvar->size;
-
-    struct RepairHashNode **ptr = &thisvar->bucket[hashkey];
-
-    /* check that thisvar key/object pair isn't already here */
-    /* TBD can be optimized for set v. relation */
-    while (*ptr) {
-        if ((*ptr)->setrelation == relation &&
-           (*ptr)->rule==rule &&
-           (*ptr)->lvalue==lvalue &&
-           (*ptr)->rvalue==rvalue &&
-           (*ptr)->data == data&&
-           (*ptr)->data2 == 0) {
-            return 0;
-        }
-        ptr = &((*ptr)->next);
-    }
-
-    *ptr = allocateRepairHashNode(relation,rule,lvalue,rvalue, data,0,0);
-    (*ptr)->lnext=thisvar->nodelist;
-    thisvar->nodelist=*ptr;
-    thisvar->numelements++;
-    return 1;
-}
-
-int addrelation2(struct RepairHash *thisvar, int relation, int rule, int lvalue, int rvalue, int data, int data2) {
-    unsigned int hashkey = ((unsigned int)(relation ^ rule ^ lvalue ^ rvalue)) % thisvar->size;
-
-    struct RepairHashNode **ptr = &thisvar->bucket[hashkey];
-
-    /* check that thisvar key/object pair isn't already here */
-    /* TBD can be optimized for set v. relation */
-    while (*ptr) {
-        if ((*ptr)->setrelation == relation &&
-           (*ptr)->rule==rule &&
-           (*ptr)->lvalue==lvalue &&
-           (*ptr)->rvalue==rvalue &&
-           (*ptr)->data == data &&
-           (*ptr)->data2 == data2) {
-            return 0;
-        }
-        ptr = &((*ptr)->next);
-    }
-
-    *ptr = allocateRepairHashNode(relation,rule,lvalue,rvalue, data,data2,1);
-    (*ptr)->lnext=thisvar->nodelist;
-    thisvar->nodelist=*ptr;
-    thisvar->numelements++;
-    return 1;
-}
-
-bool containsset(struct RepairHash *thisvar, int setv, int rule, int value) {
-  return containsrelation(thisvar, setv||SETFLAG, rule, value,0);
-}
-
-bool containsrelation(struct RepairHash *thisvar, int relation, int rule, int lvalue, int rvalue) {
-    unsigned int hashkey = ((unsigned int)(relation ^ rule ^ lvalue ^ rvalue)) % thisvar->size;
-
-    struct RepairHashNode **ptr = &thisvar->bucket[hashkey];
-
-    /* check that thisvar key/object pair isn't already here */
-    /*  TBD can be optimized for set v. relation */
-    while (*ptr) {
-        if ((*ptr)->setrelation == relation &&
-           (*ptr)->rule==rule &&
-           (*ptr)->lvalue==lvalue &&
-           (*ptr)->rvalue==rvalue) {
-            return true;
-        }
-        ptr = &((*ptr)->next);
-    }
-    return false;
-}
-
-int getset(struct RepairHash *thisvar, int setv, int rule, int value) {
-  return getrelation(thisvar, setv||SETFLAG, rule, value,0);
-}
-
-int ismodify(struct RepairHash *thisvar, int relation, int rule, int lvalue,int rvalue) {
-    unsigned int hashkey = ((unsigned int)(relation ^ rule ^ lvalue ^ rvalue)) % thisvar->size;
-
-    struct RepairHashNode **ptr = &thisvar->bucket[hashkey];
-
-    /* check that thisvar key/object pair isn't already here */
-    /* TBD can be optimized for set v. relation */
-    while (*ptr) {
-        if ((*ptr)->setrelation == relation &&
-           (*ptr)->rule==rule &&
-           (*ptr)->lvalue==lvalue &&
-           (*ptr)->rvalue==rvalue) {
-         return (*ptr)->ismodify;
-        }
-        ptr = &((*ptr)->next);
-    }
-    return 0;
-}
-
-int getrelation2(struct RepairHash *thisvar, int relation, int rule, int lvalue,int rvalue) {
-    unsigned int hashkey = ((unsigned int)(relation ^ rule ^ lvalue ^ rvalue)) % thisvar->size;
-
-    struct RepairHashNode **ptr = &thisvar->bucket[hashkey];
-
-    /* check that thisvar key/object pair isn't already here */
-    /* TBD can be optimized for set v. relation */
-    while (*ptr) {
-        if ((*ptr)->setrelation == relation &&
-           (*ptr)->rule==rule &&
-           (*ptr)->lvalue==lvalue &&
-           (*ptr)->rvalue==rvalue) {
-         return (*ptr)->data2;
-        }
-        ptr = &((*ptr)->next);
-    }
-    return 0;
-}
-
-int getrelation(struct RepairHash *thisvar, int relation, int rule, int lvalue,int rvalue) {
-    unsigned int hashkey = ((unsigned int)(relation ^ rule ^ lvalue ^ rvalue)) % thisvar->size;
-
-    struct RepairHashNode **ptr = &thisvar->bucket[hashkey];
-
-    /* check that this key/object pair isn't already here */
-    /* TBD can be optimized for set v. relation */
-    while (*ptr) {
-        if ((*ptr)->setrelation == relation &&
-           (*ptr)->rule==rule &&
-           (*ptr)->lvalue==lvalue &&
-           (*ptr)->rvalue==rvalue) {
-         return (*ptr)->data;
-        }
-        ptr = &((*ptr)->next);
-    }
-    return 0;
-}
diff --git a/Repair/RepairCompiler/MCC/Runtime/instrument.c b/Repair/RepairCompiler/MCC/Runtime/instrument.c
deleted file mode 100755 (executable)
index 66aef0d..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Defines interfaces for the applications and exports function calls that
-   the applications should use instead of the standard ones. */
-
-#include <stdlib.h>
-#include <sys/time.h>
-
-#include "instrument.h"
-#include <stdio.h>
-#include "tmap.h"
-#include "size.h"
-
-struct typemap * memmap;
-
-void *ourcalloc(size_t nmemb, size_t size) {
-  void *oc=calloc(nmemb,size);
-  typemapallocate(memmap, oc,size*nmemb);
-  return oc;
-}
-
-void *ourmalloc(size_t size) {
-  void *oc=malloc(size);
-  typemapallocate(memmap, oc,size);
-  return oc;
-}
-
-void ourfree(void *ptr) {
-  typemapdeallocate(memmap, ptr);
-  free(ptr);
-}
-
-void *ourrealloc(void *ptr, size_t size) {
-  void *orr=realloc(ptr,size);
-  if (size==0) {
-    typemapdeallocate(memmap, ptr);
-    return orr;
-  }
-  if (orr==NULL) {
-    return orr;
-  }
-  typemapdeallocate(memmap, ptr);
-  typemapallocate(memmap, ptr,size);
-}
-
-void alloc(void *ptr,int size) {
-  typemapallocate(memmap, ptr,size);
-}
-
-void dealloc(void *ptr) {
-  typemapdeallocate(memmap, ptr);
-}
-
-void initializemmap() {
-  memmap=allocatetypemap();
-}
-
-void resettypemap() {
-  typemapreset(memmap);
-}
-
-bool assertvalidtype(int ptr, int structure) {
-  return typemapasserttype(memmap, (void *)ptr, structure);
-}
-bool assertvalidmemory(int ptr, int structure) {
-  return typemapassertvalidmemory(memmap, (void *)ptr, structure);
-}
-
-void initializestack(void *high) {
-  initializetypemapstack(memmap, high);
-}
diff --git a/Repair/RepairCompiler/MCC/Runtime/tmap.c b/Repair/RepairCompiler/MCC/Runtime/tmap.c
deleted file mode 100755 (executable)
index 2e1a818..0000000
+++ /dev/null
@@ -1,241 +0,0 @@
-#include <stdio.h>
-#include "tmap.h"
-#include "size.h"
-#include "stack.h"
-#include <stdlib.h>
-
-#define CHECKTYPE
-#define CHECKMEMORY
-
-struct typemap * allocatetypemap() {
-  struct typemap *thisvar=(struct typemap *) malloc(sizeof(struct typemap));
-  thisvar->alloctree=rbinit();
-  thisvar->typetree=rbinit();
-  thisvar->low=GC_linux_stack_base();
-}
-
-void freefunction(void *ptr) {
-  if(ptr!=NULL) {
-    free((struct structuremap *)ptr);
-  }
-}
-
-void freetypemap(struct typemap * ptr) {
-  rbdestroy(ptr->typetree,freefunction);
-  rbdestroy(ptr->alloctree,freefunction);
-  free(ptr);
-}
-
-void typemapreset(struct typemap *ptr) {
-  rbdestroy(ptr->typetree,freefunction);
-  ptr->typetree=rbinit();
-  if (ptr->low<ptr->high)
-    rbdelete(ptr->low,ptr->alloctree);
-  else
-    rbdelete(ptr->high,ptr->alloctree);
-}
-
-void initializetypemapstack(struct typemap * ptr, void *high) {
-  ptr->high=high;
-  if (ptr->low<ptr->high)
-    rbinsert(ptr->low,ptr->high,NULL,ptr->alloctree);
-  else
-    rbinsert(ptr->high,ptr->low,NULL,ptr->alloctree);
-}
-
-struct structuremap * allocatestructuremap(int s) {
-  struct structuremap *ptr=(struct structuremap *)malloc(sizeof(struct structuremap));
-  ptr->str=s;
-  ptr->typetree=rbinit();
-  return ptr;
-}
-
-void freestructuremap(struct structuremap *ptr) {
-  rbdestroy(ptr->typetree,freefunction);
-  free(ptr);
-}
-
-bool typemapasserttype(struct typemap *thisvar, void *ptr, int s) {
-  int toadd=sizeBytes(s);
-  return typemapasserttypeB(thisvar, ptr,((char *) ptr)+toadd,s);
-}
-
-bool typemapasserttypeB(struct typemap * thisvar, void *ptr, void *high, int s) {
-#ifdef CHECKTYPE
-  bool b=typemapchecktype(thisvar,true,ptr,s);
-  if (!b) {
-    printf("Assertion failure\n");
-    {
-      bool testb=typemapchecktype(thisvar,true,ptr,s);
-    }
-  }
-  return b;
-#endif
-  return typemapassertvalidmemoryB(thisvar,ptr, high);
-}
-
-bool typemapassertvalidmemory(struct typemap * thisvar, void* low, int s) {
-  int toadd=sizeBytes(s);
-  return typemapassertvalidmemoryB(thisvar, low,((char *)low)+toadd);
-}
-
-bool typemapassertvalidmemoryB(struct typemap * thisvar, void* low, void* high) {
-#ifdef CHECKMEMORY
-  return typemapcheckmemory(thisvar, low, high);
-#endif
-  return true;
-}
-
-bool typemapistype(struct typemap *thisvar, void *ptr, void *high, int s) {
-#ifdef CHECKTYPE
-  bool b=typemapchecktype(thisvar, false,ptr,s);
-  if (!b) {
-    printf("Verify failure\n");
-    {
-      bool testb=typemapchecktype(thisvar, false,ptr,s);
-    }
-  }
-  return b;
-#endif
-  return typemapassertvalidmemoryB(thisvar, ptr, high);
-}
-
-void typemapallocate(struct typemap *thisvar,void *ptr, int size) {
-  void *low=ptr;
-  void *high=((char *)ptr)+size;
-  int val=rbinsert(low,high,NULL,thisvar->alloctree);
-  if (val==0)
-    printf("Error\n");
-}
-
-inline int sizeinbytes(unsigned int bits) {
-  int bytes=bits>>3;
-  if (bits %8)
-    bytes++;
-  return bytes;
-}
-
-int typemapfindoffsetstructure(struct typemap * thisvar, int s, int offset) {
-  int count=0;
-  int i;
-  int increment;
-  for(i=0;i<getnumfields(s);i++) {
-    int mult=1;
-    int ttype=getfield(s,i);
-    if (isArray(s,i)) {
-      mult=numElements(s,i);
-    }
-    increment=size(ttype);
-    if (increment%8) {
-      int delt=offset-count;
-      int byteincrement=increment/8;
-      if (delt<mult*byteincrement) {
-       if (delt%byteincrement==0) {
-         return ttype;
-       } else
-         return -1;
-      }
-    } else {
-      if ((count+sizeinbytes(mult*increment))>offset)
-       return -1;
-    }
-    count+=sizeinbytes(mult*increment);
-  }
-  return -1;
-}
-
-void typemapdeallocate(struct typemap * thisvar,void *ptr) {
-  if (rbdelete(ptr,thisvar->alloctree)==NULL)
-    printf("Freeing unallocated memory\n");
-}
-
-bool typemapcheckmemory(struct typemap *thisvar, void* low, void* high) {
-  struct pair allocp=rbfind(low,high,thisvar->alloctree);
-  if (allocp.low == NULL) {
-    return false;
-  } else if ((allocp.low > low) || (allocp.high < high)) { /* make sure this block is used */
-    return false;
-  } else {
-    return true;
-  }
-}
-
-
-bool typemapchecktype(struct typemap *thisvar, bool doaction,void *ptr, int structure) {
-  int ssize=sizeBytes(structure);
-  void *low=ptr;
-  void *high=((char *)low)+ssize;
-  struct pair allocp=rbfind(low,high,thisvar->alloctree);
-  if (allocp.low==NULL)
-    return false;
-  if (allocp.low>low||allocp.high<high) /* make sure this block is used */
-    return false;
-  {
-    struct pair typep=rbfind(low,high,thisvar->typetree);
-    struct structuremap *smap=(struct structuremap *)rblookup(low,high,thisvar->typetree);
-    if (typep.low==NULL) {
-      if(!doaction)
-        return true;
-      {
-        struct structuremap *sm=allocatestructuremap(structure);
-        int flag=rbinsert(low, high, sm, thisvar->typetree);
-        if (flag==0) {
-          printf("Error in asserttype\n");
-          return false;
-        } else
-          return true;
-      }
-    }
-    return typemapchecktypeB(thisvar, doaction, low,high, structure, thisvar->typetree);
-  }
-}
-
-bool typemapchecktypeB(struct typemap *thisvar, bool doaction, void *low, void *high, int structure, struct rbtree *ttree) {
-  struct pair typep=rbfind(low,high,ttree);
-  struct structuremap *smap=(struct structuremap *)rblookup(low,high,ttree);
-  if (typep.low==low&&typep.high==high) {
-    /* Recast */
-    if (issubtype(structure,smap->str)) {
-      /* narrowing cast */
-      if (!doaction)
-       return true;
-      smap->str=structure;
-      return true;
-    } else if (issubtype(smap->str,structure)) {
-      /* widening cast */
-      return true;
-    } else
-      return false; /* incompatible types */
-  } else if (typep.low<=low&&typep.high>=high) {
-    /* See if it matches up with structure inside typep */
-    if (rbsearch(low,high,smap->typetree)) {
-      /* recurse */
-      return typemapchecktypeB(thisvar,doaction,low,high, structure, smap->typetree);
-    } else {
-      /* check to see if data lines up correctly */
-      int offset=((char *)low)-((char *)typep.low);
-      int st=typemapfindoffsetstructure(thisvar, smap->str,offset);
-      if (st==-1)
-       return false;
-      if (issubtype(structure,st)) {
-       if (!doaction)
-         return true;
-        {
-          struct structuremap *newsm=allocatestructuremap(structure);
-          int flag=rbinsert(low, high, newsm, smap->typetree);
-          return (flag==1);
-        }
-      } else if (issubtype(st,structure)) {
-       if (!doaction)
-         return true;
-        {
-          struct structuremap *newsm=allocatestructuremap(st);
-          int flag=rbinsert(low, high, newsm, smap->typetree);
-          return (flag==1);
-        }
-      } else
-       return false;
-    }
-  } else
-    return false;
-}