Re: 5.8.3-RC1, ext/threads/shared/t/wait still hanging
[p5sagit/p5-mst-13.2.git] / ext / threads / threads.xs
index c65d3ce..48530fe 100755 (executable)
@@ -71,7 +71,7 @@ I32 active_threads = 0;
 
 void Perl_ithread_set (pTHX_ ithread* thread)
 {
-  SV* thread_sv = newSViv((IV)thread);
+  SV* thread_sv = newSViv(PTR2IV(thread));
   if(!hv_store(PL_modglobal, "threads::self", 12, thread_sv,0)) {
     croak("%s\n","Internal error, couldn't set TLS");
   }
@@ -82,7 +82,7 @@ ithread* Perl_ithread_get (pTHX) {
   if(!thread_sv) {
     croak("%s\n","Internal error, couldn't get TLS");
   }
-  return (ithread*)SvIV(*thread_sv);
+  return INT2PTR(ithread*,SvIV(*thread_sv));
 }
 
 
@@ -519,6 +519,7 @@ Perl_ithread_self (pTHX_ SV *obj, char* Class)
        return ithread_to_SV(aTHX_ obj, thread, Class, TRUE);
    else
        Perl_croak(aTHX_ "panic: cannot find thread data");
+   return NULL; /* silence compiler warning */
 }
 
 /*
@@ -571,12 +572,17 @@ Perl_ithread_join(pTHX_ SV *obj)
        {
          ithread*        current_thread;
          AV* params = (AV*) SvRV(thread->params);      
+         PerlInterpreter *other_perl = thread->interp;
          CLONE_PARAMS clone_params;
          clone_params.stashes = newAV();
          clone_params.flags |= CLONEf_JOIN_IN;
          PL_ptr_table = ptr_table_new();
          current_thread = Perl_ithread_get(aTHX);
          Perl_ithread_set(aTHX_ thread);
+         /* ensure 'meaningful' addresses retain their meaning */
+         ptr_table_store(PL_ptr_table, &other_perl->Isv_undef, &PL_sv_undef);
+         ptr_table_store(PL_ptr_table, &other_perl->Isv_no, &PL_sv_no);
+         ptr_table_store(PL_ptr_table, &other_perl->Isv_yes, &PL_sv_yes);
 
 #if 0
          {