12 pthread_mutex_t gclock;
13 pthread_mutex_t gclistlock;
14 pthread_cond_t gccond;
15 pthread_mutex_t objlock;
16 pthread_cond_t objcond;
17 pthread_key_t threadlocks;
20 struct ___Object___ *ll=pthread_getspecific(threadlocks);
22 struct ___Object___ *llnext=ll->___nextlockobject___;
23 ll->___nextlockobject___=NULL;
24 ll->___prevlockobject___=NULL;
26 ll->tid=0; //unlock it
29 pthread_mutex_lock(&objlock);//wake everyone up
30 pthread_cond_broadcast(&objcond);
31 pthread_mutex_unlock(&objlock);
32 pthread_mutex_lock(&gclistlock);
34 pthread_cond_signal(&gccond);
35 pthread_mutex_unlock(&gclistlock);
39 void threadhandler(int sig, siginfo_t *info, void *uap) {
41 printf("sig=%d\n",sig);
47 void initializethreads() {
50 pthread_mutex_init(&gclock, NULL);
51 pthread_mutex_init(&gclistlock, NULL);
52 pthread_cond_init(&gccond, NULL);
53 pthread_mutex_init(&objlock,NULL);
54 pthread_cond_init(&objcond,NULL);
55 pthread_key_create(&threadlocks, NULL);
57 initializeexithandler();
59 sig.sa_sigaction=&threadhandler;
60 sig.sa_flags=SA_SIGINFO;
61 sigemptyset(&sig.sa_mask);
63 /* Catch bus errors, segmentation faults, and floating point exceptions*/
64 sigaction(SIGBUS,&sig,0);
65 sigaction(SIGSEGV,&sig,0);
66 sigaction(SIGFPE,&sig,0);
69 void initthread(struct ___Thread___ * ___this___) {
71 struct ___Thread______staticStart____L___Thread____params p={1, NULL, ___this___};
72 ___Thread______staticStart____L___Thread___(&p);
74 ___Thread______staticStart____L___Thread___(___this___);
76 pthread_mutex_lock(&gclistlock);
78 pthread_cond_signal(&gccond);
79 pthread_mutex_unlock(&gclistlock);
82 void CALL11(___Thread______sleep____J, long long ___millis___, long long ___millis___) {
85 struct listitem *tmp=stopforgc((struct garbagelist *)___params___);
96 void CALL01(___Thread______nativeCreate____, struct ___Thread___ * ___this___) {
101 pthread_mutex_lock(&gclistlock);
103 pthread_mutex_unlock(&gclistlock);
104 pthread_attr_init(&nattr);
105 pthread_attr_setdetachstate(&nattr, PTHREAD_CREATE_DETACHED);
108 retval=pthread_create(&thread, &nattr, (void * (*)(void *)) &initthread, VAR(___this___));
113 pthread_attr_destroy(&nattr);