#endif
#if defined(STM)||defined(THREADS)||defined(MLP)
+#ifndef MAC
__thread char * memorybase=NULL;
__thread char * memorytop=NULL;
#endif
+#endif
void collect(struct garbagelist * stackptr) {
}
#endif
#if defined(STM)||defined(THREADS)||defined(MLP)
+#ifdef MAC
+ *((char **)pthread_getspecific(memorybasekey))=NULL;
+#else
memorybase=NULL;
+#endif
#endif
/* Check current stack */
#ifndef MAC
litem.stackptr=ptr;
#if defined(STM)||defined(THREADS)||defined(MLP)
+#ifdef MAC
+ litem.base=pthread_getspecific(memorybasekey);
+#else
litem.base=&memorybase;
#endif
+#endif
#ifdef STM
litem.tc_size=c_size;
litem.tc_table=&c_table;
void * mygcmalloc(struct garbagelist * stackptr, int size) {
if ((size&7)!=0)
size=(size&~7)+8;
+#ifdef MAC
+ char * memorybase=*(char **)pthread_getspecific(memorybasekey);
+ char * memorytop=*(char **)pthread_getspecific(memorytopkey);
+#endif
if (memorybase==NULL||size>(memorytop-memorybase)) {
int toallocate=(size>MEMORYBLOCK)?size:MEMORYBLOCK;
memorybase=helper(stackptr, toallocate);
#ifndef MAC
extern __thread struct listitem litem;
#else
+pthread_key_t memorybasekey;
+pthread_key_t memorytopkey;
pthread_key_t litemkey;
#endif
extern struct listitem * list;
pthread_exit(NULL);
}
+#ifdef MAC
+void threadhandler(int sig) {
+ printf("We just took sig=%d\n",sig);
+ printf("signal\n");
+ printf("To get stack trace, set breakpoint in threadhandler in gdb\n");
+
+ threadexit();
+}
+#else
void threadhandler(int sig, struct sigcontext ctx) {
void *buffer[100];
char **strings;
threadexit();
}
+#endif
#define downpage(x) ((void *)(((INTPTR)x)&~((INTPTR)4095)))
#ifdef MAC
pthread_key_create(&macthreadid, NULL);
pthread_key_create(&threadlocks, NULL);
- pthread_key_create(&litem, NULL);
+ pthread_key_create(&memorybasekey, NULL);
+ pthread_key_create(&memorytopkey, NULL);
#endif
processOptions();
initializeexithandler();
#ifdef MAC
struct listitem *litem=malloc(sizeof(struct listitem));
struct lockvector *lvector=malloc(sizeof(struct lockvector));
- litem->lockvector=lvector;
+ litem->lvector=lvector;
lvector->index=0;
pthread_setspecific(threadlocks, lvector);
- pthread_setspecific(macthreadid, 0);
+ pthread_setspecific(macthreadid, (void *)0);
pthread_setspecific(litemkey, litem);
+ char ** memorybase=malloc(sizeof(char *));
+ *memorybase=NULL;
+ pthread_setspecific(memorybasekey, memorybase);
+ char ** memorytop=malloc(sizeof(char *));
+ *memorytop=NULL;
+ pthread_setspecific(memorytopkey, memorytop);
+
litem->prev=NULL;
litem->next=list;
if(list!=NULL)
//Add our litem to list of threads
#ifdef MAC
struct listitem litem;
- pthread_setspecific(litemkey, &litem);
struct lockvector lvector;
+ char * memorybase=NULL;
+ char * memorytop=NULL;
+ pthread_setspecific(litemkey, &litem);
+ pthread_setspecific(memorybasekey, &memorybase);
+ pthread_setspecific(memorytopkey, &memorytop);
pthread_setspecific(threadlocks, &lvector);
#endif
litem.lvector=&lvector;
litem.prev=NULL;
pthread_mutex_lock(&gclistlock);
#ifdef MAC
- pthread_setspecific(macthreadid, ++threadcounter);
+ pthread_setspecific(macthreadid, (void *)((long)(++threadcounter)));
#else
mythreadid=++threadcounter;
#endif