From: Nick Ing-Simmons Date: Sat, 15 Nov 1997 19:52:53 +0000 (+0000) Subject: Use __declspec(thread) var rather tha TslAlloc & co. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9811a7d768316e95d4f07bb4877adaf9834ec499;p=p5sagit%2Fp5-mst-13.2.git Use __declspec(thread) var rather tha TslAlloc & co. p4raw-id: //depot/ansiperl@257 --- diff --git a/win32/makedef.pl b/win32/makedef.pl index abc89d8..3ec9b82 100644 --- a/win32/makedef.pl +++ b/win32/makedef.pl @@ -402,4 +402,6 @@ win32_open_osfhandle win32_get_osfhandle Perl_win32_init Perl_init_os_extras +Perl_setTHR +Perl_getTHR RunPerl diff --git a/win32/win32thread.c b/win32/win32thread.c index 4dbc750..eefa92c 100644 --- a/win32/win32thread.c +++ b/win32/win32thread.c @@ -1,6 +1,20 @@ #include "EXTERN.h" #include "perl.h" +__declspec(thread) struct thread *current_thread; + +void +Perl_setTHR(struct thread *t) +{ + current_thread = t; +} + +struct thread * +Perl_getTHR(void) +{ + return current_thread; +} + void Perl_alloc_thread_key(void) { diff --git a/win32/win32thread.h b/win32/win32thread.h index 0c6bb55..6af548d 100644 --- a/win32/win32thread.h +++ b/win32/win32thread.h @@ -97,7 +97,8 @@ typedef HANDLE perl_mutex; } \ } STMT_END -#define THR ((struct thread *) TlsGetValue(thr_key)) + +#define THR Perl_getTHR() #define THREAD_CREATE(t, f) Perl_thread_create(t, f) #define THREAD_POST_CREATE(t) NOOP #define THREAD_RET_TYPE DWORD WINAPI @@ -109,6 +110,8 @@ START_EXTERN_C void Perl_alloc_thread_key _((void)); int Perl_thread_create _((struct thread *thr, thread_func_t *fn)); void Perl_set_thread_self _((struct thread *thr)); +struct thread *Perl_getTHR _((void)); +void Perl_setTHR _((struct thread *t)); END_EXTERN_C #define INIT_THREADS NOOP @@ -122,12 +125,7 @@ END_EXTERN_C croak("panic: JOIN"); \ } STMT_END -#define SET_THR(t) \ - STMT_START { \ - if (TlsSetValue(thr_key, (void *) (t)) == 0) \ - croak("panic: TlsSetValue"); \ - } STMT_END - +#define SET_THR(t) Perl_setTHR(t) #define YIELD Sleep(0) #endif /* _WIN32THREAD_H */