+#ifdef STM
+ newobjs=calloc(1, sizeof(struct objlist));
+ t_cache = objstrCreate(1048576);
+ t_reserve=NULL;
+ t_chashCreate(CHASH_SIZE, CLOADFACTOR);
+#ifdef READSET
+ rd_t_chashCreate(CHASH_SIZE, CLOADFACTOR);
+#endif
+#ifdef DELAYCOMP
+ dc_t_chashCreate(CHASH_SIZE, CLOADFACTOR);
+ ptrstack.count=0;
+ primstack.count=0;
+ branchstack.count=0;
+#ifdef STMARRAY
+ arraystack.count=0;
+#endif
+ int a=mprotect((downpage(&ptrstack.buffer[1024])), 4096, PROT_NONE);
+ if (a==-1)
+ perror("ptrstack");
+ a=mprotect(downpage(&primstack.array[MAXVALUES]), 4096, PROT_NONE);
+ if (a==-1)
+ perror("primstack");
+ a=mprotect(downpage(&branchstack.array[MAXBRANCHES]), 4096, PROT_NONE);
+ if (a==-1)
+ perror("branchstack");
+#ifdef STMARRAY
+ a=mprotect(downpage(&arraystack.index[MAXARRAY]), 4096, PROT_NONE);
+ if (a==-1)
+ perror("arraystack");
+#endif
+#endif
+#ifdef STMSTATS
+ trec=calloc(1, sizeof(threadrec_t));
+ trec->blocked = 0;
+ lockedobjs=calloc(1, sizeof(struct objlist));
+ objlockscope = calloc(1, sizeof(objlockstate_t));
+ pthread_mutex_init(&lockedobjstore, NULL);
+ {
+ int i;
+ for(i=0; i<TOTALNUMCLASSANDARRAY; i++) {
+ typesCausingAbort[i].numaccess = 0;
+ typesCausingAbort[i].numabort = 0;
+ typesCausingAbort[i].numtrans = 0;
+ }
+ }
+#endif
+#endif
+#ifdef MAC
+ struct listitem *litem=malloc(sizeof(struct listitem));
+ pthread_setspecific(litemkey, litem);
+ litem->prev=NULL;
+ litem->next=list;
+ if(list!=NULL)
+ list->prev=litem;
+ list=litem;
+#else
+ //Add our litem to list of threads
+ litem.prev=NULL;
+ litem.next=list;
+ if(list!=NULL)
+ list->prev=&litem;
+ list=&litem;
+#endif