#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) {\
#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");\
} 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
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);
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),
#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);