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;
21 struct ___Object___ *ll=pthread_getspecific(threadlocks);
23 struct ___Object___ *llnext=ll->___nextlockobject___;
24 ll->___nextlockobject___=NULL;
25 ll->___prevlockobject___=NULL;
27 ll->tid=0; //unlock it
30 pthread_mutex_lock(&objlock);//wake everyone up
31 pthread_cond_broadcast(&objcond);
32 pthread_mutex_unlock(&objlock);
34 pthread_mutex_lock(&gclistlock);
36 pthread_cond_signal(&gccond);
37 pthread_mutex_unlock(&gclistlock);
41 void threadhandler(int sig, siginfo_t *info, void *uap) {
43 printf("sig=%d\n",sig);
49 void initializethreads() {
52 pthread_mutex_init(&gclock, NULL);
53 pthread_mutex_init(&gclistlock, NULL);
54 pthread_cond_init(&gccond, NULL);
55 pthread_mutex_init(&objlock,NULL);
56 pthread_cond_init(&objcond,NULL);
57 pthread_key_create(&threadlocks, NULL);
59 initializeexithandler();
61 sig.sa_sigaction=&threadhandler;
62 sig.sa_flags=SA_SIGINFO;
63 sigemptyset(&sig.sa_mask);
65 /* Catch bus errors, segmentation faults, and floating point exceptions*/
66 sigaction(SIGBUS,&sig,0);
67 sigaction(SIGSEGV,&sig,0);
68 sigaction(SIGFPE,&sig,0);
72 void initthread(struct ___Thread___ * ___this___) {
74 struct ___Thread______staticStart____L___Thread____params p={1, NULL, ___this___};
75 ___Thread______staticStart____L___Thread___(&p);
77 ___Thread______staticStart____L___Thread___(___this___);
79 pthread_mutex_lock(&gclistlock);
81 pthread_cond_signal(&gccond);
82 pthread_mutex_unlock(&gclistlock);
86 void CALL11(___Thread______sleep____J, long long ___millis___, long long ___millis___) {
89 struct listitem *tmp=stopforgc((struct garbagelist *)___params___);
101 void CALL01(___Thread______nativeCreate____, struct ___Thread___ * ___this___) {
104 pthread_attr_t nattr;
106 pthread_mutex_lock(&gclistlock);
108 pthread_mutex_unlock(&gclistlock);
109 pthread_attr_init(&nattr);
110 pthread_attr_setdetachstate(&nattr, PTHREAD_CREATE_DETACHED);
113 retval=pthread_create(&thread, &nattr, (void * (*)(void *)) &initthread, VAR(___this___));
118 pthread_attr_destroy(&nattr);