changes
authorbdemsky <bdemsky>
Fri, 9 Oct 2009 10:40:14 +0000 (10:40 +0000)
committerbdemsky <bdemsky>
Fri, 9 Oct 2009 10:40:14 +0000 (10:40 +0000)
Robust/src/Runtime/STM/objstr.c [new file with mode: 0644]
Robust/src/Runtime/STM/stm.c

diff --git a/Robust/src/Runtime/STM/objstr.c b/Robust/src/Runtime/STM/objstr.c
new file mode 100644 (file)
index 0000000..fd32b0d
--- /dev/null
@@ -0,0 +1,90 @@
+#include"tm.h"
+
+/* ======================================
+ * objstrCreate
+ * - create an object store of given size
+ * ======================================
+ */
+objstr_t *objstrCreate(unsigned int size) {
+  objstr_t *tmp;
+  if((tmp = calloc(1, (sizeof(objstr_t) + size))) == NULL) {
+    printf("%s() Calloc error at line %d, %s\n", __func__, __LINE__, __FILE__);
+    return NULL;
+  }
+  tmp->size = size;
+  tmp->next = NULL;
+  tmp->top = tmp + 1; //points to end of objstr_t structure!
+  return tmp;
+}
+
+void objstrReset() {
+  while(t_cache->next!=NULL) {
+    objstr_t *next=t_cache->next;
+    t_cache->next=t_reserve;
+    t_reserve=t_cache;
+    t_cache=next;
+  }
+  t_cache->top=t_cache+1;
+#ifdef STMSTATS
+  t_objnumcount=0;
+#endif
+}
+
+//free entire list, starting at store
+void objstrDelete(objstr_t *store) {
+  objstr_t *tmp;
+  while (store != NULL) {
+    tmp = store->next;
+    free(store);
+    store = tmp;
+  }
+  return;
+}
+
+/* ==============================================
+ * objstrAlloc
+ * - allocate space in an object store
+ * ==============================================
+ */
+void *objstrAlloc(unsigned int size) {
+  void *tmp;
+  int i=0;
+  objstr_t *store=t_cache;
+  if ((size&7)!=0) {
+    size+=(8-(size&7));
+  }
+
+  for(; i<2; i++) {
+    if (OSFREE(store)>=size) {
+      tmp=store->top;
+      store->top +=size;
+      return tmp;
+    }
+    if ((store=store->next)==NULL)
+      break;
+  }
+
+  {
+    unsigned int newsize=size>DEFAULT_OBJ_STORE_SIZE ? size : DEFAULT_OBJ_STORE_SIZE;
+    objstr_t **otmp=&t_reserve;
+    objstr_t *ptr;
+    while((ptr=*otmp)!=NULL) {
+      if (ptr->size>=newsize) {
+       //remove from list
+       *otmp=ptr->next;
+       ptr->next=t_cache;
+       t_cache=ptr;
+       ptr->top=((char *)(&ptr[1]))+size;
+       return &ptr[1];
+      }
+    }
+
+    objstr_t *os=(objstr_t *)calloc(1,(sizeof(objstr_t) + newsize));
+    void *nptr=&os[1];
+    os->next=t_cache;
+    t_cache=os;
+    os->size=newsize;
+    os->top=((char *)nptr)+size;
+    return nptr;
+  }
+}
index 57c97d6b2fdb080e5c65c2506070aa9a3c87b414..5632b83afaa5be5e2b7a501a917e511a8bf3ebf7 100644 (file)
@@ -156,47 +156,6 @@ int stmStartup() {
   return 0;
 }
 
-/* ======================================
- * objstrCreate
- * - create an object store of given size
- * ======================================
- */
-objstr_t *objstrCreate(unsigned int size) {
-  objstr_t *tmp;
-  if((tmp = calloc(1, (sizeof(objstr_t) + size))) == NULL) {
-    printf("%s() Calloc error at line %d, %s\n", __func__, __LINE__, __FILE__);
-    return NULL;
-  }
-  tmp->size = size;
-  tmp->next = NULL;
-  tmp->top = tmp + 1; //points to end of objstr_t structure!
-  return tmp;
-}
-
-void objstrReset() {
-  while(t_cache->next!=NULL) {
-    objstr_t *next=t_cache->next;
-    t_cache->next=t_reserve;
-    t_reserve=t_cache;
-    t_cache=next;
-  }
-  t_cache->top=t_cache+1;
-#ifdef STMSTATS
-  t_objnumcount=0;
-#endif
-}
-
-//free entire list, starting at store
-void objstrDelete(objstr_t *store) {
-  objstr_t *tmp;
-  while (store != NULL) {
-    tmp = store->next;
-    free(store);
-    store = tmp;
-  }
-  return;
-}
-
 /* =================================================
  * transStart
  * This function initializes things required in the
@@ -251,55 +210,6 @@ void randomdelay(int softaborted) {
   return;
 }
 
-/* ==============================================
- * objstrAlloc
- * - allocate space in an object store
- * ==============================================
- */
-void *objstrAlloc(unsigned int size) {
-  void *tmp;
-  int i=0;
-  objstr_t *store=t_cache;
-  if ((size&7)!=0) {
-    size+=(8-(size&7));
-  }
-
-  for(; i<2; i++) {
-    if (OSFREE(store)>=size) {
-      tmp=store->top;
-      store->top +=size;
-      return tmp;
-    }
-    if ((store=store->next)==NULL)
-      break;
-  }
-
-  {
-    unsigned int newsize=size>DEFAULT_OBJ_STORE_SIZE ? size : DEFAULT_OBJ_STORE_SIZE;
-    objstr_t **otmp=&t_reserve;
-    objstr_t *ptr;
-    while((ptr=*otmp)!=NULL) {
-      if (ptr->size>=newsize) {
-       //remove from list
-       *otmp=ptr->next;
-       ptr->next=t_cache;
-       t_cache=ptr;
-       ptr->top=((char *)(&ptr[1]))+size;
-       return &ptr[1];
-      }
-    }
-
-    objstr_t *os=(objstr_t *)calloc(1,(sizeof(objstr_t) + newsize));
-    void *nptr=&os[1];
-    os->next=t_cache;
-    t_cache=os;
-    os->size=newsize;
-    os->top=((char *)nptr)+size;
-    return nptr;
-  }
-}
-
-
 /* =============================================================
  * transRead
  * -finds the objects either in main heap