diff options
author | Nick Ing-Simmons <nik@tiuk.ti.com> | 1997-11-29 18:38:26 +0000 |
---|---|---|
committer | Nick Ing-Simmons <nik@tiuk.ti.com> | 1997-11-29 18:38:26 +0000 |
commit | c53bd28a003b43d77a08bf70a3cb54001d1f4afe (patch) | |
tree | 1bd925f336ec621412af1c931a2f82707dba7281 | |
parent | 4c36ecb7bb90b0ff73777a2addf5e8968d98eec5 (diff) | |
download | perl-c53bd28a003b43d77a08bf70a3cb54001d1f4afe.tar.gz |
Avoid __declspec(thread) by default, for both scratch
return areas and THR stuff. Use struct thread intern instead.
p4raw-id: //depot/ansiperl@335
-rw-r--r-- | win32/win32.c | 9 | ||||
-rw-r--r-- | win32/win32.h | 17 | ||||
-rw-r--r-- | win32/win32sck.c | 13 | ||||
-rw-r--r-- | win32/win32thread.c | 18 | ||||
-rw-r--r-- | win32/win32thread.h | 1 |
5 files changed, 56 insertions, 2 deletions
diff --git a/win32/win32.c b/win32/win32.c index ba6086496b..c4b8c3bb7c 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 93b74efd3f..db87a6dca8 100644 --- a/win32/win32.h +++ b/win32/win32.h @@ -16,7 +16,6 @@ typedef long long __int64; #endif - #define WIN32_LEAN_AND_MEAN #include <windows.h> @@ -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 670bcf424d..64d1a0a65c 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 0dd3e77f47..d3783f6857 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 6f355f09eb..1a16c78b67 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 |