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);
58 sig.sa_sigaction=&threadhandler;
59 sig.sa_flags=SA_SIGINFO;
60 sigemptyset(&sig.sa_mask);
62 /* Catch bus errors, segmentation faults, and floating point exceptions*/
63 sigaction(SIGBUS,&sig,0);
64 sigaction(SIGSEGV,&sig,0);
65 sigaction(SIGFPE,&sig,0);
68 void initthread(struct ___Thread___ * ___this___) {
70 struct ___Thread______staticStart____L___Thread____params p={1, NULL, ___this___};
71 ___Thread______staticStart____L___Thread___(&p);
73 ___Thread______staticStart____L___Thread___(___this___);
75 pthread_mutex_lock(&gclistlock);
77 pthread_cond_signal(&gccond);
78 pthread_mutex_unlock(&gclistlock);
81 void CALL01(___Thread______nativeCreate____, struct ___Thread___ * ___this___) {
86 pthread_mutex_lock(&gclistlock);
88 pthread_mutex_unlock(&gclistlock);
89 pthread_attr_init(&nattr);
90 pthread_attr_setdetachstate(&nattr, PTHREAD_CREATE_DETACHED);
93 retval=pthread_create(&thread, &nattr, (void * (*)(void *)) &initthread, VAR(___this___));
98 pthread_attr_destroy(&nattr);