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)
{
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;
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;
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);
}
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 */
#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;
child_tab * children;
HANDLE child_handles[MAXIMUM_WAIT_OBJECTS];
struct host_link * hostlist;
+#ifndef USE_THREADS
+ struct thread_intern thr_intern;
+#endif
};
#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 */
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
#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 */
SOCKET_TEST(r = getservbyname(name, proto), NULL);
if (r) {
- r = win32_savecopyservent(&myservent, r, proto);
+ r = win32_savecopyservent(&w32_servent, r, proto);
}
return r;
}
SOCKET_TEST(r = getservbyport(port, proto), NULL);
if (r) {
- r = win32_savecopyservent(&myservent, r, proto);
+ r = win32_savecopyservent(&w32_servent, r, proto);
}
return r;
}