Apperently OLD PTHREADS API is a bit retarded.
Artur Bergman [Fri, 12 Oct 2001 18:07:37 +0000 (18:07 +0000)]
This should fix another set of compile failures in HP-UX 10.20.

p4raw-id: //depot/perl@12410

ext/threads/threads.h
ext/threads/threads.xs

index d3e9c8a..01baaa4 100755 (executable)
@@ -9,8 +9,8 @@
 #include <windows.h>
 #include <win32thread.h>
 #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 <pthread.h>
 #include <thread.h>
 
-#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
 
index 0d00c81..378127c 100755 (executable)
@@ -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);