From: Gurusamy Sarathy Date: Mon, 8 Nov 1999 07:16:10 +0000 (+0000) Subject: win32 internal data must be interpreter-local X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3352bfcb1116ab429a5d6310d2803aabbed4237e;p=p5sagit%2Fp5-mst-13.2.git win32 internal data must be interpreter-local p4raw-id: //depot/perl@4536 --- diff --git a/win32/win32.c b/win32/win32.c index 3f56f60..cf341cd 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -100,29 +100,6 @@ HANDLE w32_perldll_handle = INVALID_HANDLE_VALUE; char w32_module_name[MAX_PATH+1]; static DWORD w32_platform = (DWORD)-1; -#ifdef USE_THREADS -# ifdef USE_DECLSPEC_THREAD -__declspec(thread) char strerror_buffer[512]; -__declspec(thread) char getlogin_buffer[128]; -__declspec(thread) char w32_perllib_root[MAX_PATH+1]; -# ifdef HAVE_DES_FCRYPT -__declspec(thread) char crypt_buffer[30]; -# endif -# else -# define strerror_buffer (thr->i.Wstrerror_buffer) -# define getlogin_buffer (thr->i.Wgetlogin_buffer) -# define w32_perllib_root (thr->i.Ww32_perllib_root) -# define crypt_buffer (thr->i.Wcrypt_buffer) -# endif -#else -static char strerror_buffer[512]; -static char getlogin_buffer[128]; -static char w32_perllib_root[MAX_PATH+1]; -# ifdef HAVE_DES_FCRYPT -static char crypt_buffer[30]; -# endif -#endif - int IsWin95(void) { @@ -916,8 +893,8 @@ char * getlogin(void) { dTHXo; - char *buf = getlogin_buffer; - DWORD size = sizeof(getlogin_buffer); + char *buf = w32_getlogin_buffer; + DWORD size = sizeof(w32_getlogin_buffer); if (GetUserName(buf,&size)) return buf; return (char*)NULL; @@ -1582,7 +1559,7 @@ win32_crypt(const char *txt, const char *salt) dTHXo; #ifdef HAVE_DES_FCRYPT dTHR; - return des_fcrypt(txt, salt, crypt_buffer); + return des_fcrypt(txt, salt, w32_crypt_buffer); #else die("The crypt() function is unimplemented due to excessive paranoia."); return Nullch; @@ -1808,10 +1785,11 @@ win32_strerror(int e) e = GetLastError(); if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, &source, e, 0, - strerror_buffer, sizeof(strerror_buffer), NULL) == 0) - strcpy(strerror_buffer, "Unknown Error"); + w32_strerror_buffer, + sizeof(w32_strerror_buffer), NULL) == 0) + strcpy(w32_strerror_buffer, "Unknown Error"); - return strerror_buffer; + return w32_strerror_buffer; } return strerror(e); } @@ -2971,8 +2949,8 @@ static XS(w32_LoginName) { dXSARGS; - char *name = getlogin_buffer; - DWORD size = sizeof(getlogin_buffer); + char *name = w32_getlogin_buffer; + DWORD size = sizeof(w32_getlogin_buffer); EXTEND(SP,1); if (GetUserName(name,&size)) { /* size includes NULL */ diff --git a/win32/win32.h b/win32/win32.h index 766f488..9eaf76a 100644 --- a/win32/win32.h +++ b/win32/win32.h @@ -348,6 +348,32 @@ EXT void win32_strip_return(struct sv *sv); #define win32_strip_return(sv) NOOP #endif +/* + * Now Win32 specific per-thread data stuff + */ + +struct thread_intern { + /* XXX can probably use one buffer instead of several */ + char Wstrerror_buffer[512]; + struct servent Wservent; + char Wgetlogin_buffer[128]; +# ifdef USE_SOCKETS_AS_HANDLES + int Winit_socktype; +# endif +# ifdef HAVE_DES_FCRYPT + char Wcrypt_buffer[30]; +# endif +# ifdef USE_RTL_THREAD_API + void * retv; /* slot for thread return value */ +# endif +}; + +#ifdef USE_THREADS +# ifndef USE_DECLSPEC_THREAD +# define HAVE_THREAD_INTERN +# endif /* !USE_DECLSPEC_THREAD */ +#endif /* USE_THREADS */ + #define HAVE_INTERP_INTERN typedef struct { long num; @@ -368,6 +394,9 @@ struct interp_intern { child_tab * children; HANDLE child_handles[MAXIMUM_WAIT_OBJECTS]; struct host_link * hostlist; +#ifndef USE_THREADS + struct thread_intern thr_intern; +#endif }; @@ -380,32 +409,18 @@ struct interp_intern { #define w32_child_pids (w32_children->pids) #define w32_child_handles (PL_sys_intern.child_handles) #define w32_host_link (PL_sys_intern.hostlist) - -/* - * Now Win32 specific per-thread data stuff - */ - #ifdef USE_THREADS -# ifndef USE_DECLSPEC_THREAD -# define HAVE_THREAD_INTERN - -struct thread_intern { - /* XXX can probably use one buffer instead of several */ - char Wstrerror_buffer[512]; - struct servent Wservent; - char Wgetlogin_buffer[128]; - char Ww32_perllib_root[MAX_PATH+1]; -# ifdef USE_SOCKETS_AS_HANDLES - int Winit_socktype; -# endif -# ifdef HAVE_DES_FCRYPT - char Wcrypt_buffer[30]; -# endif -# ifdef USE_RTL_THREAD_API - void * retv; /* slot for thread return value */ -# endif -}; -# endif /* !USE_DECLSPEC_THREAD */ +# define w32_strerror_buffer (thr->i.Wstrerror_buffer) +# define w32_getlogin_buffer (thr->i.Wgetlogin_buffer) +# define w32_crypt_buffer (thr->i.Wcrypt_buffer) +# define w32_servent (thr->i.Wservent) +# define w32_init_socktype (thr->i.Winit_socktype) +#else +# define w32_strerror_buffer (PL_sys_intern.thr_intern.Wstrerror_buffer) +# define w32_getlogin_buffer (PL_sys_intern.thr_intern.Wgetlogin_buffer) +# define w32_crypt_buffer (PL_sys_intern.thr_intern.Wcrypt_buffer) +# define w32_servent (PL_sys_intern.thr_intern.Wservent) +# define w32_init_socktype (PL_sys_intern.thr_intern.Winit_socktype) #endif /* USE_THREADS */ /* UNICODE<>ANSI translation helpers */ diff --git a/win32/win32sck.c b/win32/win32sck.c index 49d38f3..93d501e 100644 --- a/win32/win32sck.c +++ b/win32/win32sck.c @@ -75,18 +75,6 @@ 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; -__declspec(thread) int init_socktype; -#else -#define myservent (thr->i.Wservent) -#define init_socktype (thr->i.Winit_socktype) -#endif -#else -static struct servent myservent; -#endif - static int wsock_started = 0; void @@ -117,16 +105,16 @@ set_socktype(void) #ifdef USE_SOCKETS_AS_HANDLES #ifdef USE_THREADS dTHX; - if(!init_socktype) { + if (!w32_init_socktype) { #endif - int iSockOpt = SO_SYNCHRONOUS_NONALERT; - /* - * Enable the use of sockets as filehandles - */ - setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, - (char *)&iSockOpt, sizeof(iSockOpt)); + int iSockOpt = SO_SYNCHRONOUS_NONALERT; + /* + * Enable the use of sockets as filehandles + */ + setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, + (char *)&iSockOpt, sizeof(iSockOpt)); #ifdef USE_THREADS - init_socktype = 1; + w32_init_socktype = 1; } #endif #endif /* USE_SOCKETS_AS_HANDLES */ @@ -500,7 +488,7 @@ win32_getservbyname(const char *name, const char *proto) SOCKET_TEST(r = getservbyname(name, proto), NULL); if (r) { - r = win32_savecopyservent(&myservent, r, proto); + r = win32_savecopyservent(&w32_servent, r, proto); } return r; } @@ -513,7 +501,7 @@ win32_getservbyport(int port, const char *proto) SOCKET_TEST(r = getservbyport(port, proto), NULL); if (r) { - r = win32_savecopyservent(&myservent, r, proto); + r = win32_savecopyservent(&w32_servent, r, proto); } return r; }