perldelta update, typos and whitespace adjustments
[p5sagit/p5-mst-13.2.git] / win32 / perllib.c
index 84a2a6d..6211ba7 100644 (file)
@@ -160,7 +160,7 @@ perl_construct(PerlInterpreter* my_perl)
        CPerlHost* pHost = (CPerlHost*)w32_internal_host;
        Perl_free();
        delete pHost;
-       SetPerlInterpreter(NULL);
+       PERL_SET_THX(NULL);
     }
 }
 
@@ -200,7 +200,7 @@ perl_free(PerlInterpreter* my_perl)
     {
     }
 #endif
-    SetPerlInterpreter(NULL);
+    PERL_SET_THX(NULL);
 }
 
 EXTERN_C int
@@ -254,26 +254,11 @@ perl_parse(PerlInterpreter* my_perl, void (*xsinit)(CPerlObj*), int argc, char**
 
 EXTERN_C HANDLE w32_perldll_handle;
 
-static DWORD g_TlsAllocIndex;
-
-EXTERN_C DllExport bool
-SetPerlInterpreter(void *interp)
-{
-    return TlsSetValue(g_TlsAllocIndex, interp);
-}
-
-EXTERN_C DllExport void*
-GetPerlInterpreter(void)
-{
-    return TlsGetValue(g_TlsAllocIndex);
-}
-
 EXTERN_C DllExport int
 RunPerl(int argc, char **argv, char **env)
 {
     int exitstatus;
     PerlInterpreter *my_perl, *new_perl = NULL;
-    struct perl_thread *thr;
 
 #ifndef __BORLANDC__
     /* XXX this _may_ be a problem on some compilers (e.g. Borland) that
@@ -303,7 +288,7 @@ RunPerl(int argc, char **argv, char **env)
 
     if (!(my_perl = perl_alloc()))
        return (1);
-    perl_construct( my_perl );
+    perl_construct(my_perl);
     PL_perl_destruct_level = 0;
 
     exitstatus = perl_parse(my_perl, xs_init, argc, argv, env);
@@ -326,18 +311,18 @@ RunPerl(int argc, char **argv, char **env)
 #  else
        new_perl = perl_clone(my_perl, 1);
 #  endif
-       exitstatus = perl_run( new_perl );
-       SetPerlInterpreter(my_perl);
+       exitstatus = perl_run(new_perl);
+       PERL_SET_THX(my_perl);
 #else
-       exitstatus = perl_run( my_perl );
+       exitstatus = perl_run(my_perl);
 #endif
     }
 
-    perl_destruct( my_perl );
-    perl_free( my_perl );
+    perl_destruct(my_perl);
+    perl_free(my_perl);
 #ifdef USE_ITHREADS
     if (new_perl) {
-       SetPerlInterpreter(new_perl);
+       PERL_SET_THX(new_perl);
        perl_destruct(new_perl);
        perl_free(new_perl);
     }
@@ -348,6 +333,12 @@ RunPerl(int argc, char **argv, char **env)
     return (exitstatus);
 }
 
+EXTERN_C void
+set_w32_module_name(void);
+
+#ifdef __MINGW32__
+EXTERN_C               /* GCC in C++ mode mangles the name, otherwise */
+#endif
 BOOL APIENTRY
 DllMain(HANDLE hModule,                /* DLL module handle */
        DWORD fdwReason,        /* reason called */
@@ -365,16 +356,15 @@ DllMain(HANDLE hModule,           /* DLL module handle */
        setmode( fileno( stderr ), O_BINARY );
        _fmode = O_BINARY;
 #endif
-       g_TlsAllocIndex = TlsAlloc();
        DisableThreadLibraryCalls((HMODULE)hModule);
        w32_perldll_handle = hModule;
+       set_w32_module_name();
        break;
 
        /* The DLL is detaching from a process due to
         * process termination or call to FreeLibrary.
         */
     case DLL_PROCESS_DETACH:
-       TlsFree(g_TlsAllocIndex);
        break;
 
        /* The attached process creates a new thread. */