From: Artur Bergman Date: Fri, 12 Oct 2001 18:07:37 +0000 (+0000) Subject: Apperently OLD PTHREADS API is a bit retarded. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7f9a95ef4ccdf2b0ea72c8ae7e731ca9572edfac;p=p5sagit%2Fp5-mst-13.2.git Apperently OLD PTHREADS API is a bit retarded. This should fix another set of compile failures in HP-UX 10.20. p4raw-id: //depot/perl@12410 --- diff --git a/ext/threads/threads.h b/ext/threads/threads.h index d3e9c8a..01baaa4 100755 --- a/ext/threads/threads.h +++ b/ext/threads/threads.h @@ -9,8 +9,8 @@ #include #include #define PERL_THREAD_DETACH(t) -#define PERL_THREAD_SET_SPECIFIC(k,v) TlsSetValue(k,v) -#define PERL_THREAD_GET_SPECIFIC(k) TlsGetValue(k) +#define PERL_THREAD_SETSPECIFIC(k,v) TlsSetValue(k,v) +#define PERL_THREAD_GETSPECIFIC(k,v) v = TlsGetValue(k) #define PERL_THREAD_ALLOC_SPECIFIC(k) \ STMT_START {\ if((k = TlsAlloc()) == TLS_OUT_OF_INDEXES) {\ @@ -22,8 +22,7 @@ STMT_START {\ #include #include -#define PERL_THREAD_SET_SPECIFIC(k,v) pthread_setspecific(k,v) -#define PERL_THREAD_GET_SPECIFIC(k) pthread_getspecific(k) +#define PERL_THREAD_SETSPECIFIC(k,v) pthread_setspecific(k,v) #define PERL_THREAD_ALLOC_SPECIFIC(k) STMT_START {\ if(pthread_key_create(&(k),0)) {\ PerlIO_printf(PerlIO_stderr(), "panic threads.h: pthread_key_create");\ @@ -32,8 +31,10 @@ STMT_START {\ } STMT_END #ifdef OLD_PTHREADS_API #define PERL_THREAD_DETACH(t) pthread_detach(&(t)) +#define PERL_THREAD_GETSPECIFIC(k,v) pthread_getspecific(k,&v) #else #define PERL_THREAD_DETACH(t) pthread_detach((t)) +#define PERL_THREAD_GETSPECIFIC(k,v) v = pthread_getspecific(k) #endif #endif diff --git a/ext/threads/threads.xs b/ext/threads/threads.xs index 0d00c81..378127c 100755 --- a/ext/threads/threads.xs +++ b/ext/threads/threads.xs @@ -24,8 +24,8 @@ void* Perl_thread_run(void * arg) { SHAREDSvLOCK(threads); SHAREDSvEDIT(threads); PERL_THREAD_ALLOC_SPECIFIC(self_key); - PERL_THREAD_SET_SPECIFIC(self_key,INT2PTR(void*,thread->tid)); - thread_tid_ptr = Perl_newSVuv(PL_sharedsv_space, PTR2UV(PERL_THREAD_GET_SPECIFIC(self_key))); + PERL_THREAD_SETSPECIFIC(self_key,INT2PTR(void*,thread->tid)); + thread_tid_ptr = Perl_newSVuv(PL_sharedsv_space, thread->tid); thread_ptr = Perl_newSVuv(PL_sharedsv_space, PTR2UV(thread)); hv_store_ent((HV*)SHAREDSvGET(threads), thread_tid_ptr, thread_ptr,0); SvREFCNT_dec(thread_tid_ptr); @@ -189,11 +189,12 @@ SV* Perl_thread_self (char* class) { SV* thread_tid_ptr; SV* thread_ptr; HE* thread_entry; - + void* id; + PERL_THREAD_GETSPECIFIC(self_key,id); SHAREDSvLOCK(threads); SHAREDSvEDIT(threads); - - thread_tid_ptr = Perl_newSVuv(PL_sharedsv_space, PTR2UV(PERL_THREAD_GET_SPECIFIC(self_key))); + + thread_tid_ptr = Perl_newSVuv(PL_sharedsv_space, PTR2UV(id)); thread_entry = Perl_hv_fetch_ent(PL_sharedsv_space, (HV*) SHAREDSvGET(threads), @@ -285,8 +286,8 @@ BOOT: #endif SHAREDSvEDIT(threads); PERL_THREAD_ALLOC_SPECIFIC(self_key); - PERL_THREAD_SET_SPECIFIC(self_key,0); - thread_tid_ptr = Perl_newSVuv(PL_sharedsv_space, PTR2UV(PERL_THREAD_GET_SPECIFIC(self_key))); + PERL_THREAD_SETSPECIFIC(self_key,0); + thread_tid_ptr = Perl_newSVuv(PL_sharedsv_space, 0); thread_ptr = Perl_newSVuv(PL_sharedsv_space, PTR2UV(thread)); hv_store_ent((HV*) SHAREDSvGET(threads), thread_tid_ptr, thread_ptr,0); SvREFCNT_dec(thread_tid_ptr);