From: Nick Ing-Simmons Date: Sat, 29 Nov 1997 18:38:26 +0000 (+0000) Subject: Avoid __declspec(thread) by default, for both scratch X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c53bd28a003b43d77a08bf70a3cb54001d1f4afe;p=p5sagit%2Fp5-mst-13.2.git Avoid __declspec(thread) by default, for both scratch return areas and THR stuff. Use struct thread intern instead. p4raw-id: //depot/ansiperl@335 --- diff --git a/win32/win32.c b/win32/win32.c index ba60864..c4b8c3b 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -936,7 +936,15 @@ win32_feof(FILE *fp) * we have to roll our own. */ +#ifdef USE_THREADS +#ifdef USE_DECLSPEC_THREAD __declspec(thread) char strerror_buffer[512]; +#else +#define strerror_buffer (thr->i.Wstrerror_buffer) +#endif +#else +char strerror_buffer[512]; +#endif DllExport char * win32_strerror(int e) @@ -947,6 +955,7 @@ win32_strerror(int e) DWORD source = 0; if(e < 0 || e > sys_nerr) { + dTHR; if(e < 0) e = GetLastError(); diff --git a/win32/win32.h b/win32/win32.h index 93b74ef..db87a6d 100644 --- a/win32/win32.h +++ b/win32/win32.h @@ -16,7 +16,6 @@ typedef long long __int64; #endif - #define WIN32_LEAN_AND_MEAN #include @@ -178,4 +177,20 @@ EXT void win32_strip_return(struct sv *sv); #define win32_strip_return(sv) NOOP #endif +/* + * Now Win32 specific per-thread data stuff + */ + +#ifdef USE_THREADS +#ifndef USE_DECLSPEC_THREAD +#define HAVE_THREAD_INTERN + +struct thread_intern +{ + char Wstrerror_buffer[512]; + struct servent Wservent; +}; +#endif +#endif + #endif /* _INC_WIN32_PERL5 */ diff --git a/win32/win32sck.c b/win32/win32sck.c index 670bcf4..64d1a0a 100644 --- a/win32/win32sck.c +++ b/win32/win32sck.c @@ -57,7 +57,16 @@ static struct servent* win32_savecopyservent(struct servent*d, struct servent*s, const char *proto); +#ifdef USE_THREADS +#ifdef USE_DECLSPEC_THREAD __declspec(thread) struct servent myservent; +#else +#define myservent (thr->i.Wservent) +#endif +#else +static struct servent myservent; +#endif + static int wsock_started = 0; void @@ -435,7 +444,8 @@ struct servent * win32_getservbyname(const char *name, const char *proto) { struct servent *r; - + dTHR; + SOCKET_TEST(r = getservbyname(name, proto), NULL); if (r) { r = win32_savecopyservent(&myservent, r, proto); @@ -447,6 +457,7 @@ struct servent * win32_getservbyport(int port, const char *proto) { struct servent *r; + dTHR; SOCKET_TEST(r = getservbyport(port, proto), NULL); if (r) { diff --git a/win32/win32thread.c b/win32/win32thread.c index 0dd3e77..d3783f6 100644 --- a/win32/win32thread.c +++ b/win32/win32thread.c @@ -45,6 +45,24 @@ Perl_alloc_thread_key(void) } void +Perl_init_thread_intern(struct perl_thread *thr) +{ +#ifdef USE_THREADS +#ifndef USE_DECLSPEC_THREAD + + /* + * Initialize port-specific per-thread data in thr->i + * as only things we have there are just static areas for + * return values we don't _need_ to do anything but + * this is good practice: + */ + memset(&thr->i,0,sizeof(thr->i)); + +#endif +#endif +} + +void Perl_set_thread_self(struct perl_thread *thr) { #ifdef USE_THREADS diff --git a/win32/win32thread.h b/win32/win32thread.h index 6f355f0..1a16c78 100644 --- a/win32/win32thread.h +++ b/win32/win32thread.h @@ -123,6 +123,7 @@ int Perl_thread_create _((struct perl_thread *thr, thread_func_t *fn)); void Perl_set_thread_self _((struct perl_thread *thr)); struct perl_thread *Perl_getTHR _((void)); void Perl_setTHR _((struct perl_thread *t)); +void Perl_init_thread_intern _((struct perl_thread *t)); END_EXTERN_C