X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=ext%2Fthreads%2Fthreads.xs;h=83f9e89dfec2bf93d7b0fa76380467e46bdfb3fd;hb=20b634c2cddd73f32cb58e435a5061f5c6e53570;hp=0110724ab47ac981eddc67d45e4643c011c899a5;hpb=3c42a367e53aec886fda59abee7d5b4b2e100590;p=p5sagit%2Fp5-mst-13.2.git diff --git a/ext/threads/threads.xs b/ext/threads/threads.xs index 0110724..83f9e89 100755 --- a/ext/threads/threads.xs +++ b/ext/threads/threads.xs @@ -350,13 +350,21 @@ ithread * SV_to_ithread(pTHX_ SV *sv) { ithread *thread; +#ifdef OEMVS + void *ptr; +#endif if (SvROK(sv)) { thread = INT2PTR(ithread*, SvIV(SvRV(sv))); } else { +#ifdef OEMVS + PERL_THREAD_GETSPECIFIC(self_key,ptr); + thread = (ithread *) ptr; +#else PERL_THREAD_GETSPECIFIC(self_key,thread); +#endif } return thread; } @@ -399,7 +407,10 @@ Perl_ithread_create(pTHX_ SV *obj, char* classname, SV* init_function, SV* param PerlIO_flush((PerlIO*)NULL); PERL_THREAD_SETSPECIFIC(self_key,thread); - + SAVEBOOL(PL_srand_called); /* Save this so it becomes the correct + value */ + PL_srand_called = FALSE; /* Set it to false so we can detect + if it gets set during the clone */ #ifdef WIN32 thread->interp = perl_clone(aTHX, CLONEf_KEEP_PTR_TABLE | CLONEf_CLONE_HOST); @@ -413,6 +424,7 @@ Perl_ithread_create(pTHX_ SV *obj, char* classname, SV* init_function, SV* param */ { dTHXa(thread->interp); + /* Here we remove END blocks since they should only run in the thread they are created */ @@ -494,6 +506,7 @@ Perl_ithread_create(pTHX_ SV *obj, char* classname, SV* init_function, SV* param #ifdef OLD_PTHREADS_API pthread_create( &thread->thr, attr, Perl_ithread_run, (void *)thread); #else + pthread_attr_setscope( &attr, PTHREAD_SCOPE_SYSTEM ); pthread_create( &thread->thr, &attr, Perl_ithread_run, (void *)thread); #endif } @@ -510,7 +523,13 @@ SV* Perl_ithread_self (pTHX_ SV *obj, char* Class) { ithread *thread; +#ifdef OEMVS + void *ptr; + PERL_THREAD_GETSPECIFIC(self_key,ptr); + thread = (ithread *) ptr; +#else PERL_THREAD_GETSPECIFIC(self_key,thread); +#endif return ithread_to_SV(aTHX_ obj, thread, Class, TRUE); } @@ -600,7 +619,7 @@ Perl_ithread_join(pTHX_ SV *obj) /* We have finished with it */ thread->state |= PERL_ITHR_JOINED; MUTEX_UNLOCK(&thread->mutex); - sv_unmagic(SvRV(obj),PERL_MAGIC_shared_scalar); + return retparam; } return (AV*)NULL;